use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class Normalizer method doForExpr.
// does a for and a quantified expression
// takes the iterator for var expr paris
private void doForExpr(Iterator iter, Expr expr) {
Collection vars = new ArrayList();
// go through expression and cache variables
while (iter.hasNext()) {
VarExprPair pair = (VarExprPair) iter.next();
QName var = pair.varname();
Expr e = pair.expr();
// XXX this is wrong!
// need to define new scope, and reference "inner scope"
// [shadow outer vars]
/*
* if(_sc.variable_exists(var)) report_error(new
* StaticNameError("Variable " + var.string() +
* " already defined"));
*/
// ok we can cheat here cuz we only care about variable
// "presence" not its specific instance / value so we
// can fakely shadow without creating explicit scopes
// if variable already exists.... then leave it there...
// [we do not need to create a new instance and delete
// it at the end]
// we only need to if variable does not exist
// XXX: i fink this is all wrong
vars.add(var);
e.accept(this);
}
// add variables to scope
for (Iterator i = vars.iterator(); i.hasNext(); ) {
QName var = (QName) i.next();
}
// do the bounded expression
expr.accept(this);
// remove variables
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair in project webtools.sourceediting by eclipse.
the class Normalizer method printVarExprPairs.
private void printVarExprPairs(Iterator i) {
while (i.hasNext()) {
VarExprPair pair = (VarExprPair) i.next();
QName var = pair.varname();
Expr e = pair.expr();
e.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 fex
* is the For expression.
* @return fex expression.
*/
public Object visit(ForExpr fex) {
ForExpr last = fex;
Expr ret = fex.expr();
int depth = 0;
for (Iterator i = fex.iterator(); i.hasNext(); ) {
VarExprPair ve = (VarExprPair) i.next();
// ok we got nested fors...
if (depth > 0) {
Collection pairs = new ArrayList();
pairs.add(ve);
ForExpr fe = new ForExpr(pairs, ret);
last.set_expr(fe);
last = fe;
}
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)
fex.truncate_pairs();
return fex;
}
Aggregations