Package net.sf.saxon.instruct

Examples of net.sf.saxon.instruct.Block


        if (test instanceof Value) {
            // condition known statically, so we only need compile the code if true.
            // This can happen with expressions such as test="function-available('abc')".
            try {
                if (test.effectiveBooleanValue(null)) {
                    Block block = new Block();
                    block.setLocationId(allocateLocationId(getSystemId(), getLineNumber()));
                    compileChildren(exec, block, true);
                    return block.simplify(getStaticContext());
                } else {
                    return null;
                }
            } catch (XPathException err) {
                // can't happen, but if it does then we'll fall through to non-optimizing case
            }
        }

        Block b = new Block();
        b.setLocationId(allocateLocationId(getSystemId(), getLineNumber()));
        Expression action = b;
        Expression[] children = compileChildren(exec, b, true);
        if (children.length==1) {
            action = children[0];
        }
View Full Code Here


                base = new AxisExpression(Axis.DESCENDANT, NodeKindTest.makeNodeKindTest(kind));
                break;

            case Type.NODE:
                Expression allChildren = new AxisExpression(Axis.DESCENDANT, NodeKindTest.ELEMENT);
                Block block = new Block();
                Expression[] union = {new ContextItemExpression(),
                                      new AxisExpression(Axis.ATTRIBUTE, AnyNodeTest.getInstance())};
                block.setChildren(union);
                base = new PathExpression(allChildren, block);
                break;

            case Type.NAMESPACE:
               throw new UnsupportedOperationException("Patterns can't match namespace nodes");
View Full Code Here

                return Closure.make(tail, context, ref);
            }

            case SHARED_APPEND_EXPRESSION: {
                Block block = (Block)exp;
                Expression base = block.getChildren()[0];
                Value baseVal;
                if (base instanceof Literal) {
                    baseVal = ((Literal)base).getValue();
                } else if (base instanceof VariableReference) {
                    baseVal = Value.asValue(evaluate(base, EVALUATE_VARIABLE, context, ref));
                    if (baseVal instanceof MemoClosure && ((MemoClosure)baseVal).isFullyRead()) {
                        baseVal = ((MemoClosure)baseVal).materialize();
                    }
                } else {
                    throw new AssertionError("base of shared append expression is of class " + base.getClass());
                }
                if (baseVal instanceof ShareableSequence && ((ShareableSequence)baseVal).isShareable()) {
                    List list = ((ShareableSequence)baseVal).getList();
                    SequenceIterator iter = block.getChildren()[1].iterate(context);
                    while (true) {
                        Item i = iter.next();
                        if (i == null) {
                            break;
                        }
                        list.add(i);
                    }
                    return new ShareableSequence(list);
                } else {
                    List list = new ArrayList(20);
                    SequenceIterator iter = baseVal.iterate();
                    while (true) {
                        Item i = iter.next();
                        if (i == null) {
                            break;
                        }
                        list.add(i);
                    }
                    iter = block.getChildren()[1].iterate(context);
                    while (true) {
                        Item i = iter.next();
                        if (i == null) {
                            break;
                        }
View Full Code Here

        // Convert @*|node() into @*,node() to eliminate the sorted merge operation
        if (operator == Token.UNION && operand0 instanceof AxisExpression && operand1 instanceof AxisExpression) {
            AxisExpression a0 = (AxisExpression)operand0;
            AxisExpression a1 = (AxisExpression)operand1;
            if (a0.getAxis() == Axis.ATTRIBUTE && a1.getAxis() == Axis.CHILD) {
                Block b = new Block();
                b.setChildren(new Expression[]{operand0, operand1});
                return b;
            } else if (a1.getAxis() == Axis.ATTRIBUTE && a0.getAxis() == Axis.CHILD) {
                Block b = new Block();
                b.setChildren(new Expression[]{operand1, operand0});
                return b;
            }
        }
        return this;
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.instruct.Block

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.