• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "etsStringLiteralType.h"
17 
18 #include "checker/ETSchecker.h"
19 #include "ir/astDump.h"
20 
21 namespace ark::es2panda::ir {
TransformChildren(const NodeTransformer & cb,std::string_view const transformationName)22 void ETSStringLiteralType::TransformChildren([[maybe_unused]] const NodeTransformer &cb,
23                                              [[maybe_unused]] std::string_view const transformationName)
24 {
25 }
26 
Iterate(const NodeTraverser & cb) const27 void ETSStringLiteralType::Iterate([[maybe_unused]] const NodeTraverser &cb) const {}
28 
Dump(ir::AstDumper * dumper) const29 void ETSStringLiteralType::Dump(ir::AstDumper *dumper) const
30 {
31     dumper->Add({{"type", "ETSStringLiteralType"}, {"value", value_}});
32 }
33 
Dump(ir::SrcDumper * dumper) const34 void ETSStringLiteralType::Dump(ir::SrcDumper *dumper) const
35 {
36     dumper->Add(value_.Mutf8());
37 }
38 
Compile(compiler::PandaGen * pg) const39 void ETSStringLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const
40 {
41     UNREACHABLE();
42 }
43 
Check(checker::TSChecker * checker)44 checker::Type *ETSStringLiteralType::Check([[maybe_unused]] checker::TSChecker *checker)
45 {
46     UNREACHABLE();
47 }
48 
Check(checker::ETSChecker * checker)49 checker::Type *ETSStringLiteralType::Check([[maybe_unused]] checker::ETSChecker *checker)
50 {
51     return checker->GetAnalyzer()->Check(this);
52 }
53 
GetType(checker::ETSChecker * checker)54 checker::Type *ETSStringLiteralType::GetType([[maybe_unused]] checker::ETSChecker *checker)
55 {
56     SetTsType(checker->CreateETSStringLiteralType(value_));
57     return TsType();
58 }
59 
Clone(ArenaAllocator * allocator,AstNode * parent)60 ETSStringLiteralType *ETSStringLiteralType::Clone(ArenaAllocator *allocator, AstNode *parent)
61 {
62     if (auto *const clone = allocator->New<ir::ETSStringLiteralType>(value_); clone != nullptr) {
63         if (parent != nullptr) {
64             clone->SetParent(parent);
65         }
66         return clone;
67     }
68     return nullptr;
69 }
70 }  // namespace ark::es2panda::ir
71