mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
lang: add io_reader.peek_u8_at
This commit is contained in:
1 parent
d4bab677b0
commit
6693250aa9
6 files changed
+22
-7
No files matched your search
@@ -510,8 +510,9 @@ var funcsOther = [...]string{
|
||||
"io_reader.peek_u64le() u64",
|
||||
|
||||
// As an implementation restriction, we require that offset has a constant
|
||||
// value. The (0x1_0000 - sizeof(u64)) limit is arbitrary, but high enough
|
||||
// value. The (0x1_0000 - sizeof(uxx)) limit is arbitrary, but high enough
|
||||
// in practice.
|
||||
"io_reader.peek_u8_at(offset: u32[..= 0xFFFF]) u8",
|
||||
"io_reader.peek_u64le_at(offset: u32[..= 0xFFF8]) u64",
|
||||
|
||||
"io_reader.count_since(mark: u64) u64",
|
||||
|
||||
@@ -1259,16 +1259,20 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
||||
advanceExpr, update = actual, true
|
||||
}
|
||||
|
||||
} else if method == t.IDPeekU64LEAt {
|
||||
} else if (method == t.IDPeekU8At) || (method == t.IDPeekU64LEAt) {
|
||||
args := n.Args()
|
||||
if len(args) != 1 {
|
||||
return bounds{}, fmt.Errorf("check: internal error: bad peek_u64le_at arguments")
|
||||
return bounds{}, fmt.Errorf("check: internal error: bad peek_uxx_at arguments")
|
||||
}
|
||||
offset := args[0].AsArg().Value()
|
||||
if offset.ConstValue() == nil {
|
||||
return bounds{}, fmt.Errorf("check: peek_u64le_at offset is not a constant value")
|
||||
return bounds{}, fmt.Errorf("check: peek_uxx_at offset is not a constant value")
|
||||
}
|
||||
advance, update = big.NewInt(8), false
|
||||
adv := int64(1)
|
||||
if method == t.IDPeekU64LEAt {
|
||||
adv = 8
|
||||
}
|
||||
advance, update = big.NewInt(adv), false
|
||||
advance.Add(advance, offset.ConstValue())
|
||||
|
||||
} else if method >= t.IDPeekU8 {
|
||||
|
||||
@@ -570,6 +570,7 @@ const (
|
||||
|
||||
IDPeekUndoByte = ID(0x1A0)
|
||||
IDPeekU8 = ID(0x1A1)
|
||||
IDPeekU8At = ID(0x1A2)
|
||||
|
||||
IDPeekU8AsU16 = ID(0x1A5)
|
||||
IDPeekU16BE = ID(0x1A6)
|
||||
@@ -1020,6 +1021,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
|
||||
IDPeekUndoByte: "peek_undo_byte",
|
||||
IDPeekU8: "peek_u8",
|
||||
IDPeekU8At: "peek_u8_at",
|
||||
|
||||
IDPeekU8AsU16: "peek_u8_as_u16",
|
||||
IDPeekU16BE: "peek_u16be",
|
||||
|
||||
Reference in new issue
Block a user