Class: EleetScript::BaseContext
- Inherits:
-
Object
- Object
- EleetScript::BaseContext
show all
- Defined in:
- lib/lang/runtime/context.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BaseContext.
21
22
23
24
|
# File 'lib/lang/runtime/context.rb', line 21
def initialize(*args)
init(args)
self
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/lang/runtime/context.rb', line 86
def method_missing(name, *args)
if @parent_context && @parent_context.respond_to?(name)
@parent_context.send(name, *args)
else
super(name, *args)
end
end
|
Class Attribute Details
.init_funcs ⇒ Object
Returns the value of attribute init_funcs.
9
10
11
|
# File 'lib/lang/runtime/context.rb', line 9
def init_funcs
@init_funcs
end
|
Instance Attribute Details
#constants ⇒ Object
Returns the value of attribute constants.
5
6
7
|
# File 'lib/lang/runtime/context.rb', line 5
def constants
@constants
end
|
#current_class ⇒ Object
Returns the value of attribute current_class.
6
7
8
|
# File 'lib/lang/runtime/context.rb', line 6
def current_class
@current_class
end
|
#current_self ⇒ Object
Returns the value of attribute current_self.
6
7
8
|
# File 'lib/lang/runtime/context.rb', line 6
def current_self
@current_self
end
|
#global_vars ⇒ Object
Returns the value of attribute global_vars.
5
6
7
|
# File 'lib/lang/runtime/context.rb', line 5
def global_vars
@global_vars
end
|
#local_vars ⇒ Object
Returns the value of attribute local_vars.
5
6
7
|
# File 'lib/lang/runtime/context.rb', line 5
def local_vars
@local_vars
end
|
#namespaces ⇒ Object
Returns the value of attribute namespaces.
5
6
7
|
# File 'lib/lang/runtime/context.rb', line 5
def namespaces
@namespaces
end
|
Class Method Details
.init_with(*func_symbols) ⇒ Object
11
12
13
14
|
# File 'lib/lang/runtime/context.rb', line 11
def init_with(*func_symbols)
(@init_funcs ||= [])
@init_funcs += func_symbols
end
|
Instance Method Details
#[](key) ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/lang/runtime/context.rb', line 66
def [](key)
store = fetch_var_store(key)
if store[key]
store[key]
elsif @parent_context
@parent_context[key]
else
es_nil
end
end
|
#[]=(key, value) ⇒ Object
77
78
79
80
|
# File 'lib/lang/runtime/context.rb', line 77
def []=(key, value)
store = fetch_var_store(key)
store[key] = value
end
|
#class_vars ⇒ Object
46
47
48
|
# File 'lib/lang/runtime/context.rb', line 46
def class_vars
@current_self.class_vars
end
|
#es_nil ⇒ Object
26
27
28
|
# File 'lib/lang/runtime/context.rb', line 26
def es_nil
@_es_nil ||= root_ns["nil"]
end
|
#instance_vars ⇒ Object
42
43
44
|
# File 'lib/lang/runtime/context.rb', line 42
def instance_vars
@current_self.instance_vars
end
|
#local_constant(name) ⇒ Object
62
63
64
|
# File 'lib/lang/runtime/context.rb', line 62
def local_constant(name)
constants[name] || es_nil
end
|
#local_var(name, value = nil) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/lang/runtime/context.rb', line 54
def local_var(name, value = nil)
if value
local_vars[name] = value
else
local_vars[name] || es_nil
end
end
|
#namespace_context ⇒ Object
50
51
52
|
# File 'lib/lang/runtime/context.rb', line 50
def namespace_context
root_ns
end
|
#respond_to_missing?(name, incl_priv = false) ⇒ Boolean
82
83
84
|
# File 'lib/lang/runtime/context.rb', line 82
def respond_to_missing?(name, incl_priv = false)
@parent_context && @parent_context.respond_to?(name, incl_priv)
end
|
#root_ns ⇒ Object
30
31
32
|
# File 'lib/lang/runtime/context.rb', line 30
def root_ns
@parent_context ? @parent_context.root_ns : nil
end
|