diff --git a/lib/boot/boot_space.rb b/lib/boot/boot_space.rb index 86957691..e1f00356 100644 --- a/lib/boot/boot_space.rb +++ b/lib/boot/boot_space.rb @@ -1,9 +1,10 @@ -require "boot/boot_class" +require_relative "boot_class" #require "vm/call_site" require "kernel/all" -require "boot/object" -require "boot/string" -require "trickle/send" +require_relative "object" +require_relative "string" +require "virtual/send_implementation" + module Boot # The BootSpace contains all objects for a program. In functional terms it is a program, but in oo # it is a collection of objects, some of which are data, some classes, some functions @@ -25,9 +26,9 @@ module Boot #global objects (data) @objects = [] boot_classes - @passes = [ Trickle::Send ] + @passes = [ Virtual::SendImplementation ] end - attr_reader :context , :main , :classes , :entry , :exit + attr_reader :main , :classes , :objects def run_passes @passes.each do |pass| @@ -41,6 +42,26 @@ module Boot end end + # Passes are initiated empty and added to by anyone who want (basically) + # Even linking and assembly are passes and so there are quite a few system passes neccesary to result in a + # working binary. Other than that, this is intentionally quite flexible + + def add_pass_after( pass , after) + index = @passes.index(after) + raise "No such pass to add after: #{after}" unless index + @passes.insert(index+1 , pass) + end + def add_pass_before( pass , after) + index = @passes.index(after) + raise "No such pass to add after: #{after}" unless index + @passes.insert(index , pass) + end + + def add_pass_after( pass , after) + index = @passes.index(after) + raise "No such pass to add after: #{after}" unless index + @passes.insert(index , pass) + end # boot the classes, ie create a minimal set of classes with a minimal set of functions # minimal means only that which can not be coded in ruby # MethodDefinitions are grabbed from respective modules by sending the method name. This should return the diff --git a/lib/trickle/send.rb b/lib/virtual/send_implementation.rb similarity index 71% rename from lib/trickle/send.rb rename to lib/virtual/send_implementation.rb index 25521726..124e19d5 100644 --- a/lib/trickle/send.rb +++ b/lib/virtual/send_implementation.rb @@ -1,22 +1,22 @@ -module Trickle +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 Send + class SendImplementation def run block block.codes.dup.each do |code| - next unless code.is_a? Virtual::MessageSend + next unless code.is_a? MessageSend me = code.me - next unless ( me.type == Virtual::Reference) - if( me.is_a? Virtual::Constant) + next unless ( me.type == Reference) + if( me.is_a? Constant) Boot::BootClass if( me.is_a? Boot::BootClass ) raise "unimplemented" - elsif( me.is_a? Virtual::ObjectConstant ) + elsif( me.is_a? ObjectConstant ) clazz = me.clazz method = clazz.get_method_definition code.name raise "Method not implemented #{clazz.name}.#{code.name}" unless method - call = Virtual::FunctionCall.new( method ) + call = FunctionCall.new( method ) block.replace(code , [call] ) else raise "unimplemented"