Class: Laser::Analysis::LaserObject
- Inherits:
-
Object
- Object
- Laser::Analysis::LaserObject
show all
- Extended by:
- ModuleExtensions
- Defined in:
- lib/laser/analysis/bootstrap/laser_object.rb
Overview
Catch all representation of an object. Should never have klass <:
Module.
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
attr_accessor_with_default, cattr_accessor, cattr_accessor_with_default, cattr_get_and_setter, cattr_reader, cattr_writer, opposite_method
Constructor Details
- (LaserObject) initialize(klass = ClassRegistry['Object'], scope = Scope::GlobalScope, name = "#<#{klass.path}:#{object_id.to_s(16)}>")
A new instance of LaserObject
8
9
10
11
12
13
14
15
16
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 8
def initialize(klass = ClassRegistry['Object'], scope = Scope::GlobalScope,
name = "#<#{klass.path}:#{object_id.to_s(16)}>")
@klass = klass
@scope = scope
@name = name
@instance_variables = Hash.new do |h, k|
h[k] = Bindings::InstanceVariableBinding.new(k, nil)
end
end
|
Instance Attribute Details
- (Object) klass
Returns the value of attribute klass
6
7
8
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 6
def klass
@klass
end
|
- (Object) name
Also known as:
path
Returns the value of attribute name
6
7
8
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 6
def name
@name
end
|
- (Object) scope
Returns the value of attribute scope
6
7
8
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 6
def scope
@scope
end
|
- (Object) singleton_class
37
38
39
40
41
42
43
44
45
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 37
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|
new_singleton_class.superclass = self.klass
end
@klass = @singleton_class
end
|
Instance Method Details
- (Object) add_instance_method!(method)
18
19
20
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 18
def add_instance_method!(method)
singleton_class.add_instance_method!(method)
end
|
- (Object) inspect
22
23
24
25
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 22
def inspect
return 'main' if self == Scope::GlobalScope.self_ptr
super
end
|
- (Boolean) instance_variable_defined?(var)
53
54
55
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 53
def instance_variable_defined?(var)
@instance_variables.has_key?(var)
end
|
- (Object) instance_variable_get(var)
57
58
59
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 57
def instance_variable_get(var)
@instance_variables[var].value
end
|
- (Object) instance_variable_set(var, value)
61
62
63
64
65
66
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 61
def instance_variable_set(var, value)
normal_class.instance_variable(var).inferred_type =
Types::UnionType.new([normal_class.instance_variable(var).expr_type,
Utilities.normal_class_for(value).as_type])
@instance_variables[var].bind!(value)
end
|
- (Object) laser_simulate(method, args, opts = {})
47
48
49
50
51
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 47
def laser_simulate(method, args, opts={})
opts = {self: self, mutation: false}.merge(opts)
method = klass.instance_method(method)
method.master_cfg.dup.simulate(args, opts.merge(method: method))
end
|
- (Object) normal_class
29
30
31
32
33
34
35
|
# File 'lib/laser/analysis/bootstrap/laser_object.rb', line 29
def normal_class
if @singleton_class
return @singleton_class.superclass
else
return @klass
end
end
|