-
Notifications
You must be signed in to change notification settings - Fork 31
Enter Symbols
This algorithm traverses a source model and enters symbols into their scopes.
-
A list tul of translation units.
-
An analysis data structure a representing the results of analysis so far.
-
Translation unit lists: Visit each translation unit tu in tul in order.
-
Translation units: Visit a translation unit tu by visiting its members tum.
-
Translation unit members: Visit a translation unit member tum as follows:
-
Module definitions: If tum is a module definition d with name n, then
-
Look up the symbol sym with unqualified name n in the innermost nested scope of a in the value name group.
-
If sym exists and is a module symbol, then let s be the scope corresponding to sym in the symbol-scope map of a.
-
Otherwise if sym exists then report an error.
-
Otherwise
-
Let s be a fresh scope.
-
Construct a module symbol sym.
-
Add the mapping from n to sym in the innermost nested scope of a in every name group.
-
Add sym to the parent symbol map of a.
-
-
Add n to the scope name list of a.
-
Push s onto the nested scope of a.
-
Visit each translation unit member of d, yielding a new analysis data structure a.
-
Let s' be the innermost nested scope of a.
-
Add the mapping from sym to s' in the symbol-scope map of a.
-
-
Pop s' off the nested scope of a.
-
Remove n from the scope name list of a.
-
-
Constant definitions: If tum is a constant definition d with name n, then
-
Construct the unique symbol s of the correct kind for d.
-
Add the mapping from n to s in the innermost nested scope of a in the value name group.
-
Add s to the parent symbol map of a.
-
-
Type definitions: If tum is an abstract type, array, or struct definition d with name n, then
-
Construct the unique symbol s of the correct kind for d.
-
Add the mapping from n to s in the innermost nested scope of a in the type name group.
-
Add s to the parent symbol map of a.
-
-
Enum definitions: If tum is an enum definition d with name n, then
-
Construct the unique enum definition symbol sym for d.
-
Add the mapping from n to sym in the innermost nested scope of a in the type and the value name groups.
-
Add sym to the parent symbol map of a.
-
Create a fresh scope s.
-
Push s onto the nested scope of a.
-
Add n to the scope name list of a.
-
Visit each enumerated constant definition of d, yielding a new analysis data structure a.
-
Remove n from the scope name list of a.
-
Let s' be the innermost nested scope of a.
-
Add the mapping from sym to s' in the symbol-scope map of a.
-
Pop s' off the nested scope of a.
-
-
Port definitions: If tum is a port definition d with name n, then
-
Construct the unique symbol s of the correct kind for d.
-
Add the mapping from n to s in the innermost nested scope of a in the port name group.
-
Add s to the parent symbol map of a.
-
-
Component definitions: If tum is a component definition d with name n, then
-
Construct the unique component definition symbol sym for d.
-
Add the mapping from n to sym in the innermost nested scope of a in the component, type, and value name groups.
-
Add sym to the parent symbol map of a.
-
Create a fresh scope s.
-
Push s onto the nested scope of a.
-
Add n to the scope name list of a.
-
Visit each component member of d, yielding a new analysis data structure a.
-
Remove n from the scope name list of a.
-
Let s' be the innermost nested scope of a.
-
Add the mapping from sym to s' in the symbol-scope map of a.
-
Pop s' off the nested scope of a.
-
-
Component instance definitions: If tum is a component instance definition d with name n, then
-
Construct the unique symbol s of the correct kind for d.
-
Add the mapping from n to s in the innermost nested scope of a in the component instance name group.
-
Add s to the parent symbol map of a.
-
-
Topology definitions: If tum is a topology definition d with name n, then
-
Construct the unique symbol s of the correct kind for d.
-
Add the mapping from n to s in the innermost nested scope of a in the topology name group.
-
Add s to the parent symbol map of a.
-
-
-
Enumerated constant definitions: Visit an enumerated constant definition d with name n as follows:
-
Construct the unique enumerated constant definition symbol s for d.
-
Add the mapping from n to s in the innermost nested scope of a in the value name group.
-
Add s to the parent symbol map of a.
-
-
-
Component members: Visit a component member cm as follows:
-
If cm corresponds to a translation unit member tum, then visit cm in the same way as tum.
-
Otherwise do nothing.
-