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