diff --git a/lib/risc/builtin.rb b/lib/mom/builtin.rb similarity index 98% rename from lib/risc/builtin.rb rename to lib/mom/builtin.rb index be76923d..2148cb2a 100644 --- a/lib/risc/builtin.rb +++ b/lib/mom/builtin.rb @@ -1,4 +1,4 @@ - module Risc +module Mom module Builtin module CompileHelper @@ -16,7 +16,7 @@ require_relative "builtin/integer" require_relative "builtin/object" require_relative "builtin/word" -module Risc +module Mom module Builtin # classes have booted, now create a minimal set of functions # minimal means only that which can not be coded in ruby diff --git a/lib/risc/builtin/README.md b/lib/mom/builtin/README.md similarity index 100% rename from lib/risc/builtin/README.md rename to lib/mom/builtin/README.md diff --git a/lib/risc/builtin/integer.rb b/lib/mom/builtin/integer.rb similarity index 99% rename from lib/risc/builtin/integer.rb rename to lib/mom/builtin/integer.rb index 46419002..23154e58 100644 --- a/lib/risc/builtin/integer.rb +++ b/lib/mom/builtin/integer.rb @@ -1,4 +1,4 @@ -module Risc +module Mom module Builtin # integer related kernel functions # all these functions (return the function they implement) assume interger input diff --git a/lib/risc/builtin/object.rb b/lib/mom/builtin/object.rb similarity index 95% rename from lib/risc/builtin/object.rb rename to lib/mom/builtin/object.rb index b8a91b11..d0c99224 100644 --- a/lib/risc/builtin/object.rb +++ b/lib/mom/builtin/object.rb @@ -1,4 +1,4 @@ -module Risc +module Mom module Builtin class Object module ClassMethods @@ -133,7 +133,7 @@ module Risc # there is a Syscall instruction, but the message has to be saved and restored def self.emit_syscall( builder , name ) save_message( builder ) - builder.add_code Syscall.new("emit_syscall(#{name})", name ) + builder.add_code Risc::Syscall.new("emit_syscall(#{name})", name ) restore_message(builder) return unless (@clazz and @method) builder.add_code Risc.label( "#{@clazz.name}.#{@message.name}" , "return_syscall" ) @@ -147,7 +147,7 @@ module Risc builder.build do message << message[:return_value] message.reduce_int - add_code Syscall.new("emit_syscall(exit)", :exit ) + add_code Risc::Syscall.new("emit_syscall(exit)", :exit ) end end @@ -156,7 +156,7 @@ module Risc # This relies on linux to save and restore all registers # def self.save_message(builder) - r8 = RegisterValue.new( :r8 , :Message).set_builder(builder) + r8 = Risc::RegisterValue.new( :r8 , :Message).set_builder(builder) builder.build {r8 << message} end @@ -166,7 +166,7 @@ module Risc # so that the return value already has an integer instance # This instance is filled with os return value def self.restore_message(builder) - r8 = RegisterValue.new( :r8 , :Message) + r8 = Risc::RegisterValue.new( :r8 , :Message) builder.build do integer_reg! << message message << r8 diff --git a/lib/risc/builtin/space.rb b/lib/mom/builtin/space.rb similarity index 96% rename from lib/risc/builtin/space.rb rename to lib/mom/builtin/space.rb index ec638d0f..61999513 100644 --- a/lib/risc/builtin/space.rb +++ b/lib/mom/builtin/space.rb @@ -1,4 +1,4 @@ -module Risc +module Mom module Builtin class Space module ClassMethods diff --git a/lib/risc/builtin/word.rb b/lib/mom/builtin/word.rb similarity index 97% rename from lib/risc/builtin/word.rb rename to lib/mom/builtin/word.rb index 54e4f9b0..67814f57 100644 --- a/lib/risc/builtin/word.rb +++ b/lib/mom/builtin/word.rb @@ -1,4 +1,4 @@ -module Risc +module Mom module Builtin module Word module ClassMethods @@ -23,7 +23,7 @@ module Risc word! << message[:receiver] integer! << word[Parfait::Word.get_length_index] end - Risc::Builtin.emit_syscall( builder , :putstring ) + Mom::Builtin.emit_syscall( builder , :putstring ) compiler end end diff --git a/lib/mom/mom.rb b/lib/mom/mom.rb index 132c2661..22e0dbfb 100644 --- a/lib/mom/mom.rb +++ b/lib/mom/mom.rb @@ -12,6 +12,10 @@ # Machine capabilities (instructions) for basic operations. Use of macros for higher level. module Mom + # boot bubiltin function (subject to change) + def self.boot! + Builtin.boot_functions + end end require_relative "instruction.rb" @@ -19,3 +23,4 @@ require_relative "mom_collection" require_relative "callable_compiler" require_relative "method_compiler" require_relative "block_compiler" +require_relative "builtin" diff --git a/lib/risc.rb b/lib/risc.rb index 40fa9a4e..65ab5c54 100644 --- a/lib/risc.rb +++ b/lib/risc.rb @@ -12,15 +12,11 @@ class Class end end -# The Risc Machine, is an abstract machine with registers. Think of it as an arm machine with -# normal instruction names. It is not however an abstraction of existing hardware, but only -# of that subset that we need. # See risc/Readme module Risc # module method to reset, and init def self.boot! Position.clear_positions - Builtin.boot_functions end end @@ -47,5 +43,4 @@ end require_relative "risc/instruction" require_relative "risc/register_value" require_relative "risc/text_writer" -require_relative "risc/builtin" require_relative "risc/builder" diff --git a/lib/rubyx.rb b/lib/rubyx.rb index 05e9450e..1e849175 100644 --- a/lib/rubyx.rb +++ b/lib/rubyx.rb @@ -3,8 +3,8 @@ require "rx-file" require "util/logging" require "util/list" require_relative "elf/object_writer" -require_relative "mom/mom" require_relative "risc" +require_relative "mom/mom" require_relative "arm/arm_machine" require_relative "arm/arm_platform" require_relative "vool/statement" diff --git a/lib/rubyx/rubyx_compiler.rb b/lib/rubyx/rubyx_compiler.rb index b0c84371..d6249c0c 100644 --- a/lib/rubyx/rubyx_compiler.rb +++ b/lib/rubyx/rubyx_compiler.rb @@ -21,6 +21,7 @@ module RubyX # initialize boots Parfait and Risc (ie load Builin) def initialize(options) Parfait.boot!(options[:parfait] || {}) + Mom.boot! Risc.boot! end diff --git a/test/mom/builtin/README.md b/test/mom/builtin/README.md new file mode 100644 index 00000000..b632d710 --- /dev/null +++ b/test/mom/builtin/README.md @@ -0,0 +1,8 @@ +# Builtin Testing + +Mostly testing that +- functions exist +- they compile +- basic length tests (no "contents") + +Functionality is tested by interpreter over in interpreter dir diff --git a/test/risc/builtin/helper.rb b/test/mom/builtin/helper.rb similarity index 76% rename from test/risc/builtin/helper.rb rename to test/mom/builtin/helper.rb index 55dea0ce..2be0a87b 100644 --- a/test/risc/builtin/helper.rb +++ b/test/mom/builtin/helper.rb @@ -1,12 +1,7 @@ require_relative "../helper" -module Risc +module Mom module Builtin - class BuiltinTest < MiniTest::Test - include Ticker - def setup - end - end class BootTest < MiniTest::Test def setup Parfait.boot!(Parfait.default_test_options) diff --git a/test/risc/builtin/test_integer.rb b/test/mom/builtin/test_integer.rb similarity index 99% rename from test/risc/builtin/test_integer.rb rename to test/mom/builtin/test_integer.rb index 807854d0..21a7e90e 100644 --- a/test/risc/builtin/test_integer.rb +++ b/test/mom/builtin/test_integer.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Risc +module Mom module Builtin class TestIntDiv4 < BootTest def setup diff --git a/test/risc/builtin/test_object.rb b/test/mom/builtin/test_object.rb similarity index 99% rename from test/risc/builtin/test_object.rb rename to test/mom/builtin/test_object.rb index 277942b6..4472a420 100644 --- a/test/risc/builtin/test_object.rb +++ b/test/mom/builtin/test_object.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Risc +module Mom module Builtin class TestObjectFunctionGet < BootTest def setup diff --git a/test/risc/builtin/test_word.rb b/test/mom/builtin/test_word.rb similarity index 99% rename from test/risc/builtin/test_word.rb rename to test/mom/builtin/test_word.rb index e257f578..e1801db7 100644 --- a/test/risc/builtin/test_word.rb +++ b/test/mom/builtin/test_word.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Risc +module Mom module Builtin class TestWordPut < BootTest def setup diff --git a/test/risc/test_builtin.rb b/test/mom/test_builtin.rb similarity index 97% rename from test/risc/test_builtin.rb rename to test/mom/test_builtin.rb index 2edf442e..3ccdde52 100644 --- a/test/risc/test_builtin.rb +++ b/test/mom/test_builtin.rb @@ -1,6 +1,6 @@ require_relative "helper" -module Risc +module Mom class TestBuiltinFunction < MiniTest::Test def setup diff --git a/test/risc/builtin/README.md b/test/risc/interpreter/builtin/README.md similarity index 100% rename from test/risc/builtin/README.md rename to test/risc/interpreter/builtin/README.md diff --git a/test/risc/builtin/test_int_cmp.rb b/test/risc/interpreter/builtin/test_int_cmp.rb similarity index 96% rename from test/risc/builtin/test_int_cmp.rb rename to test/risc/interpreter/builtin/test_int_cmp.rb index 902637c0..af8b66da 100644 --- a/test/risc/builtin/test_int_cmp.rb +++ b/test/risc/interpreter/builtin/test_int_cmp.rb @@ -1,9 +1,12 @@ require_relative "helper" # TODO move these to interpreter dir -module Risc +module Mom module Builtin class IntCmp < BuiltinTest + include Ticker + def setup + end def test_smaller_true run_main_return "4 < 5" diff --git a/test/risc/builtin/test_int_math.rb b/test/risc/interpreter/builtin/test_int_math.rb similarity index 94% rename from test/risc/builtin/test_int_math.rb rename to test/risc/interpreter/builtin/test_int_math.rb index fe9fd893..c22cc652 100644 --- a/test/risc/builtin/test_int_math.rb +++ b/test/risc/interpreter/builtin/test_int_math.rb @@ -1,8 +1,11 @@ require_relative "helper" -module Risc +module Mom module Builtin class IntMath < BuiltinTest + include Ticker + def setup + end def test_add run_main_return "5 + 5" diff --git a/test/vool/send/helper.rb b/test/vool/send/helper.rb index 04651c92..1f860562 100644 --- a/test/vool/send/helper.rb +++ b/test/vool/send/helper.rb @@ -8,7 +8,7 @@ module Vool def setup Parfait.boot!(Parfait.default_test_options) - Risc::Builtin.boot_functions + Mom.boot! @compiler = compile_first_method( send_method ) @ins = @compiler.mom_instructions.next end