Class: CodeTools::AST::CollectSplat
- Defined in:
- lib/rubinius/code/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.
386 387 388 389 390 391 |
# File 'lib/rubinius/code/ast/sends.rb', line 386 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.
384 385 386 |
# File 'lib/rubinius/code/ast/sends.rb', line 384 def array @array end |
#last ⇒ Object
Returns the value of attribute last.
384 385 386 |
# File 'lib/rubinius/code/ast/sends.rb', line 384 def last @last end |
#splat ⇒ Object
Returns the value of attribute splat.
384 385 386 |
# File 'lib/rubinius/code/ast/sends.rb', line 384 def splat @splat end |
Instance Method Details
#bytecode(g) ⇒ Object
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 424 |
# File 'lib/rubinius/code/ast/sends.rb', line 393 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.goto_if_false not_hash g.make_array 1 g.goto done not_hash.set! g.cast_array done.set! g.send :+, 1 end |
#to_sexp ⇒ Object
426 427 428 |
# File 'lib/rubinius/code/ast/sends.rb', line 426 def to_sexp [:collect_splat] + @array.map { |x| x.to_sexp } end |