Skip to content

Commit

Permalink
evaluateBlockStmt -- Connect
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Nov 16, 2023
1 parent d7b6e48 commit 59fa15e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
evaluateBlockStmt -- Connect

evaluateBlockStmt -- LetPlace

- Add a place node to the current net,
Expand Down
29 changes: 21 additions & 8 deletions src/lang/evaluate/evaluateBlockStmt.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {
connectTransitionToInputs,
connectTransitionToOutputs,
} from "../connect"
import { Env } from "../env"
import { appendReport } from "../errors"
import { BlockStmt } from "../exp/BlockStmt"
import { formatBlockStmt } from "../exp/formatBlockStmt"
import { Mod } from "../mod"
import { Value } from "../value"
import { Value, assertValueKind } from "../value"
import { EvaluateOptions } from "./evaluate"
import { evaluateOne } from "./evaluateOne"

Expand All @@ -17,13 +21,22 @@ export function evaluateBlockStmt(
switch (stmt["@kind"]) {
case "Connect": {
const transition = evaluateOne(mod, env, stmt.transition, options)
const inputArgs = stmt.inputArgs.map((arg) =>
evaluateOne(mod, env, arg, options),
)
const outputArgs = stmt.outputArgs.map((arg) =>
evaluateOne(mod, env, arg, options),
)
throw new Error("TODO")
assertValueKind(transition, "Transition")

const inputArgs = stmt.inputArgs.map((arg) => {
const place = evaluateOne(mod, env, arg, options)
assertValueKind(place, "Place")
return place
})

const outputArgs = stmt.outputArgs.map((arg) => {
const place = evaluateOne(mod, env, arg, options)
assertValueKind(place, "Place")
return place
})

connectTransitionToInputs(env.net, transition, inputArgs)
connectTransitionToOutputs(env.net, transition, outputArgs)
}

case "LetPlace": {
Expand Down

0 comments on commit 59fa15e

Please sign in to comment.