carry constants through in reference slots. resolve functions with it
This commit is contained in:
@ -6,14 +6,15 @@ module Virtual
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? MessageSend
|
||||
me = code.me
|
||||
raise "ahm" unless ( me.type == Reference)
|
||||
if( me.is_a? Constant)
|
||||
ref = code.me
|
||||
raise "only refs implemented #{me.inspect}" unless ( ref.type == Reference)
|
||||
if(ref.value)
|
||||
me = ref.value
|
||||
if( me.is_a? BootClass )
|
||||
raise "unimplemented #{code}"
|
||||
elsif( me.is_a? ObjectConstant )
|
||||
clazz = me.clazz
|
||||
method = clazz.get_instance_method code.name
|
||||
# get the function from my class. easy peasy
|
||||
method = me.clazz.get_instance_method(code.name)
|
||||
raise "Method not implemented #{clazz.name}.#{code.name}" unless method
|
||||
call = FunctionCall.new( method )
|
||||
block.replace(code , call )
|
||||
@ -21,7 +22,7 @@ module Virtual
|
||||
raise "unimplemented #{code}"
|
||||
end
|
||||
else
|
||||
raise "unimplemented #{code.me}"
|
||||
raise "not constant/ known object for send #{me.inspect}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -15,64 +15,65 @@ module Virtual
|
||||
NAME = 3
|
||||
MESSAGE_PAYLOAD = 4
|
||||
|
||||
attr_accessor :index , :type
|
||||
attr_accessor :index , :type , :value
|
||||
private #abstract base class
|
||||
def initialize index , type
|
||||
def initialize index , type , value
|
||||
@index = index
|
||||
@type = type
|
||||
@value = value
|
||||
end
|
||||
end
|
||||
|
||||
class MessageSlot < Slot
|
||||
def initialize index , type = Mystery
|
||||
super(index + MESSAGE_PAYLOAD ,type)
|
||||
def initialize index , type = Mystery , value = nil
|
||||
super(index + MESSAGE_PAYLOAD ,type , value )
|
||||
end
|
||||
end
|
||||
class FrameSlot < Slot
|
||||
def initialize index , type = Mystery
|
||||
def initialize index , type = Mystery, value = nil
|
||||
super
|
||||
end
|
||||
end
|
||||
class SelfSlot < Slot
|
||||
def initialize index , type = Mystery
|
||||
def initialize index , type = Mystery, value = nil
|
||||
super
|
||||
end
|
||||
end
|
||||
class NewMessageSlot < Slot
|
||||
def initialize index , type = Mystery
|
||||
super(index + MESSAGE_PAYLOAD , type)
|
||||
def initialize index , type = Mystery, value = nil
|
||||
super(index + MESSAGE_PAYLOAD , type , value )
|
||||
end
|
||||
end
|
||||
|
||||
class Return < MessageSlot
|
||||
def initialize type = Mystery
|
||||
super( RETURN - MESSAGE_PAYLOAD, type )
|
||||
def initialize type = Mystery, value = nil
|
||||
super( RETURN - MESSAGE_PAYLOAD, type , value )
|
||||
end
|
||||
end
|
||||
class Self < MessageSlot
|
||||
def initialize type = Mystery
|
||||
super( SELF - MESSAGE_PAYLOAD , type )
|
||||
def initialize type = Mystery, value = nil
|
||||
super( SELF - MESSAGE_PAYLOAD , type , value )
|
||||
end
|
||||
end
|
||||
class Name < MessageSlot
|
||||
def initialize type = Mystery
|
||||
super( NAME - MESSAGE_PAYLOAD , type )
|
||||
def initialize type = Mystery, value = nil
|
||||
super( NAME - MESSAGE_PAYLOAD , type , value )
|
||||
end
|
||||
end
|
||||
|
||||
class NewReturn < NewMessageSlot
|
||||
def initialize type = Mystery
|
||||
super( RETURN - MESSAGE_PAYLOAD, type )
|
||||
def initialize type = Mystery, value = nil
|
||||
super( RETURN - MESSAGE_PAYLOAD, type , value )
|
||||
end
|
||||
end
|
||||
class NewSelf < NewMessageSlot
|
||||
def initialize type = Mystery
|
||||
super( SELF - MESSAGE_PAYLOAD , type )
|
||||
def initialize type = Mystery, value = nil
|
||||
super( SELF - MESSAGE_PAYLOAD , type , value )
|
||||
end
|
||||
end
|
||||
class NewName < NewMessageSlot
|
||||
def initialize type = Mystery
|
||||
super( NAME - MESSAGE_PAYLOAD , type )
|
||||
def initialize type = Mystery, value = nil
|
||||
super( NAME - MESSAGE_PAYLOAD , type , value )
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user