Class: CodeTools::AST::ClassVariableAccess
Instance Attribute Summary
#name
Attributes inherited from Node
#line
Instance Method Summary
collapse
#initialize, #value_defined
Methods inherited from Node
#ascii_graph, #attributes, #children, #initialize, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Instance Method Details
#bytecode(g) ⇒ Object
160
161
162
163
164
165
|
# File 'lib/rubinius/code/ast/variables.rb', line 160
def bytecode(g)
pos(g)
push_scope(g)
g.send :class_variable_get, 1
end
|
#defined(g) ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/rubinius/code/ast/variables.rb', line 182
def defined(g)
f = g.new_label
done = g.new_label
variable_defined(g, f)
g.push_literal "class variable"
g.goto done
f.set!
g.push_nil
done.set!
end
|
#or_bytecode(g) ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/rubinius/code/ast/variables.rb', line 139
def or_bytecode(g)
pos(g)
done = g.new_label
notfound = g.new_label
variable_defined(g, notfound)
bytecode(g)
g.dup
g.goto_if_true done
g.pop
notfound.set!
yield
done.set!
end
|
#push_scope(g) ⇒ Object
167
168
169
170
171
172
173
174
|
# File 'lib/rubinius/code/ast/variables.rb', line 167
def push_scope(g)
if g.state.scope.module?
g.push_self
else
g.push_scope
end
g.push_literal @name
end
|
#to_sexp ⇒ Object
196
197
198
|
# File 'lib/rubinius/code/ast/variables.rb', line 196
def to_sexp
[:cvar, @name]
end
|
#variable_defined(g, f) ⇒ Object
176
177
178
179
180
|
# File 'lib/rubinius/code/ast/variables.rb', line 176
def variable_defined(g, f)
push_scope(g)
g.send :class_variable_defined?, 1
g.goto_if_false f
end
|