Class: CodeTools::AST::ConstantAccess
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::ConstantAccess
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
#initialize(line, name, top_level = false) ⇒ ConstantAccess
Returns a new instance of ConstantAccess.
201
202
203
204
205
|
# File 'lib/rubinius/code/ast/constants.rb', line 201
def initialize(line, name, top_level = false)
@line = line
@name = name
@top_level = top_level
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
199
200
201
|
# File 'lib/rubinius/code/ast/constants.rb', line 199
def name
@name
end
|
Instance Method Details
#assign_bytecode(g, value) ⇒ Object
226
227
228
229
230
231
232
|
# File 'lib/rubinius/code/ast/constants.rb', line 226
def assign_bytecode(g, value)
pos(g)
g.push_scope
g.push_literal @name
value.bytecode(g)
end
|
#assign_sexp ⇒ Object
284
285
286
|
# File 'lib/rubinius/code/ast/constants.rb', line 284
def assign_sexp
@name
end
|
#bytecode(g) ⇒ Object
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/rubinius/code/ast/constants.rb', line 207
def bytecode(g)
pos(g)
if g.state.op_asgn?
g.push_rubinius
g.find_const :Runtime
g.push_literal @name
g.push_scope
g.send :find_constant_for_op_asign_or, 2
else
if @top_level
g.push_cpath_top
g.find_const @name
else
g.push_const @name
end
end
end
|
#defined(g) ⇒ Object
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
# File 'lib/rubinius/code/ast/constants.rb', line 242
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
234
235
236
237
238
239
240
|
# File 'lib/rubinius/code/ast/constants.rb', line 234
def masgn_bytecode(g)
pos(g)
g.push_scope
g.swap
g.push_literal @name
end
|
#to_sexp ⇒ Object
288
289
290
|
# File 'lib/rubinius/code/ast/constants.rb', line 288
def to_sexp
[:const, @name]
end
|
#value_defined(g, f) ⇒ Object
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
# File 'lib/rubinius/code/ast/constants.rb', line 258
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_literal @name
g.invoke_primitive :vm_const_defined, 1
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
|