From 5b45bafaac26570f698c85fddb86cae562b81a90 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Sun, 11 Nov 2018 19:50:26 +0100 Subject: [PATCH] Array params in templates --- cli.js | 1 + package-lock.json | 18 +++++++++--------- package.json | 2 +- src/exec.js | 19 ++++++++++++------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cli.js b/cli.js index 18e7cd9..350e132 100755 --- a/cli.js +++ b/cli.js @@ -61,6 +61,7 @@ compiler(fullFileName).then( (cir) => { process.exit(0); }, (err) => { // console.log(err); + console.log(err.stack); if (err.pos) { console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column} ${err.errStr}`); } else { diff --git a/package-lock.json b/package-lock.json index e2b6f99..2159543 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1469,9 +1469,9 @@ } }, "snarkjs": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.3.tgz", - "integrity": "sha512-z5HhuNt019ZzNzUztETK31rpjRRSz3Uzy8TjGgSROf+9ZT9i6dbdWkjTC3fh5o9H+R/2+hcR+7IKAmpIR56V+A==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.5.tgz", + "integrity": "sha512-4GiP60ONIitWRnC5+Gsl7nIO62fvkGN9Y9jsDWBKORZI34eNXJBrMjhCbT+0X57FS2XjY0MsR0/Qvg2cs1H0sQ==", "dev": true, "requires": { "big-integer": "^1.6.35", @@ -1481,9 +1481,9 @@ }, "dependencies": { "ajv": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", - "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", + "version": "6.5.5", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.5.tgz", + "integrity": "sha512-7q7gtRQDJSyuEHjuVgHoUa2VuemFiCMrfQc9Tc08XTAc4Zj/5U1buQJ0HU6i7fKjXU09SVgSmxa4sLvuvS8Iyg==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -1514,9 +1514,9 @@ } }, "eslint": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz", - "integrity": "sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==", + "version": "5.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.9.0.tgz", + "integrity": "sha512-g4KWpPdqN0nth+goDNICNXGfJF7nNnepthp46CAlJoJtC5K/cLu3NgCM3AHu1CkJ5Hzt9V0Y0PBAO6Ay/gGb+w==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", diff --git a/package.json b/package.json index 9c8e587..2351a07 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,6 @@ "eslint": "^5.0.1", "eslint-plugin-mocha": "^5.0.0", "jison": "^0.4.18", - "snarkjs": "0.1.5" + "snarkjs": "0.1.6" } } diff --git a/src/exec.js b/src/exec.js index cd5b9d3..01371f2 100644 --- a/src/exec.js +++ b/src/exec.js @@ -318,8 +318,7 @@ function execInstantiateComponet(ctx, vr, fn) { const v = exec(ctx, fn.params[i]); if (ctx.error) return; - if (v.type != "NUMBER") return error(ctx, fn.params[i], "expected a number"); - paramValues.push( v.value); + paramValues.push(v); } if (template.params.length != paramValues.length) error(ctx, fn, "Invalid Number of parameters"); @@ -330,6 +329,15 @@ function execInstantiateComponet(ctx, vr, fn) { instantiateComponent(vv); function instantiateComponent(varVal) { + + function extractValue(v) { + if (Array.isArray(v)) { + return v.map(extractValue); + } else { + return v.value.toString(); + } + } + if (Array.isArray(varVal)) { for (let i =0; i