Skip to content

Commit 986f2d5

Browse files
NullVoxPopuliclaude
andcommitted
Make the scope bag an object instead of an array
Now that the scope bag is a `Record<string, unknown>`, the lexical symbol names are always carried alongside their values. This eliminates the need for the `lexicalSymbols` slot in the wire format block (previously only available when `debugSymbols` was enabled) and allows `meta()` to derive `lexical` names and `scopeValues` directly from the scope object's keys and values. See also: upstream PR #21224, PR #21068. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 468a145 commit 986f2d5

4 files changed

Lines changed: 4 additions & 13 deletions

File tree

packages/@glimmer-workspace/integration-tests/lib/compile.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export function preprocess(templateSource: string, options?: PrecompileOptions):
1515
return createTemplate(templateSource, options)({});
1616
}
1717

18-
let templateId = 0;
19-
2018
export function createTemplate(
2119
templateSource: Nullable<string>,
2220
options: PrecompileOptions | PrecompileOptionsWithLexicalScope = {},
@@ -29,12 +27,7 @@ export function createTemplate(
2927
reifiedScope[key] = scopeValues[key];
3028
}
3129

32-
if ('emit' in options && options.emit?.debugSymbols) {
33-
block.push(usedLocals);
34-
}
35-
3630
let templateBlock: SerializedTemplateWithLazyBlock = {
37-
id: String(templateId++),
3831
block: JSON.stringify(block),
3932
moduleName: options.meta?.moduleName ?? '(unknown template module)',
4033
scope: usedLocals.length > 0 ? () => reifiedScope : null,

packages/@glimmer/compiler/lib/compiler.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ export function precompile(
123123
): TemplateJavascript {
124124
const [block, usedLocals] = precompileJSON(source, options);
125125

126-
if ('emit' in options && options.emit?.debugSymbols && usedLocals.length > 0) {
127-
block.push(usedLocals);
128-
}
126+
// lexical symbol names are now carried by the scope object itself (as keys),
127+
// so we no longer need to push them into the wire format block for debug symbols.
129128

130129
const moduleName = options.meta?.moduleName;
131130
const idFn = options.id || defaultId;

packages/@glimmer/interfaces/lib/compile/wire-format/api.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ export type SerializedTemplateBlock = [
373373
statements: Statements.Statement[],
374374
locals: string[],
375375
upvars: string[],
376-
lexicalSymbols?: string[],
377376
];
378377

379378
/**

packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ export function CompilePositional(
106106
}
107107

108108
export function meta(layout: LayoutWithContext): BlockMetadata {
109-
let [, locals, upvars, lexicalSymbols] = layout.block;
109+
let [, locals, upvars] = layout.block;
110110
let scopeRecord = layout.scope?.() ?? null;
111111

112112
return {
113113
symbols: {
114114
locals,
115115
upvars,
116-
lexical: scopeRecord ? Object.keys(scopeRecord) : lexicalSymbols,
116+
lexical: scopeRecord ? Object.keys(scopeRecord) : undefined,
117117
},
118118
scopeValues: scopeRecord ? Object.values(scopeRecord) : null,
119119
isStrictMode: layout.isStrictMode,

0 commit comments

Comments
 (0)