diff --git a/internal/cgen/cgen.go b/internal/cgen/cgen.go index 72242c05..fe7519a6 100644 --- a/internal/cgen/cgen.go +++ b/internal/cgen/cgen.go @@ -200,8 +200,8 @@ const ( ) const ( - maxIOBinds = 100 - maxTemp = 10000 + maxIOManips = 100 + maxTemp = 10000 ) type status struct { diff --git a/internal/cgen/func.go b/internal/cgen/func.go index ba12ee7c..a28637a1 100644 --- a/internal/cgen/func.go +++ b/internal/cgen/func.go @@ -40,7 +40,7 @@ type funk struct { derivedVars map[t.ID]struct{} jumpTargets map[a.Loop]string coroSuspPoint uint32 - ioBinds uint32 + ioManips uint32 tempW uint32 tempR uint32 usesEmptyIOBuffer bool diff --git a/internal/cgen/liveness.go b/internal/cgen/liveness.go index 0247607b..cbbc4e1f 100644 --- a/internal/cgen/liveness.go +++ b/internal/cgen/liveness.go @@ -185,8 +185,8 @@ loop: return err } - case a.KIOBind: - if err := h.doIOBind(r, o.AsIOBind(), depth); err != nil { + case a.KIOManip: + if err := h.doIOManip(r, o.AsIOManip(), depth); err != nil { return err } @@ -324,7 +324,7 @@ func (h *livenessHelper) doExpr1(r livenesses, n *a.Expr, allToStrong bool, dept return nil } -func (h *livenessHelper) doIOBind(r livenesses, n *a.IOBind, depth uint32) error { +func (h *livenessHelper) doIOManip(r livenesses, n *a.IOManip, depth uint32) error { if err := h.doExpr(r, n.IO()); err != nil { return err } diff --git a/internal/cgen/statement.go b/internal/cgen/statement.go index 283c8795..0524bbf5 100644 --- a/internal/cgen/statement.go +++ b/internal/cgen/statement.go @@ -60,8 +60,8 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error { return g.writeStatementAssign(b, n.Operator(), n.LHS(), n.RHS(), depth) case a.KChoose: return g.writeStatementChoose(b, n.AsChoose(), depth) - case a.KIOBind: - return g.writeStatementIOBind(b, n.AsIOBind(), depth) + case a.KIOManip: + return g.writeStatementIOManip(b, n.AsIOManip(), depth) case a.KIf: return g.writeStatementIf(b, n.AsIf(), depth) case a.KIterate: @@ -293,12 +293,12 @@ func cpuArchCNames(asserts []*a.Node) (caMacro string, caName string, caAttribut return caMacro, caName, caAttribute, nil } -func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error { - if g.currFunk.ioBinds > maxIOBinds { +func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error { + if g.currFunk.ioManips > maxIOManips { return fmt.Errorf("too many temporary variables required") } - ioBindNum := g.currFunk.ioBinds - g.currFunk.ioBinds++ + ioBindNum := g.currFunk.ioManips + g.currFunk.ioManips++ e := n.IO() prefix := vPrefix diff --git a/internal/cgen/var.go b/internal/cgen/var.go index 59000b8e..1181ec0d 100644 --- a/internal/cgen/var.go +++ b/internal/cgen/var.go @@ -64,8 +64,8 @@ func (g *gen) needDerivedVar(name t.ID) bool { } } - case a.KIOBind: - if p.AsIOBind().IO().IsArgsDotFoo() == name { + case a.KIOManip: + if p.AsIOManip().IO().IsArgsDotFoo() == name { return errNeedDerivedVar } } diff --git a/lang/ast/ast.go b/lang/ast/ast.go index 8512e49d..1becd28f 100644 --- a/lang/ast/ast.go +++ b/lang/ast/ast.go @@ -46,7 +46,7 @@ const ( KField KFile KFunc - KIOBind + KIOManip KIf KIterate KJump @@ -78,7 +78,7 @@ var kindStrings = [...]string{ KField: "KField", KFile: "KFile", KFunc: "KFunc", - KIOBind: "KIOBind", + KIOManip: "KIOManip", KIf: "KIf", KIterate: "KIterate", KJump: "KJump", @@ -169,7 +169,7 @@ type Node struct { // Field . . name Field // File . . . File // Func funcName receiverPkg receiverName Func - // IOBind . . . IOBind + // IOManip keyword . . IOManip // If . . . If // Iterate advance label length Iterate // Jump keyword label . Jump @@ -208,7 +208,7 @@ func (n *Node) AsExpr() *Expr { return (*Expr)(n) } func (n *Node) AsField() *Field { return (*Field)(n) } func (n *Node) AsFile() *File { return (*File)(n) } func (n *Node) AsFunc() *Func { return (*Func)(n) } -func (n *Node) AsIOBind() *IOBind { return (*IOBind)(n) } +func (n *Node) AsIOManip() *IOManip { return (*IOManip)(n) } func (n *Node) AsIf() *If { return (*If)(n) } func (n *Node) AsIterate() *Iterate { return (*Iterate)(n) } func (n *Node) AsJump() *Jump { return (*Jump)(n) } @@ -583,25 +583,25 @@ func NewField(flags Flags, name t.ID, xType *TypeExpr) *Field { } } -// IOBind is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or +// IOManip is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or // "io_limit (io:LHS, limit:MHS) { List2 }": // - ID0: // - LHS: // - MHS: // - RHS: // - List2: body -type IOBind Node +type IOManip Node -func (n *IOBind) AsNode() *Node { return (*Node)(n) } -func (n *IOBind) Keyword() t.ID { return n.id0 } -func (n *IOBind) IO() *Expr { return n.lhs.AsExpr() } -func (n *IOBind) Arg1() *Expr { return n.mhs.AsExpr() } -func (n *IOBind) HistoryPosition() *Expr { return n.rhs.AsExpr() } -func (n *IOBind) Body() []*Node { return n.list2 } +func (n *IOManip) AsNode() *Node { return (*Node)(n) } +func (n *IOManip) Keyword() t.ID { return n.id0 } +func (n *IOManip) IO() *Expr { return n.lhs.AsExpr() } +func (n *IOManip) Arg1() *Expr { return n.mhs.AsExpr() } +func (n *IOManip) HistoryPosition() *Expr { return n.rhs.AsExpr() } +func (n *IOManip) Body() []*Node { return n.list2 } -func NewIOBind(keyword t.ID, io *Expr, arg1 *Expr, historyPosition *Expr, body []*Node) *IOBind { - return &IOBind{ - kind: KIOBind, +func NewIOManip(keyword t.ID, io *Expr, arg1 *Expr, historyPosition *Expr, body []*Node) *IOManip { + return &IOManip{ + kind: KIOManip, id0: keyword, lhs: io.AsNode(), mhs: arg1.AsNode(), @@ -1152,7 +1152,7 @@ func NewFile(filename string, topLevelDecls []*Node) *File { // - Assert // - Assign // - Choose -// - IOBind +// - IOManip // - If // - Iterate // - Jump diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 4806066f..10e037ff 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -250,8 +250,8 @@ func (q *checker) bcheckStatement(n *a.Node) error { case a.KChoose: // No-op. - case a.KIOBind: - n := n.AsIOBind() + case a.KIOManip: + n := n.AsIOManip() if _, err := q.bcheckExpr(n.IO(), 0); err != nil { return err } diff --git a/lang/check/type.go b/lang/check/type.go index 31153886..0ce0d34b 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -149,8 +149,8 @@ func (q *checker) tcheckStatement(n *a.Node) error { } return nil - case a.KIOBind: - n := n.AsIOBind() + case a.KIOManip: + n := n.AsIOManip() if err := q.tcheckExpr(n.IO(), 0); err != nil { return err } diff --git a/lang/parse/parse.go b/lang/parse/parse.go index c99fe101..4c10b652 100644 --- a/lang/parse/parse.go +++ b/lang/parse/parse.go @@ -861,7 +861,7 @@ func (p *parser) parseStatement1() (*a.Node, error) { return a.NewChoose(name, args).AsNode(), nil case t.IDIOBind, t.IDIOLimit: - return p.parseIOBindNode() + return p.parseIOManipNode() case t.IDIf: o, err := p.parseIf() @@ -1050,7 +1050,7 @@ func (p *parser) parseAsserts() ([]*a.Node, error) { return asserts, nil } -func (p *parser) parseIOBindNode() (*a.Node, error) { +func (p *parser) parseIOManipNode() (*a.Node, error) { keyword := p.peek1() p.src = p.src[1:] @@ -1164,7 +1164,7 @@ func (p *parser) parseIOBindNode() (*a.Node, error) { return nil, err } - return a.NewIOBind(keyword, io, arg1, histPos, body).AsNode(), nil + return a.NewIOManip(keyword, io, arg1, histPos, body).AsNode(), nil } func (p *parser) parseIf() (*a.If, error) { @@ -1384,22 +1384,6 @@ func (p *parser) parseArgNode() (*a.Node, error) { return a.NewArg(name, value).AsNode(), nil } -func (p *parser) parseIOBindExprNode() (*a.Node, error) { - e, err := p.parseExpr() - if err != nil { - return nil, err - } - switch e.Operator() { - case 0: - return e.AsNode(), nil - case t.IDDot: - if lhs := e.LHS().AsExpr(); lhs.Operator() == 0 && lhs.Ident() == t.IDArgs { - return e.AsNode(), nil - } - } - return nil, fmt.Errorf(`parse: expected "args.something", got %q at %s:%d`, e.Str(p.tm), p.filename, p.line()) -} - func (p *parser) parseVarNode() (*a.Node, error) { id, err := p.parseIdent() if err != nil {