incubator-vxquery-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Till Westmann <t...@westmann.org>
Subject Re: svn commit: r906965 [1/3] - in /incubator/vxquery/trunk/vxquery/src: main/java/org/apache/vxquery/api/ main/java/org/apache/vxquery/compiler/expression/ main/java/org/apache/vxquery/compiler/rewriter/ main/java/org/apache/vxquery/compiler/rewriter/fram...
Date Fri, 05 Feb 2010 22:40:58 GMT
Very nice, one submission and we've got an optimizer :)

It seems that we got rid of the OOM in the  XQTS with these optimizations.
Is that right?

Thanks,
Till

On Feb 5, 2010, at 4:19 PM, vinayakb@apache.org wrote:

> Author: vinayakb
> Date: Fri Feb  5 15:19:44 2010
> New Revision: 906965
> 
> URL: http://svn.apache.org/viewvc?rev=906965&view=rev
> Log:
> Added optimization.
> 
> Added:
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/MutableExpressionVisitor.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/framework/
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/framework/AbstractRewriteRule.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/framework/RewriteRule.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/framework/RulesetDriver.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/framework/RulesetProvider.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/rules/
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateIfThenElseDeadCode.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EliminateUnusedLetVariables.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/rules/EvaluateInvariantInstanceofExpressions.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/rewriter/rulesets/DefaultRulesetProviderImpl.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/tools/ExpressionTypeInferringVisitor.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/tools/FreeVariableMaintainer.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryOptimizer.java
> Modified:
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/api/InternalAPI.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/AttributeNodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastableExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CommentNodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ConstantExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/DocumentNodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementNodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementOrAttributeNodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/Expression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionHandle.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExtensionExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FLWORExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ForLetVariable.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/IfThenElseExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/InstanceofExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PINodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PathStepExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PromoteExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/QuantifiedExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TextNodeConstructorExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TreatExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TypeExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TypeswitchExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ValidateExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/VariableReferenceExpression.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/tools/ExpressionUtils.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/tools/FreeVariableFinder.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/drivers/VXQuery.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/functions/UserDefinedXQueryFunction.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/types/TypeOperations.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/Module.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/NoopXQueryCompilationListener.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCodeGenerator.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTranslator.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryTypeChecker.java
>    incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/xmlquery/query/XQueryCompilationListener.java
>    incubator/vxquery/trunk/vxquery/src/test/java/org/apache/vxquery/xmlquery/query/SimpleXQueryTest.java
>    incubator/vxquery/trunk/vxquery/src/test/java/org/apache/vxquery/xtest/TestRunnerFactory.java
>    incubator/vxquery/trunk/vxquery/src/test/java/org/apache/vxquery/xtest/XTestOptions.java
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/api/InternalAPI.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/api/InternalAPI.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/api/InternalAPI.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/api/InternalAPI.java Fri Feb  5 15:19:44 2010
> @@ -1,13 +1,11 @@
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one or more
> - * contributor license agreements.  See the NOTICE file distributed with
> + * 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
> - *
> + * 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.
> @@ -61,8 +59,9 @@
>         return XMLQueryParser.parse(name, query);
>     }
> 
> -    public Module compile(XQueryCompilationListener listener, ModuleNode ast) throws SystemException {
> -        return XMLQueryCompiler.compile(listener, ast, ccb);
> +    public Module compile(XQueryCompilationListener listener, ModuleNode ast, int optimizationLevel)
> +            throws SystemException {
> +        return XMLQueryCompiler.compile(listener, ast, ccb, optimizationLevel);
>     }
> 
>     public StaticContext getStaticContext() {
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/AttributeNodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/AttributeNodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/AttributeNodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/AttributeNodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.NodeKind;
> 
> @@ -33,4 +33,15 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitAttributeNodeConstructorExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitAttributeNodeConstructorExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new AttributeNodeConstructorExpression(ctx, name.get().copy(substitution), content.get().copy(
> +                substitution));
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.SequenceType;
> 
> @@ -33,4 +33,14 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitCastExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitCastExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new CastExpression(ctx, input.get().copy(substitution), type);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastableExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastableExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastableExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CastableExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.SequenceType;
> 
> @@ -33,4 +33,14 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitCastableExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitCastableExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new CastableExpression(ctx, input.get().copy(substitution), type);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CommentNodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CommentNodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CommentNodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/CommentNodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,30 +1,30 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.NodeKind;
> 
> public class CommentNodeConstructorExpression extends NodeConstructorExpression {
> -    private Expression content;
> +    private ExpressionHandle content;
> 
>     public CommentNodeConstructorExpression(StaticContext ctx, Expression content) {
>         super(ctx);
> -        this.content = content;
> +        this.content = new ExpressionHandle(content);
>     }
> 
>     @Override
> @@ -32,16 +32,22 @@
>         return NodeKind.COMMENT;
>     }
> 
> -    public Expression getContent() {
> +    public ExpressionHandle getContent() {
>         return content;
>     }
> 
> -    public void setContent(Expression content) {
> -        this.content = content;
> -    }
> -
>     @Override
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitCommentNodeConstructorExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitCommentNodeConstructorExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new CommentNodeConstructorExpression(ctx, content.get().copy(substitution));
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ConstantExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ConstantExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ConstantExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ConstantExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.SequenceType;
> 
> @@ -54,4 +54,14 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitConstantExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitConstantExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new ConstantExpression(ctx, value, type);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/DocumentNodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/DocumentNodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/DocumentNodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/DocumentNodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,33 +1,33 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.NodeKind;
> 
> public class DocumentNodeConstructorExpression extends NodeConstructorExpression {
> -    private Expression content;
> +    private ExpressionHandle content;
> 
>     public DocumentNodeConstructorExpression(StaticContext ctx, Expression content) {
>         super(ctx);
> -        this.content = content;
> +        this.content = new ExpressionHandle(content);
>     }
> 
> -    public Expression getContent() {
> +    public ExpressionHandle getContent() {
>         return content;
>     }
> 
> @@ -40,4 +40,14 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitDocumentNodeConstructorExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitDocumentNodeConstructorExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new DocumentNodeConstructorExpression(ctx, content.get().copy(substitution));
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementNodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementNodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementNodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementNodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.NodeKind;
> 
> @@ -33,4 +33,15 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitElementNodeConstructorExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitElementNodeConstructorExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new ElementNodeConstructorExpression(ctx, name.get().copy(substitution), content.get()
> +                .copy(substitution));
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementOrAttributeNodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementOrAttributeNodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementOrAttributeNodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ElementOrAttributeNodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,46 +1,36 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> import org.apache.vxquery.context.StaticContext;
> 
> public abstract class ElementOrAttributeNodeConstructorExpression extends NodeConstructorExpression {
> -    protected Expression name;
> -    protected Expression content;
> +    protected ExpressionHandle name;
> +    protected ExpressionHandle content;
> 
>     public ElementOrAttributeNodeConstructorExpression(StaticContext ctx, Expression name, Expression content) {
>         super(ctx);
> -        this.name = name;
> -        this.content = content;
> +        this.name = new ExpressionHandle(name);
> +        this.content = new ExpressionHandle(content);
>     }
> 
> -    public Expression getName() {
> +    public ExpressionHandle getName() {
>         return name;
>     }
> 
> -    public void setName(Expression name) {
> -        this.name = name;
> -    }
> -
> -    public Expression getContent() {
> +    public ExpressionHandle getContent() {
>         return content;
>     }
> -
> -    public void setContent(Expression content) {
> -        this.content = content;
> -    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/Expression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/Expression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/Expression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/Expression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,22 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.HashMap;
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.util.Debug;
> 
> @@ -30,10 +31,18 @@
> 
>     public abstract <T> T accept(ExpressionVisitor<T> visitor);
> 
> +    public abstract <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle);
> +
> +    public abstract Expression copy(Map<Variable, Expression> substitution);
> +
> +    public final Expression copy() {
> +        return copy(new HashMap<Variable, Expression>());
> +    }
> +
>     public final StaticContext getStaticContext() {
>         return ctx;
>     }
> -        
> +
>     public String toString(Object o) {
>         return Debug.toString(o);
>     }
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionHandle.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionHandle.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionHandle.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionHandle.java Fri Feb  5 15:19:44 2010
> @@ -1,19 +1,17 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> public final class ExpressionHandle {
> @@ -33,4 +31,12 @@
>     public void set(Expression expression) {
>         this.expression = expression;
>     }
> +
> +    public <T> T accept(ExpressionVisitor<T> visitor) {
> +        return expression.accept(visitor);
> +    }
> +
> +    public <T> T accept(MutableExpressionVisitor<T> visitor) {
> +        return expression.accept(visitor, this);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExpressionPrinter.java Fri Feb  5 15:19:44 2010
> @@ -1,19 +1,17 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> public class ExpressionPrinter {
> @@ -37,7 +35,7 @@
>             return buffer;
>         }
> 
> -        private void print(Expression e) {
> +        private void print(ExpressionHandle e) {
>             ++level;
>             e.accept(this);
>             --level;
> @@ -194,7 +192,7 @@
>                     expr.getFunction().getSignature().getArity()).append("] [");
>             for (ExpressionHandle arg : expr.getArguments()) {
>                 buffer.append("\n");
> -                print(arg.get());
> +                print(arg);
>                 buffer.append(",");
>             }
>             buffer.append("\n");
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExtensionExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExtensionExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExtensionExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ExtensionExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,22 +1,22 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.ArrayList;
> import java.util.List;
> +import java.util.Map;
> 
> import javax.xml.namespace.QName;
> 
> @@ -46,16 +46,26 @@
>         this.pragmas = pragmas;
>     }
> 
> -    public Expression getInput() {
> -        return input.get();
> -    }
> -
> -    public void setInput(Expression input) {
> -        this.input.set(input);
> +    public ExpressionHandle getInput() {
> +        return input;
>     }
> 
>     @Override
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitExtensionExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitExtensionExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        List<Pair<QName, String>> pragmasCopy = new ArrayList<Pair<QName, String>>();
> +        for (Pair<QName, String> p : pragmas) {
> +            pragmasCopy.add(new Pair<QName, String>(p.first, p.second));
> +        }
> +        return new ExtensionExpression(ctx, input.get().copy(substitution), pragmasCopy);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FLWORExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FLWORExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FLWORExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FLWORExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,24 +1,24 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> import java.util.ArrayList;
> import java.util.List;
> +import java.util.Map;
> 
> +import org.apache.vxquery.compiler.tools.ExpressionUtils;
> import org.apache.vxquery.context.StaticContext;
> 
> public class FLWORExpression extends Expression {
> @@ -40,20 +40,21 @@
>         return clauses;
>     }
> 
> -    public Expression getReturnExpression() {
> -        return rExpr.get();
> -    }
> -
> -    public void setReturnExpression(Expression rExpr) {
> -        this.rExpr.set(rExpr);
> +    public ExpressionHandle getReturnExpression() {
> +        return rExpr;
>     }
> 
>     public enum ClauseTag {
> -        FOR, LET, WHERE, ORDERBY,
> +        FOR,
> +        LET,
> +        WHERE,
> +        ORDERBY,
>     }
> 
>     public static abstract class Clause {
>         public abstract ClauseTag getTag();
> +
> +        public abstract Clause copy(StaticContext ctx, Map<Variable, Expression> substitution);
>     }
> 
>     public static final class ForClause extends Clause {
> @@ -95,6 +96,25 @@
>         public void setScoreVariable(ScoreVariable scoreVar) {
>             this.scoreVar = scoreVar;
>         }
> +
> +        @Override
> +        public Clause copy(StaticContext ctx, Map<Variable, Expression> substitution) {
> +            ForLetVariable fv = new ForLetVariable(Variable.VarTag.FOR, ExpressionUtils.createVariableCopyName(forVar
> +                    .getName()), forVar.getSequence().get().copy(substitution));
> +            substitution.put(forVar, new VariableReferenceExpression(ctx, fv));
> +            PositionVariable pv = null;
> +            if (posVar != null) {
> +                pv = new PositionVariable(ExpressionUtils.createVariableCopyName(posVar.getName()));
> +                substitution.put(posVar, new VariableReferenceExpression(ctx, pv));
> +            }
> +            ScoreVariable sv = null;
> +            if (scoreVar != null) {
> +                sv = new ScoreVariable(scoreVar.getName());
> +                substitution.put(scoreVar, new VariableReferenceExpression(ctx, sv));
> +            }
> +            return new ForClause(fv, pv, sv);
> +        }
> +
>     }
> 
>     public static final class LetClause extends Clause {
> @@ -116,6 +136,14 @@
>         public void setLetVariable(ForLetVariable letVar) {
>             this.letVar = letVar;
>         }
> +
> +        @Override
> +        public Clause copy(StaticContext ctx, Map<Variable, Expression> substitution) {
> +            ForLetVariable lv = new ForLetVariable(Variable.VarTag.LET, ExpressionUtils.createVariableCopyName(letVar
> +                    .getName()), letVar.getSequence().get().copy(substitution));
> +            substitution.put(letVar, new VariableReferenceExpression(ctx, lv));
> +            return new LetClause(lv);
> +        }
>     }
> 
>     public static final class WhereClause extends Clause {
> @@ -130,21 +158,25 @@
>             return ClauseTag.WHERE;
>         }
> 
> -        public Expression getCondition() {
> -            return condition.get();
> +        public ExpressionHandle getCondition() {
> +            return condition;
>         }
> 
> -        public void setCondition(Expression condition) {
> -            this.condition.set(condition);
> +        @Override
> +        public Clause copy(StaticContext ctx, Map<Variable, Expression> substitution) {
> +            return new WhereClause(condition.get().copy(substitution));
>         }
>     }
> 
>     public enum OrderDirection {
> -        ASCENDING, DESCENDING,
> +        ASCENDING,
> +        DESCENDING,
>     }
> 
>     public enum EmptyOrder {
> -        GREATEST, LEAST, DEFAULT,
> +        GREATEST,
> +        LEAST,
> +        DEFAULT,
>     }
> 
>     public static final class OrderbyClause extends Clause {
> @@ -206,10 +238,34 @@
>         public void setStability(boolean stable) {
>             this.stable = stable;
>         }
> +
> +        @Override
> +        public Clause copy(StaticContext ctx, Map<Variable, Expression> substitution) {
> +            List<Expression> oe = new ArrayList<Expression>();
> +            for (ExpressionHandle h : orderingExpressions) {
> +                oe.add(h.get().copy(substitution));
> +            }
> +            return new OrderbyClause(oe, new ArrayList<OrderDirection>(orderingDirections), new ArrayList<EmptyOrder>(
> +                    emptyOrders), new ArrayList<String>(collations), stable);
> +        }
>     }
> 
>     @Override
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitFLWORExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitFLWORExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        List<Clause> clausesCopy = new ArrayList<Clause>();
> +        for (Clause c : clauses) {
> +            clausesCopy.add(c.copy(ctx, substitution));
> +        }
> +        return new FLWORExpression(ctx, clausesCopy, rExpr.get().copy(substitution));
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ForLetVariable.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ForLetVariable.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ForLetVariable.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/ForLetVariable.java Fri Feb  5 15:19:44 2010
> @@ -1,19 +1,17 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> import javax.xml.namespace.QName;
> @@ -33,11 +31,7 @@
>         return tag;
>     }
> 
> -    public Expression getSequence() {
> -        return sequence.get();
> -    }
> -
> -    public void setSequence(Expression sequence) {
> -        this.sequence.set(sequence);
> +    public ExpressionHandle getSequence() {
> +        return sequence;
>     }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/FunctionCallExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,23 +1,22 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> import java.util.ArrayList;
> import java.util.List;
> +import java.util.Map;
> 
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.functions.Function;
> @@ -53,4 +52,18 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitFunctionCallExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitFunctionCallExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        List<Expression> argsCopy = new ArrayList<Expression>();
> +        for (ExpressionHandle h : args) {
> +            argsCopy.add(h.get().copy(substitution));
> +        }
> +        return new FunctionCallExpression(ctx, function, argsCopy);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/IfThenElseExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/IfThenElseExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/IfThenElseExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/IfThenElseExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> 
> public class IfThenElseExpression extends Expression {
> @@ -35,32 +35,31 @@
>         return ExprTag.IFTHENELSE;
>     }
> 
> -    public Expression getCondition() {
> -        return condition.get();
> -    }
> -
> -    public void setCondition(Expression condition) {
> -        this.condition.set(condition);
> +    public ExpressionHandle getCondition() {
> +        return condition;
>     }
> 
> -    public Expression getThenExpression() {
> -        return thenExpr.get();
> +    public ExpressionHandle getThenExpression() {
> +        return thenExpr;
>     }
> 
> -    public void setThenExpression(Expression thenExpr) {
> -        this.thenExpr.set(thenExpr);
> +    public ExpressionHandle getElseExpression() {
> +        return elseExpr;
>     }
> 
> -    public Expression getElseExpression() {
> -        return elseExpr.get();
> +    @Override
> +    public <T> T accept(ExpressionVisitor<T> visitor) {
> +        return visitor.visitIfThenElseExpression(this);
>     }
> 
> -    public void setElseExpression(Expression elseExpr) {
> -        this.elseExpr.set(elseExpr);
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitIfThenElseExpression(handle);
>     }
> 
>     @Override
> -    public <T> T accept(ExpressionVisitor<T> visitor) {
> -        return visitor.visitIfThenElseExpression(this);
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new IfThenElseExpression(ctx, condition.get().copy(substitution), thenExpr.get().copy(substitution),
> +                elseExpr.get().copy(substitution));
>     }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/InstanceofExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/InstanceofExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/InstanceofExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/InstanceofExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.SequenceType;
> 
> @@ -33,4 +33,14 @@
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitInstanceofExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitInstanceofExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new InstanceofExpression(ctx, input.get().copy(substitution), type);
> +    }
> }
> \ No newline at end of file
> 
> Added: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/MutableExpressionVisitor.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/MutableExpressionVisitor.java?rev=906965&view=auto
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/MutableExpressionVisitor.java (added)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/MutableExpressionVisitor.java Fri Feb  5 15:19:44 2010
> @@ -0,0 +1,59 @@
> +/*
> + * Licensed to the Apache Software Foundation (ExpressionHandle 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
> + * (ExpressionHandle "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 handleess or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.vxquery.compiler.expression;
> +
> +public interface MutableExpressionVisitor<T> {
> +    T visitAttributeNodeConstructorExpression(ExpressionHandle handle);
> +
> +    T visitCastableExpression(ExpressionHandle handle);
> +
> +    T visitCastExpression(ExpressionHandle handle);
> +
> +    T visitCommentNodeConstructorExpression(ExpressionHandle handle);
> +
> +    T visitConstantExpression(ExpressionHandle handle);
> +
> +    T visitDocumentNodeConstructorExpression(ExpressionHandle handle);
> +
> +    T visitElementNodeConstructorExpression(ExpressionHandle handle);
> +
> +    T visitExtensionExpression(ExpressionHandle handle);
> +
> +    T visitFLWORExpression(ExpressionHandle handle);
> +
> +    T visitFunctionCallExpression(ExpressionHandle handle);
> +
> +    T visitIfThenElseExpression(ExpressionHandle handle);
> +
> +    T visitInstanceofExpression(ExpressionHandle handle);
> +
> +    T visitPINodeConstructorExpression(ExpressionHandle handle);
> +
> +    T visitPromoteExpression(ExpressionHandle handle);
> +
> +    T visitQuantifiedExpression(ExpressionHandle handle);
> +
> +    T visitTextNodeConstructorExpression(ExpressionHandle handle);
> +
> +    T visitTreatExpression(ExpressionHandle handle);
> +
> +    T visitTypeswitchExpression(ExpressionHandle handle);
> +
> +    T visitValidateExpression(ExpressionHandle handle);
> +
> +    T visitVariableReferenceExpression(ExpressionHandle handle);
> +
> +    T visitPathStepExpression(ExpressionHandle handle);
> +}
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PINodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PINodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PINodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PINodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,32 +1,32 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.NodeKind;
> 
> public class PINodeConstructorExpression extends NodeConstructorExpression {
> -    private Expression target;
> -    private Expression content;
> +    private ExpressionHandle target;
> +    private ExpressionHandle content;
> 
>     public PINodeConstructorExpression(StaticContext ctx, Expression target, Expression content) {
>         super(ctx);
> -        this.target = target;
> -        this.content = content;
> +        this.target = new ExpressionHandle(target);
> +        this.content = new ExpressionHandle(content);
>     }
> 
>     @Override
> @@ -34,24 +34,26 @@
>         return NodeKind.PI;
>     }
> 
> -    public Expression getTarget() {
> +    public ExpressionHandle getTarget() {
>         return target;
>     }
> 
> -    public void setTarget(Expression target) {
> -        this.target = target;
> +    public ExpressionHandle getContent() {
> +        return content;
>     }
> 
> -    public Expression getContent() {
> -        return content;
> +    @Override
> +    public <T> T accept(ExpressionVisitor<T> visitor) {
> +        return visitor.visitPINodeConstructorExpression(this);
>     }
> 
> -    public void setContent(Expression content) {
> -        this.content = content;
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitPINodeConstructorExpression(handle);
>     }
> 
>     @Override
> -    public <T> T accept(ExpressionVisitor<T> visitor) {
> -        return visitor.visitPINodeConstructorExpression(this);
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new PINodeConstructorExpression(ctx, target.get().copy(substitution), content.get().copy(substitution));
>     }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PathStepExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PathStepExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PathStepExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PathStepExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.datamodel.AxisKind;
> import org.apache.vxquery.types.NodeType;
> @@ -42,12 +42,8 @@
>         return ExprTag.PATH_STEP;
>     }
> 
> -    public Expression getInput() {
> -        return input.get();
> -    }
> -
> -    public void setInput(Expression input) {
> -        this.input.set(input);
> +    public ExpressionHandle getInput() {
> +        return input;
>     }
> 
>     public AxisKind getAxis() {
> @@ -65,4 +61,14 @@
>     public void setNodeType(NodeType nodeType) {
>         this.nodeType = nodeType;
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitPathStepExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new PathStepExpression(ctx, input.get().copy(substitution), axis, nodeType);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PromoteExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PromoteExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PromoteExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/PromoteExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,21 +1,21 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.SequenceType;
> 
> @@ -33,4 +33,14 @@
>     public ExprTag getTag() {
>         return ExprTag.PROMOTE;
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitPromoteExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new PromoteExpression(ctx, input.get().copy(substitution), type);
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/QuantifiedExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/QuantifiedExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/QuantifiedExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/QuantifiedExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,23 +1,24 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.ArrayList;
> import java.util.List;
> +import java.util.Map;
> 
> +import org.apache.vxquery.compiler.tools.ExpressionUtils;
> import org.apache.vxquery.context.StaticContext;
> 
> public class QuantifiedExpression extends Expression {
> @@ -39,7 +40,8 @@
>     }
> 
>     public enum Quantification {
> -        SOME, EVERY,
> +        SOME,
> +        EVERY,
>     }
> 
>     public Quantification getQuantification() {
> @@ -58,16 +60,29 @@
>         this.quantVars = quantVars;
>     }
> 
> -    public Expression getSatisfiesExpression() {
> -        return satisfiesExpr.get();
> -    }
> -
> -    public void setSatisfiesExpression(Expression satisfiesExpr) {
> -        this.satisfiesExpr.set(satisfiesExpr);
> +    public ExpressionHandle getSatisfiesExpression() {
> +        return satisfiesExpr;
>     }
> 
>     @Override
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitQuantifiedExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitQuantifiedExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        List<ForLetVariable> varsCopy = new ArrayList<ForLetVariable>();
> +        for (ForLetVariable v : quantVars) {
> +            ForLetVariable fv = new ForLetVariable(Variable.VarTag.FOR, ExpressionUtils.createVariableCopyName(v
> +                    .getName()), v.getSequence().get().copy(substitution));
> +            substitution.put(v, new VariableReferenceExpression(ctx, fv));
> +            varsCopy.add(fv);
> +        }
> +        return new QuantifiedExpression(ctx, quantification, varsCopy, satisfiesExpr.get().copy(substitution));
> +    }
> }
> \ No newline at end of file
> 
> Modified: incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TextNodeConstructorExpression.java
> URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TextNodeConstructorExpression.java?rev=906965&r1=906964&r2=906965&view=diff
> ==============================================================================
> --- incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TextNodeConstructorExpression.java (original)
> +++ incubator/vxquery/trunk/vxquery/src/main/java/org/apache/vxquery/compiler/expression/TextNodeConstructorExpression.java Fri Feb  5 15:19:44 2010
> @@ -1,30 +1,30 @@
> /*
> -* 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.
> -*/
> + * 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.expression;
> 
> +import java.util.Map;
> +
> import org.apache.vxquery.context.StaticContext;
> import org.apache.vxquery.types.NodeKind;
> 
> public class TextNodeConstructorExpression extends NodeConstructorExpression {
> -    private Expression content;
> +    private ExpressionHandle content;
> 
>     public TextNodeConstructorExpression(StaticContext ctx, Expression content) {
>         super(ctx);
> -        this.content = content;
> +        this.content = new ExpressionHandle(content);
>     }
> 
>     @Override
> @@ -32,16 +32,22 @@
>         return NodeKind.TEXT;
>     }
> 
> -    public Expression getContent() {
> +    public ExpressionHandle getContent() {
>         return content;
>     }
> 
> -    public void setContent(Expression content) {
> -        this.content = content;
> -    }
> -
>     @Override
>     public <T> T accept(ExpressionVisitor<T> visitor) {
>         return visitor.visitTextNodeConstructorExpression(this);
>     }
> +
> +    @Override
> +    public <T> T accept(MutableExpressionVisitor<T> visitor, ExpressionHandle handle) {
> +        return visitor.visitTextNodeConstructorExpression(handle);
> +    }
> +
> +    @Override
> +    public Expression copy(Map<Variable, Expression> substitution) {
> +        return new TextNodeConstructorExpression(ctx, content.get().copy(substitution));
> +    }
> }
> \ No newline at end of file
> 


Mime
View raw message