Skip to content

Commit

Permalink
Node should not have definition -- which was used to lookupRule
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jul 29, 2023
1 parent 1c3d96f commit ffc5d92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lang/definitions/NodeDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/lang/graph/Node.ts
Original file line number Diff line number Diff line change
@@ -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<Type>
Expand Down
9 changes: 5 additions & 4 deletions src/lang/graph/createNode.ts
Original file line number Diff line number Diff line change
@@ -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<Type>,
outputTypes: Array<Type>,
): Node {
const node: Node = {
id: counter++,
definition,
mod: definition.mod,
name: definition.name,
mod,
name,
types: [...inputTypes, ...outputTypes],
input: [],
output: [],
Expand Down

0 comments on commit ffc5d92

Please sign in to comment.