mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +01:00
Add a "deref" unary operator.
This commit is contained in:
1 parent
51bd52239b
commit
2cd6ebed8e
8 files changed
+55
-53
No files matched your search
@@ -920,6 +920,8 @@ func (q *checker) bcheckExprUnaryOp(n *a.Expr, depth uint32) (*big.Int, *big.Int
|
||||
return neg(rMax), neg(rMin), nil
|
||||
case t.KeyXUnaryNot:
|
||||
return zero, one, nil
|
||||
case t.KeyXUnaryRef, t.KeyXUnaryDeref:
|
||||
return q.bcheckTypeExpr(n.MType())
|
||||
}
|
||||
|
||||
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprUnaryOp", n.ID0().Key())
|
||||
|
||||
@@ -796,6 +796,17 @@ func (q *checker) tcheckExprUnaryOp(n *a.Expr, depth uint32) error {
|
||||
}
|
||||
n.SetMType(typeExprBool)
|
||||
return nil
|
||||
|
||||
case t.KeyXUnaryRef:
|
||||
// TODO.
|
||||
|
||||
case t.KeyXUnaryDeref:
|
||||
if rTyp.Decorator().Key() != t.KeyPtr { // TODO: t.KeyNptr?
|
||||
return fmt.Errorf("check: %q is a dereference of a non-pointer type %q",
|
||||
n.String(q.tm), rTyp.String(q.tm))
|
||||
}
|
||||
n.SetMType(rTyp.Inner())
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("check: unrecognized token.Key (0x%X) for tcheckExprUnaryOp", n.ID0().Key())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user