zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #13921
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/expr-memman3 into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/expr-memman3/+merge/123341
expression clauses allocated via memory pool
--
https://code.launchpad.net/~zorba-coders/zorba/expr-memman3/+merge/123341
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/common/shared_types.h'
--- src/common/shared_types.h 2012-08-30 13:45:43 +0000
+++ src/common/shared_types.h 2012-09-07 18:36:36 +0000
@@ -98,9 +98,6 @@
class forletwin_clause;
class for_clause;
class let_clause;
-typedef rchandle<flwor_clause> flwor_clause_t;
-typedef rchandle<for_clause> for_clause_t;
-typedef rchandle<let_clause> let_clause_t;
class ItemVariableIterator;
typedef rchandle<ItemVariableIterator> ItemVariableIterator_t;
=== modified file 'src/compiler/api/compilercb.cpp'
--- src/compiler/api/compilercb.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/api/compilercb.cpp 2012-09-07 18:36:36 +0000
@@ -119,9 +119,9 @@
theIsSequential(false),
theHaveTimeout(false),
theTimeout(timeout),
- theTempIndexCounter(0)
+ theTempIndexCounter(0),
+ theEM(new ExprManager(this))
{
- theEM = new ExprManager(this);
if (timeout >= 0)
theHaveTimeout = true;
@@ -148,9 +148,9 @@
theHaveTimeout(cb.theHaveTimeout),
theTimeout(cb.theTimeout),
theTempIndexCounter(0),
- theConfig(cb.theConfig)
+ theConfig(cb.theConfig),
+ theEM(new ExprManager(this))
{
- theEM = new ExprManager(this);
}
@@ -166,9 +166,9 @@
theDebuggerCommons(NULL),
#endif
theHasEval(false),
- theIsEval(false)
+ theIsEval(false),
+ theEM(new ExprManager(this))
{
- theEM = new ExprManager(this);
}
=== modified file 'src/compiler/api/compilercb.h'
--- src/compiler/api/compilercb.h 2012-08-30 13:45:43 +0000
+++ src/compiler/api/compilercb.h 2012-09-07 18:36:36 +0000
@@ -161,7 +161,7 @@
typedef std::map<csize, static_context_t> SctxMap;
public:
- ExprManager * theEM;
+ ExprManager *const theEM;
XQueryDiagnostics * theXQueryDiagnostics;
=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/codegen/plan_visitor.cpp 2012-09-07 18:36:36 +0000
@@ -932,7 +932,8 @@
(v.get_order_clause() != NULL || v.get_group_clause() == NULL))
{
materialize_clause* mat =
- new materialize_clause(v.get_sctx(), v.get_return_expr()->get_loc());
+ theCCB->theEM->create_materialize_clause(v.get_sctx(),
+ v.get_return_expr()->get_loc());
v.add_clause(mat);
++numClauses;
@@ -981,7 +982,7 @@
v.get_clause(i-1)->get_kind() != flwor_clause::group_clause)
{
orderby_clause* mat =
- new orderby_clause(v.get_sctx(),
+ theCCB->theEM->create_orderby_clause(v.get_sctx(),
c->get_loc(),
true,
modifiers,
@@ -997,7 +998,7 @@
v.get_clause(i+1)->get_kind() != flwor_clause::group_clause))
{
orderby_clause* mat =
- new orderby_clause(v.get_sctx(),
+ theCCB->theEM->create_orderby_clause(v.get_sctx(),
c->get_loc(),
true,
modifiers,
@@ -1032,7 +1033,7 @@
lastClause->get_kind() != flwor_clause::group_clause)
{
orderby_clause* mat =
- new orderby_clause(v.get_sctx(),
+ theCCB->theEM->create_orderby_clause(v.get_sctx(),
v.get_return_expr()->get_loc(),
true,
modifiers,
@@ -1986,7 +1987,7 @@
for(int i = v.clause_count() - 1; i >= 0; --i)
{
- catch_clause* cc = &*v[i];
+ catch_clause* cc = const_cast<catch_clause*>(v[i]);
catch_clause::var_map_t& vars = cc->get_vars();
for (catch_clause::var_map_t::const_iterator lIter = vars.begin();
@@ -2008,7 +2009,7 @@
for(int i = v.clause_count() - 1; i >= 0; --i)
{
- catch_clause* cc = &*v[i];
+ catch_clause* cc = const_cast<catch_clause*>(v[i]);
TryCatchIterator::CatchClause rcc;
rcc.node_names = cc->get_nametests();
rcc.catch_expr = pop_itstack();
@@ -2103,7 +2104,7 @@
args,
varNames,
varTypes,
- isGlobalVar,
+ isGlobalVar,
v.get_inner_scripting_kind(),
localBindings,
v.getNodeCopy(),
@@ -3406,8 +3407,8 @@
TypeManager* tm = v.get_type_manager();
- std::vector<rchandle<copy_clause> >::const_iterator lIter = v.begin();
- std::vector<rchandle<copy_clause> >::const_iterator lEnd = v.end();
+ std::vector<copy_clause*>::const_iterator lIter = v.begin();
+ std::vector<copy_clause*>::const_iterator lEnd = v.end();
for (; lIter != lEnd; ++lIter)
{
var_expr* var = (*lIter)->getVar();
@@ -3447,8 +3448,8 @@
// Create an ApplyIterator to apply the above PUL
PlanIter_t applyIter = new ApplyIterator(sctx, modifyIter->loc, true, pulHolderIter);
- std::vector<rchandle<copy_clause> >::const_iterator lIter = v.begin();
- std::vector<rchandle<copy_clause> >::const_iterator lEnd = v.end();
+ std::vector<copy_clause*>::const_iterator lIter = v.begin();
+ std::vector<copy_clause*>::const_iterator lEnd = v.end();
for(; lIter != lEnd; ++lIter)
{
PlanIter_t lInput = plan_visitor_ns::pop_stack(lInputs);
=== modified file 'src/compiler/expression/expr.cpp'
--- src/compiler/expression/expr.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/expr.cpp 2012-09-07 18:36:36 +0000
@@ -1053,7 +1053,8 @@
/*******************************************************************************
********************************************************************************/
-catch_clause::catch_clause()
+catch_clause::catch_clause(CompilerCB* ccb)
+:theCCB(ccb)
{
}
@@ -1079,7 +1080,7 @@
}
-void trycatch_expr::add_clause(catch_clause_t cc)
+void trycatch_expr::add_clause(catch_clause* cc)
{
theCatchClauses.insert(theCatchClauses.begin(), cc);
}
@@ -1139,9 +1140,9 @@
}
-catch_clause_t catch_clause::clone(expr::substitution_t& subst) const
+catch_clause* catch_clause::clone(expr::substitution_t& subst) const
{
- catch_clause_t lClause(new catch_clause());
+ catch_clause* lClause = theCCB->theEM->create_catch_clause();
for (nt_list_t::const_iterator lIter = theNameTests.begin();
lIter != theNameTests.end();
@@ -1156,7 +1157,7 @@
lClause->add_var((catch_clause::var_type)lIter->first, lIter->second);
}
- return lClause.getp();
+ return lClause;
}
=== modified file 'src/compiler/expression/expr.h'
--- src/compiler/expression/expr.h 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/expr.h 2012-09-07 18:36:36 +0000
@@ -886,15 +886,12 @@
[173] CatchErrorList ::= NameTest ("|" NameTest)*
********************************************************************************/
-class catch_clause;
-
-typedef rchandle<catch_clause> catch_clause_t;
-
-
-class catch_clause : public SimpleRCObject
+
+class catch_clause
{
friend class expr;
friend class trycatch_expr;
+ friend class ExprManager;
public:
enum var_type
@@ -914,11 +911,11 @@
typedef std::map<int, var_expr*> var_map_t;
protected:
- nt_list_t theNameTests;
- var_map_t theVarMap;
+ nt_list_t theNameTests;
+ var_map_t theVarMap;
+ CompilerCB *const theCCB;
-public:
- catch_clause();
+ catch_clause(CompilerCB* ccb);
public:
void set_nametests(nt_list_t& a) { theNameTests = a; }
@@ -933,7 +930,7 @@
void add_var(var_type v, var_expr* n) { theVarMap[v] = n; }
- catch_clause_t clone(expr::substitution_t& subst) const;
+ catch_clause* clone(expr::substitution_t& subst) const;
};
@@ -946,7 +943,7 @@
protected:
expr* theTryExpr;
std::vector<expr*> theCatchExprs;
- std::vector<catch_clause_t> theCatchClauses;
+ std::vector<catch_clause*> theCatchClauses;
protected:
trycatch_expr(CompilerCB* ccb, static_context* sctx, const QueryLoc&, expr* tryExpr);
@@ -960,11 +957,11 @@
void add_catch_expr(expr* e);
- void add_clause(catch_clause_t cc);
+ void add_clause(catch_clause* cc);
csize clause_count() const { return theCatchClauses.size(); }
- const catch_clause_t& operator[](csize i) const { return theCatchClauses[i]; }
+ const catch_clause* operator[](csize i) const { return theCatchClauses[i]; }
void compute_scripting_kind();
=== modified file 'src/compiler/expression/expr_base.h'
--- src/compiler/expression/expr_base.h 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/expr_base.h 2012-09-07 18:36:36 +0000
@@ -184,7 +184,7 @@
FreeVars theFreeVars;
- CompilerCB * theCCB;
+ CompilerCB *const theCCB;
public:
static bool is_sequential(unsigned short theScriptingKind);
=== modified file 'src/compiler/expression/expr_iter.cpp'
--- src/compiler/expression/expr_iter.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/expr_iter.cpp 2012-09-07 18:36:36 +0000
@@ -120,7 +120,7 @@
for (; theClausesIter != theClausesEnd; ++(theClausesIter))
{
- c = (theClausesIter)->getp();
+ c = *theClausesIter;
if (c->get_kind() == flwor_clause::for_clause)
{
@@ -136,17 +136,17 @@
{
for (theWincondIter = 0; theWincondIter < 2; ++theWincondIter)
{
- wc = static_cast<window_clause *>(theClausesIter->getp());
+ wc = static_cast<window_clause *>(*theClausesIter);
wincond = (theWincondIter == 0 ?
- wc->theWinStartCond.getp() :
- wc->theWinStopCond.getp());
+ wc->theWinStartCond :
+ wc->theWinStopCond );
if (wincond != 0)
EXPR_ITER_NEXT(wincond->theCondExpr);
}
- wc = static_cast<window_clause *>(theClausesIter->getp());
+ wc = static_cast<window_clause *>(*theClausesIter);
EXPR_ITER_NEXT(wc->theDomainExpr);
}
=== modified file 'src/compiler/expression/expr_iter.h'
--- src/compiler/expression/expr_iter.h 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/expr_iter.h 2012-09-07 18:36:36 +0000
@@ -50,8 +50,8 @@
flwor_clause::rebind_list_t::iterator theNonGroupVarsEnd;
int theWincondIter;
- std::vector<copy_clause_t>::iterator theCopyClauseIter;
- std::vector<copy_clause_t>::iterator theCopyClauseEnd;
+ std::vector<copy_clause*>::iterator theCopyClauseIter;
+ std::vector<copy_clause*>::iterator theCopyClauseEnd;
#ifndef ZORBA_NO_FULL_TEXT
std::vector<expr**> theFTSelectionExprs;
=== modified file 'src/compiler/expression/expr_manager.cpp'
--- src/compiler/expression/expr_manager.cpp 2012-08-13 14:45:23 +0000
+++ src/compiler/expression/expr_manager.cpp 2012-09-07 18:36:36 +0000
@@ -44,6 +44,35 @@
std::ostream& put(std::ostream& stream) const{return stream;}
};
+class NullFlworClause : public flwor_clause
+{
+public:
+ //it being a let clause is arbitrary, it doesn't matter what type it is.
+ NullFlworClause() :
+ flwor_clause(NULL, NULL, QueryLoc(),flwor_clause::let_clause) {}
+ std::ostream& put(std::ostream& stream) const{return stream;}
+ flwor_clause* clone(expr::substitution_t &) const {return NULL;}
+};
+
+class NullWincond : public flwor_wincond
+{
+public:
+ NullWincond() : flwor_wincond(NULL, NULL, false, vars(), vars(), NULL) {}
+ std::ostream& put(std::ostream& stream) const{return stream;}
+};
+
+class NullCatchClause : public catch_clause
+{
+public:
+ NullCatchClause() : catch_clause(NULL) {}
+ std::ostream& put(std::ostream& stream) const{return stream;}
+};
+
+class NullCopyClause : public copy_clause
+{
+public:
+ NullCopyClause() : copy_clause(NULL, NULL, NULL) {}
+};
ExprManager::ExprManager(CompilerCB* ccb)
:
@@ -60,8 +89,8 @@
iter != theExprs.end();
++iter)
{
- //Here we delete all remaining exprs, we assume that they may be "held"
- //by a reference somewhere.
+ //We assume that the exprs being deleted they may be "held"
+ //by a reference or pointer somewhere and will try deleting them again.
//To prevent deleting an already deleted expr, we replace them with
//a NullExpr
@@ -72,6 +101,42 @@
//constructs a new NULLExpr where the old expr existed
new (exp) NullExpr();
}
+
+ for(std::vector<flwor_clause*>::iterator iter = theFlworClauses.begin();
+ iter != theFlworClauses.end();
+ ++iter)
+ {
+ flwor_clause* clause = *iter;
+ clause->~flwor_clause();
+ new (clause) NullFlworClause();
+ }
+
+ for(std::vector<flwor_wincond*>::iterator iter = theWinconds.begin();
+ iter != theWinconds.end();
+ ++iter)
+ {
+ flwor_wincond* wincond = *iter;
+ wincond->~flwor_wincond();
+ new (wincond) NullWincond();
+ }
+
+ for(std::vector<catch_clause*>::iterator iter = theCatchClauses.begin();
+ iter != theCatchClauses.end();
+ ++iter)
+ {
+ catch_clause* clause = *iter;
+ clause->~catch_clause();
+// new (clause) NullCatchClause();
+ }
+
+ for(std::vector<copy_clause*>::iterator iter = theCopyClauses.begin();
+ iter != theCopyClauses.end();
+ ++iter)
+ {
+ copy_clause* clause = *iter;
+ clause->~copy_clause();
+// new (clause) NullCopyClause();
+ }
}
@@ -81,6 +146,30 @@
return exp;
}
+flwor_clause* ExprManager::reg(flwor_clause* clause)
+{
+ theFlworClauses.push_back(clause);
+ return clause;
+}
+
+flwor_wincond* ExprManager::reg(flwor_wincond* wincond)
+{
+ theWinconds.push_back(wincond);
+ return wincond;
+}
+
+catch_clause* ExprManager::reg(catch_clause* clause)
+{
+ theCatchClauses.push_back(clause);
+ return clause;
+}
+
+copy_clause* ExprManager::reg(copy_clause* clause)
+{
+ theCopyClauses.push_back(clause);
+ return clause;
+}
+
////////////////////////////////////////////////////////////////////////////////
@@ -91,7 +180,7 @@
#define CREATE_AND_RETURN(TYPE, ...) \
TYPE* EXPPTR = new (theMemoryMgr) TYPE(__VA_ARGS__); \
- return EXPPTR
+ return static_cast<TYPE *>(reg(EXPPTR))
////////////////////////////////////////////////////////////////////////////////
@@ -368,7 +457,7 @@
catch_clause* ExprManager::create_catch_clause()
{
- CREATE_AND_RETURN(catch_clause);
+ CREATE_AND_RETURN(catch_clause, theCCB);
}
@@ -534,7 +623,7 @@
copy_clause* ExprManager::create_copy_clause(var_expr* aVar, expr* aExpr)
{
- CREATE_AND_RETURN(copy_clause, aVar, aExpr);
+ CREATE_AND_RETURN(copy_clause, theCCB, aVar, aExpr);
}
@@ -771,8 +860,8 @@
window_clause::window_t winKind,
var_expr* varExpr,
expr* domainExpr,
- flwor_wincond_t winStart,
- flwor_wincond_t winStop,
+ flwor_wincond* winStart,
+ flwor_wincond* winStop,
bool lazy)
{
CREATE_AND_RETURN(window_clause,
@@ -796,7 +885,7 @@
flwor_clause::rebind_list_t ngvars,
const std::vector<std::string>& collations)
{
- CREATE_AND_RETURN(group_clause, sctx, loc, gvars, ngvars, collations);
+ CREATE_AND_RETURN(group_clause, sctx, theCCB, loc, gvars, ngvars, collations);
}
orderby_clause* ExprManager::create_orderby_clause(
@@ -806,25 +895,25 @@
const std::vector<OrderModifier>& modifiers,
const std::vector<expr*>& orderingExprs)
{
- CREATE_AND_RETURN(orderby_clause, sctx, loc, stable, modifiers, orderingExprs);
+ CREATE_AND_RETURN(orderby_clause, sctx, theCCB, loc, stable, modifiers, orderingExprs);
}
materialize_clause* ExprManager::create_materialize_clause(
static_context* sctx, const QueryLoc& loc)
{
- CREATE_AND_RETURN(materialize_clause, sctx, loc);
+ CREATE_AND_RETURN(materialize_clause, sctx, theCCB, loc);
}
count_clause* ExprManager::create_count_clause(
static_context* sctx, const QueryLoc& loc, var_expr* var)
{
- CREATE_AND_RETURN(count_clause, sctx, loc, var);
+ CREATE_AND_RETURN(count_clause, sctx, theCCB, loc, var);
}
where_clause* ExprManager::create_where_clause(
static_context* sctx, const QueryLoc& loc, expr* where)
{
- CREATE_AND_RETURN(where_clause, sctx, loc, where);
+ CREATE_AND_RETURN(where_clause, sctx, theCCB, loc, where);
}
flwor_expr* ExprManager::create_flwor_expr(
=== modified file 'src/compiler/expression/expr_manager.h'
--- src/compiler/expression/expr_manager.h 2012-08-13 14:45:23 +0000
+++ src/compiler/expression/expr_manager.h 2012-09-07 18:36:36 +0000
@@ -34,9 +34,13 @@
class ExprManager
{
private:
- std::vector<expr*> theExprs;
- MemoryManager theMemoryMgr;
- CompilerCB * theCCB;
+ std::vector<expr*> theExprs;
+ std::vector<flwor_clause*> theFlworClauses;
+ std::vector<flwor_wincond*> theWinconds;
+ std::vector<catch_clause*> theCatchClauses;
+ std::vector<copy_clause*> theCopyClauses;
+ MemoryManager theMemoryMgr;
+ CompilerCB *const theCCB;
public:
ExprManager(CompilerCB* ccb);
@@ -45,6 +49,14 @@
expr* reg(expr*);
+ flwor_clause* reg(flwor_clause*);
+
+ flwor_wincond* reg(flwor_wincond*);
+
+ catch_clause* reg(catch_clause*);
+
+ copy_clause* reg(copy_clause*);
+
private:
//An ExprManager is the only object to handle a collection of Exprs and
//the memory in which they recide. Copying it in a senseful way would.
@@ -455,8 +467,8 @@
window_clause::window_t winKind,
var_expr* varExpr,
expr* domainExpr,
- flwor_wincond_t winStart,
- flwor_wincond_t winStop,
+ flwor_wincond* winStart,
+ flwor_wincond* winStop,
bool lazy = false);
flwor_wincond* create_flwor_wincond(
=== modified file 'src/compiler/expression/expr_put.cpp'
--- src/compiler/expression/expr_put.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/expr_put.cpp 2012-09-07 18:36:36 +0000
@@ -263,8 +263,8 @@
BEGIN_PUT(WINDOW);
theVarExpr->put(os);
PUT_SUB("IN", theDomainExpr);
- PUT_SUB("START", theWinStartCond.getp());
- PUT_SUB("STOP", theWinStopCond.getp());
+ PUT_SUB("START", theWinStartCond);
+ PUT_SUB("STOP", theWinStopCond);
END_PUT();
}
@@ -281,7 +281,7 @@
ostream& flwor_wincond::put(ostream& os) const
{
- BEGIN_PUT(flwor_wincond);
+ BEGIN_PUT_NO_LOCATION(flwor_wincond);
PUT_SUB("IN-VARS", &get_in_vars());
PUT_SUB("OUT-VARS", &get_out_vars());
PUT_SUB("WHEN", theCondExpr);
@@ -442,7 +442,7 @@
for (ulong i = 0; i < numClauses; ++i)
{
- catch_clause_t cc = theCatchClauses[i];
+ catch_clause* cc = theCatchClauses[i];
os << indent << "CATCH ";
os << "\n";
theCatchExprs[i]->put(os);
@@ -917,7 +917,7 @@
ostream& copy_clause::put(ostream& os) const
{
- BEGIN_PUT(copy);
+ BEGIN_PUT_NO_LOCATION(copy);
theVar->put(os);
theExpr->put(os);
END_PUT();
@@ -928,10 +928,10 @@
{
BEGIN_PUT(transform_expr);
- for (vector<rchandle<copy_clause> >::const_iterator it = theCopyClauses.begin();
+ for (vector<copy_clause*>::const_iterator it = theCopyClauses.begin();
it != theCopyClauses.end(); ++it)
{
- rchandle<copy_clause> e = *it;
+ copy_clause* e = *it;
e->put(os);
}
theModifyExpr->put(os);
=== modified file 'src/compiler/expression/flwor_expr.cpp'
--- src/compiler/expression/flwor_expr.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/flwor_expr.cpp 2012-09-07 18:36:36 +0000
@@ -52,10 +52,9 @@
var_expr* varExpr,
expr* domainExpr)
:
- flwor_clause(sctx, loc, kind),
+ flwor_clause(sctx, ccb, loc, kind),
theVarExpr(varExpr),
- theDomainExpr(domainExpr),
- theCCB(ccb)
+ theDomainExpr(domainExpr)
{
if (theVarExpr != NULL)
theVarExpr->set_flwor_clause(this);
@@ -219,7 +218,7 @@
}
-flwor_clause_t for_clause::clone(expr::substitution_t& subst) const
+flwor_clause* for_clause::clone(expr::substitution_t& subst) const
{
expr* domainCopy = theDomainExpr->clone(subst);
@@ -242,8 +241,7 @@
subst[score_var_ptr] = scorevarCopy;
}
- return new for_clause(theContext,
- theCCB,
+ return theCCB->theEM->create_for_clause(theContext,
get_loc(),
varCopy,
domainCopy,
@@ -327,7 +325,7 @@
}
-flwor_clause_t let_clause::clone(expr::substitution_t& subst) const
+flwor_clause* let_clause::clone(expr::substitution_t& subst) const
{
expr* domainCopy = theDomainExpr->clone(subst);
@@ -339,13 +337,12 @@
var_expr* score_var_ptr = theScoreVarExpr;
if (score_var_ptr)
{
- scorevarCopy = new var_expr(*score_var_ptr);
+ scorevarCopy = theCCB->theEM->create_var_expr(*score_var_ptr);
subst->get(score_var_ptr) = scorevarCopy;
}
#endif
- return new let_clause(theContext,
- theCCB,
+ return theCCB->theEM->create_let_clause(theContext,
get_loc(),
varCopy,
domainCopy,
@@ -364,8 +361,8 @@
window_t winKind,
var_expr* varExpr,
expr* domainExpr,
- flwor_wincond_t winStart,
- flwor_wincond_t winStop,
+ flwor_wincond* winStart,
+ flwor_wincond* winStop,
bool lazy)
:
forletwin_clause(sctx, ccb, loc, flwor_clause::window_clause, varExpr, domainExpr),
@@ -436,15 +433,15 @@
}
-flwor_clause_t window_clause::clone(expr::substitution_t& subst) const
+flwor_clause* window_clause::clone(expr::substitution_t& subst) const
{
expr* domainCopy = theDomainExpr->clone(subst);
var_expr* varCopy = theCCB->theEM->create_var_expr(*theVarExpr);
subst[theVarExpr] = varCopy;
- flwor_wincond_t cloneStartCond;
- flwor_wincond_t cloneStopCond;
+ flwor_wincond* cloneStartCond;
+ flwor_wincond* cloneStopCond;
if (theWinStartCond != NULL)
cloneStartCond = theWinStartCond->clone(subst);
@@ -452,8 +449,7 @@
if (theWinStopCond != NULL)
cloneStopCond = theWinStopCond->clone(subst);
- return new window_clause(theContext,
- theCCB,
+ return theCCB->theEM->create_window_clause(theContext,
get_loc(),
theWindowKind,
varCopy,
@@ -575,7 +571,7 @@
}
-flwor_wincond_t flwor_wincond::clone(expr::substitution_t& subst) const
+flwor_wincond* flwor_wincond::clone(expr::substitution_t& subst) const
{
flwor_wincond::vars cloneInVars;
flwor_wincond::vars cloneOutVars;
@@ -585,8 +581,7 @@
expr* cloneCondExpr = theCondExpr->clone(subst);
- return new flwor_wincond(theCCB,
- NULL,
+ return theCCB->theEM->create_flwor_wincond(NULL,
theIsOnly,
cloneInVars,
cloneOutVars,
@@ -599,12 +594,13 @@
********************************************************************************/
group_clause::group_clause(
static_context* sctx,
+ CompilerCB* ccb,
const QueryLoc& loc,
const rebind_list_t& gvars,
rebind_list_t ngvars,
const std::vector<std::string>& collations)
:
- flwor_clause(sctx, loc, flwor_clause::group_clause),
+ flwor_clause(sctx, ccb, loc, flwor_clause::group_clause),
theGroupVars(gvars),
theNonGroupVars(ngvars),
theCollations(collations)
@@ -659,7 +655,7 @@
}
-flwor_clause_t group_clause::clone(expr::substitution_t& subst) const
+flwor_clause* group_clause::clone(expr::substitution_t& subst) const
{
csize numGroupVars = theGroupVars.size();
csize numNonGroupVars = theNonGroupVars.size();
@@ -688,7 +684,7 @@
subst[theNonGroupVars[i].second] = cloneNonGroupVars[i].second;
}
- return new group_clause(theContext,
+ return theCCB->theEM->create_group_clause(theContext,
get_loc(),
cloneGroupVars,
cloneNonGroupVars,
@@ -701,12 +697,13 @@
********************************************************************************/
orderby_clause::orderby_clause(
static_context* sctx,
+ CompilerCB* ccb,
const QueryLoc& loc,
bool stable,
const std::vector<OrderModifier>& modifiers,
const std::vector<expr*>& orderingExprs)
:
- flwor_clause(sctx, loc, flwor_clause::order_clause),
+ flwor_clause(sctx, ccb, loc, flwor_clause::order_clause),
theStableOrder(stable),
theModifiers(modifiers),
theOrderingExprs(orderingExprs)
@@ -721,7 +718,7 @@
}
-flwor_clause_t orderby_clause::clone(expr::substitution_t& subst) const
+flwor_clause* orderby_clause::clone(expr::substitution_t& subst) const
{
ulong numColumns = num_columns();
@@ -732,7 +729,7 @@
cloneExprs[i] = theOrderingExprs[i]->clone(subst);
}
- return new orderby_clause(theContext,
+ return theCCB->theEM->create_orderby_clause(theContext,
get_loc(),
theStableOrder,
theModifiers,
@@ -745,14 +742,15 @@
********************************************************************************/
materialize_clause::materialize_clause(
static_context* sctx,
+ CompilerCB* ccb,
const QueryLoc& loc)
:
- flwor_clause(sctx, loc, flwor_clause::materialize_clause)
+ flwor_clause(sctx, ccb, loc, flwor_clause::materialize_clause)
{
}
-flwor_clause_t materialize_clause::clone(expr::substitution_t& subst) const
+flwor_clause* materialize_clause::clone(expr::substitution_t& subst) const
{
// we will reach here under the following scenario:
// 1. We do plan seriazation
@@ -760,16 +758,16 @@
// during the codegen on A's body
// 3. getPlan is called on udf B, which invokes A, and A's body is
// inlined (and as a result cloned) inside B's body.
- return new materialize_clause(theContext, get_loc());
+ return theCCB->theEM->create_materialize_clause(theContext, get_loc());
}
/*******************************************************************************
********************************************************************************/
-count_clause::count_clause(static_context* sctx, const QueryLoc& loc, var_expr* var)
+count_clause::count_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc, var_expr* var)
:
- flwor_clause(sctx, loc, flwor_clause::count_clause),
+ flwor_clause(sctx, ccb, loc, flwor_clause::count_clause),
theVarExpr(var)
{
}
@@ -782,23 +780,23 @@
}
-flwor_clause_t count_clause::clone(expr::substitution_t& subst) const
+flwor_clause* count_clause::clone(expr::substitution_t& subst) const
{
ExprManager* exprMgr = theVarExpr->get_ccb()->theEM;
var_expr* cloneVar = exprMgr->create_var_expr(*theVarExpr);
subst[theVarExpr] = cloneVar;
- return new count_clause(theContext, get_loc(), cloneVar);
+ return theCCB->theEM->create_count_clause(theContext, get_loc(), cloneVar);
}
/*******************************************************************************
********************************************************************************/
-where_clause::where_clause(static_context* sctx, const QueryLoc& loc, expr* where)
+where_clause::where_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc, expr* where)
:
- flwor_clause(sctx, loc, flwor_clause::where_clause),
+ flwor_clause(sctx, ccb, loc, flwor_clause::where_clause),
theWhereExpr(where)
{
expr::checkSimpleExpr(theWhereExpr);
@@ -811,11 +809,11 @@
}
-flwor_clause_t where_clause::clone(expr::substitution_t& subst) const
+flwor_clause* where_clause::clone(expr::substitution_t& subst) const
{
expr* cloneExpr = theWhereExpr->clone(subst);
- return new where_clause(theContext, get_loc(), cloneExpr);
+ return theCCB->theEM->create_where_clause(theContext, get_loc(), cloneExpr);
}
@@ -840,7 +838,7 @@
{
assert(i < theClauses.size());
- return theClauses[i].getp();
+ return theClauses[i];
}
@@ -888,7 +886,7 @@
********************************************************************************/
void flwor_expr::add_where(expr* e)
{
- where_clause* whereClause = new where_clause(theSctx, e->get_loc(), e);
+ where_clause* whereClause = theCCB->theEM->create_where_clause(theSctx, e->get_loc(), e);
add_clause(whereClause);
}
@@ -922,12 +920,12 @@
if (theClauses[i]->get_kind() == flwor_clause::where_clause)
{
- where_clause* wc = reinterpret_cast<where_clause*>(theClauses[i].getp());
+ where_clause* wc = reinterpret_cast<where_clause*>(theClauses[i]);
wc->set_expr(e);
return;
}
- where_clause* wc = new where_clause(theSctx, e->get_loc(), e);
+ where_clause* wc = theCCB->theEM->create_where_clause(theSctx, e->get_loc(), e);
theClauses.insert(theClauses.begin() + i, wc);
wc->theFlworExpr = this;
}
@@ -960,7 +958,7 @@
for (unsigned i = 0; i < numClauses; ++i)
{
if (theClauses[i]->get_kind() == flwor_clause::where_clause)
- return reinterpret_cast<where_clause*>(theClauses[i].getp())->get_expr();
+ return reinterpret_cast<where_clause*>(theClauses[i])->get_expr();
}
return NULL;
@@ -976,7 +974,7 @@
for (ulong i = 0; i < numClauses; ++i)
{
if (theClauses[i]->get_kind() == flwor_clause::group_clause)
- return reinterpret_cast<group_clause*>(theClauses[i].getp());
+ return reinterpret_cast<group_clause*>(theClauses[i]);
}
return NULL;
@@ -992,7 +990,7 @@
for (ulong i = 0; i < numClauses; ++i)
{
if (theClauses[i]->get_kind() == flwor_clause::order_clause)
- return reinterpret_cast<orderby_clause*>(theClauses[i].getp());
+ return reinterpret_cast<orderby_clause*>(theClauses[i]);
}
return NULL;
@@ -1159,9 +1157,9 @@
for (ulong i = 0; i < numClauses; ++i)
{
- flwor_clause_t cloneClause = theClauses[i]->clone(subst);
+ flwor_clause* cloneClause = theClauses[i]->clone(subst);
- cloneFlwor->add_clause(cloneClause.getp(), false);
+ cloneFlwor->add_clause(cloneClause, false);
}
cloneFlwor->set_return_expr(theReturnExpr->clone(subst));
=== modified file 'src/compiler/expression/flwor_expr.h'
--- src/compiler/expression/flwor_expr.h 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/flwor_expr.h 2012-09-07 18:36:36 +0000
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#pragma once
#ifndef ZORBA_COMPILER_FLWOR_EXPR_H
#define ZORBA_COMPILER_FLWOR_EXPR_H
@@ -39,23 +40,14 @@
class group_clause;
class flwor_expr;
-typedef rchandle<flwor_clause> flwor_clause_t;
-typedef rchandle<for_clause> for_clause_t;
-typedef rchandle<let_clause> let_clause_t;
-typedef rchandle<window_clause> window_clause_t;
-typedef rchandle<flwor_wincond> flwor_wincond_t;
-typedef rchandle<orderby_clause> orderby_clause_t;
-typedef rchandle<materialize_clause> materialize_clause_t;
-typedef rchandle<group_clause> group_clause_t;
-
-
/***************************************************************************//**
********************************************************************************/
-class flwor_clause : public SimpleRCObject
+class flwor_clause
{
friend class flwor_expr;
friend class ExprIterator;
+ friend class ExprManager;
public:
typedef std::vector<std::pair<expr*, var_expr*> > rebind_list_t;
@@ -79,16 +71,20 @@
ClauseKind theKind;
flwor_expr * theFlworExpr;
-public:
- flwor_clause(static_context* sctx, const QueryLoc& loc, ClauseKind kind)
+ CompilerCB *const theCCB;
+
+ flwor_clause(static_context* sctx, CompilerCB* ccb,
+ const QueryLoc& loc, ClauseKind kind)
:
theContext(sctx),
theLocation(loc),
theKind(kind),
+ theCCB(ccb),
theFlworExpr(NULL)
{
}
+public:
const QueryLoc& get_loc() const { return theLocation; }
ClauseKind get_kind() const { return theKind; }
@@ -103,13 +99,13 @@
virtual var_expr* get_score_var() const { return NULL; }
- virtual flwor_clause_t clone(expr::substitution_t& substitution) const = 0;
+ virtual flwor_clause* clone(expr::substitution_t& substitution) const = 0;
};
/***************************************************************************//**
- ForClause ::= "outer"? "for" "$" VarName TypeDeclaration? PositionalVar?
+ ForClause ::= "outer"? "for" "$" VarName TypeDeclaration? PositionalVar?
"in" DomainExpr
LetClause ::= "let" "$" VarName TypeDeclaration? ":=" DomainExpr
@@ -136,22 +132,22 @@
class forletwin_clause : public flwor_clause
{
friend class flwor_expr;
+ friend class ExprManager;
friend class ExprIterator;
protected:
var_expr * theVarExpr;
expr * theDomainExpr;
- CompilerCB * theCCB;
-public:
forletwin_clause(
static_context* sctx,
- CompilerCB* exprMan,
+ CompilerCB* ccb,
const QueryLoc& loc,
ClauseKind kind,
var_expr* varExpr,
expr* domainExpr);
+public:
~forletwin_clause();
void set_expr(expr* v);
@@ -170,6 +166,7 @@
class for_clause : public forletwin_clause
{
friend class flwor_expr;
+ friend class ExprManager;
friend class ExprIterator;
protected:
@@ -177,10 +174,9 @@
var_expr * theScoreVarExpr;
bool theAllowingEmpty;
-public:
for_clause(
static_context* sctx,
- CompilerCB* exprMan,
+ CompilerCB* ccb,
const QueryLoc& loc,
var_expr* varExpr,
expr* domainExpr,
@@ -188,6 +184,7 @@
var_expr* scoreVarExpr = NULL,
bool isOuter = false);
+public:
~for_clause();
public:
@@ -203,7 +200,7 @@
void set_score_var(var_expr* v);
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -216,21 +213,22 @@
class let_clause : public forletwin_clause
{
friend class flwor_expr;
+ friend class ExprManager;
friend class ExprIterator;
protected:
var_expr * theScoreVarExpr;
bool theLazyEval;
-public:
let_clause(
static_context* sctx,
- CompilerCB* exprMan,
+ CompilerCB* ccb,
const QueryLoc& loc,
var_expr* varExpr,
expr* domainExpr,
bool lazy = false);
+public:
~let_clause();
public:
@@ -242,7 +240,7 @@
bool lazyEval() const { return theLazyEval; }
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -257,6 +255,7 @@
class window_clause : public forletwin_clause
{
friend class flwor_expr;
+ friend class ExprManager;
friend class ExprIterator;
public:
@@ -264,30 +263,30 @@
protected:
window_t theWindowKind;
- flwor_wincond_t theWinStartCond;
- flwor_wincond_t theWinStopCond;
+ flwor_wincond* theWinStartCond;
+ flwor_wincond* theWinStopCond;
bool theLazyEval;
-public:
window_clause(
static_context* sctx,
- CompilerCB* exprMan,
+ CompilerCB* ccb,
const QueryLoc& loc,
window_t winKind,
var_expr* varExpr,
expr* domainExpr,
- flwor_wincond_t winStart,
- flwor_wincond_t winStop,
+ flwor_wincond* winStart,
+ flwor_wincond* winStop,
bool lazy = false);
+public:
~window_clause();
public:
window_t get_winkind() const { return theWindowKind; }
- flwor_wincond* get_win_start() const { return theWinStartCond.getp(); }
+ flwor_wincond* get_win_start() const { return theWinStartCond; }
- flwor_wincond* get_win_stop() const { return theWinStopCond.getp(); }
+ flwor_wincond* get_win_stop() const { return theWinStopCond; }
void set_win_start(flwor_wincond* cond);
@@ -297,7 +296,7 @@
bool lazyEval() const { return theLazyEval; }
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -333,9 +332,10 @@
clause).
theCondExpr : The start/end condition expr.
********************************************************************************/
-class flwor_wincond : public SimpleRCObject
+class flwor_wincond
{
friend class flwor_expr;
+ friend class ExprManager;
friend class ExprIterator;
public:
@@ -361,9 +361,8 @@
vars theOutputVars;
expr * theCondExpr;
- CompilerCB* theCCB;
+ CompilerCB *const theCCB;
-public:
flwor_wincond(
CompilerCB* ccb,
static_context* sctx,
@@ -372,6 +371,7 @@
const vars& out_vars,
expr* cond);
+public:
~flwor_wincond();
expr* get_cond() const { return theCondExpr; }
@@ -386,7 +386,7 @@
void set_flwor_clause(flwor_clause *);
- flwor_wincond_t clone(expr::substitution_t& substitution) const;
+ flwor_wincond* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -420,6 +420,7 @@
class group_clause : public flwor_clause
{
friend class flwor_expr;
+ friend class ExprManager;
friend class ExprIterator;
protected:
@@ -427,14 +428,15 @@
rebind_list_t theNonGroupVars;
std::vector<std::string> theCollations;
-public:
group_clause(
static_context* sctx,
+ CompilerCB* ccb,
const QueryLoc& loc,
const rebind_list_t& gvars,
rebind_list_t ngvars,
const std::vector<std::string>& collations);
+public:
~group_clause();
const std::vector<std::string>& get_collations() const { return theCollations; }
@@ -459,7 +461,7 @@
expr* get_input_for_nongroup_var(const var_expr* var);
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -482,6 +484,7 @@
class orderby_clause : public flwor_clause
{
friend class ExprIterator;
+ friend class ExprManager;
friend class flwor_expr;
protected:
@@ -490,14 +493,15 @@
std::vector<OrderModifier> theModifiers;
std::vector<expr*> theOrderingExprs;
-public:
orderby_clause (
static_context* sctx,
+ CompilerCB* ccb,
const QueryLoc& loc,
bool stable,
const std::vector<OrderModifier>& modifiers,
const std::vector<expr*>& orderingExprs);
+public:
bool is_stable() const { return theStableOrder; }
const std::vector<OrderModifier>& get_modifiers() const { return theModifiers; }
@@ -514,7 +518,7 @@
void set_column_expr(csize i, expr* e) { theOrderingExprs[i] = e; }
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -528,12 +532,13 @@
class materialize_clause : public flwor_clause
{
friend class ExprIterator;
+ friend class ExprManager;
friend class flwor_expr;
+ materialize_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc);
+
public:
- materialize_clause(static_context* sctx, const QueryLoc& loc);
-
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
std::ostream& put(std::ostream&) const;
};
@@ -546,18 +551,19 @@
class count_clause : public flwor_clause
{
friend class ExprIterator;
+ friend class ExprManager;
protected:
var_expr* theVarExpr;
+ count_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc, var_expr* var);
+
public:
- count_clause(static_context* sctx, const QueryLoc& loc, var_expr* var);
-
~count_clause();
var_expr* get_var() const { return theVarExpr; }
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
};
@@ -567,18 +573,19 @@
class where_clause : public flwor_clause
{
friend class ExprIterator;
+ friend class ExprManager;
friend class flwor_expr;
expr* theWhereExpr;
+ where_clause(static_context* sctx, CompilerCB* ccb, const QueryLoc& loc, expr* where);
+
public:
- where_clause(static_context* sctx, const QueryLoc& loc, expr* where);
-
expr* get_expr() const { return theWhereExpr; }
void set_expr(expr* where);
- flwor_clause_t clone(expr::substitution_t& substitution) const;
+ flwor_clause* clone(expr::substitution_t& substitution) const;
};
@@ -615,7 +622,7 @@
friend class ExprManager;
public:
- typedef std::vector<rchandle<flwor_clause> > clause_list_t;
+ typedef std::vector<flwor_clause*> clause_list_t;
protected:
bool theIsGeneral;
=== modified file 'src/compiler/expression/update_exprs.cpp'
--- src/compiler/expression/update_exprs.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/update_exprs.cpp 2012-09-07 18:36:36 +0000
@@ -166,10 +166,11 @@
/*******************************************************************************
********************************************************************************/
-copy_clause::copy_clause(var_expr* aVar, expr* aExpr)
+copy_clause::copy_clause(CompilerCB* ccb, var_expr* aVar, expr* aExpr)
:
theVar(aVar),
- theExpr(aExpr)
+ theExpr(aExpr),
+ theCCB(ccb)
{
theVar->set_copy_clause(this);
}
@@ -182,7 +183,7 @@
}
-copy_clause_t copy_clause::clone(expr::substitution_t& subst) const
+copy_clause* copy_clause::clone(expr::substitution_t& subst) const
{
ZORBA_ASSERT(theVar && theExpr);
@@ -192,7 +193,7 @@
subst[theVar] = varCopy;
- return new copy_clause(varCopy, domainCopy);
+ return theCCB->theEM->create_copy_clause(varCopy, domainCopy);
}
@@ -232,7 +233,7 @@
}
-void transform_expr::add_back(copy_clause_t c)
+void transform_expr::add_back(copy_clause* c)
{
theCopyClauses.push_back(c);
@@ -253,7 +254,7 @@
transform_expr* cloneExpr =
theCCB->theEM->create_transform_expr(theSctx, get_loc());
- for (std::vector<copy_clause_t>::const_iterator lIter = theCopyClauses.begin();
+ for (std::vector<copy_clause*>::const_iterator lIter = theCopyClauses.begin();
lIter != theCopyClauses.end();
++lIter)
{
=== modified file 'src/compiler/expression/update_exprs.h'
--- src/compiler/expression/update_exprs.h 2012-08-30 13:45:43 +0000
+++ src/compiler/expression/update_exprs.h 2012-09-07 18:36:36 +0000
@@ -182,10 +182,7 @@
("," "$" VarName ":=" ExprSingle)*
"modify" ExprSingle "return" ExprSingle
********************************************************************************/
-class copy_clause;
-typedef rchandle<copy_clause> copy_clause_t;
-
-class copy_clause : public SimpleRCObject
+class copy_clause
{
friend class expr;
friend class transform_expr;
@@ -193,12 +190,12 @@
friend class ExprManager;
private:
- var_expr * theVar;
- expr * theExpr;
- CompilerCB* theExprManager;
+ var_expr * theVar;
+ expr * theExpr;
+ CompilerCB *const theCCB;
protected:
- copy_clause(var_expr* aVar, expr* aExpr);
+ copy_clause(CompilerCB* ccb, var_expr* aVar, expr* aExpr);
public:
~copy_clause();
@@ -209,7 +206,7 @@
expr* getExpr() const { return theExpr; }
- copy_clause_t clone(expr::substitution_t& s) const;
+ copy_clause* clone(expr::substitution_t& s) const;
std::ostream& put(std::ostream&) const;
};
@@ -222,7 +219,7 @@
friend class ExprManager;
protected:
- std::vector<copy_clause_t> theCopyClauses;
+ std::vector<copy_clause*> theCopyClauses;
expr * theModifyExpr;
expr * theReturnExpr;
@@ -238,14 +235,14 @@
void setReturnExpr(expr* e);
- void add_back(copy_clause_t c);
-
- copy_clause_t const& operator[](int i) const { return theCopyClauses[i]; }
-
- std::vector<copy_clause_t>::const_iterator begin() const
+ void add_back(copy_clause* c);
+
+ copy_clause* const& operator[](int i) const { return theCopyClauses[i]; }
+
+ std::vector<copy_clause*>::const_iterator begin() const
{ return theCopyClauses.begin(); }
- std::vector<copy_clause_t>::const_iterator end() const
+ std::vector<copy_clause*>::const_iterator end() const
{ return theCopyClauses.end(); }
csize size() const { return theCopyClauses.size(); }
=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
--- src/compiler/rewriter/rules/flwor_rules.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp 2012-09-07 18:36:36 +0000
@@ -367,7 +367,7 @@
}
else if (domainQuant == TypeConstants::QUANT_ONE)
{
- let_clause_t save = lc;
+ let_clause* save = lc;
MODIFY(flwor.remove_clause(i));
const QueryLoc& loc = var->get_loc();
var_expr* fvar = rCtx.theEM->create_var_expr(sctx,
@@ -375,7 +375,10 @@
var_expr::for_var,
var->get_name());
fvar->getFreeVars().insert(fvar);
- for_clause_t fc = new for_clause(sctx, rCtx.theCCB, loc, fvar, domainExpr);
+ for_clause* fc = rCtx.theEM->create_for_clause(sctx,
+ loc,
+ fvar,
+ domainExpr);
flwor.add_clause(i, fc);
subst_vars(rCtx, node, var, fvar);
=== modified file 'src/compiler/rewriter/rules/hoist_rules.cpp'
--- src/compiler/rewriter/rules/hoist_rules.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/rewriter/rules/hoist_rules.cpp 2012-09-07 18:36:36 +0000
@@ -381,9 +381,10 @@
for (csize i = 0; i < numClauses; ++i)
{
- const catch_clause_t& clause = (*trycatch)[i];
+ const catch_clause* clause = (*trycatch)[i];
- catch_clause::var_map_t& trycatchVars = clause->get_vars();
+ catch_clause::var_map_t& trycatchVars =
+ const_cast<catch_clause*>(clause)->get_vars();
catch_clause::var_map_t::const_iterator ite = trycatchVars.begin();
catch_clause::var_map_t::const_iterator end = trycatchVars.end();
@@ -482,9 +483,10 @@
hoisted->setFlags(e->getFlags());
letvar->setFlags(e->getFlags());
- let_clause_t flref(new let_clause(e->get_sctx(), rCtx.theCCB, e->get_loc(), letvar, hoisted));
+ let_clause* flref(
+ rCtx.theEM->create_let_clause(e->get_sctx(), e->get_loc(), letvar, hoisted));
- letvar->set_flwor_clause(flref.getp());
+ letvar->set_flwor_clause(flref);
if (step->prev == NULL)
{
=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-09-07 18:36:36 +0000
@@ -858,8 +858,8 @@
if (sctx->preserve_mode() != StaticContextConsts::no_preserve_ns)
{
- std::vector<copy_clause_t>::const_iterator ite = e->begin();
- std::vector<copy_clause_t>::const_iterator end = e->end();
+ std::vector<copy_clause*>::const_iterator ite = e->begin();
+ std::vector<copy_clause*>::const_iterator end = e->end();
for (; ite != end; ++ite)
{
@@ -1323,7 +1323,7 @@
#if 1
std::vector<VarInfo*> globalVars;
e->get_sctx()->getVariables(globalVars, true, true);
-
+
FOR_EACH(std::vector<VarInfo*>, ite, globalVars)
{
var_expr* globalVar = (*ite)->getVar();
=== modified file 'src/compiler/rewriter/tools/expr_tools.cpp'
--- src/compiler/rewriter/tools/expr_tools.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/rewriter/tools/expr_tools.cpp 2012-09-07 18:36:36 +0000
@@ -308,9 +308,10 @@
for (csize i = 0; i < numClauses; ++i)
{
- const catch_clause_t& clause = (*trycatch)[i];
+ const catch_clause* clause = (*trycatch)[i];
- catch_clause::var_map_t& trycatchVars = clause->get_vars();
+ catch_clause::var_map_t& trycatchVars =
+ const_cast<catch_clause*>(clause)->get_vars();
catch_clause::var_map_t::const_iterator ite = trycatchVars.begin();
catch_clause::var_map_t::const_iterator end = trycatchVars.end();
@@ -499,9 +500,10 @@
for (csize i = 0; i < numClauses; ++i)
{
- const catch_clause_t& clause = (*trycatch)[i];
+ const catch_clause* clause = (*trycatch)[i];
- catch_clause::var_map_t& trycatchVars = clause->get_vars();
+ catch_clause::var_map_t& trycatchVars =
+ const_cast<catch_clause*>(clause)->get_vars();
catch_clause::var_map_t::const_iterator ite = trycatchVars.begin();
catch_clause::var_map_t::const_iterator end = trycatchVars.end();
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-08-31 12:40:20 +0000
+++ src/compiler/translator/translator.cpp 2012-09-07 18:36:36 +0000
@@ -605,7 +605,7 @@
std::stack<xqtref_t> theTypeStack;
- std::vector<flwor_clause_t> theFlworClausesStack;
+ std::vector<flwor_clause*> theFlworClausesStack;
std::vector<const parsenode*> theTryStack;
@@ -1568,11 +1568,14 @@
Create a LET clause for the given LET variable "lv", with the given expr "e" as
its defining expression.
********************************************************************************/
-let_clause_t wrap_in_letclause(expr* e, var_expr* lv)
+let_clause* wrap_in_letclause(expr* e, var_expr* lv)
{
assert (lv->get_kind () == var_expr::let_var);
- return new let_clause(theRootSctx, theCCB, e->get_loc(), lv, e);
+ return theExprManager->create_let_clause(theRootSctx,
+ e->get_loc(),
+ lv,
+ e);
}
@@ -1581,7 +1584,7 @@
local sctx obj. Then, create a LET clause for this new var_expr, with the given
expr "e" as its defining expression.
********************************************************************************/
-let_clause_t wrap_in_letclause(
+let_clause* wrap_in_letclause(
expr* e,
const QueryLoc& loc,
const QName* qname)
@@ -1595,7 +1598,7 @@
this new var_expr, with the given expr "e" as its defining expression. NOTE:
the internal var is not registered in the sctx.
********************************************************************************/
-let_clause_t wrap_in_letclause(expr* e)
+let_clause* wrap_in_letclause(expr* e)
{
return wrap_in_letclause(e, create_temp_var(e->get_loc(), var_expr::let_var));
}
@@ -1605,7 +1608,7 @@
Create a FOR clause for the given FOR variable "fv" and its associated POS var
"pv" (pv may be NULL). Use the given expr "e" as the defining expr for "fv".
********************************************************************************/
-for_clause_t wrap_in_forclause(expr* e, var_expr* fv, var_expr* pv)
+for_clause* wrap_in_forclause(expr* e, var_expr* fv, var_expr* pv)
{
assert(fv->get_kind () == var_expr::for_var);
if (pv != NULL)
@@ -1613,8 +1616,11 @@
assert(pv->get_kind() == var_expr::pos_var);
}
- return new for_clause(theRootSctx, theCCB,
- e->get_loc(), fv, e, pv);
+ return theExprManager->create_for_clause(theRootSctx,
+ e->get_loc(),
+ fv,
+ e,
+ pv);
}
@@ -1624,7 +1630,7 @@
Then, create a FOR clause for these new var_exprs, with the given expr as the
defining expression of the FOR var.
********************************************************************************/
-for_clause_t wrap_in_forclause(
+for_clause* wrap_in_forclause(
expr* expr,
const QueryLoc& loc,
const QName* fv_qname,
@@ -1641,7 +1647,7 @@
this new var_expr, with the given expr as its defining expression. NOTE:
the internal var is not registered in the sctx.
********************************************************************************/
-for_clause_t wrap_in_forclause(expr* expr, bool add_posvar)
+for_clause* wrap_in_forclause(expr* expr, bool add_posvar)
{
var_expr* fv = create_temp_var(expr->get_loc(), var_expr::for_var);
@@ -1666,7 +1672,9 @@
var_expr* lv,
expr* retExpr)
{
- flwor_expr* fe = theExprManager->create_flwor_expr(theRootSctx, lv->get_loc(), false);
+ flwor_expr* fe = theExprManager->create_flwor_expr(theRootSctx,
+ lv->get_loc(),
+ false);
fe->add_clause(wrap_in_letclause(domExpr, lv));
@@ -1703,7 +1711,7 @@
if (withContextSize)
{
// create a LET var equal to the seq returned by the input epxr
- let_clause_t lcInputSeq = wrap_in_letclause(inputExpr);
+ let_clause* lcInputSeq = wrap_in_letclause(inputExpr);
// compute the size of the input seq
fo_expr* countExpr = theExprManager->create_fo_expr(theRootSctx,
@@ -1712,12 +1720,12 @@
lcInputSeq->get_var());
normalize_fo(countExpr);
- let_clause_t lcLast = wrap_in_letclause(countExpr,
+ let_clause* lcLast = wrap_in_letclause(countExpr,
loc,
LAST_IDX_VARNAME);
// Iterate over the input seq
- for_clause_t fcDot = wrap_in_forclause(lcInputSeq->get_var(),
+ for_clause* fcDot = wrap_in_forclause(lcInputSeq->get_var(),
loc,
DOT_VARNAME,
DOT_POS_VARNAME);
@@ -1728,7 +1736,7 @@
else
{
// Iterate over the input seq
- for_clause_t fcDot = wrap_in_forclause(inputExpr,
+ for_clause* fcDot = wrap_in_forclause(inputExpr,
loc,
DOT_VARNAME,
DOT_POS_VARNAME);
@@ -1994,7 +2002,7 @@
TreatIterator::TYPE_MATCH);
}
- expr* declExpr =
+ expr* declExpr =
theExprManager->create_var_decl_expr(theRootSctx, loc, varExpr, initExpr);
stmts.push_back(declExpr);
@@ -3809,7 +3817,7 @@
var_expr* arg_var = create_var(loc, qnameItem, var_expr::arg_var);
var_expr* subst_var = bind_var(loc, qnameItem, var_expr::let_var);
- let_clause_t lc = wrap_in_letclause(&*arg_var, subst_var);
+ let_clause* lc = wrap_in_letclause(&*arg_var, subst_var);
// theCurrentPrologVFDecl might be null in case of inline functions
// inline functions currently can't be sequential anyway
@@ -4793,8 +4801,7 @@
var_expr* varExpr = bind_var(loc, varQName, var_expr::let_var, NULL);
// let $x := dc:collection(xs:QName("example:coll1"))
- let_clause* lc = new let_clause(theRootSctx,
- theCCB,
+ let_clause* lc = theExprManager->create_let_clause(theRootSctx,
loc,
varExpr,
collExpr);
@@ -4892,12 +4899,13 @@
var_expr::let_var,
NULL);
- let_clause* letClause = new let_clause(theRootSctx,
- theCCB,
+ let_clause* letClause = theExprManager->create_let_clause(theRootSctx,
loc,
varExpr,
collExpr);
- flwor_expr* flworExpr = theExprManager->create_flwor_expr(theRootSctx, loc, false);
+
+ flwor_expr* flworExpr = theExprManager->create_flwor_expr(theRootSctx,
+ loc, false);
@@ -6219,8 +6227,7 @@
posVarExpr = bind_var(pv->get_location(), pvarQName, var_expr::pos_var);
}
- for_clause* fc = new for_clause(theRootSctx,
- theCCB,
+ for_clause* fc = theExprManager->create_for_clause(theRootSctx,
loc,
varExpr,
domainExpr,
@@ -6308,8 +6315,7 @@
var_expr* varExpr = bind_var(loc, varName, var_expr::let_var, type);
- let_clause* clause = new let_clause(theRootSctx,
- theCCB,
+ let_clause* clause = theExprManager->create_let_clause(theRootSctx,
loc,
varExpr,
domainExpr);
@@ -6373,8 +6379,7 @@
window_clause::tumbling_window :
window_clause::sliding_window);
- window_clause* clause = new window_clause(theRootSctx,
- theCCB,
+ window_clause* clause = theExprManager->create_window_clause(theRootSctx,
v.get_location(),
winKind,
NULL,
@@ -6396,7 +6401,8 @@
{
TRACE_VISIT_OUT();
- window_clause* windowClause = theFlworClausesStack.back().dyn_cast<window_clause>();
+ window_clause* windowClause =
+ dynamic_cast<window_clause*>(theFlworClausesStack.back());
assert(windowClause != NULL);
// Pop the window var and associate it with this window clause
@@ -6434,7 +6440,7 @@
// them in a flwor_wincond::vars obj. Also pop the condition expr and
// create a flwor_wincond obj for each condition.
flwor_wincond::vars inputCondVarExprs[2];
- flwor_wincond_t conds[2];
+ flwor_wincond* conds[2];
for (int i = 1; i >= 0; i--)
{
@@ -6446,13 +6452,17 @@
rchandle<WindowVars> vars = cond->get_winvars();
pop_wincond_vars(vars, inputCondVarExprs[i]);
- conds[i] = new flwor_wincond(theCCB,
+ conds[i] = theExprManager->create_flwor_wincond(
theSctx,
cond->is_only(),
inputCondVarExprs[i],
outputCondVarExprs[i],
condExpr);
}
+ else
+ {
+ conds[i] = NULL;
+ }
}
windowClause->set_var(windowVarExpr);
@@ -6781,7 +6791,7 @@
nongrouping_rebind.push_back(std::pair<expr*, var_expr*>(inputExpr, ngvar));
}
- group_clause* clause = new group_clause(theRootSctx,
+ group_clause* clause = theExprManager->create_group_clause(theRootSctx,
loc,
grouping_rebind,
nongrouping_rebind,
@@ -6904,7 +6914,7 @@
orderExprs[i] = orderExpr;
}
- orderby_clause* clause = new orderby_clause(theRootSctx,
+ orderby_clause* clause = theExprManager->create_orderby_clause(theRootSctx,
loc,
v.get_stable_bit(),
modifiers,
@@ -7020,7 +7030,7 @@
wrap_in_debugger_expr(whereExpr, whereExpr->get_loc());
- where_clause* clause = new where_clause(theRootSctx,
+ where_clause* clause = theExprManager->create_where_clause(theRootSctx,
loc,
whereExpr);
@@ -7047,7 +7057,7 @@
var_expr* varExpr = bind_var(loc, v.get_varname(), var_expr::count_var, NULL);
- count_clause* clause = new count_clause(theRootSctx,
+ count_clause* clause = theExprManager->create_count_clause(theRootSctx,
loc,
varExpr);
@@ -7552,7 +7562,7 @@
trycatch_expr* tce = dynamic_cast<trycatch_expr *>(theNodeStack.top());
- catch_clause_t cc = new catch_clause();
+ catch_clause* cc = theExprManager->create_catch_clause();
push_scope();
@@ -9147,7 +9157,7 @@
axisExpr->set_reverse_order();
}
- rchandle<let_clause> lcPredInput = wrap_in_letclause(predInputExpr);
+ let_clause* lcPredInput = wrap_in_letclause(predInputExpr);
flworExpr->add_clause(lcPredInput);
@@ -9442,7 +9452,7 @@
}
else if ((tce = dynamic_cast<trycatch_expr *>(top)) != NULL)
{
- catch_clause* cc = &*(*tce)[0];
+ catch_clause* cc = const_cast<catch_clause*>((*tce)[0]);
if (v.getQName() != NULL)
{
store::Item_t qnItem;
@@ -9547,7 +9557,7 @@
{
// for each item in the input seq compute the input seq for the pred
// (= outer_dot/primaryExpr)
- let_clause_t lcPredSeq = wrap_in_letclause(primaryExpr);
+ let_clause* lcPredSeq = wrap_in_letclause(primaryExpr);
flworExpr->add_clause(lcPredSeq);
@@ -9624,7 +9634,7 @@
const QueryLoc& loc = predExpr->get_loc();
// let $predVar := predExpr
- let_clause_t lcPred = wrap_in_letclause(predExpr);
+ let_clause* lcPred = wrap_in_letclause(predExpr);
var_expr* predvar = lcPred->get_var();
flworExpr->add_clause(lcPred);
@@ -10664,7 +10674,7 @@
for (csize i = 0; i < numArgs ; ++i)
{
- let_clause_t lc;
+ let_clause* lc;
store::Item_t qnameItem;
// cannot use create_temp_var() as the variables created there are not
@@ -11064,7 +11074,7 @@
var_expr* arg_var = create_var(loc, qname, var_expr::arg_var);
var_expr* subst_var = bind_var(loc, qname, var_expr::let_var);
- let_clause_t lc = wrap_in_letclause(&*arg_var, subst_var);
+ let_clause* lc = wrap_in_letclause(&*arg_var, subst_var);
arg_var->set_param_pos(flwor->num_clauses());
arg_var->set_type(varExpr->get_return_type());
@@ -13233,7 +13243,7 @@
fo_expr* updExpr = theExprManager->
create_fo_expr(theRootSctx,
- loc,
+ loc,
GET_BUILTIN_FUNCTION(OP_ZORBA_JSON_ARRAY_APPEND_2),
targetExpr,
contentExpr);
@@ -13339,7 +13349,7 @@
loc,
TreatIterator::JSONIQ_OBJECT_UPDATE_VALUE, // JNUP0017
NULL);
-
+
fo_expr* updExpr = theExprManager->
create_fo_expr(theRootSctx,
loc,
=== modified file 'src/compiler/xqddf/value_index.cpp'
--- src/compiler/xqddf/value_index.cpp 2012-08-30 13:45:43 +0000
+++ src/compiler/xqddf/value_index.cpp 2012-09-07 18:36:36 +0000
@@ -69,7 +69,8 @@
theDomainVar(NULL),
theDomainPosVar(NULL),
theBuildExpr(NULL),
- theDocIndexerExpr(NULL)
+ theDocIndexerExpr(NULL),
+ theDomainClause(NULL)
{
}
@@ -144,8 +145,7 @@
theDomainExpr = domainExpr;
if (theDomainClause == NULL)
- theDomainClause = new for_clause(domainExpr->get_sctx(),
- theCCB,
+ theDomainClause = theCCB->theEM->create_for_clause(domainExpr->get_sctx(),
domainExpr->get_loc(),
NULL,
NULL);
@@ -171,8 +171,7 @@
theDomainVar = domainVar;
if (theDomainClause == NULL)
- theDomainClause = new for_clause(domainVar->get_sctx(),
- theCCB,
+ theDomainClause = theCCB->theEM->create_for_clause(domainVar->get_sctx(),
domainVar->get_loc(),
NULL,
NULL);
@@ -497,7 +496,8 @@
//
// for $newdot at $newpos in new_domain_expr
//
- for_clause_t fc = new for_clause(sctx, theCCB, dotloc, newdot, newdom, newpos);
+ for_clause* fc =
+ theCCB->theEM->create_for_clause(sctx, dotloc, newdot, newdom, newpos);
//
// Clone the key exprs, replacing their references to the 2 domain variables
@@ -647,7 +647,8 @@
//
// for $newdot at $newpos in new_domain_expr
//
- for_clause_t fc = new for_clause(sctx, theCCB, dotloc, newdot, newdom, newpos);
+ for_clause* fc =
+ theCCB->theEM->create_for_clause(sctx, dotloc, newdot, newdom, newpos);
//
// Clone the key exprs, replacing their references to the 2 domain variables
=== modified file 'src/compiler/xqddf/value_index.h'
--- src/compiler/xqddf/value_index.h 2012-08-30 13:45:43 +0000
+++ src/compiler/xqddf/value_index.h 2012-09-07 18:36:36 +0000
@@ -264,7 +264,7 @@
MaintenanceMode theMaintenanceMode;
ContainerKind theContainerKind;
- for_clause_t theDomainClause;
+ for_clause * theDomainClause;
expr * theDomainExpr;
var_expr * theDomainVar;
var_expr * theDomainPosVar;
Follow ups
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: noreply, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Markos Zaharioudakis, 2012-09-10
-
Re: [Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Markos Zaharioudakis, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-10
-
Re: [Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-10
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Markos Zaharioudakis, 2012-09-09
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-09
-
Re: [Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-09
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Zorba Build Bot, 2012-09-09
-
[Merge] lp:~zorba-coders/zorba/expr-memman3 into lp:zorba
From: Markos Zaharioudakis, 2012-09-08