start on passes
after all that booting and vm/parfait changes passes have gone out of sync, start to fix
This commit is contained in:
parent
47abdffd1a
commit
6786855e95
@ -5,25 +5,25 @@ module Virtual
|
||||
# - All existing instances are stored in the space for both
|
||||
# - Size is currently 2, ie 16 words (TODO a little flexibility here would not hurt, but the mountain is big)
|
||||
# - Unused instances for a linked list with their first instance variable. This is HARD coded to avoid any lookup
|
||||
|
||||
|
||||
# Just as a reminder: a message object is created before a send and holds return address/message and arguemnts + self
|
||||
# frames are created upon entering a method and hold local and temporary variables
|
||||
# as a result one of each is created for every single method call. A LOT, so make it fast luke
|
||||
# Note: this is off course the reason for stack based implementations that just increment a known pointer/register or
|
||||
# something. But i think most programs are memory bound and a few extra instructions don't hurt.
|
||||
# something. But i think most programs are memory bound and a few extra instructions don't hurt.
|
||||
# After all, we are buying a big prize:oo, otherwise known as sanity.
|
||||
|
||||
class FrameImplementation
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
if code.is_a?(NewFrame)
|
||||
if code.is_a?(NewFrame)
|
||||
kind = :next_frame
|
||||
elsif code.is_a?(NewMessage)
|
||||
kind = :next_message
|
||||
else
|
||||
next
|
||||
end
|
||||
space = Space.space
|
||||
space = Parfait::Space.object_space
|
||||
slot = Virtual::Slot
|
||||
# a place to store a reference to the space, we grab the next_frame from the space
|
||||
space_tmp = Register::RegisterReference.new(Virtual::Message::TMP_REG)
|
||||
|
@ -13,7 +13,7 @@ module Virtual
|
||||
next unless code.is_a? MessageSend
|
||||
new_codes = [ ]
|
||||
ref = code.me
|
||||
raise "only refs implemented #{ref.inspect}" unless ( ref.type == Reference)
|
||||
raise "only refs implemented #{ref.type}" unless ( ref.type.is_a? Reference)
|
||||
# value known at compile time, got do something with it
|
||||
if(ref.value)
|
||||
me = ref.value
|
||||
@ -34,9 +34,17 @@ module Virtual
|
||||
raise "unimplemented: \n#{code}"
|
||||
end
|
||||
else
|
||||
# must defer send to run-time
|
||||
# So inlining the code from message.send (in the future)
|
||||
raise "not constant/ known object for send #{ref.inspect}"
|
||||
if ref.type.is_a?(Reference) and ref.type.of_class
|
||||
#find method and call
|
||||
clazz = ref.type.of_class
|
||||
method = clazz.resolve_method Virtual.new_word(code.name)
|
||||
raise "No method found #{code.name}" unless method
|
||||
new_codes << MethodCall.new( method )
|
||||
else
|
||||
# must defer send to run-time
|
||||
# So inlining the code from message.send (in the future)
|
||||
raise "not constant/ known object for send #{ref.inspect}"
|
||||
end
|
||||
end
|
||||
block.replace(code , new_codes )
|
||||
end
|
||||
|
@ -4,17 +4,22 @@ module Virtual
|
||||
# The Mystery Type has unknown type and has only casting methods. So it must be cast to be useful.
|
||||
class Type
|
||||
def == other
|
||||
return false unless other.class == self.class
|
||||
return false unless other.class == self.class
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class Integer < Type
|
||||
end
|
||||
|
||||
|
||||
class Reference < Type
|
||||
# possibly unknown value, but known class (as in methods)
|
||||
def initialize clazz = nil
|
||||
@of_class = clazz
|
||||
end
|
||||
attr_reader :of_class
|
||||
end
|
||||
|
||||
|
||||
class Mystery < Type
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user