move test helper code to support

to be reused
This commit is contained in:
Torsten Ruger 2018-04-19 19:33:40 +03:00
parent 13d8a65e07
commit 1741ad540e
3 changed files with 19 additions and 26 deletions

View File

@ -1,2 +1 @@
require_relative "../helper"
Risc.machine.boot unless Risc.machine.booted

View File

@ -1,24 +1 @@
require_relative "../helper"
require "util/eventable"
require "risc/interpreter"
module Risc
module Ticker
include InterpreterHelpers
include CompilerHelper
def setup
Risc.machine.boot
do_clean_compile
Vool::VoolCompiler.ruby_to_vool( @string_input )
Collector.collect_space
@interpreter = Interpreter.new
@interpreter.start Risc.machine.risc_init
end
# must be after boot, but before main compile, to define method
def do_clean_compile
end
end
end

View File

@ -1,6 +1,23 @@
require "util/eventable"
require "risc/interpreter"
require_relative "compiling"
module Risc
# relies on @interpreter instance to be set up during setup
module InterpreterHelpers
module Ticker
include CompilerHelper
def setup
Risc.machine.boot
do_clean_compile
Vool::VoolCompiler.ruby_to_vool( @string_input )
Collector.collect_space
@interpreter = Interpreter.new
@interpreter.start Risc.machine.risc_init
end
# must be after boot, but before main compile, to define method
def do_clean_compile
end
# check the given array of instructions is what the interpreter actually does
# possible second argument ignores the given amount, usually up until main