• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 namespace panda::es2panda::compiler {
23 class PandaGen;
24 }  // namespace panda::es2panda::compiler
25 
26 namespace panda::es2panda::checker {
27 class Checker;
28 class Type;
29 }  // namespace panda::es2panda::checker
30 
31 namespace panda::es2panda::ir {
32 
33 class Expression;
34 
35 class TSModuleDeclaration : public Statement {
36 public:
37     explicit TSModuleDeclaration(binder::TSModuleScope *scope, Expression *name, Statement *body, bool declare,
38                                  bool global, bool isInstantiated = true)
Statement(AstNodeType::TS_MODULE_DECLARATION)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 
Scope()49     binder::TSModuleScope *Scope() const
50     {
51         return scope_;
52     }
53 
Name()54     const Expression *Name() const
55     {
56         return name_;
57     }
58 
Body()59     const Statement *Body() const
60     {
61         return body_;
62     }
63 
Body()64     Statement *Body()
65     {
66         return body_;
67     }
68 
Declare()69     bool Declare() const
70     {
71         return declare_;
72     }
73 
Global()74     bool Global() const
75     {
76         return global_;
77     }
78 
IsInstantiated()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 
90 private:
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