Sunday, December 11, 2022

Function Environment Record

Function Environment Record

GetSuperBase():

  • Let envRec be the function Environment Record for which the method was invoked.
  • Let home be envRec.[[HomeObject]].
  • If home has the value undefined, return undefined.
  • Return home.[[Prototype]].
  • would it better to rename it into GetSuper or GetSuperObject()?

GetThisBinding():

  • Assert: envRec.[[ThisBindingStatus]] is not lexical.
  • If envRec.[[ThisBindingStatus]] is uninitialized, throw a ReferenceError exception.
  • Return envRec.[[ThisValue]].

HasSuperBinding():

  • If envRec.[[ThisBindingStatus]] is lexical, return false.
  • If envRec.[[HomeObject]] has the value undefined, return false; otherwise, return true.
  • zxxu:[[HomeObject]] is meanful only when has super accesses; ecma: [[HomeObject]] is the object that the function is bound to as a method; zxxu: [[HomeObject]] is added since es6 to support class definitions

HasThisBinding(): If envRec.[[ThisBindingStatus]] is lexical, return false; otherwise, return true.

BindThisValue(V):

  • Assert: envRec.[[ThisBindingStatus]] is not lexical.
  • If envRec.[[ThisBindingStatus]] is initialized, throw a ReferenceError exception.
  • Set envRec.[[ThisValue]] to V.
  • Set envRec.[[ThisBindingStatus]] to initialized.
  • Return V.

No comments:

Post a Comment