Skip to content

Construct Dictionary Map

Rob Bocchino edited this page Jan 29, 2025 · 11 revisions

This algorithm traverses the source model and constructs the dictionary map.

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 dictionary map filled in if the dictionaries in tul are valid; 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.

Topology Definitions

For each topology definition d:

  1. Let the dictionary element kinds be commands, events, telemetry channels, parameters, records, and containers.

  2. Construct the unique topology symbol s for d.

  3. Look up the topology t corresponding to s in the topology map of a.

  4. Compute the used symbol set S as follows:

    1. For each component instance ci of t:

      1. Compute the set S' of symbols directly used in each dictionary element kind of ci.

      2. Let S'' be the set of symbols transitively used in the symbols of S' (i.e., the symbols of S', the symbols used in those symbols, and so forth).

    2. Let S be the union of the sets S'' computed in the previous step.

  5. For each dictionary element kind k, compute the mapping mk as follows:

    1. Let mk be an empty mapping.

    2. For each component instance ci of t:

      1. Look up the component C of ci.

      2. For each mapping (i, s) from a component-local identifier i to a specifier s of kind k in C, do the following:

        1. Let b be the base ID of ci.

        2. Let i' = b + i.

        3. Construct a dictionary entry e = (ci, s).

        4. Add (i', e) to mk.

  6. Compute the mapping m from telemetry packet group names to telemetry packet groups as follows:

    1. Let m be an empty mapping.

    2. Visit the telemetry packet groups of d. For each telemetry packet group g with name n:

      1. Check that each telemetry packet p of g is semantically valid.

      2. Use the telemetry channel map computed in step 3 to check that g is semantically valid.

      3. Add the mapping (n, g) to m.

  7. Use the set S, the maps mk, and the map m to construct a dictionary D.

  8. Map s to D in the dictionary map of a.

  9. Return a as the result.

Clone this wiki locally