some renaming, start on cached
cached stalled for now, continue down to rise with what is first
This commit is contained in:
parent
a3a31ba38d
commit
be1481ce34
@ -33,16 +33,16 @@ module Vool
|
|||||||
# FIXME: we now presume direct (assignable) values for the arguments and receiver.
|
# FIXME: we now presume direct (assignable) values for the arguments and receiver.
|
||||||
# in a not so distant future, temporary variables will have to be created
|
# in a not so distant future, temporary variables will have to be created
|
||||||
# and complex statements hoisted to assign to them. pps: same as in conditions
|
# and complex statements hoisted to assign to them. pps: same as in conditions
|
||||||
def to_mom( method )
|
def to_mom( in_method )
|
||||||
if(@receiver.ct_type)
|
if(@receiver.ct_type)
|
||||||
simple_call(method)
|
simple_call(in_method)
|
||||||
else
|
else
|
||||||
cached_call(method)
|
cached_call(in_method)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def message_setup(method)
|
def message_setup(in_method)
|
||||||
setup = [Mom::MessageSetup.new(method)]
|
setup = [Mom::MessageSetup.new(in_method)]
|
||||||
receiver = @receiver.slot_class.new([:message , :next_message , :receiver] , @receiver)
|
receiver = @receiver.slot_class.new([:message , :next_message , :receiver] , @receiver)
|
||||||
arg_target = [:message , :next_message , :arguments]
|
arg_target = [:message , :next_message , :arguments]
|
||||||
args = []
|
args = []
|
||||||
@ -52,16 +52,16 @@ module Vool
|
|||||||
setup << Mom::ArgumentTransfer.new( receiver , args )
|
setup << Mom::ArgumentTransfer.new( receiver , args )
|
||||||
end
|
end
|
||||||
|
|
||||||
def simple_call(method)
|
def simple_call(in_method)
|
||||||
type = @receiver.ct_type
|
type = @receiver.ct_type
|
||||||
method = type.resolve_method(@name)
|
called_method = type.resolve_method(@name)
|
||||||
raise "No method #{@name} for #{type}" unless method
|
raise "No method #{@name} for #{type}" unless called_method
|
||||||
Mom::Statements.new( message_setup(method) << Mom::SimpleCall.new( method) )
|
Mom::Statements.new( message_setup(in_method) << Mom::SimpleCall.new( called_method) )
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_call(method)
|
def cached_call(method)
|
||||||
raise "Not implemented #{method}"
|
raise "Not implemented #{method}"
|
||||||
Mom::Statements.new( message_setup + call_instruction )
|
Mom::Statements.new( message_setup(method) + call_instruction )
|
||||||
[@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
|
[@receiver.slot_class.new([:message , :next_message , :receiver] , @receiver) ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
45
test/vool/to_mom/send/test_send_cached_simple.rb
Normal file
45
test/vool/to_mom/send/test_send_cached_simple.rb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
require_relative "../helper"
|
||||||
|
|
||||||
|
module Vool
|
||||||
|
class TestSendCachedSimpleMom < MiniTest::Test
|
||||||
|
include MomCompile
|
||||||
|
|
||||||
|
def setup
|
||||||
|
Risc.machine.boot
|
||||||
|
@stats = compile_first_method( "arg.mod4").first
|
||||||
|
@first = @stats.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def est_compiles_not_array
|
||||||
|
assert Array != @stats.class , @stats
|
||||||
|
end
|
||||||
|
def est_class_compiles
|
||||||
|
assert_equal Mom::SlotConstant , @first.class , @stats
|
||||||
|
end
|
||||||
|
def est_slot_is_set
|
||||||
|
assert @stats.first.left
|
||||||
|
end
|
||||||
|
def est_two_instructions_are_returned
|
||||||
|
assert_equal 2 , @stats.length
|
||||||
|
end
|
||||||
|
def est_receiver_move_class
|
||||||
|
assert_equal Mom::SlotConstant, @first.class
|
||||||
|
end
|
||||||
|
def est_receiver_move
|
||||||
|
assert_equal :receiver, @first.left[2]
|
||||||
|
end
|
||||||
|
def est_receiver
|
||||||
|
assert_equal IntegerStatement, @first.right.class
|
||||||
|
assert_equal 5, @stats.first.right.value
|
||||||
|
end
|
||||||
|
def est_call_is
|
||||||
|
assert_equal Mom::SimpleCall, @stats[1].class
|
||||||
|
end
|
||||||
|
def est_call_has_method
|
||||||
|
assert_equal Parfait::TypedMethod, @stats[1].method.class
|
||||||
|
end
|
||||||
|
def est_call_has_right_method
|
||||||
|
assert_equal :mod4, @stats[1].method.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user