diff --git a/lib/mom/instruction/resolve_method.rb b/lib/mom/instruction/resolve_method.rb index f762da23..95d7fa46 100644 --- a/lib/mom/instruction/resolve_method.rb +++ b/lib/mom/instruction/resolve_method.rb @@ -20,6 +20,9 @@ module Mom @cache_entry = cache_entry end + def to_s + "ResolveMethod #{name}" + end # When the method is resolved, a cache_entry is used to hold the result. # That cache_entry (holding type and method) is checked before, and diff --git a/lib/parfait/typed_method.rb b/lib/parfait/typed_method.rb index cf7de6ed..0fb7acb1 100644 --- a/lib/parfait/typed_method.rb +++ b/lib/parfait/typed_method.rb @@ -44,10 +44,9 @@ module Parfait @arguments_type = arguments_type @frame_type = frame_type @binary = BinaryCode.new(0) - source = "_init_method" name = "#{@for_type.name}.#{@name}" - @risc_instructions = Risc.label(source, name) - @risc_instructions << Risc.label( source, "unreachable") + @risc_instructions = Risc.label(self, name) + @risc_instructions << Risc.label( self, "unreachable") end def translate_cpu(translator) diff --git a/lib/risc/boot.rb b/lib/risc/boot.rb index 21c74969..96954072 100644 --- a/lib/risc/boot.rb +++ b/lib/risc/boot.rb @@ -181,7 +181,7 @@ module Risc end obj = space.get_class_by_name(:Integer) - [ :putint, :mod4, :div10, :+ , :- , :*].each do |f| #mod4 is just a forward declaration + [ :putint, :div4, :div10, :+ , :- , :*].each do |f| #div4 is just a forward declaration obj.instance_type.add_method Builtin::Integer.send(f , nil) end end diff --git a/lib/risc/builtin/integer.rb b/lib/risc/builtin/integer.rb index 8eb9bcd9..23759ece 100644 --- a/lib/risc/builtin/integer.rb +++ b/lib/risc/builtin/integer.rb @@ -5,9 +5,9 @@ module Risc module ClassMethods include CompileHelper - def mod4(context) - source = "mod4" - compiler = compiler_for(:Integer,:mod4 ,{}) + def div4(context) + source = "div4" + compiler = compiler_for(:Integer,:div4 ,{}) builder = compiler.builder(true, compiler.method) me = builder.add_known( :receiver ) builder.reduce_int( source , me ) diff --git a/stash/parfait/test_integer.rb b/stash/parfait/test_integer.rb index 79cc4f5b..679e5731 100644 --- a/stash/parfait/test_integer.rb +++ b/stash/parfait/test_integer.rb @@ -3,28 +3,28 @@ require_relative 'helper' class TestPutiRT < MiniTest::Test include ParfaitTests - def test_mod4_2 - @main = "return 2.mod4()" + def test_div4_2 + @main = "return 2.div4()" check 2 % 4 end - def test_mod4_3 - @main = "return 3.mod4()" + def test_div4_3 + @main = "return 3.div4()" check 3 % 4 end - def test_mod4_4 - @main = "return 4.mod4()" + def test_div4_4 + @main = "return 4.div4()" check 4 % 4 end - def test_mod4_5 - @main = "return 5.mod4()" + def test_div4_5 + @main = "return 5.div4()" check 5 % 4 end - def test_mod4_12 - @main = "return 12.mod4()" + def test_div4_12 + @main = "return 12.div4()" check 12 % 4 end - def test_mod4_10 - @main = "return 10.mod4()" + def test_div4_10 + @main = "return 10.div4()" check 10 % 4 end diff --git a/test/bench/vm/integer.soml b/test/bench/vm/integer.soml index 8a442dfc..5b1a15a2 100644 --- a/test/bench/vm/integer.soml +++ b/test/bench/vm/integer.soml @@ -54,7 +54,7 @@ class Integer < Value return self end - int mod4() + int div4() return self & 3 end diff --git a/test/mom/assign/test_assign_local_send.rb b/test/mom/assign/test_assign_local_send.rb index 794732dd..10817e4f 100644 --- a/test/mom/assign/test_assign_local_send.rb +++ b/test/mom/assign/test_assign_local_send.rb @@ -6,7 +6,7 @@ module Risc def setup super - @input = "r = 5.mod4" + @input = "r = 5.div4" @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, diff --git a/test/mom/send/test_send_dynamic.rb b/test/mom/send/test_send_dynamic.rb index a9a4dad9..cdb9ec26 100644 --- a/test/mom/send/test_send_dynamic.rb +++ b/test/mom/send/test_send_dynamic.rb @@ -6,7 +6,7 @@ module Risc def setup super - @input = "@a.mod4" + @input = "@a.div4" @expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg, LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, diff --git a/test/mom/send/test_send_simple.rb b/test/mom/send/test_send_simple.rb index ee75c5dd..25f00f74 100644 --- a/test/mom/send/test_send_simple.rb +++ b/test/mom/send/test_send_simple.rb @@ -6,7 +6,7 @@ module Risc def setup super - @input = "5.mod4" + @input = "5.div4" @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, @@ -32,7 +32,7 @@ module Risc def test_function_call produced = produce_body assert_equal FunctionCall , produced.next(23).class - assert_equal :mod4 , produced.next(23).method.name + assert_equal :div4 , produced.next(23).method.name end def test_check_continue produced = produce_body diff --git a/test/mom/send/test_setup_simple.rb b/test/mom/send/test_setup_simple.rb index 860e6a43..d862aab1 100644 --- a/test/mom/send/test_setup_simple.rb +++ b/test/mom/send/test_setup_simple.rb @@ -7,7 +7,7 @@ module Risc def setup super - @input = "5.mod4" + @input = "5.div4" @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, @@ -22,7 +22,7 @@ module Risc def test_load_method method = @produced assert_load( method, Parfait::TypedMethod ,:r1) - assert_equal :mod4 , method.constant.name + assert_equal :div4 , method.constant.name end def test_load_space space = @produced.next(1) diff --git a/test/mom/test_return_call.rb b/test/mom/test_return_call.rb index f28c1643..d7d54cb4 100644 --- a/test/mom/test_return_call.rb +++ b/test/mom/test_return_call.rb @@ -6,7 +6,7 @@ module Risc def setup super - @input = "return 5.mod4" + @input = "return 5.div4" @expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, diff --git a/test/mom/test_return_dynamic.rb b/test/mom/test_return_dynamic.rb index 8e676f01..cc092794 100644 --- a/test/mom/test_return_dynamic.rb +++ b/test/mom/test_return_dynamic.rb @@ -6,7 +6,7 @@ module Risc def setup super - @input = "return @a.mod4" + @input = "return @a.div4" @expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, diff --git a/test/risc/interpreter/test_dynamic_call.rb b/test/risc/interpreter/test_dynamic_call.rb index bcd68d6b..47a58024 100644 --- a/test/risc/interpreter/test_dynamic_call.rb +++ b/test/risc/interpreter/test_dynamic_call.rb @@ -5,7 +5,7 @@ module Risc include Ticker def setup - @string_input = as_main("a = 5 ; return a.mod4") + @string_input = as_main("a = 5 ; return a.div4") super end diff --git a/test/risc/interpreter/test_mod.rb b/test/risc/interpreter/test_mod.rb index ff876d9a..90e6f49a 100644 --- a/test/risc/interpreter/test_mod.rb +++ b/test/risc/interpreter/test_mod.rb @@ -5,7 +5,7 @@ module Risc include Ticker def setup - @string_input = as_main "return 9.mod4" + @string_input = as_main "return 9.div4" super end diff --git a/test/vool/ruby_compiler/test_send_statement.rb b/test/vool/ruby_compiler/test_send_statement.rb index 55144b07..2eb5e885 100644 --- a/test/vool/ruby_compiler/test_send_statement.rb +++ b/test/vool/ruby_compiler/test_send_statement.rb @@ -66,7 +66,7 @@ module Vool end def test_int_receiver - sent = RubyCompiler.compile( "5.mod4") + sent = RubyCompiler.compile( "5.div4") assert_equal Parfait::Type , sent.receiver.ct_type.class assert_equal "Integer_Type" , sent.receiver.ct_type.name end diff --git a/test/vool/to_mom/send/test_send_cached_simple.rb b/test/vool/to_mom/send/test_send_cached_simple.rb index 0ae179ec..fcbdd67d 100644 --- a/test/vool/to_mom/send/test_send_cached_simple.rb +++ b/test/vool/to_mom/send/test_send_cached_simple.rb @@ -7,7 +7,7 @@ module Vool def setup Risc.machine.boot - @ins = compile_first_method( "a = 5; a.mod4") + @ins = compile_first_method( "a = 5; a.div4") end def test_check_type assert_equal NotSameCheck , @ins.next.class , @ins diff --git a/test/vool/to_mom/send/test_send_simple.rb b/test/vool/to_mom/send/test_send_simple.rb index d35a8068..d610df01 100644 --- a/test/vool/to_mom/send/test_send_simple.rb +++ b/test/vool/to_mom/send/test_send_simple.rb @@ -8,13 +8,13 @@ module Vool def setup Risc.machine.boot - @ins = compile_first_method( "5.mod4") + @ins = compile_first_method( "5.div4") end def receiver [Mom::IntegerConstant , 5] end def test_call_has_right_method - assert_equal :mod4, @ins.next(2).method.name + assert_equal :div4, @ins.next(2).method.name end end diff --git a/test/vool/to_mom/send/test_send_simple_args.rb b/test/vool/to_mom/send/test_send_simple_args.rb index e4e7a5f8..b81f0293 100644 --- a/test/vool/to_mom/send/test_send_simple_args.rb +++ b/test/vool/to_mom/send/test_send_simple_args.rb @@ -8,7 +8,7 @@ module Vool def setup Risc.machine.boot - @ins = compile_first_method( "5.mod4(1,2)") + @ins = compile_first_method( "5.div4(1,2)") end def receiver diff --git a/test/vool/to_mom/test_if_condition.rb b/test/vool/to_mom/test_if_condition.rb index 7d3b95e0..a2fe6035 100644 --- a/test/vool/to_mom/test_if_condition.rb +++ b/test/vool/to_mom/test_if_condition.rb @@ -8,7 +8,7 @@ module Vool def setup Risc.machine.boot - @ins = compile_first_method( "if(5.mod4) ; @a = 6 ; else; @a = 5 ; end") + @ins = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end") end def test_condition @@ -19,7 +19,7 @@ module Vool end def test_hoisted_dynamic_call assert_equal SimpleCall , @ins.next(2).class - assert_equal :mod4 , @ins.next(2).method.name + assert_equal :div4 , @ins.next(2).method.name end def test_array check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label , diff --git a/test/vool/to_mom/test_return.rb b/test/vool/to_mom/test_return.rb index a16e0c51..223eafa6 100644 --- a/test/vool/to_mom/test_return.rb +++ b/test/vool/to_mom/test_return.rb @@ -44,7 +44,7 @@ module Vool def setup Risc.machine.boot - @ins = compile_first_method( "return 5.mod4") + @ins = compile_first_method( "return 5.div4") end def test_return_is_last diff --git a/test/vool/to_mom/test_while_condition.rb b/test/vool/to_mom/test_while_condition.rb index fc0c8225..6536baf2 100644 --- a/test/vool/to_mom/test_while_condition.rb +++ b/test/vool/to_mom/test_while_condition.rb @@ -8,7 +8,7 @@ module Vool def setup Risc.machine.boot - @ins = compile_first_method( "while(5.mod4) ; 5.mod4 ; end") + @ins = compile_first_method( "while(5.div4) ; 5.div4 ; end") end def test_condition_compiles_to_check