You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by vi...@apache.org on 2011/08/23 04:22:12 UTC
svn commit: r1160524 - in
/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery:
compiler/expression/ compiler/rewriter/rules/ compiler/rewriter/rulesets/
functions/ types/ xmlquery/query/
Author: vinayakb
Date: Tue Aug 23 02:22:12 2011
New Revision: 1160524
URL: http://svn.apache.org/viewvc?rev=1160524&view=rev
Log:
Added rules to optimize type-coersion and fn:data. Made type inferencing more precise.
Added:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateFnData.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateUselessTypeCoersionExpressions.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/LoggingRewriteRule.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceWithSpecificOperators.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/LoggingRulesetProviderImpl.java
Modified:
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/DefaultRulesetProviderImpl.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/QuantifiedType.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/Quantifier.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/TypeOperations.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java
incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTranslator.java
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java Tue Aug 23 02:22:12 2011
@@ -19,6 +19,12 @@ public class ExpressionPrinter {
e.accept(new PrettyPrinter(buffer, level));
}
+ public static String prettyPrint(Expression e) {
+ StringBuilder buffer = new StringBuilder();
+ prettyPrint(e, 0, buffer);
+ return buffer.toString();
+ }
+
private static final class PrettyPrinter implements ExpressionVisitor<Void> {
private StringBuilder buffer;
private int level;
@@ -188,8 +194,8 @@ public class ExpressionPrinter {
@Override
public Void visitFunctionCallExpression(FunctionCallExpression expr) {
indent(level);
- buffer.append("fn [").append(expr.getFunction().getName()).append('/').append(
- expr.getFunction().getSignature().getArity()).append("] [");
+ buffer.append("fn [").append(expr.getFunction().getName()).append('/')
+ .append(expr.getFunction().getSignature().getArity()).append("] [");
for (ExpressionHandle arg : expr.getArguments()) {
buffer.append("\n");
print(arg);
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java Tue Aug 23 02:22:12 2011
@@ -48,6 +48,10 @@ public class FunctionCallExpression exte
return function;
}
+ public void setFunction(Function function) {
+ this.function = function;
+ }
+
@Override
public <T> T accept(ExpressionVisitor<T> visitor) {
return visitor.visitFunctionCallExpression(this);
Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateFnData.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateFnData.java?rev=1160524&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateFnData.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateFnData.java Tue Aug 23 02:22:12 2011
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.compiler.rewriter.rules;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.vxquery.compiler.expression.ExprTag;
+import org.apache.vxquery.compiler.expression.Expression;
+import org.apache.vxquery.compiler.expression.ExpressionHandle;
+import org.apache.vxquery.compiler.expression.ExpressionPrinter;
+import org.apache.vxquery.compiler.expression.FunctionCallExpression;
+import org.apache.vxquery.compiler.rewriter.framework.AbstractRewriteRule;
+import org.apache.vxquery.compiler.tools.ExpressionUtils;
+import org.apache.vxquery.functions.BuiltinFunctions;
+import org.apache.vxquery.types.BuiltinTypeRegistry;
+import org.apache.vxquery.types.Quantifier;
+import org.apache.vxquery.types.TypeOperations;
+import org.apache.vxquery.types.XQType;
+
+public class EliminateFnData extends AbstractRewriteRule {
+ private static final Logger LOGGER = Logger.getLogger(EliminateFnData.class.getName());
+
+ public EliminateFnData(int minOptimizationLevel) {
+ super(minOptimizationLevel);
+ }
+
+ public boolean rewritePost(ExpressionHandle exprHandle) {
+ Expression expr = exprHandle.get();
+ if (expr.getTag() == ExprTag.FUNCTION) {
+ FunctionCallExpression fce = (FunctionCallExpression) expr;
+ if (BuiltinFunctions.FN_DATA_QNAME.equals(fce.getFunction().getName())) {
+ ExpressionHandle arg = fce.getArguments().get(0);
+ XQType inType = arg.accept(ExpressionUtils.createTypeInferringVisitor());
+ boolean dataRemovable = TypeOperations.isSubtypeOf(inType,
+ TypeOperations.quantified(BuiltinTypeRegistry.XS_ANY_ATOMIC, Quantifier.QUANT_STAR));
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.fine("Found fn:data()");
+ LOGGER.fine(ExpressionPrinter.prettyPrint(fce));
+ LOGGER.fine("Input type: " + inType);
+ LOGGER.fine("subtype(anyAtomicType*): " + dataRemovable);
+ }
+ if (dataRemovable) {
+ exprHandle.set(arg.get());
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateUselessTypeCoersionExpressions.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateUselessTypeCoersionExpressions.java?rev=1160524&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateUselessTypeCoersionExpressions.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateUselessTypeCoersionExpressions.java Tue Aug 23 02:22:12 2011
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.compiler.rewriter.rules;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.vxquery.compiler.expression.ExprTag;
+import org.apache.vxquery.compiler.expression.Expression;
+import org.apache.vxquery.compiler.expression.ExpressionHandle;
+import org.apache.vxquery.compiler.expression.ExpressionPrinter;
+import org.apache.vxquery.compiler.expression.PromoteExpression;
+import org.apache.vxquery.compiler.expression.TreatExpression;
+import org.apache.vxquery.compiler.rewriter.framework.AbstractRewriteRule;
+import org.apache.vxquery.compiler.tools.ExpressionUtils;
+import org.apache.vxquery.types.TypeOperations;
+import org.apache.vxquery.types.XQType;
+
+public class EliminateUselessTypeCoersionExpressions extends AbstractRewriteRule {
+ private static final Logger LOGGER = Logger.getLogger(EliminateUselessTypeCoersionExpressions.class.getName());
+
+ public EliminateUselessTypeCoersionExpressions(int minOptimizationLevel) {
+ super(minOptimizationLevel);
+ }
+
+ public boolean rewritePost(ExpressionHandle exprHandle) {
+ Expression expr = exprHandle.get();
+ if (expr.getTag() == ExprTag.TREAT) {
+ TreatExpression te = (TreatExpression) expr;
+ XQType eType = te.getInput().accept(ExpressionUtils.createTypeInferringVisitor());
+ XQType rType = te.getType().toXQType();
+ boolean subtype = TypeOperations.isSubtypeOf(eType, rType);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.fine("Found TREAT expression");
+ LOGGER.fine(ExpressionPrinter.prettyPrint(te));
+ LOGGER.fine("Input type: " + eType);
+ LOGGER.fine("Required type: " + rType);
+ LOGGER.fine("isSubtypeOf(eType, rType): " + subtype);
+ }
+ if (subtype) {
+ exprHandle.set(te.getInput().get());
+ return true;
+ }
+ } else if (expr.getTag() == ExprTag.PROMOTE) {
+ PromoteExpression pe = (PromoteExpression) expr;
+ XQType eType = pe.getInput().accept(ExpressionUtils.createTypeInferringVisitor());
+ XQType rType = pe.getType().toXQType();
+ boolean subtype = TypeOperations.isSubtypeOf(eType, rType);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.fine("Found PROMOTE expression");
+ LOGGER.fine(ExpressionPrinter.prettyPrint(pe));
+ LOGGER.fine("Input type: " + eType);
+ LOGGER.fine("Required type: " + rType);
+ LOGGER.fine("isSubtypeOf(eType, rType): " + subtype);
+ }
+ if (subtype) {
+ exprHandle.set(pe.getInput().get());
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/LoggingRewriteRule.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/LoggingRewriteRule.java?rev=1160524&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/LoggingRewriteRule.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/LoggingRewriteRule.java Tue Aug 23 02:22:12 2011
@@ -0,0 +1,39 @@
+package org.apache.vxquery.compiler.rewriter.rules;
+
+import org.apache.vxquery.compiler.expression.ExpressionHandle;
+import org.apache.vxquery.compiler.expression.ExpressionPrinter;
+import org.apache.vxquery.compiler.rewriter.framework.RewriteRule;
+import org.apache.vxquery.xmlquery.query.XMLQueryOptimizer;
+
+public class LoggingRewriteRule implements RewriteRule {
+ private final RewriteRule delegate;
+
+ public LoggingRewriteRule(RewriteRule delagate) {
+ this.delegate = delagate;
+ }
+
+ @Override
+ public int getMinOptimizationLevel() {
+ return delegate.getMinOptimizationLevel();
+ }
+
+ @Override
+ public boolean rewritePre(ExpressionHandle exprHandle) {
+ boolean result = delegate.rewritePre(exprHandle);
+ if (result) {
+ XMLQueryOptimizer.LOGGER.fine(delegate.getClass().getName() + ".rewritePre() SUCCEEDED");
+ XMLQueryOptimizer.LOGGER.fine(ExpressionPrinter.prettyPrint(exprHandle.get()));
+ }
+ return result;
+ }
+
+ @Override
+ public boolean rewritePost(ExpressionHandle exprHandle) {
+ boolean result = delegate.rewritePost(exprHandle);
+ if (result) {
+ XMLQueryOptimizer.LOGGER.fine(delegate.getClass().getName() + ".rewritePost() SUCCEEDED");
+ XMLQueryOptimizer.LOGGER.fine(ExpressionPrinter.prettyPrint(exprHandle.get()));
+ }
+ return result;
+ }
+}
\ No newline at end of file
Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceWithSpecificOperators.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceWithSpecificOperators.java?rev=1160524&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceWithSpecificOperators.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceWithSpecificOperators.java Tue Aug 23 02:22:12 2011
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.vxquery.compiler.rewriter.rules;
+
+import java.util.logging.Logger;
+
+import org.apache.vxquery.compiler.expression.ExprTag;
+import org.apache.vxquery.compiler.expression.Expression;
+import org.apache.vxquery.compiler.expression.ExpressionHandle;
+import org.apache.vxquery.compiler.expression.FunctionCallExpression;
+import org.apache.vxquery.compiler.rewriter.framework.AbstractRewriteRule;
+import org.apache.vxquery.compiler.tools.ExpressionUtils;
+import org.apache.vxquery.functions.BuiltinOperators;
+import org.apache.vxquery.types.Quantifier;
+import org.apache.vxquery.types.TypeOperations;
+import org.apache.vxquery.types.XQType;
+
+public class ReplaceWithSpecificOperators extends AbstractRewriteRule {
+ private static final Logger LOGGER = Logger.getLogger(ReplaceWithSpecificOperators.class.getName());
+
+ public ReplaceWithSpecificOperators(int minOptimizationLevel) {
+ super(minOptimizationLevel);
+ }
+
+ public boolean rewritePost(ExpressionHandle exprHandle) {
+ Expression expr = exprHandle.get();
+ if (expr.getTag() == ExprTag.FUNCTION) {
+ FunctionCallExpression fce = (FunctionCallExpression) expr;
+ if (BuiltinOperators.IDIV_QNAME.equals(fce.getFunction().getName())) {
+ ExpressionHandle arg1 = fce.getArguments().get(0);
+ ExpressionHandle arg2 = fce.getArguments().get(1);
+
+ XQType inType1 = arg1.accept(ExpressionUtils.createTypeInferringVisitor());
+ XQType inType2 = arg2.accept(ExpressionUtils.createTypeInferringVisitor());
+
+ Quantifier inQ1 = TypeOperations.quantifier(inType1);
+ Quantifier inQ2 = TypeOperations.quantifier(inType2);
+
+ if (inQ1 == Quantifier.QUANT_ONE && inQ2 == Quantifier.QUANT_ONE) {
+ fce.setFunction(BuiltinOperators.NUMERIC_INTEGER_DIVIDE);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/DefaultRulesetProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/DefaultRulesetProviderImpl.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/DefaultRulesetProviderImpl.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/DefaultRulesetProviderImpl.java Tue Aug 23 02:22:12 2011
@@ -20,9 +20,12 @@ import java.util.List;
import org.apache.vxquery.compiler.rewriter.framework.RewriteRule;
import org.apache.vxquery.compiler.rewriter.framework.RulesetProvider;
+import org.apache.vxquery.compiler.rewriter.rules.EliminateFnData;
import org.apache.vxquery.compiler.rewriter.rules.EliminateIfThenElseDeadCode;
import org.apache.vxquery.compiler.rewriter.rules.EliminateUnusedLetVariables;
+import org.apache.vxquery.compiler.rewriter.rules.EliminateUselessTypeCoersionExpressions;
import org.apache.vxquery.compiler.rewriter.rules.EvaluateInvariantInstanceofExpressions;
+import org.apache.vxquery.compiler.rewriter.rules.ReplaceWithSpecificOperators;
public class DefaultRulesetProviderImpl implements RulesetProvider {
public static final RulesetProvider INSTANCE = new DefaultRulesetProviderImpl();
@@ -33,6 +36,9 @@ public class DefaultRulesetProviderImpl
List<RewriteRule> temp = new ArrayList<RewriteRule>();
temp.add(new EliminateUnusedLetVariables(1));
temp.add(new EvaluateInvariantInstanceofExpressions(1));
+ temp.add(new EliminateUselessTypeCoersionExpressions(1));
+ temp.add(new ReplaceWithSpecificOperators(1));
+ temp.add(new EliminateFnData(1));
temp.add(new EliminateIfThenElseDeadCode(1));
rules = Collections.unmodifiableList(temp);
Added: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/LoggingRulesetProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/LoggingRulesetProviderImpl.java?rev=1160524&view=auto
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/LoggingRulesetProviderImpl.java (added)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/LoggingRulesetProviderImpl.java Tue Aug 23 02:22:12 2011
@@ -0,0 +1,25 @@
+package org.apache.vxquery.compiler.rewriter.rulesets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.vxquery.compiler.rewriter.framework.RewriteRule;
+import org.apache.vxquery.compiler.rewriter.framework.RulesetProvider;
+import org.apache.vxquery.compiler.rewriter.rules.LoggingRewriteRule;
+
+public class LoggingRulesetProviderImpl implements RulesetProvider {
+ private final RulesetProvider delegate;
+
+ public LoggingRulesetProviderImpl(RulesetProvider delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public List<RewriteRule> createRuleset() {
+ List<RewriteRule> loggingRules = new ArrayList<RewriteRule>();
+ for (RewriteRule rule : delegate.createRuleset()) {
+ loggingRules.add(new LoggingRewriteRule(rule));
+ }
+ return loggingRules;
+ }
+}
\ No newline at end of file
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-operators.xml Tue Aug 23 02:22:12 2011
@@ -329,6 +329,7 @@
<param name="arg1" type="xsext:numeric"/>
<param name="arg2" type="xsext:numeric"/>
<return type="xs:integer"/>
+ <runtime class="org.apache.vxquery.runtime.functions.IntegerDivideArithmeticOperationIterator"/>
</operator>
<!-- op:numeric-less-than( $arg1 as numeric, $arg2 as numeric) as xs:boolean -->
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/QuantifiedType.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/QuantifiedType.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/QuantifiedType.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/QuantifiedType.java Tue Aug 23 02:22:12 2011
@@ -89,4 +89,9 @@ public class QuantifiedType implements X
}
return NotCastableCastProcessor.INSTANCE_XPST0051;
}
+
+ @Override
+ public String toString() {
+ return "QuantifiedType[" + contentType + ":" + quantifier + "]";
+ }
}
\ No newline at end of file
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/Quantifier.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/Quantifier.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/Quantifier.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/Quantifier.java Tue Aug 23 02:22:12 2011
@@ -17,7 +17,11 @@
package org.apache.vxquery.types;
public enum Quantifier {
- QUANT_ZERO, QUANT_ONE, QUANT_QUESTION, QUANT_STAR, QUANT_PLUS;
+ QUANT_ZERO,
+ QUANT_ONE,
+ QUANT_QUESTION,
+ QUANT_STAR,
+ QUANT_PLUS;
private static final Quantifier[][] QPRODUCT = { { QUANT_ZERO, QUANT_ZERO, QUANT_ZERO, QUANT_ZERO, QUANT_ZERO },
{ QUANT_ZERO, QUANT_ONE, QUANT_QUESTION, QUANT_STAR, QUANT_PLUS },
@@ -29,6 +33,69 @@ public enum Quantifier {
return QPRODUCT[quant1.ordinal()][quant2.ordinal()];
}
+ public boolean isSubQuantifier(Quantifier subQuant) {
+ switch (this) {
+ case QUANT_ONE:
+ switch (subQuant) {
+ case QUANT_ONE:
+ return true;
+
+ case QUANT_PLUS:
+ case QUANT_QUESTION:
+ case QUANT_STAR:
+ case QUANT_ZERO:
+ return false;
+ }
+
+ case QUANT_PLUS:
+ switch (subQuant) {
+ case QUANT_ONE:
+ case QUANT_PLUS:
+ return true;
+
+ case QUANT_QUESTION:
+ case QUANT_STAR:
+ case QUANT_ZERO:
+ return false;
+ }
+
+ case QUANT_QUESTION:
+ switch (subQuant) {
+ case QUANT_ONE:
+ case QUANT_QUESTION:
+ return true;
+
+ case QUANT_PLUS:
+ case QUANT_STAR:
+ case QUANT_ZERO:
+ return false;
+ }
+
+ case QUANT_STAR:
+ switch (subQuant) {
+ case QUANT_ONE:
+ case QUANT_QUESTION:
+ case QUANT_PLUS:
+ case QUANT_STAR:
+ case QUANT_ZERO:
+ return true;
+ }
+
+ case QUANT_ZERO:
+ switch (subQuant) {
+ case QUANT_ZERO:
+ return true;
+
+ case QUANT_ONE:
+ case QUANT_QUESTION:
+ case QUANT_PLUS:
+ case QUANT_STAR:
+ return false;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+
public boolean allowsEmptySequence() {
return this == QUANT_QUESTION || this == QUANT_STAR || this == QUANT_ZERO;
}
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/TypeOperations.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/TypeOperations.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/TypeOperations.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/types/TypeOperations.java Tue Aug 23 02:22:12 2011
@@ -18,10 +18,20 @@ import java.util.Arrays;
public class TypeOperations {
public static Quantifier quantifier(XQType type) {
+ if (type instanceof QuantifiedType) {
+ return ((QuantifiedType) type).getQuantifier();
+ } else if (type instanceof ItemType) {
+ return Quantifier.QUANT_ONE;
+ }
return Quantifier.QUANT_STAR;
}
public static XQType primeType(XQType type) {
+ if (type instanceof QuantifiedType) {
+ return ((QuantifiedType) type).getContentType();
+ } else if (type instanceof ItemType) {
+ return type;
+ }
return AnyItemType.INSTANCE;
}
@@ -56,7 +66,21 @@ public class TypeOperations {
}
temp = temp.getBaseType();
}
+ return false;
+ } else if (supertype instanceof AnyItemType && subtype instanceof ItemType) {
+ return true;
+ } else if (subtype instanceof QuantifiedType || supertype instanceof QuantifiedType) {
+ XQType pSubType = primeType(subtype);
+ XQType pSupType = primeType(supertype);
+ Quantifier subQuant = quantifier(subtype);
+ Quantifier supQuant = quantifier(supertype);
+
+ boolean isSubtype = isSubtypeOf(pSubType, pSupType);
+ if (isSubtype) {
+ return supQuant.isSubQuantifier(subQuant);
+ }
}
+
return false;
}
}
\ No newline at end of file
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java Tue Aug 23 02:22:12 2011
@@ -19,8 +19,8 @@ import org.apache.vxquery.exceptions.Sys
import org.apache.vxquery.xmlquery.ast.ModuleNode;
public class XMLQueryCompiler {
- public static Module compile(ModuleNode moduleNode, CompilerControlBlock ccb, int optimizationLevel)
- throws SystemException {
+ public static Module compile(ModuleNode moduleNode, CompilerControlBlock ccb, int optimizationLevel,
+ boolean debugOptimizer) throws SystemException {
return compile(NoopXQueryCompilationListener.INSTANCE, moduleNode, ccb, optimizationLevel);
}
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java Tue Aug 23 02:22:12 2011
@@ -15,15 +15,21 @@
package org.apache.vxquery.xmlquery.query;
import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.vxquery.compiler.expression.ExpressionHandle;
import org.apache.vxquery.compiler.rewriter.framework.RulesetDriver;
+import org.apache.vxquery.compiler.rewriter.framework.RulesetProvider;
import org.apache.vxquery.compiler.rewriter.rulesets.DefaultRulesetProviderImpl;
+import org.apache.vxquery.compiler.rewriter.rulesets.LoggingRulesetProviderImpl;
import org.apache.vxquery.context.StaticContext;
import org.apache.vxquery.functions.Function;
import org.apache.vxquery.functions.UserDefinedXQueryFunction;
-final class XMLQueryOptimizer {
+public final class XMLQueryOptimizer {
+ public static final Logger LOGGER = Logger.getLogger(XMLQueryOptimizer.class.getName());
+
static void optimize(Module module, int optimizationLevel) {
StaticContext sCtx = module.getModuleContext();
for (Iterator<Function> i = sCtx.listFunctions(); i.hasNext();) {
@@ -40,6 +46,10 @@ final class XMLQueryOptimizer {
private static void optimize(ExpressionHandle handle, int optimizationLevel) {
RulesetDriver rd = new RulesetDriver();
- rd.rewrite(handle, DefaultRulesetProviderImpl.INSTANCE.createRuleset(), optimizationLevel);
+ RulesetProvider provider = DefaultRulesetProviderImpl.INSTANCE;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ provider = new LoggingRulesetProviderImpl(provider);
+ }
+ rd.rewrite(handle, provider.createRuleset(), optimizationLevel);
}
}
\ No newline at end of file
Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTranslator.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTranslator.java?rev=1160524&r1=1160523&r2=1160524&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTranslator.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTranslator.java Tue Aug 23 02:22:12 2011
@@ -54,8 +54,8 @@ import org.apache.vxquery.compiler.expre
import org.apache.vxquery.compiler.expression.TypeswitchExpression;
import org.apache.vxquery.compiler.expression.ValidateExpression;
import org.apache.vxquery.compiler.expression.Variable;
-import org.apache.vxquery.compiler.expression.VariableReferenceExpression;
import org.apache.vxquery.compiler.expression.Variable.VarTag;
+import org.apache.vxquery.compiler.expression.VariableReferenceExpression;
import org.apache.vxquery.context.StaticContext;
import org.apache.vxquery.context.StaticContextImpl;
import org.apache.vxquery.context.ThinStaticContextImpl;
@@ -129,6 +129,7 @@ import org.apache.vxquery.xmlquery.ast.F
import org.apache.vxquery.xmlquery.ast.FunctionExprNode;
import org.apache.vxquery.xmlquery.ast.IfExprNode;
import org.apache.vxquery.xmlquery.ast.InfixExprNode;
+import org.apache.vxquery.xmlquery.ast.InfixExprNode.InfixOperator;
import org.apache.vxquery.xmlquery.ast.LetClauseNode;
import org.apache.vxquery.xmlquery.ast.LetVarDeclNode;
import org.apache.vxquery.xmlquery.ast.LibraryModuleNode;
@@ -167,7 +168,6 @@ import org.apache.vxquery.xmlquery.ast.V
import org.apache.vxquery.xmlquery.ast.VarRefNode;
import org.apache.vxquery.xmlquery.ast.VersionDeclNode;
import org.apache.vxquery.xmlquery.ast.WhereClauseNode;
-import org.apache.vxquery.xmlquery.ast.InfixExprNode.InfixOperator;
import org.apache.vxquery.xmlquery.query.XQueryConstants.PathType;
import org.apache.vxquery.xmlquery.query.XQueryConstants.TypeQuantifier;
@@ -718,8 +718,11 @@ final class XMLQueryTranslator {
}
Expression e = translateExpression(ueNode.getExpr());
if (neg) {
- e = ExpressionBuilder.functionCall(currCtx, BuiltinOperators.NUMERIC_UNARY_MINUS, normalize(
- currCtx, e, BuiltinOperators.NUMERIC_UNARY_MINUS.getSignature().getParameterType(0)));
+ e = ExpressionBuilder.functionCall(
+ currCtx,
+ BuiltinOperators.NUMERIC_UNARY_MINUS,
+ normalize(currCtx, e,
+ BuiltinOperators.NUMERIC_UNARY_MINUS.getSignature().getParameterType(0)));
}
return e;
}
@@ -761,8 +764,8 @@ final class XMLQueryTranslator {
if (!type.isAtomicType()) {
throw new SystemException(ErrorCode.XPST0051, fnNode.getName().getSourceLocation());
}
- Expression arg = args.isEmpty() ? new VariableReferenceExpression(currCtx, varScope
- .lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME)) : args.get(0);
+ Expression arg = args.isEmpty() ? new VariableReferenceExpression(currCtx,
+ varScope.lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME)) : args.get(0);
return new CastExpression(currCtx, arg, SequenceType.create((ItemType) type,
Quantifier.QUANT_QUESTION));
}
@@ -780,8 +783,7 @@ final class XMLQueryTranslator {
if (fn != null && fn.useContextImplicitly()) {
args.add(new VariableReferenceExpression(currCtx, varScope
.lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME)));
- nArgs = fnNode.getArguments().size();
- fn = moduleCtx.lookupFunction(fName, nArgs);
+ fn = moduleCtx.lookupFunction(fName, nArgs + 1);
}
if (fn == null) {
Function[] fns = moduleCtx.lookupFunctions(fName);
@@ -878,17 +880,16 @@ final class XMLQueryTranslator {
DirectPIConstructorNode dpicNode = (DirectPIConstructorNode) value;
String target = dpicNode.getTarget();
String content = dpicNode.getContent();
- return new PINodeConstructorExpression(currCtx,
- new ConstantExpression(currCtx, avf.createString(target), SequenceType.create(
- BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)), new ConstantExpression(currCtx,
- avf.createString(content), SequenceType.create(BuiltinTypeRegistry.XS_STRING,
- Quantifier.QUANT_ONE)));
+ return new PINodeConstructorExpression(currCtx, new ConstantExpression(currCtx,
+ avf.createString(target), SequenceType.create(BuiltinTypeRegistry.XS_STRING,
+ Quantifier.QUANT_ONE)), new ConstantExpression(currCtx, avf.createString(content),
+ SequenceType.create(BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)));
}
case DIRECT_COMMENT_CONSTRUCTOR:
- return new CommentNodeConstructorExpression(currCtx, new ConstantExpression(currCtx, avf
- .createString(((DirectCommentConstructorNode) value).getContent()), SequenceType.create(
- BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)));
+ return new CommentNodeConstructorExpression(currCtx, new ConstantExpression(currCtx,
+ avf.createString(((DirectCommentConstructorNode) value).getContent()), SequenceType.create(
+ BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)));
case DIRECT_ELEMENT_CONSTRUCTOR: {
DirectElementConstructorNode decNode = (DirectElementConstructorNode) value;
@@ -908,8 +909,8 @@ final class XMLQueryTranslator {
throw new SystemException(ErrorCode.XQST0022, acNode.getSourceLocation());
}
- currCtx.registerNamespaceUri(aName.getLocalName(), unquote(((ContentCharsNode) values.get(0))
- .getContent()));
+ currCtx.registerNamespaceUri(aName.getLocalName(),
+ unquote(((ContentCharsNode) values.get(0)).getContent()));
}
}
List<Expression> content = new ArrayList<Expression>();
@@ -919,8 +920,8 @@ final class XMLQueryTranslator {
content.add(translateExpression(acNode));
}
}
- Expression name = new ConstantExpression(currCtx, avf.createQName(createQName(startName, moduleCtx
- .getDefaultElementNamespaceUri())), SequenceType.create(BuiltinTypeRegistry.XS_QNAME,
+ Expression name = new ConstantExpression(currCtx, avf.createQName(createQName(startName,
+ moduleCtx.getDefaultElementNamespaceUri())), SequenceType.create(BuiltinTypeRegistry.XS_QNAME,
Quantifier.QUANT_ONE));
for (ASTNode cVal : decNode.getContent()) {
switch (cVal.getTag()) {
@@ -957,14 +958,14 @@ final class XMLQueryTranslator {
}
}
Expression content = attrContent.size() == 1 ? attrContent.get(0) : createConcatenation(attrContent);
- return new AttributeNodeConstructorExpression(currCtx, new ConstantExpression(currCtx, avf
- .createQName(aQName), SequenceType.create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE)),
- content);
+ return new AttributeNodeConstructorExpression(currCtx, new ConstantExpression(currCtx,
+ avf.createQName(aQName),
+ SequenceType.create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE)), content);
}
case CONTEXT_ITEM:
- return new VariableReferenceExpression(currCtx, varScope
- .lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME));
+ return new VariableReferenceExpression(currCtx,
+ varScope.lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME));
case IF_EXPRESSION: {
IfExprNode ieNode = (IfExprNode) value;
@@ -982,8 +983,8 @@ final class XMLQueryTranslator {
if (var == null) {
throw new SystemException(ErrorCode.XPST0008, vrNode.getSourceLocation());
}
- return new TreatExpression(currCtx, new VariableReferenceExpression(currCtx, var), var
- .getDeclaredStaticType());
+ return new TreatExpression(currCtx, new VariableReferenceExpression(currCtx, var),
+ var.getDeclaredStaticType());
}
case FLWOR_EXPRESSION: {
@@ -1185,8 +1186,8 @@ final class XMLQueryTranslator {
case COMPUTED_ELEMENT_CONSTRUCTOR: {
ComputedElementConstructorNode cNode = (ComputedElementConstructorNode) value;
- Expression eName = new CastExpression(currCtx, translateExpression(cNode.getName()), SequenceType
- .create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE));
+ Expression eName = new CastExpression(currCtx, translateExpression(cNode.getName()),
+ SequenceType.create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE));
Expression content = cNode.getContent() == null ? ExpressionBuilder.functionCall(currCtx,
BuiltinOperators.CONCATENATE) : translateExpression(cNode.getContent());
return new ElementNodeConstructorExpression(currCtx, eName, content);
@@ -1194,25 +1195,25 @@ final class XMLQueryTranslator {
case COMPUTED_ATTRIBUTE_CONSTRUCTOR: {
ComputedAttributeConstructorNode cNode = (ComputedAttributeConstructorNode) value;
- Expression aName = new CastExpression(currCtx, translateExpression(cNode.getName()), SequenceType
- .create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE));
+ Expression aName = new CastExpression(currCtx, translateExpression(cNode.getName()),
+ SequenceType.create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE));
Expression content = cNode.getContent() == null ? ExpressionBuilder.functionCall(currCtx,
BuiltinOperators.CONCATENATE) : translateExpression(cNode.getContent());
return new AttributeNodeConstructorExpression(currCtx, aName, content);
}
case QNAME:
- return new ConstantExpression(currCtx, avf.createQName(createQName((QNameNode) value)), SequenceType
- .create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE));
+ return new ConstantExpression(currCtx, avf.createQName(createQName((QNameNode) value)),
+ SequenceType.create(BuiltinTypeRegistry.XS_QNAME, Quantifier.QUANT_ONE));
case NCNAME:
- return new ConstantExpression(currCtx, avf.createString(((NCNameNode) value).getName()), SequenceType
- .create(BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE));
+ return new ConstantExpression(currCtx, avf.createString(((NCNameNode) value).getName()),
+ SequenceType.create(BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE));
case CDATA_SECTION:
- return new TextNodeConstructorExpression(currCtx, new ConstantExpression(currCtx, avf
- .createString(((CDataSectionNode) value).getContent()), SequenceType.create(
- BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)));
+ return new TextNodeConstructorExpression(currCtx, new ConstantExpression(currCtx,
+ avf.createString(((CDataSectionNode) value).getContent()), SequenceType.create(
+ BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)));
case ORDERED_EXPRESSION:
return ExpressionBuilder.functionCall(currCtx, BuiltinOperators.ORDERED,
@@ -1344,8 +1345,8 @@ final class XMLQueryTranslator {
predicates = axisNode.getPredicates();
AxisStepNode.Axis axis = axisNode.getAxis();
if (ctxExpr == null) {
- ctxExpr = new VariableReferenceExpression(currCtx, varScope
- .lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME));
+ ctxExpr = new VariableReferenceExpression(currCtx,
+ varScope.lookupVariable(XMLQueryCompilerConstants.DOT_VAR_NAME));
}
AxisKind axisKind = translateAxis(axis);
@@ -1492,14 +1493,16 @@ final class XMLQueryTranslator {
Expression typeTest = ExpressionBuilder.instanceOf(currCtx, new VariableReferenceExpression(currCtx, pVar),
SequenceType.create(BuiltinTypeRegistry.XSEXT_NUMERIC, Quantifier.QUANT_ONE));
- Expression posTest = ExpressionBuilder.functionCall(currCtx, BuiltinOperators.VALUE_EQ,
- new VariableReferenceExpression(currCtx, pVar), new VariableReferenceExpression(currCtx, varScope
+ Expression posTest = ExpressionBuilder.functionCall(
+ currCtx,
+ BuiltinOperators.VALUE_EQ,
+ new VariableReferenceExpression(currCtx, pVar),
+ new VariableReferenceExpression(currCtx, varScope
.lookupVariable(XMLQueryCompilerConstants.POS_VAR_NAME)));
Expression boolTest = ExpressionBuilder.functionCall(currCtx, BuiltinFunctions.FN_BOOLEAN_1,
new VariableReferenceExpression(currCtx, pVar));
- clauses
- .add(new FLWORExpression.WhereClause(new IfThenElseExpression(currCtx, typeTest, posTest, boolTest)));
+ clauses.add(new FLWORExpression.WhereClause(new IfThenElseExpression(currCtx, typeTest, posTest, boolTest)));
innerFLWOR.getReturnExpression().set(
new VariableReferenceExpression(currCtx, varScope