mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +01:00
std/jpeg: call slice.bulk_memset
This commit is contained in:
1 parent
5edfe45e15
commit
2f18dc61d0
8 files changed
+160
-91
No files matched your search
@@ -838,6 +838,33 @@ func (n *TypeExpr) Pointee() *TypeExpr {
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *TypeExpr) BulkSize() *big.Int {
|
||||
if !n.IsBulkNumType() {
|
||||
return nil
|
||||
}
|
||||
ret := big.NewInt(1)
|
||||
for ; n.id0 == t.IDArray; n = n.rhs.AsTypeExpr() {
|
||||
ret = ret.Mul(ret, n.ArrayLength().ConstValue())
|
||||
}
|
||||
switch n.id2 {
|
||||
case t.IDU8:
|
||||
return ret
|
||||
case t.IDU16:
|
||||
return ret.Lsh(ret, 1)
|
||||
case t.IDU32:
|
||||
return ret.Lsh(ret, 2)
|
||||
case t.IDU64:
|
||||
return ret.Lsh(ret, 3)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *TypeExpr) IsBulkNumType() bool {
|
||||
for ; n.id0 == t.IDArray; n = n.rhs.AsTypeExpr() {
|
||||
}
|
||||
return n.id0 == 0 && n.id1 == t.IDBase && n.id2.IsNumType()
|
||||
}
|
||||
|
||||
func (n *TypeExpr) IsBool() bool {
|
||||
return n.id0 == 0 && n.id1 == t.IDBase && n.id2 == t.IDBool
|
||||
}
|
||||
@@ -914,6 +941,10 @@ func (n *TypeExpr) IsReadOnly() bool {
|
||||
return (n.id0 == t.IDRoarray) || (n.id0 == t.IDRoslice) || (n.id0 == t.IDRotable)
|
||||
}
|
||||
|
||||
func (n *TypeExpr) IsContainerOfSpecificNumType(container t.ID, numType t.ID) bool {
|
||||
return (n.id0 == container) && n.Inner().IsNumType() && (n.Inner().id2 == numType)
|
||||
}
|
||||
|
||||
func (n *TypeExpr) IsUnsignedInteger() bool {
|
||||
return n.id0 == 0 && n.id1 == t.IDBase &&
|
||||
(n.id2 == t.IDU8 || n.id2 == t.IDU16 || n.id2 == t.IDU32 || n.id2 == t.IDU64)
|
||||
|
||||
@@ -964,6 +964,11 @@ var SliceFuncs = []string{
|
||||
"GENERIC T1.prefix(up_to: u64) T1",
|
||||
"GENERIC T1.uintptr_low_12_bits() u32[..= 4095]",
|
||||
"GENERIC T1.suffix(up_to: u64) T1",
|
||||
|
||||
// The bulk_etc methods are further restricted to those slices whose
|
||||
// elements are bulk-numeric types: numerics (e.g. base.u32), arrays of
|
||||
// numerics, arrays of arrays of numerics, etc.
|
||||
"GENERIC T1.bulk_memset!(byte_value: u8)",
|
||||
}
|
||||
|
||||
var SliceU8Funcs = []string{
|
||||
|
||||
+10
-2
@@ -730,8 +730,16 @@ func (q *checker) tcheckDot(n *a.Expr, depth uint32) error {
|
||||
qqid[0] = t.IDBase
|
||||
qqid[1] = t.IDDagger1
|
||||
if q.c.isBuiltInSliceFunc(qqid, lTyp) {
|
||||
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.AsNode(), nil, nil))
|
||||
return nil
|
||||
bulky := false
|
||||
switch qqid[2] {
|
||||
case t.IDBulkMemset:
|
||||
bulky = true
|
||||
}
|
||||
|
||||
if !bulky || lTyp.Inner().IsBulkNumType() {
|
||||
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.AsNode(), nil, nil))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("check: no %s method %q", lTyp.Decorator().Str(q.tm), n.Ident().Str(q.tm))
|
||||
|
||||
|
||||
+9
-9
@@ -668,14 +668,14 @@ const (
|
||||
IDIsOK = ID(0x231)
|
||||
IDIsSuspension = ID(0x232)
|
||||
|
||||
IDData = ID(0x240)
|
||||
IDHeight = ID(0x241)
|
||||
IDIO = ID(0x242)
|
||||
IDLimit = ID(0x243)
|
||||
IDPrefix = ID(0x244)
|
||||
IDRowU32 = ID(0x245)
|
||||
IDStride = ID(0x246)
|
||||
IDSubslice = ID(0x247)
|
||||
IDBulkMemset = ID(0x240)
|
||||
IDData = ID(0x241)
|
||||
IDHeight = ID(0x242)
|
||||
IDIO = ID(0x243)
|
||||
IDLimit = ID(0x244)
|
||||
IDPrefix = ID(0x245)
|
||||
IDRowU32 = ID(0x246)
|
||||
IDStride = ID(0x247)
|
||||
IDSubtable = ID(0x248)
|
||||
IDSuffix = ID(0x249)
|
||||
IDUintptrLow12Bits = ID(0x24A)
|
||||
@@ -1100,6 +1100,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDIsOK: "is_ok",
|
||||
IDIsSuspension: "is_suspension",
|
||||
|
||||
IDBulkMemset: "bulk_memset",
|
||||
IDData: "data",
|
||||
IDHeight: "height",
|
||||
IDIO: "io",
|
||||
@@ -1107,7 +1108,6 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDPrefix: "prefix",
|
||||
IDRowU32: "row_u32",
|
||||
IDStride: "stride",
|
||||
IDSubslice: "subslice",
|
||||
IDSubtable: "subtable",
|
||||
IDSuffix: "suffix",
|
||||
IDUintptrLow12Bits: "uintptr_low_12_bits",
|
||||
|
||||
Reference in new issue
Block a user