diff --git a/lib/vool/builtin.rb b/lib/vool/builtin.rb index 67dc69bf..1a2fdde6 100644 --- a/lib/vool/builtin.rb +++ b/lib/vool/builtin.rb @@ -6,9 +6,12 @@ module Vool end def self.load_builtin(loads) + return "class Space;def main(arg);return 0; end; end" if(loads == "Space.main") + raise "no preload #{loads}" unless builtin[loads] clazz , meth = loads.split(".") - "class #{clazz} #{derive(clazz)}; #{Vool::Builtin.builtin[loads]};end;" + "class #{clazz} #{derive(clazz)}; #{builtin[loads]};end;" end + def self.derive(clazz) #must get derived classes rigth, so no mismatch case clazz when "Integer" @@ -40,7 +43,6 @@ module Vool "Word.put" => "def putstring(at); X.putstring;end", "Word.set" => "def set_internal_byte(at, val); X.set_internal_byte;end", "Word.get" => "def get_internal_byte(at); X.get_internal_byte;end", - "Space.main" => "def main(args);return nil;end", } end def self.builtin_code diff --git a/lib/vool/method_expression.rb b/lib/vool/method_expression.rb index 4a5de92d..28e1210b 100644 --- a/lib/vool/method_expression.rb +++ b/lib/vool/method_expression.rb @@ -13,6 +13,10 @@ module Vool # Must pass in the actual Parfait class (default nil is just to conform to api) def to_parfait( clazz = nil ) raise "No class given to method #{name}" unless clazz + if( method = clazz.get_instance_method(name)) + #FIXME , should check arg_type, and if the same, clear method and ok + raise "Redefining #{clazz.name}.#{name} not supported #{method}" + end clazz.add_instance_method_for(name , make_arg_type , make_frame , body ) end diff --git a/test/mom/macro/test_init.rb b/test/mom/macro/test_init.rb index 48421d1f..9a6a7043 100644 --- a/test/mom/macro/test_init.rb +++ b/test/mom/macro/test_init.rb @@ -4,8 +4,8 @@ module Mom module Builtin class TestObjectInitRisc < BootTest def setup - Parfait.boot!(Parfait.default_test_options) - get_compiler("Space",:main) + compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options) + coll = compiler.ruby_to_mom( get_preload("Space.main") ) @method = MomCollection.create_init_compiler end def test_mom_length diff --git a/test/parfait/test_vool_method.rb b/test/parfait/test_vool_method.rb index 1d6ac49e..0b7d9cf8 100644 --- a/test/parfait/test_vool_method.rb +++ b/test/parfait/test_vool_method.rb @@ -22,7 +22,7 @@ module Vool end def test_method clazz = @clazz.to_parfait - assert_equal Parfait::VoolMethod , method.to_parfait(clazz).class + assert_equal Parfait::VoolMethod , clazz.get_instance_method(:main).class end end end diff --git a/test/risc/interpreter/builtin/test_int_math.rb b/test/risc/interpreter/builtin/test_int_math.rb index 24fba9da..0646279f 100644 --- a/test/risc/interpreter/builtin/test_int_math.rb +++ b/test/risc/interpreter/builtin/test_int_math.rb @@ -5,38 +5,45 @@ module Risc class IntMath < Minitest::Test include Ticker def setup - @preload = "all" end def test_add + @preload = "Integer.plus" run_main_return "5 + 5" assert_equal 10 , get_return end def test_minus + @preload = "Integer.minus" run_main_return "5 - 5" assert_equal 0 , get_return end def test_minus_neg + @preload = "Integer.minus" run_main_return "5 - 15" assert_equal( -10 , get_return) end def test_rshift + @preload = "Integer.rs" run_main_return "#{2**8} >> 3" assert_equal 2**5 , get_return end def test_lshift + @preload = "Integer.ls" run_main_return "#{2**8} << 3" assert_equal 2**11 , get_return end def test_div10 + @preload = "Integer.div10" run_main_return "45.div10" assert_equal 4 , get_return end def test_div4 + @preload = "Integer.div4" run_main_return "45.div4" assert_equal 11 , get_return end def test_mult + @preload = "Integer.mul" run_main_return "4 * 4" assert_equal 16 , get_return end diff --git a/test/rubyx/macro/test_object_missing.rb b/test/rubyx/macro/test_object_missing.rb index 31a93f7e..53e5d609 100644 --- a/test/rubyx/macro/test_object_missing.rb +++ b/test/rubyx/macro/test_object_missing.rb @@ -6,11 +6,6 @@ module RubyX include MacroHelper def source <