@eagleoutice/flowr - v2.15.8
    Preparing search index...

    This class represents the control flow graph of an R program. The control flow may be hierarchical when confronted with function definitions (see CfgVertex and ControlFlowGraph#rootIds|rootIds()).

    Edges are in flow order: an edge from a to b means that b is evaluated after a. Reading them backwards (what leads into a vertex) goes through a reverse index built on the first such read.

    There are two very simple visitors to traverse a CFG:

    • visitCfgInOrder visits it in the order the program runs
    • visitCfgInReverseOrder visits it in the opposite order

    If you want to prohibit modification, please refer to the ReadOnlyControlFlowGraph interface.

    Type Parameters

    Implements

    Index
    _mayBB: boolean = false

    used as an optimization to avoid unnecessary lookups

    bbChildren: Map<NodeId, NodeId> = ...

    the basic block children map contains a mapping of ids to all vertices that are nested in basic blocks, mapping them to the Id of the block they appear in

    edgeInfos: Map<NodeId, Map<NodeId, CfgEdge>> = ...

    basic block agnostic edges, in flow order: edgeInfos[a][b] means that b is evaluated after a

    revEdgeInfos: Map<NodeId, Map<NodeId, CfgEdge>> | undefined

    reverse edges for bidirectional mapping, derived from edgeInfos on the first ingoing lookup

    roots: Set<NodeId> = ...
    vtxInfos: Map<NodeId, Vertex> = ...

    Nesting-Independent vertex information, mapping the id to the vertex

    • Add a new vertex to the control flow graph.

      Parameters

      • vertex: Vertex
      • rootVertex: boolean = true

      Returns this

      ControlFlowGraph#addEdge|addEdge() - to add an edge

    • The constructs whose outcome this vertex decides, e.g. the if a condition belongs to.

      Since a construct is reached only once its parts have run, standing on the condition is the moment to ask what that condition is for.

      Parameters

      Returns readonly NodeId[]

      entryOf() - for the way back, from the construct to its condition

      if(u) a else b # decides(u) names the if, so `u` is known to be its condition
      
    • The vertex control flow enters the construct rooted at id at, i.e. the first thing it evaluates. For if(u) a else b that is the condition, for 2 * 3 the left operand, and for a leaf the leaf itself.

      undefined if the construct is not part of the control flow at all.

      Parameters

      • id: NodeId

        the construct to look at

      • idMap: AstIdMap | undefined = ...

        the AST the graph belongs to; a graph that knows its own (a view on a dataflow graph) may omit it

      Returns NodeId | undefined

      exitOf() - for where it is over

    • The vertex a construct is over at, i.e. where its branches join and control flow continues past it.

      The control flow is modeled in post-order: everything a construct is made of is evaluated before the construct itself, so an if is over on the if vertex, a loop on its loop vertex, and 2 * 3 on the * vertex. There is no separate marker to look for — reaching the vertex is the construct ending.

      Parameters

      Returns NodeId

      entryOf() - for where it begins instead

    • Check if a vertex with the given id exists in the graph.

      Parameters

      • id: NodeId

        the id of the vertex to check

      • includeBlocks: boolean = true

        if true, the elements of basic block elements are included in the check, otherwise this will only check the basic blocks themselves

                         This is the pendant of <a href="src_dataflow_graph_graph.DataflowGraph.html#hasvertex" class="tsd-kind-method">hasVertex()</a> on a <a href="src_dataflow_graph_graph.DataflowGraph.html" class="tsd-kind-class">DataflowGraph</a>.
        

      Returns boolean

    • Fill the state of this graph from the dataflow graph it views. Reading a view does not need this — the reads below are answered from the dataflow graph — but modifying one does, and so does asking for every vertex or edge at once.

      Returns void

    • This Operation is in-place and modifies the current graph. Merge another control flow graph into this one.

      Parameters

      • other: ControlFlowGraph<Vertex>

        the other control flow graph to merge into this one

      • forceNested: boolean = false

        should the other graph be assumed to be fully nested (e.g., within a function definition).

                       This is the pendant of <a href="src_dataflow_graph_graph.DataflowGraph.html#mergewith" class="tsd-kind-method">mergeWith()</a> on a <a href="src_dataflow_graph_graph.DataflowGraph.html" class="tsd-kind-class">DataflowGraph</a>.
        

      Returns this

    • Removes a all direct edges between from and to from the control flow graph.

      Parameters

      Returns this

      • ControlFlowGraph#addEdge|addEdge() - to add an edge
      • ControlFlowGraph#removeVertex|removeVertex() - to remove a vertex and all its edges
    • This removes the vertex and all edges to and from it.

      Parameters

      • id: NodeId

        the id of the vertex to remove

      Returns this

      • ControlFlowGraph#addVertex|addVertex() - to add a vertex
      • ControlFlowGraph#removeEdge|removeEdge() - to remove a specific edge
    • Serializing a graph hands out its vertices and edges, never the dataflow graph a view reads them from, so a view and a graph of its own serialize alike.

      Returns unknown