Class: CodeTools::AST::SplatValue
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::SplatValue
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, value) ⇒ SplatValue
Returns a new instance of SplatValue.
8
9
10
11
|
# File 'lib/rubinius/ast/values.rb', line 8
def initialize(line, value)
@line = line
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6
7
8
|
# File 'lib/rubinius/ast/values.rb', line 6
def value
@value
end
|
Instance Method Details
#bytecode(g) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/rubinius/ast/values.rb', line 13
def bytecode(g)
done = g.new_label
coerce = g.new_label
make_array = g.new_label
@value.bytecode(g)
kind_of_array(g, done)
g.dup
g.push_literal :to_a
g.push :true
g.send :respond_to?, 2, true
g.git coerce
make_array.set!
g.make_array 1
g.goto done
coerce.set!
g.dup
g.send :to_a, 0, true
discard = g.new_label
check_array = g.new_label
g.dup
g.push :nil
g.send :equal?, 1, true
g.gif check_array
g.pop
g.goto make_array
check_array.set!
kind_of_array(g, discard)
g.push_type
g.move_down 2
g.push_literal :to_a
g.push_cpath_top
g.find_const :Array
g.send :coerce_to_type_error, 4, true
g.goto done
discard.set!
g.swap
g.pop
done.set!
end
|
#kind_of_array(g, label) ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'lib/rubinius/ast/values.rb', line 64
def kind_of_array(g, label)
g.dup
g.push_cpath_top
g.find_const :Array
g.swap
g.kind_of
g.git label
end
|
#splat? ⇒ Boolean
77
78
79
|
# File 'lib/rubinius/ast/values.rb', line 77
def splat?
true
end
|
#to_sexp ⇒ Object
73
74
75
|
# File 'lib/rubinius/ast/values.rb', line 73
def to_sexp
[:splat, @value.to_sexp]
end
|