converted resolve_method
Big, left till last, but surprisingly painless
This commit is contained in:
parent
12fe0b9a10
commit
c1cfc12a1c
@ -37,35 +37,34 @@ module SlotMachine
|
||||
#
|
||||
# currently a fail results in sys exit
|
||||
def to_risc( compiler )
|
||||
name_ = @name
|
||||
cache_entry_ = @cache_entry
|
||||
builder = compiler.builder(self)
|
||||
word = builder.load_object(Parfait.new_word(@name.to_s))
|
||||
entry = builder.load_object(@cache_entry)
|
||||
while_start_label = Risc.label(to_s, "while_start_label_#{object_id}")
|
||||
ok_label = Risc.label(to_s, "ok_label_#{object_id}")
|
||||
exit_label = Risc.label(to_s, "exit_label_#{object_id}")
|
||||
builder.build do
|
||||
word! << name_
|
||||
cache_entry! << cache_entry_
|
||||
|
||||
type! << cache_entry[:cached_type]
|
||||
callable_method! << type[:methods]
|
||||
callable_method = entry[:cached_type][:methods].to_reg
|
||||
|
||||
add_code while_start_label
|
||||
|
||||
object! << Parfait.object_space.nil_object
|
||||
object - callable_method
|
||||
object = load_object Parfait.object_space.nil_object
|
||||
object.op :- , callable_method
|
||||
if_zero exit_label
|
||||
|
||||
name! << callable_method[:name]
|
||||
name - word
|
||||
name = callable_method[:name].to_reg
|
||||
name.op :- , word
|
||||
|
||||
if_zero ok_label
|
||||
|
||||
callable_method << callable_method[:next_callable]
|
||||
callable_method = callable_method[:next_callable].to_reg
|
||||
branch while_start_label
|
||||
|
||||
add_code exit_label
|
||||
MethodMissing.new(compiler.source_name , word.symbol).to_risc(compiler)
|
||||
|
||||
add_code ok_label
|
||||
cache_entry[:cached_method] << callable_method
|
||||
entry[:cached_method] << callable_method
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -9,46 +9,45 @@ module SlotMachine
|
||||
cache_entry = Parfait::CacheEntry.new(method.frame_type, method)
|
||||
ResolveMethod.new( "method" , :name , cache_entry )
|
||||
end
|
||||
def test_len
|
||||
def est_len
|
||||
assert_equal 19 , all.length , all_str
|
||||
end
|
||||
def test_1_load_name
|
||||
assert_load 1, Symbol , :r1
|
||||
assert_equal :name , risc(1).constant
|
||||
assert_load 1, Parfait::Word , "id_word_"
|
||||
assert_equal "name" , risc(1).constant.to_string
|
||||
end
|
||||
def test_2_load_cache
|
||||
assert_load 2, Parfait::CacheEntry , :r2
|
||||
assert_load 2, Parfait::CacheEntry , "id_cacheentry_"
|
||||
end
|
||||
def test_3_get_cache_type
|
||||
assert_slot_to_reg 3,:r2 , 1 , :r3
|
||||
assert_slot_to_reg 3 , "id_cacheentry_" , 1 , "id_cacheentry_.cached_type"
|
||||
end
|
||||
def test_4_get_type_methods
|
||||
assert_slot_to_reg 4,:r3 , 4 , :r4
|
||||
assert_slot_to_reg 4 , "id_cacheentry_.cached_type" , 4 , "id_cacheentry_.cached_type.methods"
|
||||
end
|
||||
def test_5_start_label
|
||||
assert_label 5, "while_start_"
|
||||
assert_label 5 , "while_start_"
|
||||
end
|
||||
def test_6_load_nil
|
||||
assert_load 6, Parfait::NilClass , :r5
|
||||
assert_load 6, Parfait::NilClass , "id_nilclass_"
|
||||
end
|
||||
def test_7_check_nil
|
||||
assert_operator 7, :- , :r5 , :r4
|
||||
assert_operator 7, :- , "id_nilclass_" , "id_cacheentry_.cached_type.methods"
|
||||
end
|
||||
def test_8_nil_branch
|
||||
assert_zero 8, "exit_label_"
|
||||
end
|
||||
def test_9_get_method_name
|
||||
assert_slot_to_reg 9,:r4 , 6 , :r6
|
||||
assert_slot_to_reg 9, "id_cacheentry_.cached_type.methods" , 6 , "id_cacheentry_.cached_type.methods.name"
|
||||
end
|
||||
# Syscall, Label, RegToSlot,] #20
|
||||
def test_10_check_name
|
||||
assert_operator 10, :- , :r6 , :r1
|
||||
assert_operator 10, :- , "id_cacheentry_.cached_type.methods.name" , "id_word_"
|
||||
end
|
||||
def test_11_nil_branch
|
||||
assert_zero 11, "ok_label_"
|
||||
end
|
||||
def test_12_get_next_method
|
||||
assert_slot_to_reg 12,:r4 , 2 , :r4
|
||||
assert_slot_to_reg 12, "id_cacheentry_.cached_type.methods" , 2 , "id_cacheentry_.cached_type.methods.next_callable"
|
||||
end
|
||||
def test_13_continue_while
|
||||
assert_branch 13, "while_start_"
|
||||
@ -57,7 +56,7 @@ module SlotMachine
|
||||
assert_label 14, "exit_label_"
|
||||
end
|
||||
def test_15_move_name
|
||||
assert_transfer( 15, :r1 , :r1)
|
||||
assert_transfer 15, "id_word_" , :r1
|
||||
end
|
||||
def test_16_die
|
||||
assert_syscall 16, :died
|
||||
@ -66,7 +65,7 @@ module SlotMachine
|
||||
assert_label 17, "ok_label_"
|
||||
end
|
||||
def test_18_load_method
|
||||
assert_reg_to_slot 18, :r4 , :r2 , 2
|
||||
assert_reg_to_slot 18 , "id_cacheentry_.cached_type.methods.next_callable" , "id_cacheentry_" , 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user