diff options
author | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-06-18 23:04:28 +0900 |
---|---|---|
committer | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-06-18 23:04:28 +0900 |
commit | dd248f268ca290abc999a8d1b4f5d24dc0317cdc (patch) | |
tree | 52c67ca5288a7c79454494d3afc02299c42dfb57 /ast.go | |
parent | 5a374593daddc502fd0ee020de31007d173a0c87 (diff) | |
download | kati-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.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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 "+=": |