Class: Rubinius::ToolSet.current::TS::AST::ConcatArgs

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/ast/values.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

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, array, rest) ⇒ ConcatArgs

Returns a new instance of ConcatArgs.



30
31
32
33
34
# File 'lib/rubinius/ast/values.rb', line 30

def initialize(line, array, rest)
  @line = line
  @array = array
  @rest = rest
end

Instance Attribute Details

#arrayObject

Returns the value of attribute array.



28
29
30
# File 'lib/rubinius/ast/values.rb', line 28

def array
  @array
end

#restObject

Returns the value of attribute rest.



28
29
30
# File 'lib/rubinius/ast/values.rb', line 28

def rest
  @rest
end

Instance Method Details

#bytecode(g) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rubinius/ast/values.rb', line 36

def bytecode(g)
  if @array
    @array.bytecode(g)
    @rest.bytecode(g)
    g.cast_array
    g.send :+, 1
  else
    @rest.bytecode(g)
    g.cast_array
  end
end

#peel_lhsObject

Dive down and try to find an array of regular values that could construct the left side of a concatination. This is used to minimize the splat doing a send.



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubinius/ast/values.rb', line 51

def peel_lhs
  case @array
  when ConcatArgs
    @array.peel_lhs
  when ArrayLiteral
    ary = @array.body
    @array = nil
    ary
  else
    nil
  end
end

#splat?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/rubinius/ast/values.rb', line 68

def splat?
  true
end

#to_sexpObject



64
65
66
# File 'lib/rubinius/ast/values.rb', line 64

def to_sexp
  [:argscat, @array.to_sexp, @rest.to_sexp]
end