Class: CodeTools::AST::BackRef
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::BackRef
show all
- Defined in:
- lib/rubinius/code/ast/variables.rb
Constant Summary
collapse
- Kinds =
{
:~ => 0,
:& => 1,
:"`" => 2,
:"'" => 3,
:+ => 4
}
Instance Attribute Summary collapse
Attributes inherited from Node
#line
Instance Method Summary
collapse
Methods inherited from Node
#ascii_graph, #attributes, #children, 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, ref) ⇒ BackRef
Returns a new instance of BackRef.
8
9
10
11
|
# File 'lib/rubinius/code/ast/variables.rb', line 8
def initialize(line, ref)
@line = line
@kind = ref
end
|
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
6
7
8
|
# File 'lib/rubinius/code/ast/variables.rb', line 6
def kind
@kind
end
|
Instance Method Details
#bytecode(g) ⇒ Object
29
30
31
32
|
# File 'lib/rubinius/code/ast/variables.rb', line 29
def bytecode(g)
pos(g)
g.last_match mode, 0
end
|
#defined(g) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/rubinius/code/ast/variables.rb', line 34
def defined(g)
if @kind == :~
g.push_literal "global-variable"
g.string_dup
return
end
f = g.new_label
done = g.new_label
g.last_match mode, 0
g.goto_if_nil f
g.push_literal "global-variable"
g.string_dup
g.goto done
f.set!
g.push_nil
done.set!
end
|
#mode ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/rubinius/code/ast/variables.rb', line 21
def mode
unless mode = Kinds[@kind]
raise "Unknown backref: #{@kind}"
end
mode
end
|
#to_sexp ⇒ Object
58
59
60
|
# File 'lib/rubinius/code/ast/variables.rb', line 58
def to_sexp
[:back_ref, @kind]
end
|