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

Inherits:
Break
  • Object
show all
Defined in:
lib/rubinius/ast/control_flow.rb

Instance Attribute Summary

Attributes inherited from Break

#value

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Break

#defined, #jump_error, #to_sexp

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, value) ⇒ Next

Returns a new instance of Next.



586
587
588
589
# File 'lib/rubinius/ast/control_flow.rb', line 586

def initialize(line, value)
  @line = line
  @value = value
end

Instance Method Details

#bytecode(g) ⇒ Object



591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# File 'lib/rubinius/ast/control_flow.rb', line 591

def bytecode(g)
  pos(g)

  g.pop if g.state.top_level_ensure?

  # From "The Ruby Programming Lanuage"
  #  "When next is used in a loop, any values following the next
  #   are ignored"
  #
  # By ignored, it must mean evaluated and the value of the expression
  # is thrown away, because 1.8 evaluates them even though it doesn't
  # use them.
  if @value
    @value.bytecode(g)
  else
    g.push :nil
  end

  if g.state.loop?
    g.goto g.next
  elsif g.state.block?
    if g.next
      g.goto g.next
    else
      g.ret
    end
  else
    g.pop

    jump_error g, :next
  end

  g.push_nil if g.state.top_level_ensure?
end

#sexp_nameObject



626
627
628
# File 'lib/rubinius/ast/control_flow.rb', line 626

def sexp_name
  :next
end