Skip to content

Commit

Permalink
rename Definition.call to Definition.compose
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 1, 2023
1 parent 61681ab commit 9eeb14d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lang/definition/Definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { Net } from "../net"
export interface Definition {
mod: Mod
name: string
call(net: Net): void
compose(net: Net): void
}
2 changes: 1 addition & 1 deletion src/lang/definitions/NetDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class NetDefinition implements Definition {
public words: Array<Word>,
) {}

call(net: Net): void {
compose(net: Net): void {
composeWords(this.mod, net, this.words)
}
}
4 changes: 2 additions & 2 deletions src/lang/definitions/NodeDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NodeDefinition implements Definition {
public output: Array<PortExp>,
) {}

call(net: Net): Node {
compose(net: Net): Node {
const node = createNode(this.mod, this.name, this.input, this.output)

// Be careful about the order:
Expand All @@ -25,7 +25,7 @@ export class NodeDefinition implements Definition {
const top = net.ports.pop()
if (top === undefined) {
throw new Error(
`[NodeDefinition.call] I expect a port on top of the stack`,
`[NodeDefinition.compose] I expect a port on top of the stack`,
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/lang/definitions/OperatorDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export class OperatorDefinition implements Definition {
constructor(
public mod: Mod,
public name: string,
public call: (net: Net) => void,
public compose: (net: Net) => void,
) {}
}
6 changes: 4 additions & 2 deletions src/lang/definitions/TypeDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export class TypeDefinition implements Definition {
public arity: number,
) {}

call(net: Net): void {
throw new Error(`[TypeDefinition.call] Can not call a type: ${this.name}`)
compose(net: Net): void {
throw new Error(
`[TypeDefinition.compose] Can not compose a type: ${this.name}`,
)
}
}
2 changes: 1 addition & 1 deletion src/lang/run/closeFreePorts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export function closeFreePorts(net: Net): Node | undefined {
"*root*",
[...net.ports],
[],
).call(net)
).compose(net)
}
2 changes: 1 addition & 1 deletion src/lang/words/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Call implements Word {
net.ports.push(found)
net.localPorts.delete(this.name)
} else {
lookupDefinitionOrFail(mod, this.name).call(net)
lookupDefinitionOrFail(mod, this.name).compose(net)
}
}
}

0 comments on commit 9eeb14d

Please sign in to comment.