Class: Rubinius::ToolSet.current::TS::AST::Flip2
- Inherits:
-
Node
- Object
- Node
- Rubinius::ToolSet.current::TS::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.
228
229
230
231
232
|
# File 'lib/rubinius/ast/control_flow.rb', line 228
def initialize(line, start, finish)
@line = line
@start = start
@finish = finish
end
|
Instance Method Details
#bytecode(g) ⇒ Object
242
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
|
# File 'lib/rubinius/ast/control_flow.rb', line 242
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
238
239
240
|
# File 'lib/rubinius/ast/control_flow.rb', line 238
def exclusive?
false
end
|
#get_flip_flop(g, index) ⇒ Object
273
274
275
276
277
278
|
# File 'lib/rubinius/ast/control_flow.rb', line 273
def get_flip_flop(g, index)
g.push_literal Compiler::Runtime
g.push_scope
g.push_literal index
g.send(:get_flip_flop, 2)
end
|
#set_flip_flop(g, index, value) ⇒ Object
280
281
282
283
284
285
286
|
# File 'lib/rubinius/ast/control_flow.rb', line 280
def set_flip_flop(g, index, value)
g.push_literal Compiler::Runtime
g.push_scope
g.push_literal index
g.push_literal value
g.send(:set_flip_flop, 3)
end
|
#sexp_name ⇒ Object
234
235
236
|
# File 'lib/rubinius/ast/control_flow.rb', line 234
def sexp_name
:flip2
end
|
#to_sexp ⇒ Object
288
289
290
|
# File 'lib/rubinius/ast/control_flow.rb', line 288
def to_sexp
[sexp_name, @start.to_sexp, @finish.to_sexp]
end
|