use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class StaticNameResolver method doForExpr.
// does a for and a quantified expression
// takes the iterator for var expr paris
private void doForExpr(Iterator iter, Expr expr) {
int scopes = 0;
// add variables to scope and check the binding sequence
while (iter.hasNext()) {
VarExprPair pair = (VarExprPair) iter.next();
QName var = pair.varname();
if (!expandVarQName(var))
reportBadPrefix(var.prefix());
Expr e = pair.expr();
e.accept(this);
pushScope(var, BuiltinTypeLibrary.XS_ANYTYPE);
scopes++;
}
expr.accept(this);
// kill the scopes
for (int i = 0; i < scopes; i++) popScope();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_exists.
private XSBoolean do_exists(ListIterator iter, Expr finalexpr) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
QName varname = ve.varname();
try {
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
XSBoolean effbool = do_exists(iter, finalexpr);
popScope();
// out what to do with it
if (effbool.value())
return XSBoolean.TRUE;
}
} finally {
iter.previous();
}
// since none in this sequence evaluated to true, return false
return XSBoolean.FALSE;
} else // we finally got to do the "last expression"
{
return effective_boolean_value((ResultSequence) finalexpr.accept(this));
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_for_each.
private void do_for_each(ListIterator iter, Expr finalexpr, ResultBuffer destination) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
// XXX
if (rs.empty()) {
iter.previous();
return;
}
QName varname = ve.varname();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
do_for_each(iter, finalexpr, destination);
popScope();
}
iter.previous();
} else // we finally got to do the "last expression"
{
destination.concat((ResultSequence) finalexpr.accept(this));
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_for_all.
// XXX ugly
// type: 0 = for [return == "correct"]
// 1 = for all [return false, return empty on true]
// 2 = there exists [return true, return empty on false]
private XSBoolean do_for_all(ListIterator iter, Expr finalexpr) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
QName varname = ve.varname();
try {
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
XSBoolean effbool = do_for_all(iter, finalexpr);
popScope();
// out what to do with it
if (!effbool.value())
return XSBoolean.FALSE;
}
} finally {
iter.previous();
}
return XSBoolean.TRUE;
} else // we finally got to do the "last expression"
{
return effective_boolean_value((ResultSequence) finalexpr.accept(this));
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class Normalizer method visit.
/**
* @param qex
* is the Quantified expression.
* @return qex expression.
*/
// XXX: code duplication
public Object visit(QuantifiedExpr qex) {
QuantifiedExpr last = qex;
Expr ret = qex.expr();
int depth = 0;
for (Iterator i = qex.iterator(); i.hasNext(); ) {
VarExprPair ve = (VarExprPair) i.next();
// ok we got nested fors...
if (depth > 0) {
Collection pairs = new ArrayList();
pairs.add(ve);
QuantifiedExpr qe = new QuantifiedExpr(qex.type(), pairs, ret);
last.set_expr(qe);
last = qe;
}
depth++;
}
// normalize return value, and set it to the last for expr
ret.accept(this);
// get rid of the pairs in the parent (original) for
if (depth > 1)
qex.truncate_pairs();
return qex;
}
Aggregations