From 4334b687363a10b1eff1696e3ba7b0e880eda967 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 10 Oct 2015 11:14:31 +0300 Subject: [PATCH] remove virtual main instruction on a quest to remove all virtual instructions --- lib/register/passes/main_implementation.rb | 17 ---------------- lib/register/register.rb | 1 - lib/virtual/instruction.rb | 1 - lib/virtual/instructions/virtual_main.rb | 23 ---------------------- lib/virtual/machine.rb | 9 ++------- 5 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 lib/register/passes/main_implementation.rb delete mode 100644 lib/virtual/instructions/virtual_main.rb diff --git a/lib/register/passes/main_implementation.rb b/lib/register/passes/main_implementation.rb deleted file mode 100644 index c73aa07b..00000000 --- a/lib/register/passes/main_implementation.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Register - - # "Boot" the virtual machine at the function given - # meaning jump to that function currently. Maybe better to do some machine setup - # and possibly some cleanup/exit has to tie in, but that is not this day - - class MainImplementation - def run block - block.codes.dup.each do |code| - next unless code.is_a? Virtual::VirtualMain - branch = Register::Branch.new( code , code.method.source.blocks.first ) - block.replace(code , branch ) - end - end - end - Virtual.machine.add_pass "Register::MainImplementation" -end diff --git a/lib/register/register.rb b/lib/register/register.rb index b936af83..21dd6d5f 100644 --- a/lib/register/register.rb +++ b/lib/register/register.rb @@ -1,7 +1,6 @@ require_relative "instruction" require_relative "register_reference" require_relative "assembler" -require_relative "passes/main_implementation" require_relative "passes/frame_implementation" require_relative "passes/message_implementation" require_relative "passes/set_implementation" diff --git a/lib/virtual/instruction.rb b/lib/virtual/instruction.rb index 05da66b2..640ed3e8 100644 --- a/lib/virtual/instruction.rb +++ b/lib/virtual/instruction.rb @@ -21,4 +21,3 @@ require_relative "instructions/method_return" require_relative "instructions/new_frame" require_relative "instructions/new_message" require_relative "instructions/set" -require_relative "instructions/virtual_main" diff --git a/lib/virtual/instructions/virtual_main.rb b/lib/virtual/instructions/virtual_main.rb deleted file mode 100644 index e3eecc2d..00000000 --- a/lib/virtual/instructions/virtual_main.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Virtual - - # This starts the Virtual machine machine at the given function. - - # The implementation is most likely a jump/branch , but since we have the extra layer - # we make good use of it, ie give things descriptive names (what they do, not how) - - class VirtualMain < Instruction - include Positioned - - def initialize method - @method = method - end - attr_reader :method - def word_length - 4 - end - - def to_s - "#{self.class.name}( method: #{method.name})" - end - end -end diff --git a/lib/virtual/machine.rb b/lib/virtual/machine.rb index d7453d13..35c82bbc 100644 --- a/lib/virtual/machine.rb +++ b/lib/virtual/machine.rb @@ -119,15 +119,10 @@ module Virtual end def boot -# if @booted -# boot_functions! -# @init = Block.new("init", :__init__ ) -# @init.add_code Virtual::VirtualMain.new( self.space.get_init ) -# return self -# end boot_parfait! @init = Block.new("init", :__init__ ) - @init.add_code Virtual::VirtualMain.new( self.space.get_init ) + branch = Register::Branch.new( "__init__" , self.space.get_init.source.blocks.first ) + @init.add_code branch @booted = true self end