Skip to content

Commit

Permalink
Merge pull request #5 from vshymanskyy/main
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Dec 29, 2021
2 parents 0c027a6 + c5cd736 commit cd7d34f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions c.c
Original file line number Diff line number Diff line change
Expand Up @@ -3035,11 +3035,15 @@ wasmCWriteFunctionExport(
const WasmModule* module,
WasmExport export,
WasmFunction function,
bool external,
bool pretty
) {
const WasmFunctionType functionType =
module->functionTypes.functionTypes[function.functionTypeIndex];

if (external) {
fputs("extern ", file);
}
fputs(wasmCGetReturnType(functionType), file);
fputs(" (*", file);
wasmCWriteExportName(file, export.name);
Expand All @@ -3052,8 +3056,12 @@ static
void
wasmCWriteMemoryExport(
FILE* file,
WasmExport export
WasmExport export,
bool external
) {
if (external) {
fputs("extern ", file);
}
fputs("wasmMemory (*", file);
wasmCWriteExportName(file, export.name);
fputs(");\n\n", file);
Expand All @@ -3064,7 +3072,8 @@ void
wasmCWriteExports(
FILE* file,
const WasmModule* module,
bool pretty
bool pretty,
bool external
) {
U32 exportIndex = 0;
for (; exportIndex < module->exports.count; exportIndex++) {
Expand All @@ -3074,11 +3083,11 @@ wasmCWriteExports(
U32 functionImportCount = module->functionImports.length;
U32 functionIndex = export.index - functionImportCount;
const WasmFunction function = module->functions.functions[functionIndex];
wasmCWriteFunctionExport(file, module, export, function, pretty);
wasmCWriteFunctionExport(file, module, export, function, external, pretty);
break;
}
case wasmExportKindMemory: {
wasmCWriteMemoryExport(file, export);
wasmCWriteMemoryExport(file, export, external);
break;
}

Expand All @@ -3096,6 +3105,8 @@ wasmCWriteInitExports(
) {
U32 exportIndex = 0;

wasmCWriteExports(file, module, pretty, false);

fputs("static void initExports(void) {\n", file);

for (; exportIndex < module->exports.count; exportIndex++) {
Expand Down Expand Up @@ -3384,7 +3395,7 @@ wasmCWriteModuleDeclarations(
wasmCWriteGlobalImports(file, module);
wasmCWriteGlobals(file, module, keyword);

wasmCWriteExports(file, module, pretty);
wasmCWriteExports(file, module, pretty, true);
}

static
Expand Down

0 comments on commit cd7d34f

Please sign in to comment.