Skip to content

Commit 7ce2f75

Browse files
authored
add total build time to verbose output, harden dispatchNamedObject (#497)
`chad build -v foo.ts` now appends " in Xms" to the "Compiled: ..." line. Useful when something feels slow and you want to know without reaching for the shell's `time`. No behavior change at default verbosity. The one-line `return null;` added to `MethodCallGenerator.dispatchNamedObject` after the switch-with-default is a workaround for a native-compiler false positive in checkMissingReturns: any edit to compileNative's body shifts AST layout enough to trip it on dispatchNamedObject. The extra trailing return makes the function immune. Node compiler accepts the original code fine; this only affects the self-hosted path. Co-authored-by: cs01 <cs01@users.noreply.github.com>
1 parent 726e8f2 commit 7ce2f75

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/codegen/expressions/method-calls.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ export class MethodCallGenerator {
436436
default:
437437
return null;
438438
}
439+
return null;
439440
}
440441

441442
private handleYamlParse(expr: MethodCallNode, params: string[]): string {

src/native-compiler-lib.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ export function parseFileToAST(inputFile: string): string {
430430
}
431431

432432
export function compileNative(inputFile: string, outputFile: string): void {
433+
const phaseStart = Date.now();
433434
const execDir = path.dirname(path.resolve(process.argv0));
434435
const installedLibDir = execDir + "/lib";
435436
const isInstalled = fs.existsSync(installedLibDir + "/libgc.a");
@@ -939,7 +940,7 @@ export function compileNative(inputFile: string, outputFile: string): void {
939940

940941
fs.unlinkSync(objFile);
941942
if (verbose) {
942-
console.log("Compiled: " + outputFile);
943+
console.log("Compiled: " + outputFile + " in " + (Date.now() - phaseStart) + "ms");
943944
}
944945
}
945946

0 commit comments

Comments
 (0)