From 99881ded115cfd05b9cd475457000a895b9ab0f6 Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sun, 17 Sep 2023 10:27:57 +0800 Subject: [PATCH] [half-edge] `Mod` has `nodeCounters` -- remove `globalNodeCounters` --- TODO.md | 2 -- src/lang/mod/Mod.ts | 1 + src/lang/mod/createMod.ts | 1 + src/lang/node/createNodeId.ts | 7 +++---- src/lang/node/globalNodeCounters.ts | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 src/lang/node/globalNodeCounters.ts diff --git a/TODO.md b/TODO.md index cbf95c03..86d4fd32 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ # half-edge -[half-edge] `Mod` has `nodeCounters` -- remove `globalNodeCounters` - [half-edge] `Mod` has `halfEdgeCounter` [half-edge] `createHalfEdgeId` diff --git a/src/lang/mod/Mod.ts b/src/lang/mod/Mod.ts index 09ae0855..4eea34ee 100644 --- a/src/lang/mod/Mod.ts +++ b/src/lang/mod/Mod.ts @@ -16,4 +16,5 @@ export type Mod = { builtins: Map ruleEntries: Map requiredMods: Map + nodeCounters: Map } diff --git a/src/lang/mod/createMod.ts b/src/lang/mod/createMod.ts index f4a58d34..cd038dbe 100644 --- a/src/lang/mod/createMod.ts +++ b/src/lang/mod/createMod.ts @@ -20,6 +20,7 @@ export function createMod(options: { builtins: new Map(), ruleEntries: new Map(), requiredMods: new Map(), + nodeCounters: new Map(), } as Mod mod.env = createEnv(mod) diff --git a/src/lang/node/createNodeId.ts b/src/lang/node/createNodeId.ts index 648be931..beb9971c 100644 --- a/src/lang/node/createNodeId.ts +++ b/src/lang/node/createNodeId.ts @@ -1,13 +1,12 @@ import { Mod } from "../mod" -import { globalNodeCounters } from "./globalNodeCounters" export function createNodeId(mod: Mod, name: string): string { - const foundCounter = globalNodeCounters.get(name) + const foundCounter = mod.nodeCounters.get(name) if (foundCounter === undefined) { - globalNodeCounters.set(name, 0) + mod.nodeCounters.set(name, 0) return String(0) } else { - globalNodeCounters.set(name, foundCounter + 1) + mod.nodeCounters.set(name, foundCounter + 1) return String(foundCounter + 1) } } diff --git a/src/lang/node/globalNodeCounters.ts b/src/lang/node/globalNodeCounters.ts deleted file mode 100644 index 5d02fd3a..00000000 --- a/src/lang/node/globalNodeCounters.ts +++ /dev/null @@ -1 +0,0 @@ -export const globalNodeCounters: Map = new Map()