Compare commits

..

3 Commits

Author SHA1 Message Date
Jordi Baylina
25759e53cd 0.0.13 2018-10-24 20:00:07 +02:00
Jordi Baylina
4fa0c79e26 If without else 2018-10-24 19:59:50 +02:00
Jordi Baylina
e685392523 Fix title in readme 2018-10-23 08:06:23 +02:00
6 changed files with 15 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
# Circon # Circom
Circon is a language designed to write arithmetic circuits that can be used in zero knowledge proofs. Circon is a language designed to write arithmetic circuits that can be used in zero knowledge proofs.

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "circom", "name": "circom",
"version": "0.0.12", "version": "0.0.13",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "circom", "name": "circom",
"version": "0.0.12", "version": "0.0.13",
"description": "Language to generate logic circuits", "description": "Language to generate logic circuits",
"main": "index.js", "main": "index.js",
"directories": { "directories": {

View File

@@ -31,7 +31,7 @@ module.exports = compile;
const parser = require("../parser/jaz.js").parser; const parser = require("../parser/jaz.js").parser;
const timeout = ms => new Promise(res => setTimeout(res, ms)) const timeout = ms => new Promise(res => setTimeout(res, ms));
async function compile(srcFile) { async function compile(srcFile) {
const fullFileName = srcFile; const fullFileName = srcFile;

View File

@@ -578,8 +578,10 @@ function execIf(ctx, ast) {
exec(ctx, ast.then); exec(ctx, ast.then);
if (ctx.error) return; if (ctx.error) return;
} else { } else {
exec(ctx, ast.else); if (ast.else) {
if (ctx.error) return; exec(ctx, ast.else);
if (ctx.error) return;
}
} }
} }

View File

@@ -246,9 +246,13 @@ function genIf(ctx, ast) {
if (ctx.error) return; if (ctx.error) return;
const thenBody = gen(ctx, ast.then); const thenBody = gen(ctx, ast.then);
if (ctx.error) return; if (ctx.error) return;
const elseBody = gen(ctx, ast.else); if (ast.else) {
if (ctx.error) return; const elseBody = gen(ctx, ast.else);
return `if (${condition}) {\n${thenBody}\n} else {\n${elseBody}\n}\n`; if (ctx.error) return;
return `if (${condition}) {\n${thenBody}\n} else {\n${elseBody}\n}\n`;
} else {
return `if (${condition}) {\n${thenBody}\n}\n`;
}
} }