removed unused NamedList
args and locals got inlined into message, forgot to delete then ripples out due to type creation small type class api change, more ripples, but also more consistent
This commit is contained in:
@ -1,42 +0,0 @@
|
||||
|
||||
# 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
|
||||
|
||||
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
|
@ -151,10 +151,17 @@ module Parfait
|
||||
|
||||
# this is the way to instantiate classes (not Parfait::Class.new)
|
||||
# so we get and keep exactly one per name
|
||||
#
|
||||
# The superclass must be known when the class is created, or it raises an error.
|
||||
# The class is initiated with the type of the superclass (hence above)
|
||||
#
|
||||
# Only Vool::ClassExpression really ever creates classes and "grows" the type
|
||||
# according to the instances it finds, see there
|
||||
#
|
||||
def create_class( name , superclass = nil )
|
||||
raise "create_class #{name.class}" unless name.is_a? Symbol
|
||||
superclass = :Object unless superclass
|
||||
raise "create_class #{superclass.class}" unless superclass.is_a? Symbol
|
||||
raise "create_class failed for #{name}:#{superclass.class}" unless superclass.is_a? Symbol
|
||||
type = get_type_by_class_name(superclass)
|
||||
c = Class.new(name , superclass , type )
|
||||
@classes[name] = c
|
||||
|
@ -42,12 +42,19 @@ module Parfait
|
||||
5
|
||||
end
|
||||
|
||||
def self.for_hash( object_class , hash)
|
||||
def self.for_hash( hash , object_class = :Object)
|
||||
name = object_class
|
||||
if(object_class.is_a?(Symbol))
|
||||
object_class = Parfait.object_space.get_class_by_name(object_class)
|
||||
end
|
||||
raise "No such class #{name}" unless object_class
|
||||
hash = {type: object_class.name }.merge(hash) unless hash[:type]
|
||||
new_type = Type.new( object_class , hash)
|
||||
Parfait.object_space.add_type(new_type)
|
||||
end
|
||||
|
||||
# should not be called directly. Use Type.for_hash instead, that adds the
|
||||
# type to the global list
|
||||
def initialize( object_class , hash )
|
||||
super()
|
||||
set_object_class( object_class)
|
||||
@ -185,7 +192,7 @@ module Parfait
|
||||
raise "No nil type" unless type
|
||||
hash = to_hash
|
||||
hash[name] = type
|
||||
return Type.for_hash( object_class , hash)
|
||||
return Type.for_hash( hash , object_class)
|
||||
end
|
||||
|
||||
def set_object_class(oc)
|
||||
|
Reference in New Issue
Block a user