From 9d567dc8d922af670668c249b26384a33145068e Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Thu, 16 Nov 2023 10:46:30 +0800 Subject: [PATCH] evaluateDefinition -- TransitionDefinition - return add transition to current net, and return the transition value --- TODO.md | 14 ++++++-------- src/lang/evaluate/evaluateDefinition.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/TODO.md b/TODO.md index a510b5a..3db1a30 100644 --- a/TODO.md +++ b/TODO.md @@ -1,14 +1,15 @@ -evaluateBlockStmt -- Connect -evaluateBlockStmt -- LetPlace - execute -- DefineTransition -- call evaluate and define execute -- Begin -- `createEnv` and run - [maybe] Mod -- has no env -- top level `evaluate` -evaluateDefinition -- TransitionDefinition -- return transition value + +[connect] connectTransitionToInputs(net: Net, transition: Transition, places: Array) +[connect] connectTransitionToOutputs(net: Net, transition: Transition, places: Array) + +evaluateBlockStmt -- Connect +evaluateBlockStmt -- LetPlace # builtins @@ -17,9 +18,6 @@ evaluateDefinition -- TransitionDefinition # net -[connect] connectTransitionToInputs(net: Net, transition: Transition, places: Array) -[connect] connectTransitionToOutputs(net: Net, transition: Transition, places: Array) - [run] run - everytime a marking changes, diff --git a/src/lang/evaluate/evaluateDefinition.ts b/src/lang/evaluate/evaluateDefinition.ts index eb01e7c..637dff0 100644 --- a/src/lang/evaluate/evaluateDefinition.ts +++ b/src/lang/evaluate/evaluateDefinition.ts @@ -1,5 +1,6 @@ import { Definition } from "../definition" import { Env } from "../env" +import { addTransition } from "../net" import { Value } from "../value" import { EvaluateOptions } from "./evaluate" @@ -10,7 +11,13 @@ export function evaluateDefinition( ): Value { switch (definition["@kind"]) { case "TransitionDefinition": { - throw new Error("TODO") + return addTransition( + env.net, + env.mod, + definition.name, + definition.inputParameters, + definition.outputParameters, + ) } } }