Class: Rubinius::ToolSet.current::TS::AST::CollectSplat
- Defined in:
- lib/rubinius/ast/sends.rb
Instance Attribute Summary
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.
363 364 365 366 367 368 |
# File 'lib/rubinius/ast/sends.rb', line 363 def initialize(line, *parts) @line = line @splat = parts.shift @last = parts.pop @array = parts end |
Instance Method Details
#bytecode(g) ⇒ Object
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/rubinius/ast/sends.rb', line 370 def bytecode(g) @splat.bytecode(g) g.cast_array @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_const :Hash g.push_type g.move_down 2 g.send :object_kind_of?, 2 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
405 406 407 |
# File 'lib/rubinius/ast/sends.rb', line 405 def to_sexp [:collect_splat] + @parts.map { |x| x.to_sexp } end |