mirage
A nifty bytecode generator and runtime
Summary
| Latest Version | 1.1.2 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:26 |
Tags
Authors
- xTrayambak
Installation
nimble install mirage
choosenim install mirage
git clone https://github.com/ferus-web/mirage
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| mirage | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.0.0 | No |
| flatty >= | 0.3.4 | No |
| zippy >= | 0.10.12 | No |
| nimsimd >= | 1.2.9 | No |
| pretty >= | 0.1.0 | No |
| https://github.com/ferus-web/nim-gmp >= | 0.1.0 | No |
Source
| Repository | https://github.com/ferus-web/mirage |
|---|---|
| Homepage | https://github.com/ferus-web/mirage |
| Registry Source | nimble_official |
README
Mirage - the Modest Intermediate RepresentAtion GEnerator
Mirage is a (soon) bytecode emitter and interpreter designed to make it easier to write interpreted languages in Nim. \ It is made for the Bali JavaScript engine that will be used for Ferus. \ A lot of the bytecode instructions are shamelessly ripped off from Lua :^) \
It returns an IR object that has all the warnings generated by the IR generator alongside the IR source itself.
What it can do
- Interpret bytecode
- Proper exception tracing
- Rudimentarily analyze "hot" code paths
Mirage is ~2800 LoC and does most of the bytecode generation and interpretation work already. We're probably never going to get as fast/efficient as LLVM which has millions of hours of manpower and research applied to it with millions of LoC. \ It has plenty of bytecodes (there's too many to list here!) and can do most things you want. \ There's also some work going on to implement a fully functioning JIT compiler without any external libraries, in pure Nim!
What it'll do
- JIT compile the bytecode whenever necessary
What it won't do, for now atleast.
- Be a real competitor to LLVM's JIT runtime
- Do the other things needed to write a programming language interpreter (tokenizer, parser, semantic rule applier, etc.)
Why not add a semantic rule applier?
- A lot of languages have very bizzare allowances on what they allow the programmer to do (take JavaScript's detached-from-reality "type" system for example)
- I'm lazy