captbaritone / eel-wasm

Compile Nullsoft's EEL code to Web Assembly
https://eel.capt.dev
48 stars 4 forks source link

Constant Propagation is not safe on code with loops/whiles #15

Closed captbaritone closed 2 years ago

captbaritone commented 4 years ago

When in a loop of any kind, we need to disallow propagating constants to any variable that gets updated anywhere in the loop. Currently we only prevent propagation to variable access for variables that get touched before the access.

captbaritone commented 4 years ago

Here's an example of code that fails:

n = 0; loop(10, g = n; n += 1);
Screen Shot 2020-02-20 at 7 30 39 AM

https://eel.capt.dev/?optimize=MQ%3D%3D&globals=eyJ4IjowfQ%3D%3D&eel=biA9IDA7IGxvb3AoMTAsIGcgPSBuOyBuICs9IDEpOw%3D%3D

captbaritone commented 2 years ago

I think optimizations are not going to be necessary.