@noir-lang/noir_wasm 0.17.0-86704ba.nightly → 0.17.0-b8b7782.aztec

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,12 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {string} level
5
- */
6
- export function init_log_level(level: string): void;
7
- /**
4
+ * @param {string} entry_point
5
+ * @param {boolean | undefined} contracts
6
+ * @param {DependencyGraph | undefined} dependency_graph
8
7
  * @returns {any}
9
8
  */
10
- export function build_info(): any;
9
+ export function compile(entry_point: string, contracts?: boolean, dependency_graph?: DependencyGraph): any;
11
10
  /**
12
11
  * @param {Uint8Array} bytes
13
12
  * @returns {any}
@@ -19,16 +18,17 @@ export function acir_read_bytes(bytes: Uint8Array): any;
19
18
  */
20
19
  export function acir_write_bytes(acir: any): Uint8Array;
21
20
  /**
22
- * @param {string} entry_point
23
- * @param {boolean | undefined} contracts
24
- * @param {string[] | undefined} dependencies
21
+ * @param {string} level
22
+ */
23
+ export function init_log_level(level: string): void;
24
+ /**
25
25
  * @returns {any}
26
26
  */
27
- export function compile(entry_point: string, contracts?: boolean, dependencies?: string[]): any;
27
+ export function build_info(): any;
28
28
 
29
29
  export type Diagnostic = {
30
30
  message: string;
31
- file_path: string;
31
+ file: string;
32
32
  secondaries: ReadonlyArray<{
33
33
  message: string;
34
34
  start: number;
@@ -36,19 +36,16 @@ export type Diagnostic = {
36
36
  }>;
37
37
  }
38
38
 
39
- interface CompileError {
39
+ export interface CompileError extends Error {
40
+ message: string;
40
41
  diagnostics: ReadonlyArray<Diagnostic>;
41
42
  }
42
43
 
43
44
 
44
- /**
45
- */
46
- export class CompileError {
47
- free(): void;
48
- /**
49
- */
50
- diagnostics: any;
51
- /**
52
- */
53
- message: string;
45
+
46
+ export type DependencyGraph = {
47
+ root_dependencies: readonly string[];
48
+ library_dependencies: Readonly<Record<string, readonly string[]>>;
54
49
  }
50
+
51
+
@@ -2,7 +2,7 @@ let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
4
  const { read_file } = require(`@noir-lang/source-resolver`);
5
- const { TextEncoder, TextDecoder } = require(`util`);
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
6
 
7
7
  const heap = new Array(128).fill(undefined);
8
8
 
@@ -24,16 +24,9 @@ function takeObject(idx) {
24
24
  return ret;
25
25
  }
26
26
 
27
- function addHeapObject(obj) {
28
- if (heap_next === heap.length) heap.push(heap.length + 1);
29
- const idx = heap_next;
30
- heap_next = heap[idx];
31
-
32
- heap[idx] = obj;
33
- return idx;
34
- }
27
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
35
28
 
36
- let WASM_VECTOR_LEN = 0;
29
+ cachedTextDecoder.decode();
37
30
 
38
31
  let cachedUint8Memory0 = null;
39
32
 
@@ -44,6 +37,22 @@ function getUint8Memory0() {
44
37
  return cachedUint8Memory0;
45
38
  }
46
39
 
40
+ function getStringFromWasm0(ptr, len) {
41
+ ptr = ptr >>> 0;
42
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
43
+ }
44
+
45
+ function addHeapObject(obj) {
46
+ if (heap_next === heap.length) heap.push(heap.length + 1);
47
+ const idx = heap_next;
48
+ heap_next = heap[idx];
49
+
50
+ heap[idx] = obj;
51
+ return idx;
52
+ }
53
+
54
+ let WASM_VECTOR_LEN = 0;
55
+
47
56
  let cachedTextEncoder = new TextEncoder('utf-8');
48
57
 
49
58
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -110,31 +119,102 @@ function getInt32Memory0() {
110
119
  return cachedInt32Memory0;
111
120
  }
112
121
 
113
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
114
-
115
- cachedTextDecoder.decode();
116
-
117
- function getStringFromWasm0(ptr, len) {
118
- ptr = ptr >>> 0;
119
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
122
+ function debugString(val) {
123
+ // primitive types
124
+ const type = typeof val;
125
+ if (type == 'number' || type == 'boolean' || val == null) {
126
+ return `${val}`;
127
+ }
128
+ if (type == 'string') {
129
+ return `"${val}"`;
130
+ }
131
+ if (type == 'symbol') {
132
+ const description = val.description;
133
+ if (description == null) {
134
+ return 'Symbol';
135
+ } else {
136
+ return `Symbol(${description})`;
137
+ }
138
+ }
139
+ if (type == 'function') {
140
+ const name = val.name;
141
+ if (typeof name == 'string' && name.length > 0) {
142
+ return `Function(${name})`;
143
+ } else {
144
+ return 'Function';
145
+ }
146
+ }
147
+ // objects
148
+ if (Array.isArray(val)) {
149
+ const length = val.length;
150
+ let debug = '[';
151
+ if (length > 0) {
152
+ debug += debugString(val[0]);
153
+ }
154
+ for(let i = 1; i < length; i++) {
155
+ debug += ', ' + debugString(val[i]);
156
+ }
157
+ debug += ']';
158
+ return debug;
159
+ }
160
+ // Test for built-in
161
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
162
+ let className;
163
+ if (builtInMatches.length > 1) {
164
+ className = builtInMatches[1];
165
+ } else {
166
+ // Failed to match the standard '[object ClassName]'
167
+ return toString.call(val);
168
+ }
169
+ if (className == 'Object') {
170
+ // we're a user defined class or Object
171
+ // JSON.stringify avoids problems with cycles, and is generally much
172
+ // easier than looping through ownProperties of `val`.
173
+ try {
174
+ return 'Object(' + JSON.stringify(val) + ')';
175
+ } catch (_) {
176
+ return 'Object';
177
+ }
178
+ }
179
+ // errors
180
+ if (val instanceof Error) {
181
+ return `${val.name}: ${val.message}\n${val.stack}`;
182
+ }
183
+ // TODO we could test for more things here, like `Set`s and `Map`s.
184
+ return className;
120
185
  }
121
186
  /**
122
- * @param {string} level
123
- */
124
- module.exports.init_log_level = function(level) {
125
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
126
- const len0 = WASM_VECTOR_LEN;
127
- wasm.init_log_level(ptr0, len0);
128
- };
129
-
130
- /**
187
+ * @param {string} entry_point
188
+ * @param {boolean | undefined} contracts
189
+ * @param {DependencyGraph | undefined} dependency_graph
131
190
  * @returns {any}
132
191
  */
133
- module.exports.build_info = function() {
134
- const ret = wasm.build_info();
135
- return takeObject(ret);
192
+ module.exports.compile = function(entry_point, contracts, dependency_graph) {
193
+ try {
194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
+ const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph));
198
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
199
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
200
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
201
+ if (r2) {
202
+ throw takeObject(r1);
203
+ }
204
+ return takeObject(r0);
205
+ } finally {
206
+ wasm.__wbindgen_add_to_stack_pointer(16);
207
+ }
136
208
  };
137
209
 
210
+ function handleError(f, args) {
211
+ try {
212
+ return f.apply(this, args);
213
+ } catch (e) {
214
+ wasm.__wbindgen_export_2(addHeapObject(e));
215
+ }
216
+ }
217
+
138
218
  function passArray8ToWasm0(arg, malloc) {
139
219
  const ptr = malloc(arg.length * 1) >>> 0;
140
220
  getUint8Memory0().set(arg, ptr / 1);
@@ -167,7 +247,7 @@ module.exports.acir_write_bytes = function(acir) {
167
247
  var r0 = getInt32Memory0()[retptr / 4 + 0];
168
248
  var r1 = getInt32Memory0()[retptr / 4 + 1];
169
249
  var v1 = getArrayU8FromWasm0(r0, r1).slice();
170
- wasm.__wbindgen_export_2(r0, r1 * 1);
250
+ wasm.__wbindgen_export_3(r0, r1 * 1);
171
251
  return v1;
172
252
  } finally {
173
253
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -175,116 +255,31 @@ module.exports.acir_write_bytes = function(acir) {
175
255
  };
176
256
 
177
257
  /**
178
- * @param {string} entry_point
179
- * @param {boolean | undefined} contracts
180
- * @param {string[] | undefined} dependencies
181
- * @returns {any}
258
+ * @param {string} level
182
259
  */
183
- module.exports.compile = function(entry_point, contracts, dependencies) {
184
- try {
185
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
186
- const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
187
- const len0 = WASM_VECTOR_LEN;
188
- wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependencies) ? 0 : addHeapObject(dependencies));
189
- var r0 = getInt32Memory0()[retptr / 4 + 0];
190
- var r1 = getInt32Memory0()[retptr / 4 + 1];
191
- var r2 = getInt32Memory0()[retptr / 4 + 2];
192
- if (r2) {
193
- throw takeObject(r1);
194
- }
195
- return takeObject(r0);
196
- } finally {
197
- wasm.__wbindgen_add_to_stack_pointer(16);
198
- }
260
+ module.exports.init_log_level = function(level) {
261
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
262
+ const len0 = WASM_VECTOR_LEN;
263
+ wasm.init_log_level(ptr0, len0);
199
264
  };
200
265
 
201
- function handleError(f, args) {
202
- try {
203
- return f.apply(this, args);
204
- } catch (e) {
205
- wasm.__wbindgen_export_3(addHeapObject(e));
206
- }
207
- }
208
266
  /**
267
+ * @returns {any}
209
268
  */
210
- class CompileError {
211
-
212
- static __wrap(ptr) {
213
- ptr = ptr >>> 0;
214
- const obj = Object.create(CompileError.prototype);
215
- obj.__wbg_ptr = ptr;
216
-
217
- return obj;
218
- }
219
-
220
- __destroy_into_raw() {
221
- const ptr = this.__wbg_ptr;
222
- this.__wbg_ptr = 0;
223
-
224
- return ptr;
225
- }
226
-
227
- free() {
228
- const ptr = this.__destroy_into_raw();
229
- wasm.__wbg_compileerror_free(ptr);
230
- }
231
- /**
232
- * @returns {string}
233
- */
234
- get message() {
235
- const ret = wasm.__wbg_get_compileerror_message(this.__wbg_ptr);
236
- return takeObject(ret);
237
- }
238
- /**
239
- * @param {string} arg0
240
- */
241
- set message(arg0) {
242
- wasm.__wbg_set_compileerror_message(this.__wbg_ptr, addHeapObject(arg0));
243
- }
244
- /**
245
- * @returns {any}
246
- */
247
- get diagnostics() {
248
- const ret = wasm.__wbg_get_compileerror_diagnostics(this.__wbg_ptr);
249
- return takeObject(ret);
250
- }
251
- /**
252
- * @param {any} arg0
253
- */
254
- set diagnostics(arg0) {
255
- wasm.__wbg_set_compileerror_diagnostics(this.__wbg_ptr, addHeapObject(arg0));
256
- }
257
- }
258
- module.exports.CompileError = CompileError;
259
-
260
- module.exports.__wbg_compileerror_new = function(arg0) {
261
- const ret = CompileError.__wrap(arg0);
262
- return addHeapObject(ret);
269
+ module.exports.build_info = function() {
270
+ const ret = wasm.build_info();
271
+ return takeObject(ret);
263
272
  };
264
273
 
265
274
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
266
275
  takeObject(arg0);
267
276
  };
268
277
 
269
- module.exports.__wbindgen_object_clone_ref = function(arg0) {
270
- const ret = getObject(arg0);
278
+ module.exports.__wbg_constructor_5ae64b4b6121edd9 = function(arg0) {
279
+ const ret = new Error(takeObject(arg0));
271
280
  return addHeapObject(ret);
272
281
  };
273
282
 
274
- module.exports.__wbindgen_string_get = function(arg0, arg1) {
275
- const obj = getObject(arg1);
276
- const ret = typeof(obj) === 'string' ? obj : undefined;
277
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
278
- var len1 = WASM_VECTOR_LEN;
279
- getInt32Memory0()[arg0 / 4 + 1] = len1;
280
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
281
- };
282
-
283
- module.exports.__wbindgen_is_undefined = function(arg0) {
284
- const ret = getObject(arg0) === undefined;
285
- return ret;
286
- };
287
-
288
283
  module.exports.__wbg_readfile_db7d495e3e198483 = function() { return handleError(function (arg0, arg1, arg2) {
289
284
  const ret = read_file(getStringFromWasm0(arg1, arg2));
290
285
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -293,6 +288,11 @@ module.exports.__wbg_readfile_db7d495e3e198483 = function() { return handleError
293
288
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
294
289
  }, arguments) };
295
290
 
291
+ module.exports.__wbindgen_is_undefined = function(arg0) {
292
+ const ret = getObject(arg0) === undefined;
293
+ return ret;
294
+ };
295
+
296
296
  module.exports.__wbindgen_string_new = function(arg0, arg1) {
297
297
  const ret = getStringFromWasm0(arg0, arg1);
298
298
  return addHeapObject(ret);
@@ -319,7 +319,7 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
319
319
  deferred0_1 = arg1;
320
320
  console.error(getStringFromWasm0(arg0, arg1));
321
321
  } finally {
322
- wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
322
+ wasm.__wbindgen_export_3(deferred0_0, deferred0_1);
323
323
  }
324
324
  };
325
325
 
@@ -347,15 +347,19 @@ module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
347
347
  console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
348
348
  };
349
349
 
350
- module.exports.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
351
- const ret = getObject(arg0)[arg1 >>> 0];
352
- return addHeapObject(ret);
350
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
351
+ const obj = getObject(arg1);
352
+ const ret = typeof(obj) === 'string' ? obj : undefined;
353
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
354
+ var len1 = WASM_VECTOR_LEN;
355
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
356
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
353
357
  };
354
358
 
355
- module.exports.__wbg_length_820c786973abdd8a = function(arg0) {
356
- const ret = getObject(arg0).length;
359
+ module.exports.__wbg_set_07da13cc24b69217 = function() { return handleError(function (arg0, arg1, arg2) {
360
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
357
361
  return ret;
358
- };
362
+ }, arguments) };
359
363
 
360
364
  module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
361
365
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
@@ -367,6 +371,14 @@ module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleErro
367
371
  return addHeapObject(ret);
368
372
  }, arguments) };
369
373
 
374
+ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
375
+ const ret = debugString(getObject(arg1));
376
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
377
+ const len1 = WASM_VECTOR_LEN;
378
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
379
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
380
+ };
381
+
370
382
  module.exports.__wbindgen_throw = function(arg0, arg1) {
371
383
  throw new Error(getStringFromWasm0(arg0, arg1));
372
384
  };
Binary file
@@ -1,18 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function __wbg_compileerror_free(a: number): void;
5
- export function __wbg_get_compileerror_message(a: number): number;
6
- export function __wbg_set_compileerror_message(a: number, b: number): void;
7
- export function __wbg_get_compileerror_diagnostics(a: number): number;
8
- export function __wbg_set_compileerror_diagnostics(a: number, b: number): void;
9
- export function init_log_level(a: number, b: number): void;
10
- export function build_info(): number;
4
+ export function compile(a: number, b: number, c: number, d: number, e: number): void;
11
5
  export function acir_read_bytes(a: number, b: number): number;
12
6
  export function acir_write_bytes(a: number, b: number): void;
13
- export function compile(a: number, b: number, c: number, d: number, e: number): void;
7
+ export function init_log_level(a: number, b: number): void;
8
+ export function build_info(): number;
14
9
  export function __wbindgen_export_0(a: number): number;
15
10
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
16
11
  export function __wbindgen_add_to_stack_pointer(a: number): number;
17
- export function __wbindgen_export_2(a: number, b: number): void;
18
- export function __wbindgen_export_3(a: number): void;
12
+ export function __wbindgen_export_2(a: number): void;
13
+ export function __wbindgen_export_3(a: number, b: number): void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "The Noir Team <team@noir-lang.org>"
5
5
  ],
6
- "version": "0.17.0-86704ba.nightly",
6
+ "version": "0.17.0-b8b7782.aztec",
7
7
  "license": "(MIT OR Apache-2.0)",
8
8
  "main": "./nodejs/noir_wasm.js",
9
9
  "types": "./web/noir_wasm.d.ts",
@@ -31,7 +31,7 @@
31
31
  "install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/noir_wasm/nodejs ./ && cp -rL ./result/noir_wasm/web ./"
32
32
  },
33
33
  "peerDependencies": {
34
- "@noir-lang/source-resolver": "0.17.0-86704ba.nightly"
34
+ "@noir-lang/source-resolver": "0.17.0-b8b7782.aztec"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@esm-bundle/chai": "^4.3.4-fix.0",
@@ -1,13 +1,12 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {string} level
5
- */
6
- export function init_log_level(level: string): void;
7
- /**
4
+ * @param {string} entry_point
5
+ * @param {boolean | undefined} contracts
6
+ * @param {DependencyGraph | undefined} dependency_graph
8
7
  * @returns {any}
9
8
  */
10
- export function build_info(): any;
9
+ export function compile(entry_point: string, contracts?: boolean, dependency_graph?: DependencyGraph): any;
11
10
  /**
12
11
  * @param {Uint8Array} bytes
13
12
  * @returns {any}
@@ -19,16 +18,17 @@ export function acir_read_bytes(bytes: Uint8Array): any;
19
18
  */
20
19
  export function acir_write_bytes(acir: any): Uint8Array;
21
20
  /**
22
- * @param {string} entry_point
23
- * @param {boolean | undefined} contracts
24
- * @param {string[] | undefined} dependencies
21
+ * @param {string} level
22
+ */
23
+ export function init_log_level(level: string): void;
24
+ /**
25
25
  * @returns {any}
26
26
  */
27
- export function compile(entry_point: string, contracts?: boolean, dependencies?: string[]): any;
27
+ export function build_info(): any;
28
28
 
29
29
  export type Diagnostic = {
30
30
  message: string;
31
- file_path: string;
31
+ file: string;
32
32
  secondaries: ReadonlyArray<{
33
33
  message: string;
34
34
  start: number;
@@ -36,42 +36,34 @@ export type Diagnostic = {
36
36
  }>;
37
37
  }
38
38
 
39
- interface CompileError {
39
+ export interface CompileError extends Error {
40
+ message: string;
40
41
  diagnostics: ReadonlyArray<Diagnostic>;
41
42
  }
42
43
 
43
44
 
44
- /**
45
- */
46
- export class CompileError {
47
- free(): void;
48
- /**
49
- */
50
- diagnostics: any;
51
- /**
52
- */
53
- message: string;
45
+
46
+ export type DependencyGraph = {
47
+ root_dependencies: readonly string[];
48
+ library_dependencies: Readonly<Record<string, readonly string[]>>;
54
49
  }
55
50
 
51
+
52
+
56
53
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
57
54
 
58
55
  export interface InitOutput {
59
56
  readonly memory: WebAssembly.Memory;
60
- readonly __wbg_compileerror_free: (a: number) => void;
61
- readonly __wbg_get_compileerror_message: (a: number) => number;
62
- readonly __wbg_set_compileerror_message: (a: number, b: number) => void;
63
- readonly __wbg_get_compileerror_diagnostics: (a: number) => number;
64
- readonly __wbg_set_compileerror_diagnostics: (a: number, b: number) => void;
65
- readonly init_log_level: (a: number, b: number) => void;
66
- readonly build_info: () => number;
57
+ readonly compile: (a: number, b: number, c: number, d: number, e: number) => void;
67
58
  readonly acir_read_bytes: (a: number, b: number) => number;
68
59
  readonly acir_write_bytes: (a: number, b: number) => void;
69
- readonly compile: (a: number, b: number, c: number, d: number, e: number) => void;
60
+ readonly init_log_level: (a: number, b: number) => void;
61
+ readonly build_info: () => number;
70
62
  readonly __wbindgen_export_0: (a: number) => number;
71
63
  readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
72
64
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
73
- readonly __wbindgen_export_2: (a: number, b: number) => void;
74
- readonly __wbindgen_export_3: (a: number) => void;
65
+ readonly __wbindgen_export_2: (a: number) => void;
66
+ readonly __wbindgen_export_3: (a: number, b: number) => void;
75
67
  }
76
68
 
77
69
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/web/noir_wasm.js CHANGED
@@ -22,16 +22,9 @@ function takeObject(idx) {
22
22
  return ret;
23
23
  }
24
24
 
25
- function addHeapObject(obj) {
26
- if (heap_next === heap.length) heap.push(heap.length + 1);
27
- const idx = heap_next;
28
- heap_next = heap[idx];
29
-
30
- heap[idx] = obj;
31
- return idx;
32
- }
25
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
33
26
 
34
- let WASM_VECTOR_LEN = 0;
27
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
35
28
 
36
29
  let cachedUint8Memory0 = null;
37
30
 
@@ -42,6 +35,22 @@ function getUint8Memory0() {
42
35
  return cachedUint8Memory0;
43
36
  }
44
37
 
38
+ function getStringFromWasm0(ptr, len) {
39
+ ptr = ptr >>> 0;
40
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
41
+ }
42
+
43
+ function addHeapObject(obj) {
44
+ if (heap_next === heap.length) heap.push(heap.length + 1);
45
+ const idx = heap_next;
46
+ heap_next = heap[idx];
47
+
48
+ heap[idx] = obj;
49
+ return idx;
50
+ }
51
+
52
+ let WASM_VECTOR_LEN = 0;
53
+
45
54
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
46
55
 
47
56
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -108,29 +117,100 @@ function getInt32Memory0() {
108
117
  return cachedInt32Memory0;
109
118
  }
110
119
 
111
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
112
-
113
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
114
-
115
- function getStringFromWasm0(ptr, len) {
116
- ptr = ptr >>> 0;
117
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
120
+ function debugString(val) {
121
+ // primitive types
122
+ const type = typeof val;
123
+ if (type == 'number' || type == 'boolean' || val == null) {
124
+ return `${val}`;
125
+ }
126
+ if (type == 'string') {
127
+ return `"${val}"`;
128
+ }
129
+ if (type == 'symbol') {
130
+ const description = val.description;
131
+ if (description == null) {
132
+ return 'Symbol';
133
+ } else {
134
+ return `Symbol(${description})`;
135
+ }
136
+ }
137
+ if (type == 'function') {
138
+ const name = val.name;
139
+ if (typeof name == 'string' && name.length > 0) {
140
+ return `Function(${name})`;
141
+ } else {
142
+ return 'Function';
143
+ }
144
+ }
145
+ // objects
146
+ if (Array.isArray(val)) {
147
+ const length = val.length;
148
+ let debug = '[';
149
+ if (length > 0) {
150
+ debug += debugString(val[0]);
151
+ }
152
+ for(let i = 1; i < length; i++) {
153
+ debug += ', ' + debugString(val[i]);
154
+ }
155
+ debug += ']';
156
+ return debug;
157
+ }
158
+ // Test for built-in
159
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
160
+ let className;
161
+ if (builtInMatches.length > 1) {
162
+ className = builtInMatches[1];
163
+ } else {
164
+ // Failed to match the standard '[object ClassName]'
165
+ return toString.call(val);
166
+ }
167
+ if (className == 'Object') {
168
+ // we're a user defined class or Object
169
+ // JSON.stringify avoids problems with cycles, and is generally much
170
+ // easier than looping through ownProperties of `val`.
171
+ try {
172
+ return 'Object(' + JSON.stringify(val) + ')';
173
+ } catch (_) {
174
+ return 'Object';
175
+ }
176
+ }
177
+ // errors
178
+ if (val instanceof Error) {
179
+ return `${val.name}: ${val.message}\n${val.stack}`;
180
+ }
181
+ // TODO we could test for more things here, like `Set`s and `Map`s.
182
+ return className;
118
183
  }
119
184
  /**
120
- * @param {string} level
185
+ * @param {string} entry_point
186
+ * @param {boolean | undefined} contracts
187
+ * @param {DependencyGraph | undefined} dependency_graph
188
+ * @returns {any}
121
189
  */
122
- export function init_log_level(level) {
123
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
124
- const len0 = WASM_VECTOR_LEN;
125
- wasm.init_log_level(ptr0, len0);
190
+ export function compile(entry_point, contracts, dependency_graph) {
191
+ try {
192
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
193
+ const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
194
+ const len0 = WASM_VECTOR_LEN;
195
+ wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph));
196
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
197
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
198
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
199
+ if (r2) {
200
+ throw takeObject(r1);
201
+ }
202
+ return takeObject(r0);
203
+ } finally {
204
+ wasm.__wbindgen_add_to_stack_pointer(16);
205
+ }
126
206
  }
127
207
 
128
- /**
129
- * @returns {any}
130
- */
131
- export function build_info() {
132
- const ret = wasm.build_info();
133
- return takeObject(ret);
208
+ function handleError(f, args) {
209
+ try {
210
+ return f.apply(this, args);
211
+ } catch (e) {
212
+ wasm.__wbindgen_export_2(addHeapObject(e));
213
+ }
134
214
  }
135
215
 
136
216
  function passArray8ToWasm0(arg, malloc) {
@@ -165,7 +245,7 @@ export function acir_write_bytes(acir) {
165
245
  var r0 = getInt32Memory0()[retptr / 4 + 0];
166
246
  var r1 = getInt32Memory0()[retptr / 4 + 1];
167
247
  var v1 = getArrayU8FromWasm0(r0, r1).slice();
168
- wasm.__wbindgen_export_2(r0, r1 * 1);
248
+ wasm.__wbindgen_export_3(r0, r1 * 1);
169
249
  return v1;
170
250
  } finally {
171
251
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -173,85 +253,20 @@ export function acir_write_bytes(acir) {
173
253
  }
174
254
 
175
255
  /**
176
- * @param {string} entry_point
177
- * @param {boolean | undefined} contracts
178
- * @param {string[] | undefined} dependencies
179
- * @returns {any}
256
+ * @param {string} level
180
257
  */
181
- export function compile(entry_point, contracts, dependencies) {
182
- try {
183
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
184
- const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
185
- const len0 = WASM_VECTOR_LEN;
186
- wasm.compile(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependencies) ? 0 : addHeapObject(dependencies));
187
- var r0 = getInt32Memory0()[retptr / 4 + 0];
188
- var r1 = getInt32Memory0()[retptr / 4 + 1];
189
- var r2 = getInt32Memory0()[retptr / 4 + 2];
190
- if (r2) {
191
- throw takeObject(r1);
192
- }
193
- return takeObject(r0);
194
- } finally {
195
- wasm.__wbindgen_add_to_stack_pointer(16);
196
- }
258
+ export function init_log_level(level) {
259
+ const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
260
+ const len0 = WASM_VECTOR_LEN;
261
+ wasm.init_log_level(ptr0, len0);
197
262
  }
198
263
 
199
- function handleError(f, args) {
200
- try {
201
- return f.apply(this, args);
202
- } catch (e) {
203
- wasm.__wbindgen_export_3(addHeapObject(e));
204
- }
205
- }
206
264
  /**
265
+ * @returns {any}
207
266
  */
208
- export class CompileError {
209
-
210
- static __wrap(ptr) {
211
- ptr = ptr >>> 0;
212
- const obj = Object.create(CompileError.prototype);
213
- obj.__wbg_ptr = ptr;
214
-
215
- return obj;
216
- }
217
-
218
- __destroy_into_raw() {
219
- const ptr = this.__wbg_ptr;
220
- this.__wbg_ptr = 0;
221
-
222
- return ptr;
223
- }
224
-
225
- free() {
226
- const ptr = this.__destroy_into_raw();
227
- wasm.__wbg_compileerror_free(ptr);
228
- }
229
- /**
230
- * @returns {string}
231
- */
232
- get message() {
233
- const ret = wasm.__wbg_get_compileerror_message(this.__wbg_ptr);
234
- return takeObject(ret);
235
- }
236
- /**
237
- * @param {string} arg0
238
- */
239
- set message(arg0) {
240
- wasm.__wbg_set_compileerror_message(this.__wbg_ptr, addHeapObject(arg0));
241
- }
242
- /**
243
- * @returns {any}
244
- */
245
- get diagnostics() {
246
- const ret = wasm.__wbg_get_compileerror_diagnostics(this.__wbg_ptr);
247
- return takeObject(ret);
248
- }
249
- /**
250
- * @param {any} arg0
251
- */
252
- set diagnostics(arg0) {
253
- wasm.__wbg_set_compileerror_diagnostics(this.__wbg_ptr, addHeapObject(arg0));
254
- }
267
+ export function build_info() {
268
+ const ret = wasm.build_info();
269
+ return takeObject(ret);
255
270
  }
256
271
 
257
272
  async function __wbg_load(module, imports) {
@@ -288,29 +303,13 @@ async function __wbg_load(module, imports) {
288
303
  function __wbg_get_imports() {
289
304
  const imports = {};
290
305
  imports.wbg = {};
291
- imports.wbg.__wbg_compileerror_new = function(arg0) {
292
- const ret = CompileError.__wrap(arg0);
293
- return addHeapObject(ret);
294
- };
295
306
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
296
307
  takeObject(arg0);
297
308
  };
298
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
299
- const ret = getObject(arg0);
309
+ imports.wbg.__wbg_constructor_5ae64b4b6121edd9 = function(arg0) {
310
+ const ret = new Error(takeObject(arg0));
300
311
  return addHeapObject(ret);
301
312
  };
302
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
303
- const obj = getObject(arg1);
304
- const ret = typeof(obj) === 'string' ? obj : undefined;
305
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
306
- var len1 = WASM_VECTOR_LEN;
307
- getInt32Memory0()[arg0 / 4 + 1] = len1;
308
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
309
- };
310
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
311
- const ret = getObject(arg0) === undefined;
312
- return ret;
313
- };
314
313
  imports.wbg.__wbg_readfile_db7d495e3e198483 = function() { return handleError(function (arg0, arg1, arg2) {
315
314
  const ret = read_file(getStringFromWasm0(arg1, arg2));
316
315
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
@@ -318,6 +317,10 @@ function __wbg_get_imports() {
318
317
  getInt32Memory0()[arg0 / 4 + 1] = len1;
319
318
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
320
319
  }, arguments) };
320
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
321
+ const ret = getObject(arg0) === undefined;
322
+ return ret;
323
+ };
321
324
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
322
325
  const ret = getStringFromWasm0(arg0, arg1);
323
326
  return addHeapObject(ret);
@@ -341,7 +344,7 @@ function __wbg_get_imports() {
341
344
  deferred0_1 = arg1;
342
345
  console.error(getStringFromWasm0(arg0, arg1));
343
346
  } finally {
344
- wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
347
+ wasm.__wbindgen_export_3(deferred0_0, deferred0_1);
345
348
  }
346
349
  };
347
350
  imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
@@ -362,14 +365,18 @@ function __wbg_get_imports() {
362
365
  imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
363
366
  console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
364
367
  };
365
- imports.wbg.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
366
- const ret = getObject(arg0)[arg1 >>> 0];
367
- return addHeapObject(ret);
368
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
369
+ const obj = getObject(arg1);
370
+ const ret = typeof(obj) === 'string' ? obj : undefined;
371
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
372
+ var len1 = WASM_VECTOR_LEN;
373
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
374
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
368
375
  };
369
- imports.wbg.__wbg_length_820c786973abdd8a = function(arg0) {
370
- const ret = getObject(arg0).length;
376
+ imports.wbg.__wbg_set_07da13cc24b69217 = function() { return handleError(function (arg0, arg1, arg2) {
377
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
371
378
  return ret;
372
- };
379
+ }, arguments) };
373
380
  imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
374
381
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
375
382
  return addHeapObject(ret);
@@ -378,6 +385,13 @@ function __wbg_get_imports() {
378
385
  const ret = JSON.stringify(getObject(arg0));
379
386
  return addHeapObject(ret);
380
387
  }, arguments) };
388
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
389
+ const ret = debugString(getObject(arg1));
390
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
391
+ const len1 = WASM_VECTOR_LEN;
392
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
393
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
394
+ };
381
395
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
382
396
  throw new Error(getStringFromWasm0(arg0, arg1));
383
397
  };
Binary file
@@ -1,18 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function __wbg_compileerror_free(a: number): void;
5
- export function __wbg_get_compileerror_message(a: number): number;
6
- export function __wbg_set_compileerror_message(a: number, b: number): void;
7
- export function __wbg_get_compileerror_diagnostics(a: number): number;
8
- export function __wbg_set_compileerror_diagnostics(a: number, b: number): void;
9
- export function init_log_level(a: number, b: number): void;
10
- export function build_info(): number;
4
+ export function compile(a: number, b: number, c: number, d: number, e: number): void;
11
5
  export function acir_read_bytes(a: number, b: number): number;
12
6
  export function acir_write_bytes(a: number, b: number): void;
13
- export function compile(a: number, b: number, c: number, d: number, e: number): void;
7
+ export function init_log_level(a: number, b: number): void;
8
+ export function build_info(): number;
14
9
  export function __wbindgen_export_0(a: number): number;
15
10
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
16
11
  export function __wbindgen_add_to_stack_pointer(a: number): number;
17
- export function __wbindgen_export_2(a: number, b: number): void;
18
- export function __wbindgen_export_3(a: number): void;
12
+ export function __wbindgen_export_2(a: number): void;
13
+ export function __wbindgen_export_3(a: number, b: number): void;