Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/CEL
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27935
Modified Files:
CEL-Atom.cpp CEL-Atom.h CEL-Var.cpp
Log Message:
Look for variable recursively.
Index: CEL-Atom.h
===================================================================
RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/CEL/CEL-Atom.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CEL-Atom.h 11 Mar 2007 18:51:32 -0000 1.5
--- CEL-Atom.h 13 Mar 2007 20:28:48 -0000 1.6
***************
*** 41,45 ****
virtual std::string xmlValue(void);
virtual std::string xmlProperties(void);
! virtual CelAtom *varOwner(void);
virtual std::string evaluate(void) = 0;
--- 41,46 ----
virtual std::string xmlValue(void);
virtual std::string xmlProperties(void);
! virtual CelAtom *varOwner(int _global = 0);
! virtual CelAtom *varOwner(std::string _var);
virtual std::string evaluate(void) = 0;
***************
*** 83,86 ****
--- 84,98 ----
};
+ class CelDebug : public CelAtom {
+ protected:
+ virtual std::string evaluate(void);
+ public:
+ CelDebug();
+
+ virtual std::string xmlEntityName(void);
+
+ virtual ~CelDebug();
+ };
+
}
Index: CEL-Var.cpp
===================================================================
RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/CEL/CEL-Var.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CEL-Var.cpp 11 Mar 2007 18:47:49 -0000 1.3
--- CEL-Var.cpp 13 Mar 2007 20:28:48 -0000 1.4
***************
*** 48,53 ****
value=V->Evaluate();
! varOwner()->VarSet(name,
! value);
return("1");
}
--- 48,53 ----
value=V->Evaluate();
! varOwner(name)->VarSet(name,
! value);
return("1");
}
***************
*** 73,76 ****
--- 73,77 ----
CelAtom *N;
celVar_t *cv;
+ std::string name;
if (n!=1)
***************
*** 79,83 ****
N=childs[0];
! cv=varOwner()->VarGet(N->Evaluate());
if (cv)
return(cv->value);
--- 80,85 ----
N=childs[0];
! name=N->Evaluate();
! cv=varOwner(name)->VarGet(name);
if (cv)
return(cv->value);
***************
*** 104,107 ****
--- 106,110 ----
int n = childs.size();
CelAtom *N;
+ std::string name;
if (n!=1)
***************
*** 109,113 ****
N=childs[0];
! return(varOwner()->VarUndef(N->Evaluate()));
}
--- 112,117 ----
N=childs[0];
! name=N->Evaluate();
! return(varOwner(name)->VarUndef(name));
}
Index: CEL-Atom.cpp
===================================================================
RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/CEL/CEL-Atom.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CEL-Atom.cpp 11 Mar 2007 18:50:47 -0000 1.5
--- CEL-Atom.cpp 13 Mar 2007 20:28:48 -0000 1.6
***************
*** 62,66 ****
}
! CelAtom *CelAtom::varOwner(void)
{
CelAtom *ptr = this;
--- 62,66 ----
}
! CelAtom *CelAtom::varOwner(int _global)
{
CelAtom *ptr = this;
***************
*** 68,75 ****
while (ptr->parent) {
e=ptr->xmlEntityName();
! if ((e=="cel-function-def") ||
! /* (e=="cel-block") || */
! (e=="cel")) {
! return(ptr);
}
ptr=ptr->parent;
--- 68,80 ----
while (ptr->parent) {
e=ptr->xmlEntityName();
! if (_global) {
! if (e=="cel")
! return(ptr);
! } else {
! if ((e=="cel-function-def") ||
! /* (e=="cel-block") || */
! (e=="cel")) {
! return(ptr);
! }
}
ptr=ptr->parent;
***************
*** 79,82 ****
--- 84,108 ----
}
+ CelAtom *CelAtom::varOwner(std::string _var)
+ {
+ CelAtom *ptr;
+ CelAtom *previous;
+
+ ptr=varOwner();
+ previous=0;
+
+ while (ptr!=previous) {
+ if (ptr->VarGet(_var))
+ return(ptr);
+ previous=ptr;
+ if (ptr->parent) {
+ ptr=ptr->parent;
+ ptr=ptr->varOwner();
+ }
+ }
+
+ return(ptr);
+ }
+
std::string CelAtom::xmlValue(void)
{
***************
*** 365,366 ****
--- 391,424 ----
{
}
+
+
+ CelDebug::CelDebug()
+ : CelAtom()
+ {
+ }
+
+ std::string CelDebug::evaluate(void)
+ {
+ int i;
+ int n = childs.size();
+ CelAtom *A;
+
+ std::string r;
+
+ std::cerr << "CelDebug : ";
+ for(i=0; i<n; i++) {
+ A=childs[i];
+ std::cerr << A->Evaluate();
+ }
+ std::cerr << std::endl;
+ return("1");
+ }
+
+ std::string CelDebug::xmlEntityName(void)
+ {
+ return("cel-debug");
+ }
+
+ CelDebug::~CelDebug()
+ {
+ }
|