/** The real evaluation method. */
gmx::sel_evalfunc evaluate;
/** Number of references to a \ref SEL_SUBEXPR element. */
- int refcount;
+ int refcount;
/** Flags for specifying how to treat this element during compilation. */
- int flags;
+ int flags;
/** Smallest selection that can be selected by the subexpression. */
- gmx_ana_index_t *gmin;
+ gmx_ana_index_t *gmin;
/** Largest selection that can be selected by the subexpression. */
- gmx_ana_index_t *gmax;
+ gmx_ana_index_t *gmax;
} t_compiler_data;
int nalloc;
GMX_RELEASE_ASSERT(sel->v.type != POS_VALUE,
- "Wrong allocation method called");
+ "Wrong allocation method called");
if (sel->mempool)
{
return;
if (sel->type == SEL_SUBEXPRREF)
{
GMX_RELEASE_ASSERT(sel->child && sel->child->type == SEL_SUBEXPR,
- "Subexpression expected for subexpression reference");
+ "Subexpression expected for subexpression reference");
child = sel->child->child;
GMX_RELEASE_ASSERT(child,
- "Subexpression elements should always have a child element");
+ "Subexpression elements should always have a child element");
}
nalloc = child->v.nr;
}
int nalloc, isize;
GMX_RELEASE_ASSERT(sel->v.type == POS_VALUE,
- "Wrong allocation method called");
+ "Wrong allocation method called");
GMX_RELEASE_ASSERT(!(sel->flags & SEL_ATOMVAL),
- "Per-atom evaluated positions not implemented");
+ "Per-atom evaluated positions not implemented");
if (sel->mempool)
{
return;
if (sel->type == SEL_SUBEXPRREF)
{
GMX_RELEASE_ASSERT(sel->child && sel->child->type == SEL_SUBEXPR,
- "Subexpression expected for subexpression reference");
+ "Subexpression expected for subexpression reference");
child = sel->child->child;
GMX_RELEASE_ASSERT(child,
- "Subexpression elements should always have a child element");
+ "Subexpression elements should always have a child element");
}
nalloc = child->v.u.p->nr;
- isize = child->v.u.p->m.b.nra;
+ isize = child->v.u.p->m.b.nra;
/* For positions, we want to allocate just a single structure
* for nalloc positions. */
*/
static void
set_evaluation_function(const SelectionTreeElementPointer &sel,
- gmx::sel_evalfunc eval)
+ gmx::sel_evalfunc eval)
{
sel->evaluate = eval;
if (sel->type != SEL_SUBEXPRREF)
if (root->type == SEL_EXPRESSION)
{
bool bSelection = (sel != NULL);
- int flags = bSelection ? POS_COMPLMAX : POS_COMPLWHOLE;
+ int flags = bSelection ? POS_COMPLMAX : POS_COMPLWHOLE;
if (bSelection)
{
if (sel->hasFlag(gmx::efSelection_DynamicMask))
{
SelectionTreeElementPointer next = item->next;
item->next = prev;
- prev = item;
- item = next;
+ prev = item;
+ item = next;
}
return prev;
}
*/
static SelectionTreeElementPointer
extract_item_subselections(const SelectionTreeElementPointer &sel,
- int *subexprn)
+ int *subexprn)
{
SelectionTreeElementPointer root;
SelectionTreeElementPointer subexpr;
/*! \brief
* Extracts subexpressions of the selection chain.
- *
+ *
* \param sel First selection in the whole selection chain.
* \returns The new first element for the chain.
*
{
SelectionTreeElementPointer root;
SelectionTreeElementPointer next = sel;
- int subexprn = 0;
+ int subexprn = 0;
while (next)
{
SelectionTreeElementPointer item
{
root = next;
}
- sel = next;
+ sel = next;
next = next->next;
}
return root;
}
else
{
- prev = child;
+ prev = child;
child = child->next;
}
}
snew(r, 1);
r[0] = child->v.u.i[0];
sfree(child->v.u.i);
- child->v.u.r = r;
+ child->v.u.r = r;
child->v.type = REAL_VALUE;
}
else if (child->v.type != REAL_VALUE)
*/
static void
setup_memory_pooling(const SelectionTreeElementPointer &sel,
- gmx_sel_mempool_t *mempool)
+ gmx_sel_mempool_t *mempool)
{
if (sel->type != SEL_SUBEXPRREF)
{
else if (sel->type == SEL_SUBEXPR
&& (sel->cdata->flags & SEL_CDATA_FULLEVAL))
{
- sel->evaluate = &_gmx_sel_evaluate_subexpr_staticeval;
+ sel->evaluate = &_gmx_sel_evaluate_subexpr_staticeval;
sel->cdata->evaluate = sel->evaluate;
- sel->child->mempool = NULL;
- sel->flags &= ~(SEL_ALLOCVAL | SEL_ALLOCDATA);
+ sel->child->mempool = NULL;
+ sel->flags &= ~(SEL_ALLOCVAL | SEL_ALLOCDATA);
if (sel->v.type == GROUP_VALUE || sel->v.type == POS_VALUE)
{
_gmx_selvalue_setstore(&sel->v, sel->child->v.u.ptr);
while (child)
{
child->cdata->flags |= SEL_CDATA_EVALMAX;
- child = child->next;
+ child = child->next;
}
}
}
while (child)
{
child->cdata->flags &= ~SEL_CDATA_STATICEVAL;
- child = child->next;
+ child = child->next;
}
}
*/
static void
mark_subexpr_dynamic(const SelectionTreeElementPointer &sel,
- bool bDynamic)
+ bool bDynamic)
{
if (!bDynamic && !(sel->flags & SEL_DYNAMIC))
{
{
if (sel->child->child->flags & SEL_ALLOCDATA)
{
- sel->flags |= SEL_ALLOCDATA;
+ sel->flags |= SEL_ALLOCDATA;
sel->child->child->flags &= ~SEL_ALLOCDATA;
}
if (sel->child->child->flags & SEL_ALLOCVAL)
{
- sel->flags |= SEL_ALLOCVAL;
- sel->v.nalloc = sel->child->child->v.nalloc;
- sel->child->child->flags &= ~SEL_ALLOCVAL;
+ sel->flags |= SEL_ALLOCVAL;
+ sel->v.nalloc = sel->child->child->v.nalloc;
+ sel->child->child->flags &= ~SEL_ALLOCVAL;
sel->child->child->v.nalloc = -1;
}
}
* \returns 0 on success, a non-zero error code on error.
*/
static void
-process_const(gmx_sel_evaluate_t *data,
+process_const(gmx_sel_evaluate_t *data,
const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+ gmx_ana_index_t *g)
{
if (sel->v.type == GROUP_VALUE)
{
init_method(const SelectionTreeElementPointer &sel, t_topology *top, int isize)
{
/* Find out whether there are any atom-valued parameters */
- bool bAtomVal = false;
+ bool bAtomVal = false;
SelectionTreeElementPointer child = sel->child;
while (child)
{
{
sel->flags |= SEL_METHODINIT;
sel->u.expr.method->init(top, sel->u.expr.method->nparams,
- sel->u.expr.method->param, sel->u.expr.mdata);
+ sel->u.expr.method->param, sel->u.expr.mdata);
}
if (bAtomVal || !(sel->flags & SEL_OUTINIT))
{
else
{
GMX_RELEASE_ASSERT(sel->v.type != POS_VALUE,
- "Output initialization must be provided for "
- "position-valued selection methods");
+ "Output initialization must be provided for "
+ "position-valued selection methods");
GMX_RELEASE_ASSERT(!(sel->flags & SEL_VARNUMVAL),
- "Output initialization must be provided for "
- "SMETH_VARNUMVAL selection methods");
+ "Output initialization must be provided for "
+ "SMETH_VARNUMVAL selection methods");
alloc_selection_data(sel, isize, true);
if ((sel->flags & SEL_DYNAMIC)
&& sel->v.type != GROUP_VALUE && sel->v.type != POS_VALUE)
* reorder_item_static_children() should have been called.
*/
static void
-evaluate_boolean_static_part(gmx_sel_evaluate_t *data,
+evaluate_boolean_static_part(gmx_sel_evaluate_t *data,
const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+ gmx_ana_index_t *g)
{
/* Find the last static subexpression */
SelectionTreeElementPointer child = sel->child;
init_item_minmax_groups(child);
child->cdata->flags &= ~SEL_CDATA_STATICEVAL;
child->cdata->flags |= sel->cdata->flags & SEL_CDATA_STATICEVAL;
- child->next = next;
+ child->next = next;
// Frees the old static subexpressions.
sel->child = child;
}
&& sel->child->v.u.g->isize < gmin->isize)
{
GMX_RELEASE_ASSERT(sel->child->type == SEL_CONST,
- "The first child should have already been evaluated "
- "to a constant expression");
+ "The first child should have already been evaluated "
+ "to a constant expression");
gmx_ana_index_reserve(sel->child->v.u.g, gmin->isize);
gmx_ana_index_copy(sel->child->v.u.g, gmin, false);
if (sel->child->u.cgrp.nalloc_index > 0)
else
{
GMX_RELEASE_ASSERT(sel->child->u.cgrp.index == sel->child->v.u.g->index,
- "If not allocated, the static group should equal the value");
+ "If not allocated, the static group should equal the value");
sel->child->u.cgrp.isize = sel->child->v.u.g->isize;
}
}
/*! \brief
* Evaluates the static parts of \p sel and analyzes the structure.
- *
+ *
* \param[in] data Evaluation data.
* \param[in,out] sel Selection currently being evaluated.
* \param[in] g Group for which \p sel should be evaluated.
* It does the single most complex task in the compiler: after all elements
* have been processed, the \p gmin and \p gmax fields of \p t_compiler_data
* have been properly initialized, enough memory has been allocated for
- * storing the value of each expression, and the static parts of the
+ * storing the value of each expression, and the static parts of the
* expressions have been evaluated.
* The above is exactly true only for elements other than subexpressions:
* another pass is required for subexpressions that are referred to more than
* once and whose evaluation group is not known in advance.
*/
static void
-analyze_static(gmx_sel_evaluate_t *data,
+analyze_static(gmx_sel_evaluate_t *data,
const SelectionTreeElementPointer &sel,
- gmx_ana_index_t *g)
+ gmx_ana_index_t *g)
{
bool bDoMinMax;
*/
static void
init_root_item(const SelectionTreeElementPointer &root,
- gmx_ana_index_t *gall)
+ gmx_ana_index_t *gall)
{
const SelectionTreeElementPointer &expr = root->child;
/* Subexpressions with non-static evaluation group should not be
gmx_ana_index_deinit(&sel->u.cgrp);
sel->u.cgrp.name = name;
- sel->evaluate = &_gmx_sel_evaluate_subexpr_staticeval;
+ sel->evaluate = &_gmx_sel_evaluate_subexpr_staticeval;
sel->cdata->evaluate = sel->evaluate;
sel->child->freeValues();
{
if (sel->child->child->flags & SEL_ALLOCVAL)
{
- sel->flags |= SEL_ALLOCVAL;
- sel->flags |= (sel->child->child->flags & SEL_ALLOCDATA);
- sel->v.nalloc = sel->child->child->v.nalloc;
- sel->child->child->flags &= ~(SEL_ALLOCVAL | SEL_ALLOCDATA);
+ sel->flags |= SEL_ALLOCVAL;
+ sel->flags |= (sel->child->child->flags & SEL_ALLOCDATA);
+ sel->v.nalloc = sel->child->child->v.nalloc;
+ sel->child->child->flags &= ~(SEL_ALLOCVAL | SEL_ALLOCDATA);
sel->child->child->v.nalloc = -1;
}
}
&& !(sel->cdata->flags & SEL_CDATA_SIMPLESUBEXPR)
&& (sel->cdata->flags & SEL_CDATA_FULLEVAL))
{
- sel->flags |= SEL_ALLOCVAL;
- sel->flags |= (sel->child->flags & SEL_ALLOCDATA);
- sel->v.nalloc = sel->child->v.nalloc;
- sel->child->flags &= ~(SEL_ALLOCVAL | SEL_ALLOCDATA);
+ sel->flags |= SEL_ALLOCVAL;
+ sel->flags |= (sel->child->flags & SEL_ALLOCDATA);
+ sel->v.nalloc = sel->child->v.nalloc;
+ sel->child->flags &= ~(SEL_ALLOCVAL | SEL_ALLOCDATA);
sel->child->v.nalloc = -1;
}
}
}
if (!sel->u.expr.pc)
{
- cflags |= flags;
+ cflags |= flags;
sel->u.expr.pc = pcc->createCalculation(type, cflags);
}
else
void
SelectionCompiler::compile(SelectionCollection *coll)
{
- gmx_ana_selcollection_t *sc = &coll->impl_->sc_;
- gmx_sel_evaluate_t evaldata;
+ gmx_ana_selcollection_t *sc = &coll->impl_->sc_;
+ gmx_sel_evaluate_t evaldata;
SelectionTreeElementPointer item;
- e_poscalc_t post;
- size_t i;
- int flags;
- bool bDebug = (coll->impl_->debugLevel_ >= 2
- && coll->impl_->debugLevel_ != 3);
+ e_poscalc_t post;
+ size_t i;
+ int flags;
+ bool bDebug = (coll->impl_->debugLevel_ >= 2
+ && coll->impl_->debugLevel_ != 3);
/* FIXME: Clean up the collection on exceptions */