@fluffylabs/anan-as 1.1.2 → 1.1.3-001e039
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/README.md +106 -11
- package/dist/bin/build-inline.js +70 -0
- package/dist/bin/index.js +263 -0
- package/dist/bin/src/fuzz.js +155 -0
- package/dist/bin/src/test-json.js +135 -0
- package/dist/bin/src/trace-parse.js +315 -0
- package/dist/bin/src/trace-replay.js +125 -0
- package/dist/bin/src/tracer.js +64 -0
- package/dist/bin/src/utils.js +25 -0
- package/dist/bin/test.js +1 -0
- package/dist/build/compiler-inline.d.ts +11 -0
- package/dist/build/compiler-inline.js +22 -0
- package/dist/build/compiler.d.ts +26 -0
- package/dist/build/compiler.js +76 -0
- package/dist/build/compiler.wasm +0 -0
- package/{build → dist/build}/debug-inline.d.ts +1 -1
- package/dist/build/debug-inline.js +22 -0
- package/{build → dist/build}/debug-raw-inline.d.ts +1 -1
- package/dist/build/debug-raw-inline.js +22 -0
- package/{build → dist/build}/debug-raw.d.ts +154 -37
- package/{build → dist/build}/debug-raw.js +126 -39
- package/dist/build/debug-raw.wasm +0 -0
- package/{build → dist/build}/debug.d.ts +154 -37
- package/{build → dist/build}/debug.js +139 -41
- package/dist/build/debug.wasm +0 -0
- package/{build → dist/build}/release-inline.d.ts +1 -1
- package/dist/build/release-inline.js +22 -0
- package/{build → dist/build}/release-mini-inline.d.ts +1 -1
- package/dist/build/release-mini-inline.js +22 -0
- package/{build → dist/build}/release-mini.d.ts +154 -37
- package/{build → dist/build}/release-mini.js +139 -41
- package/dist/build/release-mini.wasm +0 -0
- package/{build → dist/build}/release-stub-inline.d.ts +1 -1
- package/dist/build/release-stub-inline.js +22 -0
- package/{build → dist/build}/release-stub.d.ts +154 -37
- package/{build → dist/build}/release-stub.js +139 -41
- package/dist/build/release-stub.wasm +0 -0
- package/{build → dist/build}/release.d.ts +154 -37
- package/{build → dist/build}/release.js +139 -41
- package/dist/build/release.wasm +0 -0
- package/{build → dist/build}/test-inline.d.ts +1 -1
- package/dist/build/test-inline.js +22 -0
- package/dist/build/test.wasm +0 -0
- package/dist/test/test-as.js +3 -0
- package/dist/test/test-gas-cost.js +57 -0
- package/dist/test/test-trace-replay.js +19 -0
- package/dist/test/test-w3f.js +121 -0
- package/dist/web/bump-version.js +7 -0
- package/package.json +50 -42
- package/build/debug-inline.js +0 -22
- package/build/debug-raw-inline.js +0 -22
- package/build/debug-raw.wasm +0 -0
- package/build/debug.wasm +0 -0
- package/build/release-inline.js +0 -22
- package/build/release-mini-inline.js +0 -22
- package/build/release-mini.wasm +0 -0
- package/build/release-stub-inline.js +0 -22
- package/build/release-stub.wasm +0 -0
- package/build/release.wasm +0 -0
- package/build/test-inline.js +0 -22
- package/build/test.wasm +0 -0
- /package/{build → dist/build}/test.d.ts +0 -0
- /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 `
|
|
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,48 @@ 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 logs `bool`
|
|
132
|
+
* @param useSbrkGas `bool`
|
|
133
|
+
* @returns `assembly/api-types/VmOutput`
|
|
134
|
+
*/
|
|
135
|
+
export declare function vmRunOnce(input: __Internref49, logs?: boolean, useSbrkGas?: boolean): __Record50<never>;
|
|
136
|
+
/**
|
|
137
|
+
* assembly/api-internal/vmExecute
|
|
138
|
+
* @param int `assembly/interpreter/Interpreter`
|
|
139
|
+
* @param logs `bool`
|
|
140
|
+
*/
|
|
141
|
+
export declare function vmExecute(int: __Internref25, logs?: boolean): void;
|
|
142
|
+
/**
|
|
143
|
+
* assembly/api-internal/vmDestroy
|
|
144
|
+
* @param int `assembly/interpreter/Interpreter`
|
|
145
|
+
* @param dumpMemory `bool`
|
|
146
|
+
* @returns `assembly/api-types/VmOutput`
|
|
147
|
+
*/
|
|
148
|
+
export declare function vmDestroy(int: __Internref25, dumpMemory?: boolean): __Record50<never>;
|
|
119
149
|
/** assembly/api-utils/InputKind */
|
|
120
150
|
export declare enum InputKind {
|
|
121
151
|
/** @type `i32` */
|
|
@@ -137,7 +167,7 @@ export declare enum HasMetadata {
|
|
|
137
167
|
* @param withMetadata `i32`
|
|
138
168
|
* @returns `~lib/array/Array<assembly/gas-costs/BlockGasCost>`
|
|
139
169
|
*/
|
|
140
|
-
export declare function getGasCosts(input: Array<number>, kind: number, withMetadata: number): Array<
|
|
170
|
+
export declare function getGasCosts(input: Array<number>, kind: number, withMetadata: number): Array<__Record55<never>>;
|
|
141
171
|
/**
|
|
142
172
|
* assembly/api-utils/disassemble
|
|
143
173
|
* @param input `~lib/array/Array<u8>`
|
|
@@ -152,12 +182,12 @@ export declare function disassemble(input: Array<number>, kind: number, withMeta
|
|
|
152
182
|
* @param hasMetadata `i32`
|
|
153
183
|
* @param program `~lib/array/Array<u8>`
|
|
154
184
|
* @param initialRegisters `~lib/array/Array<u64>`
|
|
155
|
-
* @param initialPageMap `~lib/array/Array<assembly/api-
|
|
156
|
-
* @param initialMemory `~lib/array/Array<assembly/api-
|
|
185
|
+
* @param initialPageMap `~lib/array/Array<assembly/api-types/InitialPage>`
|
|
186
|
+
* @param initialMemory `~lib/array/Array<assembly/api-types/InitialChunk>`
|
|
157
187
|
* @param args `~lib/array/Array<u8>`
|
|
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<
|
|
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>): __Internref40;
|
|
161
191
|
/**
|
|
162
192
|
* assembly/api-utils/runProgram
|
|
163
193
|
* @param program `assembly/spi/StandardProgram`
|
|
@@ -165,23 +195,71 @@ 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-
|
|
198
|
+
* @returns `assembly/api-types/VmOutput`
|
|
199
|
+
*/
|
|
200
|
+
export declare function runProgram(program: __Internref40, initialGas?: bigint, programCounter?: number, logs?: boolean, useSbrkGas?: boolean): __Record50<never>;
|
|
201
|
+
/**
|
|
202
|
+
* assembly/api-utils/pvmStart
|
|
203
|
+
* @param program `assembly/spi/StandardProgram`
|
|
204
|
+
* @param useSbrkGas `bool`
|
|
205
|
+
* @returns `u32`
|
|
206
|
+
*/
|
|
207
|
+
export declare function pvmStart(program: __Internref40, useSbrkGas?: boolean): number;
|
|
208
|
+
/**
|
|
209
|
+
* assembly/api-utils/pvmDestroy
|
|
210
|
+
* @param pvmId `u32`
|
|
211
|
+
* @returns `assembly/api-types/VmOutput | null`
|
|
212
|
+
*/
|
|
213
|
+
export declare function pvmDestroy(pvmId: number): __Record50<never> | null;
|
|
214
|
+
/**
|
|
215
|
+
* assembly/api-utils/pvmSetRegisters
|
|
216
|
+
* @param pvmId `u32`
|
|
217
|
+
* @param registers `~lib/array/Array<u64>`
|
|
218
|
+
*/
|
|
219
|
+
export declare function pvmSetRegisters(pvmId: number, registers: Array<bigint>): void;
|
|
220
|
+
/**
|
|
221
|
+
* assembly/api-utils/pvmReadMemory
|
|
222
|
+
* @param pvmId `u32`
|
|
223
|
+
* @param address `u32`
|
|
224
|
+
* @param length `u32`
|
|
225
|
+
* @returns `~lib/typedarray/Uint8Array | null`
|
|
226
|
+
*/
|
|
227
|
+
export declare function pvmReadMemory(pvmId: number, address: number, length: number): Uint8Array | null;
|
|
228
|
+
/**
|
|
229
|
+
* assembly/api-utils/pvmWriteMemory
|
|
230
|
+
* @param pvmId `u32`
|
|
231
|
+
* @param address `u32`
|
|
232
|
+
* @param data `~lib/typedarray/Uint8Array`
|
|
233
|
+
* @returns `bool`
|
|
169
234
|
*/
|
|
170
|
-
export declare function
|
|
235
|
+
export declare function pvmWriteMemory(pvmId: number, address: number, data: Uint8Array): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* assembly/api-utils/pvmResume
|
|
238
|
+
* @param pvmId `u32`
|
|
239
|
+
* @param gas `i64`
|
|
240
|
+
* @param pc `u32`
|
|
241
|
+
* @param logs `bool`
|
|
242
|
+
* @returns `assembly/api-types/VmPause | null`
|
|
243
|
+
*/
|
|
244
|
+
export declare function pvmResume(pvmId: number, gas: bigint, pc: number, logs?: boolean): __Record59<never> | null;
|
|
245
|
+
/**
|
|
246
|
+
* assembly/program-build/wrapAsProgram
|
|
247
|
+
* @param bytecode `~lib/typedarray/Uint8Array`
|
|
248
|
+
* @returns `~lib/typedarray/Uint8Array`
|
|
249
|
+
*/
|
|
250
|
+
export declare function wrapAsProgram(bytecode: Uint8Array): Uint8Array;
|
|
171
251
|
/** assembly/program/Program */
|
|
172
252
|
declare class __Internref26 extends Number {
|
|
173
253
|
private __nominal26: symbol;
|
|
174
254
|
private __nominal0: symbol;
|
|
175
255
|
}
|
|
176
|
-
/** assembly/
|
|
177
|
-
declare
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
/** @type `u64` */
|
|
181
|
-
gas: bigint | TOmittable;
|
|
256
|
+
/** assembly/memory/MemoryBuilder */
|
|
257
|
+
declare class __Internref41 extends Number {
|
|
258
|
+
private __nominal41: symbol;
|
|
259
|
+
private __nominal0: symbol;
|
|
182
260
|
}
|
|
183
|
-
/** assembly/api-
|
|
184
|
-
declare interface
|
|
261
|
+
/** assembly/api-types/InitialPage */
|
|
262
|
+
declare interface __Record44<TOmittable> {
|
|
185
263
|
/** @type `u32` */
|
|
186
264
|
address: number | TOmittable;
|
|
187
265
|
/** @type `u32` */
|
|
@@ -189,30 +267,69 @@ declare interface __Record46<TOmittable> {
|
|
|
189
267
|
/** @type `i32` */
|
|
190
268
|
access: number | TOmittable;
|
|
191
269
|
}
|
|
192
|
-
/** assembly/api-
|
|
193
|
-
declare interface
|
|
270
|
+
/** assembly/api-types/InitialChunk */
|
|
271
|
+
declare interface __Record46<TOmittable> {
|
|
194
272
|
/** @type `u32` */
|
|
195
273
|
address: number | TOmittable;
|
|
196
274
|
/** @type `~lib/array/Array<u8>` */
|
|
197
275
|
data: Array<number>;
|
|
198
276
|
}
|
|
199
|
-
/** assembly/
|
|
200
|
-
declare class
|
|
201
|
-
private
|
|
277
|
+
/** assembly/memory/Memory */
|
|
278
|
+
declare class __Internref15 extends Number {
|
|
279
|
+
private __nominal15: symbol;
|
|
202
280
|
private __nominal0: symbol;
|
|
203
281
|
}
|
|
204
|
-
/** assembly/api-
|
|
205
|
-
declare
|
|
282
|
+
/** assembly/api-types/VmInput */
|
|
283
|
+
declare class __Internref49 extends Number {
|
|
284
|
+
private __nominal49: symbol;
|
|
285
|
+
private __nominal0: symbol;
|
|
286
|
+
}
|
|
287
|
+
/** assembly/interpreter/Interpreter */
|
|
288
|
+
declare class __Internref25 extends Number {
|
|
289
|
+
private __nominal25: symbol;
|
|
290
|
+
private __nominal0: symbol;
|
|
291
|
+
}
|
|
292
|
+
/** assembly/api-types/VmOutput */
|
|
293
|
+
declare interface __Record50<TOmittable> {
|
|
206
294
|
/** @type `i32` */
|
|
207
295
|
status: number | TOmittable;
|
|
296
|
+
/** @type `u32` */
|
|
297
|
+
exitCode: number | TOmittable;
|
|
298
|
+
/** @type `u32` */
|
|
299
|
+
pc: number | TOmittable;
|
|
300
|
+
/** @type `i64` */
|
|
301
|
+
gas: bigint | TOmittable;
|
|
302
|
+
/** @type `~lib/array/Array<u8>` */
|
|
303
|
+
result: Array<number>;
|
|
208
304
|
/** @type `~lib/array/Array<u64>` */
|
|
209
305
|
registers: Array<bigint>;
|
|
306
|
+
/** @type `~lib/array/Array<assembly/api-types/InitialChunk>` */
|
|
307
|
+
memory: Array<__Record46<never>>;
|
|
308
|
+
}
|
|
309
|
+
/** assembly/gas-costs/BlockGasCost */
|
|
310
|
+
declare interface __Record55<TOmittable> {
|
|
210
311
|
/** @type `u32` */
|
|
211
312
|
pc: number | TOmittable;
|
|
212
|
-
/** @type
|
|
213
|
-
memory: Array<__Record48<never>>;
|
|
214
|
-
/** @type `i64` */
|
|
313
|
+
/** @type `u64` */
|
|
215
314
|
gas: bigint | TOmittable;
|
|
315
|
+
}
|
|
316
|
+
/** assembly/spi/StandardProgram */
|
|
317
|
+
declare class __Internref40 extends Number {
|
|
318
|
+
private __nominal40: symbol;
|
|
319
|
+
private __nominal0: symbol;
|
|
320
|
+
}
|
|
321
|
+
/** assembly/api-types/VmPause */
|
|
322
|
+
declare interface __Record59<TOmittable> {
|
|
323
|
+
/** @type `i32` */
|
|
324
|
+
status: number | TOmittable;
|
|
216
325
|
/** @type `u32` */
|
|
217
326
|
exitCode: number | TOmittable;
|
|
327
|
+
/** @type `u32` */
|
|
328
|
+
pc: number | TOmittable;
|
|
329
|
+
/** @type `u32` */
|
|
330
|
+
nextPc: number | TOmittable;
|
|
331
|
+
/** @type `i64` */
|
|
332
|
+
gas: bigint | TOmittable;
|
|
333
|
+
/** @type `~lib/array/Array<u64>` */
|
|
334
|
+
registers: Array<bigint>;
|
|
218
335
|
}
|
|
@@ -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>,
|
|
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,52 @@ 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, logs, useSbrkGas) {
|
|
136
|
+
// assembly/api-internal/vmRunOnce(assembly/api-types/VmInput, bool?, bool?) => assembly/api-types/VmOutput
|
|
137
|
+
input = __lowerInternref(input) || __notnull();
|
|
138
|
+
logs = logs ? 1 : 0;
|
|
139
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
140
|
+
exports.__setArgumentsLength(arguments.length);
|
|
141
|
+
return __liftRecord50(exports.vmRunOnce(input, logs, useSbrkGas) >>> 0);
|
|
142
|
+
},
|
|
143
|
+
vmExecute(int, logs) {
|
|
144
|
+
// assembly/api-internal/vmExecute(assembly/interpreter/Interpreter, bool?) => void
|
|
145
|
+
int = __lowerInternref(int) || __notnull();
|
|
146
|
+
logs = logs ? 1 : 0;
|
|
147
|
+
exports.__setArgumentsLength(arguments.length);
|
|
148
|
+
exports.vmExecute(int, logs);
|
|
149
|
+
},
|
|
150
|
+
vmDestroy(int, dumpMemory) {
|
|
151
|
+
// assembly/api-internal/vmDestroy(assembly/interpreter/Interpreter, bool?) => assembly/api-types/VmOutput
|
|
152
|
+
int = __lowerInternref(int) || __notnull();
|
|
153
|
+
dumpMemory = dumpMemory ? 1 : 0;
|
|
154
|
+
exports.__setArgumentsLength(arguments.length);
|
|
155
|
+
return __liftRecord50(exports.vmDestroy(int, dumpMemory) >>> 0);
|
|
156
|
+
},
|
|
121
157
|
InputKind: (values => (
|
|
122
158
|
// assembly/api-utils/InputKind
|
|
123
159
|
values[values.Generic = exports["InputKind.Generic"].valueOf()] = "Generic",
|
|
@@ -133,7 +169,7 @@ async function instantiate(module, imports = {}) {
|
|
|
133
169
|
getGasCosts(input, kind, withMetadata) {
|
|
134
170
|
// assembly/api-utils/getGasCosts(~lib/array/Array<u8>, i32, i32) => ~lib/array/Array<assembly/gas-costs/BlockGasCost>
|
|
135
171
|
input = __lowerArray(__setU8, 6, 0, input) || __notnull();
|
|
136
|
-
return __liftArray(pointer =>
|
|
172
|
+
return __liftArray(pointer => __liftRecord55(__getU32(pointer)), 2, exports.getGasCosts(input, kind, withMetadata) >>> 0);
|
|
137
173
|
},
|
|
138
174
|
disassemble(input, kind, withMetadata) {
|
|
139
175
|
// assembly/api-utils/disassemble(~lib/array/Array<u8>, i32, i32) => ~lib/string/String
|
|
@@ -141,11 +177,11 @@ async function instantiate(module, imports = {}) {
|
|
|
141
177
|
return __liftString(exports.disassemble(input, kind, withMetadata) >>> 0);
|
|
142
178
|
},
|
|
143
179
|
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-
|
|
180
|
+
// 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>) => assembly/spi/StandardProgram
|
|
145
181
|
program = __retain(__lowerArray(__setU8, 6, 0, program) || __notnull());
|
|
146
|
-
initialRegisters = __retain(__lowerArray(__setU64,
|
|
147
|
-
initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
148
|
-
initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
182
|
+
initialRegisters = __retain(__lowerArray(__setU64, 51, 3, initialRegisters) || __notnull());
|
|
183
|
+
initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, initialPageMap) || __notnull());
|
|
184
|
+
initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, initialMemory) || __notnull());
|
|
149
185
|
args = __lowerArray(__setU8, 6, 0, args) || __notnull();
|
|
150
186
|
try {
|
|
151
187
|
return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) >>> 0);
|
|
@@ -157,47 +193,75 @@ async function instantiate(module, imports = {}) {
|
|
|
157
193
|
}
|
|
158
194
|
},
|
|
159
195
|
runProgram(program, initialGas, programCounter, logs, useSbrkGas) {
|
|
160
|
-
// assembly/api-utils/runProgram(assembly/spi/StandardProgram, i64?, u32?, bool?, bool?) => assembly/api-
|
|
196
|
+
// assembly/api-utils/runProgram(assembly/spi/StandardProgram, i64?, u32?, bool?, bool?) => assembly/api-types/VmOutput
|
|
161
197
|
program = __lowerInternref(program) || __notnull();
|
|
162
198
|
initialGas = initialGas || 0n;
|
|
163
199
|
logs = logs ? 1 : 0;
|
|
164
200
|
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
165
201
|
exports.__setArgumentsLength(arguments.length);
|
|
166
|
-
return
|
|
202
|
+
return __liftRecord50(exports.runProgram(program, initialGas, programCounter, logs, useSbrkGas) >>> 0);
|
|
203
|
+
},
|
|
204
|
+
pvmStart(program, useSbrkGas) {
|
|
205
|
+
// assembly/api-utils/pvmStart(assembly/spi/StandardProgram, bool?) => u32
|
|
206
|
+
program = __lowerInternref(program) || __notnull();
|
|
207
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
208
|
+
exports.__setArgumentsLength(arguments.length);
|
|
209
|
+
return exports.pvmStart(program, useSbrkGas) >>> 0;
|
|
210
|
+
},
|
|
211
|
+
pvmDestroy(pvmId) {
|
|
212
|
+
// assembly/api-utils/pvmDestroy(u32) => assembly/api-types/VmOutput | null
|
|
213
|
+
return __liftRecord50(exports.pvmDestroy(pvmId) >>> 0);
|
|
214
|
+
},
|
|
215
|
+
pvmSetRegisters(pvmId, registers) {
|
|
216
|
+
// assembly/api-utils/pvmSetRegisters(u32, ~lib/array/Array<u64>) => void
|
|
217
|
+
registers = __lowerArray(__setU64, 51, 3, registers) || __notnull();
|
|
218
|
+
exports.pvmSetRegisters(pvmId, registers);
|
|
219
|
+
},
|
|
220
|
+
pvmReadMemory(pvmId, address, length) {
|
|
221
|
+
// assembly/api-utils/pvmReadMemory(u32, u32, u32) => ~lib/typedarray/Uint8Array | null
|
|
222
|
+
return __liftTypedArray(Uint8Array, exports.pvmReadMemory(pvmId, address, length) >>> 0);
|
|
223
|
+
},
|
|
224
|
+
pvmWriteMemory(pvmId, address, data) {
|
|
225
|
+
// assembly/api-utils/pvmWriteMemory(u32, u32, ~lib/typedarray/Uint8Array) => bool
|
|
226
|
+
data = __lowerTypedArray(Uint8Array, 10, 0, data) || __notnull();
|
|
227
|
+
return exports.pvmWriteMemory(pvmId, address, data) != 0;
|
|
228
|
+
},
|
|
229
|
+
pvmResume(pvmId, gas, pc, logs) {
|
|
230
|
+
// assembly/api-utils/pvmResume(u32, i64, u32, bool?) => assembly/api-types/VmPause | null
|
|
231
|
+
gas = gas || 0n;
|
|
232
|
+
logs = logs ? 1 : 0;
|
|
233
|
+
exports.__setArgumentsLength(arguments.length);
|
|
234
|
+
return __liftRecord59(exports.pvmResume(pvmId, gas, pc, logs) >>> 0);
|
|
235
|
+
},
|
|
236
|
+
wrapAsProgram(bytecode) {
|
|
237
|
+
// assembly/program-build/wrapAsProgram(~lib/typedarray/Uint8Array) => ~lib/typedarray/Uint8Array
|
|
238
|
+
bytecode = __lowerTypedArray(Uint8Array, 10, 0, bytecode) || __notnull();
|
|
239
|
+
return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
|
|
167
240
|
},
|
|
168
241
|
}, exports);
|
|
169
|
-
function
|
|
170
|
-
// assembly/
|
|
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
|
|
242
|
+
function __lowerRecord44(value) {
|
|
243
|
+
// assembly/api-types/InitialPage
|
|
180
244
|
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
181
245
|
if (value == null) return 0;
|
|
182
|
-
const pointer = exports.__pin(exports.__new(12,
|
|
246
|
+
const pointer = exports.__pin(exports.__new(12, 44));
|
|
183
247
|
__setU32(pointer + 0, value.address);
|
|
184
248
|
__setU32(pointer + 4, value.length);
|
|
185
249
|
__setU32(pointer + 8, value.access);
|
|
186
250
|
exports.__unpin(pointer);
|
|
187
251
|
return pointer;
|
|
188
252
|
}
|
|
189
|
-
function
|
|
190
|
-
// assembly/api-
|
|
253
|
+
function __lowerRecord46(value) {
|
|
254
|
+
// assembly/api-types/InitialChunk
|
|
191
255
|
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
192
256
|
if (value == null) return 0;
|
|
193
|
-
const pointer = exports.__pin(exports.__new(8,
|
|
257
|
+
const pointer = exports.__pin(exports.__new(8, 46));
|
|
194
258
|
__setU32(pointer + 0, value.address);
|
|
195
259
|
__setU32(pointer + 4, __lowerArray(__setU8, 6, 0, value.data) || __notnull());
|
|
196
260
|
exports.__unpin(pointer);
|
|
197
261
|
return pointer;
|
|
198
262
|
}
|
|
199
|
-
function
|
|
200
|
-
// assembly/api-
|
|
263
|
+
function __liftRecord46(pointer) {
|
|
264
|
+
// assembly/api-types/InitialChunk
|
|
201
265
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
202
266
|
if (!pointer) return null;
|
|
203
267
|
return {
|
|
@@ -205,17 +269,40 @@ async function instantiate(module, imports = {}) {
|
|
|
205
269
|
data: __liftArray(__getU8, 0, __getU32(pointer + 4)),
|
|
206
270
|
};
|
|
207
271
|
}
|
|
272
|
+
function __liftRecord50(pointer) {
|
|
273
|
+
// assembly/api-types/VmOutput
|
|
274
|
+
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
275
|
+
if (!pointer) return null;
|
|
276
|
+
return {
|
|
277
|
+
status: __getI32(pointer + 0),
|
|
278
|
+
exitCode: __getU32(pointer + 4),
|
|
279
|
+
pc: __getU32(pointer + 8),
|
|
280
|
+
gas: __getI64(pointer + 16),
|
|
281
|
+
result: __liftArray(__getU8, 0, __getU32(pointer + 24)),
|
|
282
|
+
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 28)),
|
|
283
|
+
memory: __liftArray(pointer => __liftRecord46(__getU32(pointer)), 2, __getU32(pointer + 32)),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
208
286
|
function __liftRecord55(pointer) {
|
|
209
|
-
// assembly/
|
|
287
|
+
// assembly/gas-costs/BlockGasCost
|
|
288
|
+
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
289
|
+
if (!pointer) return null;
|
|
290
|
+
return {
|
|
291
|
+
pc: __getU32(pointer + 0),
|
|
292
|
+
gas: __getU64(pointer + 8),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function __liftRecord59(pointer) {
|
|
296
|
+
// assembly/api-types/VmPause
|
|
210
297
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
211
298
|
if (!pointer) return null;
|
|
212
299
|
return {
|
|
213
300
|
status: __getI32(pointer + 0),
|
|
214
|
-
|
|
301
|
+
exitCode: __getU32(pointer + 4),
|
|
215
302
|
pc: __getU32(pointer + 8),
|
|
216
|
-
|
|
303
|
+
nextPc: __getU32(pointer + 12),
|
|
217
304
|
gas: __getI64(pointer + 16),
|
|
218
|
-
|
|
305
|
+
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 24)),
|
|
219
306
|
};
|
|
220
307
|
}
|
|
221
308
|
function __liftString(pointer) {
|
|
@@ -381,8 +468,6 @@ export const {
|
|
|
381
468
|
__unpin,
|
|
382
469
|
__collect,
|
|
383
470
|
__rtti_base,
|
|
384
|
-
getAssembly,
|
|
385
|
-
wrapAsProgram,
|
|
386
471
|
resetJAM,
|
|
387
472
|
resetGeneric,
|
|
388
473
|
resetGenericWithMemory,
|
|
@@ -399,12 +484,25 @@ export const {
|
|
|
399
484
|
getPageDump,
|
|
400
485
|
getMemory,
|
|
401
486
|
setMemory,
|
|
487
|
+
getAssembly,
|
|
488
|
+
buildMemory,
|
|
489
|
+
vmInit,
|
|
490
|
+
vmRunOnce,
|
|
491
|
+
vmExecute,
|
|
492
|
+
vmDestroy,
|
|
402
493
|
InputKind,
|
|
403
494
|
HasMetadata,
|
|
404
495
|
getGasCosts,
|
|
405
496
|
disassemble,
|
|
406
497
|
prepareProgram,
|
|
407
498
|
runProgram,
|
|
499
|
+
pvmStart,
|
|
500
|
+
pvmDestroy,
|
|
501
|
+
pvmSetRegisters,
|
|
502
|
+
pvmReadMemory,
|
|
503
|
+
pvmWriteMemory,
|
|
504
|
+
pvmResume,
|
|
505
|
+
wrapAsProgram,
|
|
408
506
|
} = await (async url => instantiate(
|
|
409
507
|
await (async () => {
|
|
410
508
|
const isNodeOrBun = typeof process != "undefined" && process.versions != null && (process.versions.node != null || process.versions.bun != null);
|
|
Binary file
|