up to, ut not including, creating frames
This commit is contained in:
parent
363fe5e35f
commit
df9d6284ae
@ -1,6 +1,9 @@
|
||||
# this is not a "normal" ruby file, ie it is not required by salama
|
||||
# instead it is parsed by salama to define part of the program that runs
|
||||
|
||||
class Frame #just for now
|
||||
end
|
||||
|
||||
class Message
|
||||
|
||||
def get_type_for(name)
|
||||
@ -8,7 +11,7 @@ class Message
|
||||
get_at(index)
|
||||
end
|
||||
|
||||
def __send__
|
||||
def __send
|
||||
typ = get_type_for( :receiver )
|
||||
# TODO: this will obviously be recoded as case, once that is done :-)
|
||||
# depending on value type get method
|
||||
|
@ -164,6 +164,10 @@ module Register
|
||||
send("add_#{clazz}".to_sym , object)
|
||||
end
|
||||
|
||||
def add_Message m
|
||||
end
|
||||
def add_Frame f
|
||||
end
|
||||
def add_Array( array )
|
||||
# also array has constant overhead, the padded helper fixes it to multiple of 8
|
||||
array.each do |elem|
|
||||
|
@ -4,11 +4,12 @@ module Register
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? Virtual::MethodEnter
|
||||
new_codes = []
|
||||
# save return register and create a new frame
|
||||
to = RegisterReference.new(:r0) # message base
|
||||
pc = RegisterReference.new(:pc)
|
||||
move1 = RegisterMachine.instance.str( pc , to , Virtual::Slot::MESSAGE_RETURN_VALUE )
|
||||
block.replace(code , [move1] )
|
||||
# lr is link register, ie where arm stores the return address when call is issued
|
||||
new_codes << RegisterMachine.instance.str( :lr , Virtual::Slot::MESSAGE_REGISTER , Virtual::Slot::MESSAGE_RETURN_ADDRESS )
|
||||
new_codes << Virtual::NewFrame.new
|
||||
block.replace(code , new_codes )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -14,17 +14,17 @@ module Virtual
|
||||
|
||||
class BootSpace < Virtual::Object
|
||||
|
||||
# Initialize with a string for cpu. Naming conventions are: for Machine XXX there exists a module XXX
|
||||
# with a XXXMachine in it that derives from Virtual::RegisterMachine
|
||||
def initialize machine = nil
|
||||
def initialize
|
||||
super()
|
||||
@classes = Parfait::Hash.new
|
||||
@main = Virtual::CompiledMethod.new("main" , [] )
|
||||
#global objects (data)
|
||||
@objects = []
|
||||
@symbols = []
|
||||
@messages = []
|
||||
@frames = []
|
||||
@messages = 100.times.collect{ ::Message.new }
|
||||
@frames = 100.times.collect{ ::Frame.new }
|
||||
@next_message = @messages.first
|
||||
@next_frame = @frames.first
|
||||
@passes = [ Virtual::SendImplementation ]
|
||||
end
|
||||
attr_reader :main , :classes , :objects , :symbols,:messages,:frames
|
||||
@ -77,7 +77,7 @@ module Virtual
|
||||
obj.add_instance_method Builtin::Object.send(f , @context)
|
||||
end
|
||||
obj = get_or_create_class :Kernel
|
||||
[:main , :__init__,:putstring,:exit,:__send__].each do |f|
|
||||
[:main , :__init__,:putstring,:exit,:__send].each do |f|
|
||||
obj.add_instance_method Builtin::Kernel.send(f , @context)
|
||||
end
|
||||
obj = get_or_create_class :Integer
|
||||
|
@ -44,6 +44,7 @@ module Virtual
|
||||
end
|
||||
#
|
||||
def compile_get method , name
|
||||
raise "CALLED"
|
||||
if method.has_arg(name)
|
||||
method.add_code MessageGet.new(name)
|
||||
else
|
||||
|
@ -1,4 +1,5 @@
|
||||
require_relative "type"
|
||||
require "parfait/message"
|
||||
|
||||
module Virtual
|
||||
# our machine is made up of objects, some of which are code, some data
|
||||
@ -80,6 +81,22 @@ module Virtual
|
||||
end
|
||||
end
|
||||
end
|
||||
::Message.class_eval do
|
||||
def layout
|
||||
Virtual::Object.layout
|
||||
end
|
||||
def mem_length
|
||||
Virtual::Object.new.padded_words(2)
|
||||
end
|
||||
end
|
||||
::Frame.class_eval do
|
||||
def layout
|
||||
Virtual::Object.layout
|
||||
end
|
||||
def mem_length
|
||||
Virtual::Object.new.padded_words(2)
|
||||
end
|
||||
end
|
||||
Parfait::Hash.class_eval do
|
||||
HASH = { :names => [:keys,:values] , :types => [Virtual::Reference,Virtual::Reference]}
|
||||
def layout
|
||||
|
@ -27,7 +27,7 @@ module Virtual
|
||||
# note: this is the current view: call internal send, even the method name says else
|
||||
# but send is "special" and accesses the internal method name and resolves.
|
||||
kernel = Virtual::BootSpace.space.get_or_create_class(:Kernel)
|
||||
method = kernel.get_instance_method(:__send__)
|
||||
method = kernel.get_instance_method(:__send)
|
||||
new_codes << FunctionCall.new( method )
|
||||
raise "unimplemented #{code}"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user