@@ -4266,31 +4266,68 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
4266
4266
export_type -> kind = aot_export -> kind ;
4267
4267
switch (export_type -> kind ) {
4268
4268
case WASM_IMPORT_EXPORT_KIND_FUNC :
4269
- export_type -> u .func_type =
4270
- (AOTFuncType * )aot_module
4271
- -> types [aot_module -> func_type_indexes
4272
- [aot_export -> index
4273
- - aot_module -> import_func_count ]];
4269
+ {
4270
+ if (aot_export -> index < aot_module -> import_func_count ) {
4271
+ export_type -> u .func_type =
4272
+ (AOTFuncType * )aot_module
4273
+ -> import_funcs [aot_export -> index ]
4274
+ .func_type ;
4275
+ }
4276
+ else {
4277
+ export_type -> u .func_type =
4278
+ (AOTFuncType * )aot_module
4279
+ -> types [aot_module -> func_type_indexes
4280
+ [aot_export -> index
4281
+ - aot_module -> import_func_count ]];
4282
+ }
4274
4283
break ;
4284
+ }
4275
4285
case WASM_IMPORT_EXPORT_KIND_GLOBAL :
4276
- export_type -> u .global_type =
4277
- & aot_module
4278
- -> globals [aot_export -> index
4279
- - aot_module -> import_global_count ]
4280
- .type ;
4286
+ {
4287
+ if (aot_export -> index < aot_module -> import_global_count ) {
4288
+ export_type -> u .global_type =
4289
+ & aot_module -> import_globals [aot_export -> index ].type ;
4290
+ }
4291
+ else {
4292
+ export_type -> u .global_type =
4293
+ & aot_module
4294
+ -> globals [aot_export -> index
4295
+ - aot_module -> import_global_count ]
4296
+ .type ;
4297
+ }
4281
4298
break ;
4299
+ }
4282
4300
case WASM_IMPORT_EXPORT_KIND_TABLE :
4283
- export_type -> u .table_type =
4284
- & aot_module
4285
- -> tables [aot_export -> index
4286
- - aot_module -> import_table_count ]
4287
- .table_type ;
4301
+ {
4302
+ if (aot_export -> index < aot_module -> import_table_count ) {
4303
+ export_type -> u .table_type =
4304
+ & aot_module -> import_tables [aot_export -> index ]
4305
+ .table_type ;
4306
+ }
4307
+ else {
4308
+ export_type -> u .table_type =
4309
+ & aot_module
4310
+ -> tables [aot_export -> index
4311
+ - aot_module -> import_table_count ]
4312
+ .table_type ;
4313
+ }
4288
4314
break ;
4315
+ }
4289
4316
case WASM_IMPORT_EXPORT_KIND_MEMORY :
4290
- export_type -> u .memory_type =
4291
- & aot_module -> memories [aot_export -> index
4292
- - aot_module -> import_memory_count ];
4317
+ {
4318
+ if (aot_export -> index < aot_module -> import_memory_count ) {
4319
+ export_type -> u .memory_type =
4320
+ & aot_module -> import_memories [aot_export -> index ]
4321
+ .mem_type ;
4322
+ }
4323
+ else {
4324
+ export_type -> u .memory_type =
4325
+ & aot_module
4326
+ -> memories [aot_export -> index
4327
+ - aot_module -> import_memory_count ];
4328
+ }
4293
4329
break ;
4330
+ }
4294
4331
default :
4295
4332
bh_assert (0 );
4296
4333
break ;
@@ -4312,31 +4349,76 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
4312
4349
export_type -> kind = wasm_export -> kind ;
4313
4350
switch (export_type -> kind ) {
4314
4351
case WASM_IMPORT_EXPORT_KIND_FUNC :
4315
- export_type -> u .func_type =
4316
- wasm_module
4317
- -> functions [wasm_export -> index
4318
- - wasm_module -> import_function_count ]
4319
- -> func_type ;
4352
+ {
4353
+ if (wasm_export -> index < wasm_module -> import_function_count ) {
4354
+ export_type -> u .func_type =
4355
+ (WASMFuncType * )wasm_module
4356
+ -> import_functions [wasm_export -> index ]
4357
+ .u .function .func_type ;
4358
+ }
4359
+ else {
4360
+ export_type -> u .func_type =
4361
+ wasm_module
4362
+ -> functions [wasm_export -> index
4363
+ - wasm_module -> import_function_count ]
4364
+ -> func_type ;
4365
+ }
4366
+
4320
4367
break ;
4368
+ }
4321
4369
case WASM_IMPORT_EXPORT_KIND_GLOBAL :
4322
- export_type -> u .global_type =
4323
- & wasm_module
4324
- -> globals [wasm_export -> index
4325
- - wasm_module -> import_global_count ]
4326
- .type ;
4370
+ {
4371
+ if (wasm_export -> index < wasm_module -> import_global_count ) {
4372
+ export_type -> u .global_type =
4373
+ (WASMGlobalType * )& wasm_module
4374
+ -> import_globals [wasm_export -> index ]
4375
+ .u .global .type ;
4376
+ }
4377
+ else {
4378
+ export_type -> u .global_type =
4379
+ & wasm_module
4380
+ -> globals [wasm_export -> index
4381
+ - wasm_module -> import_global_count ]
4382
+ .type ;
4383
+ }
4384
+
4327
4385
break ;
4386
+ }
4328
4387
case WASM_IMPORT_EXPORT_KIND_TABLE :
4329
- export_type -> u .table_type =
4330
- & wasm_module
4331
- -> tables [wasm_export -> index
4332
- - wasm_module -> import_table_count ]
4333
- .table_type ;
4388
+ {
4389
+ if (wasm_export -> index < wasm_module -> import_table_count ) {
4390
+ export_type -> u .table_type =
4391
+ (WASMTableType * )& wasm_module
4392
+ -> import_tables [wasm_export -> index ]
4393
+ .u .table .table_type ;
4394
+ }
4395
+ else {
4396
+ export_type -> u .table_type =
4397
+ & wasm_module
4398
+ -> tables [wasm_export -> index
4399
+ - wasm_module -> import_table_count ]
4400
+ .table_type ;
4401
+ }
4402
+
4334
4403
break ;
4404
+ }
4335
4405
case WASM_IMPORT_EXPORT_KIND_MEMORY :
4336
- export_type -> u .memory_type =
4337
- & wasm_module -> memories [wasm_export -> index
4338
- - wasm_module -> import_memory_count ];
4406
+ {
4407
+ if (wasm_export -> index < wasm_module -> import_memory_count ) {
4408
+ export_type -> u .memory_type =
4409
+ (WASMMemoryType * )& wasm_module
4410
+ -> import_memories [wasm_export -> index ]
4411
+ .u .memory .mem_type ;
4412
+ }
4413
+ else {
4414
+ export_type -> u .memory_type =
4415
+ & wasm_module
4416
+ -> memories [wasm_export -> index
4417
+ - wasm_module -> import_memory_count ];
4418
+ }
4419
+
4339
4420
break ;
4421
+ }
4340
4422
default :
4341
4423
bh_assert (0 );
4342
4424
break ;
0 commit comments