ShaderLang icon indicating copy to clipboard operation
ShaderLang copied to clipboard

[Compilation] Improve sanization and optimization of options

Open SirLynix opened this issue 3 years ago • 0 comments

Currently, options are treated like unknown values, or even unknown types.

However, it would be pretty simple to handle cases where the value is known and validation / optimization can be done.

option enabled: bool;

fn main()
{
    const if (enabled)
    {
        // enabled is known to be true here
    }
}
option value: i32;

fn main() -> i32
{
    const if (value == 42)
        return value + 5; //< optimized by return 47
    else
        return value; //< kept as is
}

Theses examples may seem a bit silly, but will become more interesting once we have function inlining

SirLynix avatar Jun 21 '22 10:06 SirLynix