mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Prohibit iterate loops inside coroutines
This commit is contained in:
1 parent
79ce1a7b0e
commit
14f5859311
3 files changed
+5
-22
No files matched your search
@@ -47,6 +47,7 @@
|
||||
- Made `wuffs_base__pixel_format` a struct.
|
||||
- Made `wuffs_base__pixel_subsampling` a struct.
|
||||
- Made `wuffs_base__status` a struct.
|
||||
- Prohibited iterate loops inside coroutines.
|
||||
- Removed `ack_metadata_chunk?`.
|
||||
- Removed `wuffs_base__frame_config__blend`.
|
||||
- Renamed I/O `available` methods to `length`.
|
||||
|
||||
@@ -205,9 +205,7 @@ loop:
|
||||
}
|
||||
|
||||
case a.KIterate:
|
||||
if err := h.doIterate(r, o.AsIterate(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("iterate loop is inside a coroutine")
|
||||
|
||||
case a.KJump:
|
||||
if err := h.doJump(r, o.AsJump(), depth); err != nil {
|
||||
@@ -372,24 +370,6 @@ func (h *livenessHelper) doIf(r livenesses, n *a.If, depth uint32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *livenessHelper) doIterate(r livenesses, n *a.Iterate, depth uint32) error {
|
||||
// TODO: ban jumps, rets and coroutine calls inside an iterate. Also ensure
|
||||
// that the iterate variable values are all pure expressions.
|
||||
for _, o := range n.Assigns() {
|
||||
o := o.AsAssign()
|
||||
if err := h.doExpr(r, o.RHS()); err != nil {
|
||||
return err
|
||||
}
|
||||
name := o.LHS().Ident()
|
||||
if i, ok := h.vars[name]; !ok {
|
||||
return fmt.Errorf("unrecognized variable %q", name.Str(h.tm))
|
||||
} else {
|
||||
r.lowerWeakToNone(i)
|
||||
}
|
||||
}
|
||||
return h.doBlock(r, n.Body(), depth)
|
||||
}
|
||||
|
||||
func (h *livenessHelper) doJump(r livenesses, n *a.Jump, depth uint32) error {
|
||||
l := h.loops[n.JumpTarget()]
|
||||
switch n.Keyword() {
|
||||
|
||||
+3
-1
@@ -1204,7 +1204,9 @@ func (p *parser) parseIf() (*a.If, error) {
|
||||
}
|
||||
|
||||
func (p *parser) parseIterateNode() (*a.Node, error) {
|
||||
if x := p.peek1(); x != t.IDIterate {
|
||||
if p.funcEffect.Coroutine() {
|
||||
return nil, fmt.Errorf(`parse: "iterate" inside coroutine at %s:%d`, p.filename, p.line())
|
||||
} else if x := p.peek1(); x != t.IDIterate {
|
||||
got := p.tm.ByID(x)
|
||||
return nil, fmt.Errorf(`parse: expected "iterate", got %q at %s:%d`, got, p.filename, p.line())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user