Class: Laser::Analysis::LaserClass
- Inherits:
-
LaserModule
- Object
- LaserObject
- LaserModule
- Laser::Analysis::LaserClass
- Defined in:
- lib/laser/analysis/bootstrap/laser_class.rb
Overview
Laser representation of a class. I named it LaserClass so it wouldn't clash with regular Class. This links the class to its protocol. It inherits from LaserModule to pull in everything but superclasses.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) subclasses
readonly
Returns the value of attribute subclasses.
Attributes inherited from LaserModule
Attributes inherited from LaserObject
Instance Method Summary (collapse)
-
- (Object) add_subclass!(other)
Adds a subclass.
- - (Object) class_name
-
- (LaserClass) initialize(klass = ClassRegistry['Class'], scope = Scope::GlobalScope, full_path = (@name_set = :no; "#{klass.path}:Anonymous:#{object_id.to_s(16)}"))
constructor
A new instance of LaserClass.
- - (Object) inspect
- - (Object) normal_class
-
- (Object) proper_subset
The set of all subclasses (excluding the class itself).
-
- (Object) proper_superset
The set of all superclasses (excluding the class itself).
-
- (Object) remove_subclass!(other)
Removes a subclass.
- - (Object) singleton_class
-
- (Object) subset
The set of all subclasses (including the class itself).
- - (Object) superclass
-
- (Object) superclass=(other)
Sets the superclass, which handles registering/unregistering subclass ownership elsewhere in the inheritance tree.
-
- (Object) superset
The set of all superclasses (including the class itself).
Methods inherited from LaserModule
#<=>, #===, #__all_instance_methods, #__instance_methods_with_privacy, #__make_module_function__, #__visibility_modifier__, #add_instance_method!, #add_instance_variable!, #alias_method, #ancestors, #as_type, #classes_including, #const_defined?, #const_get, #const_set, #define_method, #define_method_with_annotations, #extend, #include, #include_module, #included_modules, #initialize_protocol, #initialize_scope, #instance_method, #instance_methods, #instance_variable, #instance_variables, #ivar_type, #method_defined?, #module_function, #name, #name_set?, #parent, #private, #private_instance_methods, #protected, #protected_instance_methods, #protected_method_defined?, #public, #public_instance_method, #public_instance_methods, #remove_const, #remove_method, #set_ivar_type, #set_name, #set_visibility!, #submodule_path, #undef_method, #validate_module_path!, #visibility_for, #visibility_table
Methods inherited from LaserObject
#add_instance_method!, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #laser_simulate
Methods included from ModuleExtensions
#attr_accessor_with_default, #cattr_accessor, #cattr_accessor_with_default, #cattr_get_and_setter, #cattr_reader, #cattr_writer, #opposite_method
Constructor Details
- (LaserClass) initialize(klass = ClassRegistry['Class'], scope = Scope::GlobalScope, full_path = (@name_set = :no; "#{klass.path}:Anonymous:#{object_id.to_s(16)}"))
A new instance of LaserClass
9 10 11 12 13 14 15 16 17 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 9 def initialize(klass = ClassRegistry['Class'], scope = Scope::GlobalScope, full_path=(@name_set = :no; "#{klass.path}:Anonymous:#{object_id.to_s(16)}")) @subclasses ||= [] # bootstrapping exception unless ['Class', 'Module', 'Object', 'BasicObject'].include?(full_path) @superclass = ClassRegistry['Object'] end super # can yield, so must come last end |
Instance Attribute Details
- (Object) subclasses (readonly)
Returns the value of attribute subclasses
7 8 9 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 7 def subclasses @subclasses end |
Instance Method Details
- (Object) add_subclass!(other)
Adds a subclass.
38 39 40 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 38 def add_subclass!(other) subclasses << other end |
- (Object) class_name
93 94 95 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 93 def class_name 'Class' end |
- (Object) inspect
97 98 99 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 97 def inspect "#<LaserClass: #{path} superclass=#{superclass.inspect}>" end |
- (Object) normal_class
19 20 21 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 19 def normal_class return ClassRegistry['Class'] end |
- (Object) proper_subset
The set of all subclasses (excluding the class itself)
89 90 91 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 89 def proper_subset subset - [self] end |
- (Object) proper_superset
The set of all superclasses (excluding the class itself)
79 80 81 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 79 def proper_superset superset - [self] end |
- (Object) remove_subclass!(other)
Removes a subclass.
43 44 45 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 43 def remove_subclass!(other) subclasses.delete other end |
- (Object) singleton_class
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 23 def singleton_class return @singleton_class if @singleton_class new_scope = ClosedScope.new(self.scope, nil) @singleton_class = LaserSingletonClass.new( ClassRegistry['Class'], new_scope, "Class:#{name}", self) do |new_singleton_class| if superclass new_singleton_class.superclass = superclass.singleton_class else new_singleton_class.superclass = ClassRegistry['Class'] end end @klass = @singleton_class end |
- (Object) subset
The set of all subclasses (including the class itself)
84 85 86 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 84 def subset [self] + subclasses.map(&:subset).flatten end |
- (Object) superclass
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 47 def superclass current = @superclass while current if LaserModuleCopy === current current = current.superclass else return current end end end |
- (Object) superclass=(other)
Sets the superclass, which handles registering/unregistering subclass ownership elsewhere in the inheritance tree
60 61 62 63 64 65 66 67 68 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 60 def superclass=(other) if LaserModuleCopy === other # || LaserSingletonClass === self @superclass = other else superclass.remove_subclass! self if superclass @superclass = other superclass.add_subclass! self end end |
- (Object) superset
The set of all superclasses (including the class itself). Excludes modules.
71 72 73 74 75 76 |
# File 'lib/laser/analysis/bootstrap/laser_class.rb', line 71 def superset if superclass.nil? then [self] else [self] + superclass.superset end end |