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 "whereexpression.h"
00036
00037 WhereExpression::WhereExpression(CondExpression * _cond, Expression * _exp):
00038 Expression(et_where), cond(_cond), exp(_exp), ifexp(NULL) {
00039 }
00040
00041 WhereExpression::~WhereExpression() {
00042 delete ifexp;
00043 }
00044
00045 void WhereExpression::scopeCheck(vector < unsigned >&def_vars,
00046 vector < unsigned >&introduced_vars,
00047 vector < unsigned >&violating_vars) {
00048 cond->scopeCheck(def_vars, introduced_vars, violating_vars);
00049 exp->scopeCheck(def_vars, introduced_vars, violating_vars);
00050 }
00051
00052 void WhereExpression::replaceVarId(unsigned old_id, unsigned new_id) {
00053 cond->replaceVarId(old_id, new_id);
00054 exp->replaceVarId(old_id, new_id);
00055 }
00056
00057 void WhereExpression::mergeSequences() {
00058 ifexp->mergeSequences();
00059 }
00060
00061 void WhereExpression::extractFSAMap(FSAMap * fsamap, unsigned parent_var) {
00062 ifexp->extractFSAMap(fsamap, parent_var);
00063 }
00064
00065 void WhereExpression::extractParVarMap(ParVarMap * parvarmap) {
00066 ifexp->extractParVarMap(parvarmap);
00067 }
00068
00069 void WhereExpression::extractDependencies(vector < DependencySet * >*depset) {
00070 ifexp->extractDependencies(depset);
00071 }
00072
00073 Expression *WhereExpression::placeSignOffs(vector <
00074 SignOffExpression * >&signoffs) {
00075 ifexp = (IfExpression *) ifexp->placeSignOffs(signoffs);
00076
00077 return this;
00078 }
00079
00080 void WhereExpression::rewriteWhereExps() {
00081 ifexp = new IfExpression(cond, exp, new EmptyExpression());
00082 setType(et_if);
00083 ifexp->rewriteWhereExps();
00084 }
00085
00086 void WhereExpression::rewriteEmptyFuncts() {
00087 ifexp->rewriteEmptyFuncts();
00088 }
00089
00090 void WhereExpression::rewriteVarstepCondExps() {
00091 ifexp->rewriteVarstepCondExps();
00092 }
00093
00094 void WhereExpression::rewriteAggregateFuncts() {
00095 ifexp->rewriteAggregateFuncts();
00096 }
00097
00098 void WhereExpression::rewriteVarsteps() {
00099 ifexp->rewriteVarsteps();
00100 }
00101
00102 void WhereExpression::print(OutputStream & dos) const {
00103 if (ifexp) {
00104 dos << (*ifexp);
00105 } else {
00106 dos << "where (" << (*cond) << ") return " << NEWLINE;
00107 dos << incrementIndents() << writeIndents() << (*exp) << NEWLINE;
00108 dos << decrementIndents();
00109 }
00110 }
00111
00112 void WhereExpression::init(BufferNode * root) {
00113 ifexp->init(root);
00114 }
00115
00116 void WhereExpression::eval(OutputStream & eos, Environment * env,
00117 unsigned modus) {
00118 ifexp->eval(eos, env, modus);
00119 }
00120
00121 bool WhereExpression::containsDirectOutput() {
00122 return ifexp->containsDirectOutput();
00123 }