https://github.com/nbp/holyjit
The project is dead but you could get some inspiration there. The idea is that you only write interpreter and some wodoo macro will eventually generate very efficient code for that interpreter. But it doesn't have to be interpreted anymore. A bit like JIT JIT compiler.
It's super ambitious but it has been done already - GraalVM compiler is the most successful and production-ready example. TBH, they have far more resources but they also have much bigger scope, so... Definitely possible.
It might be easier to resurrect the project and use it instead of doing JIT all by yourself (and it might be for other dynamic languages implemented in rust).
I would do that myself if I was not busy with other things in my life right now (yeah, I know)
https://github.com/nbp/holyjit
The project is dead but you could get some inspiration there. The idea is that you only write interpreter and some wodoo macro will eventually generate very efficient code for that interpreter. But it doesn't have to be interpreted anymore. A bit like JIT JIT compiler.
It's super ambitious but it has been done already - GraalVM compiler is the most successful and production-ready example. TBH, they have far more resources but they also have much bigger scope, so... Definitely possible.
It might be easier to resurrect the project and use it instead of doing JIT all by yourself (and it might be for other dynamic languages implemented in rust).
I would do that myself if I was not busy with other things in my life right now (yeah, I know)