• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 - 2023 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_ETS_IMPORT_DECLARATION_H
17 #define ES2PANDA_IR_ETS_IMPORT_DECLARATION_H
18 
19 #include "ir/ets/etsImportSource.h"
20 #include "ir/module/importDeclaration.h"
21 #include "util/language.h"
22 #include "util/ustring.h"
23 
24 namespace panda::es2panda::ir {
25 class StringLiteral;
26 
27 class ETSImportDeclaration : public ImportDeclaration {
28 public:
ETSImportDeclaration(ImportSource * source,const ArenaVector<AstNode * > & specifiers)29     explicit ETSImportDeclaration(ImportSource *source, const ArenaVector<AstNode *> &specifiers)
30         : ImportDeclaration(source->Source(), specifiers), source_(source)
31     {
32         SetType(AstNodeType::ETS_IMPORT_DECLARATION);
33     }
34 
Language()35     es2panda::Language Language() const
36     {
37         return source_->Language();
38     }
39 
HasDecl()40     bool HasDecl() const
41     {
42         return source_->HasDecl();
43     }
44 
IsPureDynamic()45     bool IsPureDynamic() const
46     {
47         return !HasDecl() && Language().IsDynamic();
48     }
49 
AssemblerName()50     util::StringView &AssemblerName()
51     {
52         return assemblerName_;
53     }
54 
AssemblerName()55     const util::StringView &AssemblerName() const
56     {
57         return assemblerName_;
58     }
59 
ResolvedSource()60     StringLiteral *ResolvedSource()
61     {
62         return source_->ResolvedSource();
63     }
64 
ResolvedSource()65     const StringLiteral *ResolvedSource() const
66     {
67         return source_->ResolvedSource();
68     }
69 
Module()70     StringLiteral *Module()
71     {
72         return source_->Module();
73     }
74 
Module()75     const StringLiteral *Module() const
76     {
77         return source_->Module();
78     }
79 
Accept(ASTVisitorT * v)80     void Accept(ASTVisitorT *v) override
81     {
82         v->Accept(this);
83     }
84 
85 private:
86     ImportSource *source_;
87     util::StringView assemblerName_ {};
88 };
89 }  // namespace panda::es2panda::ir
90 
91 #endif
92