Method: Pegarus::Rubinius#char

Defined in:
lib/pegarus/rubinius/compiler.rb

#char(g, string) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/pegarus/rubinius/compiler.rb', line 109

def char(g, string)
  fail = g.new_label
  done = g.new_label

  g.push_literal string
  g.dup
  g.send :size, 0, false
  g.dup
  g.move_down 2

  g.push_subject
  g.swap
  g.push_index
  g.swap
  g.send :substring, 2, false
  g.send :==, 1, false
  g.gif fail

  g.inc_index
  g.goto done

  fail.set!
  g.pop
  g.goto g.fail

  done.set!
end