Introduce singleton types

Just for future, as this gives us a way to know immediately in the type, which represent normal, and which singleton classes
Also instantiate singleton class lazily (with singleton type)
This makes the type of class single, ie unique, immediately when it is used, ie methods or variables defined.
Fixes a design mistake, where all singletonn classes shared the same type, and thus unique methods per class were impossible
(Also some misc in commit)
This commit is contained in:
2019-09-30 17:09:13 +03:00
parent ba83affd8c
commit 2dcb2a9a72
22 changed files with 124 additions and 52 deletions

View File

@ -17,7 +17,7 @@
module Parfait
class Class < Behaviour
attr_reader :name , :super_class_name , :single_class
attr_reader :name , :super_class_name
def self.type_length
6
@ -30,7 +30,11 @@ module Parfait
super(instance_type)
@name = name
@super_class_name = superclass
@single_class = SingletonClass.new( self , self.type || @name)
end
def single_class
return @single_class if @single_class
@single_class = SingletonClass.new( self )
end
def rxf_reference_name