Class: CodeTools::AST::Yield
- Inherits:
-
SendWithArguments
- Object
- Node
- Send
- SendWithArguments
- CodeTools::AST::Yield
- Defined in:
- lib/rubinius/code/ast/sends.rb
Instance Attribute Summary collapse
-
#flags ⇒ Object
Returns the value of attribute flags.
Attributes inherited from SendWithArguments
Attributes inherited from Send
#block, #name, #privately, #receiver, #variable, #vcall_style
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
- #defined(g) ⇒ Object
-
#initialize(line, arguments, unwrap) ⇒ Yield
constructor
A new instance of Yield.
- #to_sexp ⇒ Object
Methods inherited from SendWithArguments
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.
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
# File 'lib/rubinius/code/ast/sends.rb', line 995 def initialize(line, arguments, unwrap) @line = line if arguments.kind_of? ArrayLiteral and not unwrap arguments = ArrayLiteral.new line, [arguments] end @arguments = Arguments.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
#flags ⇒ Object
Returns the value of attribute flags.
993 994 995 |
# File 'lib/rubinius/code/ast/sends.rb', line 993 def flags @flags end |
Instance Method Details
#bytecode(g) ⇒ Object
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
# File 'lib/rubinius/code/ast/sends.rb', line 1016 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
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'lib/rubinius/code/ast/sends.rb', line 1028 def defined(g) t = g.new_label f = g.new_label g.push_block g.goto_if_true t g.push_nil g.goto f t.set! g.push_literal "yield" f.set! end |
#to_sexp ⇒ Object
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 |
# File 'lib/rubinius/code/ast/sends.rb', line 1043 def to_sexp args = @arguments.to_sexp args << @block.to_sexp if @block if @argument_count == 1 and !@yield_splat and @arguments.splat.nil? and @arguments.array.first.kind_of? SplatValue [:yield, [:array] + args] else [:yield] + args end end |