Class: Rubinius::AST::SingleBlockArg

Inherits:
SendWithArguments show all
Defined in:
lib/compiler/ast/transforms.rb

Overview

Handles Rubinius.single_block_arg

Given the following code:

m { |x| ... }

In Ruby 1.8, this has the following semantics:

* x == nil if no values are yielded
* x == val if one value is yielded
* x == [p, q, r, ...] if more than one value is yielded
* x == [a, b, c, ...] if one Array is yielded

In Ruby 1.9, this has the following semantics:

* x == nil if no values are yielded
* x == val if one value is yielded
* x == p if yield(p, q, r, ...)
* x == [a, b, c, ...] if one Array is yielded

However, in Ruby 1.9, the Enumerator code manually implements the 1.8 block argument semantics. This transform exposes the VM instruction we use in 1.8 mode (cast_for_single_block_arg) so we can use it in 1.9 mode for Enumerator.

Instance Attribute Summary

Attributes inherited from SendWithArguments

#arguments

Attributes inherited from Send

#block, #check_for_local, #name, #privately, #receiver, #variable

Attributes inherited from Node

#line

Class Method Summary collapse

Methods inherited from SendWithArguments

#arguments_sexp, #initialize

Methods inherited from Send

#arguments_sexp, #check_local_reference, #initialize, #receiver_sexp, #sexp_name, #to_sexp

Methods inherited from Node

#ascii_graph, #attributes, #children, #initialize, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, node_name, #pos, #set_child, #to_sexp, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk

Constructor Details

This class inherits a constructor from Rubinius::AST::SendWithArguments

Class Method Details

.match?(line, receiver, name, arguments, privately) ⇒ Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/compiler/ast/transforms.rb', line 125

def self.match?(line, receiver, name, arguments, privately)
  match_send? receiver, :Rubinius, name, :single_block_arg
end