Skip to content

Construct Dictionary Map

Rob Bocchino edited this page Jan 29, 2025 · 10 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. Create a new dictionary D.

  5. 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).

    3. Add S' to the used symbol set of D.

  6. For each dictionary element kind k, 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 the mapping for kind k in D.

  7. For each telemetry packet group specifier sg in d

    1. Create a new telemetry packet group g.

    2. For each telemetry packet specifier sp of sg

      1. Create a new telemetry packet p.

      2. For each telemetry channel identifier tci in sp

        1. Check that tci refers to a telemetry channel c in D.

        2. Add the global numerical identifier for c to the telemetry channels identifiers of p.

      3. Resolve the packet identifier i of p.

      4. Map i to p in g. Check for duplicate identifiers.

    3. Check for duplicate packet names in g.

    4. For each telemetry channel identifier tci in the omitted list of sg

      1. Check that tci refers to a telemetry channel c in D.

      2. Add the global numerical identifier for c to the omitted channel identifiers of g.

    5. Check that the union of the channels named in the packets (as a set) and the set of omitted channels is equal to the set of channels in the dictionary.

    6. Add g to the telemetry packet group map of D. Check for duplicate names.

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

  9. Return a as the result.

Clone this wiki locally