arnaucube
arnaucube/circomPublic Self-hosted repository
Conditions to boolean in old versions of node
Jordi Baylina jordi@baylina.cat
Sat, 11 May 2019 20:55:05 +0200
commit

34049f2fbdfdbba86d473ef23879f6dfebb86819

parent

a602551ee57a28289076d904d04801c78777f23e

1 files changed, 4 insertions(+), 4 deletions(-)

jump to
M src/gencode.js → src/gencode.js

@@ -245,7 +245,7 @@ if (ctx.error) return;

const body = gen(ctx, ast.body); if (ctx.error) return; ctx.scopes.pop(); - return `for (${init};${condition};${step}) { \n${body}\n }\n`; + return `for (${init};bigInt(${condition}).neq(bigInt(0));${step}) { \n${body}\n }\n`; } function genWhile(ctx, ast) {

@@ -253,7 +253,7 @@ const condition = gen(ctx, ast.condition);

if (ctx.error) return; const body = gen(ctx, ast.body); if (ctx.error) return; - return `while (${condition}) {\n${body}\n}\n`; + return `while (bigInt(${condition}).neq(bigInt(0))) {\n${body}\n}\n`; } function genIf(ctx, ast) {

@@ -264,9 +264,9 @@ if (ctx.error) return;

if (ast.else) { const elseBody = gen(ctx, ast.else); if (ctx.error) return; - return `if (${condition}) {\n${thenBody}\n} else {\n${elseBody}\n}\n`; + return `if (bigInt(${condition}).neq(bigInt(0))) {\n${thenBody}\n} else {\n${elseBody}\n}\n`; } else { - return `if (${condition}) {\n${thenBody}\n}\n`; + return `if (bigInt(${condition}).neq(bigInt(0))) {\n${thenBody}\n}\n`; } }