Search in sources :

Example 1 with SequenceType

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method isInstanceOf.

private boolean isInstanceOf(ResultSequence rs, SequenceType seqt) {
    Object oldParam = this._param;
    try {
        this._param = new Pair(null, rs);
        int sequenceLength = rs.size();
        // Run the matcher
        seqt.accept(this);
        rs = (ResultSequence) ((Pair) _param)._two;
        int lengthAfter = rs.size();
        if (sequenceLength != lengthAfter)
            // Something didn't match, so it's not an instance of it
            return false;
        return seqt.isLengthValid(sequenceLength);
    } finally {
        this._param = oldParam;
    }
}
Also used : VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 2 with SequenceType

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit instance of expression
 *
 * @param ioexp
 *            is the instance of expression.
 * @return a new function
 */
public Object visit(InstOfExpr ioexp) {
    // get the value
    ResultSequence rs = (ResultSequence) ioexp.left().accept(this);
    // get the sequence type
    SequenceType seqt = (SequenceType) ioexp.right();
    return ResultSequenceFactory.create_new(new XSBoolean(isInstanceOf(rs, seqt)));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSBoolean(org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean) SequenceType(org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType)

Example 3 with SequenceType

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit treat-as expression
 *
 * @param taexp
 *            is the treat-as expression.
 * @return a new function
 */
public Object visit(TreatAsExpr taexp) {
    ResultSequence rs = (ResultSequence) taexp.left().accept(this);
    SequenceType seqt = (SequenceType) taexp.right();
    SeqType st = new SeqType(seqt, _sc, rs);
    try {
        st.match(rs);
    } catch (DynamicError err) {
        report_error(err);
    }
    return rs;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) SequenceType(org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType)

Aggregations

ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)2 SequenceType (org.eclipse.wst.xml.xpath2.processor.internal.ast.SequenceType)2 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)1 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)1 XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)1