fix assignment
tests paying off
This commit is contained in:
parent
87693112d4
commit
f49b0c7356
@ -5,19 +5,19 @@ module Typed
|
|||||||
# name , value = *statement
|
# name , value = *statement
|
||||||
reset_regs # statements reset registers, ie have all at their disposal
|
reset_regs # statements reset registers, ie have all at their disposal
|
||||||
name_s = no_space statement.name
|
name_s = no_space statement.name
|
||||||
v = process(statement.value)
|
value = process(statement.value)
|
||||||
raise "Not register #{v}" unless v.is_a?(Register::RegisterValue)
|
raise "Not register #{v}" unless value.is_a?(Register::RegisterValue)
|
||||||
code = get_code( statement , name_s )
|
code = get_code( statement , name_s , value)
|
||||||
raise "must define variable #{name} before using it in #{@method.inspect}" unless code
|
raise "must define variable #{name} before using it in #{@method.inspect}" unless code
|
||||||
add_code code
|
add_code code
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_code( statement , name_s )
|
def get_code( statement , name_s , value)
|
||||||
if( index = @method.has_arg(name_s.name))
|
if( index = @method.has_arg(name_s.name))
|
||||||
# TODO, check type @method.arguments[index].type
|
# TODO, check type @method.arguments[index].type
|
||||||
return Register.set_slot(statement , v , :message , Parfait::Message.get_indexed(index) )
|
return Register.set_slot(statement , value , :message , Parfait::Message.get_indexed(index) )
|
||||||
end
|
end
|
||||||
# or a local so it is in the frame
|
# or a local so it is in the frame
|
||||||
index = @method.has_local( name_s.name )
|
index = @method.has_local( name_s.name )
|
||||||
@ -25,7 +25,7 @@ module Typed
|
|||||||
# TODO, check type @method.locals[index].type
|
# TODO, check type @method.locals[index].type
|
||||||
frame = use_reg(:Frame)
|
frame = use_reg(:Frame)
|
||||||
add_code Register.get_slot(statement , :message , :frame , frame )
|
add_code Register.get_slot(statement , :message , :frame , frame )
|
||||||
return Register.set_slot(statement , v , frame , Parfait::Frame.get_indexed(index) )
|
return Register.set_slot(statement , value , frame , Parfait::Frame.get_indexed(index) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user