no-ops really
This commit is contained in:
parent
a2e7d7c469
commit
f5d1090c39
@ -1,7 +1,7 @@
|
|||||||
# A sample Guardfile
|
# A sample Guardfile
|
||||||
# More info at https://github.com/guard/guard#readme
|
# More info at https://github.com/guard/guard#readme
|
||||||
|
|
||||||
guard :minitest do # with Minitest::Unit
|
guard :minitest , all_on_start: false do # with Minitest::Unit
|
||||||
|
|
||||||
# if any test file changes, run that test
|
# if any test file changes, run that test
|
||||||
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
||||||
|
@ -14,6 +14,7 @@ module Risc
|
|||||||
class Instruction
|
class Instruction
|
||||||
def nil_next
|
def nil_next
|
||||||
@next = nil
|
@next = nil
|
||||||
|
self
|
||||||
end
|
end
|
||||||
def byte_length
|
def byte_length
|
||||||
4
|
4
|
||||||
@ -30,12 +31,13 @@ module Risc
|
|||||||
end
|
end
|
||||||
class IdentityTranslator
|
class IdentityTranslator
|
||||||
def translate(code)
|
def translate(code)
|
||||||
#return Label.new( code.source , code.name ) if code.is_a?(Label)
|
case code
|
||||||
if( code.is_a?(Branch))
|
when Branch
|
||||||
return code.class.new(code.source , code.label.to_cpu(self))
|
ret = code.class.new(code.source , code.label.to_cpu(self))
|
||||||
end
|
else
|
||||||
ret = code.dup
|
ret = code.dup
|
||||||
ret.nil_next
|
ret.nil_next
|
||||||
|
end
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ module Risc
|
|||||||
|
|
||||||
class Machine
|
class Machine
|
||||||
include Util::Logging
|
include Util::Logging
|
||||||
log_level :debug
|
log_level :info
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@booted = false
|
@booted = false
|
||||||
|
@ -16,7 +16,7 @@ module Risc
|
|||||||
|
|
||||||
module Position
|
module Position
|
||||||
include Util::Logging
|
include Util::Logging
|
||||||
log_level :debug
|
log_level :info
|
||||||
|
|
||||||
@positions = {}
|
@positions = {}
|
||||||
|
|
||||||
|
@ -24,11 +24,14 @@ module Risc
|
|||||||
preamble.each{ produced = produced.next }
|
preamble.each{ produced = produced.next }
|
||||||
produced
|
produced
|
||||||
end
|
end
|
||||||
|
def as_test_main
|
||||||
|
"class Test; def main(arg);#{@input};end;end"
|
||||||
|
end
|
||||||
def produce_instructions
|
def produce_instructions
|
||||||
assert @expect , "No output given"
|
assert @expect , "No output given"
|
||||||
Vool::VoolCompiler.ruby_to_vool "class Test; def main(arg);#{@input};end;end"
|
Vool::VoolCompiler.ruby_to_binary as_test_main , :interpreter
|
||||||
test = Parfait.object_space.get_class_by_name :Test
|
test = Parfait.object_space.get_class_by_name :Test
|
||||||
test.instance_type.get_method( :main).risc_instructions
|
test.instance_type.get_method(:main).cpu_instructions
|
||||||
end
|
end
|
||||||
def check_nil
|
def check_nil
|
||||||
produced = produce_instructions
|
produced = produce_instructions
|
||||||
|
@ -9,7 +9,7 @@ module Risc
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chain
|
def pest_chain
|
||||||
#show_main_ticks # get output of what is
|
#show_main_ticks # get output of what is
|
||||||
check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
||||||
SlotToReg , RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
SlotToReg , RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
||||||
@ -18,7 +18,7 @@ module Risc
|
|||||||
assert_equal 15 , get_return.value
|
assert_equal 15 , get_return.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_call_main
|
def pest_call_main
|
||||||
call_ins = ticks(main_at)
|
call_ins = ticks(main_at)
|
||||||
assert_equal FunctionCall , call_ins.class
|
assert_equal FunctionCall , call_ins.class
|
||||||
assert :main , call_ins.method.name
|
assert :main , call_ins.method.name
|
||||||
@ -29,17 +29,17 @@ module Risc
|
|||||||
assert_equal Parfait::Integer , @interpreter.get_register(load_ins.register).class
|
assert_equal Parfait::Integer , @interpreter.get_register(load_ins.register).class
|
||||||
assert_equal 15 , @interpreter.get_register(load_ins.register).value
|
assert_equal 15 , @interpreter.get_register(load_ins.register).value
|
||||||
end
|
end
|
||||||
def test_return
|
def pest_return
|
||||||
ret = main_ticks(13)
|
ret = main_ticks(13)
|
||||||
assert_equal FunctionReturn , ret.class
|
assert_equal FunctionReturn , ret.class
|
||||||
link = @interpreter.get_register( ret.register )
|
link = @interpreter.get_register( ret.register )
|
||||||
assert_equal Label , link.class
|
assert_equal Label , link.class
|
||||||
end
|
end
|
||||||
def test_transfer
|
def pest_transfer
|
||||||
transfer = main_ticks(14)
|
transfer = main_ticks(14)
|
||||||
assert_equal Transfer , transfer.class
|
assert_equal Transfer , transfer.class
|
||||||
end
|
end
|
||||||
def test_sys
|
def pest_sys
|
||||||
sys = main_ticks(15)
|
sys = main_ticks(15)
|
||||||
assert_equal Syscall , sys.class
|
assert_equal Syscall , sys.class
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ module Risc
|
|||||||
@translator = IdentityTranslator.new
|
@translator = IdentityTranslator.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_translate_label
|
def test_translate_first_label
|
||||||
label = Parfait.object_space.get_main.risc_instructions
|
label = Parfait.object_space.get_main.risc_instructions
|
||||||
assert_equal "Space_Type.main" ,label.to_cpu(@translator).name , label
|
assert_equal "Space_Type.main" ,label.to_cpu(@translator).name , label
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user