From ffc5d9244609e8ef7073e29cffb65f7e62467aee Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sat, 29 Jul 2023 13:00:59 +0800 Subject: [PATCH] `Node` should not have `definition` -- which was used to `lookupRule` --- TODO.md | 2 -- src/lang/definitions/NodeDefinition.ts | 2 +- src/lang/graph/Node.ts | 2 -- src/lang/graph/createNode.ts | 9 +++++---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/TODO.md b/TODO.md index f0773676..adc17851 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ `NodeDefinition.fullName` -`Node` should not have `definition` -- which is used to `lookupRule` - quit using `Action` `Action` should be type instead of class diff --git a/src/lang/definitions/NodeDefinition.ts b/src/lang/definitions/NodeDefinition.ts index 192e64cd..e2199026 100644 --- a/src/lang/definitions/NodeDefinition.ts +++ b/src/lang/definitions/NodeDefinition.ts @@ -20,7 +20,7 @@ export class NodeDefinition implements Definition { } build(): Node { - return createNode(this.kind, this, this.input, this.output) + return createNode(this.kind, this.mod, this.name, this.input, this.output) } meaning(net: Net): Node { diff --git a/src/lang/graph/Node.ts b/src/lang/graph/Node.ts index 588e643c..3a1f6eb3 100644 --- a/src/lang/graph/Node.ts +++ b/src/lang/graph/Node.ts @@ -1,11 +1,9 @@ -import * as Definitions from "../definitions" import { Port } from "../graph" import { Mod } from "../mod" import { Type } from "../type" export type Node = { id: number - definition: Definitions.NodeDefinition mod: Mod name: string types: Array diff --git a/src/lang/graph/createNode.ts b/src/lang/graph/createNode.ts index c6c56db0..8b9536f8 100644 --- a/src/lang/graph/createNode.ts +++ b/src/lang/graph/createNode.ts @@ -1,20 +1,21 @@ import * as Definitions from "../definitions" import { Node, createPort } from "../graph" +import { Mod } from "../mod" import { Type } from "../type" let counter = 0 export function createNode( kind: Definitions.NodeKind, - definition: Definitions.NodeDefinition, + mod: Mod, + name: string, inputTypes: Array, outputTypes: Array, ): Node { const node: Node = { id: counter++, - definition, - mod: definition.mod, - name: definition.name, + mod, + name, types: [...inputTypes, ...outputTypes], input: [], output: [],