diff --git a/bin/opcodes.json b/bin/opcodes.json index 66dd0efa4a..afdddbafb8 100644 --- a/bin/opcodes.json +++ b/bin/opcodes.json @@ -91,7 +91,6 @@ "GetComponentSelf", "GetComponentTagName", "GetComponentLayout", - "SetupForEval", "PopulateLayout", "InvokeComponentLayout", "BeginComponentTransaction", diff --git a/packages/@glimmer/debug/lib/opcode-metadata.ts b/packages/@glimmer/debug/lib/opcode-metadata.ts index c559bf57d3..1d25b42946 100644 --- a/packages/@glimmer/debug/lib/opcode-metadata.ts +++ b/packages/@glimmer/debug/lib/opcode-metadata.ts @@ -1187,36 +1187,6 @@ METADATA[Op.GetComponentLayout] = { check: true, }; -METADATA[Op.BindEvalScope] = { - name: 'BindEvalScope', - mnemonic: 'eval_scope', - before: null, - stackChange: 0, - ops: [ - { - name: 'state', - type: 'register', - }, - ], - operands: 1, - check: true, -}; - -METADATA[Op.SetupForEval] = { - name: 'SetupForEval', - mnemonic: 'eval_setup', - before: null, - stackChange: 0, - ops: [ - { - name: 'state', - type: 'register', - }, - ], - operands: 1, - check: true, -}; - METADATA[Op.PopulateLayout] = { name: 'PopulateLayout', mnemonic: 'comp_layoutput', @@ -1297,21 +1267,6 @@ METADATA[Op.DidRenderLayout] = { check: true, }; -METADATA[Op.ResolveMaybeLocal] = { - name: 'ResolveMaybeLocal', - mnemonic: 'eval_varload', - before: null, - stackChange: 1, - ops: [ - { - name: 'local', - type: 'str', - }, - ], - operands: 1, - check: true, -}; - METADATA[Op.Debugger] = { name: 'Debugger', mnemonic: 'debugger', diff --git a/packages/@glimmer/interfaces/lib/runtime/scope.d.ts b/packages/@glimmer/interfaces/lib/runtime/scope.d.ts index bfbc950fa2..1931179fb9 100644 --- a/packages/@glimmer/interfaces/lib/runtime/scope.d.ts +++ b/packages/@glimmer/interfaces/lib/runtime/scope.d.ts @@ -1,4 +1,4 @@ -import type { Dict, Nullable } from '../core.js'; +import type { Nullable } from '../core.js'; import type { Reference } from '../references.js'; import type { CompilableBlock } from '../template.js'; import type { BlockSymbolTable } from '../tier1/symbol-table.js'; @@ -18,21 +18,13 @@ export interface Scope { getSelf(): Reference; getSymbol(symbol: number): Reference; getBlock(symbol: number): Nullable; - getEvalScope(): Nullable>; - getPartialMap(): Nullable>; bind(symbol: number, value: ScopeSlot): void; bindSelf(self: Reference): void; bindSymbol(symbol: number, value: Reference): void; bindBlock(symbol: number, value: Nullable): void; - bindEvalScope(map: Nullable>): void; - bindPartialMap(map: Dict): void; child(): Scope; } -export interface PartialScope extends Scope { - bindEvalScope(scope: Nullable>): void; -} - export interface DynamicScope { get(key: string): Reference; set(key: string, reference: Reference): Reference; diff --git a/packages/@glimmer/interfaces/lib/vm-opcodes.d.ts b/packages/@glimmer/interfaces/lib/vm-opcodes.d.ts index c428f832fc..e9fe26a9f6 100644 --- a/packages/@glimmer/interfaces/lib/vm-opcodes.d.ts +++ b/packages/@glimmer/interfaces/lib/vm-opcodes.d.ts @@ -96,15 +96,12 @@ export type VmPutComponentOperations = 89; export type VmGetComponentSelf = 90; export type VmGetComponentTagName = 91; export type VmGetComponentLayout = 92; -export type VmBindEvalScope = 93; -export type VmSetupForEval = 94; export type VmPopulateLayout = 95; export type VmInvokeComponentLayout = 96; export type VmBeginComponentTransaction = 97; export type VmCommitComponentTransaction = 98; export type VmDidCreateElement = 99; export type VmDidRenderLayout = 100; -export type VmResolveMaybeLocal = 102; export type VmDebugger = 103; export type VmSize = 104; export type VmStaticComponentAttr = 105; @@ -194,15 +191,12 @@ export type VmOp = | VmGetComponentSelf | VmGetComponentTagName | VmGetComponentLayout - | VmBindEvalScope - | VmSetupForEval | VmPopulateLayout | VmInvokeComponentLayout | VmBeginComponentTransaction | VmCommitComponentTransaction | VmDidCreateElement | VmDidRenderLayout - | VmResolveMaybeLocal | VmDebugger | VmSize | VmStaticComponentAttr diff --git a/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts b/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts index 2273c88eaf..294b11d70c 100644 --- a/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts +++ b/packages/@glimmer/opcode-compiler/lib/opcode-builder/helpers/components.ts @@ -414,7 +414,6 @@ export function invokePreparedComponent( op(Op.VirtualRootScope, $s0); op(Op.SetVariable, 0); - op(Op.SetupForEval, $s0); if (bindableAtNames) op(Op.SetNamedVariables, $s0); if (bindableBlocks) op(Op.SetBlocks, $s0); diff --git a/packages/@glimmer/runtime/index.ts b/packages/@glimmer/runtime/index.ts index 0c80f9eceb..ed20c1e2c2 100644 --- a/packages/@glimmer/runtime/index.ts +++ b/packages/@glimmer/runtime/index.ts @@ -39,7 +39,7 @@ export { hash } from './lib/helpers/hash'; export { invokeHelper } from './lib/helpers/invoke'; export { on } from './lib/modifiers/on'; export { renderComponent, renderMain, renderSync } from './lib/render'; -export { DynamicScopeImpl, PartialScopeImpl } from './lib/scope'; +export { DynamicScopeImpl, ScopeImpl } from './lib/scope'; export type { SafeString } from './lib/upsert'; export { type InternalVM, VM as LowLevelVM, UpdatingVM } from './lib/vm'; export { diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/-debug-strip.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/-debug-strip.ts index 4bad535c78..12f59c0426 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/-debug-strip.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/-debug-strip.ts @@ -36,7 +36,7 @@ import { import { REFERENCE, UNDEFINED_REFERENCE } from '@glimmer/reference'; import { COMPUTE } from '@glimmer/validator'; -import { PartialScopeImpl } from '../../scope'; +import { ScopeImpl } from '../../scope'; import { VMArgumentsImpl } from '../../vm/arguments'; import { ComponentElementOperations } from './component'; @@ -92,7 +92,7 @@ export const CheckCapturedArguments: Checker = CheckInterface named: wrap(() => CheckDict(CheckReference)), }); -export const CheckScope: Checker = wrap(() => CheckInstanceof(PartialScopeImpl)); +export const CheckScope: Checker = wrap(() => CheckInstanceof(ScopeImpl)); export const CheckComponentManager: Checker> = CheckInterface({ getCapabilities: CheckFunction, diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/component.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/component.ts index 36749bf03c..c6a5508010 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/component.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/component.ts @@ -766,15 +766,6 @@ APPEND_OPCODES.add(Op.VirtualRootScope, (vm, { op1: _state }) => { vm.pushRootScope(table.symbols.length + 1, owner); }); -APPEND_OPCODES.add(Op.SetupForEval, (vm, { op1: _state }) => { - let state = check(vm.fetchValue(_state), CheckFinishedComponentInstance); - - if (state.table.hasEval) { - let lookup = (state.lookup = dict()); - vm.scope().bindEvalScope(lookup); - } -}); - APPEND_OPCODES.add(Op.SetNamedVariables, (vm, { op1: _state }) => { let state = check(vm.fetchValue(_state), CheckFinishedComponentInstance); let scope = vm.scope(); diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/debugger.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/debugger.ts index 84e40231ac..1aca4305e6 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/debugger.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/debugger.ts @@ -52,16 +52,13 @@ class ScopeInspector { let { scope, locals } = this; let parts = path.split('.'); let [head, ...tail] = path.split('.') as [string, ...string[]]; - - let evalScope = scope.getEvalScope()!; let ref: Reference; if (head === 'this') { ref = scope.getSelf(); } else if (locals[head]) { ref = unwrap(locals[head]); - } else if (head.indexOf('@') === 0 && evalScope[head]) { - ref = evalScope[head] as Reference; + // FIXME restore get("@foo") functionality } else { ref = this.scope.getSelf(); tail = parts; diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/expressions.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/expressions.ts index 2fa7af7475..633276bd13 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/expressions.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/expressions.ts @@ -181,18 +181,6 @@ APPEND_OPCODES.add(Op.SetBlock, (vm, { op1: symbol }) => { vm.scope().bindBlock(symbol, [handle, scope, table]); }); -APPEND_OPCODES.add(Op.ResolveMaybeLocal, (vm, { op1: _name }) => { - let name = vm[CONSTANTS].getValue(_name); - let locals = vm.scope().getPartialMap()!; - - let ref = locals[name]; - if (ref === undefined) { - ref = childRefFor(vm.getSelf(), name); - } - - vm.stack.push(ref); -}); - APPEND_OPCODES.add(Op.RootScope, (vm, { op1: symbols }) => { vm.pushRootScope(symbols, vm.getOwner()); }); diff --git a/packages/@glimmer/runtime/lib/scope.ts b/packages/@glimmer/runtime/lib/scope.ts index 44226d4e86..60e662376c 100644 --- a/packages/@glimmer/runtime/lib/scope.ts +++ b/packages/@glimmer/runtime/lib/scope.ts @@ -3,7 +3,6 @@ import type { DynamicScope, Nullable, Owner, - PartialScope, Scope, ScopeBlock, ScopeSlot, @@ -41,29 +40,28 @@ export function isScopeReference(s: ScopeSlot): s is Reference { return true; } -export class PartialScopeImpl implements PartialScope { - static root(self: Reference, size = 0, owner: Owner): PartialScope { +export class ScopeImpl implements Scope { + static root(self: Reference, size = 0, owner: Owner): Scope { let refs: Reference[] = new Array(size + 1).fill(UNDEFINED_REFERENCE); - return new PartialScopeImpl(refs, owner, null, null, null).init({ self }); + return new ScopeImpl(refs, owner, null).init({ self }); } static sized(size = 0, owner: Owner): Scope { let refs: Reference[] = new Array(size + 1).fill(UNDEFINED_REFERENCE); - return new PartialScopeImpl(refs, owner, null, null, null); + return new ScopeImpl(refs, owner, null); } constructor( // the 0th slot is `self` readonly slots: Array, readonly owner: Owner, - private callerScope: Scope | null, - // named arguments and blocks passed to a layout that uses eval - private evalScope: Dict | null, - // locals in scope when the partial was invoked - private partialMap: Dict> | null + private callerScope: Scope | null ) {} + getPartialMap(): Nullable>> { + throw new Error('Method not implemented.'); + } init({ self }: { self: Reference }): this { this.slots[0] = self; @@ -83,14 +81,6 @@ export class PartialScopeImpl implements PartialScope { return block === UNDEFINED_REFERENCE ? null : (block as ScopeBlock); } - getEvalScope(): Nullable> { - return this.evalScope; - } - - getPartialMap(): Nullable>> { - return this.partialMap; - } - bind(symbol: number, value: ScopeSlot) { this.set(symbol, value); } @@ -107,14 +97,6 @@ export class PartialScopeImpl implements PartialScope { this.set>(symbol, value); } - bindEvalScope(map: Nullable>) { - this.evalScope = map; - } - - bindPartialMap(map: Dict>) { - this.partialMap = map; - } - bindCallerScope(scope: Nullable): void { this.callerScope = scope; } @@ -124,13 +106,7 @@ export class PartialScopeImpl implements PartialScope { } child(): Scope { - return new PartialScopeImpl( - this.slots.slice(), - this.owner, - this.callerScope, - this.evalScope, - this.partialMap - ); + return new ScopeImpl(this.slots.slice(), this.owner, this.callerScope); } private get(index: number): T { diff --git a/packages/@glimmer/runtime/lib/vm/append.ts b/packages/@glimmer/runtime/lib/vm/append.ts index 352341d390..76d7b5018d 100644 --- a/packages/@glimmer/runtime/lib/vm/append.ts +++ b/packages/@glimmer/runtime/lib/vm/append.ts @@ -7,7 +7,6 @@ import type { Environment, Nullable, Owner, - PartialScope, RenderResult, ResolutionTimeConstants, RichIteratorResult, @@ -41,7 +40,7 @@ import { JumpIfNotModifiedOpcode, } from '../compiled/opcodes/vm'; import { APPEND_OPCODES } from '../opcodes'; -import { PartialScopeImpl } from '../scope'; +import { ScopeImpl } from '../scope'; import { ARGS, CONSTANTS, DESTROYABLE_STACK, HEAP, INNER_VM, REGISTERS, STACKS } from '../symbols'; import { VMArgumentsImpl } from './arguments'; import { LowLevelVM } from './low-level'; @@ -96,7 +95,7 @@ export interface InternalVM { enterItem(item: OpaqueIterationItem): ListItemOpcode; registerItem(item: ListItemOpcode): void; - pushRootScope(size: number, owner: Owner): PartialScope; + pushRootScope(size: number, owner: Owner): Scope; pushChildScope(): void; popScope(): void; pushScope(scope: Scope): void; @@ -303,7 +302,7 @@ export class VM implements PublicVM, InternalVM { context: CompileTimeCompilationContext, { handle, self, dynamicScope, treeBuilder, numSymbols, owner }: InitOptions ) { - let scope = PartialScopeImpl.root(self, numSymbols, owner); + let scope = ScopeImpl.root(self, numSymbols, owner); let state = vmState(runtime.program.heap.getaddr(handle), scope, dynamicScope); let vm = initVM(context)(runtime, state, treeBuilder); vm.pushUpdating(); @@ -319,7 +318,7 @@ export class VM implements PublicVM, InternalVM { runtime, vmState( runtime.program.heap.getaddr(handle), - PartialScopeImpl.root(UNDEFINED_REFERENCE, 0, owner), + ScopeImpl.root(UNDEFINED_REFERENCE, 0, owner), dynamicScope ), treeBuilder @@ -500,8 +499,8 @@ export class VM implements PublicVM, InternalVM { return child; } - pushRootScope(size: number, owner: Owner): PartialScope { - let scope = PartialScopeImpl.sized(size, owner); + pushRootScope(size: number, owner: Owner): Scope { + let scope = ScopeImpl.sized(size, owner); this[STACKS].scope.push(scope); return scope; } diff --git a/packages/@glimmer/vm/lib/opcodes.toml b/packages/@glimmer/vm/lib/opcodes.toml index 6648e3ccaa..ade542cace 100644 --- a/packages/@glimmer/vm/lib/opcodes.toml +++ b/packages/@glimmer/vm/lib/opcodes.toml @@ -834,16 +834,6 @@ operand-stack = [ ["ProgramSymbolTable", "handle"] ] -[syscall.eval_scope] - -format = ["BindEvalScope", "state:register"] -operation = "Populate the eval lookup if necessary." - -[syscall.eval_setup] - -format = ["SetupForEval", "state:register"] -operation = "Setup for eval" - [syscall.comp_layoutput] format = ["PopulateLayout", "state:register"] @@ -885,18 +875,6 @@ operation = "Invoke didCreateElement on the current component manager" format = ["DidRenderLayout", "state:register"] operation = "Invoke didRenderLayout on the current component manager" -[syscall.eval_varload] - -format = ["ResolveMaybeLocal", "local:str"] -operation = """ -Resolve {{foo}} inside a partial, which could be either a self-lookup -or a local variable that is in-scope for the caller. -""" -operand-stack = [ - [], - ["Reference"] -] - [syscall.debugger] format = ["Debugger", "symbols:str-array", "debugInfo:array"] diff --git a/packages/@glimmer/vm/lib/opcodes.ts b/packages/@glimmer/vm/lib/opcodes.ts index 165c041c4b..320e670abc 100644 --- a/packages/@glimmer/vm/lib/opcodes.ts +++ b/packages/@glimmer/vm/lib/opcodes.ts @@ -7,7 +7,6 @@ import type { VmAssertSame, VmBeginComponentTransaction, VmBindDynamicScope, - VmBindEvalScope, VmCaptureArgs, VmChildScope, VmCloseElement, @@ -91,12 +90,10 @@ import type { VmReifyU32, VmResolveCurriedComponent, VmResolveDynamicComponent, - VmResolveMaybeLocal, VmRootScope, VmSetBlock, VmSetBlocks, VmSetNamedVariables, - VmSetupForEval, VmSetVariable, VmSize, VmSpreadBlock, @@ -196,15 +193,12 @@ export const Op = { GetComponentSelf: 90 satisfies VmGetComponentSelf, GetComponentTagName: 91 satisfies VmGetComponentTagName, GetComponentLayout: 92 satisfies VmGetComponentLayout, - BindEvalScope: 93 satisfies VmBindEvalScope, - SetupForEval: 94 satisfies VmSetupForEval, PopulateLayout: 95 satisfies VmPopulateLayout, InvokeComponentLayout: 96 satisfies VmInvokeComponentLayout, BeginComponentTransaction: 97 satisfies VmBeginComponentTransaction, CommitComponentTransaction: 98 satisfies VmCommitComponentTransaction, DidCreateElement: 99 satisfies VmDidCreateElement, DidRenderLayout: 100 satisfies VmDidRenderLayout, - ResolveMaybeLocal: 102 satisfies VmResolveMaybeLocal, Debugger: 103 satisfies VmDebugger, Size: 104 satisfies VmSize, StaticComponentAttr: 105 satisfies VmStaticComponentAttr,