class CodeTools::AST::EvalExpression
Public Class Methods
new(body)
click to toggle source
Calls superclass method
CodeTools::AST::Container::new
# File lib/rubinius/code/ast/definitions.rb, line 1174 def initialize(body) super body @name = :__eval_script__ end
Public Instance Methods
assign_local_reference(var)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 1217 def assign_local_reference(var) unless reference = search_local(var.name) variable = new_local var.name reference = variable.reference end var.variable = reference end
bytecode(g)
click to toggle source
Calls superclass method
# File lib/rubinius/code/ast/definitions.rb, line 1231 def bytecode(g) super(g) container_bytecode(g) do @body.bytecode(g) g.ret end end
new_local(name)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 1213 def new_local(name) variables[name] ||= Compiler::EvalLocalVariable.new name end
push_state(g)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 1226 def push_state(g) g.push_state self g.state.push_eval self end
search_local(name)
click to toggle source
Returns a cached reference to a variable or searches all surrounding scopes for a variable. If
no variable is found, it returns nil and a nested scope will create the variable in itself.
# File lib/rubinius/code/ast/definitions.rb, line 1202 def search_local(name) if variable = variables[name] return variable.nested_reference end if variable = search_scopes(name) variables[name] = variable return variable.nested_reference end end
search_scopes(name)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 1183 def search_scopes(name) depth = 1 scope = @variable_scope while scope if !scope.method.for_eval? and slot = scope.method.local_slot(name) return Compiler::NestedLocalVariable.new(depth, slot) elsif scope.eval_local_defined?(name, false) return Compiler::EvalLocalVariable.new(name) end depth += 1 scope = scope.parent end end
sexp_name()
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 1240 def sexp_name :eval end
should_cache?()
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 1179 def should_cache? !@body.kind_of?(AST::ClosedScope) end