00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #include "andcondexpression.h"
00036
00037 AndCondExpression::AndCondExpression(CondExpression * _left, CondExpression * _right):
00038 CondExpression(ect_and), left(_left), right(_right) {
00039 }
00040
00041 AndCondExpression::~AndCondExpression() {
00042 delete left;
00043 delete right;
00044 }
00045
00046 void AndCondExpression::scopeCheck(vector < unsigned >&def_vars,
00047 vector < unsigned >&introduced_vars,
00048 vector < unsigned >&violating_vars) {
00049 left->scopeCheck(def_vars, introduced_vars, violating_vars);
00050 right->scopeCheck(def_vars, introduced_vars, violating_vars);
00051 }
00052
00053 void AndCondExpression::replaceVarId(unsigned old_id, unsigned new_id) {
00054 left->replaceVarId(old_id, new_id);
00055 right->replaceVarId(old_id, new_id);
00056 }
00057
00058 void AndCondExpression::extractFSAMap(FSAMap * fsamap, unsigned parent_var) {
00059 left->extractFSAMap(fsamap, parent_var);
00060 right->extractFSAMap(fsamap, parent_var);
00061 }
00062
00063 void AndCondExpression::extractParVarMap(ParVarMap * parvarmap) {
00064 left->extractParVarMap(parvarmap);
00065 right->extractParVarMap(parvarmap);
00066 }
00067
00068 void AndCondExpression::extractDependencies(vector < DependencySet * >*depset) {
00069 left->extractDependencies(depset);
00070 right->extractDependencies(depset);
00071 }
00072
00073 Expression *AndCondExpression::placeSignOffs(vector <
00074 SignOffExpression * >&signoffs) {
00075 left = (CondExpression *) left->placeSignOffs(signoffs);
00076 right = (CondExpression *) right->placeSignOffs(signoffs);
00077
00078 return this;
00079 }
00080
00081 void AndCondExpression::rewriteEmptyFuncts() {
00082 left->rewriteEmptyFuncts();
00083 right->rewriteEmptyFuncts();
00084 }
00085
00086 void AndCondExpression::rewriteVarstepCondExps() {
00087 left->rewriteVarstepCondExps();
00088 right->rewriteVarstepCondExps();
00089 }
00090
00091 void AndCondExpression::rewriteAggregateFuncts() {
00092 left->rewriteAggregateFuncts();
00093 right->rewriteAggregateFuncts();
00094 }
00095
00096 void AndCondExpression::print(OutputStream & dos) const {
00097 EXP_TYPE l = left->getType();
00098
00099 if (l == ect_and || l == ect_or || l == ect_not ||
00100 l == ect_exists || l == ect_operand || l == ect_true
00101 || l == ect_false) {
00102 dos << "(" << (*left) << ")";
00103 } else {
00104 dos << (*left);
00105 }
00106
00107 dos << " and ";
00108
00109 EXP_TYPE r = right->getType();
00110
00111 if (r == ect_and || r == ect_or || r == ect_not ||
00112 r == ect_exists || r == ect_operand || r == ect_true
00113 || r == ect_false) {
00114 dos << "(" << (*right) << ")";
00115 } else {
00116 dos << (*right);
00117 }
00118 }
00119
00120 void AndCondExpression::init(BufferNode * root) {
00121 left->init(root);
00122 right->init(root);
00123 }
00124
00125 void AndCondExpression::eval(OutputStream & eos, Environment * env,
00126 unsigned modus) {
00127
00128 switch (modus) {
00129
00130 case EVAL_SIGNOFF:
00131 left->eval(eos, env, EVAL_SIGNOFF);
00132 right->eval(eos, env, EVAL_SIGNOFF);
00133 break;
00134
00135 default:
00136 throw
00137 RuntimeException("AndCondExpression: Illegal Evaluation Mode",
00138 eid_runtime_illegalmode);
00139 break;
00140 }
00141 }
00142
00143 bool AndCondExpression::evalCond(OutputStream & eos, Environment * env,
00144 unsigned modus) {
00145 bool left_val = left->evalCond(eos, env, modus);
00146
00147 if (left_val) {
00148 return right->evalCond(eos, env, modus);
00149 } else {
00150
00151 right->evalCond(eos, env, EVAL_SIGNOFF);
00152 return false;
00153 }
00154 }