Categories > Coding > Lua >

Introducing LUNIR, the Lua IR

0x90

dingleberry#2286

vip

Posts: 249

Threads: 26

Joined: Dec, 2020

Reputation: 28

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
  • 1

Posts: 283

Threads: 48

Joined: May, 2022

Reputation: -4

Replied

W thread brother, I'm glad we're gonna get more contributions from the community

  • 0

https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png

Posts: 71

Threads: 6

Joined: Aug, 2022

Reputation: 6

Replied

First answer:

```

if foo() <= 0 then

 print("b")

end

```

 

Shortened:

```

if foo() < 1 then

 print"b"

end

```

Comments

TERIHAX 32 Reputation

Commented

NO NO NO NO NO NO NO NO NO NOT THE FUNCTIONS WITHOUT THE PARENTHESES

  • 0

0x90 28 Reputation

Commented

Check my latest reply for an explanation on the answer to this.

 

  • 0

  • 0

Posts: 531

Threads: 20

Joined: Nov, 2022

Reputation: 44

Replied

really cool, vouch

  • 0

https://cdn.discordapp.com/attachments/1136067487847415848/1146449877660872785/image.png

https://cdn.discordapp.com/attachments/1098921594249814066/1112144294007029932/WRDBanner_Alawapr_1.png

TERIHAX

i say im gay as a joke 🙀

Posts: 2239

Threads: 102

Joined: Jul, 2020

Reputation: 32

Replied

im not exactly sure what this does but it seems interesting

  • 0

Posts: 278

Threads: 23

Joined: Mar, 2022

Reputation: 24

Replied

looks good! 

 

Content length must be 10-5000 chars

  • 0

https://cdn.discordapp.com/attachments/1066053366758780978/1078052772567597127/image.png

Cyros

Revision

Posts: 1061

Threads: 49

Joined: Feb, 2021

Reputation: 20

Replied

veri cool vouch

  • 0

We Hate VOID

0x90

dingleberry#2286

vip

Posts: 249

Threads: 26

Joined: Dec, 2020

Reputation: 28

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 6 Reputation

Commented

You made me rethink my life. Now i think that everything are strings

  • 0

  • 0

blueless

Failed to fetch.

vip

Posts: 435

Threads: 41

Joined: Dec, 2021

Reputation: 17

Replied

ballz /vouch

  • 0

Failed to fetch.

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )