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 "nodeconstructexpression.h"
00036
00037 NodeConstructExpression::NodeConstructExpression(const char *_tag,
00038 Expression *
00039 _exp):Expression
00040 (et_nodeconstr),
00041 tag(tagmap->insertTag(_tag)),
00042 exp(_exp) {
00043 }
00044
00045 NodeConstructExpression::~NodeConstructExpression() {
00046 delete exp;
00047 }
00048
00049 void NodeConstructExpression::scopeCheck(vector < unsigned >&def_vars,
00050 vector < unsigned >&introduced_vars,
00051 vector < unsigned >&violating_vars) {
00052 exp->scopeCheck(def_vars, introduced_vars, violating_vars);
00053 }
00054
00055 void NodeConstructExpression::replaceVarId(unsigned old_id, unsigned new_id) {
00056 exp->replaceVarId(old_id, new_id);
00057 }
00058
00059 void NodeConstructExpression::mergeSequences() {
00060 exp->mergeSequences();
00061 }
00062
00063 void NodeConstructExpression::extractFSAMap(FSAMap * fsamap,
00064 unsigned parent_var) {
00065 exp->extractFSAMap(fsamap, parent_var);
00066 }
00067
00068 void NodeConstructExpression::extractParVarMap(ParVarMap * parvarmap) {
00069 exp->extractParVarMap(parvarmap);
00070 }
00071
00072 void NodeConstructExpression::extractDependencies(vector <
00073 DependencySet * >*depset) {
00074 exp->extractDependencies(depset);
00075 }
00076
00077 Expression *NodeConstructExpression::placeSignOffs(vector <
00078 SignOffExpression *
00079 >&signoffs) {
00080 exp = exp->placeSignOffs(signoffs);
00081
00082 return this;
00083 }
00084
00085 void NodeConstructExpression::rewriteWhereExps() {
00086 exp->rewriteWhereExps();
00087 }
00088
00089 void NodeConstructExpression::rewriteEmptyFuncts() {
00090 exp->rewriteEmptyFuncts();
00091 }
00092
00093 void NodeConstructExpression::rewriteVarstepCondExps() {
00094 exp->rewriteVarstepCondExps();
00095 }
00096
00097 void NodeConstructExpression::rewriteAggregateFuncts() {
00098 exp->rewriteAggregateFuncts();
00099 }
00100
00101 void NodeConstructExpression::rewriteVarsteps() {
00102 if (exp->getType() == et_varstep) {
00103 VarStepExpression *sub = ((VarStepExpression *) exp)->clone();
00104 delete exp;
00105 VarExpression *tmpvar =
00106 new VarExpression(VarName::getInstance()->getFreshVarname(),
00107 true);
00108 ForExpression *forexp = new ForExpression(tmpvar, sub, tmpvar->clone());
00109
00110 exp = forexp;
00111 } else {
00112 exp->rewriteVarsteps();
00113 }
00114 }
00115
00116 void NodeConstructExpression::print(OutputStream & dos) const {
00117 EXP_TYPE subtype = exp->getType();
00118
00119 if (subtype == et_empty) {
00120 dos << "<" << tagmap->getTag(tag) << "/>";
00121 return;
00122 }
00123 dos << "<" << tagmap->getTag(tag) << "> {";
00124 if (subtype == et_for || subtype == et_if || subtype == et_nodeconstr
00125 || subtype == et_sequence || subtype == et_signoff) {
00126 dos << NEWLINE << incrementIndents() << writeIndents() << (*exp) <<
00127 NEWLINE;
00128 dos << decrementIndents() << writeIndents();
00129 } else {
00130 dos << (*exp);
00131 }
00132 dos << "} </" << tagmap->getTag(tag) << ">";
00133 }
00134
00135 void NodeConstructExpression::init(BufferNode * root) {
00136 exp->init(root);
00137 }
00138
00139 void NodeConstructExpression::eval(OutputStream & eos, Environment * env,
00140 unsigned modus) {
00141
00142 switch (modus) {
00143
00144 case EVAL_QUERY:
00145 if (exp->getType() == et_empty) {
00146 eos << "<" << tagmap->getTag(tag) << "/>";
00147 } else {
00148 eos << "<" << tagmap->getTag(tag) << ">";
00149 exp->eval(eos, env, EVAL_QUERY);
00150 eos << "</" << tagmap->getTag(tag) << ">";
00151 }
00152 break;
00153
00154 case EVAL_SIGNOFF:
00155 exp->eval(eos, env, EVAL_SIGNOFF);
00156 break;
00157
00158 default:
00159 throw
00160 RuntimeException
00161 ("NodeConstructExpression: Illegal Evaluation Mode",
00162 eid_runtime_illegalmode);
00163 break;
00164 }
00165 }