Documentation ¶
Index ¶
- Constants
- func CreateBuiltinFunction(fn lang.NativeFunction, realm *Realm, proto lang.Value, ...) *lang.Object
- func CreateIntrinsics(r *Realm) lang.InternalValue
- func GetPrototypeFromConstructor(constructor *lang.Object, intrinsicDefaultProto lang.String) (*lang.Object, errors.Error)
- func OrdinaryCreateFromConstructor(constructor *lang.Object, intrinsicDefaultProto lang.String, ...) (*lang.Object, errors.Error)
- type Realm
- func (r *Realm) AddRestrictedFunctionProperties(f *lang.Object)
- func (r *Realm) GetIntrinsicObject(n string) lang.Value
- func (r *Realm) SetDefaultGlobalBindings() lang.Value
- func (r *Realm) SetRealmGlobalObject(globalObj, thisValue lang.Value) *Realm
- func (*Realm) Type() lang.Type
- func (r *Realm) Value() interface{}
Constants ¶
const ( IntrinsicNameObjectPrototype = "ObjectPrototype" IntrinsicNameFunctionPrototype = "FunctionPrototype" IntrinsicNameThrowTypeError = "ThrowTypeError" )
Intrinsic names used by the specification. The specification denotes the usage of these names as e.g. %ThrowTypeError% (enclosed in '%').
Variables ¶
This section is empty.
Functions ¶
func CreateBuiltinFunction ¶
func CreateBuiltinFunction(fn lang.NativeFunction, realm *Realm, proto lang.Value, internalSlotsList ...lang.StringOrSymbol) *lang.Object
CreateBuiltinFunction creates a callable object, whose Call internal method will be the passed function fn. CreateBuiltinFunction is specified in 9.3.3.
func CreateIntrinsics ¶
func CreateIntrinsics(r *Realm) lang.InternalValue
CreateIntrinsics sets intrinsic objects of a record as specified in 8.2.2.
func GetPrototypeFromConstructor ¶
func GetPrototypeFromConstructor(constructor *lang.Object, intrinsicDefaultProto lang.String) (*lang.Object, errors.Error)
GetPrototypeFromConstructor determines the [[Prototype]] value that should be used to create an object corresponding to a specific constructor. GetPrototypeFromConstructor is specified in 9.1.14.
func OrdinaryCreateFromConstructor ¶
func OrdinaryCreateFromConstructor(constructor *lang.Object, intrinsicDefaultProto lang.String, internalSlotsList ...lang.StringOrSymbol) (*lang.Object, errors.Error)
OrdinaryCreateFromConstructor creates an object, whose prototype will be the prototype of the passed constructor object. If that constructor's property is not set, the intrinsic default prototype will be used instead. OrdinaryCreateFromConstructor is specified in 9.1.13.
Types ¶
type Realm ¶
type Realm struct { Intrinsics *lang.Record GlobalObj lang.Value // Object or Undefined GlobalEnv lang.Value // Object or Undefined TemplateMap map[interface{}]*lang.Object // Parse Node -> Object HostDefined lang.InternalValue }
Realm is a struct that contains fields specified in 8.2.
func CreateRealm ¶
func CreateRealm() *Realm
CreateRealm creates a realm with Undefined GlobalObj and Undefined GlobalEnv, an empty TemplateMap, Undefined as HostDefined and the Intrinsics specified in 8.2.2. CreateRealm itself is specified in 8.2.1.
func CurrentRealm ¶
func CurrentRealm() *Realm
CurrentRealm returns the current realm as used in the specification.
func GetFunctionRealm ¶
GetFunctionRealm returns the realm that the object is belonging to. That is, if the object has a Realm internal slot, its value will be returned. If it is a proxy object, the proxy target's function realm will be returned. Otherwise, this function returns the current realm record. GetFunctionRealm is specified in 7.3.22.
func (*Realm) AddRestrictedFunctionProperties ¶
AddRestrictedFunctionProperties adds restricted function properties to the given object within this realm as specified in 9.2.9.
func (*Realm) GetIntrinsicObject ¶
GetIntrinsicObject returns the intrinsic object of the realm specified by the given name, or Undefined if no intrinsic object with that name could be found.
func (*Realm) SetDefaultGlobalBindings ¶
SetDefaultGlobalBindings is specified in 8.2.4. TODO: improve godoc
func (*Realm) SetRealmGlobalObject ¶
SetRealmGlobalObject sets the global object of a realm, as specified in 8.2.3. If the passed global object is Undefined, a new object created from the intrinsic %ObjectPrototype% object of this realm will be used instead.