aboutsummaryrefslogtreecommitdiff
path: root/ast.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-18 23:04:28 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-18 23:04:28 +0900
commitdd248f268ca290abc999a8d1b4f5d24dc0317cdc (patch)
tree52c67ca5288a7c79454494d3afc02299c42dfb57 /ast.go
parent5a374593daddc502fd0ee020de31007d173a0c87 (diff)
downloadkati-dd248f268ca290abc999a8d1b4f5d24dc0317cdc.tar.gz
split SimpleVar to SimpleVar and AutomaticVar
SimpleVar uses string, while AutomaticVar uses []byte
Diffstat (limited to 'ast.go')
-rw-r--r--ast.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/ast.go b/ast.go
index 7a418be..a8a2d8b 100644
--- a/ast.go
+++ b/ast.go
@@ -55,9 +55,16 @@ func (ast *AssignAST) evalRHS(ev *Evaluator, lhs string) Var {
// TODO(ukai): handle ast.opt == "export"
switch ast.op {
case ":=":
- var buf bytes.Buffer
- ast.rhs.Eval(&buf, ev)
- return &SimpleVar{value: buf.Bytes(), origin: origin}
+ switch v := ast.rhs.(type) {
+ case literal:
+ return &SimpleVar{value: v.String(), origin: origin}
+ case tmpval:
+ return &SimpleVar{value: v.String(), origin: origin}
+ default:
+ var buf bytes.Buffer
+ v.Eval(&buf, ev)
+ return &SimpleVar{value: buf.String(), origin: origin}
+ }
case "=":
return &RecursiveVar{expr: ast.rhs, origin: origin}
case "+=":