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
|
raise "oh noo, nil from where #{expression.right.inspect}" unless r
|
||||||
index = method.has_arg(expression.left.name.to_sym)
|
index = method.has_arg(expression.left.name.to_sym)
|
||||||
if index
|
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
|
else
|
||||||
index = method.ensure_local(expression.left.name.to_sym)
|
index = method.ensure_local(expression.left.name.to_sym)
|
||||||
method.source.add_code Set.new(FrameSlot.new(index , r.type , r ) , Return.new)
|
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
|
name = expression.name.to_sym
|
||||||
if method.has_var(name)
|
if method.has_var(name)
|
||||||
# either an argument, so it's stored in message
|
# either an argument, so it's stored in message
|
||||||
|
ret = Return.new
|
||||||
if( index = method.has_arg(name))
|
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
|
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
|
end
|
||||||
|
return ret
|
||||||
else
|
else
|
||||||
call = Ast::CallSiteExpression.new(expression.name , [] ) #receiver self is implicit
|
call = Ast::CallSiteExpression.new(expression.name , [] ) #receiver self is implicit
|
||||||
Compiler.compile(call, method)
|
Compiler.compile(call, method)
|
||||||
|
@ -37,4 +37,15 @@ module Virtual
|
|||||||
super( type , value )
|
super( type , value )
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
require_relative "test_foo"
|
require_relative "test_foo"
|
||||||
require_relative "test_if"
|
require_relative "test_if"
|
||||||
#require_relative "test_functions"
|
require_relative "test_functions"
|
||||||
#require_relative "test_hello"
|
#require_relative "test_hello"
|
||||||
#require_relative "test_putint"
|
#require_relative "test_putint"
|
||||||
#require_relative "test_recursive_fibo"
|
#require_relative "test_recursive_fibo"
|
||||||
|
@ -24,7 +24,7 @@ HERE
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def ttest_if_function
|
def test_if_function
|
||||||
@string_input = <<HERE
|
@string_input = <<HERE
|
||||||
def itest(n)
|
def itest(n)
|
||||||
if( n < 12)
|
if( n < 12)
|
||||||
|
Loading…
Reference in New Issue
Block a user