class CodeTools::AST::ConstantAccess
Attributes
name[RW]
Public Class Methods
new(line, name, top_level = false)
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 198 def initialize(line, name, top_level = false) @line = line @name = name @top_level = top_level end
Public Instance Methods
assign_bytecode(g, value)
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 223 def assign_bytecode(g, value) pos(g) g.push_scope g.push_literal @name value.bytecode(g) end
assign_sexp()
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 284 def assign_sexp @name end
bytecode(g)
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 204 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)
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 239 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_tagged_nil 0 done.set! end
masgn_bytecode(g)
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 231 def masgn_bytecode(g) pos(g) g.push_scope g.swap g.push_literal @name end
to_sexp()
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 288 def to_sexp [:const, @name] end
value_defined(g, f)
click to toggle source
# File lib/rubinius/code/ast/constants.rb, line 255 def value_defined(g, f) # Save the current exception into a stack local 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_type g.push_scope g.push_literal @name g.send :constant_scope_defined?, 2 g.dup g.goto_if_not_undefined ok g.pop g.goto f ex.set! g.clear_exception g.push_stack_local outer_exc_state g.restore_exception_state g.goto f ok.set! end