fix and test basic and name expressions
This commit is contained in:
parent
48d090f19c
commit
31d825df7b
@ -64,7 +64,7 @@ module Virtual
|
||||
raise "oh noo, nil from where #{expression.right.inspect}" unless r
|
||||
index = method.has_arg(expression.left.name.to_sym)
|
||||
if index
|
||||
method.source.add_code Set.new(MessageSlot.new(index , r,type , r ) , Return.new)
|
||||
method.source.add_code Set.new(ArgSlot.new(index , r.type , r ) , Return.new)
|
||||
else
|
||||
index = method.ensure_local(expression.left.name.to_sym)
|
||||
method.source.add_code Set.new(FrameSlot.new(index , r.type , r ) , Return.new)
|
||||
|
@ -10,11 +10,14 @@ module Virtual
|
||||
name = expression.name.to_sym
|
||||
if method.has_var(name)
|
||||
# either an argument, so it's stored in message
|
||||
ret = Return.new
|
||||
if( index = method.has_arg(name))
|
||||
method.source.add_code Set.new( MessageSlot.new(expression.name) , Return.new)
|
||||
method.source.add_code Set.new( ArgSlot.new(index ) , ret)
|
||||
else # or a local so it is in the frame
|
||||
method.source.add_code FrameGet.new(expression.name , index)
|
||||
index = method.ensure_local( name )
|
||||
method.source.add_code Set.new(FrameSlot.new(index ) , ret )
|
||||
end
|
||||
return ret
|
||||
else
|
||||
call = Ast::CallSiteExpression.new(expression.name , [] ) #receiver self is implicit
|
||||
Compiler.compile(call, method)
|
||||
|
@ -37,4 +37,15 @@ module Virtual
|
||||
super( type , value )
|
||||
end
|
||||
end
|
||||
|
||||
# NewMessageName of the next message
|
||||
class ArgSlot < MessageSlot
|
||||
def initialize index , type = Unknown, value = nil
|
||||
@index = index
|
||||
super( type , value )
|
||||
end
|
||||
attr_reader :index
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
require_relative "test_foo"
|
||||
require_relative "test_if"
|
||||
#require_relative "test_functions"
|
||||
require_relative "test_functions"
|
||||
#require_relative "test_hello"
|
||||
#require_relative "test_putint"
|
||||
#require_relative "test_recursive_fibo"
|
||||
|
@ -24,7 +24,7 @@ HERE
|
||||
end
|
||||
|
||||
|
||||
def ttest_if_function
|
||||
def test_if_function
|
||||
@string_input = <<HERE
|
||||
def itest(n)
|
||||
if( n < 12)
|
||||
|
Loading…
Reference in New Issue
Block a user