Move variable assignment handling to generation context

This allows the parsing code to be cleaner, as it
doesn't have to care about variable assignments.

Bug: 228518745
Test: go test
Change-Id: I33425c2fb51acab4901bfa82a53d337b75210f8e
This commit is contained in:
Cole Faust
2022-04-07 13:59:24 -07:00
parent 40f8c75752
commit f06326648b
5 changed files with 83 additions and 99 deletions

View File

@@ -232,19 +232,18 @@ func (xi *interpolateExpr) transform(transformer func(expr starlarkExpr) starlar
}
type variableRefExpr struct {
ref variable
isDefined bool
ref variable
}
func NewVariableRefExpr(ref variable, isDefined bool) starlarkExpr {
func NewVariableRefExpr(ref variable) starlarkExpr {
if predefined, ok := ref.(*predefinedVariable); ok {
return predefined.value
}
return &variableRefExpr{ref, isDefined}
return &variableRefExpr{ref}
}
func (v *variableRefExpr) emit(gctx *generationContext) {
v.ref.emitGet(gctx, v.isDefined)
v.ref.emitGet(gctx)
}
func (v *variableRefExpr) typ() starlarkType {