| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.expr; |
| 9 | |
| 10 | import net.sf.saxon.expr.parser.ExpressionTool; |
| 11 | import net.sf.saxon.expr.parser.RebindingMap; |
| 12 | import net.sf.saxon.expr.parser.Token; |
| 13 | |
| 14 | /** |
| 15 | * The class GeneralComparison20 specializes GeneralComparison for the case where |
| 16 | * the comparison is done with 2.0 semantics (i.e. with backwards compatibility off). |
| 17 | * It differs from the superclass in that it will never turn the expression into |
| 18 | * a GeneralComparison10, which could lead to non-terminating optimizations |
| 19 | */ |
| 20 | public class GeneralComparison20 extends GeneralComparison { |
| 21 | |
| 22 | /** |
| 23 | * Create a relational expression identifying the two operands and the operator |
| 24 | * |
| 25 | * @param p0 the left-hand operand |
| 26 | * @param op the operator, as a token returned by the Tokenizer (e.g. Token.LT) |
| 27 | * @param p1 the right-hand operand |
| 28 | */ |
| 29 | public GeneralComparison20(Expression p0, int op, Expression p1) { |
| 30 | super(p0, op, p1); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Copy an expression. This makes a deep copy. |
| 35 | * |
| 36 | * @return the copy of the original expression |
| 37 | * @param rebindings |
| 38 | */ |
| 39 | |
| 40 | /*@NotNull*/ |
| 41 | public Expression copy(RebindingMap rebindings) { |
| 42 | GeneralComparison20 gc = new GeneralComparison20(getLhsExpression().copy(rebindings), operator, getRhsExpression().copy(rebindings)); |
| 43 | ExpressionTool.copyLocationInfo(this, gc); |
| 44 | gc.setRetainedStaticContext(getRetainedStaticContext()); |
| 45 | gc.comparer = comparer; |
| 46 | gc.singletonOperator = singletonOperator; |
| 47 | gc.needsRuntimeCheck = needsRuntimeCheck; |
| 48 | gc.comparisonCardinality = comparisonCardinality; |
| 49 | return gc; |
| 50 | } |
| 51 | |
| 52 | protected GeneralComparison getInverseComparison() { |
| 53 | GeneralComparison20 gc = new GeneralComparison20(getRhsExpression(), Token.inverse(operator), getLhsExpression()); |
| 54 | gc.setRetainedStaticContext(getRetainedStaticContext()); |
| 55 | return gc; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | } |
| 60 |