@noir-lang/noir_wasm 0.21.0 → 0.22.0
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.
- package/nodejs/noir_wasm.d.ts +53 -2
- package/nodejs/noir_wasm.js +171 -8
- package/nodejs/noir_wasm_bg.wasm +0 -0
- package/nodejs/noir_wasm_bg.wasm.d.ts +9 -0
- package/package.json +1 -1
- package/web/noir_wasm.d.ts +62 -2
- package/web/noir_wasm.js +169 -8
- package/web/noir_wasm_bg.wasm +0 -0
- package/web/noir_wasm_bg.wasm.d.ts +9 -0
package/nodejs/noir_wasm.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export function acir_read_bytes(bytes: Uint8Array): any;
|
|
|
11
11
|
*/
|
|
12
12
|
export function acir_write_bytes(acir: any): Uint8Array;
|
|
13
13
|
/**
|
|
14
|
+
* This is a method that exposes the same API as `compile`
|
|
15
|
+
* But uses the Context based APi internally
|
|
16
|
+
* @param {string} entry_point
|
|
17
|
+
* @param {boolean | undefined} contracts
|
|
18
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
19
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
20
|
+
* @returns {CompileResult}
|
|
21
|
+
*/
|
|
22
|
+
export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
|
|
23
|
+
/**
|
|
14
24
|
* @param {string} level
|
|
15
25
|
*/
|
|
16
26
|
export function init_log_level(level: string): void;
|
|
@@ -52,14 +62,12 @@ export type DependencyGraph = {
|
|
|
52
62
|
export type CompiledContract = {
|
|
53
63
|
noir_version: string;
|
|
54
64
|
name: string;
|
|
55
|
-
backend: string;
|
|
56
65
|
functions: Array<any>;
|
|
57
66
|
events: Array<any>;
|
|
58
67
|
};
|
|
59
68
|
|
|
60
69
|
export type CompiledProgram = {
|
|
61
70
|
noir_version: string;
|
|
62
|
-
backend: string;
|
|
63
71
|
abi: any;
|
|
64
72
|
bytecode: string;
|
|
65
73
|
}
|
|
@@ -82,6 +90,49 @@ export type CompileResult = (
|
|
|
82
90
|
);
|
|
83
91
|
|
|
84
92
|
|
|
93
|
+
/**
|
|
94
|
+
* This is a wrapper class that is wasm-bindgen compatible
|
|
95
|
+
* We do not use js_name and rename it like CrateId because
|
|
96
|
+
* then the impl block is not picked up in javascript.
|
|
97
|
+
*/
|
|
98
|
+
export class CompilerContext {
|
|
99
|
+
free(): void;
|
|
100
|
+
/**
|
|
101
|
+
* @param {PathToFileSourceMap} source_map
|
|
102
|
+
*/
|
|
103
|
+
constructor(source_map: PathToFileSourceMap);
|
|
104
|
+
/**
|
|
105
|
+
* @param {string} path_to_crate
|
|
106
|
+
* @returns {CrateId}
|
|
107
|
+
*/
|
|
108
|
+
process_root_crate(path_to_crate: string): CrateId;
|
|
109
|
+
/**
|
|
110
|
+
* @param {string} path_to_crate
|
|
111
|
+
* @returns {CrateId}
|
|
112
|
+
*/
|
|
113
|
+
process_dependency_crate(path_to_crate: string): CrateId;
|
|
114
|
+
/**
|
|
115
|
+
* @param {string} crate_name
|
|
116
|
+
* @param {CrateId} from
|
|
117
|
+
* @param {CrateId} to
|
|
118
|
+
*/
|
|
119
|
+
add_dependency_edge(crate_name: string, from: CrateId, to: CrateId): void;
|
|
120
|
+
/**
|
|
121
|
+
* @param {number} program_width
|
|
122
|
+
* @returns {CompileResult}
|
|
123
|
+
*/
|
|
124
|
+
compile_program(program_width: number): CompileResult;
|
|
125
|
+
/**
|
|
126
|
+
* @param {number} program_width
|
|
127
|
+
* @returns {CompileResult}
|
|
128
|
+
*/
|
|
129
|
+
compile_contract(program_width: number): CompileResult;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
*/
|
|
133
|
+
export class CrateId {
|
|
134
|
+
free(): void;
|
|
135
|
+
}
|
|
85
136
|
/**
|
|
86
137
|
*/
|
|
87
138
|
export class PathToFileSourceMap {
|
package/nodejs/noir_wasm.js
CHANGED
|
@@ -222,6 +222,41 @@ module.exports.acir_write_bytes = function(acir) {
|
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
function _assertClass(instance, klass) {
|
|
226
|
+
if (!(instance instanceof klass)) {
|
|
227
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
228
|
+
}
|
|
229
|
+
return instance.ptr;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* This is a method that exposes the same API as `compile`
|
|
233
|
+
* But uses the Context based APi internally
|
|
234
|
+
* @param {string} entry_point
|
|
235
|
+
* @param {boolean | undefined} contracts
|
|
236
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
237
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
238
|
+
* @returns {CompileResult}
|
|
239
|
+
*/
|
|
240
|
+
module.exports.compile_ = function(entry_point, contracts, dependency_graph, file_source_map) {
|
|
241
|
+
try {
|
|
242
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
243
|
+
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
244
|
+
const len0 = WASM_VECTOR_LEN;
|
|
245
|
+
_assertClass(file_source_map, PathToFileSourceMap);
|
|
246
|
+
var ptr1 = file_source_map.__destroy_into_raw();
|
|
247
|
+
wasm.compile_(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
248
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
249
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
250
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
251
|
+
if (r2) {
|
|
252
|
+
throw takeObject(r1);
|
|
253
|
+
}
|
|
254
|
+
return takeObject(r0);
|
|
255
|
+
} finally {
|
|
256
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
225
260
|
/**
|
|
226
261
|
* @param {string} level
|
|
227
262
|
*/
|
|
@@ -239,12 +274,6 @@ module.exports.build_info = function() {
|
|
|
239
274
|
return takeObject(ret);
|
|
240
275
|
};
|
|
241
276
|
|
|
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
277
|
/**
|
|
249
278
|
* @param {string} entry_point
|
|
250
279
|
* @param {boolean | undefined} contracts
|
|
@@ -280,6 +309,140 @@ function handleError(f, args) {
|
|
|
280
309
|
}
|
|
281
310
|
}
|
|
282
311
|
/**
|
|
312
|
+
* This is a wrapper class that is wasm-bindgen compatible
|
|
313
|
+
* We do not use js_name and rename it like CrateId because
|
|
314
|
+
* then the impl block is not picked up in javascript.
|
|
315
|
+
*/
|
|
316
|
+
class CompilerContext {
|
|
317
|
+
|
|
318
|
+
static __wrap(ptr) {
|
|
319
|
+
ptr = ptr >>> 0;
|
|
320
|
+
const obj = Object.create(CompilerContext.prototype);
|
|
321
|
+
obj.__wbg_ptr = ptr;
|
|
322
|
+
|
|
323
|
+
return obj;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
__destroy_into_raw() {
|
|
327
|
+
const ptr = this.__wbg_ptr;
|
|
328
|
+
this.__wbg_ptr = 0;
|
|
329
|
+
|
|
330
|
+
return ptr;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
free() {
|
|
334
|
+
const ptr = this.__destroy_into_raw();
|
|
335
|
+
wasm.__wbg_compilercontext_free(ptr);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* @param {PathToFileSourceMap} source_map
|
|
339
|
+
*/
|
|
340
|
+
constructor(source_map) {
|
|
341
|
+
_assertClass(source_map, PathToFileSourceMap);
|
|
342
|
+
var ptr0 = source_map.__destroy_into_raw();
|
|
343
|
+
const ret = wasm.compilercontext_new(ptr0);
|
|
344
|
+
return CompilerContext.__wrap(ret);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* @param {string} path_to_crate
|
|
348
|
+
* @returns {CrateId}
|
|
349
|
+
*/
|
|
350
|
+
process_root_crate(path_to_crate) {
|
|
351
|
+
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
352
|
+
const len0 = WASM_VECTOR_LEN;
|
|
353
|
+
const ret = wasm.compilercontext_process_root_crate(this.__wbg_ptr, ptr0, len0);
|
|
354
|
+
return CrateId.__wrap(ret);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* @param {string} path_to_crate
|
|
358
|
+
* @returns {CrateId}
|
|
359
|
+
*/
|
|
360
|
+
process_dependency_crate(path_to_crate) {
|
|
361
|
+
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
362
|
+
const len0 = WASM_VECTOR_LEN;
|
|
363
|
+
const ret = wasm.compilercontext_process_dependency_crate(this.__wbg_ptr, ptr0, len0);
|
|
364
|
+
return CrateId.__wrap(ret);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* @param {string} crate_name
|
|
368
|
+
* @param {CrateId} from
|
|
369
|
+
* @param {CrateId} to
|
|
370
|
+
*/
|
|
371
|
+
add_dependency_edge(crate_name, from, to) {
|
|
372
|
+
const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
373
|
+
const len0 = WASM_VECTOR_LEN;
|
|
374
|
+
_assertClass(from, CrateId);
|
|
375
|
+
_assertClass(to, CrateId);
|
|
376
|
+
wasm.compilercontext_add_dependency_edge(this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* @param {number} program_width
|
|
380
|
+
* @returns {CompileResult}
|
|
381
|
+
*/
|
|
382
|
+
compile_program(program_width) {
|
|
383
|
+
try {
|
|
384
|
+
const ptr = this.__destroy_into_raw();
|
|
385
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
386
|
+
wasm.compilercontext_compile_program(retptr, ptr, program_width);
|
|
387
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
388
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
389
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
390
|
+
if (r2) {
|
|
391
|
+
throw takeObject(r1);
|
|
392
|
+
}
|
|
393
|
+
return takeObject(r0);
|
|
394
|
+
} finally {
|
|
395
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* @param {number} program_width
|
|
400
|
+
* @returns {CompileResult}
|
|
401
|
+
*/
|
|
402
|
+
compile_contract(program_width) {
|
|
403
|
+
try {
|
|
404
|
+
const ptr = this.__destroy_into_raw();
|
|
405
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
406
|
+
wasm.compilercontext_compile_contract(retptr, ptr, program_width);
|
|
407
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
408
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
409
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
410
|
+
if (r2) {
|
|
411
|
+
throw takeObject(r1);
|
|
412
|
+
}
|
|
413
|
+
return takeObject(r0);
|
|
414
|
+
} finally {
|
|
415
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
module.exports.CompilerContext = CompilerContext;
|
|
420
|
+
/**
|
|
421
|
+
*/
|
|
422
|
+
class CrateId {
|
|
423
|
+
|
|
424
|
+
static __wrap(ptr) {
|
|
425
|
+
ptr = ptr >>> 0;
|
|
426
|
+
const obj = Object.create(CrateId.prototype);
|
|
427
|
+
obj.__wbg_ptr = ptr;
|
|
428
|
+
|
|
429
|
+
return obj;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
__destroy_into_raw() {
|
|
433
|
+
const ptr = this.__wbg_ptr;
|
|
434
|
+
this.__wbg_ptr = 0;
|
|
435
|
+
|
|
436
|
+
return ptr;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
free() {
|
|
440
|
+
const ptr = this.__destroy_into_raw();
|
|
441
|
+
wasm.__wbg_crateid_free(ptr);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
module.exports.CrateId = CrateId;
|
|
445
|
+
/**
|
|
283
446
|
*/
|
|
284
447
|
class PathToFileSourceMap {
|
|
285
448
|
|
|
@@ -328,7 +491,7 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
328
491
|
takeObject(arg0);
|
|
329
492
|
};
|
|
330
493
|
|
|
331
|
-
module.exports.
|
|
494
|
+
module.exports.__wbg_constructor_a29cdb41a75eb0e8 = function(arg0) {
|
|
332
495
|
const ret = new Error(takeObject(arg0));
|
|
333
496
|
return addHeapObject(ret);
|
|
334
497
|
};
|
|
@@ -338,7 +501,7 @@ module.exports.__wbindgen_is_undefined = function(arg0) {
|
|
|
338
501
|
return ret;
|
|
339
502
|
};
|
|
340
503
|
|
|
341
|
-
module.exports.
|
|
504
|
+
module.exports.__wbg_constructor_a3b5b211c5053ce8 = function() {
|
|
342
505
|
const ret = new Object();
|
|
343
506
|
return addHeapObject(ret);
|
|
344
507
|
};
|
package/nodejs/noir_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export function acir_read_bytes(a: number, b: number): number;
|
|
5
5
|
export function acir_write_bytes(a: number, b: number): void;
|
|
6
|
+
export function __wbg_compilercontext_free(a: number): void;
|
|
7
|
+
export function __wbg_crateid_free(a: number): void;
|
|
8
|
+
export function compilercontext_new(a: number): number;
|
|
9
|
+
export function compilercontext_process_root_crate(a: number, b: number, c: number): number;
|
|
10
|
+
export function compilercontext_process_dependency_crate(a: number, b: number, c: number): number;
|
|
11
|
+
export function compilercontext_add_dependency_edge(a: number, b: number, c: number, d: number, e: number): void;
|
|
12
|
+
export function compilercontext_compile_program(a: number, b: number, c: number): void;
|
|
13
|
+
export function compilercontext_compile_contract(a: number, b: number, c: number): void;
|
|
14
|
+
export function compile_(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
6
15
|
export function init_log_level(a: number, b: number): void;
|
|
7
16
|
export function build_info(): number;
|
|
8
17
|
export function __wbg_pathtofilesourcemap_free(a: number): void;
|
package/package.json
CHANGED
package/web/noir_wasm.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export function acir_read_bytes(bytes: Uint8Array): any;
|
|
|
11
11
|
*/
|
|
12
12
|
export function acir_write_bytes(acir: any): Uint8Array;
|
|
13
13
|
/**
|
|
14
|
+
* This is a method that exposes the same API as `compile`
|
|
15
|
+
* But uses the Context based APi internally
|
|
16
|
+
* @param {string} entry_point
|
|
17
|
+
* @param {boolean | undefined} contracts
|
|
18
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
19
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
20
|
+
* @returns {CompileResult}
|
|
21
|
+
*/
|
|
22
|
+
export function compile_(entry_point: string, contracts: boolean | undefined, dependency_graph: DependencyGraph | undefined, file_source_map: PathToFileSourceMap): CompileResult;
|
|
23
|
+
/**
|
|
14
24
|
* @param {string} level
|
|
15
25
|
*/
|
|
16
26
|
export function init_log_level(level: string): void;
|
|
@@ -52,14 +62,12 @@ export type DependencyGraph = {
|
|
|
52
62
|
export type CompiledContract = {
|
|
53
63
|
noir_version: string;
|
|
54
64
|
name: string;
|
|
55
|
-
backend: string;
|
|
56
65
|
functions: Array<any>;
|
|
57
66
|
events: Array<any>;
|
|
58
67
|
};
|
|
59
68
|
|
|
60
69
|
export type CompiledProgram = {
|
|
61
70
|
noir_version: string;
|
|
62
|
-
backend: string;
|
|
63
71
|
abi: any;
|
|
64
72
|
bytecode: string;
|
|
65
73
|
}
|
|
@@ -82,6 +90,49 @@ export type CompileResult = (
|
|
|
82
90
|
);
|
|
83
91
|
|
|
84
92
|
|
|
93
|
+
/**
|
|
94
|
+
* This is a wrapper class that is wasm-bindgen compatible
|
|
95
|
+
* We do not use js_name and rename it like CrateId because
|
|
96
|
+
* then the impl block is not picked up in javascript.
|
|
97
|
+
*/
|
|
98
|
+
export class CompilerContext {
|
|
99
|
+
free(): void;
|
|
100
|
+
/**
|
|
101
|
+
* @param {PathToFileSourceMap} source_map
|
|
102
|
+
*/
|
|
103
|
+
constructor(source_map: PathToFileSourceMap);
|
|
104
|
+
/**
|
|
105
|
+
* @param {string} path_to_crate
|
|
106
|
+
* @returns {CrateId}
|
|
107
|
+
*/
|
|
108
|
+
process_root_crate(path_to_crate: string): CrateId;
|
|
109
|
+
/**
|
|
110
|
+
* @param {string} path_to_crate
|
|
111
|
+
* @returns {CrateId}
|
|
112
|
+
*/
|
|
113
|
+
process_dependency_crate(path_to_crate: string): CrateId;
|
|
114
|
+
/**
|
|
115
|
+
* @param {string} crate_name
|
|
116
|
+
* @param {CrateId} from
|
|
117
|
+
* @param {CrateId} to
|
|
118
|
+
*/
|
|
119
|
+
add_dependency_edge(crate_name: string, from: CrateId, to: CrateId): void;
|
|
120
|
+
/**
|
|
121
|
+
* @param {number} program_width
|
|
122
|
+
* @returns {CompileResult}
|
|
123
|
+
*/
|
|
124
|
+
compile_program(program_width: number): CompileResult;
|
|
125
|
+
/**
|
|
126
|
+
* @param {number} program_width
|
|
127
|
+
* @returns {CompileResult}
|
|
128
|
+
*/
|
|
129
|
+
compile_contract(program_width: number): CompileResult;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
*/
|
|
133
|
+
export class CrateId {
|
|
134
|
+
free(): void;
|
|
135
|
+
}
|
|
85
136
|
/**
|
|
86
137
|
*/
|
|
87
138
|
export class PathToFileSourceMap {
|
|
@@ -103,6 +154,15 @@ export interface InitOutput {
|
|
|
103
154
|
readonly memory: WebAssembly.Memory;
|
|
104
155
|
readonly acir_read_bytes: (a: number, b: number) => number;
|
|
105
156
|
readonly acir_write_bytes: (a: number, b: number) => void;
|
|
157
|
+
readonly __wbg_compilercontext_free: (a: number) => void;
|
|
158
|
+
readonly __wbg_crateid_free: (a: number) => void;
|
|
159
|
+
readonly compilercontext_new: (a: number) => number;
|
|
160
|
+
readonly compilercontext_process_root_crate: (a: number, b: number, c: number) => number;
|
|
161
|
+
readonly compilercontext_process_dependency_crate: (a: number, b: number, c: number) => number;
|
|
162
|
+
readonly compilercontext_add_dependency_edge: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
163
|
+
readonly compilercontext_compile_program: (a: number, b: number, c: number) => void;
|
|
164
|
+
readonly compilercontext_compile_contract: (a: number, b: number, c: number) => void;
|
|
165
|
+
readonly compile_: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
106
166
|
readonly init_log_level: (a: number, b: number) => void;
|
|
107
167
|
readonly build_info: () => number;
|
|
108
168
|
readonly __wbg_pathtofilesourcemap_free: (a: number) => void;
|
package/web/noir_wasm.js
CHANGED
|
@@ -219,6 +219,41 @@ export function acir_write_bytes(acir) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
function _assertClass(instance, klass) {
|
|
223
|
+
if (!(instance instanceof klass)) {
|
|
224
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
225
|
+
}
|
|
226
|
+
return instance.ptr;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* This is a method that exposes the same API as `compile`
|
|
230
|
+
* But uses the Context based APi internally
|
|
231
|
+
* @param {string} entry_point
|
|
232
|
+
* @param {boolean | undefined} contracts
|
|
233
|
+
* @param {DependencyGraph | undefined} dependency_graph
|
|
234
|
+
* @param {PathToFileSourceMap} file_source_map
|
|
235
|
+
* @returns {CompileResult}
|
|
236
|
+
*/
|
|
237
|
+
export function compile_(entry_point, contracts, dependency_graph, file_source_map) {
|
|
238
|
+
try {
|
|
239
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
240
|
+
const ptr0 = passStringToWasm0(entry_point, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
241
|
+
const len0 = WASM_VECTOR_LEN;
|
|
242
|
+
_assertClass(file_source_map, PathToFileSourceMap);
|
|
243
|
+
var ptr1 = file_source_map.__destroy_into_raw();
|
|
244
|
+
wasm.compile_(retptr, ptr0, len0, isLikeNone(contracts) ? 0xFFFFFF : contracts ? 1 : 0, isLikeNone(dependency_graph) ? 0 : addHeapObject(dependency_graph), ptr1);
|
|
245
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
246
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
247
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
248
|
+
if (r2) {
|
|
249
|
+
throw takeObject(r1);
|
|
250
|
+
}
|
|
251
|
+
return takeObject(r0);
|
|
252
|
+
} finally {
|
|
253
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
222
257
|
/**
|
|
223
258
|
* @param {string} level
|
|
224
259
|
*/
|
|
@@ -236,12 +271,6 @@ export function build_info() {
|
|
|
236
271
|
return takeObject(ret);
|
|
237
272
|
}
|
|
238
273
|
|
|
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
274
|
/**
|
|
246
275
|
* @param {string} entry_point
|
|
247
276
|
* @param {boolean | undefined} contracts
|
|
@@ -277,6 +306,138 @@ function handleError(f, args) {
|
|
|
277
306
|
}
|
|
278
307
|
}
|
|
279
308
|
/**
|
|
309
|
+
* This is a wrapper class that is wasm-bindgen compatible
|
|
310
|
+
* We do not use js_name and rename it like CrateId because
|
|
311
|
+
* then the impl block is not picked up in javascript.
|
|
312
|
+
*/
|
|
313
|
+
export class CompilerContext {
|
|
314
|
+
|
|
315
|
+
static __wrap(ptr) {
|
|
316
|
+
ptr = ptr >>> 0;
|
|
317
|
+
const obj = Object.create(CompilerContext.prototype);
|
|
318
|
+
obj.__wbg_ptr = ptr;
|
|
319
|
+
|
|
320
|
+
return obj;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
__destroy_into_raw() {
|
|
324
|
+
const ptr = this.__wbg_ptr;
|
|
325
|
+
this.__wbg_ptr = 0;
|
|
326
|
+
|
|
327
|
+
return ptr;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
free() {
|
|
331
|
+
const ptr = this.__destroy_into_raw();
|
|
332
|
+
wasm.__wbg_compilercontext_free(ptr);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @param {PathToFileSourceMap} source_map
|
|
336
|
+
*/
|
|
337
|
+
constructor(source_map) {
|
|
338
|
+
_assertClass(source_map, PathToFileSourceMap);
|
|
339
|
+
var ptr0 = source_map.__destroy_into_raw();
|
|
340
|
+
const ret = wasm.compilercontext_new(ptr0);
|
|
341
|
+
return CompilerContext.__wrap(ret);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* @param {string} path_to_crate
|
|
345
|
+
* @returns {CrateId}
|
|
346
|
+
*/
|
|
347
|
+
process_root_crate(path_to_crate) {
|
|
348
|
+
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
349
|
+
const len0 = WASM_VECTOR_LEN;
|
|
350
|
+
const ret = wasm.compilercontext_process_root_crate(this.__wbg_ptr, ptr0, len0);
|
|
351
|
+
return CrateId.__wrap(ret);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* @param {string} path_to_crate
|
|
355
|
+
* @returns {CrateId}
|
|
356
|
+
*/
|
|
357
|
+
process_dependency_crate(path_to_crate) {
|
|
358
|
+
const ptr0 = passStringToWasm0(path_to_crate, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
const ret = wasm.compilercontext_process_dependency_crate(this.__wbg_ptr, ptr0, len0);
|
|
361
|
+
return CrateId.__wrap(ret);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* @param {string} crate_name
|
|
365
|
+
* @param {CrateId} from
|
|
366
|
+
* @param {CrateId} to
|
|
367
|
+
*/
|
|
368
|
+
add_dependency_edge(crate_name, from, to) {
|
|
369
|
+
const ptr0 = passStringToWasm0(crate_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
370
|
+
const len0 = WASM_VECTOR_LEN;
|
|
371
|
+
_assertClass(from, CrateId);
|
|
372
|
+
_assertClass(to, CrateId);
|
|
373
|
+
wasm.compilercontext_add_dependency_edge(this.__wbg_ptr, ptr0, len0, from.__wbg_ptr, to.__wbg_ptr);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* @param {number} program_width
|
|
377
|
+
* @returns {CompileResult}
|
|
378
|
+
*/
|
|
379
|
+
compile_program(program_width) {
|
|
380
|
+
try {
|
|
381
|
+
const ptr = this.__destroy_into_raw();
|
|
382
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
383
|
+
wasm.compilercontext_compile_program(retptr, ptr, program_width);
|
|
384
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
385
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
386
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
387
|
+
if (r2) {
|
|
388
|
+
throw takeObject(r1);
|
|
389
|
+
}
|
|
390
|
+
return takeObject(r0);
|
|
391
|
+
} finally {
|
|
392
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* @param {number} program_width
|
|
397
|
+
* @returns {CompileResult}
|
|
398
|
+
*/
|
|
399
|
+
compile_contract(program_width) {
|
|
400
|
+
try {
|
|
401
|
+
const ptr = this.__destroy_into_raw();
|
|
402
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
403
|
+
wasm.compilercontext_compile_contract(retptr, ptr, program_width);
|
|
404
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
405
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
406
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
407
|
+
if (r2) {
|
|
408
|
+
throw takeObject(r1);
|
|
409
|
+
}
|
|
410
|
+
return takeObject(r0);
|
|
411
|
+
} finally {
|
|
412
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
*/
|
|
418
|
+
export class CrateId {
|
|
419
|
+
|
|
420
|
+
static __wrap(ptr) {
|
|
421
|
+
ptr = ptr >>> 0;
|
|
422
|
+
const obj = Object.create(CrateId.prototype);
|
|
423
|
+
obj.__wbg_ptr = ptr;
|
|
424
|
+
|
|
425
|
+
return obj;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
__destroy_into_raw() {
|
|
429
|
+
const ptr = this.__wbg_ptr;
|
|
430
|
+
this.__wbg_ptr = 0;
|
|
431
|
+
|
|
432
|
+
return ptr;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
free() {
|
|
436
|
+
const ptr = this.__destroy_into_raw();
|
|
437
|
+
wasm.__wbg_crateid_free(ptr);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
280
441
|
*/
|
|
281
442
|
export class PathToFileSourceMap {
|
|
282
443
|
|
|
@@ -357,7 +518,7 @@ function __wbg_get_imports() {
|
|
|
357
518
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
358
519
|
takeObject(arg0);
|
|
359
520
|
};
|
|
360
|
-
imports.wbg.
|
|
521
|
+
imports.wbg.__wbg_constructor_a29cdb41a75eb0e8 = function(arg0) {
|
|
361
522
|
const ret = new Error(takeObject(arg0));
|
|
362
523
|
return addHeapObject(ret);
|
|
363
524
|
};
|
|
@@ -365,7 +526,7 @@ function __wbg_get_imports() {
|
|
|
365
526
|
const ret = getObject(arg0) === undefined;
|
|
366
527
|
return ret;
|
|
367
528
|
};
|
|
368
|
-
imports.wbg.
|
|
529
|
+
imports.wbg.__wbg_constructor_a3b5b211c5053ce8 = function() {
|
|
369
530
|
const ret = new Object();
|
|
370
531
|
return addHeapObject(ret);
|
|
371
532
|
};
|
package/web/noir_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export function acir_read_bytes(a: number, b: number): number;
|
|
5
5
|
export function acir_write_bytes(a: number, b: number): void;
|
|
6
|
+
export function __wbg_compilercontext_free(a: number): void;
|
|
7
|
+
export function __wbg_crateid_free(a: number): void;
|
|
8
|
+
export function compilercontext_new(a: number): number;
|
|
9
|
+
export function compilercontext_process_root_crate(a: number, b: number, c: number): number;
|
|
10
|
+
export function compilercontext_process_dependency_crate(a: number, b: number, c: number): number;
|
|
11
|
+
export function compilercontext_add_dependency_edge(a: number, b: number, c: number, d: number, e: number): void;
|
|
12
|
+
export function compilercontext_compile_program(a: number, b: number, c: number): void;
|
|
13
|
+
export function compilercontext_compile_contract(a: number, b: number, c: number): void;
|
|
14
|
+
export function compile_(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
6
15
|
export function init_log_level(a: number, b: number): void;
|
|
7
16
|
export function build_info(): number;
|
|
8
17
|
export function __wbg_pathtofilesourcemap_free(a: number): void;
|