(generatedModule: W2CGeneratedModule)
| 17 | } |
| 18 | |
| 19 | function printCodegenStats(generatedModule: W2CGeneratedModule) { |
| 20 | const hglt = chalk.dim; |
| 21 | const { imports, exports } = generatedModule; |
| 22 | |
| 23 | function statsOf(set: GeneratedSymbol[]): string { |
| 24 | const highlight = chalk.dim; |
| 25 | const grouped = Object.groupBy( |
| 26 | set, |
| 27 | (s) => s.target.kind as GeneratedEntityKind |
| 28 | ); |
| 29 | const countOf = (type: GeneratedEntityKind) => grouped[type]?.length ?? 0; |
| 30 | return [ |
| 31 | `${highlight(countOf('function'))} functions`, |
| 32 | `${highlight(countOf('memory'))} memories`, |
| 33 | `${highlight(countOf('global'))} globals`, |
| 34 | `${highlight(countOf('table'))} tables`, |
| 35 | ].join(', '); |
| 36 | } |
| 37 | |
| 38 | consola.info(` Found ${hglt(imports.length)} imports (${statsOf(imports)})`); |
| 39 | consola.info(` Found ${hglt(exports.length)} exports (${statsOf(exports)})`); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Generates code for a single module. |
no test coverage detected