mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Add cpu_arch
This commit is contained in:
1 parent
6124fda77f
commit
020b8e6903
15 files changed
+353
-77
No files matched your search
@@ -370,6 +370,18 @@ func (q *checker) hasIsErrorFact(id t.ID) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (q *checker) bcheckFuncAssert(n *a.Assert) error {
|
||||
if n.IsChooseCPUArch() {
|
||||
b := bounds{zero, one}
|
||||
cond := n.Condition()
|
||||
cond.SetMBounds(b)
|
||||
cond.LHS().AsExpr().SetMBounds(b)
|
||||
cond.RHS().AsExpr().SetMBounds(b)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("check: function assertions are not supported yet")
|
||||
}
|
||||
|
||||
func (q *checker) bcheckAssert(n *a.Assert) error {
|
||||
if err := n.DropExprCachedMBounds(); err != nil {
|
||||
return err
|
||||
|
||||
+5
-1
@@ -624,7 +624,11 @@ func (c *Checker) checkFuncContract(node *a.Node) error {
|
||||
tm: c.tm,
|
||||
}
|
||||
for _, o := range n.Asserts() {
|
||||
if err := q.tcheckAssert(o.AsAssert()); err != nil {
|
||||
setPlaceholderMBoundsMType(o)
|
||||
if err := q.tcheckFuncAssert(o.AsAssert()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := q.bcheckFuncAssert(o.AsAssert()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,17 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *checker) tcheckFuncAssert(n *a.Assert) error {
|
||||
if n.IsChooseCPUArch() {
|
||||
cond := n.Condition()
|
||||
cond.SetMType(typeExprBool)
|
||||
cond.LHS().AsExpr().SetMType(typeExprU32)
|
||||
cond.RHS().AsExpr().SetMType(typeExprU32)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("check: function assertions are not supported yet")
|
||||
}
|
||||
|
||||
func (q *checker) tcheckAssert(n *a.Assert) error {
|
||||
cond := n.Condition()
|
||||
if err := q.tcheckExpr(cond, 0); err != nil {
|
||||
@@ -531,6 +542,10 @@ func (q *checker) tcheckExprCall(n *a.Expr, depth uint32) error {
|
||||
return fmt.Errorf("check: %q has effect %q but %q has effect %q",
|
||||
n.Str(q.tm), ne, f.QQID().Str(q.tm), fe)
|
||||
}
|
||||
if f.HasChooseCPUArch() {
|
||||
return fmt.Errorf(`check: cannot call cpu_arch function %q directly, only via "choose"`,
|
||||
f.QQID().Str(q.tm))
|
||||
}
|
||||
|
||||
genericType1 := (*a.TypeExpr)(nil)
|
||||
genericType2 := (*a.TypeExpr)(nil)
|
||||
|
||||
Reference in new issue
Block a user