Skip to content

Commit

Permalink
[half-edge] Mod has nodeCounters -- remove globalNodeCounters
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Sep 17, 2023
1 parent 442c365 commit 99881de
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# half-edge

[half-edge] `Mod` has `nodeCounters` -- remove `globalNodeCounters`

[half-edge] `Mod` has `halfEdgeCounter`

[half-edge] `createHalfEdgeId`
Expand Down
1 change: 1 addition & 0 deletions src/lang/mod/Mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export type Mod = {
builtins: Map<string, Definition>
ruleEntries: Map<string, RuleEntry>
requiredMods: Map<string, Mod>
nodeCounters: Map<string, number>
}
1 change: 1 addition & 0 deletions src/lang/mod/createMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions src/lang/node/createNodeId.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
1 change: 0 additions & 1 deletion src/lang/node/globalNodeCounters.ts

This file was deleted.

0 comments on commit 99881de

Please sign in to comment.