Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decls in decls.h + add exported definitions to inits.c #5

Merged
merged 1 commit into from
Dec 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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