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
22namespace panda::es2panda::ir {
23
24void MetaProperty::Iterate([[maybe_unused]] const NodeTraverser &cb) const {}
25
26void 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
47void 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        pg->Unimplemented();
56    }
57}
58
59checker::Type *MetaProperty::Check(checker::Checker *checker) const
60{
61    return checker->GlobalAnyType();
62}
63
64void MetaProperty::UpdateSelf([[maybe_unused]] const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) {}
65
66}  // namespace panda::es2panda::ir
67