scaffold for instance variable get implementation

This commit is contained in:
Torsten Ruger
2014-08-23 10:59:35 +03:00
parent 0fcb1c8f68
commit a63e37fc50
7 changed files with 27 additions and 7 deletions

View File

@ -0,0 +1,14 @@
module Virtual
# This implements the send logic
# Send is so complicated that we actually code it in ruby and stick it in
# That off course opens up an endless loop possibility that we stop by reducing to Class and Module methods
class GetImplementation
def run block
block.codes.dup.each do |code|
next unless code.is_a? InstanceGet
raise "Start coding"
end
end
end
Object.space.add_pass_after GetImplementation, SendImplementation
end

View File

@ -83,7 +83,9 @@ module Virtual
end
# class for Set instructions, A set is basically a mem move.
# to and from are indexes into the known objects(frame,message,self and new_message), or from may be a constant
# to and from are indexes into the known objects(frame,message,self and new_message), these are represented as slots
# (see there)
# from may be a Constant (Object,Integer,String,Class)
class Set < Instruction
def initialize to , from
@to = to
@ -91,8 +93,10 @@ module Virtual
end
attr_reader :to , :from
end
class ObjectGet < Instruction
# Get a instance variable by _name_ . So we have to resolve the name to an index to trnsform into a Slot
# The slot may the be used in a set on left or right hand. The transformation is done by GetImplementation
class InstanceGet < Instruction
def initialize name
@name = name.to_sym
end

View File

@ -83,4 +83,6 @@ require_relative "value"
require_relative "type"
require_relative "object"
require_relative "constants"
require "boot/boot_space"
require "boot/boot_space"
require_relative "send_implementation"
require_relative "get_implementation"

View File

@ -26,3 +26,4 @@ module Virtual
end
end
end
require_relative "get_implementation"