Class: Brainfuck::AST::BwdNode

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

Instance Method Summary collapse

Instance Method Details

#bytecode(g) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/brainfuck/ast.rb', line 30

def bytecode(g)
  g.push_local 1
  g.meta_push_1
  g.meta_send_op_minus 0
  g.set_local 1

  # Check the contents of the new cell
  g.push_local 0   
  g.swap_stack
  g.send :[], 1, false

  fin = g.new_label
  g.git fin
  g.pop

  # If the cell is nil set it to 0
  g.push_local 0
  g.push_local 1
  g.meta_push_0
  g.send :[]=, 2, false

  # Otherwise, do nothing
  fin.set!
end