nitc :: AExpr :: make_var_read
This method take care efficiently of creating and initalising an anonymous local variable
Note: since this method do side-effects (AST replacement), there could be unexpected effects when used as argument of other methods related to AST transformations.
# Return a new variable read that contains the value of the expression
# This method take care efficiently of creating and initalising an anonymous local variable
#
# Note: since this method do side-effects (AST replacement), there could be unexpected effects when used as
# argument of other methods related to AST transformations.
fun make_var_read: AVarExpr
do
var variable = self.variable_cache
if variable == null then
assert parent != null
var place = detach_with_placeholder
variable = new Variable("")
variable.declared_type = self.mtype
var nvar = new AVarAssignExpr.make(variable, self)
place.replace_with(nvar)
self.variable_cache = variable
end
return new AVarExpr.make(variable, variable.declared_type.as(not null))
end
src/astbuilder.nit:217,2--235,4