1 /* 2 * Copyright (c) 2021 - 2023 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_LIB 17 #define ES2PANDA_LIB 18 19 // Switch off the linter for C header 20 // NOLINTBEGIN 21 22 #include <stdbool.h> 23 #include <stddef.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define ES2PANDA_LIB_VERSION 1 30 31 typedef struct es2panda_Config es2panda_Config; 32 typedef struct es2panda_Context es2panda_Context; 33 34 typedef struct es2panda_Program es2panda_Program; 35 typedef struct es2panda_ExternalSource es2panda_ExternalSource; 36 typedef struct es2panda_AstNode es2panda_AstNode; 37 typedef struct es2panda_Type es2panda_Type; 38 typedef struct es2panda_Variable es2panda_Variable; 39 typedef struct es2panda_Scope es2panda_Scope; 40 41 enum es2panda_ContextState { 42 ES2PANDA_STATE_NEW, 43 ES2PANDA_STATE_PARSED, 44 ES2PANDA_STATE_SCOPE_INITED, 45 ES2PANDA_STATE_CHECKED, 46 ES2PANDA_STATE_LOWERED, 47 ES2PANDA_STATE_ASM_GENERATED, 48 ES2PANDA_STATE_BIN_GENERATED, 49 50 ES2PANDA_STATE_ERROR 51 }; 52 typedef enum es2panda_ContextState es2panda_ContextState; 53 54 // NB: has to be synchronized with astNode.h 55 enum es2panda_ModifierFlags { 56 ES2PANDA_MODIFIER_NONE = 0U, 57 ES2PANDA_MODIFIER_STATIC = 1U << 0U, 58 ES2PANDA_MODIFIER_ASYNC = 1U << 1U, 59 ES2PANDA_MODIFIER_PUBLIC = 1U << 2U, 60 ES2PANDA_MODIFIER_PROTECTED = 1U << 3U, 61 ES2PANDA_MODIFIER_PRIVATE = 1U << 4U, 62 ES2PANDA_MODIFIER_DECLARE = 1U << 5U, 63 ES2PANDA_MODIFIER_READONLY = 1U << 6U, 64 ES2PANDA_MODIFIER_OPTIONAL = 1U << 7U, 65 ES2PANDA_MODIFIER_DEFINITE = 1U << 8U, 66 ES2PANDA_MODIFIER_ABSTRACT = 1U << 9U, 67 ES2PANDA_MODIFIER_CONST = 1U << 10U, 68 ES2PANDA_MODIFIER_FINAL = 1U << 11U, 69 ES2PANDA_MODIFIER_NATIVE = 1U << 12U, 70 ES2PANDA_MODIFIER_OVERRIDE = 1U << 13U, 71 ES2PANDA_MODIFIER_CONSTRUCTOR = 1U << 14U, 72 ES2PANDA_MODIFIER_SYNCHRONIZED = 1U << 15U, 73 ES2PANDA_MODIFIER_FUNCTIONAL = 1U << 16U, 74 ES2PANDA_MODIFIER_IN = 1U << 17U, 75 ES2PANDA_MODIFIER_OUT = 1U << 18U, 76 ES2PANDA_MODIFIER_INTERNAL = 1U << 19U, 77 ES2PANDA_MODIFIER_NULL_ASSIGNABLE = 1U << 20U, 78 ES2PANDA_MODIFIER_UNDEFINED_ASSIGNABLE = 1U << 21U, 79 ES2PANDA_MODIFIER_EXPORT = 1U << 22U, 80 ES2PANDA_MODIFIER_SETTER = 1U << 23U, 81 ES2PANDA_MODIFIER_DEFAULT_EXPORT = 1U << 24U, 82 }; 83 typedef enum es2panda_ModifierFlags es2panda_ModifierFlags; 84 85 // Has to be synchronized with astNode.h 86 enum es2panda_ScriptFunctionFlags { 87 ES2PANDA_SCRIPT_FUNCTION_NONE = 0, 88 ES2PANDA_SCRIPT_FUNCTION_GENERATOR = 1U << 0U, 89 ES2PANDA_SCRIPT_FUNCTION_ASYNC = 1U << 1U, 90 ES2PANDA_SCRIPT_FUNCTION_ARROW = 1U << 2U, 91 ES2PANDA_SCRIPT_FUNCTION_EXPRESSION = 1U << 3U, 92 ES2PANDA_SCRIPT_FUNCTION_OVERLOAD = 1U << 4U, 93 ES2PANDA_SCRIPT_FUNCTION_CONSTRUCTOR = 1U << 5U, 94 ES2PANDA_SCRIPT_FUNCTION_METHOD = 1U << 6U, 95 ES2PANDA_SCRIPT_FUNCTION_STATIC_BLOCK = 1U << 7U, 96 ES2PANDA_SCRIPT_FUNCTION_HIDDEN = 1U << 8U, 97 ES2PANDA_SCRIPT_FUNCTION_IMPLICIT_SUPER_CALL_NEEDED = 1U << 9U, 98 ES2PANDA_SCRIPT_FUNCTION_ENUM = 1U << 10U, 99 ES2PANDA_SCRIPT_FUNCTION_EXTERNAL = 1U << 11U, 100 ES2PANDA_SCRIPT_FUNCTION_PROXY = 1U << 12U, 101 ES2PANDA_SCRIPT_FUNCTION_THROWS = 1U << 13U, 102 ES2PANDA_SCRIPT_FUNCTION_RETHROWS = 1U << 14U, 103 ES2PANDA_SCRIPT_FUNCTION_GETTER = 1U << 15U, 104 ES2PANDA_SCRIPT_FUNCTION_SETTER = 1U << 16U, 105 ES2PANDA_SCRIPT_FUNCTION_DEFAULT_PARAM_PROXY = 1U << 17U, 106 ES2PANDA_SCRIPT_FUNCTION_ENTRY_POINT = 1U << 18U, 107 ES2PANDA_SCRIPT_FUNCTION_INSTANCE_EXTENSION_METHOD = 1U << 19U, 108 ES2PANDA_SCRIPT_FUNCTION_HAS_RETURN = 1U << 20U 109 }; 110 typedef enum es2panda_ScriptFunctionFlags es2panda_ScriptFunctionFlags; 111 112 // Needs to be synchronized with memberExpression.h 113 enum es2panda_MemberExpressionKind { 114 ES2PANDA_MEMBER_EXPRESSION_KIND_NONE = 0, 115 ES2PANDA_MEMBER_EXPRESSION_KIND_ELEMENT_ACCESS = 1U << 0U, 116 ES2PANDA_MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS = 1U << 1U, 117 ES2PANDA_MEMBER_EXPRESSION_KIND_GETTER = 1U << 2U, 118 ES2PANDA_MEMBER_EXPRESSION_KIND_SETTER = 1U << 3U 119 }; 120 typedef enum es2panda_MemberExpressionKind es2panda_MemberExpressionKind; 121 122 struct es2panda_Impl { 123 int version; 124 125 es2panda_Config *(*CreateConfig)(int argc, char const **argv); 126 void (*DestroyConfig)(es2panda_Config *config); 127 128 es2panda_Context *(*CreateContextFromFile)(es2panda_Config *config, char const *source_file_name); 129 es2panda_Context *(*CreateContextFromString)(es2panda_Config *config, char const *source, char const *file_name); 130 es2panda_Context *(*ProceedToState)(es2panda_Context *context, es2panda_ContextState state); // context is consumed 131 void (*DestroyContext)(es2panda_Context *context); 132 133 es2panda_ContextState (*ContextState)(es2panda_Context *context); 134 char const *(*ContextErrorMessage)(es2panda_Context *context); 135 136 es2panda_Program *(*ContextProgram)(es2panda_Context *context); 137 es2panda_AstNode *(*ProgramAst)(es2panda_Program *program); 138 es2panda_ExternalSource **(*ProgramExternalSources)(es2panda_Program *program, size_t *len_p); 139 char const *(*ExternalSourceName)(es2panda_ExternalSource *e_source); 140 es2panda_Program **(*ExternalSourcePrograms)(es2panda_ExternalSource *e_source, size_t *len_p); 141 142 es2panda_Type *(*AstNodeType)(es2panda_AstNode *ast); 143 void (*AstNodeSetType)(es2panda_AstNode *ast, es2panda_Type *type); 144 145 es2panda_AstNode *const *(*AstNodeDecorators)(es2panda_AstNode *ast, size_t *size_p); 146 void (*AstNodeSetDecorators)(es2panda_Context *context, es2panda_AstNode *ast, es2panda_AstNode **decorators, 147 size_t n_decorators); 148 149 es2panda_ModifierFlags (*AstNodeModifierFlags)(es2panda_AstNode *ast); 150 151 void (*AstNodeForEach)(es2panda_AstNode *ast, void (*func)(es2panda_AstNode *, void *), void *arg); 152 153 bool (*IsArrowFunctionExpression)(es2panda_AstNode *ast); 154 es2panda_AstNode *(*CreateArrowFunctionExpression)(es2panda_Context *context, es2panda_AstNode *script_function); 155 es2panda_AstNode *(*ArrowFunctionExpressionScriptFunction)(es2panda_AstNode *ast); 156 157 bool (*IsAsExpression)(es2panda_AstNode *ast); 158 es2panda_AstNode *(*CreateAsExpression)(es2panda_Context *context, es2panda_AstNode *expr, 159 es2panda_AstNode *type_annotation, bool is_const); 160 es2panda_AstNode *(*AsExpressionExpr)(es2panda_AstNode *ast); 161 es2panda_AstNode *(*AsExpressionTypeAnnotation)(es2panda_AstNode *ast); 162 bool (*AsExpressionIsConst)(es2panda_AstNode *ast); 163 void (*AsExpressionSetExpr)(es2panda_AstNode *ast, es2panda_AstNode *expr); 164 void (*AsExpressionSetTypeAnnotation)(es2panda_AstNode *ast, es2panda_AstNode *type_annotation); 165 166 bool (*IsAssignmentExpression)(es2panda_AstNode *ast); 167 es2panda_AstNode *(*CreateAssignmentExpression)(es2panda_Context *context, es2panda_AstNode *left, 168 es2panda_AstNode *right, char const *operator_type); 169 es2panda_AstNode *(*AssignmentExpressionLeft)(es2panda_AstNode *ast); 170 es2panda_AstNode *(*AssignmentExpressionRight)(es2panda_AstNode *ast); 171 char const *(*AssignmentExpressionOperatorType)(es2panda_AstNode *ast); 172 void (*AssignmentExpressionSetOperatorType)(es2panda_AstNode *ast, char const *operator_type); 173 174 bool (*IsBinaryExpression)(es2panda_AstNode *ast); 175 es2panda_AstNode *(*CreatebinaryExpression)(es2panda_Context *context, es2panda_AstNode *left, 176 es2panda_AstNode *right, char const *operator_type); 177 es2panda_AstNode *(*BinaryExpressionLeft)(es2panda_AstNode *ast); 178 es2panda_AstNode *(*BinaryExpressionRight)(es2panda_AstNode *ast); 179 char const *(*BinaryExpressionOperator)(es2panda_AstNode *ast); 180 void (*BinaryExpressionSetOperator)(es2panda_AstNode *ast, char const *operator_type); 181 182 bool (*IsBlockStatement)(es2panda_AstNode *ast); 183 es2panda_AstNode *(*CreateBlockStatement)(es2panda_Context *context); 184 es2panda_AstNode **(*BlockStatementStatements)(es2panda_AstNode *ast, size_t *size_p); 185 void (*BlockStatementAddStatement)(es2panda_AstNode *ast, es2panda_AstNode *statement); 186 187 bool (*IsCallExpression)(es2panda_AstNode *ast); 188 es2panda_AstNode *(*CreateCallExpression)(es2panda_Context *context, es2panda_AstNode *callee, 189 es2panda_AstNode *type_arguments, es2panda_AstNode **arguments, 190 size_t n_arguments, bool optional); 191 es2panda_AstNode const *(*CallExpressionCallee)(es2panda_AstNode *ast); 192 es2panda_AstNode const *(*CallExpressionTypeArguments)(es2panda_AstNode *ast); 193 es2panda_AstNode **(*CallExpressionArguments)(es2panda_AstNode *ast, size_t *size_p); 194 bool (*CallExpressionIsOptional)(es2panda_AstNode *ast); 195 void (*CallExpressionSetTypeArguments)(es2panda_AstNode *ast, es2panda_AstNode *type_arguments); 196 197 bool (*IsChainExpression)(es2panda_AstNode *ast); 198 es2panda_AstNode *(*CreateChainExpression)(es2panda_Context *context, es2panda_AstNode *child); 199 es2panda_AstNode const *(*ChainExpressionChild)(es2panda_AstNode *ast); 200 201 bool (*IsClassDeclaration)(es2panda_AstNode *ast); 202 es2panda_AstNode *(*CreateClassDeclaration)(es2panda_Context *context, es2panda_AstNode *definition); 203 es2panda_AstNode *(*ClassDeclarationDefinition)(es2panda_AstNode *ast); 204 205 bool (*IsClassDefinition)(es2panda_AstNode *ast); 206 es2panda_AstNode *(*CreateClassDefinition)(es2panda_Context *context, es2panda_AstNode *identifier, 207 es2panda_ModifierFlags flags); 208 es2panda_AstNode *(*ClassDefinitionIdentifier)(es2panda_AstNode *ast); 209 es2panda_AstNode *(*ClassDefinitionTypeParameters)(es2panda_AstNode *ast); 210 es2panda_AstNode *(*ClassDefinitionSuperClass)(es2panda_AstNode *ast); 211 es2panda_AstNode **(*ClassDefinitionImplements)(es2panda_AstNode *ast, size_t *size_p); 212 es2panda_AstNode *(*ClassDefinitionConstructor)(es2panda_AstNode *ast); 213 es2panda_AstNode **(*ClassDefinitionBody)(es2panda_AstNode *ast, size_t *size_p); 214 void (*ClassDefinitionSetIdentifier)(es2panda_AstNode *ast, es2panda_AstNode *identifier); 215 void (*ClassDefinitionSetTypeParameters)(es2panda_AstNode *ast, es2panda_AstNode *type_params); 216 void (*ClassDefinitionSetSuperClass)(es2panda_AstNode *ast, es2panda_AstNode *super_class); 217 void (*ClassDefinitionSetImplements)(es2panda_AstNode *ast, es2panda_AstNode **implements, size_t n_implements); 218 void (*ClassDefinitionAddImplements)(es2panda_AstNode *ast, es2panda_AstNode *implements); 219 void (*ClassDefinitionSetConstructor)(es2panda_AstNode *ast, es2panda_AstNode *constructor); 220 void (*ClassDefinitonSetBody)(es2panda_AstNode *ast, es2panda_AstNode **body, size_t n_elems); 221 void (*ClassDefinitonAddToBody)(es2panda_AstNode *ast, es2panda_AstNode *statement); 222 223 es2panda_AstNode *(*ClassElementKey)(es2panda_AstNode *ast); 224 es2panda_AstNode *(*ClassElementValue)(es2panda_AstNode *ast); 225 226 bool (*IsClassImplementsClause)(es2panda_AstNode *ast); 227 es2panda_AstNode *(*CreateClassImplementsClause)(es2panda_Context *context, es2panda_AstNode *expression, 228 es2panda_AstNode *type_arguments); 229 es2panda_AstNode *(*ClassImplementsClauseExpression)(es2panda_AstNode *ast); 230 es2panda_AstNode const *(*ClassImplementsClauseTypeArguments)(es2panda_AstNode *ast); 231 232 bool (*IsClassProperty)(es2panda_AstNode *ast); 233 es2panda_AstNode *(*CreateClassProperty)(es2panda_Context *context, es2panda_AstNode *key, es2panda_AstNode *value, 234 es2panda_AstNode *type_annotation, es2panda_ModifierFlags modifier_flags, 235 bool is_computed); 236 es2panda_AstNode *(*ClassPropertyTypeAnnotation)(es2panda_AstNode *ast); 237 238 bool (*IsExpressionStatement)(es2panda_AstNode *ast); 239 es2panda_AstNode *(*CreateExpressionStatement)(es2panda_Context *context, es2panda_AstNode *expression); 240 es2panda_AstNode *(*ExpressionStatementExpression)(es2panda_AstNode *ast); 241 242 bool (*IsFunctionDeclaration)(es2panda_AstNode *ast); 243 es2panda_AstNode *(*CreateFunctionDeclaration)(es2panda_Context *context, es2panda_AstNode *function); 244 es2panda_AstNode *(*FunctionDeclarationFunction)(es2panda_AstNode *ast); 245 246 bool (*IsFunctionExpression)(es2panda_AstNode *ast); 247 es2panda_AstNode *(*CreateFunctionExpression)(es2panda_Context *context, es2panda_AstNode *function); 248 es2panda_AstNode *(*FunctionExpressionFunction)(es2panda_AstNode *ast); 249 250 bool (*IsFunctionTypeNode)(es2panda_AstNode *ast); 251 es2panda_AstNode *(*CreateFunctionTypeNode)(es2panda_Context *context, es2panda_AstNode *type_params, 252 es2panda_AstNode **params, size_t n_params, 253 es2panda_AstNode *return_type, es2panda_ScriptFunctionFlags func_flags); 254 es2panda_AstNode const *(*FunctionTypeNodeTypeParams)(es2panda_AstNode *ast); 255 es2panda_AstNode *const *(*FunctionTypeNodeParams)(es2panda_AstNode *ast, size_t *size_p); 256 es2panda_AstNode *(*FunctionTypeNodeReturnType)(es2panda_AstNode *ast); 257 es2panda_ScriptFunctionFlags (*FunctionTypeNodeFlags)(es2panda_AstNode *ast); 258 259 bool (*IsIdentifier)(es2panda_AstNode *ast); 260 es2panda_AstNode *(*CreateIdentifier)(es2panda_Context *context, char const *name, 261 es2panda_AstNode *type_annotation); 262 char const *(*IdentifierName)(es2panda_Context *context, es2panda_AstNode *identifier); 263 es2panda_AstNode *(*IdentifierTypeAnnotation)(es2panda_AstNode *identifier); 264 es2panda_Variable *(*IdentifierVariable)(es2panda_AstNode *identifier); 265 void (*IdentifierSetVariable)(es2panda_AstNode *identifier, es2panda_Variable *variable); 266 267 bool (*IsIfStatement)(es2panda_AstNode *ast); 268 es2panda_AstNode *(*CreateIfStatement)(es2panda_Context *context, es2panda_AstNode *test, 269 es2panda_AstNode *consequent, es2panda_AstNode *alternate); 270 es2panda_AstNode const *(*IfStatementTest)(es2panda_AstNode *ast); 271 es2panda_AstNode const *(*IfStatementConsequent)(es2panda_AstNode *ast); 272 es2panda_AstNode const *(*IfStatementAlternate)(es2panda_AstNode *ast); 273 274 bool (*IsImportDeclaration)(es2panda_AstNode *ast); 275 es2panda_AstNode *(*CreateImportDeclaration)(es2panda_Context *context, es2panda_AstNode *source, 276 es2panda_AstNode **specifiers, size_t n_specifiers); 277 es2panda_AstNode const *(*ImportDeclarationSource)(es2panda_AstNode *ast); 278 es2panda_AstNode *const *(*ImportDeclarationSpecifiers)(es2panda_AstNode *ast, size_t *size_p); 279 280 bool (*IsImportExpression)(es2panda_AstNode *ast); 281 es2panda_AstNode *(*CreateImportExpression)(es2panda_Context *context, es2panda_AstNode *source); 282 es2panda_AstNode *(*ImportExpressionSource)(es2panda_AstNode *ast); 283 284 bool (*IsImportSpecifier)(es2panda_AstNode *ast); 285 es2panda_AstNode *(*CreateImportSpecifier)(es2panda_Context *context, es2panda_AstNode *imported, 286 es2panda_AstNode *local); 287 es2panda_AstNode *(*ImportSpecifierImported)(es2panda_AstNode *ast); 288 es2panda_AstNode *(*ImportSpecifierLocal)(es2panda_AstNode *ast); 289 290 bool (*IsMemberExpression)(es2panda_AstNode *ast); 291 es2panda_AstNode *(*CreateMemberExpression)(es2panda_Context *context, es2panda_AstNode *object, 292 es2panda_AstNode *property, es2panda_MemberExpressionKind kind, 293 bool is_computed, bool is_optional); 294 es2panda_AstNode *(*MemberExpressionObject)(es2panda_AstNode *ast); 295 es2panda_AstNode *(*MemberExpressionProperty)(es2panda_AstNode *ast); 296 es2panda_MemberExpressionKind (*MemberExpressionKind)(es2panda_AstNode *ast); 297 bool (*MemberExpressionIsComputed)(es2panda_AstNode *ast); 298 bool (*MemberExpressionIsOptional)(es2panda_AstNode *ast); 299 300 bool (*IsMethodDefinition)(es2panda_AstNode *ast); 301 es2panda_AstNode *(*CreateMethodDefinition)(es2panda_Context *context, char const *kind, es2panda_AstNode *key, 302 es2panda_AstNode *value, es2panda_ModifierFlags modifiers, 303 bool is_computed); 304 char const *(*MethodDefinitionKind)(es2panda_AstNode *ast); 305 es2panda_AstNode const *(*MethodDefinitionKey)(es2panda_AstNode *ast); 306 es2panda_AstNode const *(*MethodDefinitionValue)(es2panda_AstNode *ast); 307 es2panda_ModifierFlags (*MethodDefinitionModifiers)(es2panda_AstNode *ast); 308 bool (*MethodDefinitionIsComputed)(es2panda_AstNode *ast); 309 es2panda_AstNode *const *(*MethodDefinitionOverloads)(es2panda_AstNode *ast, size_t *size_p); 310 void (*MethodDefinitionSetOverloads)(es2panda_AstNode *ast, es2panda_AstNode **overloads, size_t n_overloads); 311 void (*MethodDefinitionAddOverload)(es2panda_AstNode *ast, es2panda_AstNode *overload); 312 313 bool (*IsNewClassInstanceExpression)(es2panda_AstNode *ast); 314 es2panda_AstNode *(*CreateNewClassInstanceExpression)(es2panda_Context *context, es2panda_AstNode *type_reference, 315 es2panda_AstNode **arguments, size_t n_arguments, 316 es2panda_AstNode *class_definition); 317 es2panda_AstNode *(*NewClassInstanceExpressionTypeReference)(es2panda_AstNode *ast); 318 es2panda_AstNode *const *(*NewClassInstanceExpressionArguments)(es2panda_AstNode *ast, size_t *size_p); 319 es2panda_AstNode *(*NewClassInstanceExpressionClassDefinition)(es2panda_AstNode *ast); 320 321 bool (*IsNewArrayInstanceExpression)(es2panda_AstNode *ast); 322 es2panda_AstNode *(*CreateNewArrayInstanceExpression)(es2panda_Context *context, es2panda_AstNode *type_reference, 323 es2panda_AstNode *dimension); 324 es2panda_AstNode *(*NewArrayInstanceExpressionTypeReference)(es2panda_AstNode *ast); 325 es2panda_AstNode *(*NewArrayInstanceExpressionDimension)(es2panda_AstNode *ast); 326 327 bool (*IsNewMultiDimArrayInstanceExpression)(es2panda_AstNode *ast); 328 es2panda_AstNode *(*CreateNewMultiDimArrayInstanceExpression)(es2panda_Context *context, 329 es2panda_AstNode *type_reference, 330 es2panda_AstNode **dimensions, size_t n_dimensions); 331 es2panda_AstNode *(*NewMultiDimArrayInstanceExpressionTypeReference)(es2panda_AstNode *ast); 332 es2panda_AstNode *const *(*NewMultiDimArrayInstanceExpressionDimensions)(es2panda_AstNode *ast, size_t *size_p); 333 334 bool (*IsNonNullExpression)(es2panda_AstNode *ast); 335 bool (*IsNumberLiteral)(es2panda_AstNode *ast); 336 bool (*IsObjectExpression)(es2panda_AstNode *ast); 337 338 bool (*IsParameterDeclaration)(es2panda_AstNode *ast); 339 es2panda_AstNode *(*CreateParameterDeclaration)(es2panda_Context *context, es2panda_AstNode *identifier_or_spread, 340 es2panda_AstNode *initializer); 341 es2panda_AstNode *(*ParameterDeclarationIdentifierOrSpread)(es2panda_AstNode *ast); 342 es2panda_AstNode *(*ParameterDeclarationInitializer)(es2panda_AstNode *ast); 343 344 bool (*IsPrimitiveTypeNode)(es2panda_AstNode *ast); 345 es2panda_AstNode *(*CreatePrimitiveTypeNode)(es2panda_Context *context, char const *type); 346 char const *(*PrimitiveTypeNodeType)(es2panda_AstNode *ast); 347 348 bool (*IsReturnStatement)(es2panda_AstNode *ast); 349 es2panda_AstNode *(*CreatereturnStatement)(es2panda_Context *context, es2panda_AstNode *argument); 350 es2panda_AstNode *(*ReturnStatementArgument)(es2panda_AstNode *ast); 351 es2panda_Type *(*ReturnStatementReturnType)(es2panda_AstNode *ast); 352 353 bool (*IsScriptFunction)(es2panda_AstNode *ast); 354 es2panda_AstNode *(*CreateScriptFunction)(es2panda_Context *context, es2panda_AstNode *type_params, 355 es2panda_AstNode **params, size_t n_params, 356 es2panda_AstNode *return_type_annotation, 357 es2panda_ScriptFunctionFlags function_flags, 358 es2panda_ModifierFlags modifier_flags, bool is_declare); 359 es2panda_AstNode *(*ScriptFunctionTypeParams)(es2panda_AstNode *ast); 360 es2panda_AstNode *const *(*ScriptFunctionParams)(es2panda_AstNode *ast, size_t *size_p); 361 es2panda_AstNode *(*ScriptFunctionReturnTypeAnnotation)(es2panda_AstNode *ast); 362 es2panda_ScriptFunctionFlags (*ScriptFunctionScriptFunctionFlags)(es2panda_AstNode *ast); 363 bool (*ScriptFunctionIsDeclare)(es2panda_AstNode *ast); 364 es2panda_AstNode *(*ScriptFunctionIdentifier)(es2panda_AstNode *ast); 365 es2panda_AstNode *(*ScriptFunctionBody)(es2panda_AstNode *ast); 366 void (*ScriptFunctionSetIdentifier)(es2panda_AstNode *ast, es2panda_AstNode *ident); 367 void (*ScriptFunctionSetBody)(es2panda_AstNode *ast, es2panda_AstNode *body); 368 void (*ScriptFunctionSetParams)(es2panda_AstNode *ast, es2panda_AstNode **params, size_t n_params); 369 void (*ScripFunctionAddParam)(es2panda_AstNode *ast, es2panda_AstNode *param); 370 371 bool (*IsStringLiteral)(es2panda_AstNode *ast); 372 es2panda_AstNode *(*CreateStringLiteral)(es2panda_Context *context, char const *string); 373 char const *(*StringLiteralString)(es2panda_Context *context, es2panda_AstNode *ast); 374 375 bool (*IsThisExpression)(es2panda_AstNode *ast); 376 es2panda_AstNode *(*CreateThisExpression)(es2panda_Context *context); 377 378 bool (*IsTypeParameter)(es2panda_AstNode *ast); 379 es2panda_AstNode *(*CreateTypeParameter)(es2panda_Context *context, es2panda_AstNode *name, 380 es2panda_AstNode *constraint, es2panda_AstNode *defaultType); 381 es2panda_AstNode const *(*TypeParameterName)(es2panda_AstNode *ast); 382 es2panda_AstNode const *(*TypeParameterConstraint)(es2panda_AstNode *ast); 383 es2panda_AstNode const *(*TypeParameterDefaultType)(es2panda_AstNode *ast); 384 385 bool (*IsTypeParameterDeclaration)(es2panda_AstNode *ast); 386 es2panda_AstNode *(*CreateTypeParameterDeclaration)(es2panda_Context *context); 387 void (*TypeParameterDeclarationAddTypeParameter)(es2panda_AstNode *ast, es2panda_AstNode *type_parameter); 388 es2panda_AstNode *const *(*TypeParameterDeclarationTypeParameters)(es2panda_AstNode *ast, size_t *size_p); 389 390 bool (*IsTypeParameterInstantiation)(es2panda_AstNode *ast); 391 es2panda_AstNode *(*CreateTypeParameterInstantiation)(es2panda_Context *context, es2panda_AstNode **params, 392 size_t n_params); 393 es2panda_AstNode *const *(*TypeParameterInstantiationTypeParameters)(es2panda_AstNode *ast, size_t *size_p); 394 395 bool (*IsTypeReferenceNode)(es2panda_AstNode *ast); 396 es2panda_AstNode *(*CreateTypeReferenceNode)(es2panda_Context *context, es2panda_AstNode *part); 397 es2panda_AstNode *(*TypeRefrenceNodePart)(es2panda_AstNode *ast); 398 399 bool (*IsTypeReferencePart)(es2panda_AstNode *ast); 400 es2panda_AstNode *(*CreateTypeReferencePart)(es2panda_Context *context, es2panda_AstNode *name, 401 es2panda_AstNode *type_arguments, es2panda_AstNode *previous); 402 es2panda_AstNode *(*TypeReferencePartName)(es2panda_AstNode *ast); 403 es2panda_AstNode *(*TypeReferencePartTypeArguments)(es2panda_AstNode *ast); 404 es2panda_AstNode *(*TypeReferencePartPrevious)(es2panda_AstNode *ast); 405 406 bool (*IsUnionTypeNode)(es2panda_AstNode *ast); 407 es2panda_AstNode *(*CreateUnionTypeNode)(es2panda_Context *context, es2panda_AstNode **types, size_t n_types); 408 es2panda_AstNode *const *(*UnionTypeNodeTypes)(es2panda_AstNode *ast, size_t *size_p); 409 410 bool (*IsVariableDeclaration)(es2panda_AstNode *ast); 411 es2panda_AstNode *(*CreateVariableDeclaration)(es2panda_Context *context, char const *kind, 412 es2panda_AstNode **declarators, size_t n_declarators, 413 bool is_declare); 414 char const *(*VariableDeclarationKind)(es2panda_AstNode *ast); 415 es2panda_AstNode *const *(*VariableDeclarationDeclarators)(es2panda_AstNode *ast, size_t *size_p); 416 bool (*VariableDeclarationIsDeclare)(es2panda_AstNode *ast); 417 418 bool (*IsVariableDeclarator)(es2panda_AstNode *ast); 419 es2panda_AstNode *(*CreateVariableDeclarator)(es2panda_Context *context, es2panda_AstNode *identifier, 420 es2panda_AstNode *initializer); 421 es2panda_AstNode *(*VariableDeclaratorIdentifier)(es2panda_AstNode *ast); 422 es2panda_AstNode *(*VariableDeclaratorInitializer)(es2panda_AstNode *ast); 423 }; 424 425 struct es2panda_Impl const *es2panda_GetImpl(int version); 426 // NOLINTEND 427 428 #ifdef __cplusplus 429 } 430 #endif 431 432 #endif // ES2PANDA_LIB 433