Class: CodeTools::AST::Flip2
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::Flip2
show all
- Defined in:
- lib/rubinius/ast/control_flow.rb
Direct Known Subclasses
Flip3
Instance Attribute Summary
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, start, finish) ⇒ Flip2
Returns a new instance of Flip2.
229
230
231
232
233
|
# File 'lib/rubinius/ast/control_flow.rb', line 229
def initialize(line, start, finish)
@line = line
@start = start
@finish = finish
end
|
Instance Method Details
#bytecode(g) ⇒ Object
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/rubinius/ast/control_flow.rb', line 243
def bytecode(g)
done = g.new_label
on_label = g.new_label
index = g.state.flip_flops
g.state.push_flip_flop
get_flip_flop(g, index)
g.git on_label
@start.bytecode(g)
g.dup
g.gif done
g.pop
set_flip_flop(g, index, true)
if exclusive?
g.goto done
else
g.pop
end
on_label.set!
g.push_literal true
@finish.bytecode(g)
g.gif done
set_flip_flop(g, index, false)
g.pop
done.set!
end
|
#exclusive? ⇒ Boolean
239
240
241
|
# File 'lib/rubinius/ast/control_flow.rb', line 239
def exclusive?
false
end
|
#get_flip_flop(g, index) ⇒ Object
274
275
276
277
278
279
280
|
# File 'lib/rubinius/ast/control_flow.rb', line 274
def get_flip_flop(g, index)
g.push_rubinius
g.find_const :Runtime
g.push_scope
g.push_literal index
g.send(:get_flip_flop, 2)
end
|
#set_flip_flop(g, index, value) ⇒ Object
282
283
284
285
286
287
288
289
|
# File 'lib/rubinius/ast/control_flow.rb', line 282
def set_flip_flop(g, index, value)
g.push_rubinius
g.find_const :Runtime
g.push_scope
g.push_literal index
g.push_literal value
g.send(:set_flip_flop, 3)
end
|
#sexp_name ⇒ Object
235
236
237
|
# File 'lib/rubinius/ast/control_flow.rb', line 235
def sexp_name
:flip2
end
|
#to_sexp ⇒ Object
291
292
293
|
# File 'lib/rubinius/ast/control_flow.rb', line 291
def to_sexp
[sexp_name, @start.to_sexp, @finish.to_sexp]
end
|