module AdLint::Cc1::ScalarValueFactory

Public Instance Methods

not_of(numeric_or_range, logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 419
def not_of(numeric_or_range, logical_shr)
  case numeric_or_range
  when Numeric
    new(ValueDomain.not_equal_to(numeric_or_range, logical_shr))
  when Range
    new(ValueDomain.less_than(
      numeric_or_range.first, logical_shr
    ).union(ValueDomain.greater_than(
      numeric_or_range.last, logical_shr
    )))
  else
    raise TypeError, "argument must be a Numeric or a Range."
  end
end
of(numeric_or_range, logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 404
def of(numeric_or_range, logical_shr)
  case numeric_or_range
  when Numeric
    new(ValueDomain.equal_to(numeric_or_range, logical_shr))
  when Range
    new(ValueDomain.greater_than_or_equal_to(
      numeric_or_range.first, logical_shr
    ).intersection(ValueDomain.less_than_or_equal_to(
      numeric_or_range.last, logical_shr
    )))
  else
    raise TypeError, "argument must be a Numeric or a Range."
  end
end
of_arbitrary(logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 448
def of_arbitrary(logical_shr)
  new(ValueDomain.of_unlimited(logical_shr))
end
of_false(logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 438
def of_false(logical_shr)
  of(0, logical_shr)
end
of_nan(logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 464
def of_nan(logical_shr)
  new(ValueDomain.of_nan(logical_shr))
end
of_nil(logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 460
def of_nil(logical_shr)
  new(ValueDomain.of_nil(logical_shr))
end
of_null(logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 442
def of_null(logical_shr)
  # TODO: NULL may not be 0 on some environments. Representation of NULL
  #       should be configurable?
  of(0, logical_shr)
end
of_true(logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 434
def of_true(logical_shr)
  not_of(0, logical_shr)
end
of_undefined(range, logical_shr) click to toggle source
# File lib/adlint/cc1/value.rb, line 452
def of_undefined(range, logical_shr)
  new(ValueDomain.of_undefined(ValueDomain.greater_than_or_equal_to(
    range.first, logical_shr
  ).intersection(ValueDomain.less_than_or_equal_to(
    range.last, logical_shr
  ))))
end