diff --git a/bend2/comp.ts b/bend2/comp.ts index fa3f69f89..490889703 100644 --- a/bend2/comp.ts +++ b/bend2/comp.ts @@ -51,7 +51,7 @@ type HTerm = Bend.HTerm; type Name = Bend.Name; -type File = { +type File = ReturnType & { book: Bend.Book; js: boolean; bangs: Set; @@ -59,17 +59,8 @@ type File = { hot: Set; stat: Set; own: Set; - lend: Set; - segs: Seg[]; - spins: Seg[]; - spun: Map; marsh: Map; - clos: Set; - tabs: Map; tails: Map>; - img: string[]; - lits: Map; - consts: Map>; ids: Map; taken: Set; teles: Map; @@ -77,7 +68,6 @@ type File = { loops: Map; flats: Map; funs: Map; - brws: Map; nodes: Map; lays: Map; lay_ids: Map; @@ -1320,6 +1310,15 @@ export function io_run(book: Bend.Book, args: string[]): number { // types once, its arguments at every instantiation. compile_book emits until // a pass changes no fact. +// What one emitting pass writes, cleared before the next one. +function file_pass() { + return { lend: new Set(), segs: [] as Seg[], spins: [] as Seg[], + spun: new Map(), clos: new Set(), + tabs: new Map(), img: [] as string[], + lits: new Map(), consts: new Map>(), + brws: new Map() }; +} + function file_new(book: Bend.Book, js: boolean): File { PROBES.length = 1; return { @@ -1330,17 +1329,9 @@ function file_new(book: Bend.Book, js: boolean): File { hot: new Set(), stat: new Set(), own: new Set(), - lend: new Set(), - segs: [], - spins: [], - spun: new Map(), + ...file_pass(), marsh: new Map(), - clos: new Set(), - tabs: new Map(), tails: new Map(), - img: [], - lits: new Map(), - consts: new Map(), ids: new Map(), taken: new Set("FID_EXIT FID_ENTER FID_T CID_T".split(" ")), teles: new Map(), @@ -1348,7 +1339,6 @@ function file_new(book: Bend.Book, js: boolean): File { loops: new Map(), flats: new Map(), funs: new Map(), - brws: new Map(), nodes: new Map(), lays: new Map(), lay_ids: new Map(), @@ -2789,11 +2779,7 @@ export function compile_book(book: Bend.Book): string { let was: number; do { was = facts(); - [FL.lend, FL.spun, FL.clos, FL.tabs, FL.lits, FL.consts, FL.brws] - .forEach((m) => m.clear()); - FL.segs = []; - FL.spins = []; - FL.img = []; + Object.assign(FL, file_pass()); for (const [k, tld] of [...done_defs().reverse(), ...done_defs(def_foreign)]) { memo_gc();