Package xbird.xquery.expr

Examples of xbird.xquery.expr.XQExpression


                }
            }
            isLoopInvariant &= b.isLoopInvariant();
        }
        // #2 return
        XQExpression filteredRet = flwr.getFilteredReturnExpr();
        if(filteredRet != null) {
            XQExpression filteredRet2 = filteredRet.visit(this, ctxt);
            flwr.setFilteredReturnExpr(filteredRet2);
            isLoopInvariant &= filteredRet2.isLoopInvariant();
        } else {
            // #2-1 where filtering
            XQExpression where = flwr.getWhereExpr();
            if(where != null) {
                where.visit(this, ctxt);
                isLoopInvariant &= where.isLoopInvariant();
            }
            // #2-2 return
            XQExpression ret = flwr.getReturnExpr();
            assert (ret != null);
            ret.visit(this, ctxt);
            isLoopInvariant &= ret.isLoopInvariant();
        }
        // #3 order by sorting
        for(OrderSpec o : flwr.getOrderSpecs()) {
            o.visit(this, ctxt);
            isLoopInvariant &= o.isLoopInvariant();
        }
        if(isLoopInvariant) {
            for(Binding b : bindings) {
                removeInvariants(b);
            }
            if(filteredRet != null) {
                removeInvariants(filteredRet);
            } else {
                XQExpression where = flwr.getWhereExpr();
                if(where != null) {
                    removeInvariants(where);
                }
                XQExpression ret = flwr.getReturnExpr();
                removeInvariants(ret);
            }
            for(OrderSpec o : flwr.getOrderSpecs()) {
                removeInvariants(o);
            }
View Full Code Here


        }
        return flwr;
    }

    public ForClause visit(ForClause clause, XQueryContext ctxt) throws XQueryException {
        XQExpression e = clause.getInExpr();
        XQExpression e2 = e.visit(this, ctxt);
        boolean isLoopInvariant = e.isLoopInvariant();
        if(isLoopInvariant) {
            clause.setInExpr(e2);
            clause.setLoopInvariant(true);
        }
View Full Code Here

    }

    public XQExpression visit(IfExpr expr, XQueryContext ctxt) throws XQueryException {
        boolean isLoopInvariant = true;
        // if
        XQExpression cond = expr.getCondExpr();
        cond.visit(this, ctxt);
        isLoopInvariant &= cond.isLoopInvariant();
        // then
        XQExpression then = expr.getThenExpr();
        then.visit(this, ctxt);
        isLoopInvariant &= then.isLoopInvariant();
        // else
        XQExpression els = expr.getElseExpr();
        els.visit(this, ctxt);
        isLoopInvariant &= els.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(cond);
            removeInvariants(then);
            removeInvariants(els);
            return hookLoopInvariant(expr);
View Full Code Here

        }
        return expr;
    }

    public XQExpression visit(InstanceofOp op, XQueryContext ctxt) throws XQueryException {
        XQExpression e = op.getExpression();
        e.visit(this, ctxt);
        boolean isLoopInvariant = e.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(e);
            return hookLoopInvariant(op);
        }
        return op;
View Full Code Here

        this.visit((FunctionCall) call, ctxt);
        return call;
    }

    public LetClause visit(LetClause clause, XQueryContext ctxt) throws XQueryException {
        XQExpression e = clause.getExpression();
        e.visit(this, ctxt);
        boolean isLoopInvariant = e.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(e);
            clause.setLoopInvariant(true);
        }
        return clause;
View Full Code Here

        return expr;
    }

    public XQExpression visit(MultiplicativeExpr op, XQueryContext ctxt) throws XQueryException {
        boolean isLoopInvariant = true;
        XQExpression left = op.getLeftOperand();
        left.visit(this, ctxt);
        isLoopInvariant &= left.isLoopInvariant();
        XQExpression right = op.getRightOperand();
        right.visit(this, ctxt);
        isLoopInvariant &= right.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(left);
            removeInvariants(right);
            return hookLoopInvariant(op);
        }
View Full Code Here

        constructor.setLoopInvariant(true);
        return constructor;
    }

    public XQExpression visit(NegativeExpr op, XQueryContext ctxt) throws XQueryException {
        XQExpression e = op.getExpression();
        e.visit(this, ctxt);
        boolean isLoopInvariant = e.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(e);
            return hookLoopInvariant(op);
        }
        return op;
View Full Code Here

        nt.setLoopInvariant(true);
        return nt;
    }

    public XQExpression visit(OrderSpec spec, XQueryContext ctxt) throws XQueryException {
        XQExpression e = spec.getKeyExpr();
        e.visit(this, ctxt);
        boolean isLoopInvariant = e.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(e);
            return hookLoopInvariant(spec);
        }
        return spec;
View Full Code Here

        this.visit((Variable) variable, ctxt);
        return variable;
    }

    public XQExpression visit(ParenthesizedExpr paren, XQueryContext ctxt) throws XQueryException {
        XQExpression e = paren.getExpr();
        e.visit(this, ctxt);
        boolean isLoopInvariant = e.isLoopInvariant();
        if(isLoopInvariant) {
            removeInvariants(e);
            return hookLoopInvariant(paren);
        }
        return paren;
View Full Code Here

    public XQExpression visit(PathExpr path, XQueryContext ctxt) throws XQueryException {
        boolean isLoopInvariant = true;
        List<XQExpression> steps = path.getSteps();
        int steplen = steps.size();
        for(int i = 0; i < steplen; i++) {
            XQExpression s = steps.get(i);
            XQExpression s2 = s.visit(this, ctxt);
            if(s != s2) {
                steps.set(i, s2);
            }
            isLoopInvariant &= s.isLoopInvariant();
        }
View Full Code Here

TOP

Related Classes of xbird.xquery.expr.XQExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.