Categories > Coding > Lua >
Introducing LUNIR, the Lua IR
Posted
Hello everyone, you might or might not know me from my past presence on this forum.
Today I'm making a thread about a large scale project that I'm working on, and I'm looking for contributors, this can benefit any and all people using Lua.
LUNIR is a project that I started with a few friends, its an acronym for Lua Universal Intermediate Representation, and a play on words for Lunar.
What is LUNIR?
LUNIR is an open source intermediate representation for Lua source code and bytecode.
It can represent Lua 5.x (5.0 to 5.4) & Luau bytecode or source code
It's an intermediate for all relevant Lua versions that employs optimization and analysis at both the high and low level.
What can it do?
LUNIR has a wide range of application, it's generalization allows it to be very complex and useful in many scenarios.
Typically, when thinking of intermediate representations, you think of compilers, and while that applies to LUNIR, its scope is far larger.
You can use LUNIR to write a
- compiler
- decompiler
- optimizer
- formatter
- linter
- obfuscator
- deobfuscator
- transpiler
(the transpiler part applies at the bytecode & source levels)
How do I use it?
Unfortunately, LUNIR is not stable.
The issue is that this project is very large and complex, myself and the 2-3 other contributors are simply not enough.
That is why I'm coming to this forum to recruit anyone that thinks this project would be useful to them.
If you're still interested, keep reading, here's how you can contribute to the development of something great.
Contributing
First, the project is written exclusively in Rust, if you don't know Rust that's okay, don't let that scare you away, your input is still important.
Not sure if you have what it takes? That's okay.
For anyone willing to contribute to the project, I have a simple test that you can take a shot at.
There's no wrong answers here, post your thoughts in a reply to this thread if you want to try it, and in ~2 days I'll update the thread with the answer.
If you don't feel like waiting for that, post your answer then send me a DM and I'll tell you what the answer is.
------------------------------------------------------------------------------------------------------------
If you were an optimizing compiler, would you optimize anything in this code? If so, what would you optimize?
local a = foo()
if a <= 0 then
if a >= 1 then
print("a")
end
print("b")
end
Cancel
Post
Replied
W thread brother, I'm glad we're gonna get more contributions from the community
Cancel
Post
https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png
Replied
First answer:
```
if foo() <= 0 then
print("b")
end
```
Shortened:
```
if foo() < 1 then
print"b"
end
```
Cancel
Post
Replied
im not exactly sure what this does but it seems interesting
Cancel
Post
Replied
looks good!
Content length must be 10-5000 chars
Cancel
Post
https://cdn.discordapp.com/attachments/1066053366758780978/1078052772567597127/image.png
Replied
Okay everyone, I've seen the answers so far and none of them are necessarily wrong, but they're all not entirely accurate.
The fact is, most people think that if a <= 0 is true, then a >= 1 can not be true. There is a case, however, where both of these expressions are true and both if statements run through.
The issue is that everyone automatically assume that `a` is a number because it's being compared with a number, that's not true, honestly we have no clue what `foo` returns. `foo` could return a type that has a metatable with overloaded __ge and __le, then both of them can be true.
The answer is that we can't optimize anything here, not without knowing what foo returns and being sure we know what type `a` is.
Comments
DracoFAAD 4 Reputation
Commented
You made me rethink my life. Now i think that everything are strings
Cancel
Post
Replied
ballz /vouch
Cancel
Post
Failed to fetch.
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Comments
TERIHAX 30 Reputation
Commented
NO NO NO NO NO NO NO NO NO NOT THE FUNCTIONS WITHOUT THE PARENTHESES
0
0x90 27 Reputation
Commented
Check my latest reply for an explanation on the answer to this.
0