Class: Rubinius::AST::Block
- Defined in:
- lib/compiler/ast/definitions.rb
Overview
Is it weird that Block has the :arguments attribute? Yes. Is it weird that MRI parse tree puts arguments and block_arg in Block? Yes. So we make do and pull them out here rather than having something else reach inside of Block.
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
-
#locals ⇒ Object
Returns the value of attribute locals.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(line, array) ⇒ Block
constructor
A new instance of Block.
- #strip_arguments ⇒ Object
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, node_name, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk
Constructor Details
#initialize(line, array) ⇒ Block
Returns a new instance of Block.
45 46 47 48 49 50 51 52 |
# File 'lib/compiler/ast/definitions.rb', line 45 def initialize(line, array) @line = line @array = array # These are any local variable that are declared as explicit # locals for this scope. This is only used by the |a;b| syntax. @locals = nil end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
43 44 45 |
# File 'lib/compiler/ast/definitions.rb', line 43 def array @array end |
#locals ⇒ Object
Returns the value of attribute locals.
43 44 45 |
# File 'lib/compiler/ast/definitions.rb', line 43 def locals @locals end |
Instance Method Details
#strip_arguments ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/compiler/ast/definitions.rb', line 54 def strip_arguments if @array.first.kind_of? FormalArguments node = @array.shift if @array.first.kind_of? BlockArgument node.block_arg = @array.shift end return node end end |
#to_sexp ⇒ Object
64 65 66 |
# File 'lib/compiler/ast/definitions.rb', line 64 def to_sexp @array.inject([:block]) { |s, x| s << x.to_sexp } end |