Class BooleanAbstraction
java.lang.Object
org.variantsync.diffdetective.feature.BooleanAbstraction
Boolean abstraction for conditions in preprocessor macros.
Boolean abstraction heuristically reduces expressions in
higher-order logic (e.g., including arithmetics of function calls)
to a propositional formula.
Non-boolean expressions are replaced by respectively named variables.
- Author:
- Paul Bittner
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Abstraction value for additions+
.static final String
Abstraction value for bitwise and&
.static final String
Abstraction value for 'and' assign operator&=
.static final String
Abstraction value for assign operator=
.static final String
Abstraction value for opening brackets(
.static final String
Abstraction value for closing brackets)
.static final String
Abstraction value for backslash\
.static final String
Abstraction value for the alternative of the ternary operator:
, or just colons.static final String
Abstraction value for defined operatordefined
.static final String
Abstraction value for divisions/
.static final String
Abstraction value for div assign operator/=
.static final String
Abstraction value for dots in paths.
.static final String
Abstraction value for equality checks==
.static final String
Abstraction value for greater-equals checks>=
.static final String
Abstraction value for greater checks>
.static final String
Abstraction value for has_attribute operator__has_attribute(ATTRIBUTE)
.static final String
Abstraction value for has_builtin operator__has_builtin(BUILTIN)
.static final String
Abstraction value for has_c_attribute operator__has_c_attribute(ATTRIBUTE)
.static final String
Abstraction value for has_cpp_attribute operator__has_cpp_attribute(ATTRIBUTE)
.static final String
Abstraction value for has_include operator__has_include(INCLUDE)
.static final String
Abstraction value for logical and&&
.static final String
Abstraction value for logical or||
.static final String
Abstraction value for left shift assign operator<<=
.static final String
Abstraction value for smaller-equals checks<=
.static final String
Abstraction value for bitwise left shift<<
.static final String
Abstraction value for smaller checks<
.static final String
Abstraction value for minus assign operator-=
.static final String
Abstraction value for modulo%
.static final String
Abstraction value for mod assign operator%=
.static final String
Abstraction value for multiplications*
.static final String
Abstraction value for inequality checks!=
.static final String
Abstraction value for bitwise not~
.static final String
Abstraction value for bitwise or|
.static final String
Abstraction value for 'or' assign operator|=
.static final String
Abstraction value for plus assign operator+=
.static final String
Abstraction value for quotation marks in paths"
.private static final List<BooleanAbstraction.Replacement>
static final String
Abstraction value for right shift assign operator>>=
.static final String
Abstraction value for bitwise right shift>>
.static final String
Abstraction value for single quotation marks'
.static final String
Abstraction value for star assign operator*=
.static final String
Abstraction value for subtractions-
.static final String
Abstraction value for the condition of the ternary operator?
.static final String
Abstraction value for unary 'and'&
.static final String
Abstraction value for unary minus-
.static final String
Abstraction value for unary not!
.static final String
Abstraction value for unary plus+
.static final String
Abstraction value for unary star*
.static final String
Abstraction value for unary tilde~
.static final String
Abstraction value for whitespacestatic final String
Abstraction value for bitwise xor^
.static final String
Abstraction value for xor assign operator^=
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
abstractAll
(String formula) Apply all possible abstraction replacements for substrings of the given formula.static String
abstractToken
(String text) Search for the first replacement that matches the entire text and apply it.
-
Field Details
-
EQ
Abstraction value for equality checks==
.- See Also:
-
NEQ
Abstraction value for inequality checks!=
.- See Also:
-
GEQ
Abstraction value for greater-equals checks>=
.- See Also:
-
LEQ
Abstraction value for smaller-equals checks<=
.- See Also:
-
GT
Abstraction value for greater checks>
.- See Also:
-
LT
Abstraction value for smaller checks<
.- See Also:
-
SUB
Abstraction value for subtractions-
.- See Also:
-
ADD
Abstraction value for additions+
.- See Also:
-
MUL
Abstraction value for multiplications*
.- See Also:
-
DIV
Abstraction value for divisions/
.- See Also:
-
MOD
Abstraction value for modulo%
.- See Also:
-
LSHIFT
Abstraction value for bitwise left shift<<
.- See Also:
-
RSHIFT
Abstraction value for bitwise right shift>>
.- See Also:
-
NOT
Abstraction value for bitwise not~
.- See Also:
-
AND
Abstraction value for bitwise and&
.- See Also:
-
OR
Abstraction value for bitwise or|
.- See Also:
-
XOR
Abstraction value for bitwise xor^
.- See Also:
-
THEN
Abstraction value for the condition of the ternary operator?
.- See Also:
-
COLON
Abstraction value for the alternative of the ternary operator:
, or just colons.- See Also:
-
BRACKET_L
Abstraction value for opening brackets(
.- See Also:
-
BRACKET_R
Abstraction value for closing brackets)
.- See Also:
-
U_AND
Abstraction value for unary 'and'&
.- See Also:
-
U_STAR
Abstraction value for unary star*
.- See Also:
-
U_PLUS
Abstraction value for unary plus+
.- See Also:
-
U_MINUS
Abstraction value for unary minus-
.- See Also:
-
U_TILDE
Abstraction value for unary tilde~
.- See Also:
-
U_NOT
Abstraction value for unary not!
.- See Also:
-
L_AND
Abstraction value for logical and&&
.- See Also:
-
L_OR
Abstraction value for logical or||
.- See Also:
-
DOT
Abstraction value for dots in paths.
.- See Also:
-
QUOTE
Abstraction value for quotation marks in paths"
.- See Also:
-
SQUOTE
Abstraction value for single quotation marks'
.- See Also:
-
ASSIGN
Abstraction value for assign operator=
.- See Also:
-
STAR_ASSIGN
Abstraction value for star assign operator*=
.- See Also:
-
DIV_ASSIGN
Abstraction value for div assign operator/=
.- See Also:
-
MOD_ASSIGN
Abstraction value for mod assign operator%=
.- See Also:
-
PLUS_ASSIGN
Abstraction value for plus assign operator+=
.- See Also:
-
MINUS_ASSIGN
Abstraction value for minus assign operator-=
.- See Also:
-
LEFT_SHIFT_ASSIGN
Abstraction value for left shift assign operator<<=
.- See Also:
-
RIGHT_SHIFT_ASSIGN
Abstraction value for right shift assign operator>>=
.- See Also:
-
AND_ASSIGN
Abstraction value for 'and' assign operator&=
.- See Also:
-
XOR_ASSIGN
Abstraction value for xor assign operator^=
.- See Also:
-
OR_ASSIGN
Abstraction value for 'or' assign operator|=
.- See Also:
-
WHITESPACE
Abstraction value for whitespace- See Also:
-
BSLASH
Abstraction value for backslash\
.- See Also:
-
HAS_ATTRIBUTE
Abstraction value for has_attribute operator__has_attribute(ATTRIBUTE)
. One of the six special operators that require abstraction.- See Also:
-
HAS_CPP_ATTRIBUTE
Abstraction value for has_cpp_attribute operator__has_cpp_attribute(ATTRIBUTE)
. One of the six special preprocessor operators that require abstraction.- See Also:
-
HAS_C_ATTRIBUTE
Abstraction value for has_c_attribute operator__has_c_attribute(ATTRIBUTE)
. One of the six special preprocessor operators that require abstraction.- See Also:
-
HAS_BUILTIN
Abstraction value for has_builtin operator__has_builtin(BUILTIN)
. One of the six special preprocessor operators that require abstraction.- See Also:
-
HAS_INCLUDE
Abstraction value for has_include operator__has_include(INCLUDE)
. One of the six special preprocessor operators that require abstraction.- See Also:
-
DEFINED
Abstraction value for defined operatordefined
. One of the six special preprocessor operators that require abstraction.- See Also:
-
REPLACEMENTS
-
-
Constructor Details
-
BooleanAbstraction
private BooleanAbstraction()
-
-
Method Details
-
abstractAll
Apply all possible abstraction replacements for substrings of the given formula.- Parameters:
formula
- the formula to abstract- Returns:
- a fully abstracted formula
-
abstractToken
Search for the first replacement that matches the entire text and apply it. This is the case, if the given text corresponds to a single token (e.g., '&&', '||'). If no replacement for the entire text is found (e.g., if the token has no replacement), all possible replacements are applied to abstract substrings of the token that require abstraction.
The purpose of this method is to achieve a slight speedup for scenarios in which the text usually contains a single token. For example, this is useful when abstracting individual tokens of an extracted preprocessor formula in
AbstractingCExpressionVisitor
. In all other cases, directly callingabstractAll(String)
should be preferred.- Parameters:
text
- the text to abstract- Returns:
- a fully abstracted text
-