mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-07 11:16:42 +01:00
Tests added and Comparators
This commit is contained in:
16
src/exec.js
16
src/exec.js
@@ -98,6 +98,8 @@ function exec(ctx, ast) {
|
||||
return execGte(ctx, ast);
|
||||
} else if (ast.op == "==") {
|
||||
return execEq(ctx, ast);
|
||||
} else if (ast.op == "!=") {
|
||||
return execNeq(ctx, ast);
|
||||
} else if (ast.op == "?") {
|
||||
return execTerCon(ctx, ast);
|
||||
} else {
|
||||
@@ -680,6 +682,20 @@ function execEq(ctx, ast) {
|
||||
};
|
||||
}
|
||||
|
||||
function execNeq(ctx, ast) {
|
||||
const a = exec(ctx, ast.values[0]);
|
||||
if (ctx.error) return;
|
||||
if (a.type != "NUMBER") return { type: "NUMBER" };
|
||||
const b = exec(ctx, ast.values[1]);
|
||||
if (ctx.error) return;
|
||||
if (b.type != "NUMBER") return { type: "NUMBER" };
|
||||
if (!a.value || !b.value) return { type: "NUMBER" };
|
||||
return {
|
||||
type: "NUMBER",
|
||||
value: a.value.eq(b.value) ? bigInt(0) : bigInt(1)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function execBAnd(ctx, ast) {
|
||||
const a = exec(ctx, ast.values[0]);
|
||||
|
||||
Reference in New Issue
Block a user