dibyendumajumdar / ravi

Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
http://ravilang.github.io/
Other
1.16k stars 60 forks source link

Could c2mir be integrated as a library, like tcc.lua? #219

Closed skunkiferous closed 3 years ago

skunkiferous commented 3 years ago

tcc.lua seems like a great addition to luajit, to implement "hot loops" and bit-fiddling in C, instead of Lua.

Since Ravi uses MIR, and there is a c2mir compiler, that can also be used as a library, like TCC, one would think, it should be possible to provide something similar to tcc.lua, but using c2mir.

How difficult would that be?

Background: I'm looking for an all-in-one solution to scripting a game, with an "easy-to-learn" language with a community (Lua), for the "modders", the ability to use static-typing (Ravi) for "me", and the ability to code low-level for performance-critical code (C).

dibyendumajumdar commented 3 years ago

c2mir is better than tcc anyway - so can you not just use that?

skunkiferous commented 3 years ago

So, you think c2mir would be the way to go. You say that "c2mir is better than tcc anyway". Do you mean that c2mir would make faster code (because TCC hasn't been updated to support recent processors), or is there some other reason c2mir would be better? For example, would there be "less overhead" calling C from Ravi, or the other way around, using c2mir, because they share the same bytecode?

dibyendumajumdar commented 3 years ago

I am not sure I have understood what you are trying to do.

If you are seeking to easily compile C code from inside Ravi, then c2mir can do that. I have not exposed this capability.

The main limitation of c2mir is it only supports 64-bit architectures. I have not compared with tcc, but my understanding of tcc is that it lacks an optimizer.

skunkiferous commented 3 years ago

That answers my question.