Skip to main content

TreeToCircuit

treeToCircuitCore

treeToCircuitCore(node, inputs, circuit) => IOObject[]

Converts a given InputTree to an array of connected components (and the wires used to connect them). Note that the circuit parameter is edited in place by this function. Avoid calling this function directly, use TreeToCircuit instead.

Parameters

  •  node: InputTreeIdent | InputTreeUnOpNode | InputTreeBinOpNode – The root node of the InputTree to convert.

  •  inputs: Map<string, DigitalComponent> – The input components used by this expression.

  •  circuit: IOObject[] – Used to store the circuit while recursing, on the intial call it should contain the DigitalComponents found in inputs.

Returns

  •   IOObject[] – The current part of the tree that has been converted to a circuit, the most recently used component should always be last in the array.

TreeToCircuit

TreeToCircuit(tree, inputs, output) => IOObject[]

Converts a given InputTree to an array of connected components (and the wires used to connect them).

Parameters

  •  tree: InputTreeIdent | InputTreeUnOpNode | InputTreeBinOpNode – The root node of the InputTree to convert or an empty array if tree is null.

  •  inputs: Map<string, DigitalComponent> – The input components used by this expression.

  •  output: DigitalComponent – The component that the circuit outputs to.

Returns

  •   IOObject[] – The components and wires converted from the tree.