File tree Expand file tree Collapse file tree 6 files changed +49
-12
lines changed Expand file tree Collapse file tree 6 files changed +49
-12
lines changed Original file line number Diff line number Diff line change 1
- execute -- DefineTransition -- call evaluate and define
2
1
execute -- Begin -- ` createEnv ` and run
3
2
4
- - [ maybe] Mod -- has no env -- top level ` evaluate `
5
-
6
-
7
-
8
3
[ connect] connectTransitionToInputs(net: Net, transition: Transition, places: Array<Place >)
9
4
[ connect] connectTransitionToOutputs(net: Net, transition: Transition, places: Array<Place >)
10
5
Original file line number Diff line number Diff line change
1
+ import { Env } from "../env"
2
+ import { Mod } from "../mod"
3
+ import { Net } from "../net"
4
+ import { createNet } from "../net/createNet"
5
+
6
+ export function createEnv (
7
+ mod : Mod ,
8
+ options ?: {
9
+ net ?: Net
10
+ } ,
11
+ ) : Env {
12
+ return {
13
+ mod,
14
+ net : options ?. net || createNet ( ) ,
15
+ locals : new Map ( ) ,
16
+ }
17
+ }
Original file line number Diff line number Diff line change 1
1
export * from "./Env"
2
+ export * from "./createEnv"
Original file line number Diff line number Diff line change 1
1
import { appendReport } from "../errors"
2
- // import { evaluate, evaluateOne, evaluateParameters } from "../evaluate"
3
- import { Mod } from "../mod"
4
- // import { Mod, define } from "../mod"
2
+ import { EvaluateOptions , evaluateParameters } from "../evaluate"
3
+ import { Mod , define } from "../mod"
5
4
import { Stmt } from "../stmt"
6
5
7
6
export async function execute ( mod : Mod , stmt : Stmt ) : Promise < null > {
8
7
try {
8
+ const options : EvaluateOptions = { }
9
+
9
10
switch ( stmt [ "@kind" ] ) {
10
11
case "DefineTransition" : {
11
- console . log ( "[execute / DefineTransition] TODO" )
12
+ const inputParameters = evaluateParameters (
13
+ mod ,
14
+ mod . env ,
15
+ stmt . inputParameters ,
16
+ options ,
17
+ )
18
+ const outputParameters = evaluateParameters (
19
+ mod ,
20
+ mod . env ,
21
+ stmt . outputParameters ,
22
+ options ,
23
+ )
24
+ define ( mod , stmt . name , {
25
+ "@type" : "Definition" ,
26
+ "@kind" : "TransitionDefinition" ,
27
+ mod,
28
+ name : stmt . name ,
29
+ inputParameters,
30
+ outputParameters,
31
+ span : stmt . span ,
32
+ body : stmt . body ,
33
+ } )
12
34
return null
13
35
}
14
36
Original file line number Diff line number Diff line change 1
1
import { Stmt } from "../stmt"
2
+ import { Env } from "../env"
2
3
import { Definition } from "../definition"
3
4
4
5
export type Mod = {
6
+ env : Env
5
7
url : URL
6
8
text : string
7
9
stmts : Array < Stmt >
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { Loader } from "../../loader"
2
2
import { Stmt } from "../stmt"
3
3
// import { defineBuiltins } from "../builtins/defineBuiltins"
4
4
// import { createChecking } from "../checking/createChecking"
5
- // import { createEnv } from "../env/createEnv"
5
+ import { createEnv } from "../env/createEnv"
6
6
import { Mod } from "./Mod"
7
7
8
8
export function createMod ( options : {
@@ -19,9 +19,9 @@ export function createMod(options: {
19
19
definitions : new Map ( ) ,
20
20
// builtins: new Map(),
21
21
// requiredMods: new Map(),
22
- } as Mod
22
+ } as unknown as Mod
23
23
24
- // mod.env = createEnv(mod)
24
+ mod . env = createEnv ( mod )
25
25
// mod.checking = createChecking()
26
26
27
27
// defineBuiltins(mod)
You can’t perform that action at this time.
0 commit comments