mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
deps
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
"chai": "^4.2.0",
|
||||
"circom_runtime": "0.0.3",
|
||||
"ffiasm": "0.0.2",
|
||||
"ffjavascript": "0.0.3",
|
||||
"ffjavascript": "0.0.4",
|
||||
"ffwasm": "0.0.6",
|
||||
"fnv-plus": "^1.3.1",
|
||||
"r1csfile": "0.0.3",
|
||||
|
||||
@@ -624,6 +624,9 @@ function execReturn(ctx, ast) {
|
||||
function execVariable(ctx, ast) {
|
||||
|
||||
const v = ctx.refs[ast.refId];
|
||||
if (!v) {
|
||||
return ctx.throwError(ast, "Variable not defined: "+ast.name);
|
||||
}
|
||||
|
||||
const sels = [];
|
||||
for (let i=0; i< ast.selectors.length; i++) {
|
||||
|
||||
@@ -175,17 +175,17 @@ function gen(ctx, ast) {
|
||||
} else if (ast.op == ">>") {
|
||||
return genOp(ctx, ast, "shr", 2);
|
||||
} else if (ast.op == "<") {
|
||||
return genOp(ctx, ast, "lt", 2);
|
||||
return genOp(ctx, ast, "lt", 2, true);
|
||||
} else if (ast.op == ">") {
|
||||
return genOp(ctx, ast, "gt", 2);
|
||||
return genOp(ctx, ast, "gt", 2, true);
|
||||
} else if (ast.op == "<=") {
|
||||
return genOp(ctx, ast, "leq", 2);
|
||||
return genOp(ctx, ast, "leq", 2, true);
|
||||
} else if (ast.op == ">=") {
|
||||
return genOp(ctx, ast, "geq", 2);
|
||||
return genOp(ctx, ast, "geq", 2, true);
|
||||
} else if (ast.op == "==") {
|
||||
return genOp(ctx, ast, "eq", 2);
|
||||
return genOp(ctx, ast, "eq", 2, true);
|
||||
} else if (ast.op == "!=") {
|
||||
return genOp(ctx, ast, "neq", 2);
|
||||
return genOp(ctx, ast, "neq", 2, true);
|
||||
} else if (ast.op == "?") {
|
||||
return genTerCon(ctx, ast);
|
||||
} else {
|
||||
@@ -1121,7 +1121,7 @@ function genOpOp(ctx, ast, op, lr) {
|
||||
}
|
||||
}
|
||||
|
||||
function genOp(ctx, ast, op, nOps) {
|
||||
function genOp(ctx, ast, op, nOps, adjustBool) {
|
||||
const vals = [];
|
||||
const valRefs = [];
|
||||
|
||||
@@ -1159,7 +1159,8 @@ function genOp(ctx, ast, op, nOps) {
|
||||
for (let i=0; i<nOps; i++) {
|
||||
params.push(vals[i].value[0]);
|
||||
}
|
||||
rRef = newRef(ctx, "BIGINT", "_tmp", ctx.field[op](...params));
|
||||
|
||||
rRef = newRef(ctx, "BIGINT", "_tmp", adjustBool ? (ctx.field[op](...params)?bigInt.one:bigInt.zero) : ctx.field[op](...params));
|
||||
}
|
||||
return rRef;
|
||||
}
|
||||
|
||||
@@ -85,12 +85,6 @@ class LCAlgebra {
|
||||
const self = this;
|
||||
this.field= aField;
|
||||
[
|
||||
["lt",2],
|
||||
["leq",2],
|
||||
["eq",2],
|
||||
["neq",2],
|
||||
["geq",2],
|
||||
["gt",2],
|
||||
["idiv",2],
|
||||
["mod",2],
|
||||
["band",2],
|
||||
@@ -102,12 +96,18 @@ class LCAlgebra {
|
||||
["lnot",2],
|
||||
["shl",2],
|
||||
["shr",2],
|
||||
["lt",2, true],
|
||||
["leq",2, true],
|
||||
["eq",2, true],
|
||||
["neq",2, true],
|
||||
["geq",2, true],
|
||||
["gt",2, true]
|
||||
].forEach( (op) => {
|
||||
self._genNQOp(op[0], op[1]);
|
||||
self._genNQOp(op[0], op[1], op[2]);
|
||||
});
|
||||
}
|
||||
|
||||
_genNQOp(op, nOps) {
|
||||
_genNQOp(op, nOps, adjustBool) {
|
||||
const self=this;
|
||||
self[op] = function() {
|
||||
const operands = [];
|
||||
@@ -118,7 +118,7 @@ class LCAlgebra {
|
||||
}
|
||||
return {
|
||||
t: "N",
|
||||
v: self.field[op](...operands)
|
||||
v: adjustBool ? ( self.field[op](...operands) ? bigInt.one: bigInt.zero) : self.field[op](...operands)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ function fnvHash(str) {
|
||||
|
||||
|
||||
function stringifyBigInts(o) {
|
||||
if ((typeof(o) == "bigint") || o.isZero !== undefined) {
|
||||
if ((typeof(o) == "bigint") || o.eq !== undefined) {
|
||||
return o.toString(10);
|
||||
} else if (Array.isArray(o)) {
|
||||
return o.map(stringifyBigInts);
|
||||
|
||||
Reference in New Issue
Block a user