Class: Rubinius::AST::ClosedScope
- Includes:
- Compiler::LocalVariables
- Defined in:
- lib/compiler/ast/definitions.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
Attributes inherited from Node
Instance Method Summary collapse
-
#assign_local_reference(var) ⇒ Object
There is no place above us that may contain a local variable.
- #module? ⇒ Boolean
- #nest_scope(scope) ⇒ Object
- #new_local(name) ⇒ Object
- #new_nested_local(name) ⇒ Object
-
#search_local(name) ⇒ Object
A nested scope is looking up a local variable.
- #to_sexp ⇒ Object
Methods included from Compiler::LocalVariables
#allocate_slot, #local_count, #local_names, #variables
Methods inherited from Node
#ascii_graph, #attributes, #children, #initialize, match_arguments?, match_send?, #new_block_generator, #new_generator, node_name, #node_name, #pos, #set_child, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk
Constructor Details
This class inherits a constructor from Rubinius::AST::Node
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
72 73 74 |
# File 'lib/compiler/ast/definitions.rb', line 72 def body @body end |
Instance Method Details
#assign_local_reference(var) ⇒ Object
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.
94 95 96 97 98 99 100 |
# File 'lib/compiler/ast/definitions.rb', line 94 def assign_local_reference(var) unless variable = variables[var.name] variable = new_local var.name end var.variable = variable.reference end |
#module? ⇒ Boolean
106 107 108 |
# File 'lib/compiler/ast/definitions.rb', line 106 def module? false end |
#nest_scope(scope) ⇒ Object
102 103 104 |
# File 'lib/compiler/ast/definitions.rb', line 102 def nest_scope(scope) scope.parent = self end |
#new_local(name) ⇒ Object
82 83 84 85 |
# File 'lib/compiler/ast/definitions.rb', line 82 def new_local(name) variable = Compiler::LocalVariable.new allocate_slot variables[name] = variable end |
#new_nested_local(name) ⇒ Object
87 88 89 |
# File 'lib/compiler/ast/definitions.rb', line 87 def new_nested_local(name) new_local(name).nested_reference end |
#search_local(name) ⇒ Object
A nested scope is looking up a local variable. If the variable exists in our local variables hash, return a nested reference to it.
76 77 78 79 80 |
# File 'lib/compiler/ast/definitions.rb', line 76 def search_local(name) if variable = variables[name] variable.nested_reference end end |
#to_sexp ⇒ Object
110 111 112 113 114 |
# File 'lib/compiler/ast/definitions.rb', line 110 def to_sexp sexp = [:scope] sexp << @body.to_sexp if @body sexp end |