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_JS_EMITTER_H
17#define ES2PANDA_COMPILER_CORE_JS_EMITTER_H
18
19#include "emitter.h"
20
21namespace ark::es2panda::compiler {
22
23class JSFunctionEmitter : public FunctionEmitter {
24public:
25    JSFunctionEmitter(const CodeGen *cg, ProgramElement *programElement) : FunctionEmitter(cg, programElement) {}
26    ~JSFunctionEmitter() override = default;
27    NO_COPY_SEMANTIC(JSFunctionEmitter);
28    NO_MOVE_SEMANTIC(JSFunctionEmitter);
29
30protected:
31    const PandaGen *Pg() const
32    {
33        return reinterpret_cast<const PandaGen *>(Cg());
34    }
35
36    pandasm::Function *GenFunctionSignature() override;
37
38    void GenFunctionAnnotations(pandasm::Function *func) override;
39    void GenVariableSignature(pandasm::debuginfo::LocalVariable &variableDebug,
40                              varbinder::LocalVariable *variable) const override;
41};
42
43class JSEmitter : public Emitter {
44public:
45    explicit JSEmitter(const public_lib::Context *context) : Emitter(context) {}
46    ~JSEmitter() override = default;
47    NO_COPY_SEMANTIC(JSEmitter);
48    NO_MOVE_SEMANTIC(JSEmitter);
49
50    void GenAnnotation() override;
51
52private:
53    void GenESAnnotationRecord();
54    void GenESModuleModeRecord(bool isModule);
55};
56}  // namespace ark::es2panda::compiler
57
58#endif
59