MCPcopy Create free account
hub / github.com/QuipNetwork/xquad / program_from_xqasm

Function program_from_xqasm

xqvm_py/program.py:163–180  ·  view source on GitHub ↗

Parse ``.xqasm`` source via the Rust xqasm crate and wrap the result. This is the single entry point xqvm-py uses to turn assembly text into an executable ``Program``. The actual parsing + assembly is done by ``xqffi.asm.parse_xqasm`` (a pyo3 binding to Rust ``xqasm``); this helper

(source: str, name: str = "")

Source from the content-addressed store, hash-verified

161
162
163def program_from_xqasm(source: str, name: str = "") -> Program:
164 """Parse ``.xqasm`` source via the Rust xqasm crate and wrap the result.
165
166 This is the single entry point xqvm-py uses to turn assembly text
167 into an executable ``Program``. The actual parsing + assembly is
168 done by ``xqffi.asm.parse_xqasm`` (a pyo3 binding to Rust
169 ``xqasm``); this helper just adapts the wire dict into the Python
170 dataclass layout the executor expects.
171
172 The ``program_from_xqasm`` / ``Instruction`` / ``Program`` trio
173 replaces what used to be ``xqvm.assembler.assemble(src).program``
174 — xqvm-py no longer ships its own assembler.
175 """
176 from xqffi.asm import parse_xqasm
177
178 wire = parse_xqasm(source)
179 instructions = [Instruction(Opcode.from_code(code), tuple(ops), int(pc)) for code, ops, pc in wire["instructions"]]
180 return Program(instructions=instructions, name=name, jump_targets=_build_jump_targets(instructions))

Callers 12

test_full_pipeline_n3Method · 0.90
test_full_pipeline_n4Method · 0.90
_load_programFunction · 0.90
test_bytecode_round_tripFunction · 0.90

Calls 5

parse_xqasmFunction · 0.90
InstructionClass · 0.85
_build_jump_targetsFunction · 0.85
from_codeMethod · 0.80
ProgramClass · 0.70