• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_EMITTER_TYPEEXTRACTOR_EMITTER_H
17 #define ES2PANDA_COMPILER_CORE_EMITTER_TYPEEXTRACTOR_EMITTER_H
18 
19 #include <macros.h>
20 
21 #include <assembly-function.h>
22 #include <assembly-program.h>
23 
24 #include <compiler/core/pandagen.h>
25 #include <typescript/extractor/typeRecorder.h>
26 
27 namespace panda::es2panda::compiler {
28 
29 class TypeExtractorEmitter {
30 public:
31     explicit TypeExtractorEmitter(const PandaGen *pg, panda::pandasm::Function *func);
32     ~TypeExtractorEmitter() = default;
33     NO_COPY_SEMANTIC(TypeExtractorEmitter);
34     NO_MOVE_SEMANTIC(TypeExtractorEmitter);
35 
36     static void GenTypeInfoRecord(panda::pandasm::Program *prog, bool typeFlag, int64_t typeSummaryIndex);
37     static void GenTypeLiteralBuffers(panda::pandasm::Program *prog, const extractor::TypeRecorder *recorder);
38 
39     static constexpr const char *TYPE_INFO_RECORD = "_ESTypeInfoRecord";
40     static constexpr const char *TYPE_ANNOTATION = "_ESTypeAnnotation";
41     static constexpr const char *TYPE_INSTRUCTION = "_TypeOfInstruction";
42 
43     static constexpr const char *TYPE_FLAG = "typeFlag";
44     static constexpr const char *TYPE_SUMMARY = "typeSummaryIndex";
45     static constexpr const char *EXPORTED_SYMBOLS = "exportedSymbols";
46     static constexpr const char *EXPORTED_SYMBOL_TYPES = "exportedSymbolTypes";
47     static constexpr const char *DECLARED_SYMBOLS = "declaredSymbols";
48     static constexpr const char *DECLARED_SYMBOL_TYPES = "declaredSymbolTypes";
49 
50 private:
51     const PandaGen *pg_;
52     panda::pandasm::Function *func_;
53 
54     void GenFunctionTypeInfo() const;
55     void GenExportTypeInfo() const;
56     void GenDeclareTypeInfo() const;
57 };
58 
59 }  // namespace panda::es2panda::compiler
60 
61 #endif  // ES2PANDA_COMPILER_CORE_EMITTER_TYPEEXTRACTOR_EMITTER_H
62