Browse Source

deps

feature/c-tester-linux
Jordi Baylina 4 years ago
parent
commit
80cce0ccbb
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
5 changed files with 23 additions and 19 deletions
  1. +1
    -1
      package.json
  2. +3
    -0
      src/construction_phase.js
  3. +9
    -8
      src/gencode.js
  4. +9
    -9
      src/lcalgebra.js
  5. +1
    -1
      src/utils.js

+ 1
- 1
package.json

@ -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",

+ 3
- 0
src/construction_phase.js

@ -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++) {

+ 9
- 8
src/gencode.js

@ -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;
}

+ 9
- 9
src/lcalgebra.js

@ -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)
};
};
}

+ 1
- 1
src/utils.js

@ -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);

Loading…
Cancel
Save