• 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 #include "metaProperty.h"
17 
18 #include <compiler/core/pandagen.h>
19 #include <typescript/checker.h>
20 #include <ir/astDump.h>
21 
22 namespace panda::es2panda::ir {
23 
Iterate(const NodeTraverser & cb) const24 void MetaProperty::Iterate([[maybe_unused]] const NodeTraverser &cb) const {}
25 
Dump(ir::AstDumper * dumper) const26 void MetaProperty::Dump(ir::AstDumper *dumper) const
27 {
28     const char *kind = nullptr;
29 
30     switch (kind_) {
31         case MetaPropertyKind::NEW_TARGET: {
32             kind = "new.Target";
33             break;
34         }
35         case MetaPropertyKind::IMPORT_META: {
36             kind = "import.Meta";
37             break;
38         }
39         default: {
40             UNREACHABLE();
41         }
42     }
43 
44     dumper->Add({{"type", "MetaProperty"}, {"kind", kind}});
45 }
46 
Compile(compiler::PandaGen * pg) const47 void MetaProperty::Compile(compiler::PandaGen *pg) const
48 {
49     if (kind_ == ir::MetaProperty::MetaPropertyKind::NEW_TARGET) {
50         pg->GetNewTarget(this);
51         return;
52     }
53 
54     if (kind_ == ir::MetaProperty::MetaPropertyKind::IMPORT_META) {
55         // TODO()
56         pg->Unimplemented();
57     }
58 }
59 
Check(checker::Checker * checker) const60 checker::Type *MetaProperty::Check(checker::Checker *checker) const
61 {
62     // TODO(aszilagyi)
63     return checker->GlobalAnyType();
64 }
65 
UpdateSelf(const NodeUpdater & cb,binder::Binder * binder)66 void MetaProperty::UpdateSelf([[maybe_unused]] const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) {}
67 
68 }  // namespace panda::es2panda::ir
69