Skip to content

Commit 181a58c

Browse files
committed
[net] addTransition
1 parent b34b1d6 commit 181a58c

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

TODO.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# net
22

3-
[net] addTransition
4-
53
[connect] connectTransitionToPlaces(net: Net, transition: Transition, place: Place)
64

75
[run] run

src/lang/net/addPlace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { nodeKey } from "../node/nodeKey"
66
import { Place } from "../place"
77
import { Value } from "../value"
88

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

src/lang/net/addTransition.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Mod } from "../mod"
2+
import { Net } from "../net"
3+
import { createNodeId } from "../node/createNodeId"
4+
import { nodeKey } from "../node/nodeKey"
5+
import { Parameter } from "../parameter"
6+
import { Transition } from "../transition"
7+
8+
export function addTransition(
9+
net: Net,
10+
mod: Mod,
11+
name: string,
12+
inputParameters: Array<Parameter>,
13+
outputParameters: Array<Parameter>,
14+
): Transition {
15+
const modId = mod.url.href
16+
const id = createNodeId(name)
17+
18+
const transition: Transition = {
19+
"@type": "Value",
20+
"@kind": "Transition",
21+
modId,
22+
id,
23+
name,
24+
}
25+
26+
net.transitionEntries.set(nodeKey(transition), {
27+
modId,
28+
id,
29+
name,
30+
inputParameters,
31+
outputParameters,
32+
inputs: [],
33+
outputs: [],
34+
})
35+
36+
return transition
37+
}

src/lang/net/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./Net"
22
export * from "./createNet"
33
export * from "./addPlace"
4+
export * from "./addTransition"

0 commit comments

Comments
 (0)