diff --git a/TODO.md b/TODO.md index 17199d52..f0773676 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,3 @@ -[mod] drop mod prefix of lookup - `NodeDefinition.fullName` `Node` should not have `definition` -- which is used to `lookupRule` diff --git a/src/lang/graph/netConnect.ts b/src/lang/graph/netConnect.ts index ec1c87b7..5fa74486 100644 --- a/src/lang/graph/netConnect.ts +++ b/src/lang/graph/netConnect.ts @@ -1,8 +1,8 @@ import { Action, Net, Port, createEdge } from "../graph" -import { modLookupRuleByPorts } from "../mod/modLookupRuleByPorts" +import { lookupRuleByPorts } from "../mod/lookupRuleByPorts" export function netConnect(net: Net, start: Port, end: Port): void { - const rule = modLookupRuleByPorts(net.mod, start, end) + const rule = lookupRuleByPorts(net.mod, start, end) if (rule) { net.actions.push(new Action(start, end, rule)) diff --git a/src/lang/mod/defineRule.ts b/src/lang/mod/defineRule.ts index f5a9ab5c..e999ece2 100644 --- a/src/lang/mod/defineRule.ts +++ b/src/lang/mod/defineRule.ts @@ -1,7 +1,7 @@ import { Rule } from "../rule" import { Word } from "../word" import { Mod } from "./Mod" -import { modLookupNodeDefinitionOrFail } from "./modLookupNodeDefinitionOrFail" +import { lookupNodeDefinitionOrFail } from "./lookupNodeDefinitionOrFail" export function defineRule( mod: Mod, @@ -13,8 +13,8 @@ export function defineRule( `${start} ${end}`, new Rule( mod, - modLookupNodeDefinitionOrFail(mod, start), - modLookupNodeDefinitionOrFail(mod, end), + lookupNodeDefinitionOrFail(mod, start), + lookupNodeDefinitionOrFail(mod, end), words, ), ) diff --git a/src/lang/mod/modLookupDefinitionOrFail.ts b/src/lang/mod/lookupDefinitionOrFail.ts similarity index 73% rename from src/lang/mod/modLookupDefinitionOrFail.ts rename to src/lang/mod/lookupDefinitionOrFail.ts index 568ab4fc..04f8e64e 100644 --- a/src/lang/mod/modLookupDefinitionOrFail.ts +++ b/src/lang/mod/lookupDefinitionOrFail.ts @@ -1,7 +1,7 @@ import { Definition } from "../definition" import { Mod } from "./Mod" -export function modLookupDefinitionOrFail(mod: Mod, name: string): Definition { +export function lookupDefinitionOrFail(mod: Mod, name: string): Definition { const definition = mod.definitions.get(name) if (definition === undefined) { throw new Error(`Undefined name: ${name}`) diff --git a/src/lang/mod/modLookupNetDefinitionOrFail.ts b/src/lang/mod/lookupNetDefinitionOrFail.ts similarity index 65% rename from src/lang/mod/modLookupNetDefinitionOrFail.ts rename to src/lang/mod/lookupNetDefinitionOrFail.ts index 35c815be..ca2c15a6 100644 --- a/src/lang/mod/modLookupNetDefinitionOrFail.ts +++ b/src/lang/mod/lookupNetDefinitionOrFail.ts @@ -1,12 +1,12 @@ import * as Definitions from "../definitions" import { Mod } from "./Mod" -import { modLookupDefinitionOrFail } from "./modLookupDefinitionOrFail" +import { lookupDefinitionOrFail } from "./lookupDefinitionOrFail" -export function modLookupNetDefinitionOrFail( +export function lookupNetDefinitionOrFail( mod: Mod, name: string, ): Definitions.NetDefinition { - const definition = modLookupDefinitionOrFail(mod, name) + const definition = lookupDefinitionOrFail(mod, name) if (!(definition instanceof Definitions.NetDefinition)) { throw new Error( `I expect a net definition, but ${name} is ${definition.constructor.name}`, diff --git a/src/lang/mod/modLookupNodeDefinitionOrFail.ts b/src/lang/mod/lookupNodeDefinitionOrFail.ts similarity index 65% rename from src/lang/mod/modLookupNodeDefinitionOrFail.ts rename to src/lang/mod/lookupNodeDefinitionOrFail.ts index 282c52e2..2c6109c3 100644 --- a/src/lang/mod/modLookupNodeDefinitionOrFail.ts +++ b/src/lang/mod/lookupNodeDefinitionOrFail.ts @@ -1,12 +1,12 @@ import * as Definitions from "../definitions" import { Mod } from "./Mod" -import { modLookupDefinitionOrFail } from "./modLookupDefinitionOrFail" +import { lookupDefinitionOrFail } from "./lookupDefinitionOrFail" -export function modLookupNodeDefinitionOrFail( +export function lookupNodeDefinitionOrFail( mod: Mod, name: string, ): Definitions.NodeDefinition { - const definition = modLookupDefinitionOrFail(mod, name) + const definition = lookupDefinitionOrFail(mod, name) if (!(definition instanceof Definitions.NodeDefinition)) { throw new Error( `I expect a node definition, but ${name} is ${definition.constructor.name}`, diff --git a/src/lang/mod/modLookupRule.ts b/src/lang/mod/lookupRule.ts similarity index 84% rename from src/lang/mod/modLookupRule.ts rename to src/lang/mod/lookupRule.ts index 10564f74..54d6ae58 100644 --- a/src/lang/mod/modLookupRule.ts +++ b/src/lang/mod/lookupRule.ts @@ -1,7 +1,7 @@ import { Rule } from "../rule" import { Mod } from "./Mod" -export function modLookupRule( +export function lookupRule( mod: Mod, start: string, end: string, diff --git a/src/lang/mod/modLookupRuleByPorts.ts b/src/lang/mod/lookupRuleByPorts.ts similarity index 58% rename from src/lang/mod/modLookupRuleByPorts.ts rename to src/lang/mod/lookupRuleByPorts.ts index f12035e0..af57b1a0 100644 --- a/src/lang/mod/modLookupRuleByPorts.ts +++ b/src/lang/mod/lookupRuleByPorts.ts @@ -1,14 +1,14 @@ import { Port } from "../graph" import { Rule } from "../rule" import { Mod } from "./Mod" -import { modLookupRule } from "./modLookupRule" +import { lookupRule } from "./lookupRule" -export function modLookupRuleByPorts( +export function lookupRuleByPorts( mod: Mod, start: Port, end: Port, ): Rule | undefined { if (start.isPrincipal && end.isPrincipal) { - return modLookupRule(mod, start.node.name, end.node.name) + return lookupRule(mod, start.node.name, end.node.name) } } diff --git a/src/lang/mod/modBuildNet.ts b/src/lang/mod/modBuildNet.ts index a11da9ef..19afb81e 100644 --- a/src/lang/mod/modBuildNet.ts +++ b/src/lang/mod/modBuildNet.ts @@ -2,11 +2,11 @@ import { Net } from "../graph" import { createNet } from "../graph/createNet" import { netCleanUpWires } from "../graph/netCleanUpWires" import { Mod } from "./Mod" -import { modLookupNetDefinitionOrFail } from "./modLookupNetDefinitionOrFail" +import { lookupNetDefinitionOrFail } from "./lookupNetDefinitionOrFail" export function modBuildNet(mod: Mod, name: string): Net { const net = createNet(mod) - modLookupNetDefinitionOrFail(mod, name).meaning(net) + lookupNetDefinitionOrFail(mod, name).meaning(net) netCleanUpWires(net) return net } diff --git a/src/lang/words/Call.ts b/src/lang/words/Call.ts index cdbdcbb7..f87023d2 100644 --- a/src/lang/words/Call.ts +++ b/src/lang/words/Call.ts @@ -1,6 +1,6 @@ import { Net } from "../graph" import { Mod } from "../mod" -import { modLookupDefinitionOrFail } from "../mod/modLookupDefinitionOrFail" +import { lookupDefinitionOrFail } from "../mod/lookupDefinitionOrFail" import { Span } from "../span" import { Word } from "../word" @@ -16,7 +16,7 @@ export class Call implements Word { net.portStore.delete(this.name) net.portStack.push(found) } else { - modLookupDefinitionOrFail(mod, this.name).meaning(net) + lookupDefinitionOrFail(mod, this.name).meaning(net) } } }