From edd9cd50b8a572dc0d51ba6b151fbb3a9c56eb9a Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Sat, 7 Sep 2024 22:33:12 +0200 Subject: [PATCH] Dont print AST more than we need to --- src/index.mjs | 2 +- src/normalize/phase2.mjs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.mjs b/src/index.mjs index 6b2c728242..a9620883d6 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -279,7 +279,7 @@ export function preval({ entryPointFile, stdio, verbose, verboseTracing, resolve firstAfterParse = false; - changed = phase2(program, fdata, resolve, req, prng, {implicitThisIdent: options.implicitThisIdent, prngSeed: rngSeed}); + changed = phase2(program, fdata, resolve, req, passes, phase1s, verboseTracing, prng, {implicitThisIdent: options.implicitThisIdent, prngSeed: rngSeed}); options?.onAfterPhase(2, passes, phaseLoop, fdata, changed, options); if (!changed) { // Force a normalize pass before moving to phase3. Loop if it changed anything anyways. diff --git a/src/normalize/phase2.mjs b/src/normalize/phase2.mjs index 6012c62ab5..9734cfade7 100644 --- a/src/normalize/phase2.mjs +++ b/src/normalize/phase2.mjs @@ -113,10 +113,13 @@ import { freeFuncs } from '../reduce_static/free_funcs.mjs'; // - should Program always have a block just to eliminate the Program? That's not going to fix function boundaries though but maybe it is more consistent anyways? // - should loops always explicitly end with a continue statement? does that matter? -export function phase2(program, fdata, resolve, req, prng, options) { +export function phase2(program, fdata, resolve, req, passes, phase1s, verboseTracing, prng, options) { const ast = fdata.tenkoOutput.ast; group('\n\n\n##################################\n## phase2 :: ' + fdata.fname + '\n##################################\n\n\n'); - if (VERBOSE_TRACING) vlog('\nCurrent state (before phase2)\n--------------\n' + fmat(tmat(ast)) + '\n--------------\n'); + // Dont print this again when phase1 is printing almost nothing + if (!(!verboseTracing && (passes > 1 || phase1s > 1))) { + if (VERBOSE_TRACING) vlog('\nCurrent state (before phase2)\n--------------\n' + fmat(tmat(ast)) + '\n--------------\n'); + } vlog('\n\n\n##################################\n## phase2 :: ' + fdata.fname + '\n##################################\n\n\n'); {