Revert getNonIntegerValue unification

This commit is contained in:
Tamas Vajk
2020-10-07 10:56:01 +02:00
parent 1cf3196b61
commit 94dc11c45a
4 changed files with 16 additions and 28 deletions

View File

@@ -41,18 +41,6 @@ private Sign certainExprSign(Expr e) {
)
}
/**
* Gets the value of the expression if it can't be converted to integer, but
* can be converted to float.
*/
private float getNonIntegerValue(ExprWithPossibleValue e) {
exists(string s |
s = e.getValue() and
result = s.toFloat() and
not exists(s.toInt())
)
}
/** Holds if the sign of `e` is too complicated to determine. */
private predicate unknownSign(Expr e) {
not exists(certainExprSign(e)) and

View File

@@ -35,8 +35,6 @@ module Private {
class VariableUpdate = CS::AssignableDefinition;
class ExprWithPossibleValue = CS::Expr;
class Field = CS::Field;
class RealLiteral = CS::RealLiteral;
@@ -130,6 +128,15 @@ private module Impl {
/** Gets the character value of expression `e`. */
string getCharValue(Expr e) { result = e.getValue() and e.getType() instanceof CharType }
/** Gets the constant `float` value of non-`ConstantIntegerExpr` expressions. */
float getNonIntegerValue(Expr e) {
exists(string s |
s = e.getValue() and
result = s.toFloat() and
not exists(s.toInt())
)
}
/**
* Holds if `e` is an access to the size of a container (`string`, `Array`,
* `IEnumerable`, or `ICollection`).

View File

@@ -41,18 +41,6 @@ private Sign certainExprSign(Expr e) {
)
}
/**
* Gets the value of the expression if it can't be converted to integer, but
* can be converted to float.
*/
private float getNonIntegerValue(ExprWithPossibleValue e) {
exists(string s |
s = e.getValue() and
result = s.toFloat() and
not exists(s.toInt())
)
}
/** Holds if the sign of `e` is too complicated to determine. */
private predicate unknownSign(Expr e) {
not exists(certainExprSign(e)) and

View File

@@ -39,8 +39,6 @@ module Private {
class VariableUpdate = J::VariableUpdate;
class ExprWithPossibleValue = J::Literal;
class Field = J::Field;
class DivExpr = J::DivExpr;
@@ -187,6 +185,13 @@ private module Impl {
/** Gets the character value of expression `e`. */
string getCharValue(Expr e) { result = e.(CharacterLiteral).getValue() }
/** Gets the constant `float` value of non-`ConstantIntegerExpr` expressions. */
float getNonIntegerValue(Expr e) {
result = e.(LongLiteral).getValue().toFloat() or
result = e.(FloatingPointLiteral).getValue().toFloat() or
result = e.(DoubleLiteral).getValue().toFloat()
}
/**
* Holds if `e` is an access to the size of a container (`string`, `Map`, or
* `Collection`).