Add a read_u32le method.

This commit is contained in:
Nigel Tao committed 2017-07-13 16:20:59 +10:00
1 parent 7e9b3aab67
commit 368bd5e4f7
10 files changed
+126 -73

No files matched your search

+2 -1
View File
@@ -618,7 +618,8 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
case t.KeyOpenParen:
// TODO: delete this hack that only matches "in.src.read_u8?()" etc.
if isInSrc(q.tm, n, t.KeyReadU8, 0) || isInSrc(q.tm, n, t.KeySkip32, 1) ||
if isInSrc(q.tm, n, t.KeyReadU8, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
isInDst(q.tm, n, t.KeyWrite, 1) || isInDst(q.tm, n, t.KeyWriteU8, 1) ||
isInDst(q.tm, n, t.KeyCopyFrom32, 2) ||
isThisMethod(q.tm, n, "decode_header", 1) || isThisMethod(q.tm, n, "decode_lsd", 1) ||
+2 -1
View File
@@ -58,7 +58,8 @@ var (
typeExprU64 = a.NewTypeExpr(0, t.IDU64, nil, nil, nil)
// TODO: delete this.
typeExprPlaceholder = a.NewTypeExpr(0, t.IDU8, nil, nil, nil)
typeExprPlaceholder = a.NewTypeExpr(0, t.IDU8, nil, nil, nil)
typeExprPlaceholder32 = a.NewTypeExpr(0, t.IDU32, nil, nil, nil)
)
// TypeMap maps from variable names (as token IDs) to types.
+7 -2
View File
@@ -336,7 +336,8 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
case t.KeyOpenParen:
// n is a function call.
// TODO: delete this hack that only matches "in.src.read_u8?()" etc.
if isInSrc(q.tm, n, t.KeyReadU8, 0) || isInSrc(q.tm, n, t.KeySkip32, 1) ||
if isInSrc(q.tm, n, t.KeyReadU8, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
isInDst(q.tm, n, t.KeyWrite, 1) || isInDst(q.tm, n, t.KeyWriteU8, 1) ||
isInDst(q.tm, n, t.KeyCopyFrom32, 2) ||
isThisMethod(q.tm, n, "decode_header", 1) || isThisMethod(q.tm, n, "decode_lsd", 1) ||
@@ -351,7 +352,11 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
return err
}
}
n.SetMType(typeExprPlaceholder) // HACK.
if isInSrc(q.tm, n, t.KeyReadU32LE, 0) {
n.SetMType(typeExprPlaceholder32) // HACK.
} else {
n.SetMType(typeExprPlaceholder) // HACK.
}
return nil
}
// TODO: delete this hack that only matches "foo.bar_bits(etc)".