realm

package
v0.0.0-...-4ed146b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
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

func GetFunctionRealm(obj *lang.Object) *Realm

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

func (r *Realm) AddRestrictedFunctionProperties(f *lang.Object)

AddRestrictedFunctionProperties adds restricted function properties to the given object within this realm as specified in 9.2.9.

func (*Realm) GetIntrinsicObject

func (r *Realm) GetIntrinsicObject(n string) lang.Value

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

func (r *Realm) SetDefaultGlobalBindings() lang.Value

SetDefaultGlobalBindings is specified in 8.2.4. TODO: improve godoc

func (*Realm) SetRealmGlobalObject

func (r *Realm) SetRealmGlobalObject(globalObj, thisValue lang.Value) *Realm

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.

func (*Realm) Type

func (*Realm) Type() lang.Type

Type returns lang.TypeInternal.

func (*Realm) Value

func (r *Realm) Value() interface{}

Value returns the Realm itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL