Header menu logo issie

GraphMerger Module

Functions and values

Function or value Description

mergeDependencies currDiagramName graph (arg3, arg4) loadedDependencies

Full Usage: mergeDependencies currDiagramName graph (arg3, arg4) loadedDependencies

Parameters:
Returns: Result<SimulationGraph, SimulationError>
 Try to resolve all the dependencies in a graph, and replace the reducer
 of the custom components with a simulationgraph.
 
 Merges dependencies into the simulation graph and resolves all parameters.
 
 The name of the current sheet being processed
 The initial simulation graph to merge dependencies into
 The current canvas state
 List of all loaded component sheets
 
 Success: A fully merged and parameterized simulation graph
 Error: Details of any dependency or parameter resolution failures
 
 
 Parameter Resolution Process (Two-Stage):
 
 Stage 1 - Merging (via merger function):
 - Custom components are replaced with their internal graphs
 - Parameter resolution is DEFERRED to avoid forward reference issues
 - Each custom component's graph is stored in CustomSimulationGraph field
 
 Stage 2 - Parameter Resolution (happens after all merging):
 2a. Instance-specific parameters (resolveCustomComponentParameters):
     - Each custom component instance may have specific parameter bindings
     - These override any default values from the component definition
     - Resolved recursively for nested custom components
 
 2b. Sheet-level parameters (resolveParametersInSimulationGraph):
     - Uses default parameter bindings from the sheet definition
     - Applies to all parameterized slots in the current sheet
     - Evaluates expressions and updates component configurations
 
 This two-stage approach ensures:
 - No forward reference problems (all graphs merged before parameters resolved)
 - Proper parameter precedence (instance bindings override defaults)
 - Support for nested parameterized custom components
 
currDiagramName : string
graph : SimulationGraph
arg2 : Component list
arg3 : Connection list
loadedDependencies : LoadedComponent list
Returns: Result<SimulationGraph, SimulationError>

resolveParametersInSimulationGraph bindings currDiagramName (arg3, arg4) loadedDependencies graph

Full Usage: resolveParametersInSimulationGraph bindings currDiagramName (arg3, arg4) loadedDependencies graph

Parameters:
Returns: Result<SimulationGraph, SimulationError>
 Recursively update the SimulationGraph replacing integers with the correct parameter values.
 Parameter names, and slots using parameters, can be picked up from loadedDependencies
 Parameters can be resolved by looking at the parameter bindings of the custom components.
 bindings: parameter bindings for the current sheet.
 
 Recursively resolves parameter expressions in a simulation graph.
 
 Map of parameter names to their bound expressions
 The name of the current sheet
 The current CanvasState
 List of loaded component sheets
 The fully merged SimulationGraph to update
 
 Success: Updated graph with all parameters resolved to concrete values
 Error: Details of any parameter evaluation failures
 
 
 Parameter Resolution Details:
 
 1. Expression Evaluation (evalExpr):
    - PInt: Direct integer values
    - PParameter: Lookup in bindings, then recursive evaluation
    - Arithmetic: Evaluates both operands, applies operation
    - Returns None if any parameter cannot be resolved
 
 2. Slot Application (applySlotValue):
    - Buswidth: Updates width for viewers, buses, gates, registers, etc.
    - NGateInputs: Updates number of inputs for variable-input gates
    - IO: Updates Input/Output component configurations
 
 3. Component Processing:
    - Finds all parameter slots for current component
    - Evaluates each slot's expression
    - Updates component type with resolved values
    - Preserves other component properties (Id, Label, etc.)
 
 4. Recursive Resolution:
    - Processes custom components' internal graphs
    - Uses component-specific parameter bindings
    - Ensures nested parameterized components work correctly
 
 Note: SimulationGraph components include the widths of all input and output busses,
 which are crucial for simulation and must be concrete values (not expressions).
 
bindings : Map<ParamName, ParamExpression>
currDiagramName : string
arg2 : Component list
arg3 : Connection list
loadedDependencies : LoadedComponent list
graph : SimulationGraph
Returns: Result<SimulationGraph, SimulationError>

Type something to start searching.