diff --git a/src/build.js b/src/build.js index c260593..f858961 100644 --- a/src/build.js +++ b/src/build.js @@ -37,15 +37,22 @@ function build(ctx) { ctx.addConstant(ctx.F.zero); ctx.addConstant(ctx.F.one); + if (ctx.verbose) console.log("buildHeader..."); buildHeader(ctx); + if (ctx.verbose) console.log("buildEntryTables..."); buildEntryTables(ctx); ctx.globalNames = ctx.uniqueNames; + if (ctx.verbose) console.log("buildCode..."); buildCode(ctx); + if (ctx.verbose) console.log("buildComponentsArray..."); buildComponentsArray(ctx); + if (ctx.verbose) console.log("buildMapIsInput..."); buildMapIsInput(ctx); + + if (ctx.verbose) console.log("buildWit2Sig..."); buildWit2Sig(ctx); } @@ -56,6 +63,7 @@ function buildEntryTables(ctx) { const codes_componentEntries = []; const definedHashMaps = {}; for (let i=0; i=0) continue; // If has an alias, continue.. assert(typeof outIdx != "undefined", `Signal ${i} does not have index`); diff --git a/src/compiler.js b/src/compiler.js index c725e14..853dde8 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -119,6 +119,16 @@ async function compile(srcFile, options) { throw(ctx.error); } + if (options.r1csFileName) { + measures.generateR1cs = -performance.now(); + await buildR1cs(ctx, options.r1csFileName); + measures.generateR1cs += performance.now(); + } + + if (ctx.error) throw(ctx.error); + + delete ctx.constraints; // Liberate memory. + if (options.cSourceWriteStream) { if (ctx.verbose) console.log("Generating c..."); measures.generateC = -performance.now(); @@ -131,6 +141,8 @@ async function compile(srcFile, options) { // await new Promise(fulfill => options.cSourceWriteStream.on("finish", fulfill)); } + if (ctx.error) throw(ctx.error); + if ((options.wasmWriteStream)||(options.watWriteStream)) { if (ctx.verbose) console.log("Generating wasm..."); measures.generateWasm = -performance.now(); @@ -152,12 +164,6 @@ async function compile(srcFile, options) { // const mainCode = gen(ctx,ast); if (ctx.error) throw(ctx.error); - if (options.r1csFileName) { - measures.generateR1cs = -performance.now(); - await buildR1cs(ctx, options.r1csFileName); - measures.generateR1cs += performance.now(); - } - if (options.symWriteStream) { measures.generateSyms = -performance.now(); const rdStream = buildSyms(ctx);