Remove (ptr base.u8).read_u32le method

This commit is contained in:
Nigel Tao committed 2018-05-04 12:11:42 +10:00
1 parent f64bf4af61
commit c9ec81f0d6
4 files changed
+9 -33

No files matched your search

-20
View File
@@ -297,26 +297,6 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
}
return nil
}
// TODO: All of the (ptr base.u8).ReadUxx methods, not just U32LE.
if isThatMethod(g.tm, n, t.IDReadU32LE, 1) {
if pp == parenthesesMandatory {
b.writeb('(')
}
b.writes("wuffs_base__load_u32le(")
if err := g.writeExpr(b, n.LHS().Expr().LHS().Expr(), rp, parenthesesMandatory, depth); err != nil {
return err
}
b.writeb('+')
a := n.Args()[0].Arg().Value()
if err := g.writeExpr(b, a, rp, parenthesesMandatory, depth); err != nil {
return err
}
b.writeb(')')
if pp == parenthesesMandatory {
b.writeb(')')
}
return nil
}
if isThatMethod(g.tm, n, g.tm.ByName("update"), 1) {
// TODO: don't hard-code the class name or this.checksum.
class := "wuffs_crc32__ieee_hasher"
+2 -1
View File
@@ -2018,7 +2018,8 @@ uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
uint8_t* v_p = i_slice_p.ptr;
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
while (v_p < i_end0_p) {
v_s ^= (wuffs_base__load_u32le(v_p + 0));
v_s ^= ((((uint32_t)(v_p[0])) << 0) | (((uint32_t)(v_p[1])) << 8) |
(((uint32_t)(v_p[2])) << 16) | (((uint32_t)(v_p[3])) << 24));
v_s = (wuffs_crc32__ieee_table[0][v_p[7]] ^
wuffs_crc32__ieee_table[1][v_p[6]] ^
wuffs_crc32__ieee_table[2][v_p[5]] ^
+2 -9
View File
@@ -144,16 +144,9 @@ const (
PlaceholderNewName = t.IDDiamond
)
// TODO: drop the U8.
var PtrU8Funcs = []string{
// TODO: these should really have preconditions like "this.length() >= 4".
// Should this be explicit in the Wuffs syntax here, or enforced as a
// special case in the compiler (during bounds checking)?
"T.read_u16be(at u32)(ret u16)",
"T.read_u16le(at u32)(ret u16)",
"T.read_u32be(at u32)(ret u32)",
"T.read_u32le(at u32)(ret u32)",
"T.read_u64be(at u32)(ret u64)",
"T.read_u64le(at u32)(ret u64)",
// TODO: a length method.
}
var SliceFuncs = []string{
+5 -3
View File
@@ -30,9 +30,11 @@ pub func ieee_hasher.update(x slice base.u8)(checksum base.u32) {
iterate (step:8, unroll:1)(p ptr base.u8:in.x) {
// TODO: explain the slicing-by-8 algorithm.
//
// TODO: bounds checking for the ptr base.u8 methods and the index
// expressions "p[7]" etc.
s ^= p.read_u32le(at:0)
// TODO: bounds checking for the index expressions "p[7]" etc.
s ^= ((p[0] as base.u32) << 0) |
((p[1] as base.u32) << 8) |
((p[2] as base.u32) << 16) |
((p[3] as base.u32) << 24)
s = ieee_table[0][p[7]] ^
ieee_table[1][p[6]] ^
ieee_table[2][p[5]] ^