You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AST to ASR has to do something like the following.
Maintain a hashtable/mapping of labels (strings) -> (unique IDs, bool declared); initialize it as empty when entering a new function
Every time you encounger a "goto label", lookup the label in the mapping, two cases can happen:
if it is already there, use the ID from the mapping and create GoTo(ID)
if it is not there, add it to the mapping, and note that it has not been declared yet, and assign a unique ID to it; then use that unique ID in GoTo(ID)
Every time you encounter "label label", lookup the label in the mapping, two cases can happen:
if it is there, change declared to yes, use the ID in GoToTarget(ID)
if it is not there, create a new label in the mapping, assign unique ID and declared as yes, then use that ID in GoToTarget(ID)
at the end of the function, go over this mapping and check that each label has been declared. If there is one or more labels that has not been declared, raise a compiler error. This corresponds to the case of using a "goto label" without having the corresponding "label label" statement.
The text was updated successfully, but these errors were encountered:
Maintain a hashtable/mapping of labels (strings) -> (unique IDs, bool declared); initialize it as empty when entering a new function
Will we allow something like,
@with_gotodeff():
# body with goto and label@with_gotodefg():
# body with goto and label
If we are going to allow the above case, then will we generate hash maps for f and g separately? Will goto in f be allowed to jump to label defined inside g?
Uh oh!
There was an error while loading. Please reload this page.
The AST to ASR has to do something like the following.
The text was updated successfully, but these errors were encountered: