Class: Brainfuck::AST::GetsNode

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

Instance Method Summary collapse

Instance Method Details

#bytecode(g) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/brainfuck/ast.rb', line 96

def bytecode(g)
  g.push :self
  g.push_literal "stty raw -echo"
  g.send :system, 1, true
  g.pop

  g.push_local 0
  g.push_local 1

  g.push_const :STDIN
  g.send :getc, 0, false

  g.send :[]=, 2, false

  g.push :self
  g.push_literal "stty -raw echo"
  g.send :system, 1, true
  g.pop
end