tip.util
Class ExpressionEqualitor.ExpressionEquality

java.lang.Object
  extended by tip.analysis.QuestionAnswerAdapter<Node,java.lang.Boolean>
      extended by tip.util.ExpressionEqualitor.ExpressionEquality
All Implemented Interfaces:
QuestionAnswer<Node,java.lang.Boolean>
Enclosing class:
ExpressionEqualitor

static class ExpressionEqualitor.ExpressionEquality
extends QuestionAnswerAdapter<Node,java.lang.Boolean>

ExpressionEquality is an instance of the QuestionAnswer interface taking question of the type Node and returning answers of the type Boolean. The class determines equality of expressions to use for the ExpressionEqualitor.

AFunctionCallExp nodes are regarded as equal on a node basis since the result of the expression may vary if sideeffects occur.

AFunctionPtrCallExp and ADerefExp nodes are regarded as equal on a node basis since the target value may change through (other) pointer manipulating operations.

AMallocExp and AInputExp nodes as equal on a node basis since the values of the expressions are (potentially) different for each occurence.

Author:
Johnni Winther, jw@brics.dk

Constructor Summary
ExpressionEqualitor.ExpressionEquality()
           
 
Method Summary
 java.lang.Boolean caseABinopExp(ABinopExp a, Node b)
          Returns true if b is an ABinopExp which is equal to a according to this equalitor.
 java.lang.Boolean caseAIntConstExp(AIntConstExp a, Node b)
          Returns true if b is an AIntConstExp which is equal to a according to this equalitor.
 java.lang.Boolean caseANullExp(ANullExp a, Node b)
          Returns true if b is an ANullExp which is equal to a according to this equalitor.
 java.lang.Boolean caseAPointerExp(APointerExp a, Node b)
          Returns true if b is an APointerExp which is equal to a according to this equalitor.
 java.lang.Boolean caseAVarExp(AVarExp a, Node b)
          Returns true if b is an AVarExp which is equal to a according to this equalitor.
 java.lang.Boolean defaultNode(Node a, Node b)
          Returns false as the default result of equality of the two arbitrary nodes a and b.
 
Methods inherited from class tip.analysis.QuestionAnswerAdapter
caseABlock, caseABlockStm, caseABody, caseADeclStm, caseADerefExp, caseADivideBinop, caseAEqBinop, caseAFuncDecl, caseAFunctionCallExp, caseAFunctionPtrCallExp, caseAGtBinop, caseAIfThenElseStm, caseAIfThenStm, caseAInputExp, caseALocalDecl, caseAMallocExp, caseAMinusBinop, caseAOutputStm, caseAPlusBinop, caseAProgram, caseAReturnStm, caseATimesBinop, caseAWhileStm, caseEOF, caseStart, caseTAnd, caseTAssign, caseTComma, caseTCommentBlock, caseTCommentSingle, caseTDiv, caseTElse, caseTEq, caseTGt, caseTIdentifier, caseTIf, caseTInput, caseTIntegerConst, caseTLBrace, caseTLPar, caseTMalloc, caseTMinus, caseTNull, caseTOutput, caseTPlus, caseTRBrace, caseTReturn, caseTRPar, caseTSemicolon, caseTStar, caseTVar, caseTWhile, caseTWhiteSpace, caseAAssignPtrStm, caseAAssignVarStm, defaultPBinop, defaultPBlock, defaultPBody, defaultPDecl, defaultPExp, defaultPProgram, defaultPStm, defaultToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionEqualitor.ExpressionEquality

ExpressionEqualitor.ExpressionEquality()
Method Detail

defaultNode

public java.lang.Boolean defaultNode(Node a,
                                     Node b)
Returns false as the default result of equality of the two arbitrary nodes a and b.

Overrides:
defaultNode in class QuestionAnswerAdapter<Node,java.lang.Boolean>
Parameters:
a - the first node
b - the second node
Returns:
false as the default result

caseABinopExp

public java.lang.Boolean caseABinopExp(ABinopExp a,
                                       Node b)
Returns true if b is an ABinopExp which is equal to a according to this equalitor. Two binary expressions are equal if the arguments and operand are equal taking the commutativity of the operand into account.

Specified by:
caseABinopExp in interface QuestionAnswer<Node,java.lang.Boolean>
Overrides:
caseABinopExp in class QuestionAnswerAdapter<Node,java.lang.Boolean>
Parameters:
a - the binary expression
b - the node tested for equality against a
Returns:
true if b represents the same binary expression

caseAPointerExp

public java.lang.Boolean caseAPointerExp(APointerExp a,
                                         Node b)
Returns true if b is an APointerExp which is equal to a according to this equalitor. Two pointer expressions are equal if the variables are the same. This is only safe as long as the addresses of the variables are static, and is thus not an appropriate equality for analyses computing flow through pointer variables.

Specified by:
caseAPointerExp in interface QuestionAnswer<Node,java.lang.Boolean>
Overrides:
caseAPointerExp in class QuestionAnswerAdapter<Node,java.lang.Boolean>
Parameters:
a - the pointer expression
b - the node tested for equality against a
Returns:
true if b represents the same pointer expression

caseAIntConstExp

public java.lang.Boolean caseAIntConstExp(AIntConstExp a,
                                          Node b)
Returns true if b is an AIntConstExp which is equal to a according to this equalitor. Two constant expressions are equal if the constant values are equal.

Specified by:
caseAIntConstExp in interface QuestionAnswer<Node,java.lang.Boolean>
Overrides:
caseAIntConstExp in class QuestionAnswerAdapter<Node,java.lang.Boolean>
Parameters:
a - the constant expression
b - the node tested for equality against a
Returns:
true if b represents the same contanst expression

caseAVarExp

public java.lang.Boolean caseAVarExp(AVarExp a,
                                     Node b)
Returns true if b is an AVarExp which is equal to a according to this equalitor. Two variable expressions are equal if the variables are the same.

Specified by:
caseAVarExp in interface QuestionAnswer<Node,java.lang.Boolean>
Overrides:
caseAVarExp in class QuestionAnswerAdapter<Node,java.lang.Boolean>
Parameters:
a - the variable expression
b - the node tested for equality against a
Returns:
true if b represents the same variable expression

caseANullExp

public java.lang.Boolean caseANullExp(ANullExp a,
                                      Node b)
Returns true if b is an ANullExp which is equal to a according to this equalitor. Two null expressions are always equal.

Specified by:
caseANullExp in interface QuestionAnswer<Node,java.lang.Boolean>
Overrides:
caseANullExp in class QuestionAnswerAdapter<Node,java.lang.Boolean>
Parameters:
a - the binary expression
b - the node tested for equality against a
Returns:
true if b represents the same binary expression