class CodeTools::AST::ClosedScope
Attributes
body[RW]
Public Instance Methods
assign_local_reference(var)
click to toggle source
There is no place above us that may contain a local variable. Set the local in our local variables hash if not set. Set the local variable node attribute to a reference to the local variable.
# File lib/rubinius/code/ast/definitions.rb, line 129 def assign_local_reference(var) unless variable = variables[var.name] variable = new_local var.name end var.variable = variable.reference end
attach_and_call(g, arg_name, scoped=false, pass_block=false)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 145 def attach_and_call(g, arg_name, scoped=false, pass_block=false) name = @name || arg_name meth = new_generator(g, name) meth.push_state self meth.for_module_body = true if scoped meth.push_self meth.add_scope end meth.state.push_name name @body.bytecode meth meth.state.pop_name meth.ret meth.close meth.local_count = local_count meth.local_names = local_names meth.pop_state g.create_block meth g.swap g.push_scope g.push_true g.send :call_under, 3 return meth end
module?()
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 141 def module? false end
nest_scope(scope)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 137 def nest_scope(scope) scope.parent = self end
new_local(name)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 118 def new_local(name) variables[name] ||= Compiler::LocalVariable.new allocate_slot end
new_nested_local(name)
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 122 def new_nested_local(name) new_local(name).nested_reference end
search_local(name)
click to toggle source
A nested scope is looking up a local variable. If
the variable exists in our local variables hash, return a nested reference to it.
# File lib/rubinius/code/ast/definitions.rb, line 112 def search_local(name) if variable = variables[name] variable.nested_reference end end
to_sexp()
click to toggle source
# File lib/rubinius/code/ast/definitions.rb, line 180 def to_sexp sexp = [:scope] sexp << @body.to_sexp if @body sexp end