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.
385 386 387 388 389 390 |
# File 'lib/rubinius/ast/sends.rb', line 385 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.
383 384 385 |
# File 'lib/rubinius/ast/sends.rb', line 383 def array @array end |
#last ⇒ Object
Returns the value of attribute last.
383 384 385 |
# File 'lib/rubinius/ast/sends.rb', line 383 def last @last end |
#splat ⇒ Object
Returns the value of attribute splat.
383 384 385 |
# File 'lib/rubinius/ast/sends.rb', line 383 def splat @splat end |
Instance Method Details
#bytecode(g) ⇒ Object
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/rubinius/ast/sends.rb', line 392 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
425 426 427 |
# File 'lib/rubinius/ast/sends.rb', line 425 def to_sexp [:collect_splat] + @array.map { |x| x.to_sexp } end |