diff --git a/lib/mom/builtin.rb b/lib/mom/macro.rb similarity index 93% rename from lib/mom/builtin.rb rename to lib/mom/macro.rb index 0c9852b6..5e57c272 100644 --- a/lib/mom/builtin.rb +++ b/lib/mom/macro.rb @@ -9,12 +9,14 @@ module Mom end end end + class Macro < Instruction + end end -require_relative "builtin/space" -require_relative "builtin/integer" -require_relative "builtin/object" -require_relative "builtin/word" +require_relative "macro/space" +require_relative "macro/integer" +require_relative "macro/object" +require_relative "macro/word" module Mom module Builtin diff --git a/lib/mom/builtin/README.md b/lib/mom/macro/README.md similarity index 100% rename from lib/mom/builtin/README.md rename to lib/mom/macro/README.md diff --git a/lib/mom/builtin/comparison.rb b/lib/mom/macro/comparison.rb similarity index 97% rename from lib/mom/builtin/comparison.rb rename to lib/mom/macro/comparison.rb index c5f54f0f..1d05d554 100644 --- a/lib/mom/builtin/comparison.rb +++ b/lib/mom/macro/comparison.rb @@ -29,7 +29,7 @@ module Mom end end end - class Comparison < ::Mom::Instruction + class Comparison < Macro attr_reader :operator def initialize(name , operator) super(name) diff --git a/lib/mom/builtin/div10.rb b/lib/mom/macro/div10.rb similarity index 98% rename from lib/mom/builtin/div10.rb rename to lib/mom/macro/div10.rb index bf1e73d5..532d04a8 100644 --- a/lib/mom/builtin/div10.rb +++ b/lib/mom/macro/div10.rb @@ -62,7 +62,7 @@ module Mom end end end - class Div10 < ::Mom::Instruction + class Div10 < Macro def to_risc(compiler) s = "div_10 " builder = compiler.builder(compiler.source) diff --git a/lib/mom/builtin/div4.rb b/lib/mom/macro/div4.rb similarity index 96% rename from lib/mom/builtin/div4.rb rename to lib/mom/macro/div4.rb index 79a2312a..87de235a 100644 --- a/lib/mom/builtin/div4.rb +++ b/lib/mom/macro/div4.rb @@ -16,7 +16,7 @@ module Mom end end end - class Div4 < ::Mom::Instruction + class Div4 < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) integer_tmp = builder.allocate_int diff --git a/lib/mom/builtin/exit.rb b/lib/mom/macro/exit.rb similarity index 93% rename from lib/mom/builtin/exit.rb rename to lib/mom/macro/exit.rb index 0fe7acf1..e626283e 100644 --- a/lib/mom/builtin/exit.rb +++ b/lib/mom/macro/exit.rb @@ -9,7 +9,7 @@ module Mom end end end - class Exit < ::Mom::Instruction + class Exit < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) builder.prepare_int_return # makes integer_tmp variable as return diff --git a/lib/mom/builtin/get_internal_byte.rb b/lib/mom/macro/get_internal_byte.rb similarity index 95% rename from lib/mom/builtin/get_internal_byte.rb rename to lib/mom/macro/get_internal_byte.rb index cbf1e791..5727be93 100644 --- a/lib/mom/builtin/get_internal_byte.rb +++ b/lib/mom/macro/get_internal_byte.rb @@ -16,7 +16,7 @@ module Mom end end end - class GetInternalByte < ::Mom::Instruction + class GetInternalByte < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) integer_tmp = builder.allocate_int diff --git a/lib/mom/builtin/get_internal_word.rb b/lib/mom/macro/get_internal_word.rb similarity index 94% rename from lib/mom/builtin/get_internal_word.rb rename to lib/mom/macro/get_internal_word.rb index 66df3d5d..1211902d 100644 --- a/lib/mom/builtin/get_internal_word.rb +++ b/lib/mom/macro/get_internal_word.rb @@ -12,7 +12,7 @@ module Mom end end end - class GetInternalWord < Instruction + class GetInternalWord < Macro def to_risc(compiler) compiler.builder(compiler.source).build do object! << message[:receiver] diff --git a/lib/mom/builtin/init.rb b/lib/mom/macro/init.rb similarity index 98% rename from lib/mom/builtin/init.rb rename to lib/mom/macro/init.rb index 272ac106..c81dd212 100644 --- a/lib/mom/builtin/init.rb +++ b/lib/mom/macro/init.rb @@ -32,7 +32,7 @@ module Mom end end end - class Init < ::Mom::Instruction + class Init < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) builder.build do diff --git a/lib/mom/builtin/integer.rb b/lib/mom/macro/integer.rb similarity index 100% rename from lib/mom/builtin/integer.rb rename to lib/mom/macro/integer.rb diff --git a/lib/mom/builtin/method_missing.rb b/lib/mom/macro/method_missing.rb similarity index 92% rename from lib/mom/builtin/method_missing.rb rename to lib/mom/macro/method_missing.rb index de75f5bc..50a75b92 100644 --- a/lib/mom/builtin/method_missing.rb +++ b/lib/mom/macro/method_missing.rb @@ -9,7 +9,7 @@ module Mom end end end - class MethodMissing < ::Mom::Instruction + class MethodMissing < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) builder.prepare_int_return # makes integer_tmp variable as return diff --git a/lib/mom/builtin/object.rb b/lib/mom/macro/object.rb similarity index 100% rename from lib/mom/builtin/object.rb rename to lib/mom/macro/object.rb diff --git a/lib/mom/builtin/operator.rb b/lib/mom/macro/operator.rb similarity index 97% rename from lib/mom/builtin/operator.rb rename to lib/mom/macro/operator.rb index 14ed57ae..e4ee137f 100644 --- a/lib/mom/builtin/operator.rb +++ b/lib/mom/macro/operator.rb @@ -24,7 +24,7 @@ module Mom end end end - class IntOperator < Instruction + class IntOperator < Macro attr_reader :operator def initialize(name , operator) super(name) diff --git a/lib/mom/builtin/putstring.rb b/lib/mom/macro/putstring.rb similarity index 95% rename from lib/mom/builtin/putstring.rb rename to lib/mom/macro/putstring.rb index 7d4dba01..c0f3d2d7 100644 --- a/lib/mom/builtin/putstring.rb +++ b/lib/mom/macro/putstring.rb @@ -13,7 +13,7 @@ module Mom end end end - class Putstring < ::Mom::Instruction + class Putstring < Macro def to_risc(compiler) builder = compiler.builder(compiler.source) builder.prepare_int_return # makes integer_tmp variable as return diff --git a/lib/mom/builtin/set_internal_byte.rb b/lib/mom/macro/set_internal_byte.rb similarity index 95% rename from lib/mom/builtin/set_internal_byte.rb rename to lib/mom/macro/set_internal_byte.rb index 1872dc40..aa265fcf 100644 --- a/lib/mom/builtin/set_internal_byte.rb +++ b/lib/mom/macro/set_internal_byte.rb @@ -15,7 +15,7 @@ module Mom end end end - class SetInternalByte < ::Mom::Instruction + class SetInternalByte < Macro def to_risc(compiler) compiler.builder(compiler.source).build do word! << message[:receiver] diff --git a/lib/mom/builtin/set_internal_word.rb b/lib/mom/macro/set_internal_word.rb similarity index 94% rename from lib/mom/builtin/set_internal_word.rb rename to lib/mom/macro/set_internal_word.rb index 81f87c98..6c6d7561 100644 --- a/lib/mom/builtin/set_internal_word.rb +++ b/lib/mom/macro/set_internal_word.rb @@ -14,7 +14,7 @@ module Mom end end end - class SetInternalWord < ::Mom::Instruction + class SetInternalWord < Macro def to_risc(compiler) compiler.builder(compiler.source).build do object! << message[:receiver] diff --git a/lib/mom/builtin/space.rb b/lib/mom/macro/space.rb similarity index 100% rename from lib/mom/builtin/space.rb rename to lib/mom/macro/space.rb diff --git a/lib/mom/builtin/word.rb b/lib/mom/macro/word.rb similarity index 100% rename from lib/mom/builtin/word.rb rename to lib/mom/macro/word.rb diff --git a/lib/mom/mom.rb b/lib/mom/mom.rb index 392d7fac..926c7ba4 100644 --- a/lib/mom/mom.rb +++ b/lib/mom/mom.rb @@ -23,4 +23,4 @@ require_relative "mom_collection" require_relative "callable_compiler" require_relative "method_compiler" require_relative "block_compiler" -require_relative "builtin" +require_relative "macro" diff --git a/lib/vool/builtin.rb b/lib/vool/builtin.rb index d1010be3..ee1a44cf 100644 --- a/lib/vool/builtin.rb +++ b/lib/vool/builtin.rb @@ -1,5 +1,5 @@ module Vool - module Builtin + module Macro def self.boot_methods(options) return if options[:boot_methods] == false load_builtin( :int_plus ) diff --git a/lib/vool/yield_statement.rb b/lib/vool/yield_statement.rb index 02de0092..1451b9a0 100644 --- a/lib/vool/yield_statement.rb +++ b/lib/vool/yield_statement.rb @@ -39,7 +39,7 @@ module Vool check = Mom::NotSameCheck.new(compile_method , runtime_method, ok_label) # TODO? Maybe create mom instructions for this #builder = compiler.builder("yield") - #Risc::Builtin.exit_sequence(builder) + #Risc::Macro.exit_sequence(builder) #check << builder.built check << ok_label end diff --git a/test/mom/builtin/README.md b/test/mom/macro/README.md similarity index 100% rename from test/mom/builtin/README.md rename to test/mom/macro/README.md diff --git a/test/mom/builtin/helper.rb b/test/mom/macro/helper.rb similarity index 100% rename from test/mom/builtin/helper.rb rename to test/mom/macro/helper.rb diff --git a/test/mom/builtin/test_comparison.rb b/test/mom/macro/test_comparison.rb similarity index 100% rename from test/mom/builtin/test_comparison.rb rename to test/mom/macro/test_comparison.rb diff --git a/test/mom/builtin/test_div10.rb b/test/mom/macro/test_div10.rb similarity index 100% rename from test/mom/builtin/test_div10.rb rename to test/mom/macro/test_div10.rb diff --git a/test/mom/builtin/test_div4.rb b/test/mom/macro/test_div4.rb similarity index 100% rename from test/mom/builtin/test_div4.rb rename to test/mom/macro/test_div4.rb diff --git a/test/mom/builtin/test_exit.rb b/test/mom/macro/test_exit.rb similarity index 100% rename from test/mom/builtin/test_exit.rb rename to test/mom/macro/test_exit.rb diff --git a/test/mom/builtin/test_get_internal_byte.rb b/test/mom/macro/test_get_internal_byte.rb similarity index 100% rename from test/mom/builtin/test_get_internal_byte.rb rename to test/mom/macro/test_get_internal_byte.rb diff --git a/test/mom/builtin/test_get_internal_word.rb b/test/mom/macro/test_get_internal_word.rb similarity index 100% rename from test/mom/builtin/test_get_internal_word.rb rename to test/mom/macro/test_get_internal_word.rb diff --git a/test/mom/builtin/test_init.rb b/test/mom/macro/test_init.rb similarity index 100% rename from test/mom/builtin/test_init.rb rename to test/mom/macro/test_init.rb diff --git a/test/mom/builtin/test_integer.rb b/test/mom/macro/test_integer.rb similarity index 100% rename from test/mom/builtin/test_integer.rb rename to test/mom/macro/test_integer.rb diff --git a/test/mom/builtin/test_method_missing.rb b/test/mom/macro/test_method_missing.rb similarity index 100% rename from test/mom/builtin/test_method_missing.rb rename to test/mom/macro/test_method_missing.rb diff --git a/test/mom/builtin/test_object.rb b/test/mom/macro/test_object.rb similarity index 100% rename from test/mom/builtin/test_object.rb rename to test/mom/macro/test_object.rb diff --git a/test/mom/builtin/test_operator.rb b/test/mom/macro/test_operator.rb similarity index 100% rename from test/mom/builtin/test_operator.rb rename to test/mom/macro/test_operator.rb diff --git a/test/mom/builtin/test_putstring.rb b/test/mom/macro/test_putstring.rb similarity index 100% rename from test/mom/builtin/test_putstring.rb rename to test/mom/macro/test_putstring.rb diff --git a/test/mom/builtin/test_set_internal_byte.rb b/test/mom/macro/test_set_internal_byte.rb similarity index 100% rename from test/mom/builtin/test_set_internal_byte.rb rename to test/mom/macro/test_set_internal_byte.rb diff --git a/test/mom/builtin/test_set_internal_word.rb b/test/mom/macro/test_set_internal_word.rb similarity index 100% rename from test/mom/builtin/test_set_internal_word.rb rename to test/mom/macro/test_set_internal_word.rb diff --git a/test/mom/builtin/test_word.rb b/test/mom/macro/test_word.rb similarity index 100% rename from test/mom/builtin/test_word.rb rename to test/mom/macro/test_word.rb diff --git a/test/risc/interpreter/builtin/test_int_cmp.rb b/test/risc/interpreter/builtin/test_int_cmp.rb index e9024ee6..31ea070d 100644 --- a/test/risc/interpreter/builtin/test_int_cmp.rb +++ b/test/risc/interpreter/builtin/test_int_cmp.rb @@ -2,7 +2,7 @@ require_relative "../helper" # TODO move these to interpreter dir module Risc - module Builtin + module Macro class IntCmp < Minitest::Test include Ticker def setup diff --git a/test/risc/interpreter/builtin/test_int_math.rb b/test/risc/interpreter/builtin/test_int_math.rb index 514e947e..4ef9786a 100644 --- a/test/risc/interpreter/builtin/test_int_math.rb +++ b/test/risc/interpreter/builtin/test_int_math.rb @@ -1,7 +1,7 @@ require_relative "../helper" module Risc - module Builtin + module Macro class IntMath < Minitest::Test include Ticker def setup diff --git a/test/rubyx/builtin/README.md b/test/rubyx/macro/README.md similarity index 100% rename from test/rubyx/builtin/README.md rename to test/rubyx/macro/README.md diff --git a/test/rubyx/builtin/helper.rb b/test/rubyx/macro/helper.rb similarity index 94% rename from test/rubyx/builtin/helper.rb rename to test/rubyx/macro/helper.rb index 937e3d63..968816a0 100644 --- a/test/rubyx/builtin/helper.rb +++ b/test/rubyx/macro/helper.rb @@ -1,7 +1,7 @@ require_relative "../helper" module RubyX - module BuiltinHelper + module MacroHelper def setup whole ="class Space;def main(arg);return;end;end;" + source @mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(whole) diff --git a/test/rubyx/builtin/test_integer_comparison.rb b/test/rubyx/macro/test_integer_comparison.rb similarity index 96% rename from test/rubyx/builtin/test_integer_comparison.rb rename to test/rubyx/macro/test_integer_comparison.rb index 649d4b61..c7583307 100644 --- a/test/rubyx/builtin/test_integer_comparison.rb +++ b/test/rubyx/macro/test_integer_comparison.rb @@ -1,9 +1,9 @@ require_relative "helper" module RubyX - module Builtin + module Macro class TestIntegerSame < MiniTest::Test - include BuiltinHelper + include MacroHelper def op ; :== ; end def len ; 25 ; end def source diff --git a/test/rubyx/builtin/test_integer_div10.rb b/test/rubyx/macro/test_integer_div10.rb similarity index 93% rename from test/rubyx/builtin/test_integer_div10.rb rename to test/rubyx/macro/test_integer_div10.rb index 2f48e07e..cd4a8973 100644 --- a/test/rubyx/builtin/test_integer_div10.rb +++ b/test/rubyx/macro/test_integer_div10.rb @@ -1,9 +1,9 @@ require_relative "helper" module RubyX - module Builtin + module Macro class TestIntegerDiv10 < MiniTest::Test - include BuiltinHelper + include MacroHelper def source <