1/**
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef ES2PANDA_IR_TS_MODULE_DECLARATION_H
17#define ES2PANDA_IR_TS_MODULE_DECLARATION_H
18
19#include <binder/scope.h>
20#include <ir/statement.h>
21
22namespace panda::es2panda::compiler {
23class PandaGen;
24}  // namespace panda::es2panda::compiler
25
26namespace panda::es2panda::checker {
27class Checker;
28class Type;
29}  // namespace panda::es2panda::checker
30
31namespace panda::es2panda::ir {
32
33class Expression;
34
35class TSModuleDeclaration : public Statement {
36public:
37    explicit TSModuleDeclaration(binder::TSModuleScope *scope, Expression *name, Statement *body, bool declare,
38                                 bool global, bool isInstantiated = true)
39        : Statement(AstNodeType::TS_MODULE_DECLARATION),
40          scope_(scope),
41          name_(name),
42          body_(body),
43          declare_(declare),
44          global_(global),
45          isInstantiated_(isInstantiated)
46    {
47    }
48
49    binder::TSModuleScope *Scope() const
50    {
51        return scope_;
52    }
53
54    const Expression *Name() const
55    {
56        return name_;
57    }
58
59    const Statement *Body() const
60    {
61        return body_;
62    }
63
64    Statement *Body()
65    {
66        return body_;
67    }
68
69    bool Declare() const
70    {
71        return declare_;
72    }
73
74    bool Global() const
75    {
76        return global_;
77    }
78
79    bool IsInstantiated() const
80    {
81        return isInstantiated_;
82    }
83
84    void Iterate(const NodeTraverser &cb) const override;
85    void Dump(ir::AstDumper *dumper) const override;
86    void Compile([[maybe_unused]] compiler::PandaGen *pg) const override;
87    checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override;
88    void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override;
89
90private:
91    binder::TSModuleScope *scope_;
92    Expression *name_;
93    Statement *body_;
94    bool declare_;
95    bool global_;
96    bool isInstantiated_;
97};
98}  // namespace panda::es2panda::ir
99
100#endif
101