Package xbird.xquery.expr

Examples of xbird.xquery.expr.XQExpression.eval()


    public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        LetVariable lv = (LetVariable) _variable;
        XQExpression letExpr = lv.getValue();
        Sequence<? extends Item> res = letExpr.eval(contextSeq, dynEnv);
        if(lv.attemptEagarEvaluation() && lv.getReferenceCount() > 1) {
            List<? extends Item> items = res.materialize(); // TODO REVIEWME weak memory utilization
            lv.allocateResult(new ValueSequence(items, dynEnv), dynEnv);
        } else {
            lv.allocateResult(res, dynEnv);
View Full Code Here


        FunctionCallContext recEnv = new FunctionCallContext(dynEnv);
        for(int i = 0; i < paramArity; i++) {
            ParametricVariable paramVar = params.get(i);
            XQExpression argExpr = _params.get(i);
            paramVar.setValue(argExpr); // for the static analzing
            Sequence argValue = argExpr.eval(contextSeq, dynEnv);
            paramVar.allocateResult(argValue, recEnv);
        }
        XQExpression body = udf.getBodyExpression();
        // lazy function may not be analyzed TODO REVIEWME
        XQExpression analyzed = body.staticAnalysis(dynEnv.getStaticContext());
View Full Code Here

        // lazy function may not be analyzed TODO REVIEWME
        XQExpression analyzed = body.staticAnalysis(dynEnv.getStaticContext());
        if(LOG.isDebugEnabled()) {
            LOG.debug("Invoke LazyFunctionCall: " + QNameUtil.toLexicalForm(getFuncName()));
        }
        return analyzed.eval(contextSeq, recEnv);
    }

    public void setFunctionManager(FunctionManager functionManager) {
        assert (functionManager != null);
        this._functionManager = functionManager;
View Full Code Here

    }

    public ForEmurationSequence eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        XQExpression inExpr = _variable.getValue();
        Sequence<? extends Item> src = inExpr.eval(contextSeq, dynEnv);
        /*
         if(_loopDepth > 1) {
         // TODO REVIEWME memory space           
         // cache evaluated sequence in the nested loop
         if(inExpr.isLoopInvariant()) {
View Full Code Here

            } else if(paramSize == 1) {
                XQExpression expr = _params.get(0);
                if(expr instanceof Evaluable) {
                    final Sequence<? extends Item> result;
                    try {
                        result = expr.eval(null, DynamicContext.DUMMY);
                    } catch (XQueryException e) {
                        throw new IllegalStateException(e);
                    }
                    colpath = result.toString();
                } else {
View Full Code Here

        } else {
            argv = new ValueSequence(dynEnv);
            FunctionSignature sign = func.getFunctionSignature(arity);
            for(int i = 0; i < arity; i++) {
                XQExpression p = _params.get(i);
                Sequence seq = p.eval(contextSeq, dynEnv);
                Sequence converted = mapFunctionArgument(seq, sign.getArgumentType(i), dynEnv);
                argv.addItem(SingleCollection.wrap(converted, dynEnv));
            }
        }
        return func.eval(contextSeq, argv, dynEnv);
View Full Code Here

        Module mod = parser.parse();
        // static analysis
        mod.staticAnalysis(sc);
        // evaluate
        XQExpression body = mod.getExpression();
        Sequence res = body.eval(ValueSequence.EMPTY_SEQUENCE, dynEnv);
        return res;
    }

}
View Full Code Here

                            final String colpath;
                            if(params.isEmpty()) {
                                colpath = "/";
                            } else {
                                XQExpression argExpr = params.get(0);
                                colpath = argExpr.eval(null, DynamicContext.DUMMY).toString();
                            }
                            MapExpr mapExpr = new MapExpr(colpath, bindingVar, flwrExpr);
                            return mapExpr.staticAnalysis(statEnv);
                        }
                    }
View Full Code Here

                            final String colpath;
                            if(params.isEmpty()) {
                                colpath = "/";
                            } else {
                                XQExpression argExpr = params.get(0);
                                colpath = argExpr.eval(null, DynamicContext.DUMMY).toString();
                            }

                            FLWRExpr newFlwr = new FLWRExpr();
                            ForVariable forVar = new ForVariable();
                            forVar.setValue(funcall);
View Full Code Here

            final CaseVariable cv = cc.getVariable();
            final Type ccType = cv.getType();
            if(TypeUtil.instanceOf(opr, ccType)) {
                cv.allocateResult(opr, dynEnv);
                final XQExpression ccExpr = cc.getReturnExpr();
                return ccExpr.eval(contextSeq, dynEnv);
            }
        }
        throw new IllegalStateException("Typeswitch abnormally failed");
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.