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 "orcondexpression.h"
00036
00037 OrCondExpression::OrCondExpression(CondExpression * _left, CondExpression * _right):
00038 CondExpression(ect_or), left(_left), right(_right) {
00039 }
00040
00041 OrCondExpression::~OrCondExpression() {
00042 delete left;
00043 delete right;
00044 }
00045
00046 void OrCondExpression::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 OrCondExpression::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 OrCondExpression::extractFSAMap(FSAMap * fsamap, unsigned parent_var) {
00059 left->extractFSAMap(fsamap, parent_var);
00060 right->extractFSAMap(fsamap, parent_var);
00061 }
00062
00063 void OrCondExpression::extractParVarMap(ParVarMap * parvarmap) {
00064 left->extractParVarMap(parvarmap);
00065 right->extractParVarMap(parvarmap);
00066 }
00067
00068 void OrCondExpression::extractDependencies(vector < DependencySet * >*depset) {
00069 left->extractDependencies(depset);
00070 right->extractDependencies(depset);
00071 }
00072
00073 Expression *OrCondExpression::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 OrCondExpression::rewriteEmptyFuncts() {
00082 left->rewriteEmptyFuncts();
00083 right->rewriteEmptyFuncts();
00084 }
00085
00086 void OrCondExpression::rewriteVarstepCondExps() {
00087 left->rewriteVarstepCondExps();
00088 right->rewriteVarstepCondExps();
00089 }
00090
00091 void OrCondExpression::rewriteAggregateFuncts() {
00092 left->rewriteAggregateFuncts();
00093 right->rewriteAggregateFuncts();
00094 }
00095
00096 void OrCondExpression::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 dos << " or ";
00107 EXP_TYPE r = right->getType();
00108
00109 if (r == ect_and || r == ect_or || r == ect_not ||
00110 r == ect_exists || r == ect_operand || r == ect_true
00111 || r == ect_false) {
00112 dos << "(" << (*right) << ")";
00113 } else {
00114 dos << (*right);
00115 }
00116 }
00117
00118 void OrCondExpression::init(BufferNode * root) {
00119 left->init(root);
00120 right->init(root);
00121 }
00122
00123 void OrCondExpression::eval(OutputStream & eos, Environment * env,
00124 unsigned modus) {
00125
00126 switch (modus) {
00127
00128 case EVAL_SIGNOFF:
00129 left->eval(eos, env, EVAL_SIGNOFF);
00130 right->eval(eos, env, EVAL_SIGNOFF);
00131 break;
00132
00133 default:
00134 throw RuntimeException("OrCondExpression: Illegal Evaluation Mode",
00135 eid_runtime_illegalmode);
00136 break;
00137 }
00138 }
00139
00140 bool OrCondExpression::evalCond(OutputStream & eos, Environment * env,
00141 unsigned modus) {
00142 bool left_val = left->evalCond(eos, env, modus);
00143
00144 if (left_val) {
00145 right->evalCond(eos, env, EVAL_SIGNOFF);
00146 return true;
00147 } else {
00148 return right->evalCond(eos, env, modus);
00149 }
00150 }