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

Inherits:
SendWithArguments show all
Defined in:
lib/rubinius/ast/sends.rb

Instance Attribute Summary collapse

Attributes inherited from SendWithArguments

#arguments

Attributes inherited from Send

#block, #name, #privately, #receiver, #variable, #vcall_style

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from SendWithArguments

#arguments_sexp

Methods inherited from Send

#arguments_sexp, #check_local_reference, #receiver_sexp, #sexp_name, #value_defined

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, arguments, unwrap) ⇒ Yield

Returns a new instance of Yield.



962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
# File 'lib/rubinius/ast/sends.rb', line 962

def initialize(line, arguments, unwrap)
  @line = line

  if arguments.kind_of? ArrayLiteral and not unwrap
    arguments = ArrayLiteral.new line, [arguments]
  end

  @arguments = ActualArguments.new line, arguments
  @argument_count = @arguments.size
  @yield_splat = false

  if @arguments.splat?
    splat = @arguments.splat.value
    if (splat.kind_of? ArrayLiteral or splat.kind_of? EmptyArray) and not unwrap
      @argument_count += 1
    else
      @yield_splat = true
    end
  end
end

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



960
961
962
# File 'lib/rubinius/ast/sends.rb', line 960

def flags
  @flags
end

Instance Method Details

#bytecode(g) ⇒ Object



983
984
985
986
987
988
989
990
991
992
993
# File 'lib/rubinius/ast/sends.rb', line 983

def bytecode(g)
  pos(g)

  @arguments.bytecode(g)

  if @yield_splat
    g.yield_splat @argument_count
  else
    g.yield_stack @argument_count
  end
end

#defined(g) ⇒ Object



995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/rubinius/ast/sends.rb', line 995

def defined(g)
  t = g.new_label
  f = g.new_label

  g.push_block
  g.git t
  g.push :nil
  g.goto f

  t.set!
  g.push_literal "yield"

  f.set!
end

#to_sexpObject



1010
1011
1012
# File 'lib/rubinius/ast/sends.rb', line 1010

def to_sexp
  arguments_sexp :yield
end