rubyx/lib/parfait/named_list.rb
Torsten Ruger 25d7b8bd83 chaning calling convention not to add frame/arg types
these types are only needed to debug and can be gotten from the method (also in the mesage)
just saving the 6 instructions for every call
This was made possible through previous commits on fake_memory access
2018-08-12 14:47:05 +03:00

45 lines
1.5 KiB
Ruby

# A NamedList is used to store local variables and arguments when calling methods.
# Also temporary variables, which are local variables named by the system
# The items are named (and typed) by the objects type instance. In effect the
# variables are like instance variables
# A Message with is arguments, and a NamedList make up the two sides of message passing:
# A Message (see details there) is created by the caller and control is transferred
# A NamedList is created by the receiver
# PS: it turns out that both messages and named_lists are created at compile, not run-time, and
# just constantly reused. Each message has two named_list object ready and is also linked
# to the next message.
# The better way to say above is that a message is *used* by the caller, and a named_list
# by the callee.
# Also at runtime Messages and NamedLists remain completely "normal" objects.
# Ie they have have type and instances and so on.*
# Which resolves the dichotomy of objects on the stack or heap. Sama sama.
#
# *Alas the type for each call instance is unique.
#
module Parfait
class NamedList < Object
attr :type
def self.memory_size
16
end
def to_s
str = "NamedList len= #{get_length}"
str += " at #{Risc::Position.get(self)}" if Risc::Position.set?(self)
end
def get_length
get_type.get_length - 1
end
def self.type_for( arguments )
my_class = Parfait.object_space.classes[:NamedList]
Type.for_hash( my_class , {type: my_class.instance_type}.merge(arguments))
end
end
end