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_COMPILER_CORE_ETSFUNCTION_H
17#define ES2PANDA_COMPILER_CORE_ETSFUNCTION_H
18
19#include "ir/irnode.h"
20
21namespace ark::es2panda::ir {
22class ScriptFunction;
23class BlockStatement;
24}  // namespace ark::es2panda::ir
25
26namespace ark::es2panda::compiler {
27class ETSGen;
28
29class ETSFunction {
30public:
31    ETSFunction() = delete;
32
33    static void Compile(ETSGen *etsg);
34
35private:
36    static void GenerateEnumMembers(ETSGen *etsg, const ir::AstNode *node, VReg arrayObj,
37                                    const ir::TSEnumMember *enumMember, int32_t index);
38    static void CompileSourceBlock(ETSGen *etsg, const ir::BlockStatement *block);
39    static void CompileAsStaticBlock(ETSGen *etsg);
40    static void CompileAsConstructor(ETSGen *etsg, const ir::ScriptFunction *scriptFunc);
41    static void CompileFunction(ETSGen *etsg);
42    static void CallImplicitCtor(ETSGen *etsg);
43    static void ExtendWithDefaultReturn(ETSGen *etsg, const ir::AstNode *node, const ir::ScriptFunction *scriptFunc);
44};
45}  // namespace ark::es2panda::compiler
46
47#endif
48