Assembly library started

This commit is contained in:
Jordi Baylina
2020-01-14 22:43:58 +01:00
parent da969a5e16
commit 63fd72cdc7
40 changed files with 8392 additions and 5 deletions

View File

@@ -204,8 +204,18 @@ function buildComponentsArray(ctx) {
const ccodes = [];
ccodes.push(`Circom_Component _components[${ctx.components.length}] = {\n`);
for (let i=0; i< ctx.components.length; i++) {
let newThread;
if (ctx.newThreadTemplates) {
if (ctx.newThreadTemplates.test(ctx.components[i].template)) {
newThread = "true";
} else {
newThread = "false";
}
} else {
newThread = "false";
}
ccodes.push(i>0 ? " ," : " ");
ccodes.push(`{${ctx.components[i].htName},${ctx.components[i].etName},${ctx.components[i].fnName}, ${ctx.components[i].nInSignals}, true}\n`);
ccodes.push(`{${ctx.components[i].htName},${ctx.components[i].etName},${ctx.components[i].fnName}, ${ctx.components[i].nInSignals}, ${newThread}}\n`);
}
ccodes.push("};\n");
const codeComponents = ccodes.join("");

View File

@@ -41,7 +41,7 @@ async function compile(srcFile, options) {
ctx.field = new ZqField(options.p);
ctx.verbose= options.verbose || false;
ctx.mainComponent = options.mainComponent || "main";
ctx.newThreadTemplates = options.newThreadTemplates;
constructionPhase(ctx, srcFile);

View File

@@ -558,7 +558,7 @@ function execFunctionCall(ctx, ast) {
if (ast.name == "log") {
const v = exec(ctx, ast.params[0]);
const ev = val(ctx, v, ast);
console.log(ev.toString());
console.log(ev.v.toString());
return;
}
if (ast.name == "assert") {
@@ -691,7 +691,7 @@ function execPin(ctx, ast) {
}
const sIdx = ctx.components[cIdx].names.getSignalIdx(ast.pin.name, selsP);
if (sIdx<0) ctx.throwError(ast, "Signal not defined:" + buildFullName() );
if (sIdx<0) return ctx.throwError(ast, "Signal not defined:" + buildFullName() );
return {
t: "S",
sIdx: sIdx,