mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Remove (ptr base.u8).read_u32le method
This commit is contained in:
1 parent
f64bf4af61
commit
c9ec81f0d6
4 files changed
+9
-33
No files matched your search
@@ -297,26 +297,6 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
|||||||
}
|
}
|
||||||
return nil
|
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) {
|
if isThatMethod(g.tm, n, g.tm.ByName("update"), 1) {
|
||||||
// TODO: don't hard-code the class name or this.checksum.
|
// TODO: don't hard-code the class name or this.checksum.
|
||||||
class := "wuffs_crc32__ieee_hasher"
|
class := "wuffs_crc32__ieee_hasher"
|
||||||
|
|||||||
+2
-1
@@ -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* v_p = i_slice_p.ptr;
|
||||||
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
|
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
|
||||||
while (v_p < i_end0_p) {
|
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]] ^
|
v_s = (wuffs_crc32__ieee_table[0][v_p[7]] ^
|
||||||
wuffs_crc32__ieee_table[1][v_p[6]] ^
|
wuffs_crc32__ieee_table[1][v_p[6]] ^
|
||||||
wuffs_crc32__ieee_table[2][v_p[5]] ^
|
wuffs_crc32__ieee_table[2][v_p[5]] ^
|
||||||
|
|||||||
@@ -144,16 +144,9 @@ const (
|
|||||||
PlaceholderNewName = t.IDDiamond
|
PlaceholderNewName = t.IDDiamond
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: drop the U8.
|
||||||
var PtrU8Funcs = []string{
|
var PtrU8Funcs = []string{
|
||||||
// TODO: these should really have preconditions like "this.length() >= 4".
|
// TODO: a length method.
|
||||||
// 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)",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var SliceFuncs = []string{
|
var SliceFuncs = []string{
|
||||||
|
|||||||
@@ -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) {
|
iterate (step:8, unroll:1)(p ptr base.u8:in.x) {
|
||||||
// TODO: explain the slicing-by-8 algorithm.
|
// TODO: explain the slicing-by-8 algorithm.
|
||||||
//
|
//
|
||||||
// TODO: bounds checking for the ptr base.u8 methods and the index
|
// TODO: bounds checking for the index expressions "p[7]" etc.
|
||||||
// expressions "p[7]" etc.
|
s ^= ((p[0] as base.u32) << 0) |
|
||||||
s ^= p.read_u32le(at: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]] ^
|
s = ieee_table[0][p[7]] ^
|
||||||
ieee_table[1][p[6]] ^
|
ieee_table[1][p[6]] ^
|
||||||
ieee_table[2][p[5]] ^
|
ieee_table[2][p[5]] ^
|
||||||
|
|||||||
Reference in new issue
Block a user