Class: EleetScript::EleetScriptClassInstance
Instance Attribute Summary collapse
#memory, #ruby_value
Instance Method Summary
collapse
#class?, #eql?, #hash, #instance?, set_is_class, set_is_instance
Constructor Details
#initialize(class_context, runtime_class, namespace_context) ⇒ EleetScriptClassInstance
Returns a new instance of EleetScriptClassInstance.
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/lang/runtime/class_instance.rb', line 6
def initialize(class_context, runtime_class, namespace_context)
@methods = MethodHash.new
@instance_vars = ProcessedKeyHash.new
@instance_vars.set_key_preprocessor do |key|
key[0] == "@" ? key[1..-1] : key
end
@runtime_class = runtime_class
@context = class_context.new_instance_context(self, namespace_context)
@ruby_value = self
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
3
4
5
|
# File 'lib/lang/runtime/class_instance.rb', line 3
def context
@context
end
|
#instance_vars ⇒ Object
Returns the value of attribute instance_vars.
3
4
5
|
# File 'lib/lang/runtime/class_instance.rb', line 3
def instance_vars
@instance_vars
end
|
#methods ⇒ Object
Returns the value of attribute methods.
3
4
5
|
# File 'lib/lang/runtime/class_instance.rb', line 3
def methods
@methods
end
|
#runtime_class ⇒ Object
Returns the value of attribute runtime_class.
3
4
5
|
# File 'lib/lang/runtime/class_instance.rb', line 3
def runtime_class
@runtime_class
end
|
Instance Method Details
#call(method_name, arguments = []) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/lang/runtime/class_instance.rb', line 21
def call(method_name, arguments = [])
method = find_method(method_name)
if method
if method.arity == 3
method.call(self, arguments, @context)
else
method.call(self, arguments)
end
else
es_method_name = @context["String"].new_with_value(method_name.to_s, @context.namespace_context)
call(NO_METHOD, arguments.dup.unshift(es_method_name))
end
end
|
#class_name ⇒ Object
64
65
66
|
# File 'lib/lang/runtime/class_instance.rb', line 64
def class_name
@runtime_class.name
end
|
#es_responds_to?(method_name) ⇒ Boolean
17
18
19
|
# File 'lib/lang/runtime/class_instance.rb', line 17
def es_responds_to?(method_name)
!find_method(method_name).nil?
end
|
#find_method(method_name) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/lang/runtime/class_instance.rb', line 35
def find_method(method_name)
method = @methods[method_name]
if method.nil?
method = @runtime_class.instance_lookup(method_name.to_s)
end
method
end
|
#inspect ⇒ Object
47
48
49
|
# File 'lib/lang/runtime/class_instance.rb', line 47
def inspect
to_s
end
|
#is_a?(*values) ⇒ Boolean
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/lang/runtime/class_instance.rb', line 51
def is_a?(*values)
names = ["Object", runtime_class.name]
cur_class = runtime_class
while cur_class.super_class.name != "Object"
names << cur_class.super_class.name
cur_class = cur_class.super_class
end
values.each do |value|
return true if names.include?(value)
end
false
end
|
#to_s ⇒ Object
43
44
45
|
# File 'lib/lang/runtime/class_instance.rb', line 43
def to_s
"<EleetScriptClassInstance @instance_of=\"#{runtime_class.name || "Unnamed"}\">"
end
|