-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[builtin]
runPort
-- only run the top port
- move connected component out and back - run-only-top-port.i
- Loading branch information
Showing
15 changed files
with
169 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Mod } from "../mod" | ||
import { Net } from "../net" | ||
import { connectPlaceholderInputPort } from "../placeholder/connectPlaceholderInputPort" | ||
import { connectPlaceholderOutputPort } from "../placeholder/connectPlaceholderOutputPort" | ||
import { Port } from "../port" | ||
|
||
export function closePort(mod: Mod, component: Net, port: Port): Port { | ||
return port.sign === 1 | ||
? connectPlaceholderInputPort(mod, component, port) | ||
: connectPlaceholderOutputPort(mod, component, port) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Net } from "../net" | ||
import { deleteNodeEntry } from "../net/deleteNodeEntry" | ||
import { disconnectPort } from "../net/disconnectPort" | ||
import { findPortEntry } from "../net/findPortEntry" | ||
import { Port } from "../port" | ||
import { formatValue } from "../value/formatValue" | ||
|
||
export function collectResultPort(component: Net, placeholderPort: Port): Port { | ||
const placeholderPortEntry = findPortEntry(component, placeholderPort) | ||
if (placeholderPortEntry?.connection === undefined) { | ||
throw new Error( | ||
[ | ||
`[run] I expect the placeholderPort to be connected.`, | ||
``, | ||
` placeholderPort: ${formatValue(placeholderPort)}`, | ||
].join("\n"), | ||
) | ||
} | ||
|
||
const connectedPort = placeholderPortEntry.connection.port | ||
|
||
disconnectPort(component, placeholderPort) | ||
deleteNodeEntry(component, placeholderPort.node) | ||
|
||
return connectedPort | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Net } from "../net" | ||
import { deleteNodeEntry } from "../net/deleteNodeEntry" | ||
import { disconnectPort } from "../net/disconnectPort" | ||
import { Port } from "../port" | ||
|
||
export function releaseFreePorts( | ||
component: Net, | ||
placeholderPorts: Array<Port>, | ||
): void { | ||
for (const placeholderPort of placeholderPorts) { | ||
disconnectPort(component, placeholderPort) | ||
deleteNodeEntry(component, placeholderPort.node) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createEnv } from "../env/createEnv" | ||
import { interact } from "../interact" | ||
import { Mod } from "../mod" | ||
import { Net } from "../net" | ||
|
||
export function runNet(mod: Mod, net: Net): void { | ||
const env = createEnv(mod, { net }) | ||
while (net.activeEdges.length > 0) { | ||
const activeEdge = net.activeEdges.pop() | ||
if (activeEdge !== undefined) { | ||
interact(env, activeEdge, {}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Mod } from "../mod" | ||
import { Net } from "../net" | ||
import { createNet } from "../net/createNet" | ||
import { moveConnectedComponent } from "../net/moveConnectedComponent" | ||
import { Port } from "../port" | ||
import { closeFreePorts as closeAllFreePorts } from "./closeAllFreePorts" | ||
import { closePort } from "./closePort" | ||
import { collectResultPort as collectConnectedPort } from "./collectConnectedPort" | ||
import { releaseFreePorts as releasePlaceholderPorts } from "./releasePlaceholderPorts" | ||
import { runNet } from "./runNet" | ||
|
||
export function runPort(mod: Mod, net: Net, port: Port): Port { | ||
const component = createNet() | ||
|
||
moveConnectedComponent(net, component, port.node) | ||
|
||
const placeholderPort = closePort(mod, component, port) | ||
const placeholderForFreePorts = closeAllFreePorts(mod, component) | ||
|
||
runNet(mod, component) | ||
|
||
releasePlaceholderPorts(component, placeholderForFreePorts) | ||
const connectedPort = collectConnectedPort(component, placeholderPort) | ||
|
||
moveConnectedComponent(component, net, connectedPort.node) | ||
|
||
return connectedPort | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ begin | |
one one add | ||
one one add | ||
run inspect | ||
// swap inspect | ||
swap inspect | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters