1 #ifndef INT_ARITH_LOGICAL
2 #define INT_ARITH_LOGICAL
10 #include "spearWrap.h"
11 #include "printAnalysisStates.h"
39 typedef enum {eq=SpearOp::Equal, le=SpearOp::SgnLTE} cmpOps;
42 typedef enum {andOp=SpearOp::AndOp, orOp=SpearOp::OrOp, notOp=SpearOp::NotOp} logOps;
47 typedef enum {eLeaf, lNode} elt;
48 virtual elt elType()=0;
50 typedef enum {isTrue, exprKnown, isFalse} infContent;
51 virtual infContent getLevel()=0;
55 virtual bool setToTrue()=0;
59 virtual bool setToFalse()=0;
63 virtual bool notUpd()=0;
72 bool operator<(
exprLeafOrNode& that) {
return (*
this != that) && (*
this <= that); }
73 bool operator>=(
exprLeafOrNode& that) {
return (*
this == that) && !(*
this <= that); }
74 bool operator>(
exprLeafOrNode& that) {
return (*
this != that) && (*
this >= that); }
79 virtual std::string str(std::string indent=
"")=0;
102 exprLeafOrNode::infContent level;
104 std::list<SpearAbstractVar*> vars;
105 SpearAbstractVar* outVar;
107 bool varsExprInitialized;
129 infContent getLevel();
132 void computeVarsExpr();
138 const std::list<SpearAbstractVar*>& getVars();
141 SpearAbstractVar* getOutVar();
144 const std::string& getExpr();
149 std::string str(std::string indent=
"");
150 std::string str(std::string indent=
"")
const;
151 std::string genStr(std::string indent=
"")
const;
153 elt elType(){
return exprLeafOrNode::eLeaf; }
166 bool andExprs(
const exprLeaf& that,
bool &modified);
168 bool andExprsTest(
const exprLeaf& that);
175 bool orExprs(
const exprLeaf& that,
bool &modified);
177 bool orExprsTest(
const exprLeaf& that);
190 std::list<exprLeafOrNode*> children;
192 exprLeafOrNode::infContent level;
194 bool varsExprInitialized;
195 std::list<SpearAbstractVar*> vars;
196 SpearAbstractVar* outVar;
209 logicNode(logOps logOp,
const std::list<exprLeafOrNode*>& children);
232 infContent getLevel();
236 const std::list<SpearAbstractVar*>& getVars();
239 SpearAbstractVar* getOutVar();
242 const std::string& getExpr();
247 std::string str(std::string indent=
"");
248 std::string str(std::string indent=
"")
const;
249 std::string genStr(std::string indent=
"")
const;
252 void computeVarsExpr();
255 elt elType(){
return exprLeafOrNode::lNode; }
273 void genChildrenConj(std::list<exprLeafOrNode*>& newChildren, std::list<exprLeafOrNode*> newConjOrig,
274 std::list<exprLeafOrNode*>::const_iterator curChild);
287 bool replaceVar(
varID var,
int p,
int q,
int r);
294 bool removeVar(
varID var);
300 void insertNewChildOr(std::list<exprLeafOrNode*>& newChildren,
exprLeafOrNode* newTerm);
303 bool eqChildren(std::list<exprLeafOrNode*>& one, std::list<exprLeafOrNode*>& two);
360 void initialize(
bool value);
369 bool meetUpdate(
Lattice* that);
371 bool operator==(
Lattice* that);
376 std::string str(std::string indent=
"");
400 bool removeVar(
varID var);
412 SpearVar outputSpearExpr(
exprLeaf* otherExpr, std::ofstream &os,
bool createProposition);
415 static bool runSpear(std::string inputFile);
420 bool isImplied(cmpOps cmp,
int a,
varID x,
int b,
varID y,
int c);
427 bool mayConsistent(cmpOps cmp,
int a,
varID x,
int b,
varID y,
int c);
431 bool assign(
int a,
varID x,
int b,
varID y,
int c);
451 this->expr = that.expr;
456 std::string str(std::string indent=
"");
482 void runIntArithLogicalPlacer(
bool printStates);
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes, since similar to statement, expressions have a concrete location within the user's source code.