risc is GREEN
totally, man. Small fix in method missing fixed last block tests (why, i do not know)
This commit is contained in:
parent
37feba1239
commit
90935bfbbc
@ -266,7 +266,7 @@ module Risc
|
||||
set_instruction(nil)
|
||||
return false
|
||||
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
|
||||
raise "un-implemented syscall #{name}"
|
||||
end
|
||||
|
@ -1,19 +1,18 @@
|
||||
module SlotMachine
|
||||
class MethodMissing < Macro
|
||||
attr_reader :name
|
||||
attr_reader :name_reg
|
||||
|
||||
def initialize( source , name )
|
||||
def initialize( source , name_reg )
|
||||
super(source)
|
||||
name = name.value if name.is_a?(Sol::SymbolConstant)
|
||||
raise "No reg #{name.class}" unless name.class == Symbol
|
||||
@name = name
|
||||
name_reg = Risc::RegisterValue.new(name_reg , :Word) if name_reg.class == Symbol
|
||||
raise "No reg #{name_reg.class}" unless name_reg.is_a? Risc::RegisterValue
|
||||
@name_reg = name_reg
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
builder = compiler.builder(compiler.source_name)
|
||||
from = compiler.load_object(Parfait.new_word_max(@name))
|
||||
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 )
|
||||
return compiler
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ module Risc
|
||||
SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, #10
|
||||
LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15
|
||||
SlotToReg, LoadConstant, OperatorInstruction, IsZero, SlotToReg, #20
|
||||
OperatorInstruction, IsZero, RegToSlot, Branch, LoadConstant, #25
|
||||
OperatorInstruction, IsZero, RegToSlot, LoadConstant, Branch, #25
|
||||
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #30
|
||||
RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, #35
|
||||
RegToSlot, SlotToReg, DynamicJump, LoadConstant, LoadConstant, #40
|
||||
|
@ -10,7 +10,7 @@ module SlotMachine
|
||||
ResolveMethod.new( "method" , :name , cache_entry )
|
||||
end
|
||||
def test_len
|
||||
assert_equal 21 , all.length , all_str
|
||||
assert_equal 20 , all.length , all_str
|
||||
end
|
||||
def test_load_name
|
||||
assert_load 1, Parfait::Word , "id_word_"
|
||||
@ -58,21 +58,17 @@ module SlotMachine
|
||||
def test_goto_exit
|
||||
assert_label 15, "exit_label_"
|
||||
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
|
||||
assert_transfer 17, "id_word_" , :r1
|
||||
assert_transfer 16, "id_word_" , :r1
|
||||
end
|
||||
def test_sys
|
||||
assert_syscall 18, :died
|
||||
assert_syscall 17, :died
|
||||
end
|
||||
def test_label
|
||||
assert_label 19, "ok_label_"
|
||||
assert_label 18, "ok_label_"
|
||||
end
|
||||
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
|
||||
|
@ -14,19 +14,18 @@ module SlotMachine
|
||||
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
||||
end
|
||||
def test_risc_length
|
||||
assert_equal 15 , @method.to_risc.risc_instructions.length
|
||||
assert_equal 14 , @method.to_risc.risc_instructions.length
|
||||
end
|
||||
def test_all
|
||||
assert_load 1 , Parfait::Word , "id_word_"
|
||||
assert_transfer 2 , "id_word_" , :r1
|
||||
assert_syscall 3 , :died
|
||||
assert_slot_to_reg 4 , :message , 5 , "message.return_value"
|
||||
assert_reg_to_slot 5 , "message.return_value" , :message , 5
|
||||
assert_branch 6 , "return_label"
|
||||
assert_label 7 , "return_label"
|
||||
assert_transfer 1 , :r1 , :r1
|
||||
assert_syscall 2 , :died
|
||||
assert_slot_to_reg 3 , :message , 5 , "message.return_value"
|
||||
assert_reg_to_slot 4 , "message.return_value" , :message , 5
|
||||
assert_branch 5 , "return_label"
|
||||
assert_label 6 , "return_label"
|
||||
end
|
||||
def test_return
|
||||
assert_return(7)
|
||||
assert_return(6)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user