diff --git a/lib/risc.rb b/lib/risc.rb index cacfb537..d92065c2 100644 --- a/lib/risc.rb +++ b/lib/risc.rb @@ -24,7 +24,8 @@ require_relative "risc/position/position" require_relative "risc/platform" require "parfait" require_relative "risc/parfait_adapter" -require_relative "risc/machine" +require_relative "risc/parfait_boot" +require_relative "risc/linker" require_relative "risc/method_compiler" require_relative "risc/assembler" diff --git a/lib/risc/machine.rb b/lib/risc/linker.rb similarity index 82% rename from lib/risc/machine.rb rename to lib/risc/linker.rb index 6b3cb73f..f8f586bb 100644 --- a/lib/risc/machine.rb +++ b/lib/risc/linker.rb @@ -2,9 +2,6 @@ require_relative "collector" require_relative "binary_writer" module Risc - # The Risc Machine is an abstraction of the register level. This is seperate from the - # actual assembler level to allow for several cpu architectures. - # The Instructions (see class Instruction) define what the machine can do (ie load/store/maths) # From code, the next step down is Vool, then Mom (in two steps) # @@ -12,14 +9,13 @@ module Risc # executes. The step after transforms to Arm, which creates executables. # - class Machine + class Linker include Util::Logging log_level :info def initialize @risc_init = nil @constants = [] - @next_address = nil end attr_reader :constants , :cpu_init @@ -42,16 +38,6 @@ module Risc @constants << const end - # hand out a return address for use as constant the address is added - def get_address - 10.times do # 10 for whole pages - @next_address = Parfait::ReturnAddress.new(0,@next_address) - add_constant( @next_address ) - end unless @next_address - addr = @next_address - @next_address = @next_address.next_integer - addr - end # To create binaries, objects (and labels) need to have a position # (so objects can be loaded and branches know where to jump) @@ -139,23 +125,12 @@ module Risc end end - def boot - initialize - Position.clear_positions - Builtin.boot_functions - self - end - end - # Module function to retrieve singleton - def self.machine - unless defined?(@machine) - @machine = Machine.new - end - @machine + # module method to reset, and init + def self.boot + Position.clear_positions + Builtin.boot_functions end end - -require_relative "parfait_boot" diff --git a/test/risc/test_machine.rb b/test/risc/test_linker.rb similarity index 98% rename from test/risc/test_machine.rb rename to test/risc/test_linker.rb index 77fbf36d..66ff2429 100644 --- a/test/risc/test_machine.rb +++ b/test/risc/test_linker.rb @@ -5,7 +5,8 @@ module Risc def setup Parfait.boot! - @machine = Risc.machine.boot + Risc.boot + @machine = Linker.new end def test_objects objects = @machine.object_positions