UNPKG

@five-vm/cli

Version:

High-performance CLI for Five VM development with WebAssembly integration

1,553 lines (1,485 loc) 109 kB
let imports = {}; imports['__wbindgen_placeholder__'] = module.exports; let wasm; const { TextEncoder, TextDecoder } = require(`util`); const heap = new Array(128).fill(undefined); heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } let WASM_VECTOR_LEN = 0; let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8ArrayMemory0; } let cachedTextEncoder = new TextEncoder('utf-8'); const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' ? function (arg, view) { return cachedTextEncoder.encodeInto(arg, view); } : function (arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length }; }); function passStringToWasm0(arg, malloc, realloc) { if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length, 1) >>> 0; getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr; } let len = arg.length; let ptr = malloc(len, 1) >>> 0; const mem = getUint8ArrayMemory0(); let offset = 0; for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 0x7F) break; mem[ptr + offset] = code; } if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; } let cachedDataViewMemory0 = null; function getDataViewMemory0() { if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { cachedDataViewMemory0 = new DataView(wasm.memory.buffer); } return cachedDataViewMemory0; } let heap_next = heap.length; function addHeapObject(obj) { if (heap_next === heap.length) heap.push(heap.length + 1); const idx = heap_next; heap_next = heap[idx]; heap[idx] = obj; return idx; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { wasm.__wbindgen_export_2(addHeapObject(e)); } } let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0; return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } function getArrayU8FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } function dropObject(idx) { if (idx < 132) return; heap[idx] = heap_next; heap_next = idx; } function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret; } function isLikeNone(x) { return x === undefined || x === null; } function debugString(val) { // primitive types const type = typeof val; if (type == 'number' || type == 'boolean' || val == null) { return `${val}`; } if (type == 'string') { return `"${val}"`; } if (type == 'symbol') { const description = val.description; if (description == null) { return 'Symbol'; } else { return `Symbol(${description})`; } } if (type == 'function') { const name = val.name; if (typeof name == 'string' && name.length > 0) { return `Function(${name})`; } else { return 'Function'; } } // objects if (Array.isArray(val)) { const length = val.length; let debug = '['; if (length > 0) { debug += debugString(val[0]); } for(let i = 1; i < length; i++) { debug += ', ' + debugString(val[i]); } debug += ']'; return debug; } // Test for built-in const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); let className; if (builtInMatches && builtInMatches.length > 1) { className = builtInMatches[1]; } else { // Failed to match the standard '[object ClassName]' return toString.call(val); } if (className == 'Object') { // we're a user defined class or Object // JSON.stringify avoids problems with cycles, and is generally much // easier than looping through ownProperties of `val`. try { return 'Object(' + JSON.stringify(val) + ')'; } catch (_) { return 'Object'; } } // errors if (val instanceof Error) { return `${val.name}: ${val.message}\n${val.stack}`; } // TODO we could test for more things here, like `Set`s and `Map`s. return className; } /** * @param {string} message */ module.exports.log_to_console = function(message) { const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; wasm.log_to_console(ptr0, len0); }; function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1, 1) >>> 0; getUint8ArrayMemory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } let stack_pointer = 128; function addBorrowedObject(obj) { if (stack_pointer == 1) throw new Error('out of js stack'); heap[--stack_pointer] = obj; return stack_pointer; } /** * Helper function to convert JS value to VM Value * @param {any} js_val * @param {number} value_type * @returns {any} */ module.exports.js_value_to_vm_value = function(js_val, value_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.js_value_to_vm_value(retptr, addBorrowedObject(js_val), value_type); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); heap[stack_pointer++] = undefined; } }; function getArrayJsValueFromWasm0(ptr, len) { ptr = ptr >>> 0; const mem = getDataViewMemory0(); const result = []; for (let i = ptr; i < ptr + 4 * len; i += 4) { result.push(takeObject(mem.getUint32(i, true))); } return result; } function _assertClass(instance, klass) { if (!(instance instanceof klass)) { throw new Error(`expected instance of ${klass.name}`); } } /** * Get information about the WASM compiler capabilities * @returns {any} */ module.exports.get_wasm_compiler_info = function() { const ret = wasm.get_wasm_compiler_info(); return takeObject(ret); }; /** * Execution result that honestly reports what happened * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6} */ module.exports.ExecutionStatus = Object.freeze({ /** * All operations completed successfully */ Completed: 0, "0": "Completed", /** * Execution stopped because it hit a system program call that cannot be executed in WASM */ StoppedAtSystemCall: 1, "1": "StoppedAtSystemCall", /** * Execution stopped because it hit an INIT_PDA operation that requires real Solana context */ StoppedAtInitPDA: 2, "2": "StoppedAtInitPDA", /** * Execution stopped because it hit an INVOKE operation that requires real RPC */ StoppedAtInvoke: 3, "3": "StoppedAtInvoke", /** * Execution stopped because it hit an INVOKE_SIGNED operation that requires real RPC */ StoppedAtInvokeSigned: 4, "4": "StoppedAtInvokeSigned", /** * Execution stopped because compute limit was reached */ ComputeLimitExceeded: 5, "5": "ComputeLimitExceeded", /** * Execution failed due to an error */ Failed: 6, "6": "Failed", }); const BytecodeAnalyzerFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_bytecodeanalyzer_free(ptr >>> 0, 1)); /** * Bytecode analyzer for WASM */ class BytecodeAnalyzer { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; BytecodeAnalyzerFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_bytecodeanalyzer_free(ptr, 0); } /** * Analyze bytecode and return instruction breakdown (legacy method for compatibility) * @param {Uint8Array} bytecode * @returns {any} */ static analyze(bytecode) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.bytecodeanalyzer_analyze(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Advanced semantic analysis with full opcode understanding and instruction flow * This provides the intelligent analysis that understands what each opcode does * and what operands follow each instruction. * @param {Uint8Array} bytecode * @returns {any} */ static analyze_semantic(bytecode) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.bytecodeanalyzer_analyze_semantic(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Get detailed information about a specific instruction at an offset * @param {Uint8Array} bytecode * @param {number} offset * @returns {any} */ static analyze_instruction_at(bytecode, offset) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.bytecodeanalyzer_analyze_instruction_at(retptr, ptr0, len0, offset); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Get summary statistics about the bytecode * @param {Uint8Array} bytecode * @returns {any} */ static get_bytecode_summary(bytecode) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.bytecodeanalyzer_get_bytecode_summary(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Get detailed opcode flow analysis - shows execution paths through the bytecode * @param {Uint8Array} bytecode * @returns {any} */ static analyze_execution_flow(bytecode) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.bytecodeanalyzer_analyze_execution_flow(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } module.exports.BytecodeAnalyzer = BytecodeAnalyzer; const FiveVMStateFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_fivevmstate_free(ptr >>> 0, 1)); /** * JavaScript-compatible VM state representation */ class FiveVMState { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; FiveVMStateFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_fivevmstate_free(ptr, 0); } /** * @returns {Array<any>} */ get stack() { const ret = wasm.fivevmstate_stack(this.__wbg_ptr); return takeObject(ret); } /** * @returns {number} */ get instruction_pointer() { const ret = wasm.fivevmstate_instruction_pointer(this.__wbg_ptr); return ret >>> 0; } /** * @returns {bigint} */ get compute_units() { const ret = wasm.fivevmstate_compute_units(this.__wbg_ptr); return BigInt.asUintN(64, ret); } } module.exports.FiveVMState = FiveVMState; const FiveVMWasmFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_fivevmwasm_free(ptr >>> 0, 1)); /** * Main WASM VM wrapper */ class FiveVMWasm { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; FiveVMWasmFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_fivevmwasm_free(ptr, 0); } /** * Create new VM instance with bytecode * @param {Uint8Array} _bytecode */ constructor(_bytecode) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(_bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.fivevmwasm_new(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } this.__wbg_ptr = r0 >>> 0; FiveVMWasmFinalization.register(this, this.__wbg_ptr, this); return this; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Execute VM with input data and accounts (legacy method) * @param {Uint8Array} input_data * @param {Array<any>} accounts * @returns {any} */ execute(input_data, accounts) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(input_data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.fivevmwasm_execute(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(accounts)); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Execute VM with partial execution support - stops at system calls * @param {Uint8Array} input_data * @param {Array<any>} accounts * @returns {TestResult} */ execute_partial(input_data, accounts) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(input_data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.fivevmwasm_execute_partial(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(accounts)); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return TestResult.__wrap(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Get current VM state * @returns {any} */ get_state() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.fivevmwasm_get_state(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Validate bytecode without execution * @param {Uint8Array} bytecode * @returns {boolean} */ static validate_bytecode(bytecode) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.fivevmwasm_validate_bytecode(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return r0 !== 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Get VM constants for JavaScript * @returns {any} */ static get_constants() { const ret = wasm.fivevmwasm_get_constants(); return takeObject(ret); } } module.exports.FiveVMWasm = FiveVMWasm; const ParameterEncoderFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_parameterencoder_free(ptr >>> 0, 1)); /** * Parameter encoding utilities using VLE and protocol types */ class ParameterEncoder { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; ParameterEncoderFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_parameterencoder_free(ptr, 0); } /** * Encode function parameters using VLE compression * Returns ONLY parameter data - SDK handles discriminator AND function index * Each parameter value is VLE-encoded regardless of its declared type for maximum compression * @param {number} _function_index * @param {Array<any>} params * @returns {Uint8Array} */ static encode_execute_vle(_function_index, params) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.parameterencoder_encode_execute_vle(retptr, _function_index, addHeapObject(params)); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } module.exports.ParameterEncoder = ParameterEncoder; const TestResultFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_testresult_free(ptr >>> 0, 1)); /** * Detailed execution result that provides full context */ class TestResult { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(TestResult.prototype); obj.__wbg_ptr = ptr; TestResultFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; TestResultFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_testresult_free(ptr, 0); } /** * Compute units consumed * @returns {bigint} */ get compute_units_used() { const ret = wasm.__wbg_get_testresult_compute_units_used(this.__wbg_ptr); return BigInt.asUintN(64, ret); } /** * Compute units consumed * @param {bigint} arg0 */ set compute_units_used(arg0) { wasm.__wbg_set_testresult_compute_units_used(this.__wbg_ptr, arg0); } /** * Final instruction pointer * @returns {number} */ get instruction_pointer() { const ret = wasm.__wbg_get_testresult_instruction_pointer(this.__wbg_ptr); return ret >>> 0; } /** * Final instruction pointer * @param {number} arg0 */ set instruction_pointer(arg0) { wasm.__wbg_set_testresult_instruction_pointer(this.__wbg_ptr, arg0); } /** * Which opcode caused the stop (if stopped at system call) * @returns {number | undefined} */ get stopped_at_opcode() { const ret = wasm.__wbg_get_testresult_stopped_at_opcode(this.__wbg_ptr); return ret === 0xFFFFFF ? undefined : ret; } /** * Which opcode caused the stop (if stopped at system call) * @param {number | null} [arg0] */ set stopped_at_opcode(arg0) { wasm.__wbg_set_testresult_stopped_at_opcode(this.__wbg_ptr, isLikeNone(arg0) ? 0xFFFFFF : arg0); } /** * @returns {string} */ get status() { let deferred1_0; let deferred1_1; try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.testresult_status(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); deferred1_0 = r0; deferred1_1 = r1; return getStringFromWasm0(r0, r1); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1); } } /** * @returns {boolean} */ get has_result_value() { const ret = wasm.testresult_has_result_value(this.__wbg_ptr); return ret !== 0; } /** * @returns {any} */ get get_result_value() { const ret = wasm.testresult_get_result_value(this.__wbg_ptr); return takeObject(ret); } /** * @returns {Array<any>} */ get final_stack() { const ret = wasm.testresult_final_stack(this.__wbg_ptr); return takeObject(ret); } /** * @returns {string | undefined} */ get error_message() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.testresult_error_message(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 1, 1); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @returns {string | undefined} */ get execution_context() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.testresult_execution_context(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 1, 1); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @returns {string | undefined} */ get stopped_at_opcode_name() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.testresult_stopped_at_opcode_name(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 1, 1); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } module.exports.TestResult = TestResult; const VLEEncoderFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_vleencoder_free(ptr >>> 0, 1)); /** * VLE Encoding utilities for JavaScript */ class VLEEncoder { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; VLEEncoderFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_vleencoder_free(ptr, 0); } /** * Encode a u32 value using Variable-Length Encoding * Returns [size, byte1, byte2, byte3] where size is 1-3 * @param {number} value * @returns {Array<any>} */ static encode_u32(value) { const ret = wasm.vleencoder_encode_u32(value); return takeObject(ret); } /** * Encode a u16 value using Variable-Length Encoding * Returns [size, byte1, byte2] where size is 1-2 * @param {number} value * @returns {Array<any>} */ static encode_u16(value) { const ret = wasm.vleencoder_encode_u16(value); return takeObject(ret); } /** * Decode a u32 value from Variable-Length Encoding * Returns [value, bytes_consumed] or null if invalid * @param {Uint8Array} bytes * @returns {Array<any> | undefined} */ static decode_u32(bytes) { const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; const ret = wasm.vleencoder_decode_u32(ptr0, len0); return takeObject(ret); } /** * Decode a u16 value from Variable-Length Encoding * Returns [value, bytes_consumed] or null if invalid * @param {Uint8Array} bytes * @returns {Array<any> | undefined} */ static decode_u16(bytes) { const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; const ret = wasm.vleencoder_decode_u16(ptr0, len0); return takeObject(ret); } /** * Calculate encoded size without encoding * @param {number} value * @returns {number} */ static encoded_size_u32(value) { const ret = wasm.vleencoder_encoded_size_u32(value); return ret >>> 0; } /** * Calculate encoded size for u16 * @param {number} value * @returns {number} */ static encoded_size_u16(value) { const ret = wasm.vleencoder_encoded_size_u16(value); return ret >>> 0; } } module.exports.VLEEncoder = VLEEncoder; const WasmAccountFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_wasmaccount_free(ptr >>> 0, 1)); /** * JavaScript-compatible account representation */ class WasmAccount { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; WasmAccountFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_wasmaccount_free(ptr, 0); } /** * @returns {bigint} */ get lamports() { const ret = wasm.__wbg_get_wasmaccount_lamports(this.__wbg_ptr); return BigInt.asUintN(64, ret); } /** * @param {bigint} arg0 */ set lamports(arg0) { wasm.__wbg_set_wasmaccount_lamports(this.__wbg_ptr, arg0); } /** * @returns {boolean} */ get is_writable() { const ret = wasm.__wbg_get_wasmaccount_is_writable(this.__wbg_ptr); return ret !== 0; } /** * @param {boolean} arg0 */ set is_writable(arg0) { wasm.__wbg_set_wasmaccount_is_writable(this.__wbg_ptr, arg0); } /** * @returns {boolean} */ get is_signer() { const ret = wasm.__wbg_get_wasmaccount_is_signer(this.__wbg_ptr); return ret !== 0; } /** * @param {boolean} arg0 */ set is_signer(arg0) { wasm.__wbg_set_wasmaccount_is_signer(this.__wbg_ptr, arg0); } /** * @param {Uint8Array} key * @param {Uint8Array} data * @param {bigint} lamports * @param {boolean} is_writable * @param {boolean} is_signer * @param {Uint8Array} owner */ constructor(key, data, lamports, is_writable, is_signer, owner) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len1 = WASM_VECTOR_LEN; const ptr2 = passArray8ToWasm0(owner, wasm.__wbindgen_export_0); const len2 = WASM_VECTOR_LEN; wasm.wasmaccount_new(retptr, ptr0, len0, ptr1, len1, lamports, is_writable, is_signer, ptr2, len2); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } this.__wbg_ptr = r0 >>> 0; WasmAccountFinalization.register(this, this.__wbg_ptr, this); return this; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @returns {Uint8Array} */ get key() { const ret = wasm.wasmaccount_key(this.__wbg_ptr); return takeObject(ret); } /** * @returns {Uint8Array} */ get data() { const ret = wasm.wasmaccount_data(this.__wbg_ptr); return takeObject(ret); } /** * @param {Uint8Array} data */ set data(data) { const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.wasmaccount_set_data(this.__wbg_ptr, ptr0, len0); } /** * @returns {Uint8Array} */ get owner() { const ret = wasm.wasmaccount_owner(this.__wbg_ptr); return takeObject(ret); } } module.exports.WasmAccount = WasmAccount; const WasmAnalysisResultFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_wasmanalysisresult_free(ptr >>> 0, 1)); /** * WASM source analysis result */ class WasmAnalysisResult { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(WasmAnalysisResult.prototype); obj.__wbg_ptr = ptr; WasmAnalysisResultFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; WasmAnalysisResultFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_wasmanalysisresult_free(ptr, 0); } /** * Whether analysis succeeded * @returns {boolean} */ get success() { const ret = wasm.__wbg_get_wasmanalysisresult_success(this.__wbg_ptr); return ret !== 0; } /** * Whether analysis succeeded * @param {boolean} arg0 */ set success(arg0) { wasm.__wbg_set_wasmanalysisresult_success(this.__wbg_ptr, arg0); } /** * Analysis time in milliseconds * @returns {number} */ get analysis_time() { const ret = wasm.__wbg_get_wasmanalysisresult_analysis_time(this.__wbg_ptr); return ret; } /** * Analysis time in milliseconds * @param {number} arg0 */ set analysis_time(arg0) { wasm.__wbg_set_wasmanalysisresult_analysis_time(this.__wbg_ptr, arg0); } /** * @returns {string} */ get summary() { let deferred1_0; let deferred1_1; try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.wasmanalysisresult_summary(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); deferred1_0 = r0; deferred1_1 = r1; return getStringFromWasm0(r0, r1); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1); } } /** * @returns {string} */ get metrics() { let deferred1_0; let deferred1_1; try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.wasmanalysisresult_metrics(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); deferred1_0 = r0; deferred1_1 = r1; return getStringFromWasm0(r0, r1); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1); } } /** * @returns {Array<any>} */ get errors() { const ret = wasm.wasmanalysisresult_errors(this.__wbg_ptr); return takeObject(ret); } /** * Get parsed metrics as JavaScript object * @returns {any} */ get_metrics_object() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.wasmanalysisresult_get_metrics_object(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } module.exports.WasmAnalysisResult = WasmAnalysisResult; const WasmCompilationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_wasmcompilationoptions_free(ptr >>> 0, 1)); /** * Compilation options for enhanced error reporting and formatting */ class WasmCompilationOptions { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(WasmCompilationOptions.prototype); obj.__wbg_ptr = ptr; WasmCompilationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; WasmCompilationOptionsFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_wasmcompilationoptions_free(ptr, 0); } /** * Enable v2-preview features (nibble immediates, BR_EQ_U8, etc.) * @returns {boolean} */ get v2_preview() { const ret = wasm.__wbg_get_wasmcompilationoptions_v2_preview(this.__wbg_ptr); return ret !== 0; } /** * Enable v2-preview features (nibble immediates, BR_EQ_U8, etc.) * @param {boolean} arg0 */ set v2_preview(arg0) { wasm.__wbg_set_wasmcompilationoptions_v2_preview(this.__wbg_ptr, arg0); } /** * Enable constraint caching optimization * @returns {boolean} */ get enable_constraint_cache() { const ret = wasm.__wbg_get_wasmcompilationoptions_enable_constraint_cache(this.__wbg_ptr); return ret !== 0; } /** * Enable constraint caching optimization * @param {boolean} arg0 */ set enable_constraint_cache(arg0) { wasm.__wbg_set_wasmcompilationoptions_enable_constraint_cache(this.__wbg_ptr, arg0); } /** * Enable enhanced error reporting with suggestions * @returns {boolean} */ get enhanced_errors() { const ret = wasm.__wbg_get_wasmcompilationoptions_enhanced_errors(this.__wbg_ptr); return ret !== 0; } /** * Enable enhanced error reporting with suggestions * @param {boolean} arg0 */ set enhanced_errors(arg0) { wasm.__wbg_set_wasmcompilationoptions_enhanced_errors(this.__wbg_ptr, arg0); } /** * Include basic metrics * @returns {boolean} */ get include_metrics() { const ret = wasm.__wbg_get_wasmcompilationoptions_include_metrics(this.__wbg_ptr); return ret !== 0; } /** * Include basic metrics * @param {boolean} arg0 */ set include_metrics(arg0) { wasm.__wbg_set_wasmcompilationoptions_include_metrics(this.__wbg_ptr, arg0); } /** * Include comprehensive metrics collection * @returns {boolean} */ get comprehensive_metrics() { const ret = wasm.__wbg_get_wasmcompilationoptions_comprehensive_metrics(this.__wbg_ptr); return ret !== 0; } /** * Include comprehensive metrics collection * @param {boolean} arg0 */ set comprehensive_metrics(arg0) { wasm.__wbg_set_wasmcompilationoptions_comprehensive_metrics(this.__wbg_ptr, arg0); } /** * Include performance analysis * @returns {boolean} */ get performance_analysis() { const ret = wasm.__wbg_get_wasmcompilationoptions_performance_analysis(this.__wbg_ptr); return ret !== 0; } /** * Include performance analysis * @param {boolean} arg0 */ set performance_analysis(arg0) { wasm.__wbg_set_wasmcompilationoptions_performance_analysis(this.__wbg_ptr, arg0); } /** * Include complexity analysis * @returns {boolean} */ get complexity_analysis() { const ret = wasm.__wbg_get_wasmcompilationoptions_complexity_analysis(this.__wbg_ptr); return ret !== 0; } /** * Include complexity analysis * @param {boolean} arg0 */ set complexity_analysis(arg0) { wasm.__wbg_set_wasmcompilationoptions_complexity_analysis(this.__wbg_ptr, arg0); } /** * Show compilation summary * @returns {boolean} */ get summary() { const ret = wasm.__wbg_get_wasmcompilationoptions_summary(this.__wbg_ptr); return ret !== 0; } /** * Show compilation summary * @param {boolean} arg0 */ set summary(arg0) { wasm.__wbg_set_wasmcompilationoptions_summary(this.__wbg_ptr, arg0); } /** * Verbose output * @returns {boolean} */ get verbose() { const ret = wasm.__wbg_get_wasmcompilationoptions_verbose(this.__wbg_ptr); return ret !== 0; } /** * Verbose output * @param {boolean} arg0 */ set verbose(arg0) { wasm.__wbg_set_wasmcompilationoptions_verbose(this.__wbg_ptr, arg0); } /** * Suppress non-essential output * @returns {boolean} */ get quiet() { const ret = wasm.__wbg_get_wasmcompilationoptions_quiet(this.__wbg_ptr); return ret !== 0; } /** * Suppress non-essential output * @param {boolean} arg0 */ set quiet(arg0) { wasm.__wbg_set_wasmcompilationoptions_quiet(this.__wbg_ptr, arg0); } /** * Include debug information * @returns {boolean} */ get include_debug_info() { const ret = wasm.__wbg_get_wasmcompilationoptions_include_debug_info(this.__wbg_ptr); return ret !== 0; } /** * Include debug information * @param {boolean} arg0 */ set include_debug_info(arg0) { wasm.__wbg_set_wasmcompilationoptions_include_debug_info(this.__wbg_ptr, arg0); } /** * Enable bytecode compression * @returns {boolean} */ get compress_output() { const ret = wasm.__wbg_get_wasmcompilationoptions_compress_output(this.__wbg_ptr); return ret !== 0; } /** * Enable bytecode compression * @param {boolean} arg0 */ set compress_output(arg0) { wasm.__wbg_set_wasmcompilationoptions_compress_output(this.__wbg_ptr, arg0); } /** * Create default compilation options */ constructor() { const ret = wasm.wasmcompilationoptions_new(); this.__wbg_ptr = ret >>> 0; WasmCompilationOptionsFinalization.register(this, this.__wbg_ptr, this); return this; } /** * Set compilation mode * @param {string} mode * @returns {WasmCompilationOptions} */ with_mode(mode) { const ptr = this.__destroy_into_raw(); const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; const ret = wasm.wasmcompilationoptions_with_mode(ptr, ptr0, len0); return WasmCompilationOptions.__wrap(ret); } /** * Set optimization level (v1, v2, v3) * @param {string} level * @returns {WasmCompilationOptions} */ with_optimization_level(level) { const ptr = this.__destroy_into_raw(); const ptr0 = passStringToWasm0(level, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; const ret = wasm.wasmcompilationoptions_with_optimization_level(ptr, ptr0, len0); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable v2-preview features * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_v2_preview(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_v2_preview(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable constraint caching optimization * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_constraint_cache(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_constraint_cache(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable enhanced error reporting * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_enhanced_errors(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_enhanced_errors(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Set error output format * @param {string} format * @returns {WasmCompilationOptions} */ with_error_format(format) { const ptr = this.__destroy_into_raw(); const ptr0 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; const ret = wasm.wasmcompilationoptions_with_error_format(ptr, ptr0, len0); return WasmCompilationOptions.__wrap(ret); } /** * Set source file name for better error reporting * @param {string} filename * @returns {WasmCompilationOptions} */ with_source_file(filename) { const ptr = this.__destroy_into_raw(); const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; const ret = wasm.wasmcompilationoptions_with_source_file(ptr, ptr0, len0); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable basic metrics collection * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_metrics(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_metrics(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable comprehensive metrics collection * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_comprehensive_metrics(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_comprehensive_metrics(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Set metrics export format * @param {string} format * @returns {WasmCompilationOptions} */ with_metrics_format(format) { const ptr = this.__destroy_into_raw(); const ptr0 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; const ret = wasm.wasmcompilationoptions_with_metrics_format(ptr, ptr0, len0); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable performance analysis * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_performance_analysis(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_performance_analysis(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable complexity analysis * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_complexity_analysis(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_complexity_analysis(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable compilation summary * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_summary(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_summary(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable verbose output * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_verbose(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_verbose(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Enable or disable quiet mode * @param {boolean} enabled * @returns {WasmCompilationOptions} */ with_quiet(enabled) { const ptr = this.__destroy_into_raw(); const ret = wasm.wasmcompilationoptions_with_quiet(ptr, enabled); return WasmCompilationOptions.__wrap(ret); } /** * Set analysis depth level * @param {string} depth * @returns {WasmCompilationOptions} */ with_analysis_depth(depth) { const ptr = this.__destroy_into_raw(); const ptr0 = passStringToWasm0(depth, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WAS