Class: CodeTools::AST::NthRef
- Defined in:
- lib/rubinius/code/ast/variables.rb
Constant Summary collapse
- Mode =
5
Instance Attribute Summary collapse
-
#which ⇒ Object
Returns the value of attribute which.
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
- #defined(g) ⇒ Object
-
#initialize(line, ref) ⇒ NthRef
constructor
A new instance of NthRef.
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Constructor Details
#initialize(line, ref) ⇒ NthRef
Returns a new instance of NthRef.
66 67 68 69 |
# File 'lib/rubinius/code/ast/variables.rb', line 66 def initialize(line, ref) @line = line @which = ref end |
Instance Attribute Details
#which ⇒ Object
Returns the value of attribute which.
64 65 66 |
# File 'lib/rubinius/code/ast/variables.rb', line 64 def which @which end |
Instance Method Details
#bytecode(g) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/rubinius/code/ast/variables.rb', line 73 def bytecode(g) pos(g) # These are for $1, $2, etc. We subtract 1 because # we start numbering the captures from 0. g.last_match Mode, @which - 1 end |
#defined(g) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rubinius/code/ast/variables.rb', line 81 def defined(g) f = g.new_label done = g.new_label g.last_match Mode, @which - 1 g.goto_if_nil f g.push_literal "global-variable" g.string_dup g.goto done f.set! g.push_nil done.set! end |
#to_sexp ⇒ Object
99 100 101 |
# File 'lib/rubinius/code/ast/variables.rb', line 99 def to_sexp [:nth_ref, @which] end |