Skip to content

Check Component Definitions

Robert L. Bocchino Jr. edited this page Apr 18, 2024 · 3 revisions

This algorithm traverses the source model and checks component definitions.

Input

  1. A list tul of translation units.

  2. An analysis data structure a representing the results of analysis so far.

Output

An updated analysis a' with the component map filled in if the check passes; otherwise an error.

Procedure

Visit each translation unit in tul with input a, yielding either a' or an error.

AST Visitor Methods

Each method accepts an analysis data structure a as input and yields either an updated analysis data structure a' or an error as output.

Translation Units

For each translation unit tu, visit each definition appearing in tu.

Component Definitions

For each component definition d

  1. Create a new component c.

  2. Visit each member m of d with input a.

    1. If m is a port instance specifier, then

      1. Check that the specifier follows the rules. For example, async specifiers may not use ports with ref parameters; specifiers that are not async may not specify queue behavior.

      2. Create a new port instance pi

      3. Add pi to the port instance map of c. If the name is already in the map, then throw an error.

      4. If m is a special port instance specifier, then

        1. Add pi to the special port instance map of c.

        2. If the kind is already in the map, then throw an error.

    2. If m is an internal port specifier, then create a new internal port instance pi and pi to the port instance map of c. If the name is already in the map, then throw an error.

    3. If m is a command specifier, then create a new command cmd and add cmd to the commands of c. Check for duplicate opcodes.

    4. If m is a parameter specifier, then

      1. Create a new parameter p and add p to the parameters of c. Check for duplicate identifiers.

      2. Create the implied get and set commands for p. Add the commands to the commands of c. Check for duplicate opcodes.

    5. If m is a telemetry channel specifier, then create a new telemetry channel ch and add ch to the telemetry channels of c. Check for duplicate identifiers.

    6. If m is an event specifier, then create a new event e and add e to the events of c. Check for duplicate identifiers.

  3. Check that there are no duplicate names in any of the dictionaries.

  4. If the component is passive, check that there is no async input port specifier, internal port specifier, or async command specifier.

  5. If the component is active or queued, check that there is at least one async input port specifier, internal port specifier, or async command specifier.

  6. Check that the component has the ports required by the dictionary specifiers. For example, if there are any commands, then there must be a command recv port.

  7. Construct the unique component symbol s for d.

  8. Map s to c in the component map of a.

  9. Return a as the result.