From cee81d5298af715a1deb260968b7701881f58613 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Thu, 25 Feb 2016 15:53:55 +0100 Subject: [PATCH] eval: VariablesOp -> LValueOp --- eval/boilerplate.go | 16 ++++++++-------- eval/boilerplate.py | 2 +- ...compileVariablesOp.go => compileLValuesOp.go} | 13 ++++++------- 3 files changed, 15 insertions(+), 16 deletions(-) rename eval/{compileVariablesOp.go => compileLValuesOp.go} (91%) diff --git a/eval/boilerplate.go b/eval/boilerplate.go index 1a9a4f90..f1a54893 100644 --- a/eval/boilerplate.go +++ b/eval/boilerplate.go @@ -182,24 +182,24 @@ func (cp *compiler) bracedOps(ns []*parse.Primary) []ValuesOp { return ops } -func (cp *compiler) multiVariableOp(n *parse.Indexing) VariablesOp { - return VariablesOp{cp.multiVariable(n), n.Begin(), n.End()} +func (cp *compiler) multiVariableOp(n *parse.Indexing) LValuesOp { + return LValuesOp{cp.multiVariable(n), n.Begin(), n.End()} } -func (cp *compiler) multiVariableOps(ns []*parse.Indexing) []VariablesOp { - ops := make([]VariablesOp, len(ns)) +func (cp *compiler) multiVariableOps(ns []*parse.Indexing) []LValuesOp { + ops := make([]LValuesOp, len(ns)) for i, n := range ns { ops[i] = cp.multiVariableOp(n) } return ops } -func (cp *compiler) singleVariableOp(n *parse.Indexing, msg string) VariablesOp { - return VariablesOp{cp.singleVariable(n, msg), n.Begin(), n.End()} +func (cp *compiler) singleVariableOp(n *parse.Indexing, msg string) LValuesOp { + return LValuesOp{cp.singleVariable(n, msg), n.Begin(), n.End()} } -func (cp *compiler) singleVariableOps(ns []*parse.Indexing, msg string) []VariablesOp { - ops := make([]VariablesOp, len(ns)) +func (cp *compiler) singleVariableOps(ns []*parse.Indexing, msg string) []LValuesOp { + ops := make([]LValuesOp, len(ns)) for i, n := range ns { ops[i] = cp.singleVariableOp(n, msg) } diff --git a/eval/boilerplate.py b/eval/boilerplate.py index 4d48d5fb..08f6c1f5 100755 --- a/eval/boilerplate.py +++ b/eval/boilerplate.py @@ -29,7 +29,7 @@ def main(): print >>out, '''package eval import "github.com/elves/elvish/parse"''' - for fname in 'compileOp.go', 'compileValuesOp.go', 'compileVariablesOp.go': + for fname in 'compileOp.go', 'compileValuesOp.go', 'compileLValuesOp.go': for line in file(fname): m = re.match(r'^func \(cp \*compiler\) (\w+)\(\w+ ([^,]+)(.*)\) (\w*OpFunc) {$', line) if m: diff --git a/eval/compileVariablesOp.go b/eval/compileLValuesOp.go similarity index 91% rename from eval/compileVariablesOp.go rename to eval/compileLValuesOp.go index fce502ea..9d78c005 100644 --- a/eval/compileVariablesOp.go +++ b/eval/compileLValuesOp.go @@ -7,19 +7,19 @@ import ( ) // VariablesOp is an operation on an EvalCtx that produce Variable's. -type VariablesOp struct { - Func VariablesOpFunc +type LValuesOp struct { + Func LValuesOpFunc Begin, End int } -type VariablesOpFunc func(*EvalCtx) []Variable +type LValuesOpFunc func(*EvalCtx) []Variable -func (op VariablesOp) Exec(ec *EvalCtx) []Variable { +func (op LValuesOp) Exec(ec *EvalCtx) []Variable { ec.begin, ec.end = op.Begin, op.End return op.Func(ec) } -func (cp *compiler) multiVariable(n *parse.Indexing) VariablesOpFunc { +func (cp *compiler) multiVariable(n *parse.Indexing) LValuesOpFunc { if n.Head.Type == parse.Braced { // XXX ignore n.Indicies. compounds := n.Head.Braced @@ -43,8 +43,7 @@ func (cp *compiler) multiVariable(n *parse.Indexing) VariablesOpFunc { return cp.singleVariable(n, "must be a variable spec or a braced list of those") } -func (cp *compiler) singleVariable(n *parse.Indexing, msg string) VariablesOpFunc { - // XXX will we be using this for purposes other than setting? +func (cp *compiler) singleVariable(n *parse.Indexing, msg string) LValuesOpFunc { varname := cp.literal(n.Head, msg) if len(n.Indicies) == 0 {