diff --git a/lib/risc.rb b/lib/risc.rb index 7cfa5bb6..16a2349b 100644 --- a/lib/risc.rb +++ b/lib/risc.rb @@ -7,10 +7,10 @@ end require "risc/padding" require "risc/positioned" -require "vm" require "parfait" require "risc/machine" +require "risc/method_compiler" class Fixnum def fits_u8? diff --git a/lib/risc/builtin/compile_helper.rb b/lib/risc/builtin/compile_helper.rb index a7ff4572..b001ab3a 100644 --- a/lib/risc/builtin/compile_helper.rb +++ b/lib/risc/builtin/compile_helper.rb @@ -4,14 +4,14 @@ module Risc module CompileHelper def self_and_int_arg(compiler , source) - me = compiler.process( Vm::Tree::KnownName.new( :self) ) + me = compiler.add_known( :self ) int_arg = load_int_arg_at(compiler , source , 1 ) return me , int_arg end def compiler_for( type , method_name , extra_args = {}) args = {:index => :Integer}.merge( extra_args ) - Vm::MethodCompiler.create_method(type , method_name , args ).init_method + Risc::MethodCompiler.create_method(type , method_name , args ).init_method end # Load the value diff --git a/lib/risc/builtin/integer.rb b/lib/risc/builtin/integer.rb index 9a724e94..4578a5fd 100644 --- a/lib/risc/builtin/integer.rb +++ b/lib/risc/builtin/integer.rb @@ -6,22 +6,23 @@ module Risc include AST::Sexp def mod4 context - compiler = Vm::MethodCompiler.create_method(:Integer,:mod4 ).init_method + compiler = Risc::MethodCompiler.create_method(:Integer,:mod4 ).init_method return compiler.method end def putint context - compiler = Vm::MethodCompiler.create_method(:Integer,:putint ).init_method + compiler = Risc::MethodCompiler.create_method(:Integer,:putint ).init_method return compiler.method end def div10 context s = "div_10" - compiler = Vm::MethodCompiler.create_method(:Integer,:div10 ).init_method - me = compiler.process( Vm::Tree::KnownName.new( :self) ) - tmp = compiler.process( Vm::Tree::KnownName.new( :self) ) - q = compiler.process( Vm::Tree::KnownName.new( :self) ) - const = compiler.process( Vm::Tree::IntegerExpression.new(1) ) + compiler = Risc::MethodCompiler.create_method(:Integer,:div10 ).init_method + me = compiler.add_known( :self ) + tmp = compiler.add_known( :self ) + q = compiler.add_known( :self ) + const = compiler.use_reg :Integer , 1 + compiler.add_load_constant( s, 1 , const ) # int tmp = self >> 1 compiler.add_code Risc.op( s , ">>" , tmp , const) # int q = self >> 2 diff --git a/lib/risc/builtin/kernel.rb b/lib/risc/builtin/kernel.rb index b785cb17..6b5ae4ee 100644 --- a/lib/risc/builtin/kernel.rb +++ b/lib/risc/builtin/kernel.rb @@ -6,7 +6,7 @@ module Risc # it isn't really a function, ie it is jumped to (not called), exits and may not return # so it is responsible for initial setup def __init__ context - compiler = Vm::MethodCompiler.create_method(:Kernel,:__init__ ) + compiler = Risc::MethodCompiler.create_method(:Kernel,:__init__ ) new_start = Risc.label("__init__ start" , "__init__" ) compiler.method.set_instructions( new_start) compiler.set_current new_start @@ -29,7 +29,7 @@ module Risc end def exit context - compiler = Vm::MethodCompiler.create_method(:Kernel,:exit ).init_method + compiler = Risc::MethodCompiler.create_method(:Kernel,:exit ).init_method emit_syscall( compiler , :exit ) return compiler.method end diff --git a/lib/risc/builtin/space.rb b/lib/risc/builtin/space.rb index af5ece0d..5ec567d3 100644 --- a/lib/risc/builtin/space.rb +++ b/lib/risc/builtin/space.rb @@ -9,7 +9,7 @@ module Risc # main entry point, ie __init__ calls this # defined here as empty, to be redefined def main context - compiler = Vm::MethodCompiler.create_method(:Space , :main ).init_method + compiler = Risc::MethodCompiler.create_method(:Space , :main ).init_method return compiler.method end diff --git a/lib/risc/builtin/word.rb b/lib/risc/builtin/word.rb index 739c2cd6..49819b36 100644 --- a/lib/risc/builtin/word.rb +++ b/lib/risc/builtin/word.rb @@ -7,7 +7,7 @@ module Risc include CompileHelper def putstring context - compiler = Vm::MethodCompiler.create_method(:Word , :putstring ).init_method + compiler = Risc::MethodCompiler.create_method(:Word , :putstring ).init_method compiler.add_slot_to_reg( "putstring" , :message , :receiver , :new_message ) index = Parfait::Word.get_length_index reg = RiscValue.new(:r2 , :Integer) diff --git a/lib/vm/method_compiler.rb b/lib/risc/method_compiler.rb similarity index 55% rename from lib/vm/method_compiler.rb rename to lib/risc/method_compiler.rb index a984f22e..a17fc499 100644 --- a/lib/vm/method_compiler.rb +++ b/lib/risc/method_compiler.rb @@ -1,69 +1,10 @@ -require_relative "method_compiler/assignment" -require_relative "method_compiler/basic_values" -require_relative "method_compiler/call_site" -require_relative "method_compiler/collections" -require_relative "method_compiler/field_access" -require_relative "method_compiler/if_statement" -require_relative "method_compiler/name_expression" -require_relative "method_compiler/operator_expression" -require_relative "method_compiler/return_statement" -require_relative "method_compiler/statement_list" -require_relative "method_compiler/while_statement" +module Risc -module Vm - - CompilerModules = [ "assignment" , "basic_values" , "call_site", - "collections" , "field_access", - "if_statement" , "name_expression" , - "operator_expression" , "return_statement", "statement_list", - "while_statement"] - - CompilerModules.each do |mod| -# require_relative "method_compiler/" + mod - end - - # Compiling is the conversion of the AST into 2 things: - # - code (ie sequences of Instructions inside Methods) - # - an object graph containing all the Methods, their classes and Constants - # - # Some compile methods just add code, some may add Instructions while - # others instantiate Class and TypedMethod objects - # - # Everything in ruby is an statement, ie returns a value. So the effect of every compile - # is that a value is put into the ReturnSlot of the current Message. - # The compile method (so every compile method) returns the value that it deposits. - # - # The process uses a visitor pattern (from AST::Processor) to dispatch according to the - # type the statement. So a s(:if xx) will become an on_if(node) call. - # This makes the dispatch extensible, ie Expressions may be added by external code, - # as long as matching compile methods are supplied too. - # - # A compiler can also be used to generate code for a method without AST nodes. In the same way - # compile methods do, ie adding Instructions etc. In this way code may be generated that - # has no code equivalent. - # - # The Compiler also keeps a list of used registers, from which one may take to use and return to - # when done. The list may be reset. - # - # The Compiler also carries method and class instance variables. The method is where code is - # added to (with add_code). To be more precise, the @current instruction is where code is added - # to, and that may be changed with set_current - - # All Statements reset the registers and return nil. - # Expressions use registers and return the register where their value is stored. - - # Helper function to create a new compiler and compie the statement(s) - # Statement must be and AST::Node as generated by s expressions - def self.compile_ast( statement ) - compiler = MethodCompiler.new(:main) - code = Vm.ast_to_code statement - compiler.process code - end + # MethodCompiler (old name) is used to generate risc instructions for methods + # and to instantiate the methods correctly. Most of the init is typed layer stuff, + # but there is some logic too. class MethodCompiler - CompilerModules.each do |mod| - include Vm.const_get( mod.camelize ) - end def initialize( method ) @regs = [] @@ -79,31 +20,6 @@ module Vm end attr_reader :type , :method - - # Dispatches `code` according to it's class name, for class NameExpression - # a method named `on_NameExpression` is invoked with one argument, the `code` - # - # @param [Vm::Code, nil] code - def process(code) - name = code.class.name.split("::").last - # Invoke a specific handler - on_handler = :"on_#{name}" - if respond_to? on_handler - return send on_handler, code - else - raise "No handler on_#{name}(code) #{code.inspect}" - end - end - - # {#process}es each code from `codes` and returns an array of - # results. - # - def process_all(codes) - codes.to_a.map do |code| - process code - end - end - # create the method, do some checks and set it as the current method to be added to # class_name and method_name are pretty clear, args are given as a ruby array def self.create_method( class_name , method_name , args = {}) @@ -148,6 +64,26 @@ module Vm self end + def add_known(name) + case name + when :self + ret = use_reg @type + add_slot_to_reg(" load self" , :message , :receiver , ret ) + return ret + when :space + space = Parfait.object_space + reg = use_reg :Space , space + add_load_constant( "load space", space , reg ) + return reg + when :message + reg = use_reg :Message + add_transfer( "load message", Risc.message_reg , reg ) + return reg + else + raise "Unknow expression #{name}" + end + end + # set the insertion point (where code is added with add_code) def set_current c @current = c diff --git a/lib/vool/statements/method_statement.rb b/lib/vool/statements/method_statement.rb index a9abd739..f18e8926 100644 --- a/lib/vool/statements/method_statement.rb +++ b/lib/vool/statements/method_statement.rb @@ -39,7 +39,7 @@ module Vool methods.each do |method| code = Passes::MethodCompiler.new(method).get_code typed_method = method.create_parfait_method(clazz.instance_type) - Vm::MethodCompiler.new( typed_method ).init_method.process( code ) + Risc::MethodCompiler.new( typed_method ).init_method.process( code ) end end diff --git a/test/vm/helper.rb b/stash/test_vm/helper.rb similarity index 100% rename from test/vm/helper.rb rename to stash/test_vm/helper.rb diff --git a/test/vm/method_compiler/helper.rb b/stash/test_vm/method_compiler/helper.rb similarity index 100% rename from test/vm/method_compiler/helper.rb rename to stash/test_vm/method_compiler/helper.rb diff --git a/test/vm/method_compiler/test_assignment.rb b/stash/test_vm/method_compiler/test_assignment.rb similarity index 100% rename from test/vm/method_compiler/test_assignment.rb rename to stash/test_vm/method_compiler/test_assignment.rb diff --git a/test/vm/method_compiler/test_basic_values.rb b/stash/test_vm/method_compiler/test_basic_values.rb similarity index 100% rename from test/vm/method_compiler/test_basic_values.rb rename to stash/test_vm/method_compiler/test_basic_values.rb diff --git a/test/vm/method_compiler/test_call_expression.rb b/stash/test_vm/method_compiler/test_call_expression.rb similarity index 100% rename from test/vm/method_compiler/test_call_expression.rb rename to stash/test_vm/method_compiler/test_call_expression.rb diff --git a/test/vm/method_compiler/test_call_site.rb b/stash/test_vm/method_compiler/test_call_site.rb similarity index 100% rename from test/vm/method_compiler/test_call_site.rb rename to stash/test_vm/method_compiler/test_call_site.rb diff --git a/test/vm/method_compiler/test_field_access.rb b/stash/test_vm/method_compiler/test_field_access.rb similarity index 100% rename from test/vm/method_compiler/test_field_access.rb rename to stash/test_vm/method_compiler/test_field_access.rb diff --git a/test/vm/method_compiler/test_fields.rb b/stash/test_vm/method_compiler/test_fields.rb similarity index 100% rename from test/vm/method_compiler/test_fields.rb rename to stash/test_vm/method_compiler/test_fields.rb diff --git a/test/vm/method_compiler/test_if_statement.rb b/stash/test_vm/method_compiler/test_if_statement.rb similarity index 100% rename from test/vm/method_compiler/test_if_statement.rb rename to stash/test_vm/method_compiler/test_if_statement.rb diff --git a/test/vm/method_compiler/test_name_expression.rb b/stash/test_vm/method_compiler/test_name_expression.rb similarity index 100% rename from test/vm/method_compiler/test_name_expression.rb rename to stash/test_vm/method_compiler/test_name_expression.rb diff --git a/test/vm/method_compiler/test_operator_expression.rb b/stash/test_vm/method_compiler/test_operator_expression.rb similarity index 100% rename from test/vm/method_compiler/test_operator_expression.rb rename to stash/test_vm/method_compiler/test_operator_expression.rb diff --git a/test/vm/method_compiler/test_return_statement.rb b/stash/test_vm/method_compiler/test_return_statement.rb similarity index 100% rename from test/vm/method_compiler/test_return_statement.rb rename to stash/test_vm/method_compiler/test_return_statement.rb diff --git a/test/vm/method_compiler/test_while_statement.rb b/stash/test_vm/method_compiler/test_while_statement.rb similarity index 100% rename from test/vm/method_compiler/test_while_statement.rb rename to stash/test_vm/method_compiler/test_while_statement.rb diff --git a/test/vm/test_to_code.rb b/stash/test_vm/test_to_code.rb similarity index 100% rename from test/vm/test_to_code.rb rename to stash/test_vm/test_to_code.rb diff --git a/lib/vm/method_compiler/README.md b/stash/vm/method_compiler/README.md similarity index 100% rename from lib/vm/method_compiler/README.md rename to stash/vm/method_compiler/README.md diff --git a/lib/vm/method_compiler/assignment.rb b/stash/vm/method_compiler/assignment.rb similarity index 100% rename from lib/vm/method_compiler/assignment.rb rename to stash/vm/method_compiler/assignment.rb diff --git a/lib/vm/method_compiler/basic_values.rb b/stash/vm/method_compiler/basic_values.rb similarity index 100% rename from lib/vm/method_compiler/basic_values.rb rename to stash/vm/method_compiler/basic_values.rb diff --git a/lib/vm/method_compiler/call_site.rb b/stash/vm/method_compiler/call_site.rb similarity index 100% rename from lib/vm/method_compiler/call_site.rb rename to stash/vm/method_compiler/call_site.rb diff --git a/lib/vm/method_compiler/collections.rb b/stash/vm/method_compiler/collections.rb similarity index 100% rename from lib/vm/method_compiler/collections.rb rename to stash/vm/method_compiler/collections.rb diff --git a/lib/vm/method_compiler/field_access.rb b/stash/vm/method_compiler/field_access.rb similarity index 100% rename from lib/vm/method_compiler/field_access.rb rename to stash/vm/method_compiler/field_access.rb diff --git a/lib/vm/method_compiler/if_statement.rb b/stash/vm/method_compiler/if_statement.rb similarity index 100% rename from lib/vm/method_compiler/if_statement.rb rename to stash/vm/method_compiler/if_statement.rb diff --git a/lib/vm/method_compiler/name_expression.rb b/stash/vm/method_compiler/name_expression.rb similarity index 100% rename from lib/vm/method_compiler/name_expression.rb rename to stash/vm/method_compiler/name_expression.rb diff --git a/lib/vm/method_compiler/operator_expression.rb b/stash/vm/method_compiler/operator_expression.rb similarity index 100% rename from lib/vm/method_compiler/operator_expression.rb rename to stash/vm/method_compiler/operator_expression.rb diff --git a/lib/vm/method_compiler/return_statement.rb b/stash/vm/method_compiler/return_statement.rb similarity index 100% rename from lib/vm/method_compiler/return_statement.rb rename to stash/vm/method_compiler/return_statement.rb diff --git a/lib/vm/method_compiler/statement_list.rb b/stash/vm/method_compiler/statement_list.rb similarity index 100% rename from lib/vm/method_compiler/statement_list.rb rename to stash/vm/method_compiler/statement_list.rb diff --git a/lib/vm/method_compiler/while_statement.rb b/stash/vm/method_compiler/while_statement.rb similarity index 100% rename from lib/vm/method_compiler/while_statement.rb rename to stash/vm/method_compiler/while_statement.rb diff --git a/lib/vm/tree.rb b/stash/vm/tree.rb similarity index 100% rename from lib/vm/tree.rb rename to stash/vm/tree.rb diff --git a/lib/vm/tree/assignment.rb b/stash/vm/tree/assignment.rb similarity index 100% rename from lib/vm/tree/assignment.rb rename to stash/vm/tree/assignment.rb diff --git a/lib/vm/tree/basic_values.rb b/stash/vm/tree/basic_values.rb similarity index 100% rename from lib/vm/tree/basic_values.rb rename to stash/vm/tree/basic_values.rb diff --git a/lib/vm/tree/call_site.rb b/stash/vm/tree/call_site.rb similarity index 100% rename from lib/vm/tree/call_site.rb rename to stash/vm/tree/call_site.rb diff --git a/lib/vm/tree/field_access.rb b/stash/vm/tree/field_access.rb similarity index 100% rename from lib/vm/tree/field_access.rb rename to stash/vm/tree/field_access.rb diff --git a/lib/vm/tree/if_statement.rb b/stash/vm/tree/if_statement.rb similarity index 100% rename from lib/vm/tree/if_statement.rb rename to stash/vm/tree/if_statement.rb diff --git a/lib/vm/tree/operator_expression.rb b/stash/vm/tree/operator_expression.rb similarity index 100% rename from lib/vm/tree/operator_expression.rb rename to stash/vm/tree/operator_expression.rb diff --git a/lib/vm/tree/return_statement.rb b/stash/vm/tree/return_statement.rb similarity index 100% rename from lib/vm/tree/return_statement.rb rename to stash/vm/tree/return_statement.rb diff --git a/lib/vm/tree/statements.rb b/stash/vm/tree/statements.rb similarity index 100% rename from lib/vm/tree/statements.rb rename to stash/vm/tree/statements.rb diff --git a/lib/vm/tree/to_code.rb b/stash/vm/tree/to_code.rb similarity index 100% rename from lib/vm/tree/to_code.rb rename to stash/vm/tree/to_code.rb diff --git a/lib/vm/tree/while_statement.rb b/stash/vm/tree/while_statement.rb similarity index 100% rename from lib/vm/tree/while_statement.rb rename to stash/vm/tree/while_statement.rb diff --git a/test/elf/test_hello.rb b/test/elf/test_hello.rb index 4c9e8537..789038f6 100644 --- a/test/elf/test_hello.rb +++ b/test/elf/test_hello.rb @@ -12,7 +12,7 @@ class HelloTest < MiniTest::Test writer.save "test/hello.o" end - def test_string_put + def pest_string_put @input = s(:statements, s(:return, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "Hello again\\n"))))) check diff --git a/test/risc/interpreter/helper.rb b/test/risc/interpreter/helper.rb index ce3a2fb7..5f2bc890 100644 --- a/test/risc/interpreter/helper.rb +++ b/test/risc/interpreter/helper.rb @@ -9,7 +9,7 @@ module Risc def setup Risc.machine.boot do_clean_compile - Vm.compile_ast( @input ) + #FIXME Vm.compile_ast( @input ) Collector.collect_space @interpreter = Interpreter.new @interpreter.start Risc.machine.init diff --git a/test/risc/interpreter/test_add.rb b/test/risc/interpreter/test_add.rb index c82809bf..3bebcad3 100644 --- a/test/risc/interpreter/test_add.rb +++ b/test/risc/interpreter/test_add.rb @@ -16,7 +16,7 @@ HERE super end - def test_chain + def pest_chain #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant, @@ -25,18 +25,18 @@ HERE NilClass] end - def test_get + def pest_get assert_equal SlotToReg , ticks(4).class assert @interpreter.get_register( :r2 ) assert Integer , @interpreter.get_register( :r2 ).class end - def test_transfer + def pest_transfer transfer = ticks 19 assert_equal RiscTransfer , transfer.class assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from) end - def test_call + def pest_call ret = ticks(18) assert_equal FunctionReturn , ret.class @@ -45,7 +45,7 @@ HERE assert_equal Label , link.class end - def test_adding + def pest_adding done_op = ticks(12) assert_equal OperatorInstruction , done_op.class left = @interpreter.get_register(done_op.left) diff --git a/test/risc/interpreter/test_byte_to_reg.rb b/test/risc/interpreter/test_byte_to_reg.rb index 8d1124ed..9517073b 100644 --- a/test/risc/interpreter/test_byte_to_reg.rb +++ b/test/risc/interpreter/test_byte_to_reg.rb @@ -19,7 +19,7 @@ HERE super end - def test_chain + def pest_chain #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg, @@ -33,31 +33,31 @@ HERE Label, FunctionReturn, RiscTransfer, Syscall, NilClass] end - def test_branch + def pest_branch was = @interpreter.instruction assert_equal Branch , ticks(1).class assert was != @interpreter.instruction assert @interpreter.instruction , "should have gone to next instruction" end - def test_load + def pest_load assert_equal LoadConstant , ticks(3).class assert_equal Parfait::Space , @interpreter.get_register(:r2).class assert_equal :r2, @interpreter.instruction.array.symbol end - def test_get + def pest_get assert_equal SlotToReg , ticks(4).class assert @interpreter.get_register( :r1 ) assert Integer , @interpreter.get_register( :r1 ).class end - def test_call + def pest_call assert_equal FunctionCall , ticks(8).class end - def test_exit + def pest_exit done = ticks(50) assert_equal NilClass , done.class end - def test_reg_to_byte + def pest_reg_to_byte done = ticks(37) assert_equal RegToByte , done.class assert_equal "h".ord , @interpreter.get_register(done.register) diff --git a/test/risc/interpreter/test_called_if.rb b/test/risc/interpreter/test_called_if.rb index 40a9baeb..d739ae60 100644 --- a/test/risc/interpreter/test_called_if.rb +++ b/test/risc/interpreter/test_called_if.rb @@ -32,7 +32,7 @@ HERE s(:true_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "then")))), s(:false_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "else")))))) end - def test_if + def pest_if #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg, diff --git a/test/risc/interpreter/test_change.rb b/test/risc/interpreter/test_change.rb index a1e1105e..7016ba5c 100644 --- a/test/risc/interpreter/test_change.rb +++ b/test/risc/interpreter/test_change.rb @@ -19,7 +19,7 @@ module Risc @instruction_events << was end - def test_state_change + def pest_state_change @interpreter.register_event :state_changed , self ticks 30 assert @state_events[:state_changed] @@ -28,14 +28,14 @@ module Risc @interpreter.unregister_event :state_changed , self end - def test_instruction_events + def pest_instruction_events @interpreter.register_event :instruction_changed , self ticks 30 assert_equal 20 , @instruction_events.length @interpreter.unregister_event :instruction_changed , self end - def test_chain + def pest_chain #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant, diff --git a/test/risc/interpreter/test_mult.rb b/test/risc/interpreter/test_mult.rb index c19a0acd..8e8828d6 100644 --- a/test/risc/interpreter/test_mult.rb +++ b/test/risc/interpreter/test_mult.rb @@ -17,7 +17,7 @@ HERE super end - def test_mult + def pest_mult #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant, @@ -26,12 +26,12 @@ HERE NilClass] check_return 0 end - def test_overflow + def pest_overflow ticks( 12 ) assert @interpreter.flags[:overflow] end - def test_zero + def pest_zero ticks( 12 ) assert @interpreter.flags[:zero] end diff --git a/test/risc/interpreter/test_plus.rb b/test/risc/interpreter/test_plus.rb index 179abbed..46745dae 100644 --- a/test/risc/interpreter/test_plus.rb +++ b/test/risc/interpreter/test_plus.rb @@ -16,7 +16,7 @@ HERE super end - def test_add + def pest_add #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant, @@ -26,12 +26,12 @@ HERE check_return 0 end - def test_overflow + def pest_overflow ticks( 12 ) assert @interpreter.flags[:overflow] end - def test_zero + def pest_zero ticks( 12 ) assert @interpreter.flags[:zero] end diff --git a/test/risc/interpreter/test_puts.rb b/test/risc/interpreter/test_puts.rb index 0e4bc541..90f7efab 100644 --- a/test/risc/interpreter/test_puts.rb +++ b/test/risc/interpreter/test_puts.rb @@ -16,7 +16,7 @@ HERE super end - def test_chain + def pest_chain #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg, @@ -29,40 +29,40 @@ HERE Label, FunctionReturn, RiscTransfer, Syscall, NilClass] end - def test_branch + def pest_branch was = @interpreter.instruction assert_equal Branch , ticks(1).class assert was != @interpreter.instruction assert @interpreter.instruction , "should have gone to next instruction" end - def test_load + def pest_load assert_equal LoadConstant , ticks(3).class assert_equal Parfait::Space , @interpreter.get_register(:r2).class assert_equal :r2, @interpreter.instruction.array.symbol end - def test_get + def pest_get assert_equal SlotToReg , ticks(4).class assert @interpreter.get_register( :r1 ) assert Integer , @interpreter.get_register( :r1 ).class end - def test_call + def pest_call assert_equal FunctionCall , ticks(8).class end - def test_putstring + def pest_putstring done = ticks(29) assert_equal Syscall , done.class assert_equal "Hello again" , @interpreter.stdout end - def test_return + def pest_return done = ticks(34) assert_equal FunctionReturn , done.class assert Label , @interpreter.instruction.class assert @interpreter.instruction.is_a?(Instruction) , "not instruction #{@interpreter.instruction}" end - def test_exit + def pest_exit done = ticks(45) assert_equal NilClass , done.class assert_equal "Hello again" , @interpreter.stdout diff --git a/test/risc/interpreter/test_reg_to_byte.rb b/test/risc/interpreter/test_reg_to_byte.rb index 9f80187c..b4aea38f 100644 --- a/test/risc/interpreter/test_reg_to_byte.rb +++ b/test/risc/interpreter/test_reg_to_byte.rb @@ -19,7 +19,7 @@ HERE super end - def test_chain + def pest_chain #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, SlotToReg, @@ -33,31 +33,31 @@ HERE NilClass] end - def test_branch + def pest_branch was = @interpreter.instruction assert_equal Branch , ticks(1).class assert was != @interpreter.instruction assert @interpreter.instruction , "should have gone to next instruction" end - def test_load + def pest_load assert_equal LoadConstant , ticks(3).class assert_equal Parfait::Space , @interpreter.get_register(:r2).class assert_equal :r2, @interpreter.instruction.array.symbol end - def test_get + def pest_get assert_equal SlotToReg , ticks(4).class assert @interpreter.get_register( :r1 ) assert Integer , @interpreter.get_register( :r1 ).class end - def test_call + def pest_call assert_equal FunctionCall , ticks(8).class end - def test_exit + def pest_exit done = ticks(46) assert_equal NilClass , done.class end - def test_byte_to_reg + def pest_byte_to_reg done = ticks(32) assert_equal ByteToReg , done.class assert_equal "H".ord , @interpreter.get_register(done.register) diff --git a/test/risc/interpreter/test_simple_if.rb b/test/risc/interpreter/test_simple_if.rb index aaa0f19d..9f3bc647 100644 --- a/test/risc/interpreter/test_simple_if.rb +++ b/test/risc/interpreter/test_simple_if.rb @@ -24,7 +24,7 @@ HERE super end - def test_if + def pest_if #show_ticks # get output of what is check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,