Package xbird.xquery.expr.flwr

Examples of xbird.xquery.expr.flwr.Binding


    public XQExpression visit(FLWRExpr expr, XQueryContext ctxt) throws XQueryException {
        // for, let
        List causes = expr.getClauses();
        int prev_type = -1;
        for(int i = 0; i < causes.size(); i++) {
            Binding cause = (Binding) causes.get(i);
            Variable var = cause.getVariable();
            final int type = cause.getExpressionType();
            if(i != 0) {
                if(prev_type == type) {
                    buf.append(", ");
                }
                lineFeed();
View Full Code Here


    public XQExpression visit(FLWRExpr flwr, XQueryContext ctxt) throws XQueryException {
        boolean isLoopInvariant = true;
        // #1 for loop
        List<Binding> bindings = flwr.getClauses();
        for(int i = 0; i < bindings.size(); i++) {
            Binding b = bindings.get(i);
            int type = b.getExpressionType();
            if(flwr.isTransformed()) {
                if(type == Binding.FOR_CLAUSE) {
                    // no need to analyze
                    return flwr;
                } else {
                    LetClause lc = (LetClause) b;
                    lc.visit(this, ctxt);
                    if(lc.isLoopInvariant()) {
                        _pullup.put(lc, bindings);
                    }
                }
            } else {
                if(type == Binding.FOR_CLAUSE) {
                    ForClause forClause = (ForClause) b;
                    int loopDepth = forClause.getLoopDepth();
                    if(loopDepth <= 1) {
                        _protectHook = true;
                    }
                    forClause.visit(this, ctxt);
                    _protectHook = false;
                } else {
                    b.visit(this, ctxt);
                }
            }
            isLoopInvariant &= b.isLoopInvariant();
        }
        // #2 return
        XQExpression filteredRet = flwr.getFilteredReturnExpr();
        if(filteredRet != null) {
            XQExpression filteredRet2 = filteredRet.visit(this, ctxt);
View Full Code Here

        List<Binding> clauses = _flwr.getClauses();
        int clauselen = clauses.size();
        int insertionPoint = 0;
        for(int i = 0; i < clauselen; i++) {
            Binding binding = clauses.get(i);
            if(binding == _forClause) {
                insertionPoint = i;
                break;
            }
        }
View Full Code Here

                                    lv.incrementReferenceCount();
                                    final int bsize = _currentBindings.size();
                                    assert (bsize > 0) : bsize;
                                    boolean found = false;
                                    for(int i = 0; i < bsize; i++) {
                                        Binding binding = _currentBindings.get(i);
                                        if(binding == _currentForClause) {
                                            LetClause lc = new LetClause(lv);
                                            _currentBindings.add(i, lc);
                                            found = true;
                                            break;
View Full Code Here

    public XQExpression visit(FLWRExpr expr, XQueryContext ctxt) throws XQueryException {
        // #1 for loop
        List<Binding> bindings = expr.getClauses();
        int bingingLen = bindings.size();
        for(int i = 0; i < bingingLen; i++) {
            Binding b = bindings.get(i);
            b.visit(this, ctxt);
        }
        // #2 return
        XQExpression filteredRet = expr.getFilteredReturnExpr();
        if(filteredRet != null) {
            filteredRet.visit(this, ctxt);
View Full Code Here

                }
            } else if(expr instanceof FLWRExpr) {
                FLWRExpr flwrExpr = ((FLWRExpr) expr);
                List<Binding> clauses = flwrExpr.getClauses();
                if(!clauses.isEmpty()) {
                    Binding firstClause = clauses.get(0);
                    BindingVariable bindingVar = firstClause.getVariable();
                    XQExpression bindingExpr = bindingVar.getValue();
                    if(bindingExpr instanceof DirectFunctionCall) {
                        DirectFunctionCall funcall = (DirectFunctionCall) bindingExpr;
                        if(FnCollection.FUNC_NAME.equals(funcall.getFuncName())) {
                            List<XQExpression> params = funcall.getParams();
View Full Code Here

    public XQExpression visit(FLWRExpr flwr, XQueryContext ctxt) throws XQueryException {
        boolean isLoopInvariant = true;
        // #1 for loop
        List<Binding> bindings = flwr.getClauses();
        for(int i = 0; i < bindings.size(); i++) {
            Binding b = bindings.get(i);
            int type = b.getExpressionType();
            if(flwr.isTransformed()) {
                if(type == Binding.FOR_CLAUSE) {
                    // no need to analyze
                    return flwr;
                } else {
                    LetClause lc = (LetClause) b;
                    lc.visit(this, ctxt);
                    if(lc.isLoopInvariant()) {
                        _pullup.put(lc, bindings);
                    }
                }
            } else {
                if(type == Binding.FOR_CLAUSE) {
                    ForClause forClause = (ForClause) b;
                    int loopDepth = forClause.getLoopDepth();
                    if(loopDepth <= 1) {
                        _protectHook = true;
                    }
                    forClause.visit(this, ctxt);
                    _protectHook = false;
                } else {
                    b.visit(this, ctxt);
                }
            }
            isLoopInvariant &= b.isLoopInvariant();
        }
        // #2 return
        XQExpression filteredRet = flwr.getFilteredReturnExpr();
        if(filteredRet != null) {
            XQExpression filteredRet2 = filteredRet.visit(this, ctxt);
View Full Code Here

        List<Binding> clauses = _flwr.getClauses();
        int clauselen = clauses.size();
        int insertionPoint = 0;
        for(int i = 0; i < clauselen; i++) {
            Binding binding = clauses.get(i);
            if(binding == _forClause) {
                insertionPoint = i;
                break;
            }
        }
View Full Code Here

                                    lv.incrementReferenceCount();
                                    final int bsize = _currentBindings.size();
                                    assert (bsize > 0) : bsize;
                                    boolean found = false;
                                    for(int i = 0; i < bsize; i++) {
                                        Binding binding = _currentBindings.get(i);
                                        if(binding == _currentForClause) {
                                            LetClause lc = new LetClause(lv);
                                            _currentBindings.add(i, lc);
                                            found = true;
                                            break;
View Full Code Here

    public XQExpression visit(FLWRExpr expr, XQueryContext ctxt) throws XQueryException {
        // #1 for loop
        List<Binding> bindings = expr.getClauses();
        int bingingLen = bindings.size();
        for(int i = 0; i < bingingLen; i++) {
            Binding b = bindings.get(i);
            b.visit(this, ctxt);
        }
        // #2 return
        XQExpression filteredRet = expr.getFilteredReturnExpr();
        if(filteredRet != null) {
            filteredRet.visit(this, ctxt);
View Full Code Here

TOP

Related Classes of xbird.xquery.expr.flwr.Binding

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.