clean up booting
many machine boot became obsolete or just neede parfait to boot actual linker functionality pending
This commit is contained in:
parent
e75aef933d
commit
c947c27a14
@ -65,7 +65,7 @@ module Risc
|
||||
# An integer is plucked from object_space abd added to the machine constant pool
|
||||
# if none was given
|
||||
def self.label( source , name , position = nil , nekst = nil)
|
||||
position = Risc.machine.get_address unless position
|
||||
position = Parfait.object_space.get_address unless position
|
||||
Label.new( source , name , position, nekst )
|
||||
end
|
||||
end
|
||||
|
@ -19,15 +19,19 @@ module RubyX
|
||||
vool.to_mom(nil)
|
||||
end
|
||||
|
||||
def ruby_to_risc(platform)
|
||||
mom = ruby_to_mom
|
||||
mom.translate(platform)
|
||||
end
|
||||
|
||||
def ruby_to_binary(platform = :arm)
|
||||
Parfait.boot!
|
||||
machine = Risc.machine.boot
|
||||
mom = ruby_to_mom
|
||||
puts "MOM #{mom.class}"
|
||||
mom.translate(platform)
|
||||
#machine.translate(platform)
|
||||
machine.position_all
|
||||
machine.create_binary
|
||||
Risc.boot!
|
||||
assemblers = ruby_to_mom(platform)
|
||||
puts "Assemblers #{assemblers}"
|
||||
linker = Linker.new
|
||||
linker.position_all
|
||||
linker.create_binary
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ module Arm
|
||||
assert_nil code.branch_to
|
||||
end
|
||||
def test_method_call
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
bin = Parfait::BinaryCode.new(1)
|
||||
Risc::Position.new(bin).set(0x20)
|
||||
code = @machine.call( bin ,{} )#this jumps to the next instruction
|
||||
|
@ -5,7 +5,6 @@ module Arm
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
@jump = Risc::DynamicJump.new("" , :r1)
|
||||
@codes = Translator.new.translate @jump
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ module Elf
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
end
|
||||
|
||||
def in_space(input)
|
||||
|
@ -37,7 +37,7 @@ module Mains
|
||||
end
|
||||
|
||||
def compile(input , file , scp)
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
puts "Compiling test/#{file}.o" if DEBUG
|
||||
RubyX::RubyXCompiler.ruby_to_binary( "class Space;def main(arg);#{input};end;end" )
|
||||
writer = Elf::ObjectWriter.new(Risc.machine)
|
||||
|
@ -29,7 +29,7 @@ module Risc
|
||||
end
|
||||
def produce_instructions
|
||||
assert @expect , "No output given"
|
||||
RubyX::RubyXCompiler.ruby_to_binary as_test_main , :interpreter
|
||||
RubyX::RubyXCompiler.new(as_test_main).ruby_to_binary( :interpreter)
|
||||
test = Parfait.object_space.get_class_by_name :Test
|
||||
test.instance_type.get_method(:main).cpu_instructions
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ module Mom
|
||||
|
||||
class TestSlotDefinitionConstant < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(StringConstant.new("hi") , [])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
|
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module Mom
|
||||
class TestSlotDefinitionKnown1 < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(:message , :caller)
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
|
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module Mom
|
||||
class TestSlotDefinitionKnown2 < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@compiler = CompilerMock.new
|
||||
@definition = SlotDefinition.new(:message , [:caller , :type])
|
||||
@instruction = @definition.to_register(@compiler , InstructionMock.new)
|
||||
|
@ -4,7 +4,7 @@ module Mom
|
||||
class TestSlotLoad1 < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@load = SlotLoad.new( [:message, :caller] , [:message,:type] )
|
||||
@compiler = CompilerMock.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
|
@ -5,7 +5,7 @@ module Mom
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
@load = SlotLoad.new( [:message, :caller] , [:message, :caller , :type] )
|
||||
@compiler = CompilerMock.new
|
||||
@instruction = @load.to_risc(@compiler)
|
||||
|
@ -18,11 +18,27 @@ module Mom
|
||||
def test_has_translate
|
||||
assert @comp.translate(:interpreter)
|
||||
end
|
||||
end
|
||||
class TestClassCompilerTranslate < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@comp = compile_mom( "class Test ; def main(); return 1; end; end;")
|
||||
@trans = @comp.translate(:interpreter)
|
||||
end
|
||||
|
||||
def test_translate_class
|
||||
assert_equal Array , @comp.translate(:interpreter).class
|
||||
assert_equal Array , @trans.class
|
||||
end
|
||||
def test_translate_assemblers
|
||||
assert_equal Risc::Assembler , @comp.translate(:interpreter).first.class
|
||||
assert_equal Risc::Assembler , @trans.first.class
|
||||
end
|
||||
def test_assembler_code
|
||||
assert_equal Risc::Label , @trans.first.instructions.class
|
||||
end
|
||||
def test_assembler_assembled
|
||||
assert_equal Risc::LoadConstant , @trans.first.instructions.next.class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -97,6 +97,15 @@ module Parfait
|
||||
def test_has_next_address
|
||||
assert_equal Parfait::ReturnAddress , @space.next_address.next_integer.class
|
||||
end
|
||||
def test_address_count
|
||||
addr = @space.get_address
|
||||
count = 0
|
||||
while(addr)
|
||||
count += 1
|
||||
addr = addr.next_integer
|
||||
end
|
||||
assert_equal 10, count
|
||||
end
|
||||
|
||||
def test_messages
|
||||
mess = @space.first_message
|
||||
|
@ -4,7 +4,7 @@ module Parfait
|
||||
class TestEmptyWord < ParfaitTest
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@word = Parfait::Word.new(0)
|
||||
end
|
||||
def test_word_create
|
||||
|
@ -5,7 +5,6 @@ module Risc
|
||||
class TestBranchListenerBooted < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!
|
||||
DummyPlatform.boot
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@bin_pos = CodeListener.init(@binary).set(0)
|
||||
@label = Label.new("HI","ho" , FakeAddress.new(2))
|
||||
@ -26,7 +25,7 @@ module Risc
|
||||
assert @branch.precheck_called
|
||||
end
|
||||
end
|
||||
class TestBranchListenerPositioned < MiniTest::Test
|
||||
class TestBranchListenerPositioned #< MiniTest::Test
|
||||
def setup
|
||||
@machine = Risc.machine.boot
|
||||
@machine.translate(:interpreter)
|
||||
|
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module Risc
|
||||
class TestCodeListener < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@method = Parfait.object_space.types.values.first.methods
|
||||
@label = Risc.label("hi","ho")
|
||||
|
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module Risc
|
||||
class TestInstructionListener < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@bin_pos = Position.new(@binary).set(0)
|
||||
@instruction = DummyInstruction.new(DummyInstruction.new)
|
||||
|
@ -4,7 +4,7 @@ module Risc
|
||||
class TestLabelListener < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
@label = Label.new("Hi","Ho" , FakeAddress.new(5))
|
||||
@label_pos = Position.new(@label ).set(4)
|
||||
@code = Parfait::BinaryCode.new(1)
|
||||
|
@ -5,7 +5,7 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
init = Parfait.object_space.get_init
|
||||
@builder = Risc::MethodCompiler.new( init ).code_builder(init)
|
||||
@label = Risc.label("source","name")
|
||||
@ -102,7 +102,7 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
@init = Parfait.object_space.get_init
|
||||
@builder = Risc::MethodCompiler.new( @init ).compiler_builder(@init)
|
||||
end
|
||||
|
@ -5,30 +5,31 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@machine = Risc.machine.boot
|
||||
Risc.boot!
|
||||
@linker = Linker.new
|
||||
end
|
||||
|
||||
def test_simple_collect
|
||||
objects = Risc::Collector.collect_space
|
||||
objects = Collector.collect_space(@linker)
|
||||
assert ((400 < objects.length) or (450 > objects.length)) , objects.length.to_s
|
||||
end
|
||||
|
||||
def test_collect_all_types
|
||||
Risc::Collector.collect_space.each do |objekt , position|
|
||||
Collector.collect_space(@linker).each do |objekt , position|
|
||||
next unless objekt.is_a?( Parfait::Type )
|
||||
assert Parfait.object_space.get_type_for( objekt.hash ) , objekt.hash
|
||||
end
|
||||
end
|
||||
|
||||
def test_allowed_types
|
||||
Risc::Collector.collect_space.each do |objekt , position|
|
||||
Collector.collect_space(@linker).each do |objekt , position|
|
||||
next if objekt.is_a?( Parfait::Object )
|
||||
next if objekt.is_a?( Symbol )
|
||||
assert false
|
||||
end
|
||||
end
|
||||
def test_positions
|
||||
Risc::Collector.collect_space.each do |objekt , position|
|
||||
Collector.collect_space(@linker).each do |objekt , position|
|
||||
assert_equal Position , position.class
|
||||
assert !position.valid?
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.boot
|
||||
Risc.boot!
|
||||
@machine = Linker.new
|
||||
end
|
||||
def test_objects
|
||||
@ -19,22 +19,6 @@ module Risc
|
||||
def test_constant
|
||||
assert @machine.add_constant( Parfait::Integer.new(5) )
|
||||
end
|
||||
def test_address_get
|
||||
assert_equal Parfait::ReturnAddress , @machine.get_address.class
|
||||
end
|
||||
def test_address_is_constant
|
||||
addr = @machine.get_address
|
||||
assert @machine.constants.include?(addr)
|
||||
end
|
||||
def test_address_count
|
||||
addr = @machine.get_address
|
||||
count = 0
|
||||
while(addr)
|
||||
count += 1
|
||||
addr = addr.next_integer
|
||||
end
|
||||
assert_equal 5, count
|
||||
end
|
||||
end
|
||||
class TestMachinePos #< MiniTest::Test
|
||||
def setup
|
||||
|
@ -11,7 +11,6 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
@r0 = RegisterValue.new(:r0 , :Message)
|
||||
@r1 = RegisterValue.new(:r1 , :Space)
|
||||
end
|
||||
|
@ -4,11 +4,10 @@ module RubyX
|
||||
module RubyXHelper
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
end
|
||||
def ruby_to_risc(input , platform)
|
||||
mom = ruby_to_mom(input)
|
||||
puts "MOM #{mom.class}"
|
||||
mom.translate(platform)
|
||||
end
|
||||
def ruby_to_vool(input)
|
||||
|
@ -51,7 +51,7 @@ module Vool
|
||||
include RubyTests
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
end
|
||||
def compile_ct( input )
|
||||
lst = compile( input )
|
||||
|
@ -64,7 +64,7 @@ module Vool
|
||||
include RubyTests
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
end
|
||||
|
||||
def test_int_receiver
|
||||
|
@ -21,7 +21,7 @@ module Vool
|
||||
assert_equal true , @lst.has_yield?
|
||||
end
|
||||
def test_method_args
|
||||
Risc.machine.boot
|
||||
Parfait.boot!
|
||||
assert_equal 2 , @lst.make_arg_type.get_length
|
||||
end
|
||||
end
|
||||
|
@ -35,8 +35,8 @@ module MomCompile
|
||||
compile_to_mom(method , res.clazz.instance_type)
|
||||
end
|
||||
def compile_to_mom(method , for_type)
|
||||
typed_method = create_typed_method(for_type)
|
||||
source.to_mom( typed_method )
|
||||
typed_method = method.create_typed_method(for_type)
|
||||
method.source.to_mom( typed_method )
|
||||
end
|
||||
|
||||
def check_array( should , is )
|
||||
|
@ -8,7 +8,7 @@ module Risc
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
RubyX::RubyXCompiler.ruby_to_binary( @string_input , :interpreter)
|
||||
@interpreter = Interpreter.new
|
||||
@interpreter.start_machine
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
@ins = compile_first_method( "a = main(1 + 2)" )
|
||||
end
|
||||
|
||||
|
@ -7,7 +7,6 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
@ins = compile_first_method( "a = 5; a.div4")
|
||||
end
|
||||
def test_check_type
|
||||
|
@ -44,7 +44,7 @@ module Vool
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.machine.boot
|
||||
Risc.boot!
|
||||
@ins = compile_first_method( "return 5.div4")
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user