|
@ -59,14 +59,11 @@ function build(ctx) { |
|
|
|
|
|
|
|
|
function buildEntryTables(ctx) { |
|
|
function buildEntryTables(ctx) { |
|
|
|
|
|
|
|
|
const codes_hashMaps = []; |
|
|
|
|
|
const codes_componentEntries = []; |
|
|
|
|
|
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%1000 ==0)) console.log(`buildEntryTables component: ${i}/${ctx.components.length}`); |
|
|
const {htName, htMap} = addHashTable(i); |
|
|
const {htName, htMap} = addHashTable(i); |
|
|
|
|
|
|
|
|
let code = ""; |
|
|
|
|
|
const componentEntriesTableName = ctx.getUniqueName("_entryTable" + ctx.components[i].template); |
|
|
const componentEntriesTableName = ctx.getUniqueName("_entryTable" + ctx.components[i].template); |
|
|
|
|
|
|
|
|
const componentEntriesTable = []; |
|
|
const componentEntriesTable = []; |
|
@ -82,32 +79,12 @@ function buildEntryTables(ctx) { |
|
|
|
|
|
|
|
|
ctx.builder.addComponentEntriesTable(componentEntriesTableName, componentEntriesTable); |
|
|
ctx.builder.addComponentEntriesTable(componentEntriesTableName, componentEntriesTable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
code += `Circom_ComponentEntry ${componentEntriesTableName}[${htMap.length}] = {\n`; |
|
|
|
|
|
for (let j=0; j<htMap.length; j++) { |
|
|
|
|
|
const entry = ctx.components[i].names.o[htMap[j]]; |
|
|
|
|
|
code += j>0 ? " ," : " "; |
|
|
|
|
|
const sizeName = ctx.addSizes(entry.sizes); |
|
|
|
|
|
|
|
|
|
|
|
const ty = entry.type == "S" ? "_typeSignal" : "_typeComponent"; |
|
|
|
|
|
code += `{${entry.offset},${sizeName}, ${ty}}\n`; |
|
|
|
|
|
} |
|
|
|
|
|
code += "};\n"; |
|
|
|
|
|
codes_componentEntries.push(code); |
|
|
|
|
|
|
|
|
|
|
|
ctx.components[i].htName = htName; |
|
|
ctx.components[i].htName = htName; |
|
|
ctx.components[i].etName = componentEntriesTableName; |
|
|
ctx.components[i].etName = componentEntriesTableName; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
"// HashMaps\n" , |
|
|
|
|
|
codes_hashMaps , "\n" , |
|
|
|
|
|
"\n" , |
|
|
|
|
|
"// Component Entries\n" , |
|
|
|
|
|
codes_componentEntries , "\n" , |
|
|
|
|
|
"\n" |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
function addHashTable(cIdx) { |
|
|
function addHashTable(cIdx) { |
|
|
const keys = Object.keys(ctx.components[cIdx].names.o); |
|
|
const keys = Object.keys(ctx.components[cIdx].names.o); |
|
|