Compare commits

..

3 Commits

Author SHA1 Message Date
krlosMata
b107a11432 add -pthread for linux 2020-04-07 11:51:48 +02:00
Jordi Baylina
96776d2374 0.5.5 2020-03-31 15:36:55 +02:00
Jordi Baylina
ca7379995e Error reporting fixes 2020-03-31 15:36:26 +02:00
4 changed files with 11 additions and 6 deletions

2
package-lock.json generated
View File

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

View File

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

View File

@@ -42,11 +42,14 @@ async function c_tester(circomFile, _options) {
await fs.promises.writeFile(path.join(dir.path, "fr.h"), source.h, "utf8"); await fs.promises.writeFile(path.join(dir.path, "fr.h"), source.h, "utf8");
await fs.promises.writeFile(path.join(dir.path, "fr.c"), source.c, "utf8"); await fs.promises.writeFile(path.join(dir.path, "fr.c"), source.c, "utf8");
let pThread = "";
if (process.platform === "darwin") { if (process.platform === "darwin") {
await exec("nasm -fmacho64 --prefix _ " + await exec("nasm -fmacho64 --prefix _ " +
` ${path.join(dir.path, "fr.asm")}` ` ${path.join(dir.path, "fr.asm")}`
); );
} else if (process.platform === "linux") { } else if (process.platform === "linux") {
pThread = "-pthread";
await exec("nasm -felf64 " + await exec("nasm -felf64 " +
` ${path.join(dir.path, "fr.asm")}` ` ${path.join(dir.path, "fr.asm")}`
); );
@@ -54,7 +57,7 @@ async function c_tester(circomFile, _options) {
const cdir = path.join(path.dirname(require.resolve("circom_runtime")), "c"); const cdir = path.join(path.dirname(require.resolve("circom_runtime")), "c");
await exec("g++" + await exec("g++" + ` ${pThread}`
` ${path.join(cdir, "main.cpp")}` + ` ${path.join(cdir, "main.cpp")}` +
` ${path.join(cdir, "calcwit.cpp")}` + ` ${path.join(cdir, "calcwit.cpp")}` +
` ${path.join(cdir, "utils.cpp")}` + ` ${path.join(cdir, "utils.cpp")}` +

View File

@@ -359,7 +359,7 @@ function execAssignement(ctx, ast) {
} }
if (!left.s) return ctx.throwError(ast, "variable. not defined yet"); if ((!left)||(!left.s)) return ctx.throwError(ast, "variable. not defined yet");
if (left.t == "C") return execInstantiateComponet(ctx, left, ast.values[1], leftSels); if (left.t == "C") return execInstantiateComponet(ctx, left, ast.values[1], leftSels);
if ((left.t == "S")&&( ["<--", "<==", "-->", "==>"].indexOf(ast.op) < 0)) return ctx.throwError(ast, "Cannot assign to a signal with `=` use <-- or <== ops"); if ((left.t == "S")&&( ["<--", "<==", "-->", "==>"].indexOf(ast.op) < 0)) return ctx.throwError(ast, "Cannot assign to a signal with `=` use <-- or <== ops");
@@ -444,14 +444,14 @@ function execInstantiateComponet(ctx, vr, fn, sels) {
const templateName = fn.name; const templateName = fn.name;
const template = ctx.templates[templateName]; const template = ctx.templates[templateName];
if (!template) return ctx.throwError("Invalid Template"); if (!template) return ctx.throwError(fn, "Invalid Template");
const paramValues = []; const paramValues = [];
for (let i=0; i< fn.params.length; i++) { for (let i=0; i< fn.params.length; i++) {
const v = exec(ctx, fn.params[i]); const v = exec(ctx, fn.params[i]);
if (ctx.error) return; if (ctx.error) return;
for (let j=0; j<v.s[0]; j++) { for (let j=0; j<v.s[0]; j++) {
if (v.v[j].t != "N") ctx.throwError("Parameters of a template must be constant"); if (v.v[j].t != "N") ctx.throwError(fn, "Parameters of a template must be constant");
} }
paramValues.push(v); paramValues.push(v);
} }
@@ -873,6 +873,8 @@ function execOpOp(ctx, ast, op, lr) {
right = {t:"N", v: ctx.field.one}; right = {t:"N", v: ctx.field.one};
} }
if (!right) return ctx.throwError(ast, "adding a no number");
const resAfter = ctx.lc[op](resBefore, right); const resAfter = ctx.lc[op](resBefore, right);
left.v[o] = resAfter; left.v[o] = resAfter;