Class: CodeTools::AST::Return
  
  
  
  
  
    - Inherits:
- 
      Node
      
        
          - Object
- Node
- CodeTools::AST::Return
 show all
    - Defined in:
- lib/rubinius/code/ast/control_flow.rb
 
  Instance Attribute Summary collapse
  
  
  
  Attributes inherited from Node
  #line
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  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, expr)  ⇒ Return 
  
  
  
  
    
Returns a new instance of Return.
   
 
  
  
    | 
678
679
680
681
682 | # File 'lib/rubinius/code/ast/control_flow.rb', line 678
def initialize(line, expr)
  @line = line
  @value = expr
  @splat = nil
end | 
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #value  ⇒ Object 
  
  
  
  
    
Returns the value of attribute value.
   
 
  
  
    | 
676
677
678 | # File 'lib/rubinius/code/ast/control_flow.rb', line 676
def value
  @value
end | 
 
    
   
  
    Instance Method Details
    
      
  
  
    #block=(node)  ⇒ Object 
  
  
  
  
    | 
684
685
686 | # File 'lib/rubinius/code/ast/control_flow.rb', line 684
def block=(node)
  @value.block = node if @value
end | 
 
    
      
  
  
    #bytecode(g, force = false)  ⇒ Object 
  
  
  
  
    | 
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715 | # File 'lib/rubinius/code/ast/control_flow.rb', line 688
def bytecode(g, force=false)
  pos(g)
    if @splat
    splat_node = @value.body.pop
    @value.bytecode(g)
    splat_node.call_bytecode(g)
    g.send :+, 1
  elsif @value
    @value.bytecode(g)
  else
    g.push :nil
  end
  if lcl = g.state.rescue?
    g.push_stack_local lcl
    g.restore_exception_state
  end
  if g.state.block?
    g.raise_return
  elsif !force and g.state.ensure?
    g.ensure_return
  else
    g.ret
  end
end | 
 
    
      
  
  
    #defined(g)  ⇒ Object 
  
  
  
  
    | 
717
718
719 | # File 'lib/rubinius/code/ast/control_flow.rb', line 717
def defined(g)
  g.push_literal "expression"
end | 
 
    
      
  
  
    #to_sexp  ⇒ Object 
  
  
  
  
    | 
721
722
723
724
725
726 | # File 'lib/rubinius/code/ast/control_flow.rb', line 721
def to_sexp
  sexp = [:return]
  sexp << @value.to_sexp if @value
  sexp << @splat.to_sexp if @splat
  sexp
end |