more setter work
This commit is contained in:
parent
dc198ac79f
commit
25c5b2da6e
@ -7,15 +7,21 @@ 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)
|
||||||
puts context.inspect unless context.locals
|
left.make_setter
|
||||||
l_val = context.locals[left.name]
|
l_val = left.compile(context)
|
||||||
if( l_val ) #variable existed, move data there
|
elsif left.is_a?(NameExpression)
|
||||||
l_val = l_val.move( into , r_val)
|
puts context.inspect unless context.locals
|
||||||
|
l_val = context.locals[left.name]
|
||||||
|
if( l_val ) #variable existed, move data there
|
||||||
|
l_val = l_val.move( into , r_val)
|
||||||
|
else
|
||||||
|
l_val = context.function.new_local.move( into , r_val )
|
||||||
|
end
|
||||||
|
context.locals[left.name] = l_val
|
||||||
else
|
else
|
||||||
l_val = context.function.new_local.move( into , r_val )
|
raise "Can only assign variables, not #{left}"
|
||||||
end
|
end
|
||||||
context.locals[left.name] = l_val
|
|
||||||
return l_val
|
return l_val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user