dace
dace copied to clipboard
Let `defined_vars.add` emit code and use `defined_vars.get` to verify
Currently defined_vars.add is called "extra" next to the code actually emitting the definition code. Instead, let defined_vars.add (should be renamed/possibly refactored) actually return the string if it can be successfully defined, and rely on defined_vars.get every time we want to reference any variable, so we can assert that this variable actually exists, as well as return the correct C-type as we currently do.
Doing this is likely to make a bunch of new bugs emerge, due to situations where we don't properly keep track of defined variables. We can catch undefined variables early, and even unused variables (for inspiration to what could be pruned) this way.