Class: CodeTools::AST::ToplevelConstant
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::ToplevelConstant
show all
- Defined in:
- lib/rubinius/code/ast/constants.rb
Instance Attribute Summary collapse
Attributes inherited from Node
#line
Instance Method Summary
collapse
Methods inherited from Node
#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk
Constructor Details
Returns a new instance of ToplevelConstant.
119
120
121
122
|
# File 'lib/rubinius/code/ast/constants.rb', line 119
def initialize(line, name)
@line = line
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
117
118
119
|
# File 'lib/rubinius/code/ast/constants.rb', line 117
def name
@name
end
|
Instance Method Details
#assign_bytecode(g, value) ⇒ Object
131
132
133
134
135
136
137
|
# File 'lib/rubinius/code/ast/constants.rb', line 131
def assign_bytecode(g, value)
pos(g)
g.push_cpath_top
g.push_literal @name
value.bytecode(g)
end
|
#bytecode(g) ⇒ Object
124
125
126
127
128
129
|
# File 'lib/rubinius/code/ast/constants.rb', line 124
def bytecode(g)
pos(g)
g.push_cpath_top
g.find_const @name
end
|
#defined(g) ⇒ Object
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/rubinius/code/ast/constants.rb', line 147
def defined(g)
f = g.new_label
done = g.new_label
value_defined(g, f)
g.pop
g.push_literal "constant"
g.goto done
f.set!
g.push_nil
done.set!
end
|
#masgn_bytecode(g) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/rubinius/code/ast/constants.rb', line 139
def masgn_bytecode(g)
pos(g)
g.push_cpath_top
g.swap
g.push_literal @name
end
|
#to_sexp ⇒ Object
Also known as:
assign_sexp
191
192
193
|
# File 'lib/rubinius/code/ast/constants.rb', line 191
def to_sexp
[:colon3, @name]
end
|
#value_defined(g, f) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/rubinius/code/ast/constants.rb', line 163
def value_defined(g, f)
g.push_exception_state
outer_exc_state = g.new_stack_local
g.set_stack_local outer_exc_state
g.pop
ex = g.new_label
ok = g.new_label
g.setup_unwind ex, RescueType
g.push_cpath_top
g.push_literal @name
g.push_false
g.invoke_primitive :vm_const_defined_under, 3
g.pop_unwind
g.goto ok
ex.set!
g.clear_exception
g.push_stack_local outer_exc_state
g.restore_exception_state
g.goto f
ok.set!
end
|