mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
Add an io_limit keyword
This commit is contained in:
1 parent
3aff5e6f42
commit
e992921dce
10 files changed
+159
-32
No files matched your search
+11
-2
@@ -234,8 +234,17 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
||||
|
||||
case a.KIOBind:
|
||||
n := n.AsIOBind()
|
||||
for _, o := range n.InFields() {
|
||||
if _, err := q.bcheckExpr(o.AsExpr(), 0); err != nil {
|
||||
if n.Keyword() == t.IDIOBind {
|
||||
for _, o := range n.InFields() {
|
||||
if _, err := q.bcheckExpr(o.AsExpr(), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if _, err := q.bcheckExpr(n.IO(), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := q.bcheckExpr(n.Limit(), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
+23
-5
@@ -120,13 +120,31 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
|
||||
case a.KIOBind:
|
||||
n := n.AsIOBind()
|
||||
for _, o := range n.InFields() {
|
||||
if err := q.tcheckExpr(o.AsExpr(), 0); err != nil {
|
||||
if n.Keyword() == t.IDIOBind {
|
||||
for _, o := range n.InFields() {
|
||||
if err := q.tcheckExpr(o.AsExpr(), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if typ := o.AsExpr().MType(); !typ.IsIOType() {
|
||||
return fmt.Errorf("check: io_bind expression %q, of type %q, does not have an I/O type",
|
||||
o.AsExpr().Str(q.tm), typ.Str(q.tm))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := q.tcheckExpr(n.IO(), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if typ := o.AsExpr().MType(); !typ.IsIOType() {
|
||||
return fmt.Errorf("check: io_bind expression %q, of type %q, does not have an I/O type",
|
||||
o.AsExpr().Str(q.tm), typ.Str(q.tm))
|
||||
if typ := n.IO().MType(); !typ.IsIOType() {
|
||||
return fmt.Errorf("check: %s expression %q, of type %q, does not have an I/O type",
|
||||
n.Keyword().Str(q.tm), n.IO().Str(q.tm), typ.Str(q.tm))
|
||||
}
|
||||
|
||||
if err := q.tcheckExpr(n.Limit(), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if typ := n.Limit().MType(); !typ.Eq(typeExprU64) {
|
||||
return fmt.Errorf("check: %s expression %q, of type %q, does not have base.u64 type",
|
||||
n.Keyword().Str(q.tm), n.Limit().Str(q.tm), typ.Str(q.tm))
|
||||
}
|
||||
}
|
||||
for _, o := range n.Body() {
|
||||
|
||||
Reference in new issue
Block a user