13af6ab5fSopenharmony_ci/**
23af6ab5fSopenharmony_ci * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd.
33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License.
53af6ab5fSopenharmony_ci * You may obtain a copy of the License at
63af6ab5fSopenharmony_ci *
73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
83af6ab5fSopenharmony_ci *
93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and
133af6ab5fSopenharmony_ci * limitations under the License.
143af6ab5fSopenharmony_ci */
153af6ab5fSopenharmony_ci
163af6ab5fSopenharmony_ci#ifndef ES2PANDA_COMPILER_CORE_AST_VISITOR_H
173af6ab5fSopenharmony_ci#define ES2PANDA_COMPILER_CORE_AST_VISITOR_H
183af6ab5fSopenharmony_ci
193af6ab5fSopenharmony_ci#include <ir/astNodeMapping.h>
203af6ab5fSopenharmony_ci#include "macros.h"
213af6ab5fSopenharmony_ci
223af6ab5fSopenharmony_ci#include <tuple>
233af6ab5fSopenharmony_ci
243af6ab5fSopenharmony_cinamespace ark::es2panda::ir {
253af6ab5fSopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
263af6ab5fSopenharmony_ci#define DECLARE_CLASSES(nodeType, className) class className;
273af6ab5fSopenharmony_ci
283af6ab5fSopenharmony_ciAST_NODE_MAPPING(DECLARE_CLASSES)
293af6ab5fSopenharmony_ci
303af6ab5fSopenharmony_ci#undef DECLARE_CLASSES
313af6ab5fSopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
323af6ab5fSopenharmony_ci#define DECLARE_AST_NODE_CHECK_METHOD(_, __, nodeType, ___) class nodeType;
333af6ab5fSopenharmony_ciAST_NODE_REINTERPRET_MAPPING(DECLARE_AST_NODE_CHECK_METHOD)
343af6ab5fSopenharmony_ci#undef DECLARE_AST_NODE_CHECK_METHOD
353af6ab5fSopenharmony_ci
363af6ab5fSopenharmony_cinamespace visitor {
373af6ab5fSopenharmony_ci/**
383af6ab5fSopenharmony_ci * All such Visitors should override VisitClassName(Node*) for all types
393af6ab5fSopenharmony_ci */
403af6ab5fSopenharmony_ciclass ASTAbstractVisitor {
413af6ab5fSopenharmony_cipublic:
423af6ab5fSopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
433af6ab5fSopenharmony_ci#define DECLARE_CLASSES(nodeType, className)            \
443af6ab5fSopenharmony_ci    virtual void Visit##className(className *node) = 0; \
453af6ab5fSopenharmony_ci    void Accept(className *node)                        \
463af6ab5fSopenharmony_ci    {                                                   \
473af6ab5fSopenharmony_ci        Visit##className(node);                         \
483af6ab5fSopenharmony_ci    }
493af6ab5fSopenharmony_ci
503af6ab5fSopenharmony_ci    AST_NODE_MAPPING(DECLARE_CLASSES)
513af6ab5fSopenharmony_ci
523af6ab5fSopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
533af6ab5fSopenharmony_ci#define DECLARE_AST_NODE_CHECK_METHOD(nodeType1, nodeType2, baseClass, reinterpretClass) \
543af6ab5fSopenharmony_ci    DECLARE_CLASSES(nodeType1, baseClass)
553af6ab5fSopenharmony_ci
563af6ab5fSopenharmony_ci    AST_NODE_REINTERPRET_MAPPING(DECLARE_AST_NODE_CHECK_METHOD)
573af6ab5fSopenharmony_ci#undef DECLARE_AST_NODE_CHECK_METHOD
583af6ab5fSopenharmony_ci
593af6ab5fSopenharmony_ci#undef DECLARE_CLASSES
603af6ab5fSopenharmony_ci};
613af6ab5fSopenharmony_ci}  // namespace visitor
623af6ab5fSopenharmony_ci}  // namespace ark::es2panda::ir
633af6ab5fSopenharmony_ci
643af6ab5fSopenharmony_ci#endif
65