diff options
author | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-04-08 15:53:53 +0900 |
---|---|---|
committer | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-04-08 15:53:53 +0900 |
commit | 103a796f30e9a526122a310f79b0614eaa36eb6f (patch) | |
tree | 25724965b1d446e3f80118e09e00446987a73eec /ast.go | |
parent | bac3ccf9048c05b43ac2ba1fbc1db55f99cb0269 (diff) | |
download | kati-103a796f30e9a526122a310f79b0614eaa36eb6f.tar.gz |
add default origin support (for var in *bootstrap* makefile)
Diffstat (limited to 'ast.go')
-rw-r--r-- | ast.go | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -5,6 +5,8 @@ import ( "strings" ) +const BootstrapMakefile = "*bootstrap*" + type AST interface { eval(*Evaluator) show() @@ -27,15 +29,19 @@ func (ast *AssignAST) eval(ev *Evaluator) { } func (ast *AssignAST) evalRHS(ev *Evaluator, lhs string) Var { + origin := "file" + if ast.filename == BootstrapMakefile { + origin = "default" + } switch ast.op { case ":=": - return SimpleVar{value: ev.evalExpr(ast.rhs), origin: "file"} + return SimpleVar{value: ev.evalExpr(ast.rhs), origin: origin} case "=": - return RecursiveVar{expr: ast.rhs, origin: "file"} + return RecursiveVar{expr: ast.rhs, origin: origin} case "+=": prev := ev.LookupVar(lhs) if !prev.IsDefined() { - return RecursiveVar{expr: ast.rhs, origin: "file"} + return RecursiveVar{expr: ast.rhs, origin: origin} } return prev.Append(ev, ast.rhs) case "?=": @@ -43,7 +49,7 @@ func (ast *AssignAST) evalRHS(ev *Evaluator, lhs string) Var { if prev.IsDefined() { return prev } - return RecursiveVar{expr: ast.rhs, origin: "file"} + return RecursiveVar{expr: ast.rhs, origin: origin} default: panic(fmt.Sprintf("unknown assign op: %q", ast.op)) } @@ -57,8 +63,8 @@ func (ast *AssignAST) show() { // are expanded. type MaybeRuleAST struct { ASTBase - expr string - cmd string + expr string + cmd string } func (ast *MaybeRuleAST) eval(ev *Evaluator) { @@ -74,7 +80,7 @@ func (ast *MaybeRuleAST) show() { type CommandAST struct { ASTBase - cmd string + cmd string } func (ast *CommandAST) eval(ev *Evaluator) { |