class CodeTools::AST::ClassVariableAccess
Public Instance Methods
bytecode(g)
click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 159 def bytecode(g) pos(g) push_scope(g) g.send :class_variable_get, 1 end
defined(g)
click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 181 def defined(g) f = g.new_label done = g.new_label variable_defined(g, f) g.push_literal "class variable" g.goto done f.set! g.push_tagged_nil 0 done.set! end
or_bytecode(g) { || ... }
click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 138 def or_bytecode(g) pos(g) done = g.new_label notfound = g.new_label variable_defined(g, notfound) # Ok, we know the value exists, get it. bytecode(g) g.dup g.goto_if_true done g.pop # yield to generate the code for when it's not found notfound.set! yield done.set! end
push_scope(g)
click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 166 def push_scope(g) if g.state.scope.module? g.push_self else g.push_scope end g.push_literal @name end
to_sexp()
click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 195 def to_sexp [:cvar, @name] end
variable_defined(g, f)
click to toggle source
# File lib/rubinius/code/ast/variables.rb, line 175 def variable_defined(g, f) push_scope(g) g.send :class_variable_defined?, 1 g.goto_if_false f end