mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
base: add {io_reader,io_writer}.peek_undo_byte
This commit is contained in:
1 parent
29e49cded4
commit
d9bb6d4b4f
4 files changed
+58
-35
No files matched your search
@@ -1196,8 +1196,8 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
||||
}
|
||||
|
||||
} else if recvTyp.IsIOTokenType() {
|
||||
if method == t.IDUndoByte {
|
||||
if err := q.canUndoByte(recv); err != nil {
|
||||
if (method == t.IDUndoByte) || (method == t.IDPeekUndoByte) {
|
||||
if err := q.canUndoByte(recv, method == t.IDPeekUndoByte); err != nil {
|
||||
return bounds{}, err
|
||||
}
|
||||
|
||||
@@ -1319,11 +1319,13 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
||||
return bounds{}, errNotASpecialCase
|
||||
}
|
||||
|
||||
func (q *checker) canUndoByte(recv *a.Expr) error {
|
||||
func (q *checker) canUndoByte(recv *a.Expr, justPeeking bool) error {
|
||||
for _, x := range q.facts {
|
||||
if lhs, meth, args, _ := x.IsMethodCall(); (meth != t.IDCanUndoByte) || (len(args) != 0) ||
|
||||
!lhs.Eq(recv) {
|
||||
continue
|
||||
} else if justPeeking {
|
||||
return nil
|
||||
}
|
||||
return q.facts.update(func(o *a.Expr) (*a.Expr, error) {
|
||||
if o.Mentions(recv) {
|
||||
|
||||
Reference in new issue
Block a user