more setter work
This commit is contained in:
parent
dc198ac79f
commit
25c5b2da6e
@ -7,7 +7,10 @@ module Ast
|
|||||||
r_val = right.compile(context)
|
r_val = right.compile(context)
|
||||||
#puts "compiled right #{r_val.inspect}"
|
#puts "compiled right #{r_val.inspect}"
|
||||||
if operator == "=" # assignment, value based
|
if operator == "=" # assignment, value based
|
||||||
raise "Can only assign variables, not #{left}" unless left.is_a?(NameExpression)
|
if(left.is_a? VariableExpression)
|
||||||
|
left.make_setter
|
||||||
|
l_val = left.compile(context)
|
||||||
|
elsif left.is_a?(NameExpression)
|
||||||
puts context.inspect unless context.locals
|
puts context.inspect unless context.locals
|
||||||
l_val = context.locals[left.name]
|
l_val = context.locals[left.name]
|
||||||
if( l_val ) #variable existed, move data there
|
if( l_val ) #variable existed, move data there
|
||||||
@ -16,6 +19,9 @@ module Ast
|
|||||||
l_val = context.function.new_local.move( into , r_val )
|
l_val = context.function.new_local.move( into , r_val )
|
||||||
end
|
end
|
||||||
context.locals[left.name] = l_val
|
context.locals[left.name] = l_val
|
||||||
|
else
|
||||||
|
raise "Can only assign variables, not #{left}"
|
||||||
|
end
|
||||||
return l_val
|
return l_val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user