darklua icon indicating copy to clipboard operation
darklua copied to clipboard

Improve Lua binary evaluation to handle partially known values

Open jeparlefrancais opened this issue 2 years ago • 0 comments

This idea comes from a test case that I meant to add for #64, which uncovered new possibilities of optimizations:

return if call() and false then value else other

We can know statically that this will always resolve to other, but we want to preserve the potential side effect of call().

To understand this, the evaluator could have a new LuaValue variant that represents a partially known value. In the example above, we know for example that the evaluation of call() and false will always be nil or false.

Having this kind of variant gives the ability to the evaluator to implement is_truthy() and make it return an actual value in such cases.

jeparlefrancais avatar Dec 02 '22 01:12 jeparlefrancais