risc is GREEN

totally, man.
Small fix in method missing fixed last block tests
(why, i do not know)
This commit is contained in:
Torsten 2020-03-22 15:58:19 +02:00
parent 37feba1239
commit 90935bfbbc
5 changed files with 21 additions and 27 deletions

View File

@ -266,7 +266,7 @@ module Risc
set_instruction(nil) set_instruction(nil)
return false return false
when :died when :died
raise "Method #{@registers[std_reg(:syscall_2)]} not found for #{@registers[std_reg(:syscall_2)]}" raise "Method #{@registers[:r1].to_string} not found for #{@registers[std_reg(:syscall_1)]}"
else else
raise "un-implemented syscall #{name}" raise "un-implemented syscall #{name}"
end end

View File

@ -1,19 +1,18 @@
module SlotMachine module SlotMachine
class MethodMissing < Macro class MethodMissing < Macro
attr_reader :name attr_reader :name_reg
def initialize( source , name ) def initialize( source , name_reg )
super(source) super(source)
name = name.value if name.is_a?(Sol::SymbolConstant) name_reg = Risc::RegisterValue.new(name_reg , :Word) if name_reg.class == Symbol
raise "No reg #{name.class}" unless name.class == Symbol raise "No reg #{name_reg.class}" unless name_reg.is_a? Risc::RegisterValue
@name = name @name_reg = name_reg
end end
def to_risc(compiler) def to_risc(compiler)
builder = compiler.builder(compiler.source_name) builder = compiler.builder(compiler.source_name)
from = compiler.load_object(Parfait.new_word_max(@name))
to = Risc::RegisterValue.new(:r1 , :Word) to = Risc::RegisterValue.new(:r1 , :Word)
builder.add_code Risc::Transfer.new(self , from , to) builder.add_code Risc::Transfer.new(self , name_reg , to)
builder.add_code Risc::Syscall.new(self, :died ) builder.add_code Risc::Syscall.new(self, :died )
return compiler return compiler
end end

View File

@ -16,7 +16,7 @@ module Risc
SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, #10 SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, #10
LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15 LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15
SlotToReg, LoadConstant, OperatorInstruction, IsZero, SlotToReg, #20 SlotToReg, LoadConstant, OperatorInstruction, IsZero, SlotToReg, #20
OperatorInstruction, IsZero, RegToSlot, Branch, LoadConstant, #25 OperatorInstruction, IsZero, RegToSlot, LoadConstant, Branch, #25
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #30 SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #30
RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, #35 RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, #35
RegToSlot, SlotToReg, DynamicJump, LoadConstant, LoadConstant, #40 RegToSlot, SlotToReg, DynamicJump, LoadConstant, LoadConstant, #40

View File

@ -10,7 +10,7 @@ module SlotMachine
ResolveMethod.new( "method" , :name , cache_entry ) ResolveMethod.new( "method" , :name , cache_entry )
end end
def test_len def test_len
assert_equal 21 , all.length , all_str assert_equal 20 , all.length , all_str
end end
def test_load_name def test_load_name
assert_load 1, Parfait::Word , "id_word_" assert_load 1, Parfait::Word , "id_word_"
@ -58,21 +58,17 @@ module SlotMachine
def test_goto_exit def test_goto_exit
assert_label 15, "exit_label_" assert_label 15, "exit_label_"
end end
def test_load_name2
assert_load 16, Parfait::Word , "id_word_"
assert_equal "name" , risc(1).constant.to_string
end
def test_move_name def test_move_name
assert_transfer 17, "id_word_" , :r1 assert_transfer 16, "id_word_" , :r1
end end
def test_sys def test_sys
assert_syscall 18, :died assert_syscall 17, :died
end end
def test_label def test_label
assert_label 19, "ok_label_" assert_label 18, "ok_label_"
end end
def test_method def test_method
assert_reg_to_slot 20 , "id_cacheentry_.cached_type.methods" , "id_cacheentry_" , 2 assert_reg_to_slot 19 , "id_cacheentry_.cached_type.methods" , "id_cacheentry_" , 2
end end
end end
end end

View File

@ -14,19 +14,18 @@ module SlotMachine
assert_equal Risc::MethodCompiler , @method.to_risc.class assert_equal Risc::MethodCompiler , @method.to_risc.class
end end
def test_risc_length def test_risc_length
assert_equal 15 , @method.to_risc.risc_instructions.length assert_equal 14 , @method.to_risc.risc_instructions.length
end end
def test_all def test_all
assert_load 1 , Parfait::Word , "id_word_" assert_transfer 1 , :r1 , :r1
assert_transfer 2 , "id_word_" , :r1 assert_syscall 2 , :died
assert_syscall 3 , :died assert_slot_to_reg 3 , :message , 5 , "message.return_value"
assert_slot_to_reg 4 , :message , 5 , "message.return_value" assert_reg_to_slot 4 , "message.return_value" , :message , 5
assert_reg_to_slot 5 , "message.return_value" , :message , 5 assert_branch 5 , "return_label"
assert_branch 6 , "return_label" assert_label 6 , "return_label"
assert_label 7 , "return_label"
end end
def test_return def test_return
assert_return(7) assert_return(6)
end end
end end
end end