Skip to content

implement set_variable and unset_variable #157

@dcbaker

Description

@dcbaker

set_variable

We have the problem that you can use set_variable to set a variable by a variable. consider:

foreach x : ['a', 'b', 'c', 'd']
  set_variable(x, 'foo')
endforeach

It's tempting to try to do early lowering on this, where we would early on rewrite set_variable('x', 'foo') to x = 'foo', but I highly doubt that's useful. that's a case where someone can just write x = 'foo', and not get into the weeds of set_variable. Even in the case above, it's rather simple to handle this via loop unrolling. The real concern I have, is that we may not always be aware of what x is, and thus have invalid global value numbering, and perhaps even have invalid optimization of the program. This is more complicated when the value is also a variable, such as set_variable(x, y)

unset_variable

This will require better tracking of variables declared in blocks, since the biggest side effect of this is that we need to make sure that versions of variables that are undefined don't propagate across block boundaries. That probably means that we should move variable version tracking to either the cfg node or the block

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions