Examples of UserFunction


Examples of org.pdf4j.saxon.instruct.UserFunction

    public Item evaluateItem(XPathContext context) throws XPathException {
        final XPathContextMajor cm = (XPathContextMajor)context;
        while (true) {
            Item item = operand.evaluateItem(context);
            UserFunction fn = cm.getTailCallFunction();
            if (fn == null) {
               return item;
            }
            if (fn != containingFunction) {
                return Value.asItem(tailCallDifferentFunction(fn, cm));
View Full Code Here

Examples of org.pdf4j.saxon.instruct.UserFunction

    public void process(XPathContext context) throws XPathException {
        final XPathContextMajor cm = (XPathContextMajor)context;
        while (true) {
            operand.process(context);
            UserFunction fn = cm.getTailCallFunction();
            if (fn == null) {
                return;
            }
            if (fn != containingFunction) {
                Value.asValue(tailCallDifferentFunction(fn, cm)).process(cm);
View Full Code Here

Examples of org.pdf4j.saxon.instruct.UserFunction

        presenter.startElement("functions");
        for (int i=0; i<libraryList.size(); i++) {
            FunctionLibrary lib = (FunctionLibrary)libraryList.get(i);
            if (lib instanceof ExecutableFunctionLibrary) {
                for (Iterator f = ((ExecutableFunctionLibrary)lib).iterateFunctions(); f.hasNext();) {
                    UserFunction func = (UserFunction)f.next();
                    presenter.startElement("function");
                    presenter.emitAttribute("name", func.getFunctionName().getDisplayName());
                    presenter.emitAttribute("line", func.getLineNumber()+"");
                    presenter.emitAttribute("module", func.getSystemId());
                    func.getBody().explain(presenter);
                    presenter.endElement();
                }
            }
        }
        presenter.endElement();
View Full Code Here

Examples of org.pdf4j.saxon.instruct.UserFunction

     * the function call, but no function was found.
     */

    public Expression bind(StructuredQName functionName, Expression[] staticArgs, StaticContext env)
            throws XPathException {
        UserFunction fn = (UserFunction)functions.get(makeKey(functionName, staticArgs.length));
        if (fn == null) {
            return null;
        }
        ExpressionVisitor visitor = ExpressionVisitor.make(env);
        UserFunctionCall fc = new UserFunctionCall();
        fc.setFunctionName(functionName);
        fc.setArguments(staticArgs);
        fc.setFunction(fn);
        fc.checkFunctionCall(fn, visitor);
        fc.setStaticType(fn.getResultType(config.getTypeHierarchy()));
        return fc;
    }
View Full Code Here

Examples of org.pdf4j.saxon.instruct.UserFunction

        if (fd != null) {
            UserFunctionCall ufc = new UserFunctionCall();
            ufc.setFunctionName(fd.getFunctionName());
            ufc.setArguments(arguments);
            ufc.setStaticType(fd.getResultType());
            UserFunction fn = fd.getUserFunction();
            if (fn == null) {
                // not yet compiled
                fd.registerReference(ufc);
                ufc.setConfirmed(true);
            } else {
View Full Code Here

Examples of org.pdf4j.saxon.instruct.UserFunction

     * be objects of class {@link UserFunction}
     */

    public static void gatherCalledFunctions(Expression e, List list) {
        if (e instanceof UserFunctionCall) {
            UserFunction function = ((UserFunctionCall)e).getFunction();
            if (!list.contains(function)) {
                list.add(function);
            }
        } else {
            for (Iterator children = e.iterateSubExpressions(); children.hasNext();) {
View Full Code Here

Examples of org.pdf4j.saxon.instruct.UserFunction

                }
                finallyExp.process(context);
                break;
            }
            action.process(c2);
            UserFunction fn = c2.getTailCallFunction();
            if (fn == null) {
                // no saxon:continue or saxon:break was encountered; just loop around
            } else if (fn.getFunctionName().equals(BreakInstr.SAXON_BREAK)) {
                // indicates a saxon:break instruction was encountered: break the loop
                iter.close();
                return null;
            } else {
                // a saxon:continue instruction was encountered.
View Full Code Here

Examples of xbird.xquery.func.UserFunction

        if(f_itor.hasNext()) {
            attrFeed("function decls");
            indent++;
            do {
                lineFeed();
                UserFunction f = f_itor.next();
                f.visit(this, ctxt);
            } while(f_itor.hasNext());
            indent--;
        }

        final XQExpression body = module.getExpression();
View Full Code Here

Examples of xbird.xquery.func.UserFunction

    public static UserFunction createUserFunction(Module declaredModule, QualifiedName funcName, List<ParametricVariable> parameters, Type returnType)
            throws XQueryException {
        if(declaredModule.lookupFunction(funcName, parameters) != null) {
            throw new SyntaxError("err:XPST0017");
        }
        final UserFunction func = new UserFunction(declaredModule, funcName, parameters, returnType);
        declaredModule.declareLocalFunction(func);
        return func;
    }
View Full Code Here

Examples of xbird.xquery.func.UserFunction

        if(params.isEmpty()) {
            return body;
        } else {
            // Note that create function always generates new body expression for each call,
            // and must care about parameters reference.           
            UserFunction newuf = ObjectUtils.deepCopy(func);
            List<ParametricVariable> newParams = newuf.getParameters();
            final int psize = newParams.size();
            for(int i = 0; i < psize; i++) {
                ParametricVariable p = newParams.get(i);
                Type implicitParamType = p.getType();
                XQExpression arg = argv.get(i);
                Type argType = arg.getType();
                if(implicitParamType != Untyped.UNTYPED && !implicitParamType.accepts(argType)) {
                    // type promotion is required for arguments
                    p.setValue(new TypePromotedExpr(arg, implicitParamType));
                } else {
                    p.setValue(arg);
                }
            }
            XQExpression newbody = newuf.getBodyExpression();
            statEnv.setFunctionManager(funcMgr);
            if(LOG.isDebugEnabled()) {
                LOG.debug("Inlined the function '" + QNameUtil.toLexicalForm(newuf.getName()) + "'");
            }
            return newbody;
        }
    }
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.