Skip to content

Commit

Permalink
keep writing function implementations into main file by default
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Nov 6, 2023
1 parent f1dc205 commit 6196dc5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
52 changes: 36 additions & 16 deletions w2c2/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -5078,23 +5078,43 @@ wasmCWriteModuleImplementation(

/* Write implementations */

MUST (wasmCWriteModuleImplementationFiles(
module,
moduleName,
headerName,
staticFunctionIDs,
's',
options
))
if (options.functionsPerFile >= module->functions.count
&& dynamicFunctionIDs.length == 0)
{
WasmDebugLines debugLines = module->debugLines;

MUST (wasmCWriteModuleImplementationFiles(
module,
moduleName,
headerName,
dynamicFunctionIDs,
'd',
options
))
MUST (wasmCWriteFunctionImplementations(
file,
module,
moduleName,
&debugLines,
0,
(U32)staticFunctionIDs.length,
staticFunctionIDs,
options.pretty,
options.debug,
options.multipleModules
))
} else {

MUST (wasmCWriteModuleImplementationFiles(
module,
moduleName,
headerName,
staticFunctionIDs,
's',
options
))

MUST (wasmCWriteModuleImplementationFiles(
module,
moduleName,
headerName,
dynamicFunctionIDs,
'd',
options
))
}

/* Write initializations code */

Expand Down
8 changes: 4 additions & 4 deletions w2c2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ main(
referenceFunctionIDs = wasmSortedFunctionIDs(referenceReader.module->functions);

wasmSplitStaticAndDynamicFunctions(
functionIDs,
referenceFunctionIDs,
&staticFunctionIDs,
&dynamicFunctionIDs
functionIDs,
referenceFunctionIDs,
&staticFunctionIDs,
&dynamicFunctionIDs
);

total = dynamicFunctionIDs.length + staticFunctionIDs.length;
Expand Down

0 comments on commit 6196dc5

Please sign in to comment.