/* * Copyright (c) 2001, 2008, * DecisionSoft Limited. All rights reserved. * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved. * * * Licensed 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. */ #ifndef _ASTVISITOR_HPP #define _ASTVISITOR_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ALL_ASTVISITOR_METHODS() \ virtual XQGlobalVariable *optimizeGlobalVar(XQGlobalVariable *item); \ virtual XQUserFunction *optimizeFunctionDef(XQUserFunction *item); \ \ virtual ASTNode *optimizeUnknown(ASTNode *item); \ virtual ASTNode *optimizeFunction(XQFunction *item); \ virtual ASTNode *optimizeLiteral(XQLiteral *item); \ virtual ASTNode *optimizeQNameLiteral(XQQNameLiteral *item); \ virtual ASTNode *optimizeNumericLiteral(XQNumericLiteral *item); \ virtual ASTNode *optimizeNav(XQNav *item); \ virtual ASTNode *optimizeSequence(XQSequence *item); \ virtual ASTNode *optimizeStep(XQStep *item); \ virtual ASTNode *optimizeVariable(XQVariable *item); \ virtual ASTNode *optimizeIf(XQIf *item); \ virtual ASTNode *optimizeCastableAs(XQCastableAs *item); \ virtual ASTNode *optimizeCastAs(XQCastAs *item); \ virtual ASTNode *optimizeTreatAs(XQTreatAs *item); \ virtual ASTNode *optimizeFunctionCoercion(XQFunctionCoercion *item); \ virtual ASTNode *optimizeOperator(XQOperator *item); \ virtual ASTNode *optimizeContextItem(XQContextItem *item); \ virtual ASTNode *optimizeReturn(XQReturn *item); \ virtual ASTNode *optimizeQuantified(XQQuantified *item); \ virtual ASTNode *optimizeTypeswitch(XQTypeswitch *item); \ virtual ASTNode *optimizeValidate(XQValidate *item); \ virtual ASTNode *optimizeFunctionCall(XQFunctionCall *item); \ virtual ASTNode *optimizeDOMConstructor(XQDOMConstructor *item); \ virtual ASTNode *optimizeSimpleContent(XQSimpleContent *item); \ virtual ASTNode *optimizeOrderingChange(XQOrderingChange *item); \ virtual ASTNode *optimizeAtomize(XQAtomize *item); \ virtual ASTNode *optimizeEffectiveBooleanValue(XQEffectiveBooleanValue *item); \ virtual ASTNode *optimizePromoteUntyped(XQPromoteUntyped *item); \ virtual ASTNode *optimizePromoteNumeric(XQPromoteNumeric *item); \ virtual ASTNode *optimizePromoteAnyURI(XQPromoteAnyURI *item); \ virtual ASTNode *optimizeDocumentOrder(XQDocumentOrder *item); \ virtual ASTNode *optimizePredicate(XQPredicate *item); \ virtual ASTNode *optimizeUserFunction(XQUserFunctionInstance *item); \ virtual ASTNode *optimizeNameExpression(XQNameExpression *item); \ virtual ASTNode *optimizeContentSequence(XQContentSequence *item); \ virtual ASTNode *optimizeDirectName(XQDirectName *item); \ virtual ASTNode *optimizeNamespaceBinding(XQNamespaceBinding *item); \ virtual ASTNode *optimizeFunctionConversion(XQFunctionConversion *item); \ virtual ASTNode *optimizeAnalyzeString(XQAnalyzeString *item); \ virtual ASTNode *optimizeCopyOf(XQCopyOf *item); \ virtual ASTNode *optimizeCopy(XQCopy *item); \ virtual ASTNode *optimizeASTDebugHook(ASTDebugHook *item); \ virtual ASTNode *optimizeCallTemplate(XQCallTemplate *item); \ virtual ASTNode *optimizeApplyTemplates(XQApplyTemplates *item); \ virtual ASTNode *optimizeInlineFunction(XQInlineFunction *item); \ virtual ASTNode *optimizeFunctionRef(XQFunctionRef *item); \ virtual ASTNode *optimizeFunctionDeref(XQFunctionDeref *item); \ virtual ASTNode *optimizePartialApply(XQPartialApply *item); \ virtual ASTNode *optimizeMap(XQMap *item); \ \ virtual ASTNode *optimizeUDelete(UDelete *item); \ virtual ASTNode *optimizeURename(URename *item); \ virtual ASTNode *optimizeUReplace(UReplace *item); \ virtual ASTNode *optimizeUReplaceValueOf(UReplaceValueOf *item); \ virtual ASTNode *optimizeUInsertAsFirst(UInsertAsFirst *item); \ virtual ASTNode *optimizeUInsertAsLast(UInsertAsLast *item); \ virtual ASTNode *optimizeUInsertInto(UInsertInto *item); \ virtual ASTNode *optimizeUInsertAfter(UInsertAfter *item); \ virtual ASTNode *optimizeUInsertBefore(UInsertBefore *item); \ virtual ASTNode *optimizeUTransform(UTransform *item); \ virtual ASTNode *optimizeUApplyUpdates(UApplyUpdates *item); \ \ virtual ASTNode *optimizeFTContains(FTContains *item); \ virtual FTSelection *optimizeUnknownFTSelection(FTSelection *item); \ virtual FTSelection *optimizeFTWords(FTWords *selection); \ virtual FTSelection *optimizeFTWord(FTWord *selection); \ virtual FTSelection *optimizeFTOr(FTOr *selection); \ virtual FTSelection *optimizeFTAnd(FTAnd *selection); \ virtual FTSelection *optimizeFTMildnot(FTMildnot *selection); \ virtual FTSelection *optimizeFTUnaryNot(FTUnaryNot *selection); \ virtual FTSelection *optimizeFTOrder(FTOrder *selection); \ virtual FTSelection *optimizeFTDistance(FTDistance *selection); \ virtual FTSelection *optimizeFTDistanceLiteral(FTDistanceLiteral *selection); \ virtual FTSelection *optimizeFTScope(FTScope *selection); \ virtual FTSelection *optimizeFTContent(FTContent *selection); \ virtual FTSelection *optimizeFTWindow(FTWindow *selection); \ virtual FTSelection *optimizeFTWindowLiteral(FTWindowLiteral *selection); \ \ virtual TupleNode *optimizeUnknownTupleNode(TupleNode *item); \ virtual TupleNode *optimizeContextTuple(ContextTuple *item); \ virtual TupleNode *optimizeForTuple(ForTuple *item); \ virtual TupleNode *optimizeLetTuple(LetTuple *item); \ virtual TupleNode *optimizeWhereTuple(WhereTuple *item); \ virtual TupleNode *optimizeOrderByTuple(OrderByTuple *item); \ virtual TupleNode *optimizeCountTuple(CountTuple *item); \ virtual TupleNode *optimizeTupleDebugHook(TupleDebugHook *item); class XQILLA_API ASTVisitor : public Optimizer { public: ASTVisitor(Optimizer *parent = 0) : Optimizer(parent) {} protected: virtual void optimize(XQQuery *query); virtual ASTNode *optimize(ASTNode *item); virtual TupleNode *optimizeTupleNode(TupleNode *item); virtual FTSelection *optimizeFTSelection(FTSelection *selection); ALL_ASTVISITOR_METHODS() }; #endif