1/*
2 * Copyright (c) 2021-2024 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
24namespace ark::es2panda::ir {
25class StringLiteral;
26
27class ETSImportDeclaration : public ImportDeclaration {
28public:
29    explicit ETSImportDeclaration(ImportSource *source, const ArenaVector<AstNode *> &specifiers,
30                                  const ImportKinds importKind = ImportKinds::VALUE)
31        : ImportDeclaration(source->Source(), specifiers, importKind), source_(source)
32    {
33        SetType(AstNodeType::ETS_IMPORT_DECLARATION);
34    }
35
36    es2panda::Language Language() const
37    {
38        return source_->Language();
39    }
40
41    bool HasDecl() const
42    {
43        return source_->HasDecl();
44    }
45
46    bool IsPureDynamic() const
47    {
48        return !HasDecl() && Language().IsDynamic();
49    }
50
51    util::StringView &AssemblerName()
52    {
53        return assemblerName_;
54    }
55
56    const util::StringView &AssemblerName() const
57    {
58        return assemblerName_;
59    }
60
61    StringLiteral *Source() const
62    {
63        return source_->Source();
64    }
65
66    StringLiteral *ResolvedSource()
67    {
68        return source_->ResolvedSource();
69    }
70
71    const StringLiteral *ResolvedSource() const
72    {
73        return source_->ResolvedSource();
74    }
75
76    void Accept(ASTVisitorT *v) override
77    {
78        v->Accept(this);
79    }
80
81private:
82    ImportSource *source_;
83    util::StringView assemblerName_ {};
84};
85}  // namespace ark::es2panda::ir
86
87#endif
88