first resolved call running though

and returning an int, as it should
just the value .  .  .
This commit is contained in:
Torsten Ruger 2018-04-08 23:45:23 +03:00
parent fabe4db4f6
commit 59e6298879
4 changed files with 50 additions and 20 deletions

View File

@ -27,12 +27,24 @@ module Mom
# Move method name, frame and arguemnt types from the method to the next_message # Move method name, frame and arguemnt types from the method to the next_message
# Get the message from Space and link it. # Get the message from Space and link it.
def to_risc(compiler) def to_risc(compiler)
build_with(compiler.builder(false)) builder = compiler.builder(false)
build_with(builder)
end end
# directly called by to_risc # directly called by to_risc
# but also used directly in __init # but also used directly in __init
def build_with(builder) def build_with(builder)
case from = method_source
when Parfait::TypedMethod
builder.build { typed_method << from }
when Parfait::CacheEntry
builder.build do
cache_entry << from
typed_method << cache_entry[:cached_method]
end
else
raise "unknown source #{method_source}"
end
build_message_data(builder) build_message_data(builder)
return builder.built return builder.built
end end
@ -46,9 +58,7 @@ module Mom
# also put it into next_message of current message (and reverse) # also put it into next_message of current message (and reverse)
# set name and type data in the message, from the method loaded # set name and type data in the message, from the method loaded
def build_message_data( builder ) def build_message_data( builder )
from = method_source
builder.build do builder.build do
typed_method << from
space << Parfait.object_space space << Parfait.object_space
next_message << space[:first_message] next_message << space[:first_message]
message[:next_message] << next_message message[:next_message] << next_message

View File

@ -91,11 +91,11 @@ module Risc
def execute_Label def execute_Label
true true
end end
# Instruction interpretation starts here # Instruction interpretation starts here
def execute_DynamicJump def execute_DynamicJump
label = get_register(@instruction.register) method = get_register(@instruction.register)
puts "Jump to :#{label}:" set_instruction( method.risc_instructions )
set_instruction label
end end
def execute_Branch def execute_Branch
label = @instruction.label label = @instruction.label

View File

@ -15,11 +15,11 @@ module Risc
Branch, Label, Transfer, Syscall, Transfer, Branch, Label, Transfer, Syscall, Transfer,
Transfer, LoadConstant, SlotToReg, SlotToReg, RegToSlot, Transfer, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, Label, RegToSlot, Label, RegToSlot, RegToSlot, Label, RegToSlot, Label,
LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, DynamicJump] LoadConstant, SlotToReg, DynamicJump]
end end
def test_send_instructions def test_send_instructions
@ -37,7 +37,7 @@ module Risc
end end
def test_function_call def test_function_call
produced = produce_body produced = produce_body
assert_equal DynamicJump , produced.next(61).class assert_equal DynamicJump , produced.next(62).class
end end
def test_cache_check def test_cache_check
produced = produce_body produced = produce_body

View File

@ -12,14 +12,34 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
SlotToReg, SlotToReg, LoadConstant, RegToSlot, LoadConstant, IsZero, SlotToReg, SlotToReg, SlotToReg, LoadConstant,
LoadConstant, SlotToReg, SlotToReg, Label, LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, OperatorInstruction, IsZero, SlotToReg, OperatorInstruction, Label, LoadConstant, SlotToReg, OperatorInstruction, IsZero,
IsZero, SlotToReg, Branch, Label, LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch,
SlotToReg, OperatorInstruction, IsZero, Label, Transfer, Label, LoadConstant, SlotToReg, OperatorInstruction, IsZero,
Syscall, NilClass] SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch,
#assert_equal 1 , get_return Label, LoadConstant, SlotToReg, OperatorInstruction, IsZero,
SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch,
Label, LoadConstant, SlotToReg, OperatorInstruction, IsZero,
SlotToReg, OperatorInstruction, IsZero, Label, RegToSlot,
Label, LoadConstant, SlotToReg, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, DynamicJump, Label,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, LoadData, OperatorInstruction, LoadData, OperatorInstruction,
OperatorInstruction, LoadData, Transfer, OperatorInstruction, OperatorInstruction,
LoadData, Transfer, OperatorInstruction, OperatorInstruction, LoadData,
Transfer, OperatorInstruction, OperatorInstruction, LoadData, OperatorInstruction,
LoadData, Transfer, OperatorInstruction, OperatorInstruction, Transfer,
LoadData, OperatorInstruction, LoadData, OperatorInstruction, OperatorInstruction,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, FunctionReturn, Transfer, Syscall, NilClass]
assert_equal Parfait::Integer , get_return.class
#assert_equal 1 , get_return.value
end end
def test_call_main def test_call_main