• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

lua2jass

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
A lua to jass compiler.
Simply provide a common.j and your lua script to the exe and receive a war3map.j

Code:
$ lua2jass common.j war3map.lua war3map.j

Now add some config and main functions (in jass ofc) to your script, execute the lua main (call ExecuteFunc("lua_Main_init")) and have your lua script run god knows how much slower in your good ol' jass vm. Bonus points if you start your map with jass2lua translation.
(Bonus bonus points to me as i run this through jhcr, that is compiling lua to jass, interpreting that jass in jass itself, and then running that jass in lua via wc3 jass2lua. ez).

Some things don't work at the moment (and maybe never). You can see which one over at github.

Contrary to the slim real-world usecase of this whole endevaour this probably currently doesnt run on older patches. But i don't think there is any fundamental problem with it. Except maybe the way lower opcount code in earlier patches.

Speaking of slow stuff: the garbage collector is a very simple stop-the-world mark-and-sweep. So better don't produce too much garbage.

Also this is probably still very buggy. Anyone who has ever written a GC knows the pain. Feel free to report any bugs but don't expect too much attention. I spent way too much time on this allready.
 

Attachments

  • lua2jass.exe.zip
    4.4 MB · Views: 28
Last edited:

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Hell yeah. I think this is a good idea. There is nothing that could go wrong.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
This is insane yet very innovative. You've written parts of the Lua C compiler in JASS and created a bastardized concoction of LuaJASS to be run by it. Very gnarly yet somehow grotesquely beautiful.
Insane, probably, but also rather pointless :p But i always wanted to write a garbage collector and coroutines so this was a nice opportunity even though they're babbys first gc/coroutines. But for anybody wanting to implement a GC i advise you to start with the most simple one. It turns out garbage collectors are rather tough to get correct (but having zero debugging tools in jass doesn't help either :)).

Technically i implemented the compiler in haskell, which takes lua and spews out some form of bytecode (wrapped in jass arrays) and the actual interpreter is written in jass. lua does both parts in C.
The jass portion should also be the bigger part of the whole project; and also the more complex one.
 
Top