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 "varstepexpression.h"
00036
00037 VarStepExpression::VarStepExpression(unsigned _id,
00038 PathExpression *
00039 _path):VarExpression(et_varstep, _id),
00040 path(_path),
00041 bit(NULL) {
00042 }
00043
00044 VarStepExpression::~VarStepExpression() {
00045 delete path;
00046 delete bit;
00047 }
00048
00049 void VarStepExpression::extractDependencies(vector < DependencySet * >*depset) {
00050 for (unsigned i = 0; i < depset->size(); i++) {
00051 if ((*depset)[i]->getVar() == id) {
00052 (*depset)[i]->insertTuple(path, false, true, false);
00053 break;
00054 }
00055 }
00056 }
00057
00058 void VarStepExpression::print(OutputStream & dos) const {
00059 dos << "$" << VarName::getInstance()->getVarname(id) << (*path);
00060 }
00061
00062 void VarStepExpression::init(BufferNode * root) {
00063 delete bit;
00064
00065 bit = new BufferIterator(root, path);
00066 }
00067
00068 void VarStepExpression::eval(OutputStream & eos, Environment * env,
00069 unsigned modus) {
00070
00071 switch (modus) {
00072
00073 case EVAL_QUERY:
00074 {
00075 bit->init(env->getNodeBinding(id));
00076 while (BufferNode * cur = bit->getNext(READ_UP_TO_CLOSE_CONTEXT)) {
00077 cur->print(eos);
00078 }
00079 bit->clear();
00080 break;
00081 }
00082
00083 case EVAL_SIGNOFF:
00084 break;
00085
00086 default:
00087 throw
00088 RuntimeException("VarStepExpression: Illegal Evaluation Mode",
00089 eid_runtime_illegalmode);
00090 break;
00091 }
00092 }
00093
00094 VarStepExpression *VarStepExpression::clone() {
00095 return new VarStepExpression(id, path->clone());
00096 }
00097
00098 VarStepExpression *VarStepExpression::cloneWithoutFinalDosNodeAndAttributes() {
00099 return new VarStepExpression(id,
00100 path->cloneWithoutFinalDosNodeAndAttributes());
00101 }
00102
00103 void VarStepExpression::prepareOperand(OutputStream & eos, Environment * env,
00104 unsigned modus) {
00105 bit->init(env->getNodeBinding(id));
00106 }
00107
00108 void VarStepExpression::unprepareOperand() {
00109 bit->reset();
00110 }
00111
00112 Value *VarStepExpression::getNextValue() {
00113 BufferNode *cur = bit->getNext(READ_UP_TO_CLOSE_CONTEXT);
00114
00115 if (cur) {
00116 cur_val.setStrVal(cur->getPCDataRepresentation());
00117 return &cur_val;
00118 } else {
00119 return NULL;
00120 }
00121 }