vool working after message change
This commit is contained in:
parent
0a1b05b2ee
commit
0c49612e5e
@ -10,7 +10,9 @@ module Vool
|
||||
# Only snag is that we do not know this position, as only the compiler knows
|
||||
# if the variable name is a local or an arg. So we delegate to the compiler.
|
||||
def slot_position( compiler )
|
||||
compiler.slot_type_for(@name)
|
||||
slot = compiler.slot_type_for(@name)
|
||||
#puts "SLOT= #{slot}"
|
||||
slot
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -46,10 +46,10 @@ module Vool
|
||||
def message_setup(compiler,called_method)
|
||||
setup = Mom::MessageSetup.new( called_method )
|
||||
mom_receive = @receiver.to_slot(compiler)
|
||||
arg_target = [:message , :next_message , :arguments]
|
||||
arg_target = [:message , :next_message ]
|
||||
args = []
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.to_slot(compiler))
|
||||
args << Mom::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot(compiler))
|
||||
end
|
||||
setup << Mom::ArgumentTransfer.new(self, mom_receive , args )
|
||||
end
|
||||
|
@ -50,10 +50,10 @@ module Vool
|
||||
arg_index = compiler.get_method.arguments_type.get_length - 1
|
||||
setup = Mom::MessageSetup.new( arg_index )
|
||||
mom_receive = @receiver.to_slot(compiler)
|
||||
arg_target = [:message , :next_message , :arguments]
|
||||
arg_target = [:message , :next_message ]
|
||||
args = []
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
args << Mom::SlotLoad.new(self, arg_target + [index + 1] , arg.to_slot(compiler))
|
||||
args << Mom::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot(compiler))
|
||||
end
|
||||
setup << Mom::ArgumentTransfer.new( self , mom_receive , args )
|
||||
setup << Mom::BlockYield.new( self , arg_index )
|
||||
|
@ -60,7 +60,7 @@ module VoolBlocks
|
||||
assert @ins.left
|
||||
end
|
||||
def test_slots_left
|
||||
assert_equal [:caller,:caller, :arguments, :arg] , @ins.left.slots
|
||||
assert_equal [:caller,:caller, :arg1] , @ins.left.slots
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ module Vool
|
||||
left = @ins.next(1).arguments[0].left
|
||||
assert_equal Symbol, left.known_object.class
|
||||
assert_equal :message, left.known_object
|
||||
assert_equal [:next_message, :arguments, 1], left.slots
|
||||
assert_equal [:next_message, :arg1], left.slots
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ module Vool
|
||||
end
|
||||
def test_args_two_move
|
||||
assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0]
|
||||
assert_equal :arguments, @ins.next(1).arguments[1].left.slots[1]
|
||||
assert_equal :arg2, @ins.next(1).arguments[1].left.slots[1]
|
||||
end
|
||||
def test_args_two_str
|
||||
assert_equal Mom::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class
|
||||
|
@ -13,12 +13,12 @@ module Vool
|
||||
|
||||
def test_args_one_move
|
||||
assert_equal :next_message, @ins.next.arguments[0].left.slots[0]
|
||||
assert_equal :arguments, @ins.next.arguments[0].left.slots[1]
|
||||
assert_equal :arg1, @ins.next.arguments[0].left.slots[1]
|
||||
end
|
||||
def test_args_one_str
|
||||
assert_equal Mom::IntegerConstant, @ins.next.arguments[0].right.known_object.class
|
||||
assert_equal 1, @ins.next.arguments[0].right.known_object.value
|
||||
assert_equal [:next_message, :arguments, 1], @ins.next.arguments[0].left.slots
|
||||
assert_equal [:next_message, :arg1], @ins.next.arguments[0].left.slots
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -65,11 +65,8 @@ module Vool
|
||||
def test_slot_starts_at_message
|
||||
assert_equal :message , @ins.left.known_object
|
||||
end
|
||||
def test_slot_gets_self
|
||||
assert_equal :arguments , @ins.left.slots[0]
|
||||
end
|
||||
def test_slot_assigns_to_local
|
||||
assert_equal :arg , @ins.left.slots[-1]
|
||||
def test_slot_gets_arg
|
||||
assert_equal :arg1 , @ins.left.slots[0]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -35,4 +35,34 @@ module Vool
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
class TestArgMom < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = compile_first_method( "arg = 5")
|
||||
@ins = @compiler.mom_instructions.next
|
||||
end
|
||||
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
end
|
||||
def test_slot_starts_at_message
|
||||
assert_equal :message , @ins.left.known_object
|
||||
end
|
||||
def test_slot_gets_arg
|
||||
assert_equal :arg1 , @ins.left.slots[0]
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @ins.right
|
||||
end
|
||||
def test_slot_assigns_int
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ module Vool
|
||||
left = @ins.next(3).arguments[0].left
|
||||
assert_equal Symbol, left.known_object.class
|
||||
assert_equal :message, left.known_object
|
||||
assert_equal [:next_message, :arguments, 1], left.slots
|
||||
assert_equal [:next_message, :arg1], left.slots
|
||||
end
|
||||
def test_check_left
|
||||
assert_equal SlotDefinition, @ins.left.class
|
||||
|
Loading…
Reference in New Issue
Block a user