@fluffylabs/anan-as 1.1.5 → 1.1.6-8306b17

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.
Files changed (64) hide show
  1. package/README.md +107 -12
  2. package/dist/bin/build-inline.js +70 -0
  3. package/dist/bin/index.js +293 -0
  4. package/dist/bin/src/fuzz.js +155 -0
  5. package/dist/bin/src/log-host-call.js +41 -0
  6. package/dist/bin/src/test-json.js +135 -0
  7. package/dist/bin/src/trace-parse.js +315 -0
  8. package/dist/bin/src/trace-replay.js +130 -0
  9. package/dist/bin/src/tracer.js +64 -0
  10. package/dist/bin/src/utils.js +25 -0
  11. package/dist/bin/test.js +1 -0
  12. package/dist/build/compiler-inline.d.ts +11 -0
  13. package/dist/build/compiler-inline.js +22 -0
  14. package/dist/build/compiler.d.ts +26 -0
  15. package/dist/build/compiler.js +76 -0
  16. package/dist/build/compiler.wasm +0 -0
  17. package/{build → dist/build}/debug-inline.d.ts +1 -1
  18. package/dist/build/debug-inline.js +22 -0
  19. package/{build → dist/build}/debug-raw-inline.d.ts +1 -1
  20. package/dist/build/debug-raw-inline.js +22 -0
  21. package/{build → dist/build}/debug-raw.d.ts +164 -37
  22. package/{build → dist/build}/debug-raw.js +143 -42
  23. package/dist/build/debug-raw.wasm +0 -0
  24. package/{build → dist/build}/debug.d.ts +164 -37
  25. package/{build → dist/build}/debug.js +156 -44
  26. package/dist/build/debug.wasm +0 -0
  27. package/{build → dist/build}/release-inline.d.ts +1 -1
  28. package/dist/build/release-inline.js +22 -0
  29. package/{build → dist/build}/release-mini-inline.d.ts +1 -1
  30. package/dist/build/release-mini-inline.js +22 -0
  31. package/{build → dist/build}/release-mini.d.ts +164 -37
  32. package/{build → dist/build}/release-mini.js +156 -44
  33. package/dist/build/release-mini.wasm +0 -0
  34. package/{build → dist/build}/release-stub-inline.d.ts +1 -1
  35. package/dist/build/release-stub-inline.js +22 -0
  36. package/{build → dist/build}/release-stub.d.ts +164 -37
  37. package/{build → dist/build}/release-stub.js +156 -44
  38. package/dist/build/release-stub.wasm +0 -0
  39. package/{build → dist/build}/release.d.ts +164 -37
  40. package/{build → dist/build}/release.js +156 -44
  41. package/dist/build/release.wasm +0 -0
  42. package/{build → dist/build}/test-inline.d.ts +1 -1
  43. package/dist/build/test-inline.js +22 -0
  44. package/dist/build/test.wasm +0 -0
  45. package/dist/test/test-as.js +3 -0
  46. package/dist/test/test-gas-cost.js +57 -0
  47. package/dist/test/test-trace-replay.js +19 -0
  48. package/dist/test/test-w3f.js +121 -0
  49. package/dist/web/bump-version.js +7 -0
  50. package/package.json +47 -36
  51. package/build/debug-inline.js +0 -22
  52. package/build/debug-raw-inline.js +0 -22
  53. package/build/debug-raw.wasm +0 -0
  54. package/build/debug.wasm +0 -0
  55. package/build/release-inline.js +0 -22
  56. package/build/release-mini-inline.js +0 -22
  57. package/build/release-mini.wasm +0 -0
  58. package/build/release-stub-inline.js +0 -22
  59. package/build/release-stub.wasm +0 -0
  60. package/build/release.wasm +0 -0
  61. package/build/test-inline.js +0 -22
  62. package/build/test.wasm +0 -0
  63. /package/{build → dist/build}/test.d.ts +0 -0
  64. /package/{build → dist/build}/test.js +0 -0
@@ -6,22 +6,10 @@ export declare function __pin(ptr: number): number;
6
6
  export declare function __unpin(ptr: number): void;
7
7
  export declare function __collect(): void;
8
8
  export declare const __rtti_base: number;
9
- /**
10
- * assembly/api-internal/getAssembly
11
- * @param p `assembly/program/Program`
12
- * @returns `~lib/string/String`
13
- */
14
- export declare function getAssembly(p: __Internref26): string;
15
- /**
16
- * assembly/program-build/wrapAsProgram
17
- * @param bytecode `~lib/typedarray/Uint8Array`
18
- * @returns `~lib/typedarray/Uint8Array`
19
- */
20
- export declare function wrapAsProgram(bytecode: Uint8Array): Uint8Array;
21
9
  /**
22
10
  * assembly/api-debugger/resetJAM
23
11
  * @param program `~lib/array/Array<u8>`
24
- * @param pc `f64`
12
+ * @param pc `u32`
25
13
  * @param initialGas `i64`
26
14
  * @param args `~lib/array/Array<u8>`
27
15
  * @param hasMetadata `bool`
@@ -116,6 +104,47 @@ export declare function getMemory(address: number, length: number): Uint8Array |
116
104
  * @returns `bool`
117
105
  */
118
106
  export declare function setMemory(address: number, data: Uint8Array): boolean;
107
+ /**
108
+ * assembly/api-internal/getAssembly
109
+ * @param p `assembly/program/Program`
110
+ * @returns `~lib/string/String`
111
+ */
112
+ export declare function getAssembly(p: __Internref26): string;
113
+ /**
114
+ * assembly/api-internal/buildMemory
115
+ * @param builder `assembly/memory/MemoryBuilder`
116
+ * @param pages `~lib/array/Array<assembly/api-types/InitialPage>`
117
+ * @param chunks `~lib/array/Array<assembly/api-types/InitialChunk>`
118
+ * @returns `assembly/memory/Memory`
119
+ */
120
+ export declare function buildMemory(builder: __Internref41, pages: Array<__Record44<undefined>>, chunks: Array<__Record46<undefined>>): __Internref15;
121
+ /**
122
+ * assembly/api-internal/vmInit
123
+ * @param input `assembly/api-types/VmInput`
124
+ * @param useSbrkGas `bool`
125
+ * @returns `assembly/interpreter/Interpreter`
126
+ */
127
+ export declare function vmInit(input: __Internref49, useSbrkGas?: boolean): __Internref25;
128
+ /**
129
+ * assembly/api-internal/vmRunOnce
130
+ * @param input `assembly/api-types/VmInput`
131
+ * @param options `assembly/api-types/VmRunOptions`
132
+ * @returns `assembly/api-types/VmOutput`
133
+ */
134
+ export declare function vmRunOnce(input: __Internref49, options: __Record50<undefined>): __Record51<never>;
135
+ /**
136
+ * assembly/api-internal/vmExecute
137
+ * @param int `assembly/interpreter/Interpreter`
138
+ * @param logs `bool`
139
+ */
140
+ export declare function vmExecute(int: __Internref25, logs?: boolean): void;
141
+ /**
142
+ * assembly/api-internal/vmDestroy
143
+ * @param int `assembly/interpreter/Interpreter`
144
+ * @param dumpMemory `bool`
145
+ * @returns `assembly/api-types/VmOutput`
146
+ */
147
+ export declare function vmDestroy(int: __Internref25, dumpMemory?: boolean): __Record51<never>;
119
148
  /** assembly/api-utils/InputKind */
120
149
  export declare enum InputKind {
121
150
  /** @type `i32` */
@@ -137,7 +166,7 @@ export declare enum HasMetadata {
137
166
  * @param withMetadata `i32`
138
167
  * @returns `~lib/array/Array<assembly/gas-costs/BlockGasCost>`
139
168
  */
140
- export declare function getGasCosts(input: Array<number>, kind: number, withMetadata: number): Array<__Record50<never>>;
169
+ export declare function getGasCosts(input: Array<number>, kind: number, withMetadata: number): Array<__Record56<never>>;
141
170
  /**
142
171
  * assembly/api-utils/disassemble
143
172
  * @param input `~lib/array/Array<u8>`
@@ -152,12 +181,13 @@ export declare function disassemble(input: Array<number>, kind: number, withMeta
152
181
  * @param hasMetadata `i32`
153
182
  * @param program `~lib/array/Array<u8>`
154
183
  * @param initialRegisters `~lib/array/Array<u64>`
155
- * @param initialPageMap `~lib/array/Array<assembly/api-internal/InitialPage>`
156
- * @param initialMemory `~lib/array/Array<assembly/api-internal/InitialChunk>`
184
+ * @param initialPageMap `~lib/array/Array<assembly/api-types/InitialPage>`
185
+ * @param initialMemory `~lib/array/Array<assembly/api-types/InitialChunk>`
157
186
  * @param args `~lib/array/Array<u8>`
187
+ * @param preallocateMemoryPages `u32`
158
188
  * @returns `assembly/spi/StandardProgram`
159
189
  */
160
- export declare function prepareProgram(kind: number, hasMetadata: number, program: Array<number>, initialRegisters: Array<bigint>, initialPageMap: Array<__Record46<undefined>>, initialMemory: Array<__Record48<undefined>>, args: Array<number>): __Internref42;
190
+ export declare function prepareProgram(kind: number, hasMetadata: number, program: Array<number>, initialRegisters: Array<bigint>, initialPageMap: Array<__Record44<undefined>>, initialMemory: Array<__Record46<undefined>>, args: Array<number>, preallocateMemoryPages: number): __Internref40;
161
191
  /**
162
192
  * assembly/api-utils/runProgram
163
193
  * @param program `assembly/spi/StandardProgram`
@@ -165,23 +195,72 @@ export declare function prepareProgram(kind: number, hasMetadata: number, progra
165
195
  * @param programCounter `u32`
166
196
  * @param logs `bool`
167
197
  * @param useSbrkGas `bool`
168
- * @returns `assembly/api-internal/VmOutput`
198
+ * @param dumpMemory `bool`
199
+ * @returns `assembly/api-types/VmOutput`
169
200
  */
170
- export declare function runProgram(program: __Internref42, initialGas?: bigint, programCounter?: number, logs?: boolean, useSbrkGas?: boolean): __Record55<never>;
201
+ export declare function runProgram(program: __Internref40, initialGas?: bigint, programCounter?: number, logs?: boolean, useSbrkGas?: boolean, dumpMemory?: boolean): __Record51<never>;
202
+ /**
203
+ * assembly/api-utils/pvmStart
204
+ * @param program `assembly/spi/StandardProgram`
205
+ * @param useSbrkGas `bool`
206
+ * @returns `u32`
207
+ */
208
+ export declare function pvmStart(program: __Internref40, useSbrkGas?: boolean): number;
209
+ /**
210
+ * assembly/api-utils/pvmDestroy
211
+ * @param pvmId `u32`
212
+ * @returns `assembly/api-types/VmOutput | null`
213
+ */
214
+ export declare function pvmDestroy(pvmId: number): __Record51<never> | null;
215
+ /**
216
+ * assembly/api-utils/pvmSetRegisters
217
+ * @param pvmId `u32`
218
+ * @param registers `~lib/array/Array<u64>`
219
+ */
220
+ export declare function pvmSetRegisters(pvmId: number, registers: Array<bigint>): void;
221
+ /**
222
+ * assembly/api-utils/pvmReadMemory
223
+ * @param pvmId `u32`
224
+ * @param address `u32`
225
+ * @param length `u32`
226
+ * @returns `~lib/typedarray/Uint8Array | null`
227
+ */
228
+ export declare function pvmReadMemory(pvmId: number, address: number, length: number): Uint8Array | null;
229
+ /**
230
+ * assembly/api-utils/pvmWriteMemory
231
+ * @param pvmId `u32`
232
+ * @param address `u32`
233
+ * @param data `~lib/typedarray/Uint8Array`
234
+ * @returns `bool`
235
+ */
236
+ export declare function pvmWriteMemory(pvmId: number, address: number, data: Uint8Array): boolean;
237
+ /**
238
+ * assembly/api-utils/pvmResume
239
+ * @param pvmId `u32`
240
+ * @param gas `i64`
241
+ * @param pc `u32`
242
+ * @param logs `bool`
243
+ * @returns `assembly/api-types/VmPause | null`
244
+ */
245
+ export declare function pvmResume(pvmId: number, gas: bigint, pc: number, logs?: boolean): __Record60<never> | null;
246
+ /**
247
+ * assembly/program-build/wrapAsProgram
248
+ * @param bytecode `~lib/typedarray/Uint8Array`
249
+ * @returns `~lib/typedarray/Uint8Array`
250
+ */
251
+ export declare function wrapAsProgram(bytecode: Uint8Array): Uint8Array;
171
252
  /** assembly/program/Program */
172
253
  declare class __Internref26 extends Number {
173
254
  private __nominal26: symbol;
174
255
  private __nominal0: symbol;
175
256
  }
176
- /** assembly/gas-costs/BlockGasCost */
177
- declare interface __Record50<TOmittable> {
178
- /** @type `u32` */
179
- pc: number | TOmittable;
180
- /** @type `u64` */
181
- gas: bigint | TOmittable;
257
+ /** assembly/memory/MemoryBuilder */
258
+ declare class __Internref41 extends Number {
259
+ private __nominal41: symbol;
260
+ private __nominal0: symbol;
182
261
  }
183
- /** assembly/api-internal/InitialPage */
184
- declare interface __Record46<TOmittable> {
262
+ /** assembly/api-types/InitialPage */
263
+ declare interface __Record44<TOmittable> {
185
264
  /** @type `u32` */
186
265
  address: number | TOmittable;
187
266
  /** @type `u32` */
@@ -189,30 +268,78 @@ declare interface __Record46<TOmittable> {
189
268
  /** @type `i32` */
190
269
  access: number | TOmittable;
191
270
  }
192
- /** assembly/api-internal/InitialChunk */
193
- declare interface __Record48<TOmittable> {
271
+ /** assembly/api-types/InitialChunk */
272
+ declare interface __Record46<TOmittable> {
194
273
  /** @type `u32` */
195
274
  address: number | TOmittable;
196
275
  /** @type `~lib/array/Array<u8>` */
197
276
  data: Array<number>;
198
277
  }
199
- /** assembly/spi/StandardProgram */
200
- declare class __Internref42 extends Number {
201
- private __nominal42: symbol;
278
+ /** assembly/memory/Memory */
279
+ declare class __Internref15 extends Number {
280
+ private __nominal15: symbol;
281
+ private __nominal0: symbol;
282
+ }
283
+ /** assembly/api-types/VmInput */
284
+ declare class __Internref49 extends Number {
285
+ private __nominal49: symbol;
202
286
  private __nominal0: symbol;
203
287
  }
204
- /** assembly/api-internal/VmOutput */
205
- declare interface __Record55<TOmittable> {
288
+ /** assembly/interpreter/Interpreter */
289
+ declare class __Internref25 extends Number {
290
+ private __nominal25: symbol;
291
+ private __nominal0: symbol;
292
+ }
293
+ /** assembly/api-types/VmRunOptions */
294
+ declare interface __Record50<TOmittable> {
295
+ /** @type `bool` */
296
+ useSbrkGas: boolean | TOmittable;
297
+ /** @type `bool` */
298
+ logs: boolean | TOmittable;
299
+ /** @type `bool` */
300
+ dumpMemory: boolean | TOmittable;
301
+ }
302
+ /** assembly/api-types/VmOutput */
303
+ declare interface __Record51<TOmittable> {
206
304
  /** @type `i32` */
207
305
  status: number | TOmittable;
306
+ /** @type `u32` */
307
+ exitCode: number | TOmittable;
308
+ /** @type `u32` */
309
+ pc: number | TOmittable;
310
+ /** @type `i64` */
311
+ gas: bigint | TOmittable;
312
+ /** @type `~lib/array/Array<u8>` */
313
+ result: Array<number>;
208
314
  /** @type `~lib/array/Array<u64>` */
209
315
  registers: Array<bigint>;
316
+ /** @type `~lib/array/Array<assembly/api-types/InitialChunk>` */
317
+ memory: Array<__Record46<never>>;
318
+ }
319
+ /** assembly/gas-costs/BlockGasCost */
320
+ declare interface __Record56<TOmittable> {
210
321
  /** @type `u32` */
211
322
  pc: number | TOmittable;
212
- /** @type `~lib/array/Array<assembly/api-internal/InitialChunk>` */
213
- memory: Array<__Record48<never>>;
214
- /** @type `i64` */
323
+ /** @type `u64` */
215
324
  gas: bigint | TOmittable;
325
+ }
326
+ /** assembly/spi/StandardProgram */
327
+ declare class __Internref40 extends Number {
328
+ private __nominal40: symbol;
329
+ private __nominal0: symbol;
330
+ }
331
+ /** assembly/api-types/VmPause */
332
+ declare interface __Record60<TOmittable> {
333
+ /** @type `i32` */
334
+ status: number | TOmittable;
216
335
  /** @type `u32` */
217
336
  exitCode: number | TOmittable;
337
+ /** @type `u32` */
338
+ pc: number | TOmittable;
339
+ /** @type `u32` */
340
+ nextPc: number | TOmittable;
341
+ /** @type `i64` */
342
+ gas: bigint | TOmittable;
343
+ /** @type `~lib/array/Array<u64>` */
344
+ registers: Array<bigint>;
218
345
  }
@@ -22,18 +22,8 @@ async function instantiate(module, imports = {}) {
22
22
  const { exports } = await WebAssembly.instantiate(module, adaptedImports);
23
23
  const memory = exports.memory || imports.env.memory;
24
24
  const adaptedExports = Object.setPrototypeOf({
25
- getAssembly(p) {
26
- // assembly/api-internal/getAssembly(assembly/program/Program) => ~lib/string/String
27
- p = __lowerInternref(p) || __notnull();
28
- return __liftString(exports.getAssembly(p) >>> 0);
29
- },
30
- wrapAsProgram(bytecode) {
31
- // assembly/program-build/wrapAsProgram(~lib/typedarray/Uint8Array) => ~lib/typedarray/Uint8Array
32
- bytecode = __lowerTypedArray(Uint8Array, 10, 0, bytecode) || __notnull();
33
- return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
34
- },
35
25
  resetJAM(program, pc, initialGas, args, hasMetadata) {
36
- // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, f64, i64, ~lib/array/Array<u8>, bool?) => void
26
+ // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, u32, i64, ~lib/array/Array<u8>, bool?) => void
37
27
  program = __retain(__lowerArray(__setU8, 6, 0, program) || __notnull());
38
28
  initialGas = initialGas || 0n;
39
29
  args = __lowerArray(__setU8, 6, 0, args) || __notnull();
@@ -118,6 +108,54 @@ async function instantiate(module, imports = {}) {
118
108
  data = __lowerTypedArray(Uint8Array, 10, 0, data) || __notnull();
119
109
  return exports.setMemory(address, data) != 0;
120
110
  },
111
+ getAssembly(p) {
112
+ // assembly/api-internal/getAssembly(assembly/program/Program) => ~lib/string/String
113
+ p = __lowerInternref(p) || __notnull();
114
+ return __liftString(exports.getAssembly(p) >>> 0);
115
+ },
116
+ buildMemory(builder, pages, chunks) {
117
+ // assembly/api-internal/buildMemory(assembly/memory/MemoryBuilder, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>) => assembly/memory/Memory
118
+ builder = __retain(__lowerInternref(builder) || __notnull());
119
+ pages = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, pages) || __notnull());
120
+ chunks = __lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, chunks) || __notnull();
121
+ try {
122
+ return __liftInternref(exports.buildMemory(builder, pages, chunks) >>> 0);
123
+ } finally {
124
+ __release(builder);
125
+ __release(pages);
126
+ }
127
+ },
128
+ vmInit(input, useSbrkGas) {
129
+ // assembly/api-internal/vmInit(assembly/api-types/VmInput, bool?) => assembly/interpreter/Interpreter
130
+ input = __lowerInternref(input) || __notnull();
131
+ useSbrkGas = useSbrkGas ? 1 : 0;
132
+ exports.__setArgumentsLength(arguments.length);
133
+ return __liftInternref(exports.vmInit(input, useSbrkGas) >>> 0);
134
+ },
135
+ vmRunOnce(input, options) {
136
+ // assembly/api-internal/vmRunOnce(assembly/api-types/VmInput, assembly/api-types/VmRunOptions) => assembly/api-types/VmOutput
137
+ input = __retain(__lowerInternref(input) || __notnull());
138
+ options = __lowerRecord50(options) || __notnull();
139
+ try {
140
+ return __liftRecord51(exports.vmRunOnce(input, options) >>> 0);
141
+ } finally {
142
+ __release(input);
143
+ }
144
+ },
145
+ vmExecute(int, logs) {
146
+ // assembly/api-internal/vmExecute(assembly/interpreter/Interpreter, bool?) => void
147
+ int = __lowerInternref(int) || __notnull();
148
+ logs = logs ? 1 : 0;
149
+ exports.__setArgumentsLength(arguments.length);
150
+ exports.vmExecute(int, logs);
151
+ },
152
+ vmDestroy(int, dumpMemory) {
153
+ // assembly/api-internal/vmDestroy(assembly/interpreter/Interpreter, bool?) => assembly/api-types/VmOutput
154
+ int = __lowerInternref(int) || __notnull();
155
+ dumpMemory = dumpMemory ? 1 : 0;
156
+ exports.__setArgumentsLength(arguments.length);
157
+ return __liftRecord51(exports.vmDestroy(int, dumpMemory) >>> 0);
158
+ },
121
159
  InputKind: (values => (
122
160
  // assembly/api-utils/InputKind
123
161
  values[values.Generic = exports["InputKind.Generic"].valueOf()] = "Generic",
@@ -133,22 +171,22 @@ async function instantiate(module, imports = {}) {
133
171
  getGasCosts(input, kind, withMetadata) {
134
172
  // assembly/api-utils/getGasCosts(~lib/array/Array<u8>, i32, i32) => ~lib/array/Array<assembly/gas-costs/BlockGasCost>
135
173
  input = __lowerArray(__setU8, 6, 0, input) || __notnull();
136
- return __liftArray(pointer => __liftRecord50(__getU32(pointer)), 2, exports.getGasCosts(input, kind, withMetadata) >>> 0);
174
+ return __liftArray(pointer => __liftRecord56(__getU32(pointer)), 2, exports.getGasCosts(input, kind, withMetadata) >>> 0);
137
175
  },
138
176
  disassemble(input, kind, withMetadata) {
139
177
  // assembly/api-utils/disassemble(~lib/array/Array<u8>, i32, i32) => ~lib/string/String
140
178
  input = __lowerArray(__setU8, 6, 0, input) || __notnull();
141
179
  return __liftString(exports.disassemble(input, kind, withMetadata) >>> 0);
142
180
  },
143
- prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) {
144
- // assembly/api-utils/prepareProgram(i32, i32, ~lib/array/Array<u8>, ~lib/array/Array<u64>, ~lib/array/Array<assembly/api-internal/InitialPage>, ~lib/array/Array<assembly/api-internal/InitialChunk>, ~lib/array/Array<u8>) => assembly/spi/StandardProgram
181
+ prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args, preallocateMemoryPages) {
182
+ // assembly/api-utils/prepareProgram(i32, i32, ~lib/array/Array<u8>, ~lib/array/Array<u64>, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>, ~lib/array/Array<u8>, u32) => assembly/spi/StandardProgram
145
183
  program = __retain(__lowerArray(__setU8, 6, 0, program) || __notnull());
146
184
  initialRegisters = __retain(__lowerArray(__setU64, 52, 3, initialRegisters) || __notnull());
147
- initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, initialPageMap) || __notnull());
148
- initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord48(value) || __notnull()); }, 49, 2, initialMemory) || __notnull());
185
+ initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, initialPageMap) || __notnull());
186
+ initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, initialMemory) || __notnull());
149
187
  args = __lowerArray(__setU8, 6, 0, args) || __notnull();
150
188
  try {
151
- return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) >>> 0);
189
+ return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args, preallocateMemoryPages) >>> 0);
152
190
  } finally {
153
191
  __release(program);
154
192
  __release(initialRegisters);
@@ -156,48 +194,88 @@ async function instantiate(module, imports = {}) {
156
194
  __release(initialMemory);
157
195
  }
158
196
  },
159
- runProgram(program, initialGas, programCounter, logs, useSbrkGas) {
160
- // assembly/api-utils/runProgram(assembly/spi/StandardProgram, i64?, u32?, bool?, bool?) => assembly/api-internal/VmOutput
197
+ runProgram(program, initialGas, programCounter, logs, useSbrkGas, dumpMemory) {
198
+ // assembly/api-utils/runProgram(assembly/spi/StandardProgram, i64?, u32?, bool?, bool?, bool?) => assembly/api-types/VmOutput
161
199
  program = __lowerInternref(program) || __notnull();
162
200
  initialGas = initialGas || 0n;
163
201
  logs = logs ? 1 : 0;
164
202
  useSbrkGas = useSbrkGas ? 1 : 0;
203
+ dumpMemory = dumpMemory ? 1 : 0;
204
+ exports.__setArgumentsLength(arguments.length);
205
+ return __liftRecord51(exports.runProgram(program, initialGas, programCounter, logs, useSbrkGas, dumpMemory) >>> 0);
206
+ },
207
+ pvmStart(program, useSbrkGas) {
208
+ // assembly/api-utils/pvmStart(assembly/spi/StandardProgram, bool?) => u32
209
+ program = __lowerInternref(program) || __notnull();
210
+ useSbrkGas = useSbrkGas ? 1 : 0;
211
+ exports.__setArgumentsLength(arguments.length);
212
+ return exports.pvmStart(program, useSbrkGas) >>> 0;
213
+ },
214
+ pvmDestroy(pvmId) {
215
+ // assembly/api-utils/pvmDestroy(u32) => assembly/api-types/VmOutput | null
216
+ return __liftRecord51(exports.pvmDestroy(pvmId) >>> 0);
217
+ },
218
+ pvmSetRegisters(pvmId, registers) {
219
+ // assembly/api-utils/pvmSetRegisters(u32, ~lib/array/Array<u64>) => void
220
+ registers = __lowerArray(__setU64, 52, 3, registers) || __notnull();
221
+ exports.pvmSetRegisters(pvmId, registers);
222
+ },
223
+ pvmReadMemory(pvmId, address, length) {
224
+ // assembly/api-utils/pvmReadMemory(u32, u32, u32) => ~lib/typedarray/Uint8Array | null
225
+ return __liftTypedArray(Uint8Array, exports.pvmReadMemory(pvmId, address, length) >>> 0);
226
+ },
227
+ pvmWriteMemory(pvmId, address, data) {
228
+ // assembly/api-utils/pvmWriteMemory(u32, u32, ~lib/typedarray/Uint8Array) => bool
229
+ data = __lowerTypedArray(Uint8Array, 10, 0, data) || __notnull();
230
+ return exports.pvmWriteMemory(pvmId, address, data) != 0;
231
+ },
232
+ pvmResume(pvmId, gas, pc, logs) {
233
+ // assembly/api-utils/pvmResume(u32, i64, u32, bool?) => assembly/api-types/VmPause | null
234
+ gas = gas || 0n;
235
+ logs = logs ? 1 : 0;
165
236
  exports.__setArgumentsLength(arguments.length);
166
- return __liftRecord55(exports.runProgram(program, initialGas, programCounter, logs, useSbrkGas) >>> 0);
237
+ return __liftRecord60(exports.pvmResume(pvmId, gas, pc, logs) >>> 0);
238
+ },
239
+ wrapAsProgram(bytecode) {
240
+ // assembly/program-build/wrapAsProgram(~lib/typedarray/Uint8Array) => ~lib/typedarray/Uint8Array
241
+ bytecode = __lowerTypedArray(Uint8Array, 10, 0, bytecode) || __notnull();
242
+ return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
167
243
  },
168
244
  }, exports);
169
- function __liftRecord50(pointer) {
170
- // assembly/gas-costs/BlockGasCost
171
- // Hint: Opt-out from lifting as a record by providing an empty constructor
172
- if (!pointer) return null;
173
- return {
174
- pc: __getU32(pointer + 0),
175
- gas: __getU64(pointer + 8),
176
- };
177
- }
178
- function __lowerRecord46(value) {
179
- // assembly/api-internal/InitialPage
245
+ function __lowerRecord44(value) {
246
+ // assembly/api-types/InitialPage
180
247
  // Hint: Opt-out from lowering as a record by providing an empty constructor
181
248
  if (value == null) return 0;
182
- const pointer = exports.__pin(exports.__new(12, 46));
249
+ const pointer = exports.__pin(exports.__new(12, 44));
183
250
  __setU32(pointer + 0, value.address);
184
251
  __setU32(pointer + 4, value.length);
185
252
  __setU32(pointer + 8, value.access);
186
253
  exports.__unpin(pointer);
187
254
  return pointer;
188
255
  }
189
- function __lowerRecord48(value) {
190
- // assembly/api-internal/InitialChunk
256
+ function __lowerRecord46(value) {
257
+ // assembly/api-types/InitialChunk
191
258
  // Hint: Opt-out from lowering as a record by providing an empty constructor
192
259
  if (value == null) return 0;
193
- const pointer = exports.__pin(exports.__new(8, 48));
260
+ const pointer = exports.__pin(exports.__new(8, 46));
194
261
  __setU32(pointer + 0, value.address);
195
262
  __setU32(pointer + 4, __lowerArray(__setU8, 6, 0, value.data) || __notnull());
196
263
  exports.__unpin(pointer);
197
264
  return pointer;
198
265
  }
199
- function __liftRecord48(pointer) {
200
- // assembly/api-internal/InitialChunk
266
+ function __lowerRecord50(value) {
267
+ // assembly/api-types/VmRunOptions
268
+ // Hint: Opt-out from lowering as a record by providing an empty constructor
269
+ if (value == null) return 0;
270
+ const pointer = exports.__pin(exports.__new(3, 50));
271
+ __setU8(pointer + 0, value.useSbrkGas ? 1 : 0);
272
+ __setU8(pointer + 1, value.logs ? 1 : 0);
273
+ __setU8(pointer + 2, value.dumpMemory ? 1 : 0);
274
+ exports.__unpin(pointer);
275
+ return pointer;
276
+ }
277
+ function __liftRecord46(pointer) {
278
+ // assembly/api-types/InitialChunk
201
279
  // Hint: Opt-out from lifting as a record by providing an empty constructor
202
280
  if (!pointer) return null;
203
281
  return {
@@ -205,17 +283,40 @@ async function instantiate(module, imports = {}) {
205
283
  data: __liftArray(__getU8, 0, __getU32(pointer + 4)),
206
284
  };
207
285
  }
208
- function __liftRecord55(pointer) {
209
- // assembly/api-internal/VmOutput
286
+ function __liftRecord51(pointer) {
287
+ // assembly/api-types/VmOutput
210
288
  // Hint: Opt-out from lifting as a record by providing an empty constructor
211
289
  if (!pointer) return null;
212
290
  return {
213
291
  status: __getI32(pointer + 0),
214
- registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 4)),
292
+ exitCode: __getU32(pointer + 4),
215
293
  pc: __getU32(pointer + 8),
216
- memory: __liftArray(pointer => __liftRecord48(__getU32(pointer)), 2, __getU32(pointer + 12)),
217
294
  gas: __getI64(pointer + 16),
218
- exitCode: __getU32(pointer + 24),
295
+ result: __liftArray(__getU8, 0, __getU32(pointer + 24)),
296
+ registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 28)),
297
+ memory: __liftArray(pointer => __liftRecord46(__getU32(pointer)), 2, __getU32(pointer + 32)),
298
+ };
299
+ }
300
+ function __liftRecord56(pointer) {
301
+ // assembly/gas-costs/BlockGasCost
302
+ // Hint: Opt-out from lifting as a record by providing an empty constructor
303
+ if (!pointer) return null;
304
+ return {
305
+ pc: __getU32(pointer + 0),
306
+ gas: __getU64(pointer + 8),
307
+ };
308
+ }
309
+ function __liftRecord60(pointer) {
310
+ // assembly/api-types/VmPause
311
+ // Hint: Opt-out from lifting as a record by providing an empty constructor
312
+ if (!pointer) return null;
313
+ return {
314
+ status: __getI32(pointer + 0),
315
+ exitCode: __getU32(pointer + 4),
316
+ pc: __getU32(pointer + 8),
317
+ nextPc: __getU32(pointer + 12),
318
+ gas: __getI64(pointer + 16),
319
+ registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 24)),
219
320
  };
220
321
  }
221
322
  function __liftString(pointer) {
@@ -381,8 +482,6 @@ export const {
381
482
  __unpin,
382
483
  __collect,
383
484
  __rtti_base,
384
- getAssembly,
385
- wrapAsProgram,
386
485
  resetJAM,
387
486
  resetGeneric,
388
487
  resetGenericWithMemory,
@@ -399,12 +498,25 @@ export const {
399
498
  getPageDump,
400
499
  getMemory,
401
500
  setMemory,
501
+ getAssembly,
502
+ buildMemory,
503
+ vmInit,
504
+ vmRunOnce,
505
+ vmExecute,
506
+ vmDestroy,
402
507
  InputKind,
403
508
  HasMetadata,
404
509
  getGasCosts,
405
510
  disassemble,
406
511
  prepareProgram,
407
512
  runProgram,
513
+ pvmStart,
514
+ pvmDestroy,
515
+ pvmSetRegisters,
516
+ pvmReadMemory,
517
+ pvmWriteMemory,
518
+ pvmResume,
519
+ wrapAsProgram,
408
520
  } = await (async url => instantiate(
409
521
  await (async () => {
410
522
  const isNodeOrBun = typeof process != "undefined" && process.versions != null && (process.versions.node != null || process.versions.bun != null);
Binary file
@@ -1,6 +1,6 @@
1
1
  // Auto-generated type definitions for inline WASM module
2
2
  // Target: release-stub
3
- // Source: build/release-stub.wasm
3
+ // Source: dist/build/release-stub.wasm
4
4
 
5
5
  import {__AdaptedExports} from "./debug-raw.d.ts";
6
6