class AdLint::Cc1::UnionValueDomain

Public Instance Methods

!() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6824
def !
  new_sub_doms = domain_pair.map { |dom| !dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
&(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6795
def &(rhs_dom)
  if rhs_max = rhs_dom.max_value
    ValueDomain.greater_than_or_equal_to(0, logical_shr?).intersection(
      ValueDomain.less_than_or_equal_to(rhs_max, logical_shr?))
  else
    ValueDomain.greater_than_or_equal_to(0, logical_shr?)
  end
end
*(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6755
def *(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs * rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
+(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6750
def +(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs + rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
+@() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6740
def +@
  new_sub_doms = domain_pair.map { |dom| +dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
-@() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6745
def -@
  new_sub_doms = domain_pair.map { |dom| -dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
/(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6790
def /(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs / rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
<(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6829
def <(rhs_dom)
  comp_dom = domain_pair.map { |lhs| lhs < rhs_dom }
  comp_dom.first.union(comp_dom.last)
end
<<(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6814
def <<(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs << rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
>>(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6819
def >>(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs >> rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
^(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6809
def ^(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs ^ rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
_contain_equal_to?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6687
def _contain_equal_to?(lhs_dom, rhs_dom = self)
  rhs_dom.domain_pair.all? { |rhs| lhs_dom.contain_value_domain?(rhs) }
end
_contain_greater_than?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6695
def _contain_greater_than?(lhs_dom, rhs_dom = self)
  rhs_dom.domain_pair.all? { |rhs| lhs_dom.contain_value_domain?(rhs) }
end
_contain_intersection?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6699
def _contain_intersection?(lhs_dom, rhs_dom = self)
  rhs_dom.domain_pair.all? { |rhs| lhs_dom.contain_value_domain?(rhs) }
end
_contain_less_than?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6691
def _contain_less_than?(lhs_dom, rhs_dom = self)
  rhs_dom.domain_pair.all? { |rhs| lhs_dom.contain_value_domain?(rhs) }
end
_contain_nil?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6679
def _contain_nil?(lhs_dom, rhs_dom = self)
  false
end
_contain_union?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6703
def _contain_union?(lhs_dom, rhs_dom = self)
  lhs_fst, lhs_snd = lhs_dom.domain_pair
  rhs_dom_pair = rhs_dom.domain_pair
  case
  when rhs_dom_pair.all? { |rhs| lhs_fst.contain_value_domain?(rhs) }
    true
  when rhs_dom_pair.all? { |rhs| lhs_snd.contain_value_domain?(rhs) }
    true
  else
    rhs_fst, rhs_snd = rhs_dom.domain_pair
    case
    when lhs_fst.contain_value_domain?(rhs_fst) &&
         lhs_snd.contain_value_domain?(rhs_snd)
      true
    when lhs_fst.contain_value_domain?(rhs_snd) &&
         lhs_snd.contain_value_domain?(rhs_fst)
      true
    else
      false
    end
  end
end
_contain_unlimited?(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6683
def _contain_unlimited?(lhs_dom, rhs_dom = self)
  true
end
_mul_equal_to(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6772
def _mul_equal_to(lhs_dom, rhs_dom = self)
  # NOTE: `LHS * RHS' equals to `RHS * LHS'.
  #       This method invokes CompositeValueDomain#*.
  rhs_dom * lhs_dom
end
_mul_greater_than(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6784
def _mul_greater_than(lhs_dom, rhs_dom = self)
  # NOTE: `LHS * RHS' equals to `RHS * LHS'.
  #       This method invokes CompositeValueDomain#*.
  rhs_dom * lhs_dom
end
_mul_less_than(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6778
def _mul_less_than(lhs_dom, rhs_dom = self)
  # NOTE: `LHS * RHS' equals to `RHS * LHS'.
  #       This method invokes CompositeValueDomain#*.
  rhs_dom * lhs_dom
end
_mul_nil(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6760
def _mul_nil(lhs_dom, rhs_dom = self)
  # NOTE: `LHS * RHS' equals to `RHS * LHS'.
  #       This method invokes CompositeValueDomain#*.
  rhs_dom * lhs_dom
end
_mul_unlimited(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6766
def _mul_unlimited(lhs_dom, rhs_dom = self)
  # NOTE: `LHS * RHS' equals to `RHS * LHS'.
  #       This method invokes CompositeValueDomain#*.
  rhs_dom * lhs_dom
end
coerce_to_integer() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6868
def coerce_to_integer
  new_sub_doms = domain_pair.map { |dom| dom.coerce_to_integer }
  new_sub_doms.first.union(new_sub_doms.last)
end
coerce_to_real() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6873
def coerce_to_real
  new_sub_doms = domain_pair.map { |dom| dom.coerce_to_real }
  new_sub_doms.first.union(new_sub_doms.last)
end
contain_value_domain?(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6675
def contain_value_domain?(rhs_dom)
  rhs_dom._contain_union?(self)
end
each_sample() { |sample| ... } click to toggle source
# File lib/adlint/cc1/domain.rb, line 6905
def each_sample
  return to_enum(:each_sample) unless block_given?
  domain_pair.map { |d| d.each_sample.to_a }.flatten.uniq.each do |sample|
    yield(sample)
  end
end
intersect?(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6726
def intersect?(rhs_dom)
  domain_pair.any? { |lhs| lhs.intersect?(rhs_dom) }
end
intersection(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6844
def intersection(rhs_dom)
  case
  when contain_value_domain?(rhs_dom)
    rhs_dom
  when rhs_dom.contain_value_domain?(self)
    self
  else
    new_sub_doms = domain_pair.map { |lhs| lhs.intersection(rhs_dom) }
    ValueDomain.of_union(*new_sub_doms)
  end
end
inversion() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6730
def inversion
  new_sub_doms = domain_pair.map { |dom| dom.inversion }
  new_sub_doms.first.intersection(new_sub_doms.last)
end
logical_and(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6834
def logical_and(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs.logical_and(rhs_dom) }
  new_sub_doms.first.union(new_sub_doms.last)
end
logical_or(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6839
def logical_or(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs.logical_or(rhs_dom) }
  new_sub_doms.first.union(new_sub_doms.last)
end
max_value() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6896
def max_value
  # NOTE: If this is an "open-domain" (===>---<===), max-value is
  #       undefined.
  #       But, when the domain is (===>--<===>--), max-value is defined.
  max_vals = domain_pair.map { |dom| dom.max_value }
  max_vals.include?(nil) ? nil : max_vals.max
end
min_value() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6878
def min_value
  # NOTE: The union value domain may be a open-domain (==>---<==),
  #       a half-open-domain (==>--<==>-) or (-<==>--<==), or
  #       a close-domain (-<==>-<==>-).
  #       When the union value domain is a open-domain, the min-value is
  #       -infinite.
  #       When the union value domain is a half-open-domain and lower sub
  #       domain is less-than value domain, the min-value is -infinite.
  #       When the union value domain is a half-open-domain and higher sub
  #       domain is greater-than value domain, the min-value is defined by
  #       the lower value domain.
  #       When the union value domain is a close-domain, the min-value is
  #       defined by the lower value domain.
  min_vals = domain_pair.map { |dom| dom.min_value }
  min_vals.include?(nil) ? nil : min_vals.min
end
to_s() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6912
def to_s
  "(#{domain_pair.first.to_s} || #{domain_pair.last.to_s})"
end
union(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6856
def union(rhs_dom)
  case
  when contain_value_domain?(rhs_dom)
    self
  when rhs_dom.contain_value_domain?(self)
    rhs_dom
  else
    new_sub_doms = domain_pair.map { |lhs| lhs.union(rhs_dom) }
    ValueDomain.of_union(*new_sub_doms)
  end
end
|(rhs_dom) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6804
def |(rhs_dom)
  new_sub_doms = domain_pair.map { |lhs| lhs | rhs_dom }
  new_sub_doms.first.union(new_sub_doms.last)
end
~() click to toggle source
# File lib/adlint/cc1/domain.rb, line 6735
def ~
  new_sub_doms = domain_pair.map { |dom| ~dom }
  new_sub_doms.first.union(new_sub_doms.last)
end

Private Instance Methods

_div(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6918
def _div(lhs_dom, rhs_dom = self)
  new_sub_doms = rhs_dom.domain_pair.map { |rhs| lhs_dom / rhs }
  new_sub_doms.first.union(new_sub_doms.last)
end
_equal(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6938
def _equal(lhs_dom, rhs_dom = self)
  # NOTE: The union value domain may be a open-domain (==>---<==),
  #       a half-open-domain (==>--<==>-) or (-<==>--<==), or
  #       a close-domain (-<==>-<==>-).
  #       If one of the sub domains is equal to LHS, result should be true.
  comp_dom = rhs_dom.domain_pair.map { |rhs| lhs_dom == rhs }
  comp_dom.first.union(comp_dom.last)
end
_less(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6933
def _less(lhs_dom, rhs_dom = self)
  comp_dom = rhs_dom.domain_pair.map { |rhs| lhs_dom < rhs }
  comp_dom.first.union(comp_dom.last)
end
_not_equal(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6947
def _not_equal(lhs_dom, rhs_dom = self)
  # NOTE: The union value domain may be a open-domain (==>---<==),
  #       a half-open-domain (==>--<==>-) or (-<==>--<==), or
  #       a close-domain (-<==>-<==>-).
  #       If one of the sub domains is equal to LHS, result should be
  #       false.
  comp_dom = rhs_dom.domain_pair.map { |rhs| lhs_dom != rhs }
  comp_dom.first.union(comp_dom.last)
end
_shl(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6923
def _shl(lhs_dom, rhs_dom = self)
  new_sub_doms = rhs_dom.domain_pair.map { |rhs| lhs_dom << rhs }
  new_sub_doms.first.union(new_sub_doms.last)
end
_shr(lhs_dom, rhs_dom = self) click to toggle source
# File lib/adlint/cc1/domain.rb, line 6928
def _shr(lhs_dom, rhs_dom = self)
  new_sub_doms = rhs_dom.domain_pair.map { |rhs| lhs_dom >> rhs }
  new_sub_doms.first.union(new_sub_doms.last)
end