Inline arguments into message
thus removing indirection for access does affect rather much, several commits
This commit is contained in:
parent
c13d4fb017
commit
0a1b05b2ee
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -18,19 +18,24 @@ module Parfait
|
||||
attr :type, :next_message
|
||||
attr :receiver , :frame
|
||||
attr :return_address, :return_value
|
||||
attr :caller , :method , :arguments
|
||||
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
|
||||
|
||||
|
@ -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: {},
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user