Skip to content

Commit

Permalink
[net] addTransition
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Nov 15, 2023
1 parent b34b1d6 commit 181a58c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# net

[net] addTransition

[connect] connectTransitionToPlaces(net: Net, transition: Transition, place: Place)

[run] run
Expand Down
2 changes: 1 addition & 1 deletion src/lang/net/addPlace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { nodeKey } from "../node/nodeKey"
import { Place } from "../place"
import { Value } from "../value"

export function addPlace(net: Net, mod: Mod, name: string, t: Value): Node {
export function addPlace(net: Net, mod: Mod, name: string, t: Value): Place {
const modId = mod.url.href
const id = createNodeId(name)

Expand Down
37 changes: 37 additions & 0 deletions src/lang/net/addTransition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Mod } from "../mod"
import { Net } from "../net"
import { createNodeId } from "../node/createNodeId"
import { nodeKey } from "../node/nodeKey"
import { Parameter } from "../parameter"
import { Transition } from "../transition"

export function addTransition(
net: Net,
mod: Mod,
name: string,
inputParameters: Array<Parameter>,
outputParameters: Array<Parameter>,
): Transition {
const modId = mod.url.href
const id = createNodeId(name)

const transition: Transition = {
"@type": "Value",
"@kind": "Transition",
modId,
id,
name,
}

net.transitionEntries.set(nodeKey(transition), {
modId,
id,
name,
inputParameters,
outputParameters,
inputs: [],
outputs: [],
})

return transition
}
1 change: 1 addition & 0 deletions src/lang/net/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./Net"
export * from "./createNet"
export * from "./addPlace"
export * from "./addTransition"

0 comments on commit 181a58c

Please sign in to comment.