class Atomy::Pattern::Or

Attributes

a[R]
b[R]

Public Class Methods

new(a, b) click to toggle source
# File lib/atomy/pattern/or.rb, line 7
def initialize(a, b)
  @a = a
  @b = b
end

Public Instance Methods

inline_matches?(gen) click to toggle source
# File lib/atomy/pattern/or.rb, line 16
def inline_matches?(gen)
  match = gen.new_label
  done = gen.new_label

  # [value, value]
  gen.dup

  # [bool, value]
  @a.inline_matches?(gen)

  # [value]
  gen.goto_if_true(match)

  # [bool]
  @b.inline_matches?(gen)

  # [bool]
  gen.goto(done)

  # [value]
  match.set!

  # []
  gen.pop

  # [bool]
  gen.push_true

  # [bool]
  done.set!
end
matches?(val) click to toggle source
# File lib/atomy/pattern/or.rb, line 12
def matches?(val)
  @a.matches?(val) || @b.matches?(val)
end