fix name expression
This commit is contained in:
parent
1141ed9c99
commit
f105b1eb3c
@ -7,16 +7,18 @@ module Phisol
|
|||||||
# whichever way this goes the result is stored in the return slot (as all compiles)
|
# whichever way this goes the result is stored in the return slot (as all compiles)
|
||||||
def on_name statement
|
def on_name statement
|
||||||
name = statement.to_a.first
|
name = statement.to_a.first
|
||||||
return Virtual::Self.new( @clazz) if name == :self
|
return Register.self_reg(@clazz.name ) if(name == :self)
|
||||||
# either an argument, so it's stored in message
|
# either an argument, so it's stored in message
|
||||||
if( index = @method.has_arg(name))
|
if( index = @method.has_arg(name))
|
||||||
type = @method.arguments[index].type
|
ret = use_reg @method.arguments[index].type
|
||||||
return Virtual::ArgSlot.new(index , type )
|
@method.source.add_code Register.get_slot(statement , :message , index , ret )
|
||||||
|
return ret
|
||||||
else # or a local so it is in the frame
|
else # or a local so it is in the frame
|
||||||
index = @method.has_local( name )
|
index = @method.has_local( name )
|
||||||
if(index)
|
if(index)
|
||||||
type = @method.locals[index].type
|
ret = use_reg @method.locals[index].type
|
||||||
return Virtual::FrameSlot.new(index, type )
|
@method.source.add_code Register.get_slot(statement , :frame , index , ret )
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
raise "must define variable #{name} before using it"
|
raise "must define variable #{name} before using it"
|
||||||
|
@ -116,7 +116,7 @@ module Register
|
|||||||
when :new_message
|
when :new_message
|
||||||
register = new_message_reg
|
register = new_message_reg
|
||||||
when :self
|
when :self
|
||||||
register = self_reg(:Object) #TODO , prpbably have to get rid of this resolve method
|
register = self_reg(:Object) #TODO , probably have to get rid of this resolve method
|
||||||
when :frame
|
when :frame
|
||||||
register = frame_reg
|
register = frame_reg
|
||||||
else
|
else
|
||||||
|
@ -36,7 +36,6 @@ class TestBasic < MiniTest::Test
|
|||||||
|
|
||||||
def test_self
|
def test_self
|
||||||
@string_input = 'self '
|
@string_input = 'self '
|
||||||
@output = Virtual::Self
|
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ module Virtual
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def ttest_call_main_op
|
def test_call_main_op
|
||||||
Virtual.machine.space.get_main.ensure_local(:bar , :Integer)
|
Virtual.machine.space.get_main.ensure_local(:bar , :Integer)
|
||||||
@root = :call_site
|
@root = :call_site
|
||||||
@string_input = 'main( bar )'
|
@string_input = 'main( bar )'
|
||||||
|
@ -26,5 +26,21 @@ HERE
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_local
|
||||||
|
Virtual.machine.space.get_main.ensure_local(:bar , :Integer)
|
||||||
|
@root = :name
|
||||||
|
@string_input = 'bar '
|
||||||
|
@output = Register::RegisterValue
|
||||||
|
check
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_args
|
||||||
|
Virtual.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :bar)
|
||||||
|
@root = :name
|
||||||
|
@string_input = 'bar '
|
||||||
|
@output = Register::RegisterValue
|
||||||
|
check
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user