Class: Brainfuck::AST::IterationNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/brainfuck/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expObject

Returns the value of attribute exp

Returns:

  • (Object)

    the current value of exp



116
117
118
# File 'lib/brainfuck/ast.rb', line 116

def exp
  @exp
end

Instance Method Details

#bytecode(g) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/brainfuck/ast.rb', line 117

def bytecode(g)
  repeat = g.new_label
  repeat.set!

  exp.bytecode(g)

  g.push_local 0
  g.push_local 1
  g.send :[], 1, true
  g.meta_push_0
  g.meta_send_op_equal 0

  g.gif repeat
end