Class: Rubinius::ToolSet.current::TS::AST::PostPatternVariable

Inherits:
Node
  • Object
show all
Includes:
LocalVariable
Defined in:
lib/rubinius/ast/variables.rb

Instance Attribute Summary collapse

Attributes included from LocalVariable

#variable

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, #defined, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, name, idx) ⇒ PostPatternVariable

Returns a new instance of PostPatternVariable.



808
809
810
811
812
813
# File 'lib/rubinius/ast/variables.rb', line 808

def initialize(line, name, idx)
  @line = line
  @name = name
  @pos  = idx
  @variable = nil
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



806
807
808
# File 'lib/rubinius/ast/variables.rb', line 806

def name
  @name
end

#valueObject

Returns the value of attribute value.



806
807
808
# File 'lib/rubinius/ast/variables.rb', line 806

def value
  @value
end

Instance Method Details

#bytecode(g) ⇒ Object



820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
# File 'lib/rubinius/ast/variables.rb', line 820

def bytecode(g)
  pos(g)

  unless @variable
    g.state.scope.assign_local_reference self
  end

  too_big = g.new_label
  done    = g.new_label

  g.dup
  g.send :size, 0
  g.push_int @pos
  g.send :>, 1
  g.gif too_big
  g.dup
  g.send :pop, 0

  g.goto done
  too_big.set!
  g.push_nil
  @variable.set_bytecode(g)
  g.goto done

  done.set!
  @variable.set_bytecode(g)
  g.pop
end

#position_bytecode(g) ⇒ Object



815
816
817
818
# File 'lib/rubinius/ast/variables.rb', line 815

def position_bytecode(g)
  @variable.get_bytecode(g)
  g.cast_array
end