Class: CodeTools::AST::CollectSplat
- Defined in:
- lib/rubinius/ast/sends.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
-
#last ⇒ Object
Returns the value of attribute last.
-
#splat ⇒ Object
Returns the value of attribute splat.
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
-
#initialize(line, *parts) ⇒ CollectSplat
constructor
A new instance of CollectSplat.
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, #defined, 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, *parts) ⇒ CollectSplat
Returns a new instance of CollectSplat.
377 378 379 380 381 382 |
# File 'lib/rubinius/ast/sends.rb', line 377 def initialize(line, *parts) @line = line @splat = parts.shift @last = parts.pop @array = parts end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
375 376 377 |
# File 'lib/rubinius/ast/sends.rb', line 375 def array @array end |
#last ⇒ Object
Returns the value of attribute last.
375 376 377 |
# File 'lib/rubinius/ast/sends.rb', line 375 def last @last end |
#splat ⇒ Object
Returns the value of attribute splat.
375 376 377 |
# File 'lib/rubinius/ast/sends.rb', line 375 def splat @splat end |
Instance Method Details
#bytecode(g) ⇒ Object
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/rubinius/ast/sends.rb', line 384 def bytecode(g) @splat.bytecode(g) @array.each do |x| x.bytecode(g) g.cast_array g.send :+, 1 end return unless @last not_hash = g.new_label done = g.new_label @last.bytecode(g) g.dup g.push_cpath_top g.find_const :Hash g.swap g.kind_of g.gif not_hash g.make_array 1 g.goto done not_hash.set! g.cast_array done.set! g.send :+, 1 end |
#to_sexp ⇒ Object
417 418 419 |
# File 'lib/rubinius/ast/sends.rb', line 417 def to_sexp [:collect_splat] + @parts.map { |x| x.to_sexp } end |