scaffold for instance variable get implementation
This commit is contained in:
14
lib/virtual/get_implementation.rb
Normal file
14
lib/virtual/get_implementation.rb
Normal 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
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -26,3 +26,4 @@ module Virtual
|
||||
end
|
||||
end
|
||||
end
|
||||
require_relative "get_implementation"
|
Reference in New Issue
Block a user