hoist parfait boot out of the machine boot

This commit is contained in:
Torsten Ruger 2018-06-30 00:39:23 +03:00
parent 8d7a2fe4d6
commit 46d8f5002f
35 changed files with 62 additions and 33 deletions

View File

@ -13,6 +13,7 @@ group :test do
gem "simplecov"
gem "minitest-color"
gem 'minitest-fail-fast'
#gem "minitest-reporters"
gem "net-ssh"
end

View File

@ -23,7 +23,6 @@ module Risc
end
attr_reader :constants , :cpu_init
attr_reader :translated
attr_reader :platform
# Translate code to whatever cpu is specified.
@ -34,7 +33,6 @@ module Risc
def translate( platform )
platform = platform.to_s.capitalize
@platform = Platform.for(platform)
@translated = true
translate_methods( @platform.translator )
@cpu_init = risc_init.to_cpu(@platform.translator)
end
@ -85,7 +83,6 @@ module Risc
# As code length may change during assembly, this way at least the objects stay
# in place and we don't have to deal with changing loading code
def position_all
raise "Not translated " unless @translated
#need the initial jump at 0 and then functions
Position.new(cpu_init).set(0)
code_start = position_objects( @platform.padding )
@ -165,8 +162,6 @@ module Risc
def boot
initialize
Position.clear_positions
@translated = false
Parfait.boot!
Builtin.boot_functions
self
end

View File

@ -15,6 +15,7 @@ module RubyX
end
def self.ruby_to_binary(source , platform = :arm)
Parfait.boot!
machine = Risc.machine.boot
ruby_to_mom(source)
machine.translate(platform)

View File

@ -4,6 +4,7 @@ module Arm
class TestTranslator < MiniTest::Test
def setup
Parfait.boot!
Risc.machine.boot
@jump = Risc::DynamicJump.new("" , :r1)
@codes = Translator.new.translate @jump

View File

@ -8,6 +8,7 @@ module Elf
DEBUG = false
def setup
Parfait.boot!
Risc.machine.boot
end

View File

@ -3,6 +3,7 @@ require_relative "../helper"
class TestZeroCode < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@space = Parfait.object_space
@space.each_type do | type |

View File

@ -15,6 +15,8 @@ end
require "minitest/color"
require "minitest/autorun"
#require "minitest/fail_fast"
#require "minitest/reporters"
#Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))

View File

@ -4,7 +4,8 @@ module Risc
module Statements
def setup
Risc.machine.boot # force boot to reset main
Parfait.boot!
Risc::Builtin.boot_functions
end
def preamble

View File

@ -4,6 +4,7 @@ module Mom
class TestSlotLoad2 < MiniTest::Test
def setup
Parfait.boot!
Risc.machine.boot
@load = SlotLoad.new( [:message, :caller] , [:message, :caller , :type] )
@compiler = CompilerMock.new

View File

@ -4,7 +4,7 @@ module Parfait
class ParfaitTest < MiniTest::Test
def setup
@machine = Risc.machine.boot
Parfait.boot!
@space = Parfait.object_space
end
end

View File

@ -15,20 +15,10 @@ module Parfait
assert @space.false_object , "No lies"
assert @space.nil_object , "No nothing"
end
def test_methods_booted
word = @space.get_class_by_name(:Word).instance_type
assert_equal 3 , word.method_names.get_length
assert word.get_method(:putstring) , "no putstring"
end
def test_global_space
assert_equal Parfait::Space , Parfait.object_space.class
end
def test_integer
int = Parfait.object_space.get_class_by_name :Integer
assert_equal 14, int.instance_type.method_names.get_length
end
def test_get_integer_instance
int = @space.get_integer
@ -158,6 +148,21 @@ module Parfait
assert_equal 0 , cl.instance_type.methods_length , "name #{cl.name}"
end
end
end
class TestMethods < ParfaitTest
def setup
super
Risc::Builtin.boot_functions
end
def test_integer
int = Parfait.object_space.get_class_by_name :Integer
assert_equal 14, int.instance_type.method_names.get_length
end
def test_methods_booted
word = @space.get_class_by_name(:Word).instance_type
assert_equal 3 , word.method_names.get_length
assert word.get_method(:putstring) , "no putstring"
end
end
end

View File

@ -3,6 +3,7 @@ require_relative "helper"
module Risc
class TestCodeListenerFull < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@binary = Parfait::BinaryCode.new(1)
@method = Parfait.object_space.types.values.first.methods

View File

@ -3,6 +3,7 @@ require_relative "helper"
module Risc
class TestPositionTranslated < MiniTest::Test
def setup
Parfait.boot!
machine = Risc.machine.boot
machine.translate(:interpreter)
@binary = Parfait::BinaryCode.new(1)

View File

@ -3,6 +3,7 @@ require_relative "helper"
module Risc
class TestMachinePositions < MiniTest::Test
def setup_for(platform)
Parfait.boot!
@machine = Risc.machine.boot
@machine.translate(platform)
@machine.position_all

View File

@ -4,6 +4,7 @@ module Risc
class TestCodeBuilder < MiniTest::Test
def setup
Parfait.boot!
Risc.machine.boot
init = Parfait.object_space.get_init
@builder = Risc::RiscCompiler.new( init ).code_builder(init)
@ -100,6 +101,7 @@ module Risc
class TestCompilerBuilder < MiniTest::Test
def setup
Parfait.boot!
Risc.machine.boot
@init = Parfait.object_space.get_init
@builder = Risc::RiscCompiler.new( @init ).compiler_builder(@init)

View File

@ -4,6 +4,7 @@ module Risc
class TestCollector < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
end

View File

@ -18,6 +18,7 @@ module Risc
end
class TestInterpreterStarts < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@machine.translate(:interpreter)
@machine.position_all
@ -37,6 +38,7 @@ module Risc
end
class TestInterpreterTicks < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@machine.translate(:interpreter)
@machine.position_all

View File

@ -21,6 +21,7 @@ module Risc
class TestIdentityTranslator < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@translator = IdentityTranslator.new
end

View File

@ -4,6 +4,7 @@ module Risc
class TestMachineObjects < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
end
def test_objects
@ -36,6 +37,7 @@ module Risc
end
class TestMachinePos < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@machine.translate(:arm)
@machine.position_all
@ -48,6 +50,7 @@ module Risc
end
class TestMachineInit < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@machine.translate(:arm)
@machine.position_all

View File

@ -5,7 +5,7 @@ module Risc
include ScopeHelper
def setup
Risc.machine.boot
Parfait.boot!
end
def create_method

View File

@ -17,6 +17,7 @@ module Risc
class TestTextWriterPositions < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@machine.translate(:arm)
@machine.position_all

View File

@ -4,6 +4,7 @@ module Risc
class TestTranslator < MiniTest::Test
def setup
Parfait.boot!
@machine = Risc.machine.boot
@translator = Arm::Translator.new
end

View File

@ -3,6 +3,7 @@ require_relative "../helper"
module RubyX
module RubyXHelper
def setup
Parfait.boot!
Risc.machine.boot
end
def ruby_to_vool(input)

View File

@ -14,7 +14,7 @@ module RubyX
def test_creates_class_deriviation
mom = ruby_to_mom "class Testing ; end"
assert mom , "No classes created"
#assert mom , "No classes created"
end
def test_creates_class_with_deriviation

View File

@ -7,6 +7,7 @@ module Risc
include ScopeHelper
def setup
Parfait.boot!
Risc.machine.boot
RubyX::RubyXCompiler.ruby_to_binary( @string_input , :interpreter)
@interpreter = Interpreter.new

View File

@ -6,7 +6,8 @@ module Vool
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
Risc::Builtin.boot_functions
@ins = compile_first_method( send_method )
end

View File

@ -5,7 +5,8 @@ module Vool
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
Risc::Builtin.boot_functions
@ins = compile_first_method( "local = 5")
end
@ -36,7 +37,7 @@ module Vool
class TestAssignMomInstanceToLocal < MiniTest::Test
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "@a = 5 ; local = @a")
end
def test_class_compiles
@ -49,7 +50,7 @@ module Vool
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "arg = 5")
end
@ -73,7 +74,7 @@ module Vool
class TestAssignMomToInstance < MiniTest::Test
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
end
def test_assigns_const
@ins = compile_first_method( "@a = 5")

View File

@ -7,7 +7,8 @@ module Vool
include Mom
def setup
Risc.machine.boot
Parfait.boot!
Risc::Builtin.boot_functions
@ins = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
end

View File

@ -7,7 +7,7 @@ module Vool
include Mom
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "if(@a) ; @a = 5 ; end")
end

View File

@ -7,7 +7,7 @@ module Vool
include Mom
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end")
end

View File

@ -5,7 +5,7 @@ module Vool
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "@a = 5")
end

View File

@ -5,7 +5,7 @@ module Vool
include MomCompile
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "a = 5")
end

View File

@ -6,7 +6,7 @@ module Vool
include Mom
def setup
Risc.machine.boot
Parfait.boot!
@inst = compile_first_method( "return 5")
end

View File

@ -7,7 +7,8 @@ module Vool
include Mom
def setup
Risc.machine.boot
Parfait.boot!
Risc::Builtin.boot_functions
@ins = compile_first_method( "while(5.div4) ; 5.div4 ; end")
end

View File

@ -7,7 +7,7 @@ module Vool
include Mom
def setup
Risc.machine.boot
Parfait.boot!
@ins = compile_first_method( "while(@a) ; @a = 5 ; end")
end