ecma262 icon indicating copy to clipboard operation
ecma262 copied to clipboard

Editorial: Model the bindings of a declarative Env Rec as a List of Records

Open jmdyck opened this issue 4 years ago • 4 comments

Making this a draft PR because I'm not sure about module Env Recs.

jmdyck avatar Jan 24 '21 05:01 jmdyck

Some alternatives for DeclarativeBindingRecord:

(1) Replace [[IsInitialized]]: Boolean, [[BoundValue]]: ECMAScript language value with [[BoundValue]]: ~uninitialized~ or ECMAScript language value [Later: I did this.]

(2) To avoid the weirdness of the [[BoundValue]] field in indirect bindings...

(2a) Instead of defining the sub-type ImportDeclarativeBindingRecord, allow the [[BoundValue]] field of a DeclarativeBindingRecord to be a record with just the [[TargetModuleRec]] and [[TargetName]] fields.

(2b) Or you could have an abstract base type that is specialized into either having a [[BoundValue]] field or the [[TargetModuleRec]] and [[TargetName]] fields. (E.g. DeclarativeBindingRecord specializes to DirectDeclarativeBindingRecord and IndirectDeclarativeBindingRecord.) This is probably nicest from a theoretical standpoint, but 2a is basically equivalent without having to set up another type hierarchy.

[Later: I went with 2b, basically.]

jmdyck avatar Jan 24 '21 16:01 jmdyck

(forced-pushed after rebase to master)

jmdyck avatar Jan 28 '21 22:01 jmdyck

(force-pushed to resolve merge conflicts)

jmdyck avatar May 13 '21 15:05 jmdyck

Okay, this PR is ready for review.

Issue #2639 might affect SetMutableBinding, but probably not much.

jmdyck avatar Jan 27 '22 02:01 jmdyck