@noir-lang/noir_wasm 0.21.0 → 0.22.0-223e860.nightly

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,23 +1,15 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {Uint8Array} bytes
5
- * @returns {any}
6
- */
7
- export function acir_read_bytes(bytes: Uint8Array): any;
8
- /**
9
- * @param {any} acir
10
- * @returns {Uint8Array}
11
- */
12
- export function acir_write_bytes(acir: any): Uint8Array;
13
- /**
14
- * @param {string} level
15
- */
16
- export function init_log_level(level: string): void;
17
- /**
18
- * @returns {any}
4
+ * This is a method that exposes the same API as `compile`
5
+ * But uses the Context based APi internally
6
+ * @param {string} entry_point
7
+ * @param {boolean | undefined} contracts
8
+ * @param {DependencyGraph | undefined} dependency_graph
9
+ * @param {PathToFileSourceMap} file_source_map
10
+ * @returns {CompileResult}
19
11
  */
20
- export function build_info(): any;
12
+ export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
21
13
  /**
22
14
  * @param {string} entry_point
23
15
  * @param {boolean | undefined} contracts
@@ -26,6 +18,14 @@ export function build_info(): any;
26
18
  * @returns {CompileResult}
27
19
  */
28
20
  export function compile(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
21
+ /**
22
+ * @param {string} filter
23
+ */
24
+ export function init_log_level(filter: string): void;
25
+ /**
26
+ * @returns {any}
27
+ */
28
+ export function build_info(): any;
29
29
 
30
30
  export type Diagnostic = {
31
31
  message: string;
@@ -52,14 +52,12 @@ export type DependencyGraph = {
52
52
  export type CompiledContract = {
53
53
  noir_version: string;
54
54
  name: string;
55
- backend: string;
56
55
  functions: Array<any>;
57
56
  events: Array<any>;
58
57
  };
59
58
 
60
59
  export type CompiledProgram = {
61
60
  noir_version: string;
62
- backend: string;
63
61
  abi: any;
64
62
  bytecode: string;
65
63
  }
@@ -82,6 +80,49 @@ export type CompileResult = (
82
80
  );
83
81
 
84
82
 
83
+ /**
84
+ * This is a wrapper class that is wasm-bindgen compatible
85
+ * We do not use js_name and rename it like CrateId because
86
+ * then the impl block is not picked up in javascript.
87
+ */
88
+ export class CompilerContext {
89
+ free(): void;
90
+ /**
91
+ * @param {PathToFileSourceMap} source_map
92
+ */
93
+ constructor(source_map: PathToFileSourceMap);
94
+ /**
95
+ * @param {string} path_to_crate
96
+ * @returns {CrateId}
97
+ */
98
+ process_root_crate(path_to_crate: string): CrateId;
99
+ /**
100
+ * @param {string} path_to_crate
101
+ * @returns {CrateId}
102
+ */
103
+ process_dependency_crate(path_to_crate: string): CrateId;
104
+ /**
105
+ * @param {string} crate_name
106
+ * @param {CrateId} from
107
+ * @param {CrateId} to
108
+ */
109
+ add_dependency_edge(crate_name: string, from: CrateId, to: CrateId): void;
110
+ /**
111
+ * @param {number} program_width
112
+ * @returns {CompileResult}
113
+ */
114
+ compile_program(program_width: number): CompileResult;
115
+ /**
116
+ * @param {number} program_width
117
+ * @returns {CompileResult}
118
+ */
119
+ compile_contract(program_width: number): CompileResult;
120
+ }
121
+ /**
122
+ */
123
+ export class CrateId {
124
+ free(): void;
125
+ }
85
126
  /**
86
127
  */
87
128
  export class PathToFileSourceMap {
@@ -183,68 +183,41 @@ function debugString(val) {
183
183
  return className;
184
184
  }
185
185
 
186
- function passArray8ToWasm0(arg, malloc) {
187
- const ptr = malloc(arg.length * 1) >>> 0;
188
- getUint8Memory0().set(arg, ptr / 1);
189
- WASM_VECTOR_LEN = arg.length;
190
- return ptr;
191
- }
192
- /**
193
- * @param {Uint8Array} bytes
194
- * @returns {any}
195
- */
196
- module.exports.acir_read_bytes = function(bytes) {
197
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
198
- const len0 = WASM_VECTOR_LEN;
199
- const ret = wasm.acir_read_bytes(ptr0, len0);
200
- return takeObject(ret);
201
- };
202
-
203
- function getArrayU8FromWasm0(ptr, len) {
204
- ptr = ptr >>> 0;
205
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
186
+ function _assertClass(instance, klass) {
187
+ if (!(instance instanceof klass)) {
188
+ throw new Error(`expected instance of ${klass.name}`);
189
+ }
190
+ return instance.ptr;
206
191
  }
207
192
  /**
208
- * @param {any} acir
209
- * @returns {Uint8Array}
193
+ * This is a method that exposes the same API as `compile`
194
+ * But uses the Context based APi internally
195
+ * @param {string} entry_point
196
+ * @param {boolean | undefined} contracts
197
+ * @param {DependencyGraph | undefined} dependency_graph
198
+ * @param {PathToFileSourceMap} file_source_map
199
+ * @returns {CompileResult}
210
200
  */
211
- module.exports.acir_write_bytes = function(acir) {
201
+ module.exports.compile_ = function(entry_point, contracts, dependency_graph, file_source_map) {
212
202
  try {
213
203
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
214
- wasm.acir_write_bytes(retptr, addHeapObject(acir));
204
+ const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
205
+ const len0 = WASM_VECTOR_LEN;
206
+ _assertClass(file_source_map, PathToFileSourceMap);
207
+ var ptr1 = file_source_map.__destroy_into_raw();
208
+ wasm.compile_(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
215
209
  var r0 = getInt32Memory0()[retptr / 4 + 0];
216
210
  var r1 = getInt32Memory0()[retptr / 4 + 1];
217
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
218
- wasm.__wbindgen_export_2(r0, r1 * 1);
219
- return v1;
211
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
212
+ if (r2) {
213
+ throw takeObject(r1);
214
+ }
215
+ return takeObject(r0);
220
216
  } finally {
221
217
  wasm.__wbindgen_add_to_stack_pointer(16);
222
218
  }
223
219
  };
224
220
 
225
- /**
226
- * @param {string} level
227
- */
228
- module.exports.init_log_level = function(level) {
229
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
230
- const len0 = WASM_VECTOR_LEN;
231
- wasm.init_log_level(ptr0, len0);
232
- };
233
-
234
- /**
235
- * @returns {any}
236
- */
237
- module.exports.build_info = function() {
238
- const ret = wasm.build_info();
239
- return takeObject(ret);
240
- };
241
-
242
- function _assertClass(instance, klass) {
243
- if (!(instance instanceof klass)) {
244
- throw new Error(`expected instance of ${klass.name}`);
245
- }
246
- return instance.ptr;
247
- }
248
221
  /**
249
222
  * @param {string} entry_point
250
223
  * @param {boolean | undefined} contracts
@@ -272,6 +245,23 @@ module.exports.compile = function(entry_point, contracts, dependency_graph, file
272
245
  }
273
246
  };
274
247
 
248
+ /**
249
+ * @param {string} filter
250
+ */
251
+ module.exports.init_log_level = function(filter) {
252
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
253
+ const len0 = WASM_VECTOR_LEN;
254
+ wasm.init_log_level(ptr0, len0);
255
+ };
256
+
257
+ /**
258
+ * @returns {any}
259
+ */
260
+ module.exports.build_info = function() {
261
+ const ret = wasm.build_info();
262
+ return takeObject(ret);
263
+ };
264
+
275
265
  function handleError(f, args) {
276
266
  try {
277
267
  return f.apply(this, args);
@@ -280,6 +270,140 @@ function handleError(f, args) {
280
270
  }
281
271
  }
282
272
  /**
273
+ * This is a wrapper class that is wasm-bindgen compatible
274
+ * We do not use js_name and rename it like CrateId because
275
+ * then the impl block is not picked up in javascript.
276
+ */
277
+ class CompilerContext {
278
+
279
+ static __wrap(ptr) {
280
+ ptr = ptr >>> 0;
281
+ const obj = Object.create(CompilerContext.prototype);
282
+ obj.__wbg_ptr = ptr;
283
+
284
+ return obj;
285
+ }
286
+
287
+ __destroy_into_raw() {
288
+ const ptr = this.__wbg_ptr;
289
+ this.__wbg_ptr = 0;
290
+
291
+ return ptr;
292
+ }
293
+
294
+ free() {
295
+ const ptr = this.__destroy_into_raw();
296
+ wasm.__wbg_compilercontext_free(ptr);
297
+ }
298
+ /**
299
+ * @param {PathToFileSourceMap} source_map
300
+ */
301
+ constructor(source_map) {
302
+ _assertClass(source_map, PathToFileSourceMap);
303
+ var ptr0 = source_map.__destroy_into_raw();
304
+ const ret = wasm.compilercontext_new(ptr0);
305
+ return CompilerContext.__wrap(ret);
306
+ }
307
+ /**
308
+ * @param {string} path_to_crate
309
+ * @returns {CrateId}
310
+ */
311
+ process_root_crate(path_to_crate) {
312
+ const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
313
+ const len0 = WASM_VECTOR_LEN;
314
+ const ret = wasm.compilercontext_process_root_crate(this.__wbg_ptr, ptr0, len0);
315
+ return CrateId.__wrap(ret);
316
+ }
317
+ /**
318
+ * @param {string} path_to_crate
319
+ * @returns {CrateId}
320
+ */
321
+ process_dependency_crate(path_to_crate) {
322
+ const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
323
+ const len0 = WASM_VECTOR_LEN;
324
+ const ret = wasm.compilercontext_process_dependency_crate(this.__wbg_ptr, ptr0, len0);
325
+ return CrateId.__wrap(ret);
326
+ }
327
+ /**
328
+ * @param {string} crate_name
329
+ * @param {CrateId} from
330
+ * @param {CrateId} to
331
+ */
332
+ add_dependency_edge(crate_name, from, to) {
333
+ const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
334
+ const len0 = WASM_VECTOR_LEN;
335
+ _assertClass(from, CrateId);
336
+ _assertClass(to, CrateId);
337
+ wasm.compilercontext_add_dependency_edge(this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
338
+ }
339
+ /**
340
+ * @param {number} program_width
341
+ * @returns {CompileResult}
342
+ */
343
+ compile_program(program_width) {
344
+ try {
345
+ const ptr = this.__destroy_into_raw();
346
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
347
+ wasm.compilercontext_compile_program(retptr, ptr, program_width);
348
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
349
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
350
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
351
+ if (r2) {
352
+ throw takeObject(r1);
353
+ }
354
+ return takeObject(r0);
355
+ } finally {
356
+ wasm.__wbindgen_add_to_stack_pointer(16);
357
+ }
358
+ }
359
+ /**
360
+ * @param {number} program_width
361
+ * @returns {CompileResult}
362
+ */
363
+ compile_contract(program_width) {
364
+ try {
365
+ const ptr = this.__destroy_into_raw();
366
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
367
+ wasm.compilercontext_compile_contract(retptr, ptr, program_width);
368
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
369
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
370
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
371
+ if (r2) {
372
+ throw takeObject(r1);
373
+ }
374
+ return takeObject(r0);
375
+ } finally {
376
+ wasm.__wbindgen_add_to_stack_pointer(16);
377
+ }
378
+ }
379
+ }
380
+ module.exports.CompilerContext = CompilerContext;
381
+ /**
382
+ */
383
+ class CrateId {
384
+
385
+ static __wrap(ptr) {
386
+ ptr = ptr >>> 0;
387
+ const obj = Object.create(CrateId.prototype);
388
+ obj.__wbg_ptr = ptr;
389
+
390
+ return obj;
391
+ }
392
+
393
+ __destroy_into_raw() {
394
+ const ptr = this.__wbg_ptr;
395
+ this.__wbg_ptr = 0;
396
+
397
+ return ptr;
398
+ }
399
+
400
+ free() {
401
+ const ptr = this.__destroy_into_raw();
402
+ wasm.__wbg_crateid_free(ptr);
403
+ }
404
+ }
405
+ module.exports.CrateId = CrateId;
406
+ /**
283
407
  */
284
408
  class PathToFileSourceMap {
285
409
 
@@ -324,30 +448,25 @@ class PathToFileSourceMap {
324
448
  }
325
449
  module.exports.PathToFileSourceMap = PathToFileSourceMap;
326
450
 
451
+ module.exports.__wbindgen_is_undefined = function(arg0) {
452
+ const ret = getObject(arg0) === undefined;
453
+ return ret;
454
+ };
455
+
327
456
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
328
457
  takeObject(arg0);
329
458
  };
330
459
 
331
- module.exports.__wbg_constructor_35233efb35960b52 = function(arg0) {
460
+ module.exports.__wbg_constructor_a29cdb41a75eb0e8 = function(arg0) {
332
461
  const ret = new Error(takeObject(arg0));
333
462
  return addHeapObject(ret);
334
463
  };
335
464
 
336
- module.exports.__wbindgen_is_undefined = function(arg0) {
337
- const ret = getObject(arg0) === undefined;
338
- return ret;
339
- };
340
-
341
- module.exports.__wbg_constructor_0fbcf25c6da50731 = function() {
465
+ module.exports.__wbg_constructor_a3b5b211c5053ce8 = function() {
342
466
  const ret = new Object();
343
467
  return addHeapObject(ret);
344
468
  };
345
469
 
346
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
347
- const ret = getStringFromWasm0(arg0, arg1);
348
- return addHeapObject(ret);
349
- };
350
-
351
470
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
352
471
  const ret = new Error();
353
472
  return addHeapObject(ret);
@@ -373,6 +492,15 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
373
492
  }
374
493
  };
375
494
 
495
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
496
+ const ret = getStringFromWasm0(arg0, arg1);
497
+ return addHeapObject(ret);
498
+ };
499
+
500
+ module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
501
+ console.debug(getObject(arg0));
502
+ };
503
+
376
504
  module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
377
505
  console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
378
506
  };
@@ -385,12 +513,16 @@ module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
385
513
  console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
386
514
  };
387
515
 
516
+ module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
517
+ console.info(getObject(arg0));
518
+ };
519
+
388
520
  module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
389
521
  console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
390
522
  };
391
523
 
392
- module.exports.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
393
- console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
524
+ module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
525
+ console.warn(getObject(arg0));
394
526
  };
395
527
 
396
528
  module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
Binary file
@@ -1,14 +1,21 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function acir_read_bytes(a: number, b: number): number;
5
- export function acir_write_bytes(a: number, b: number): void;
6
- export function init_log_level(a: number, b: number): void;
7
- export function build_info(): number;
4
+ export function __wbg_compilercontext_free(a: number): void;
5
+ export function __wbg_crateid_free(a: number): void;
6
+ export function compilercontext_new(a: number): number;
7
+ export function compilercontext_process_root_crate(a: number, b: number, c: number): number;
8
+ export function compilercontext_process_dependency_crate(a: number, b: number, c: number): number;
9
+ export function compilercontext_add_dependency_edge(a: number, b: number, c: number, d: number, e: number): void;
10
+ export function compilercontext_compile_program(a: number, b: number, c: number): void;
11
+ export function compilercontext_compile_contract(a: number, b: number, c: number): void;
12
+ export function compile_(a: number, b: number, c: number, d: number, e: number, f: number): void;
8
13
  export function __wbg_pathtofilesourcemap_free(a: number): void;
9
14
  export function pathtofilesourcemap_new(): number;
10
15
  export function pathtofilesourcemap_add_source_code(a: number, b: number, c: number, d: number, e: number): number;
11
16
  export function compile(a: number, b: number, c: number, d: number, e: number, f: number): void;
17
+ export function init_log_level(a: number, b: number): void;
18
+ export function build_info(): number;
12
19
  export function __wbindgen_export_0(a: number): number;
13
20
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
14
21
  export function __wbindgen_add_to_stack_pointer(a: number): number;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@noir-lang/noir_wasm",
3
- "collaborators": [
3
+ "contributors": [
4
4
  "The Noir Team <team@noir-lang.org>"
5
5
  ],
6
- "version": "0.21.0",
6
+ "version": "0.22.0-223e860.nightly",
7
7
  "license": "(MIT OR Apache-2.0)",
8
8
  "main": "./nodejs/noir_wasm.js",
9
9
  "types": "./web/noir_wasm.d.ts",
@@ -14,9 +14,14 @@
14
14
  "package.json"
15
15
  ],
16
16
  "sideEffects": false,
17
+ "homepage": "https://noir-lang.org/",
17
18
  "repository": {
18
- "type": "git",
19
- "url": "https://github.com/noir-lang/noir.git"
19
+ "url": "https://github.com/noir-lang/noir.git",
20
+ "directory": "compiler/wasm",
21
+ "type": "git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/noir-lang/noir/issues"
20
25
  },
21
26
  "scripts": {
22
27
  "build": "bash ./build.sh",
@@ -1,23 +1,15 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {Uint8Array} bytes
5
- * @returns {any}
6
- */
7
- export function acir_read_bytes(bytes: Uint8Array): any;
8
- /**
9
- * @param {any} acir
10
- * @returns {Uint8Array}
11
- */
12
- export function acir_write_bytes(acir: any): Uint8Array;
13
- /**
14
- * @param {string} level
15
- */
16
- export function init_log_level(level: string): void;
17
- /**
18
- * @returns {any}
4
+ * This is a method that exposes the same API as `compile`
5
+ * But uses the Context based APi internally
6
+ * @param {string} entry_point
7
+ * @param {boolean | undefined} contracts
8
+ * @param {DependencyGraph | undefined} dependency_graph
9
+ * @param {PathToFileSourceMap} file_source_map
10
+ * @returns {CompileResult}
19
11
  */
20
- export function build_info(): any;
12
+ export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
21
13
  /**
22
14
  * @param {string} entry_point
23
15
  * @param {boolean | undefined} contracts
@@ -26,6 +18,14 @@ export function build_info(): any;
26
18
  * @returns {CompileResult}
27
19
  */
28
20
  export function compile(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
21
+ /**
22
+ * @param {string} filter
23
+ */
24
+ export function init_log_level(filter: string): void;
25
+ /**
26
+ * @returns {any}
27
+ */
28
+ export function build_info(): any;
29
29
 
30
30
  export type Diagnostic = {
31
31
  message: string;
@@ -52,14 +52,12 @@ export type DependencyGraph = {
52
52
  export type CompiledContract = {
53
53
  noir_version: string;
54
54
  name: string;
55
- backend: string;
56
55
  functions: Array<any>;
57
56
  events: Array<any>;
58
57
  };
59
58
 
60
59
  export type CompiledProgram = {
61
60
  noir_version: string;
62
- backend: string;
63
61
  abi: any;
64
62
  bytecode: string;
65
63
  }
@@ -82,6 +80,49 @@ export type CompileResult = (
82
80
  );
83
81
 
84
82
 
83
+ /**
84
+ * This is a wrapper class that is wasm-bindgen compatible
85
+ * We do not use js_name and rename it like CrateId because
86
+ * then the impl block is not picked up in javascript.
87
+ */
88
+ export class CompilerContext {
89
+ free(): void;
90
+ /**
91
+ * @param {PathToFileSourceMap} source_map
92
+ */
93
+ constructor(source_map: PathToFileSourceMap);
94
+ /**
95
+ * @param {string} path_to_crate
96
+ * @returns {CrateId}
97
+ */
98
+ process_root_crate(path_to_crate: string): CrateId;
99
+ /**
100
+ * @param {string} path_to_crate
101
+ * @returns {CrateId}
102
+ */
103
+ process_dependency_crate(path_to_crate: string): CrateId;
104
+ /**
105
+ * @param {string} crate_name
106
+ * @param {CrateId} from
107
+ * @param {CrateId} to
108
+ */
109
+ add_dependency_edge(crate_name: string, from: CrateId, to: CrateId): void;
110
+ /**
111
+ * @param {number} program_width
112
+ * @returns {CompileResult}
113
+ */
114
+ compile_program(program_width: number): CompileResult;
115
+ /**
116
+ * @param {number} program_width
117
+ * @returns {CompileResult}
118
+ */
119
+ compile_contract(program_width: number): CompileResult;
120
+ }
121
+ /**
122
+ */
123
+ export class CrateId {
124
+ free(): void;
125
+ }
85
126
  /**
86
127
  */
87
128
  export class PathToFileSourceMap {
@@ -101,14 +142,21 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
101
142
 
102
143
  export interface InitOutput {
103
144
  readonly memory: WebAssembly.Memory;
104
- readonly acir_read_bytes: (a: number, b: number) => number;
105
- readonly acir_write_bytes: (a: number, b: number) => void;
106
- readonly init_log_level: (a: number, b: number) => void;
107
- readonly build_info: () => number;
145
+ readonly __wbg_compilercontext_free: (a: number) => void;
146
+ readonly __wbg_crateid_free: (a: number) => void;
147
+ readonly compilercontext_new: (a: number) => number;
148
+ readonly compilercontext_process_root_crate: (a: number, b: number, c: number) => number;
149
+ readonly compilercontext_process_dependency_crate: (a: number, b: number, c: number) => number;
150
+ readonly compilercontext_add_dependency_edge: (a: number, b: number, c: number, d: number, e: number) => void;
151
+ readonly compilercontext_compile_program: (a: number, b: number, c: number) => void;
152
+ readonly compilercontext_compile_contract: (a: number, b: number, c: number) => void;
153
+ readonly compile_: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
108
154
  readonly __wbg_pathtofilesourcemap_free: (a: number) => void;
109
155
  readonly pathtofilesourcemap_new: () => number;
110
156
  readonly pathtofilesourcemap_add_source_code: (a: number, b: number, c: number, d: number, e: number) => number;
111
157
  readonly compile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
158
+ readonly init_log_level: (a: number, b: number) => void;
159
+ readonly build_info: () => number;
112
160
  readonly __wbindgen_export_0: (a: number) => number;
113
161
  readonly __wbindgen_export_1: (a: number, b: number, c: number) => number;
114
162
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
package/web/noir_wasm.js CHANGED
@@ -180,68 +180,41 @@ function debugString(val) {
180
180
  return className;
181
181
  }
182
182
 
183
- function passArray8ToWasm0(arg, malloc) {
184
- const ptr = malloc(arg.length * 1) >>> 0;
185
- getUint8Memory0().set(arg, ptr / 1);
186
- WASM_VECTOR_LEN = arg.length;
187
- return ptr;
188
- }
189
- /**
190
- * @param {Uint8Array} bytes
191
- * @returns {any}
192
- */
193
- export function acir_read_bytes(bytes) {
194
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0);
195
- const len0 = WASM_VECTOR_LEN;
196
- const ret = wasm.acir_read_bytes(ptr0, len0);
197
- return takeObject(ret);
198
- }
199
-
200
- function getArrayU8FromWasm0(ptr, len) {
201
- ptr = ptr >>> 0;
202
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
183
+ function _assertClass(instance, klass) {
184
+ if (!(instance instanceof klass)) {
185
+ throw new Error(`expected instance of ${klass.name}`);
186
+ }
187
+ return instance.ptr;
203
188
  }
204
189
  /**
205
- * @param {any} acir
206
- * @returns {Uint8Array}
190
+ * This is a method that exposes the same API as `compile`
191
+ * But uses the Context based APi internally
192
+ * @param {string} entry_point
193
+ * @param {boolean | undefined} contracts
194
+ * @param {DependencyGraph | undefined} dependency_graph
195
+ * @param {PathToFileSourceMap} file_source_map
196
+ * @returns {CompileResult}
207
197
  */
208
- export function acir_write_bytes(acir) {
198
+ export function compile_(entry_point, contracts, dependency_graph, file_source_map) {
209
199
  try {
210
200
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
211
- wasm.acir_write_bytes(retptr, addHeapObject(acir));
201
+ const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
202
+ const len0 = WASM_VECTOR_LEN;
203
+ _assertClass(file_source_map, PathToFileSourceMap);
204
+ var ptr1 = file_source_map.__destroy_into_raw();
205
+ wasm.compile_(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
212
206
  var r0 = getInt32Memory0()[retptr / 4 + 0];
213
207
  var r1 = getInt32Memory0()[retptr / 4 + 1];
214
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
215
- wasm.__wbindgen_export_2(r0, r1 * 1);
216
- return v1;
208
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
209
+ if (r2) {
210
+ throw takeObject(r1);
211
+ }
212
+ return takeObject(r0);
217
213
  } finally {
218
214
  wasm.__wbindgen_add_to_stack_pointer(16);
219
215
  }
220
216
  }
221
217
 
222
- /**
223
- * @param {string} level
224
- */
225
- export function init_log_level(level) {
226
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
227
- const len0 = WASM_VECTOR_LEN;
228
- wasm.init_log_level(ptr0, len0);
229
- }
230
-
231
- /**
232
- * @returns {any}
233
- */
234
- export function build_info() {
235
- const ret = wasm.build_info();
236
- return takeObject(ret);
237
- }
238
-
239
- function _assertClass(instance, klass) {
240
- if (!(instance instanceof klass)) {
241
- throw new Error(`expected instance of ${klass.name}`);
242
- }
243
- return instance.ptr;
244
- }
245
218
  /**
246
219
  * @param {string} entry_point
247
220
  * @param {boolean | undefined} contracts
@@ -269,6 +242,23 @@ export function compile(entry_point, contracts, dependency_graph, file_source_ma
269
242
  }
270
243
  }
271
244
 
245
+ /**
246
+ * @param {string} filter
247
+ */
248
+ export function init_log_level(filter) {
249
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
250
+ const len0 = WASM_VECTOR_LEN;
251
+ wasm.init_log_level(ptr0, len0);
252
+ }
253
+
254
+ /**
255
+ * @returns {any}
256
+ */
257
+ export function build_info() {
258
+ const ret = wasm.build_info();
259
+ return takeObject(ret);
260
+ }
261
+
272
262
  function handleError(f, args) {
273
263
  try {
274
264
  return f.apply(this, args);
@@ -277,6 +267,138 @@ function handleError(f, args) {
277
267
  }
278
268
  }
279
269
  /**
270
+ * This is a wrapper class that is wasm-bindgen compatible
271
+ * We do not use js_name and rename it like CrateId because
272
+ * then the impl block is not picked up in javascript.
273
+ */
274
+ export class CompilerContext {
275
+
276
+ static __wrap(ptr) {
277
+ ptr = ptr >>> 0;
278
+ const obj = Object.create(CompilerContext.prototype);
279
+ obj.__wbg_ptr = ptr;
280
+
281
+ return obj;
282
+ }
283
+
284
+ __destroy_into_raw() {
285
+ const ptr = this.__wbg_ptr;
286
+ this.__wbg_ptr = 0;
287
+
288
+ return ptr;
289
+ }
290
+
291
+ free() {
292
+ const ptr = this.__destroy_into_raw();
293
+ wasm.__wbg_compilercontext_free(ptr);
294
+ }
295
+ /**
296
+ * @param {PathToFileSourceMap} source_map
297
+ */
298
+ constructor(source_map) {
299
+ _assertClass(source_map, PathToFileSourceMap);
300
+ var ptr0 = source_map.__destroy_into_raw();
301
+ const ret = wasm.compilercontext_new(ptr0);
302
+ return CompilerContext.__wrap(ret);
303
+ }
304
+ /**
305
+ * @param {string} path_to_crate
306
+ * @returns {CrateId}
307
+ */
308
+ process_root_crate(path_to_crate) {
309
+ const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
310
+ const len0 = WASM_VECTOR_LEN;
311
+ const ret = wasm.compilercontext_process_root_crate(this.__wbg_ptr, ptr0, len0);
312
+ return CrateId.__wrap(ret);
313
+ }
314
+ /**
315
+ * @param {string} path_to_crate
316
+ * @returns {CrateId}
317
+ */
318
+ process_dependency_crate(path_to_crate) {
319
+ const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
320
+ const len0 = WASM_VECTOR_LEN;
321
+ const ret = wasm.compilercontext_process_dependency_crate(this.__wbg_ptr, ptr0, len0);
322
+ return CrateId.__wrap(ret);
323
+ }
324
+ /**
325
+ * @param {string} crate_name
326
+ * @param {CrateId} from
327
+ * @param {CrateId} to
328
+ */
329
+ add_dependency_edge(crate_name, from, to) {
330
+ const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
331
+ const len0 = WASM_VECTOR_LEN;
332
+ _assertClass(from, CrateId);
333
+ _assertClass(to, CrateId);
334
+ wasm.compilercontext_add_dependency_edge(this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
335
+ }
336
+ /**
337
+ * @param {number} program_width
338
+ * @returns {CompileResult}
339
+ */
340
+ compile_program(program_width) {
341
+ try {
342
+ const ptr = this.__destroy_into_raw();
343
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
344
+ wasm.compilercontext_compile_program(retptr, ptr, program_width);
345
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
346
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
347
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
348
+ if (r2) {
349
+ throw takeObject(r1);
350
+ }
351
+ return takeObject(r0);
352
+ } finally {
353
+ wasm.__wbindgen_add_to_stack_pointer(16);
354
+ }
355
+ }
356
+ /**
357
+ * @param {number} program_width
358
+ * @returns {CompileResult}
359
+ */
360
+ compile_contract(program_width) {
361
+ try {
362
+ const ptr = this.__destroy_into_raw();
363
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
364
+ wasm.compilercontext_compile_contract(retptr, ptr, program_width);
365
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
366
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
367
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
368
+ if (r2) {
369
+ throw takeObject(r1);
370
+ }
371
+ return takeObject(r0);
372
+ } finally {
373
+ wasm.__wbindgen_add_to_stack_pointer(16);
374
+ }
375
+ }
376
+ }
377
+ /**
378
+ */
379
+ export class CrateId {
380
+
381
+ static __wrap(ptr) {
382
+ ptr = ptr >>> 0;
383
+ const obj = Object.create(CrateId.prototype);
384
+ obj.__wbg_ptr = ptr;
385
+
386
+ return obj;
387
+ }
388
+
389
+ __destroy_into_raw() {
390
+ const ptr = this.__wbg_ptr;
391
+ this.__wbg_ptr = 0;
392
+
393
+ return ptr;
394
+ }
395
+
396
+ free() {
397
+ const ptr = this.__destroy_into_raw();
398
+ wasm.__wbg_crateid_free(ptr);
399
+ }
400
+ }
401
+ /**
280
402
  */
281
403
  export class PathToFileSourceMap {
282
404
 
@@ -354,25 +476,21 @@ async function __wbg_load(module, imports) {
354
476
  function __wbg_get_imports() {
355
477
  const imports = {};
356
478
  imports.wbg = {};
479
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
480
+ const ret = getObject(arg0) === undefined;
481
+ return ret;
482
+ };
357
483
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
358
484
  takeObject(arg0);
359
485
  };
360
- imports.wbg.__wbg_constructor_35233efb35960b52 = function(arg0) {
486
+ imports.wbg.__wbg_constructor_a29cdb41a75eb0e8 = function(arg0) {
361
487
  const ret = new Error(takeObject(arg0));
362
488
  return addHeapObject(ret);
363
489
  };
364
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
365
- const ret = getObject(arg0) === undefined;
366
- return ret;
367
- };
368
- imports.wbg.__wbg_constructor_0fbcf25c6da50731 = function() {
490
+ imports.wbg.__wbg_constructor_a3b5b211c5053ce8 = function() {
369
491
  const ret = new Object();
370
492
  return addHeapObject(ret);
371
493
  };
372
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
373
- const ret = getStringFromWasm0(arg0, arg1);
374
- return addHeapObject(ret);
375
- };
376
494
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
377
495
  const ret = new Error();
378
496
  return addHeapObject(ret);
@@ -395,6 +513,13 @@ function __wbg_get_imports() {
395
513
  wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
396
514
  }
397
515
  };
516
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
517
+ const ret = getStringFromWasm0(arg0, arg1);
518
+ return addHeapObject(ret);
519
+ };
520
+ imports.wbg.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
521
+ console.debug(getObject(arg0));
522
+ };
398
523
  imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
399
524
  console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
400
525
  };
@@ -404,11 +529,14 @@ function __wbg_get_imports() {
404
529
  imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
405
530
  console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
406
531
  };
532
+ imports.wbg.__wbg_info_05db236d79f1b785 = function(arg0) {
533
+ console.info(getObject(arg0));
534
+ };
407
535
  imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
408
536
  console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
409
537
  };
410
- imports.wbg.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
411
- console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
538
+ imports.wbg.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
539
+ console.warn(getObject(arg0));
412
540
  };
413
541
  imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
414
542
  console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
Binary file
@@ -1,14 +1,21 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function acir_read_bytes(a: number, b: number): number;
5
- export function acir_write_bytes(a: number, b: number): void;
6
- export function init_log_level(a: number, b: number): void;
7
- export function build_info(): number;
4
+ export function __wbg_compilercontext_free(a: number): void;
5
+ export function __wbg_crateid_free(a: number): void;
6
+ export function compilercontext_new(a: number): number;
7
+ export function compilercontext_process_root_crate(a: number, b: number, c: number): number;
8
+ export function compilercontext_process_dependency_crate(a: number, b: number, c: number): number;
9
+ export function compilercontext_add_dependency_edge(a: number, b: number, c: number, d: number, e: number): void;
10
+ export function compilercontext_compile_program(a: number, b: number, c: number): void;
11
+ export function compilercontext_compile_contract(a: number, b: number, c: number): void;
12
+ export function compile_(a: number, b: number, c: number, d: number, e: number, f: number): void;
8
13
  export function __wbg_pathtofilesourcemap_free(a: number): void;
9
14
  export function pathtofilesourcemap_new(): number;
10
15
  export function pathtofilesourcemap_add_source_code(a: number, b: number, c: number, d: number, e: number): number;
11
16
  export function compile(a: number, b: number, c: number, d: number, e: number, f: number): void;
17
+ export function init_log_level(a: number, b: number): void;
18
+ export function build_info(): number;
12
19
  export function __wbindgen_export_0(a: number): number;
13
20
  export function __wbindgen_export_1(a: number, b: number, c: number): number;
14
21
  export function __wbindgen_add_to_stack_pointer(a: number): number;