fix insertion and add assign send
must implement send conversion before this makes sense
This commit is contained in:
parent
66a160d8ab
commit
c0a7f1d284
@ -93,11 +93,12 @@ module Risc
|
||||
# continue down the instruction chain unti depleted
|
||||
# (adding moves the insertion point so the whole mom chain is added as a risc chain)
|
||||
def add_mom( instruction )
|
||||
raise "whats this a #{instruction}" unless instruction.is_a?(Mom::Instruction)
|
||||
while( instruction )
|
||||
#puts "adding #{instruction.to_s}:#{instruction.next.to_s}"
|
||||
raise "whats this a #{instruction}" unless instruction.is_a?(Mom::Instruction)
|
||||
#puts "adding mom #{instruction.to_s}:#{instruction.next.to_s}"
|
||||
risc = instruction.to_risc( self )
|
||||
add_code(risc)
|
||||
#puts "adding risc #{risc.to_s}:#{risc.next.to_s}"
|
||||
instruction = instruction.next
|
||||
end
|
||||
end
|
||||
@ -106,8 +107,9 @@ module Risc
|
||||
def add_code( instruction )
|
||||
raise "Not an instruction:#{instruction.to_s}" unless instruction.is_a?(Risc::Instruction)
|
||||
raise instruction.to_s if( instruction.class.name.split("::").first == "Arm")
|
||||
new_current = instruction.last #after insertion this point is lost
|
||||
@current.insert(instruction) #insert after current
|
||||
@current = instruction.last
|
||||
@current = new_current
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Risc
|
||||
class TestLocalAssign < MiniTest::Test
|
||||
class TestAssignLocalConst < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def setup
|
28
test/mom/test_assign_local_send.rb
Normal file
28
test/mom/test_assign_local_send.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Risc
|
||||
class TestAssignLocalSend < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "r = 5.mod4"
|
||||
@expect = [Label, LoadConstant, RegToSlot, Label, Label, SlotToReg ,
|
||||
RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def ttest_constant_load
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.constant.known_object.value
|
||||
end
|
||||
|
||||
def ttest_slot_move
|
||||
produced = produce_body
|
||||
assert_equal produced.next.register , produced.register
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user