Skip to main content

unidecompiler-simulator

unidecompiler-simulator is a library for bounded execution of unidecompiler generic IR. It depends on the decompiler core but the core does not depend on, import, or know about this package.

The simulator owns frames, control flow, calls, limits, exceptions, and the execution trace. A frontend may expose an optional simulation_adapter attribute for frontend-specific function lookup and runtime facts. The adapter may answer individual operations, but it must not execute functions, interpret instructions, recover control flow, or return executable callbacks.

Generic IR execution is available without a frontend:

from unidecompiler_simulator import SimulationEngine

result = SimulationEngine().simulate_function(module, function, args=(1, 2))

Artifact execution gives an adapter the decoded frontend-owned payload only for function lookup and runtime hooks:

result = SimulationEngine().simulate_artifact(
    data,
    "sample.bytecode",
    query={"class": "Example", "method": "run"},
)

The unidecompiler-cli package hosts the command-line interface and accepts a frontend-owned function query and JSON arguments:

unidecompiler simulate sample.bytecode --function 'Example.run' --args '[1, 2]'

For the Lua bubble-sort fixture, compile the source before invoking the simulator. The Lua frontend adapter supplies only Lua function lookup and runtime value facts; the simulator still executes the lifted generic IR.

luac -o bubble_sort.luac simulator_projects/source/arithmetic.lua
unidecompiler simulate bubble_sort.luac --frontend lua --function bubble_sort --args '[[5, 1, 4, 2, 8]]'

The completed result contains "values": [[1, 2, 4, 5, 8]].

Built-in frontend adapters accept the following frontend-owned function queries:

Frontend Query
Python .pyc Unique function name, for example arithmetic
JVM .class Unique method name or Class.method, for example Sample.add
.NET assembly Unique method name or Type.Method, for example Probe.Add
WebAssembly Function name or $funcN, for example add or $func0
Lua chunk Unique function name, for example bubble_sort

Ambiguous queries are rejected by the relevant frontend adapter. The simulator does not choose among overloads or perform frontend-specific name recovery.

Execution is bounded and in-memory. Unknown operations, unsupported IR, and unsafe runtime behavior stop with a structured result instead of guessing.

Generic numeric execution supports canonical operators and common neutral shift, rotate, and bitwise aliases, including shl, shr, rol, and ror. Signedness, bit width, float width, and integer wrap/trap overflow policy come from generic IR and are never inferred from a frontend ID. Phi assignments at block entry use parallel-copy semantics; explicit generic stores, deletes, tuple/list kinds, and exception matching are also preserved.

Applications may inject an ExternalEnvironment for unresolved named calls. The environment receives only ExternalCallRequest data and returns an ExternalCallResult; it never receives IR, frames, adapters, or execution control. Python-file loading is intentionally owned by unidecompiler-cli, not this library.

The simulator does not resolve Global expressions as function names. Any frontend-specific function lookup or dynamic call target must be provided by the optional adapter and must resolve back to a FunctionIR owned by the current lifted module.

The simulator intentionally does not execute frontend bytecode, frontend opcode tables, or core Effect objects directly. Core is responsible for lifting VM-neutral effects into generic IR; this package executes that generic IR. Keeping that boundary strict prevents a language-specific opcode switch from leaking into the simulator and keeps every frontend replaceable.

Release files for unidecompiler-simulator 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unidecompiler-simulator 0.2.2
File Size Uploaded
unidecompiler_simulator-0.2.2.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unidecompiler-simulator 0.2.2
File Interpreter ABI Platform
unidecompiler_simulator-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 46.6 kB

Release files / unidecompiler_simulator-0.2.2.tar.gz

Download URL unidecompiler_simulator-0.2.2.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f9793e068125731983d973b58bef91f65a0056759e7e2a782b4feda1c9c89c3c
BLAKE2b-256 checksum
How to use checksums
d8419ebe24a6f1ef54f69943c3b993104885f280c90ccde71d137e88cde3b010
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / unidecompiler_simulator-0.2.2-py3-none-any.whl

Download URL unidecompiler_simulator-0.2.2-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f1e3a6ebbd38379fd8b4847e5fcf806c4383b22979fcdb50f12bb53ddbf82db
BLAKE2b-256 checksum
How to use checksums
1dbc4cba116f65d474a3e18f3f62256406db67f1864c114e6c40738c796b0d9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release history Release notifications | RSS feed

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page