Class: Rubinius::ToolSet.current::TS::AST::NthRef
- Defined in:
- lib/rubinius/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.
67 68 69 70 |
# File 'lib/rubinius/ast/variables.rb', line 67 def initialize(line, ref) @line = line @which = ref end |
Instance Attribute Details
#which ⇒ Object
Returns the value of attribute which.
65 66 67 |
# File 'lib/rubinius/ast/variables.rb', line 65 def which @which end |
Instance Method Details
#bytecode(g) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/rubinius/ast/variables.rb', line 74 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
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rubinius/ast/variables.rb', line 82 def defined(g) f = g.new_label done = g.new_label g.last_match Mode, @which - 1 g.is_nil g.git f g.push_literal "global-variable" g.string_dup g.goto done f.set! g.push :nil done.set! end |
#to_sexp ⇒ Object
101 102 103 |
# File 'lib/rubinius/ast/variables.rb', line 101 def to_sexp [:nth_ref, @which] end |