• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024-2025 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 // Autogenerated file -- DO NOT EDIT!
17 
18 #ifndef ES2PANDA_PUBLIC_ES2PANDA_LIB
19 #define ES2PANDA_PUBLIC_ES2PANDA_LIB
20 
21 // Switch off the linter for C header
22 // NOLINTBEGIN
23 //
24 
25 #include <stdbool.h>
26 #include <stddef.h>
27 #include <stdint.h>
28 #include <uchar.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define ES2PANDA_LIB_VERSION 1
35 
36 #ifndef CAPI_EXPORT
37 #ifdef PANDA_TARGET_WINDOWS
38 #define CAPI_EXPORT __declspec(dllexport)
39 #else
40 #define CAPI_EXPORT __attribute__((visibility("default")))
41 #endif
42 #endif
43 
44 typedef struct es2panda_Config es2panda_Config;
45 typedef struct es2panda_Context es2panda_Context;
46 
47 typedef struct es2panda_variantDoubleCharArrayBool {
48     int index;
49     union {
50         double d;
51         char *c;
52         bool b;
53     } variant;
54 } es2panda_variantDoubleCharArrayBool;
55 
56 enum es2panda_variantIndex {
57     CAPI_DOUBLE = 0,
58     CAPI_CHAR = 1,
59     CAPI_BOOL = 2,
60 };
61 
62 typedef struct es2panda_Program es2panda_Program;
63 typedef struct es2panda_ExternalSource es2panda_ExternalSource;
64 typedef struct es2panda_ArkTsConfig es2panda_ArkTsConfig;
65 typedef struct es2panda_AstNode es2panda_AstNode;
66 typedef struct es2panda_FunctionSignature es2panda_FunctionSignature;
67 typedef struct es2panda_SourcePosition es2panda_SourcePosition;
68 typedef struct es2panda_SourceRange es2panda_SourceRange;
69 typedef struct es2panda_SrcDumper es2panda_SrcDumper;
70 typedef struct es2panda_AstDumper es2panda_AstDumper;
71 typedef struct es2panda_LabelPair es2panda_LabelPair;
72 typedef struct es2panda_ScriptFunctionData es2panda_ScriptFunctionData;
73 typedef struct es2panda_ImportSource es2panda_ImportSource;
74 typedef struct es2panda_Signature es2panda_Signature;
75 typedef struct es2panda_SignatureInfo es2panda_SignatureInfo;
76 typedef struct es2panda_CheckerContext es2panda_CheckerContext;
77 typedef struct es2panda_ResolveResult es2panda_ResolveResult;
78 typedef struct es2panda_ValidationInfo es2panda_ValidationInfo;
79 typedef struct es2panda_Type es2panda_Type;
80 typedef struct es2panda_TypeRelation es2panda_TypeRelation;
81 typedef struct es2panda_IndexInfo es2panda_IndexInfo;
82 typedef struct es2panda_GlobalTypesHolder es2panda_GlobalTypesHolder;
83 typedef struct es2panda_ObjectDescriptor es2panda_ObjectDescriptor;
84 typedef struct es2panda_Variable es2panda_Variable;
85 typedef struct es2panda_Scope es2panda_Scope;
86 typedef struct es2panda_ScopeFindResult es2panda_ScopeFindResult;
87 typedef struct es2panda_BindingProps es2panda_BindingProps;
88 typedef struct es2panda_Declaration es2panda_Declaration;
89 typedef struct es2panda_RecordTable es2panda_RecordTable;
90 typedef struct es2panda_BoundContext es2panda_BoundContext;
91 typedef struct es2panda_AstVisitor es2panda_AstVisitor;
92 typedef struct es2panda_AstVerifier es2panda_AstVerifier;
93 typedef struct es2panda_VerifierMessage es2panda_VerifierMessage;
94 typedef struct es2panda_CodeGen es2panda_CodeGen;
95 typedef struct es2panda_VReg es2panda_VReg;
96 typedef struct es2panda_IRNode es2panda_IRNode;
97 typedef struct es2panda_ErrorLogger es2panda_ErrorLogger;
98 typedef struct es2panda_VerificationContext es2panda_VerificationContext;
99 typedef struct es2panda_ImportPathManager es2panda_ImportPathManager;
100 typedef struct es2panda_DiagnosticKind es2panda_DiagnosticKind;
101 typedef struct es2panda_DiagnosticMessageParams es2panda_DiagnosticMessageParams;
102 typedef struct es2panda_DiagnosticStorage es2panda_DiagnosticStorage;
103 typedef struct es2panda_Path es2panda_Path;
104 typedef struct es2panda_Options es2panda_Options;
105 typedef void (*NodeTraverser)(es2panda_AstNode *);
106 typedef es2panda_AstNode *(*NodeTransformer)(es2panda_AstNode *);
107 typedef bool (*NodePredicate)(es2panda_AstNode *);
108 typedef es2panda_Variable *(*PropertyProcessor)(es2panda_Variable *, es2panda_Type *);
109 typedef void (*PropertyTraverser)(const es2panda_Variable *);
110 typedef void (*ClassBuilder)(es2panda_AstNode **nodes, size_t size);
111 typedef void (*MethodBuilder)(es2panda_AstNode **statements, size_t sizeStatements, es2panda_AstNode **expression,
112                               size_t sizeExpression, es2panda_Type **type);
113 typedef void (*ClassInitializerBuilder)(es2panda_AstNode **statements, size_t sizeStatements,
114                                         es2panda_AstNode **expression, size_t sizeExpression);
115 
116 typedef struct es2panda_DynamicImportData {
117     const es2panda_AstNode *import;
118     const es2panda_AstNode *specifier;
119     es2panda_Variable *variable;
120 } es2panda_DynamicImportData;
121 
122 typedef struct es2panda_OverloadInfo {
123     uint32_t minArg;
124     size_t maxArg;
125     bool needHelperOverload;
126     bool isDeclare;
127     bool hasRestVar;
128     bool returnVoid;
129 } es2panda_OverloadInfo;
130 
131 typedef struct es2panda_JsDocRecord {
132     char *name;
133     char *param;
134     char *comment;
135 } es2panda_JsDocRecord;
136 
137 typedef struct es2panda_JsDocInfo {
138     char **strings;
139     es2panda_JsDocRecord **jsDocRecords;
140     size_t len;
141 } es2panda_JsDocInfo;
142 
143 enum es2panda_ContextState {
144     ES2PANDA_STATE_NEW,
145     ES2PANDA_STATE_PARSED,
146     ES2PANDA_STATE_BOUND,
147     ES2PANDA_STATE_CHECKED,
148     ES2PANDA_STATE_LOWERED,
149     ES2PANDA_STATE_ASM_GENERATED,
150     ES2PANDA_STATE_BIN_GENERATED,
151 
152     ES2PANDA_STATE_ERROR
153 };
154 
155 typedef struct es2panda_SuggestionInfo {
156     const es2panda_DiagnosticKind *kind;
157     const char **args;
158     size_t argc;
159     const char *substitutionCode;
160 } es2panda_SuggestionInfo;
161 
162 typedef struct es2panda_DiagnosticInfo {
163     const es2panda_DiagnosticKind *kind;
164     const char **args;
165     size_t argc;
166 } es2panda_DiagnosticInfo;
167 
168 enum es2panda_PluginDiagnosticType { ES2PANDA_PLUGIN_WARNING, ES2PANDA_PLUGIN_ERROR, ES2PANDA_PLUGIN_SUGGESTION };
169 
170 typedef enum es2panda_PluginDiagnosticType es2panda_PluginDiagnosticType;
171 typedef enum es2panda_ContextState es2panda_ContextState;
172 // CC-OFFNXT(G.INC.08) project code style
173 #include "generated/es2panda_lib/es2panda_lib_enums.inc"
174 
175 struct CAPI_EXPORT es2panda_Impl {
176     int version;
177 
178     es2panda_Config *(*CreateConfig)(int argc, char const *const *argv);
179     void (*DestroyConfig)(es2panda_Config *config);
180     char const *(*GetAllErrorMessages)(es2panda_Context *context);
181     const es2panda_Options *(*ConfigGetOptions)(es2panda_Config *config);
182 
183     es2panda_Context *(*CreateContextFromFile)(es2panda_Config *config, char const *source_file_name);
184     es2panda_Context *(*CreateContextFromString)(es2panda_Config *config, const char *source, char const *file_name);
185     es2panda_Context *(*CreateContextGenerateAbcForExternalSourceFiles)(es2panda_Config *config, int fileNamesCount,
186                                                                         char const *const *fileNames);
187     es2panda_Context *(*ProceedToState)(es2panda_Context *context, es2panda_ContextState state);  // context is consumed
188     void (*DestroyContext)(es2panda_Context *context);
189 
190     es2panda_ContextState (*ContextState)(es2panda_Context *context);
191     char const *(*ContextErrorMessage)(es2panda_Context *context);
192 
193     es2panda_Program *(*ContextProgram)(es2panda_Context *context);
194     char const *(*ExternalSourceName)(es2panda_ExternalSource *e_source);
195     es2panda_Program **(*ExternalSourcePrograms)(es2panda_ExternalSource *e_source, size_t *len_p);
196     void (*AstNodeForEach)(es2panda_AstNode *ast, void (*func)(es2panda_AstNode *, void *), void *arg);
197 
198 #define NUMBER_LITERAL_SET_DECL(name, type) bool (*NumberLiteralSet##name)(es2panda_AstNode * node, type new_value)
199 
200     NUMBER_LITERAL_SET_DECL(Int, int32_t);
201     NUMBER_LITERAL_SET_DECL(Long, int64_t);
202     NUMBER_LITERAL_SET_DECL(Double, double);
203     NUMBER_LITERAL_SET_DECL(Float, float);
204 
205 #undef NUMBER_LITERAL_SET_DECL
206 
207 #define CREATE_UPDATE_NUMBER_LITERAL_IMPL(num, type)                                   \
208     es2panda_AstNode *(*CreateNumberLiteral##num)(es2panda_Context * ctx, type value); \
209     es2panda_AstNode *(*UpdateNumberLiteral##num)(es2panda_Context * ctx, es2panda_AstNode * original, type value)
210 
211     CREATE_UPDATE_NUMBER_LITERAL_IMPL(, int32_t);
212     CREATE_UPDATE_NUMBER_LITERAL_IMPL(1, int64_t);
213     CREATE_UPDATE_NUMBER_LITERAL_IMPL(2, double);
214     CREATE_UPDATE_NUMBER_LITERAL_IMPL(3, float);
215 
216 #undef CREATE_UPDATE_NUMBER_LITERAL_IMPL
217     const char *(*NumberLiteralStrConst)(es2panda_Context *context, es2panda_AstNode *classInstance);
218 
219     void *(*AllocMemory)(es2panda_Context *context, size_t numberOfElements, size_t sizeOfElement);
220     es2panda_SourcePosition *(*CreateSourcePosition)(es2panda_Context *context, size_t index, size_t line);
221     es2panda_SourceRange *(*CreateSourceRange)(es2panda_Context *context, es2panda_SourcePosition *start,
222                                                es2panda_SourcePosition *end);
223     size_t (*SourcePositionIndex)(es2panda_Context *context, es2panda_SourcePosition *position);
224     size_t (*SourcePositionLine)(es2panda_Context *context, es2panda_SourcePosition *position);
225     es2panda_SourcePosition *(*SourceRangeStart)(es2panda_Context *context, es2panda_SourceRange *range);
226     es2panda_SourcePosition *(*SourceRangeEnd)(es2panda_Context *context, es2panda_SourceRange *range);
227     const es2panda_DiagnosticKind *(*CreateDiagnosticKind)(es2panda_Context *context, const char *dmessage,
228                                                            es2panda_PluginDiagnosticType etype);
229     es2panda_DiagnosticInfo *(*CreateDiagnosticInfo)(es2panda_Context *context, const es2panda_DiagnosticKind *kind,
230                                                      const char **args, size_t argc);
231     es2panda_SuggestionInfo *(*CreateSuggestionInfo)(es2panda_Context *context, const es2panda_DiagnosticKind *kind,
232                                                      const char **args, size_t argc, const char *substitutionCode);
233     void (*LogDiagnosticWithSuggestion)(es2panda_Context *context, const es2panda_DiagnosticInfo *diagnosticInfo,
234                                         const es2panda_SuggestionInfo *suggestionInfo, es2panda_SourceRange *range);
235     void (*LogDiagnostic)(es2panda_Context *context, const es2panda_DiagnosticKind *kind, const char **args,
236                           size_t argc, es2panda_SourcePosition *pos);
237     const es2panda_DiagnosticStorage *(*GetSemanticErrors)(es2panda_Context *context);
238     const es2panda_DiagnosticStorage *(*GetSyntaxErrors)(es2panda_Context *context);
239     const es2panda_DiagnosticStorage *(*GetPluginErrors)(es2panda_Context *context);
240     const es2panda_DiagnosticStorage *(*GetWarnings)(es2panda_Context *context);
241     bool (*IsAnyError)(es2panda_Context *context);
242     es2panda_Scope *(*AstNodeFindNearestScope)(es2panda_Context *ctx, es2panda_AstNode *node);
243     es2panda_Scope *(*AstNodeRebind)(es2panda_Context *ctx, es2panda_AstNode *node);
244     void (*AstNodeRecheck)(es2panda_Context *ctx, es2panda_AstNode *node);
245     Es2pandaEnum (*Es2pandaEnumFromString)(es2panda_Context *ctx, const char *str);
246     char *(*Es2pandaEnumToString)(es2panda_Context *ctx, Es2pandaEnum id);
247     es2panda_AstNode *(*DeclarationFromIdentifier)(es2panda_Context *ctx, es2panda_AstNode *node);
248     es2panda_AstNode *(*FirstDeclarationByNameFromNode)(es2panda_Context *ctx, const es2panda_AstNode *node,
249                                                         const char *name);
250     es2panda_AstNode *(*FirstDeclarationByNameFromProgram)(es2panda_Context *ctx, const es2panda_Program *program,
251                                                            const char *name);
252     es2panda_AstNode **(*AllDeclarationsByNameFromNode)(es2panda_Context *ctx, const es2panda_AstNode *node,
253                                                         const char *name, size_t *declsLen);
254     es2panda_AstNode **(*AllDeclarationsByNameFromProgram)(es2panda_Context *ctx, const es2panda_Program *program,
255                                                            const char *name, size_t *declsLen);
256 
257     int (*GenerateTsDeclarationsFromContext)(es2panda_Context *context, const char *outputDeclEts,
258                                              const char *outputEts, bool exportAll, const char *recordFile);
259     void (*InsertETSImportDeclarationAndParse)(es2panda_Context *context, es2panda_Program *program,
260                                                es2panda_AstNode *importDeclaration);
261     int (*GenerateStaticDeclarationsFromContext)(es2panda_Context *context, const char *outputPath);
262 
263 // CC-OFFNXT(G.INC.08) project code style
264 #include "generated/es2panda_lib/es2panda_lib_decl.inc"
265 };
266 
267 CAPI_EXPORT struct es2panda_Impl const *es2panda_GetImpl(int version);
268 
269 // NOLINTEND
270 
271 #ifdef __cplusplus
272 }
273 #endif
274 
275 #endif
276