fix type in call issue

This commit is contained in:
Torsten Ruger
2015-10-06 15:26:57 +03:00
parent f4a4ccb98e
commit 4e26166dff
7 changed files with 40 additions and 19 deletions

View File

@ -53,8 +53,15 @@ module Bosl
raise "unimplemented: \n#{code} \nfor #{ref.inspect}"
end
else
method = @method
@method.source.add_code Virtual::MethodCall.new( @method )
if( me.type == :int)
name = :plus if name == :+
method = Virtual.machine.space.get_class_by_name(:Integer).get_instance_method(name)
puts Virtual.machine.space.get_class_by_name(:Integer).method_names.to_a
raise "Method not implemented Integer.#{name}" unless method
@method.source.add_code Virtual::MethodCall.new( method )
else
raise "me #{me}"
end
end
raise "Method not implemented #{me.value}.#{name}" unless method
# the effect of the method is that the NewMessage Return slot will be filled, return it

View File

@ -9,18 +9,17 @@ module Bosl
name = expression.to_a.first
return Virtual::Self.new( Virtual::Reference.new(@clazz)) if name == :self
# either an argument, so it's stored in message
ret = Virtual::Return.new :int
if( index = @method.has_arg(name))
@method.source.add_code Virtual::Set.new( Virtual::ArgSlot.new(index,:int ) , ret)
type = @method.arguments[index].type
return Virtual::ArgSlot.new(index , type )
else # or a local so it is in the frame
index = @method.has_local( name )
if(index)
@method.source.add_code Virtual::Set.new(Virtual::FrameSlot.new(index,:int ) , ret )
else
raise "must define variable #{name} before using it"
type = @method.locals[index].type
return Virtual::FrameSlot.new(index, type )
end
end
return ret
raise "must define variable #{name} before using it"
end
end #module

View File

@ -8,16 +8,17 @@ module Bosl
end
def on_assign expression
puts expression.inspect
name , value = *expression
name = name.to_a.first
v = process(value)
index = @method.has_local( name )
if(index)
@method.source.add_code Virtual::Set.new(Virtual::FrameSlot.new(:int,index ) , v )
@method.source.add_code Virtual::Set.new(Virtual::FrameSlot.new(index, :int ) , v )
else
index = @method.has_arg( name )
if(index)
@method.source.add_code Virtual::Set.new(Virtual::ArgSlot.new(:int,index ) , v )
@method.source.add_code Virtual::Set.new(Virtual::ArgSlot.new(index , :int ) , v )
else
raise "must define variable #{name} before using it in #{@method.inspect}"
end