mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
BigArray in CBuild
This commit is contained in:
@@ -3,6 +3,7 @@ const utils = require("../../src/utils");
|
|||||||
const assert = require("assert");
|
const assert = require("assert");
|
||||||
const Scalar = require("ffjavascript").Scalar;
|
const Scalar = require("ffjavascript").Scalar;
|
||||||
const F1Field = require("ffjavascript").F1Field;
|
const F1Field = require("ffjavascript").F1Field;
|
||||||
|
const BigArray = require("../../src/bigarray");
|
||||||
|
|
||||||
function ref2src(c) {
|
function ref2src(c) {
|
||||||
if ((c[0] == "R")||(c[0] == "RI")) {
|
if ((c[0] == "R")||(c[0] == "RI")) {
|
||||||
@@ -341,16 +342,17 @@ class FunctionBuilderC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BuilderC {
|
class BuilderC {
|
||||||
constructor(p) {
|
constructor(p, verbose) {
|
||||||
this.F = new F1Field(p);
|
this.F = new F1Field(p);
|
||||||
|
|
||||||
this.hashMaps={};
|
this.hashMaps={};
|
||||||
this.componentEntriesTables={};
|
this.componentEntriesTables=new BigArray();
|
||||||
this.sizes ={};
|
this.sizes ={};
|
||||||
this.constants = [];
|
this.constants = [];
|
||||||
this.functions = [];
|
this.functions = [];
|
||||||
this.components = [];
|
this.components = new BigArray();
|
||||||
this.usedConstants = {};
|
this.usedConstants = {};
|
||||||
|
this.verbose = verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
setHeader(header) {
|
setHeader(header) {
|
||||||
@@ -363,7 +365,10 @@ class BuilderC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addComponentEntriesTable(name, cet) {
|
addComponentEntriesTable(name, cet) {
|
||||||
this.componentEntriesTables[name] = cet;
|
this.componentEntriesTables.push({
|
||||||
|
name: name,
|
||||||
|
cet: cet
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addSizes(name, accSizes) {
|
addSizes(name, accSizes) {
|
||||||
@@ -444,8 +449,10 @@ class BuilderC {
|
|||||||
|
|
||||||
_buildComponentEntriesTables(code) {
|
_buildComponentEntriesTables(code) {
|
||||||
code.push("// Component Entry tables");
|
code.push("// Component Entry tables");
|
||||||
for (let cetName in this.componentEntriesTables) {
|
for (let i=0; i< this.componentEntriesTables.length; i++) {
|
||||||
const cet = this.componentEntriesTables[cetName];
|
if ((this.verbose)&&(i%100000 ==0)) console.log(`_buildComponentEntriesTables ${i}/${this.componentEntriesTables.length}`);
|
||||||
|
const cetName = this.componentEntriesTables[i].name;
|
||||||
|
const cet = this.componentEntriesTables[i].cet;
|
||||||
|
|
||||||
code.push(`Circom_ComponentEntry ${cetName}[${cet.length}] = {`);
|
code.push(`Circom_ComponentEntry ${cetName}[${cet.length}] = {`);
|
||||||
for (let j=0; j<cet.length; j++) {
|
for (let j=0; j<cet.length; j++) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ function buildEntryTables(ctx) {
|
|||||||
|
|
||||||
const definedHashMaps = {};
|
const definedHashMaps = {};
|
||||||
for (let i=0; i<ctx.components.length; i++) {
|
for (let i=0; i<ctx.components.length; i++) {
|
||||||
if (ctx.verbose && (i%1000 ==0)) console.log(`buildEntryTables component: ${i}/${ctx.components.length}`);
|
if (ctx.verbose && (i%100000 ==0)) console.log(`buildEntryTables component: ${i}/${ctx.components.length}`);
|
||||||
const {htName, htMap} = addHashTable(i);
|
const {htName, htMap} = addHashTable(i);
|
||||||
|
|
||||||
const componentEntriesTableName = ctx.getUniqueName("_entryTable" + ctx.components[i].template);
|
const componentEntriesTableName = ctx.getUniqueName("_entryTable" + ctx.components[i].template);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ async function compile(srcFile, options) {
|
|||||||
if (options.cSourceWriteStream) {
|
if (options.cSourceWriteStream) {
|
||||||
if (ctx.verbose) console.log("Generating c...");
|
if (ctx.verbose) console.log("Generating c...");
|
||||||
measures.generateC = -performance.now();
|
measures.generateC = -performance.now();
|
||||||
ctx.builder = new BuilderC(options.prime);
|
ctx.builder = new BuilderC(options.prime, ctx.verbose);
|
||||||
build(ctx);
|
build(ctx);
|
||||||
const rdStream = ctx.builder.build();
|
const rdStream = ctx.builder.build();
|
||||||
rdStream.pipe(options.cSourceWriteStream);
|
rdStream.pipe(options.cSourceWriteStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user