class Atomy::Pattern::And

Attributes

a[R]
b[R]

Public Class Methods

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

Public Instance Methods

assign(gen) click to toggle source
# File lib/atomy/pattern/and.rb, line 48
def assign(gen)
  @a.assign(gen)
  @b.assign(gen)
end
inline_matches?(gen) click to toggle source
# File lib/atomy/pattern/and.rb, line 16
def inline_matches?(gen)
  mismatch = gen.new_label
  done = gen.new_label

  # [value, value]
  gen.dup

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

  # [value]
  gen.goto_if_false(mismatch)

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

  # [bool]
  gen.goto(done)

  # [value]
  mismatch.set!

  # []
  gen.pop

  # [bool]
  gen.push_false

  # [bool]
  done.set!
end
matches?(val) click to toggle source
# File lib/atomy/pattern/and.rb, line 12
def matches?(val)
  @a.matches?(val) && @b.matches?(val)
end
target() click to toggle source
# File lib/atomy/pattern/and.rb, line 53
def target
  a = @a.target
  b = @b.target
  a < b ? a : b
end