diff --git a/lib/mom/builtin.rb b/lib/mom/builtin.rb index f135a2f8..4b66bc55 100644 --- a/lib/mom/builtin.rb +++ b/lib/mom/builtin.rb @@ -54,7 +54,7 @@ module Mom [ :div4, :<,:<= , :>=, :> , :div10 ].each do |f| #div4 is just a forward declaration compilers << compiler_for( int_type , Integer , f) end - compilers + return compilers end def self.compiler_for( type , mod , name) diff --git a/lib/mom/builtin/comparison.rb b/lib/mom/builtin/comparison.rb index 841482ce..d38335e9 100644 --- a/lib/mom/builtin/comparison.rb +++ b/lib/mom/builtin/comparison.rb @@ -12,8 +12,7 @@ module Mom builder.build do integer! << message[:receiver] integer.reduce_int - integer_reg! << message[:arguments] - integer_reg << integer_reg[Parfait::NamedList.type_length + 0] #"other" is at index 0 + integer_reg! << message[:arg1] #"other" integer_reg.reduce_int swap_names(:integer , :integer_reg) if(operator.to_s.start_with?('<') ) integer.op :- , integer_reg diff --git a/lib/mom/builtin/get_internal_byte.rb b/lib/mom/builtin/get_internal_byte.rb index 89732a1e..66951662 100644 --- a/lib/mom/builtin/get_internal_byte.rb +++ b/lib/mom/builtin/get_internal_byte.rb @@ -6,8 +6,7 @@ module Mom integer_tmp = builder.allocate_int builder.build do object! << message[:receiver] - integer! << message[:arguments] - integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0 + integer! << message[:arg1] #"at" integer.reduce_int object <= object[integer] integer_tmp[Parfait::Integer.integer_index] << object diff --git a/lib/mom/builtin/get_internal_word.rb b/lib/mom/builtin/get_internal_word.rb index d6e98f3e..e41cbefb 100644 --- a/lib/mom/builtin/get_internal_word.rb +++ b/lib/mom/builtin/get_internal_word.rb @@ -4,8 +4,7 @@ module Mom def to_risc(compiler) compiler.builder(compiler.source).build do object! << message[:receiver] - integer! << message[:arguments] - integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0 + integer! << message[:arg1] #"at" is at index 0 integer.reduce_int object << object[integer] message[:return_value] << object diff --git a/lib/mom/builtin/operator.rb b/lib/mom/builtin/operator.rb index 070bb2ee..a67c5183 100644 --- a/lib/mom/builtin/operator.rb +++ b/lib/mom/builtin/operator.rb @@ -14,8 +14,7 @@ module Mom builder.build do integer! << message[:receiver] integer.reduce_int - integer_reg! << message[:arguments] - integer_reg << integer_reg[Parfait::NamedList.type_length + 0] #"other" is at index 0 + integer_reg! << message[:arg1] #"other" integer_reg.reduce_int integer.op operator , integer_reg integer_tmp[Parfait::Integer.integer_index] << integer diff --git a/lib/mom/builtin/set_internal_byte.rb b/lib/mom/builtin/set_internal_byte.rb index 36a1eb2e..c606e86a 100644 --- a/lib/mom/builtin/set_internal_byte.rb +++ b/lib/mom/builtin/set_internal_byte.rb @@ -4,10 +4,9 @@ module Mom def to_risc(compiler) compiler.builder(compiler.source).build do word! << message[:receiver] - integer! << message[:arguments] - integer_reg! << integer[Parfait::NamedList.type_length + 1] #"value" is at index 1 + integer_reg! << message[:arg2] #VALUE message[:return_value] << integer_reg - integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0 + integer! << message[:arg1] #"index" integer.reduce_int integer_reg.reduce_int word[integer] <= integer_reg diff --git a/lib/mom/builtin/set_internal_word.rb b/lib/mom/builtin/set_internal_word.rb index a43b0dcb..6cae8376 100644 --- a/lib/mom/builtin/set_internal_word.rb +++ b/lib/mom/builtin/set_internal_word.rb @@ -4,9 +4,8 @@ module Mom def to_risc(compiler) compiler.builder(compiler.source).build do object! << message[:receiver] - integer! << message[:arguments] - object_reg! << integer[Parfait::NamedList.type_length + 1] #"value" is at index 1 - integer << integer[Parfait::NamedList.type_length + 0] #"at" is at index 0 + integer! << message[:arg1] # "index" + object_reg! << message[:arg2]#"value" integer.reduce_int object[integer] << object_reg message[:return_value] << object_reg diff --git a/lib/parfait/message.rb b/lib/parfait/message.rb index d0a803e7..275386fa 100644 --- a/lib/parfait/message.rb +++ b/lib/parfait/message.rb @@ -15,22 +15,27 @@ module Parfait # :return_address => :Integer, :return_value => :Integer, # :caller => :Message , :name => :Word , :arguments => :NamedList - attr :type, :next_message - attr :receiver , :frame - attr :return_address, :return_value - attr :caller , :method , :arguments + attr :type, :next_message + attr :receiver , :frame + attr :return_address, :return_value + attr :caller , :method + attr :arguments_given + attr :arg1 , :arg2, :arg3, :arg4, :arg5, :arg6 def self.type_length - 9 + 16 end def self.memory_size - 16 + 32 + end + def self.args_start_at + Parfait.object_space.get_type_by_class_name(:Message).variable_index(:arguments_given) end def initialize( ) super() self.frame = NamedList.new() - self.arguments = NamedList.new() + self.arguments_given = Parfait::Integer.new(0) end public :initialize diff --git a/lib/risc/parfait_boot.rb b/lib/risc/parfait_boot.rb index d0c62573..32d600f4 100644 --- a/lib/risc/parfait_boot.rb +++ b/lib/risc/parfait_boot.rb @@ -151,6 +151,7 @@ module Parfait Data4: {}, Data8: {}, Data16: {}, + Data32: {}, Dictionary: {i_keys: :List , i_values: :List } , FalseClass: {}, Factory: { for_type: :Type , next_object: :Object , @@ -159,7 +160,10 @@ module Parfait List: {indexed_length: :Integer , next_list: :List} , Message: { next_message: :Message, receiver: :Object, frame: :NamedList , return_address: :Integer, return_value: :Object, - caller: :Message , method: :TypedMethod , arguments: :NamedList }, + caller: :Message , method: :TypedMethod , + arguments_given: :Integer , + arg1: :Integer , arg2: :Integer, arg3: :Integer, + arg4: :Integer, arg5: :Integer, arg6: :Integer}, MetaClass: {instance_methods: :List, instance_type: :Type, clazz: :Class }, NamedList: {}, NilClass: {}, diff --git a/test/parfait/test_attributes.rb b/test/parfait/test_attributes.rb index 453d69f7..37691080 100644 --- a/test/parfait/test_attributes.rb +++ b/test/parfait/test_attributes.rb @@ -15,7 +15,7 @@ module Parfait def test_message_name_nil last = @type.names.last - assert_equal :arguments , last , @type.names.inspect + assert_equal :arg6 , last , @type.names.inspect assert_nil @mess.method end def test_message_next_set diff --git a/test/parfait/test_message.rb b/test/parfait/test_message.rb index 6cf08967..cc776743 100644 --- a/test/parfait/test_message.rb +++ b/test/parfait/test_message.rb @@ -7,15 +7,20 @@ module Parfait super @mess = @space.get_next_for(:Message) end + def test_args_start + assert_equal 8 , Message.args_start_at + end def test_length - assert_equal 9 , @mess.get_type.instance_length , @mess.get_type.inspect + assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect end def test_attribute_set @mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed assert_equal 55 , @mess.receiver end def test_indexed - assert_equal 8 , @mess.get_type.variable_index(:arguments) + assert_equal 8 , @mess.get_type.variable_index(:arguments_given) + assert_equal 9 , @mess.get_type.variable_index(:arg1) + assert_equal 13 , @mess.get_type.variable_index(:arg5) end def test_next_message assert_equal Message , @mess.next_message.class @@ -24,7 +29,7 @@ module Parfait assert_equal NamedList , @mess.frame.class end def test_arguments - assert_equal NamedList , @mess.arguments.class + assert_equal Integer , @mess.arguments_given.class end def test_return_address assert_nil @mess.return_address diff --git a/test/parfait/test_space.rb b/test/parfait/test_space.rb index fdbe2423..52027243 100644 --- a/test/parfait/test_space.rb +++ b/test/parfait/test_space.rb @@ -5,7 +5,7 @@ module Parfait def classes [:BinaryCode,:Block,:CacheEntry,:Callable,:CallableMethod,:Class, - :DataObject,:Data4,:Data8,:Data16,:Dictionary,:Factory, :Integer,:FalseClass, + :DataObject,:Data4,:Data8,:Data16,:Data32,:Dictionary,:Factory, :Integer,:FalseClass, :List,:Message, :MetaClass, :NamedList,:NilClass,:Object,:ReturnAddress, :Space,:TrueClass,:Type,:VoolMethod,:Word] end