@noir-lang/noir_wasm 0.21.0 → 0.22.0-179c90d.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,19 +1,19 @@
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}
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}
11
11
  */
12
- export function acir_write_bytes(acir: any): Uint8Array;
12
+ export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
13
13
  /**
14
- * @param {string} level
14
+ * @param {string} filter
15
15
  */
16
- export function init_log_level(level: string): void;
16
+ export function init_log_level(filter: string): void;
17
17
  /**
18
18
  * @returns {any}
19
19
  */
@@ -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,50 +183,46 @@ 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
221
  /**
226
- * @param {string} level
222
+ * @param {string} filter
227
223
  */
228
- module.exports.init_log_level = function(level) {
229
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
224
+ module.exports.init_log_level = function(filter) {
225
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
230
226
  const len0 = WASM_VECTOR_LEN;
231
227
  wasm.init_log_level(ptr0, len0);
232
228
  };
@@ -239,12 +235,6 @@ module.exports.build_info = function() {
239
235
  return takeObject(ret);
240
236
  };
241
237
 
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
238
  /**
249
239
  * @param {string} entry_point
250
240
  * @param {boolean | undefined} contracts
@@ -280,6 +270,150 @@ 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
+ try {
334
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
335
+ const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
336
+ const len0 = WASM_VECTOR_LEN;
337
+ _assertClass(from, CrateId);
338
+ _assertClass(to, CrateId);
339
+ wasm.compilercontext_add_dependency_edge(retptr, this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
340
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
341
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
342
+ if (r1) {
343
+ throw takeObject(r0);
344
+ }
345
+ } finally {
346
+ wasm.__wbindgen_add_to_stack_pointer(16);
347
+ }
348
+ }
349
+ /**
350
+ * @param {number} program_width
351
+ * @returns {CompileResult}
352
+ */
353
+ compile_program(program_width) {
354
+ try {
355
+ const ptr = this.__destroy_into_raw();
356
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
357
+ wasm.compilercontext_compile_program(retptr, ptr, program_width);
358
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
359
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
360
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
361
+ if (r2) {
362
+ throw takeObject(r1);
363
+ }
364
+ return takeObject(r0);
365
+ } finally {
366
+ wasm.__wbindgen_add_to_stack_pointer(16);
367
+ }
368
+ }
369
+ /**
370
+ * @param {number} program_width
371
+ * @returns {CompileResult}
372
+ */
373
+ compile_contract(program_width) {
374
+ try {
375
+ const ptr = this.__destroy_into_raw();
376
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
377
+ wasm.compilercontext_compile_contract(retptr, ptr, program_width);
378
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
379
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
380
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
381
+ if (r2) {
382
+ throw takeObject(r1);
383
+ }
384
+ return takeObject(r0);
385
+ } finally {
386
+ wasm.__wbindgen_add_to_stack_pointer(16);
387
+ }
388
+ }
389
+ }
390
+ module.exports.CompilerContext = CompilerContext;
391
+ /**
392
+ */
393
+ class CrateId {
394
+
395
+ static __wrap(ptr) {
396
+ ptr = ptr >>> 0;
397
+ const obj = Object.create(CrateId.prototype);
398
+ obj.__wbg_ptr = ptr;
399
+
400
+ return obj;
401
+ }
402
+
403
+ __destroy_into_raw() {
404
+ const ptr = this.__wbg_ptr;
405
+ this.__wbg_ptr = 0;
406
+
407
+ return ptr;
408
+ }
409
+
410
+ free() {
411
+ const ptr = this.__destroy_into_raw();
412
+ wasm.__wbg_crateid_free(ptr);
413
+ }
414
+ }
415
+ module.exports.CrateId = CrateId;
416
+ /**
283
417
  */
284
418
  class PathToFileSourceMap {
285
419
 
@@ -328,24 +462,19 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
328
462
  takeObject(arg0);
329
463
  };
330
464
 
331
- module.exports.__wbg_constructor_35233efb35960b52 = function(arg0) {
465
+ module.exports.__wbg_constructor_a29cdb41a75eb0e8 = function(arg0) {
332
466
  const ret = new Error(takeObject(arg0));
333
467
  return addHeapObject(ret);
334
468
  };
335
469
 
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() {
470
+ module.exports.__wbg_constructor_a3b5b211c5053ce8 = function() {
342
471
  const ret = new Object();
343
472
  return addHeapObject(ret);
344
473
  };
345
474
 
346
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
347
- const ret = getStringFromWasm0(arg0, arg1);
348
- return addHeapObject(ret);
475
+ module.exports.__wbindgen_is_undefined = function(arg0) {
476
+ const ret = getObject(arg0) === undefined;
477
+ return ret;
349
478
  };
350
479
 
351
480
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
@@ -373,6 +502,15 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
373
502
  }
374
503
  };
375
504
 
505
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
506
+ const ret = getStringFromWasm0(arg0, arg1);
507
+ return addHeapObject(ret);
508
+ };
509
+
510
+ module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
511
+ console.debug(getObject(arg0));
512
+ };
513
+
376
514
  module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
377
515
  console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
378
516
  };
@@ -385,12 +523,16 @@ module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
385
523
  console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
386
524
  };
387
525
 
526
+ module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
527
+ console.info(getObject(arg0));
528
+ };
529
+
388
530
  module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
389
531
  console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
390
532
  };
391
533
 
392
- module.exports.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
393
- console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
534
+ module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
535
+ console.warn(getObject(arg0));
394
536
  };
395
537
 
396
538
  module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
Binary file
@@ -1,8 +1,15 @@
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;
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, f: 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;
6
13
  export function init_log_level(a: number, b: number): void;
7
14
  export function build_info(): number;
8
15
  export function __wbg_pathtofilesourcemap_free(a: number): void;
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-179c90d.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,19 +1,19 @@
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}
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}
11
11
  */
12
- export function acir_write_bytes(acir: any): Uint8Array;
12
+ export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
13
13
  /**
14
- * @param {string} level
14
+ * @param {string} filter
15
15
  */
16
- export function init_log_level(level: string): void;
16
+ export function init_log_level(filter: string): void;
17
17
  /**
18
18
  * @returns {any}
19
19
  */
@@ -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,8 +142,15 @@ 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;
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, f: 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;
106
154
  readonly init_log_level: (a: number, b: number) => void;
107
155
  readonly build_info: () => number;
108
156
  readonly __wbg_pathtofilesourcemap_free: (a: number) => void;
package/web/noir_wasm.js CHANGED
@@ -180,50 +180,46 @@ 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
218
  /**
223
- * @param {string} level
219
+ * @param {string} filter
224
220
  */
225
- export function init_log_level(level) {
226
- const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
221
+ export function init_log_level(filter) {
222
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
227
223
  const len0 = WASM_VECTOR_LEN;
228
224
  wasm.init_log_level(ptr0, len0);
229
225
  }
@@ -236,12 +232,6 @@ export function build_info() {
236
232
  return takeObject(ret);
237
233
  }
238
234
 
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
235
  /**
246
236
  * @param {string} entry_point
247
237
  * @param {boolean | undefined} contracts
@@ -277,6 +267,148 @@ 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
+ try {
331
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
332
+ const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
333
+ const len0 = WASM_VECTOR_LEN;
334
+ _assertClass(from, CrateId);
335
+ _assertClass(to, CrateId);
336
+ wasm.compilercontext_add_dependency_edge(retptr, this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
337
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
338
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
339
+ if (r1) {
340
+ throw takeObject(r0);
341
+ }
342
+ } finally {
343
+ wasm.__wbindgen_add_to_stack_pointer(16);
344
+ }
345
+ }
346
+ /**
347
+ * @param {number} program_width
348
+ * @returns {CompileResult}
349
+ */
350
+ compile_program(program_width) {
351
+ try {
352
+ const ptr = this.__destroy_into_raw();
353
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
354
+ wasm.compilercontext_compile_program(retptr, ptr, program_width);
355
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
356
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
357
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
358
+ if (r2) {
359
+ throw takeObject(r1);
360
+ }
361
+ return takeObject(r0);
362
+ } finally {
363
+ wasm.__wbindgen_add_to_stack_pointer(16);
364
+ }
365
+ }
366
+ /**
367
+ * @param {number} program_width
368
+ * @returns {CompileResult}
369
+ */
370
+ compile_contract(program_width) {
371
+ try {
372
+ const ptr = this.__destroy_into_raw();
373
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
374
+ wasm.compilercontext_compile_contract(retptr, ptr, program_width);
375
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
376
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
377
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
378
+ if (r2) {
379
+ throw takeObject(r1);
380
+ }
381
+ return takeObject(r0);
382
+ } finally {
383
+ wasm.__wbindgen_add_to_stack_pointer(16);
384
+ }
385
+ }
386
+ }
387
+ /**
388
+ */
389
+ export class CrateId {
390
+
391
+ static __wrap(ptr) {
392
+ ptr = ptr >>> 0;
393
+ const obj = Object.create(CrateId.prototype);
394
+ obj.__wbg_ptr = ptr;
395
+
396
+ return obj;
397
+ }
398
+
399
+ __destroy_into_raw() {
400
+ const ptr = this.__wbg_ptr;
401
+ this.__wbg_ptr = 0;
402
+
403
+ return ptr;
404
+ }
405
+
406
+ free() {
407
+ const ptr = this.__destroy_into_raw();
408
+ wasm.__wbg_crateid_free(ptr);
409
+ }
410
+ }
411
+ /**
280
412
  */
281
413
  export class PathToFileSourceMap {
282
414
 
@@ -357,21 +489,17 @@ function __wbg_get_imports() {
357
489
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
358
490
  takeObject(arg0);
359
491
  };
360
- imports.wbg.__wbg_constructor_35233efb35960b52 = function(arg0) {
492
+ imports.wbg.__wbg_constructor_a29cdb41a75eb0e8 = function(arg0) {
361
493
  const ret = new Error(takeObject(arg0));
362
494
  return addHeapObject(ret);
363
495
  };
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() {
496
+ imports.wbg.__wbg_constructor_a3b5b211c5053ce8 = function() {
369
497
  const ret = new Object();
370
498
  return addHeapObject(ret);
371
499
  };
372
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
373
- const ret = getStringFromWasm0(arg0, arg1);
374
- return addHeapObject(ret);
500
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
501
+ const ret = getObject(arg0) === undefined;
502
+ return ret;
375
503
  };
376
504
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
377
505
  const ret = new Error();
@@ -395,6 +523,13 @@ function __wbg_get_imports() {
395
523
  wasm.__wbindgen_export_2(deferred0_0, deferred0_1);
396
524
  }
397
525
  };
526
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
527
+ const ret = getStringFromWasm0(arg0, arg1);
528
+ return addHeapObject(ret);
529
+ };
530
+ imports.wbg.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
531
+ console.debug(getObject(arg0));
532
+ };
398
533
  imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
399
534
  console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
400
535
  };
@@ -404,11 +539,14 @@ function __wbg_get_imports() {
404
539
  imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
405
540
  console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
406
541
  };
542
+ imports.wbg.__wbg_info_05db236d79f1b785 = function(arg0) {
543
+ console.info(getObject(arg0));
544
+ };
407
545
  imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
408
546
  console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
409
547
  };
410
- imports.wbg.__wbg_log_9b164efbe6db702f = function(arg0, arg1, arg2, arg3) {
411
- console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
548
+ imports.wbg.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
549
+ console.warn(getObject(arg0));
412
550
  };
413
551
  imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
414
552
  console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
Binary file
@@ -1,8 +1,15 @@
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;
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, f: 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;
6
13
  export function init_log_level(a: number, b: number): void;
7
14
  export function build_info(): number;
8
15
  export function __wbg_pathtofilesourcemap_free(a: number): void;