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.
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 |
# File 'lib/rubinius/code/ast/sends.rb', line 1052 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.
1050 1051 1052 |
# File 'lib/rubinius/code/ast/sends.rb', line 1050 def flags @flags end |
Instance Method Details
#bytecode(g) ⇒ Object
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 |
# File 'lib/rubinius/code/ast/sends.rb', line 1073 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
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
# File 'lib/rubinius/code/ast/sends.rb', line 1085 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
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 |
# File 'lib/rubinius/code/ast/sends.rb', line 1100 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 |