1 /** 2 * Copyright (c) 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 // 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 typedef struct es2panda_Config es2panda_Config; 37 typedef struct es2panda_Context es2panda_Context; 38 39 typedef struct es2panda_variantDoubleCharArrayBool { 40 int index; 41 union { 42 double d; 43 char *c; 44 bool b; 45 } variant; 46 } es2panda_variantDoubleCharArrayBool; 47 48 enum es2panda_variantIndex { 49 DOUBLE = 0, 50 CHAR = 1, 51 BOOL = 2, 52 }; 53 54 typedef struct es2panda_Program es2panda_Program; 55 typedef struct es2panda_ExternalSource es2panda_ExternalSource; 56 typedef struct es2panda_ArkTsConfig es2panda_ArkTsConfig; 57 typedef struct es2panda_AstNode es2panda_AstNode; 58 typedef struct es2panda_FunctionSignature es2panda_FunctionSignature; 59 typedef struct es2panda_SourcePosition es2panda_SourcePosition; 60 typedef struct es2panda_SourceRange es2panda_SourceRange; 61 typedef struct es2panda_SrcDumper es2panda_SrcDumper; 62 typedef struct es2panda_AstDumper es2panda_AstDumper; 63 typedef struct es2panda_LabelPair es2panda_LabelPair; 64 typedef struct es2panda_ScriptFunctionData es2panda_ScriptFunctionData; 65 typedef struct es2panda_ImportSource es2panda_ImportSource; 66 typedef struct es2panda_Signature es2panda_Signature; 67 typedef struct es2panda_SignatureInfo es2panda_SignatureInfo; 68 typedef struct es2panda_CheckerContext es2panda_CheckerContext; 69 typedef struct es2panda_ResolveResult es2panda_ResolveResult; 70 typedef struct es2panda_ValidationInfo es2panda_ValidationInfo; 71 typedef struct es2panda_Type es2panda_Type; 72 typedef struct es2panda_TypeRelation es2panda_TypeRelation; 73 typedef struct es2panda_IndexInfo es2panda_IndexInfo; 74 typedef struct es2panda_GlobalTypesHolder es2panda_GlobalTypesHolder; 75 typedef struct es2panda_ObjectDescriptor es2panda_ObjectDescriptor; 76 typedef struct es2panda_Variable es2panda_Variable; 77 typedef struct es2panda_Scope es2panda_Scope; 78 typedef struct es2panda_ScopeFindResult es2panda_ScopeFindResult; 79 typedef struct es2panda_BindingProps es2panda_BindingProps; 80 typedef struct es2panda_Declaration es2panda_Declaration; 81 typedef struct es2panda_RecordTable es2panda_RecordTable; 82 typedef struct es2panda_BoundContext es2panda_BoundContext; 83 typedef struct es2panda_AstVisitor es2panda_AstVisitor; 84 typedef struct es2panda_CodeGen es2panda_CodeGen; 85 typedef struct es2panda_VReg es2panda_VReg; 86 typedef struct es2panda_IRNode es2panda_IRNode; 87 typedef struct es2panda_ErrorLogger es2panda_ErrorLogger; 88 typedef void (*NodeTraverser)(es2panda_AstNode *); 89 typedef es2panda_AstNode *(*NodeTransformer)(es2panda_AstNode *); 90 typedef bool (*NodePredicate)(es2panda_AstNode *); 91 typedef es2panda_Variable *(*PropertyProcessor)(es2panda_Variable *, es2panda_Type *); 92 typedef void (*PropertyTraverser)(const es2panda_Variable *); 93 typedef void (*ClassBuilder)(es2panda_AstNode **nodes, size_t size); 94 typedef void (*MethodBuilder)(es2panda_AstNode **statements, size_t sizeStatements, es2panda_AstNode **expression, 95 size_t sizeExpression, es2panda_Type **type); 96 typedef void (*ClassInitializerBuilder)(es2panda_AstNode **statements, size_t sizeStatements, 97 es2panda_AstNode **expression, size_t sizeExpression); 98 99 typedef struct es2panda_DynamicImportData { 100 const es2panda_AstNode *import; 101 const es2panda_AstNode *specifier; 102 es2panda_Variable *variable; 103 } es2panda_DynamicImportData; 104 105 enum es2panda_ContextState { 106 ES2PANDA_STATE_NEW, 107 ES2PANDA_STATE_PARSED, 108 ES2PANDA_STATE_SCOPE_INITED, 109 ES2PANDA_STATE_CHECKED, 110 ES2PANDA_STATE_LOWERED, 111 ES2PANDA_STATE_ASM_GENERATED, 112 ES2PANDA_STATE_BIN_GENERATED, 113 114 ES2PANDA_STATE_ERROR 115 }; 116 typedef enum es2panda_ContextState es2panda_ContextState; 117 // CC-OFFNXT(G.INC.08) project code style 118 #include "generated/es2panda_lib/es2panda_lib_enums.inc" 119 120 struct es2panda_Impl { 121 int version; 122 123 es2panda_Config *(*CreateConfig)(int argc, char const **argv); 124 void (*DestroyConfig)(es2panda_Config *config); 125 126 es2panda_Context *(*CreateContextFromFile)(es2panda_Config *config, char const *source_file_name); 127 es2panda_Context *(*CreateContextFromString)(es2panda_Config *config, char const *source, char const *file_name); 128 es2panda_Context *(*ProceedToState)(es2panda_Context *context, es2panda_ContextState state); // context is consumed 129 void (*DestroyContext)(es2panda_Context *context); 130 131 es2panda_ContextState (*ContextState)(es2panda_Context *context); 132 char const *(*ContextErrorMessage)(es2panda_Context *context); 133 134 es2panda_Program *(*ContextProgram)(es2panda_Context *context); 135 es2panda_AstNode *(*ProgramAst)(es2panda_Program *program); 136 es2panda_ExternalSource **(*ProgramExternalSources)(es2panda_Program *program, size_t *len_p); 137 char const *(*ExternalSourceName)(es2panda_ExternalSource *e_source); 138 es2panda_Program **(*ExternalSourcePrograms)(es2panda_ExternalSource *e_source, size_t *len_p); 139 void (*AstNodeForEach)(es2panda_AstNode *ast, void (*func)(es2panda_AstNode *, void *), void *arg); 140 141 #define SET_NUMBER_LITERAL_DECL(name, type) bool (*SetNumberLiteral##name)(es2panda_AstNode * node, type new_value) 142 143 SET_NUMBER_LITERAL_DECL(Int, int32_t); 144 SET_NUMBER_LITERAL_DECL(Long, int64_t); 145 SET_NUMBER_LITERAL_DECL(Double, double); 146 SET_NUMBER_LITERAL_DECL(Float, float); 147 148 #undef SET_NUMBER_LITERAL_DECL 149 150 void *(*AllocMemory)(es2panda_Context *context, size_t numberOfElements, size_t sizeOfElement); 151 es2panda_SourcePosition *(*CreateSourcePosition)(es2panda_Context *context, size_t index, size_t line); 152 es2panda_SourceRange *(*CreateSourceRange)(es2panda_Context *context, es2panda_SourcePosition *start, 153 es2panda_SourcePosition *end); 154 size_t (*SourcePositionIndex)(es2panda_Context *context, es2panda_SourcePosition *position); 155 size_t (*SourcePositionLine)(es2panda_Context *context, es2panda_SourcePosition *position); 156 es2panda_SourcePosition *(*SourceRangeStart)(es2panda_Context *context, es2panda_SourceRange *range); 157 es2panda_SourcePosition *(*SourceRangeEnd)(es2panda_Context *context, es2panda_SourceRange *range); 158 159 // CC-OFFNXT(G.INC.08) project code style 160 #include "generated/es2panda_lib/es2panda_lib_decl.inc" 161 }; 162 163 struct es2panda_Impl const *es2panda_GetImpl(int version); 164 165 // NOLINTEND 166 167 #ifdef __cplusplus 168 } 169 #endif 170 171 #endif 172