binding

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: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	// contains filtered or unexported fields
}

Binding represents a concept described throughout the specification, especially in context with environment records.

func NewBinding

func NewBinding(name lang.String) *Binding

NewBinding creates a new named binding with the given name.

func (*Binding) IsDeletable

func (b *Binding) IsDeletable() bool

IsDeletable is used to determine whether this binding is deletable.

func (*Binding) IsFinal

func (b *Binding) IsFinal() bool

IsFinal is used to determine whether this binding is final.

func (*Binding) IsImmutable

func (b *Binding) IsImmutable() bool

IsImmutable is used to determine whether this binding is immutable.

func (*Binding) IsInitialized

func (b *Binding) IsInitialized() bool

IsInitialized is used to determine whether this binding is initialized.

func (*Binding) IsStrict

func (b *Binding) IsStrict() bool

IsStrict is used to determine whether this binding is a strict binding.

func (*Binding) Name

func (b *Binding) Name() lang.String

Name returns the name of this binding.

func (*Binding) Set

func (b *Binding) Set(val lang.Value)

Set assigns a value to this binding.

func (*Binding) Value

func (b *Binding) Value() lang.Value

Value returns the value of this binding.

type DeclarativeEnvironment

type DeclarativeEnvironment struct {
	// contains filtered or unexported fields
}

DeclarativeEnvironment represents a declarative environment record as described in 8.1.1.1.

func NewDeclarativeEnvironment

func NewDeclarativeEnvironment(outer Environment) *DeclarativeEnvironment

NewDeclarativeEnvironment creates a new declarative environment with the given outer environment. NewDeclarativeEnvironment is specified in 8.1.2.2.

func (*DeclarativeEnvironment) CreateImmutableBinding

func (e *DeclarativeEnvironment) CreateImmutableBinding(n lang.String, strict bool) errors.Error

CreateImmutableBinding creates a new immutable binding for the given name that is uninitialized. A binding must not already exist in this Environment Record with that name. If strict is true the new binding is marked as a strict binding. CreateImmutableBinding is specified in 8.1.1.1.3.

func (*DeclarativeEnvironment) CreateMutableBinding

func (e *DeclarativeEnvironment) CreateMutableBinding(n lang.String, deletable bool) errors.Error

CreateMutableBinding creates a new mutable binding for the name N that is uninitialized. A binding must not already exist in this Environment Record for the given name. If Boolean argument deletable is true the new binding can be deleted by a subsequent DeleteBinding call. CreateMutableBinding is specified in 8.1.1.1.2.

func (*DeclarativeEnvironment) DeleteBinding

func (e *DeclarativeEnvironment) DeleteBinding(n lang.String) bool

DeleteBinding deletes a binding with the given name if the binding is deletable. If the binding is not deletable, this function returns false. If the binding does not exist or is deletable, this function returns true. DeleteBinding is specified in 8.1.1.1.7.

func (*DeclarativeEnvironment) GetBindingValue

func (e *DeclarativeEnvironment) GetBindingValue(n lang.String, strict bool) (lang.Value, errors.Error)

GetBindingValue returns the value of its bound identifier whose name is the given name. GetBindingValue is specified in 8.1.1.1.6.

func (*DeclarativeEnvironment) GetThisBinding

func (e *DeclarativeEnvironment) GetThisBinding() (lang.Value, errors.Error)

GetThisBinding is not supported for DeclarativeEnvironment. It will panic.

func (*DeclarativeEnvironment) HasBinding

func (e *DeclarativeEnvironment) HasBinding(n lang.String) bool

HasBinding determines whether the given name is an identifier bound by the record. HasBinding is specified in 8.1.1.1.1.

func (*DeclarativeEnvironment) HasSuperBinding

func (e *DeclarativeEnvironment) HasSuperBinding() bool

HasSuperBinding returns false. HasSuperBinding is specified in 8.1.1.1.9.

func (*DeclarativeEnvironment) HasThisBinding

func (e *DeclarativeEnvironment) HasThisBinding() bool

HasThisBinding returns false. HasThisBinding is specified in 8.1.1.1.8.

func (*DeclarativeEnvironment) InitializeBinding

func (e *DeclarativeEnvironment) InitializeBinding(n lang.String, val lang.Value) errors.Error

InitializeBinding is used to set the bound value of the current binding of the environment with the given name to the given value. An uninitialized binding for the given name must already exist. InitializeBinding is specified in 8.1.1.1.4.

func (*DeclarativeEnvironment) Outer

Outer returns the outer environment of this declarative environment.

func (*DeclarativeEnvironment) SetMutableBinding

func (e *DeclarativeEnvironment) SetMutableBinding(n lang.String, val lang.Value, strict bool) errors.Error

SetMutableBinding attempts to change the bound value of the binding with the given name in this environment to the given new value. If the binding is an immutable binding AND strict is true, a TypeError is raised. If no binding with the given name exists AND strict is true, a ReferenceError is raised. If the binding with the given name is not yet initialized, a ReferenceError is raised. SetMutableBinding is specified in 8.1.1.1.5.

func (*DeclarativeEnvironment) Type

func (e *DeclarativeEnvironment) Type() lang.Type

Type returns lang.TypeInternal.

func (*DeclarativeEnvironment) Value

func (e *DeclarativeEnvironment) Value() interface{}

Value returns the declarative environment itself.

func (*DeclarativeEnvironment) WithBaseObject

func (e *DeclarativeEnvironment) WithBaseObject() lang.Value

WithBaseObject returns Undefined. WithBaseObject is specified in 8.1.1.1.10.

type Environment

type Environment interface {
	lang.Value

	Outer() Environment

	HasBinding(n lang.String) bool
	CreateMutableBinding(n lang.String, deletable bool) errors.Error
	CreateImmutableBinding(n lang.String, strict bool) errors.Error
	InitializeBinding(n lang.String, val lang.Value) errors.Error
	SetMutableBinding(n lang.String, val lang.Value, strict bool) errors.Error
	GetThisBinding() (lang.Value, errors.Error)
	GetBindingValue(n lang.String, strict bool) (lang.Value, errors.Error)
	DeleteBinding(n lang.String) bool
	HasThisBinding() bool
	HasSuperBinding() bool
	WithBaseObject() lang.Value
}

Environment is an abstraction over the different types of environment records used in the specification. Not all functions are supported by all environments. There is an issue suggesting that this abstraction should be improved (#34).

type FunctionEnvironment

type FunctionEnvironment struct {
	*DeclarativeEnvironment

	// Used as 'this' for invocation of the function.
	ThisValue lang.Value
	// If the value is StatusLexical, this function is an
	// arrow function and does not have a local this value.
	ThisBindingStatus Status
	// The function object whose invocation caused this
	// environment to be created.
	FunctionObject *lang.Object
	// If the associated function has 'super' property
	// accesses and is not an arrow function, HomeObject
	// is the object that the function is bound to as a
	// method. The default value for HomeObject is Undefined.
	HomeObject lang.Value // Object or Undefined
	// If this environment was created by the Construct-internal
	// method, NewTarget is the value of the Construct-function's
	// newTarget parameter. Otherwise, this value is Undefined.
	NewTarget lang.Value // Object or Undefined
}

FunctionEnvironment is a declarative environment that is ised to represent the top-level scope of a function and, if the function is not an arrow function, provides a this binding. If a function is not an arrow function and references super, its function environment also contains the state that is ised to perform super method invocations from within the function. FunctionEnvironment is specified in 8.1.1.3.

func NewFunctionEnvironment

func NewFunctionEnvironment(f *lang.Object, newTarget lang.Value) *FunctionEnvironment

NewFunctionEnvironment creates a new function environment for the given function object. The passed function object can either be Undefined or an Object. NewFunctionEnvironment is specified in 8.1.2.4.

func (*FunctionEnvironment) BindThisValue

func (e *FunctionEnvironment) BindThisValue(val lang.Value) (lang.Value, errors.Error)

BindThisValue sets ThisValue and records that it has been initialized. BindThisValue is specified in 8.1.1.3.1.

func (*FunctionEnvironment) GetSuperBase

func (e *FunctionEnvironment) GetSuperBase() lang.Value

GetSuperBase returns the prototype object of the super binding's value. GetSuperBase is specified in 8.1.1.3.5.

func (*FunctionEnvironment) GetThisBinding

func (e *FunctionEnvironment) GetThisBinding() (lang.Value, errors.Error)

GetThisBinding returns the ThisValue of this environment. If it has not been initialized yet, a reference error will be returned. GetThisBinding is specified in 8.1.1.3.4.

func (*FunctionEnvironment) HasSuperBinding

func (e *FunctionEnvironment) HasSuperBinding() bool

HasSuperBinding returns true if and only if this HomeObject is not Undefined. HasSuperBinding is specified in 8.1.1.3.3.

func (*FunctionEnvironment) HasThisBinding

func (e *FunctionEnvironment) HasThisBinding() bool

HasThisBinding returns true if and only if ThisBindingStatus is not StatusLexical. HasThisBinding is specified in 8.1.1.3.2.

type GlobalEnvironment

type GlobalEnvironment struct {
	ObjectRecord      *ObjectEnvironment
	GlobalThisValue   *lang.Object
	DeclarativeRecord *DeclarativeEnvironment
	VarNames          []string
}

GlobalEnvironment is used to represent the outer most scope that is shared by all of the ECMAScript Script elements that are processed in a common realm. A global Environment Record provides the bindings for built-in globals (clause 18), properties of the global object, and for all top-level declarations (13.2.8, 13.2.10) that occur within a Script. A global Environment Record is logically a single record but it is specified as a composite encapsulating an object Environment Record and a declarative Environment Record. The object Environment Record has as its base object the global object of the associated Realm Record. This global object is the value returned by the global Environment Record's GetThisBinding concrete method. The object Environment Record component of a global Environment Record contains the bindings for all built-in globals (clause 18) and all bindings introduced by a FunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration, AsyncGeneratorDeclaration, or VariableStatement contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the declarative Environment Record component of the global Environment Record. Properties may be created directly on a global object. Hence, the object Environment Record component of a global Environment Record may contain both bindings created explicitly by FunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration, AsyncGeneratorDeclaration, or VariableDeclaration declarations and bindings created implicitly as properties of the global object. In order to identify which bindings were explicitly created using declarations, a global Environment Record maintains a list of the names bound using its CreateGlobalVarBinding and CreateGlobalFunctionBinding concrete methods. GlobalEnvironment is specified in 8.1.1.4.

func NewGlobalEnvironment

func NewGlobalEnvironment(globalObj, thisValue *lang.Object) *GlobalEnvironment

NewGlobalEnvironment creates a new global environment with the given global object and the given thisValue as this value. NewGlobalEnvironment is specified in 8.1.2.5.

func (*GlobalEnvironment) CanDeclareGlobalFunction

func (e *GlobalEnvironment) CanDeclareGlobalFunction(n lang.String)

CanDeclareGlobalFunction determines if a corresponding CreateGlobalFunctionBinding call would succeed if called for the same given name. CanDeclareGlobalFunction is specified in 8.1.1.4.16.

func (*GlobalEnvironment) CanDeclareGlobalVar

func (e *GlobalEnvironment) CanDeclareGlobalVar(n lang.String) bool

CanDeclareGlobalVar determines if a corresponding CreateGlobalVarBinding call would succeed if called for the same given name. CanDeclareGlobalVar is specified in 8.1.1.4.15.

func (*GlobalEnvironment) CreateGlobalFunctionBinding

func (e *GlobalEnvironment) CreateGlobalFunctionBinding(n lang.String, val lang.Value, deletable bool)

CreateGlobalFunctionBinding creates and initializes a mutable binding in the associated object Environment Record and records the bound name in the associated [[VarNames]] List. If a binding already exists, it is replaced. CreateGlobalFunctionBinding

func (*GlobalEnvironment) CreateGlobalVarBinding

func (e *GlobalEnvironment) CreateGlobalVarBinding(n lang.String, deletable bool)

CreateGlobalVarBinding creates and initializes a mutable binding in the associated object Environment Record and records the bound name in the associated [[VarNames]] List. If a binding already exists, it is reused and assumed to be initialized. CreateGlobalVarBinding is specified in 8.1.1.4.17.

func (*GlobalEnvironment) CreateImmutableBinding

func (e *GlobalEnvironment) CreateImmutableBinding(n lang.String, strict bool) errors.Error

CreateImmutableBinding creates a new immutable binding for the name n that is uninitialized. A binding must not already exist in this Environment Record for n. If strict is true the new binding is marked as a strict binding. CreateImmutableBinding is specified in 8.1.1.4.3.

func (*GlobalEnvironment) CreateMutableBinding

func (e *GlobalEnvironment) CreateMutableBinding(n lang.String, deletable bool) errors.Error

CreateMutableBinding creates a new mutable binding for the name N that is uninitialized. The binding is created in the associated DeclarativeRecord. A binding for n must not already exist in the DeclarativeRecord. If deletable is true the new binding is marked as being subject to deletion. CreateMutableBinding is specified in 8.1.1.4.2.

func (*GlobalEnvironment) DeleteBinding

func (e *GlobalEnvironment) DeleteBinding(n lang.String) bool

DeleteBinding deletes a binding from thie environment. DeleteBinding can only delete deletable bindings. DeleteBinding is specified in 8.1.1.4.7.

func (*GlobalEnvironment) GetBindingValue

func (e *GlobalEnvironment) GetBindingValue(n lang.String, strict bool) (lang.Value, errors.Error)

GetBindingValue returns the value of its bound identifier whose name is the value of the argument n. If the binding is an uninitialized binding throw a ReferenceError exception. A property named n normally already exists but if it does not or is not currently writable, error handling is determined by the value of struct. GetBindingValue is specified in 8.1.1.4.6.

func (*GlobalEnvironment) GetThisBinding

func (e *GlobalEnvironment) GetThisBinding() (lang.Value, errors.Error)

GetThisBinding returns the GlobalThisValue. GetThisBinding is specified in 8.1.1.4.11.

func (*GlobalEnvironment) HasBinding

func (e *GlobalEnvironment) HasBinding(n lang.String) bool

HasBinding determines if the argument identifier is one of the identifiers bound by the record. HasBinding is specified in 8.1.1.4.1.

func (*GlobalEnvironment) HasLexicalDeclaration

func (e *GlobalEnvironment) HasLexicalDeclaration(n lang.String) bool

HasLexicalDeclaration determines if the argument identifier has a binding in this record that was created using a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. HasLexicalDeclaration is specified in 8.1.1.4.13.

func (*GlobalEnvironment) HasRestrictedGlobalProperty

func (e *GlobalEnvironment) HasRestrictedGlobalProperty(n lang.String) bool

HasRestrictedGlobalProperty determines if the argument identifier is the name of a property of the global object that must not be shadowed by a global lexical binding. HasRestrictedGlobalProperty is specified in 8.1.1.4.14.

func (*GlobalEnvironment) HasSuperBinding

func (e *GlobalEnvironment) HasSuperBinding() bool

HasSuperBinding returns false. HasSuperBinding is specified in 8.1.1.4.9.

func (*GlobalEnvironment) HasThisBinding

func (e *GlobalEnvironment) HasThisBinding() bool

HasThisBinding returns true. HasThisBinding is specified in 8.1.1.4.8.

func (*GlobalEnvironment) HasVarDeclaration

func (e *GlobalEnvironment) HasVarDeclaration(n lang.String) bool

HasVarDeclaration determines if the argument identifier has a binding in this record that was created using a VariableStatement or a FunctionDeclaration. HasVarDeclaration is specified in 8.1.1.4.12.

func (*GlobalEnvironment) InitializeBinding

func (e *GlobalEnvironment) InitializeBinding(n lang.String, val lang.Value) errors.Error

InitializeBinding is used to set the bound value of the current binding of the identifier whose name is the value of the argument n to the value of argument val. An uninitialized binding for n must already exist. InitializeBinding is specified in 8.1.1.4.4.

func (*GlobalEnvironment) Outer

func (e *GlobalEnvironment) Outer() Environment

Outer returns nil.

func (*GlobalEnvironment) SetMutableBinding

func (e *GlobalEnvironment) SetMutableBinding(n lang.String, val lang.Value, strict bool) errors.Error

SetMutableBinding attempts to change the bound value of the current binding of the identifier whose name is the value of the argument n to the value of argument val. If the binding is an immutable binding, a TypeError is thrown if strict is true. A property named n normally already exists but if it does not or is not currently writable, error handling is determined by the value of strict. SetMutableBinding is specified in 8.1.1.4.5.

func (*GlobalEnvironment) Type

func (e *GlobalEnvironment) Type() lang.Type

Type returns TypeInternal.

func (*GlobalEnvironment) Value

func (e *GlobalEnvironment) Value() interface{}

Value returns the GlobalEnvironment itself.

func (*GlobalEnvironment) WithBaseObject

func (e *GlobalEnvironment) WithBaseObject() lang.Value

WithBaseObject returns Undefined. WithBaseObject is specified in 8.1.1.4.10.

type ModuleEnvironment

type ModuleEnvironment struct {
	*DeclarativeEnvironment
}

ModuleEnvironment is a declarative environment that is used to represent the outer scope of an ECMAScript Module. In addition to normal mutable and immutable bindings, module environments also provide immutable import bindings which are bindings that provide indirect access to a target binding that exists in another environment. ModuleEnvironment is specified in 8.1.1.5.

func NewModuleEnvironment

func NewModuleEnvironment(outer Environment) *ModuleEnvironment

NewModuleEnvironment creates a new module environment with the given environment as outer environment.

func (*ModuleEnvironment) CreateImportBinding

func (e *ModuleEnvironment) CreateImportBinding(n lang.String, m interface{}, n2 lang.String)

CreateImportBinding creates a new initialized immutable indirect binding for the name n. A binding must not already exist in this environment for the given name. CreateImportBinding is specified in 8.1.1.5.5.

func (*ModuleEnvironment) GetThisBinding

func (e *ModuleEnvironment) GetThisBinding() lang.Value

GetThisBinding returns Undefined. GetThisBinding is specified in 8.1.1.5.4.

type ObjectEnvironment

type ObjectEnvironment struct {
	// contains filtered or unexported fields
}

ObjectEnvironment is associated with an object called its binding object. An object Environment Record binds the set of string identifier names that directly correspond to the property names of its binding object. Property keys that are not strings in the form of an IdentifierName are not included in the set of bound identifiers. Both own and inherited properties are included in the set regardless of the setting of their [[Enumerable]] attribute. Because properties can be dynamically added and deleted from objects, the set of identifiers bound by an object Environment Record may potentially change as a side-effect of any operation that adds or deletes properties. Any bindings that are created as a result of such a side-effect are considered to be a mutable binding even if the Writable attribute of the corresponding property has the value false. Immutable bindings do not exist for object Environment Records. Object Environment Records created for withwith statements (13.11) can provide their binding object as an implicit this value for use in function calls. The capability is controlled by a withEnvironment Boolean value that is associated with each object Environment Record. By default, the value of withEnvironment is false for any object Environment Record. ObjectEnvironment is specified in 8.1.1.2.

func NewObjectEnvironment

func NewObjectEnvironment(outer Environment, obj *lang.Object) *ObjectEnvironment

NewObjectEnvironment creates a new object environment with the given outer environment for the given object. NewObjectEnvironment is specified in 8.1.2.3.

func (*ObjectEnvironment) CreateImmutableBinding

func (e *ObjectEnvironment) CreateImmutableBinding(n lang.String, strict bool) errors.Error

CreateImmutableBinding is not described by the specification and will panic upon call. CreateImmutableBinding is not specified in 8.1.1.2.3.

func (*ObjectEnvironment) CreateMutableBinding

func (e *ObjectEnvironment) CreateMutableBinding(n lang.String, deletable bool) errors.Error

CreateMutableBinding creates in an Environment Record's associated binding object a property whose name is the String value and initializes it to the value undefined. If Boolean argument D has the value true the new property's [[Configurable]] attribute is set to true; otherwise it is set to false. CreateMutableBinding is specified in 8.1.1.2.2.

func (*ObjectEnvironment) DeleteBinding

func (e *ObjectEnvironment) DeleteBinding(n lang.String) bool

DeleteBinding can only delete bindings that correspond to properties of the environment object whose [[Configurable]] attribute have the value true. DeleteBinding is specified in 8.1.1.2.7.

func (*ObjectEnvironment) GetBindingValue

func (e *ObjectEnvironment) GetBindingValue(n lang.String, strict bool) (lang.Value, errors.Error)

GetBindingValue returns the value of its associated binding object's property whose name is the String value of the argument identifier n. The property should already exist but if it does not the result depends upon the value of the strict argument. GetBindingValue is specified in 8.1.1.2.6.

func (*ObjectEnvironment) GetThisBinding

func (e *ObjectEnvironment) GetThisBinding() (lang.Value, errors.Error)

GetThisBinding is not specified for ObjectEnvironment.

func (*ObjectEnvironment) HasBinding

func (e *ObjectEnvironment) HasBinding(n lang.String) bool

HasBinding determines if its associated binding object has a property whose name is the value of the argument n. HasBinding is specified in 8.1.1.2.1.

func (*ObjectEnvironment) HasSuperBinding

func (e *ObjectEnvironment) HasSuperBinding() bool

HasSuperBinding returns false. HasSuperBinding is specified in 8.1.1.2.9.

func (*ObjectEnvironment) HasThisBinding

func (e *ObjectEnvironment) HasThisBinding() bool

HasThisBinding returns false. HasThisBinding is specified in 8.1.1.2.8.

func (*ObjectEnvironment) InitializeBinding

func (e *ObjectEnvironment) InitializeBinding(n lang.String, val lang.Value) errors.Error

InitializeBinding is used to set the bound value of the current binding of the identifier whose name is the value of the argument n to the value of argument val. An uninitialized binding for n must already exist. InitializeBinding is specified in 8.1.1.2.4.

func (*ObjectEnvironment) IsGlobalEnvironment

func (e *ObjectEnvironment) IsGlobalEnvironment() bool

IsGlobalEnvironment returns false.

func (*ObjectEnvironment) IsModuleEnvironment

func (e *ObjectEnvironment) IsModuleEnvironment() bool

IsModuleEnvironment returns false.

func (*ObjectEnvironment) Outer

func (e *ObjectEnvironment) Outer() Environment

Outer returns the outer environment of this object environment.

func (*ObjectEnvironment) SetMutableBinding

func (e *ObjectEnvironment) SetMutableBinding(n lang.String, val lang.Value, strict bool) errors.Error

SetMutableBinding attempts to set the value of the Environment Record's associated binding object's property whose name is the value of the argument n to the value of argument val. A property named n normally already exists but if it does not or is not currently writable, error handling is determined by the value of strict. SetMutableBinding is specified in 8.1.1.2.5.

func (*ObjectEnvironment) Type

func (e *ObjectEnvironment) Type() lang.Type

Type returns TypeInternal.

func (*ObjectEnvironment) Value

func (e *ObjectEnvironment) Value() interface{}

Value returns the ObjectEnvironment itself.

func (*ObjectEnvironment) WithBaseObject

func (e *ObjectEnvironment) WithBaseObject() lang.Value

WithBaseObject return Undefined as their WithBaseObject unless their withEnvironment flag is true. WithBaseObject is specified in 8.1.1.2.10.

type Reference

type Reference struct {
	// contains filtered or unexported fields
}

Reference is a resolved name or property binding. A Reference consists of three components, the base value component, the referenced name component, and the Boolean-valued strict reference flag. The base value component is either undefined, an Object, a Boolean, a String, a Symbol, a Number, or an Environment Record. A base value component of undefined indicates that the Reference could not be resolved to a binding. The referenced name component is a String or Symbol value. A Super Reference is a Reference that is used to represent a name binding that was expressed using the super keyword. A Super Reference has an additional thisValue component, and its base value component will never be an Environment Record. Reference is specified in 6.2.4.

func GetIdentifierReference

func GetIdentifierReference(env lang.InternalValue, n lang.String, strict bool) *Reference

GetIdentifierReference returns a named reference with n as the name. If strict is true, the reference will be a strict reference. The given environment must be of type Environment or Null. If the environment does not have a binding with the given name, its outer environment is used. GetIdentifierReference is specified in 8.1.2.1.

func NewReference

func NewReference(n lang.StringOrSymbol, base lang.Value, strict bool) *Reference

NewReference creates a new named reference with the given name and the given base value. The created reference is a strict reference if the strict argument is true.

func NewSuperReference

func NewSuperReference(n lang.StringOrSymbol, base, this lang.Value, strict bool) *Reference

NewSuperReference creates a new super reference with the given name and the given base and this value. The created super reference is a common reference with a set this value. The created reference is a strict reference if the strict argument is true.

func (*Reference) GetBase

func (r *Reference) GetBase() lang.Value

GetBase returns the base component value of this reference. GetBase is specified in 6.2.4.1.

func (*Reference) GetReferencedName

func (r *Reference) GetReferencedName() lang.StringOrSymbol

GetReferencedName returns the name of this reference. GetReferencedName is specified in 6.2.4.2.

func (*Reference) GetThisValue

func (r *Reference) GetThisValue() lang.Value

GetThisValue returns the thisValue of this reference. If this reference is not a super reference and thus does not have a thisValue, the base of this reference is returned instead. GetThisValue is specified in 6.2.4.10.

func (*Reference) GetValue

func (r *Reference) GetValue() (lang.Value, errors.Error)

GetValue returns the value of this reference. GetValue is specified in 6.2.4.8.

func (*Reference) HasPrimitiveBase

func (r *Reference) HasPrimitiveBase() bool

HasPrimitiveBase returns true if and only if the type of this references base component is one of [Boolean, String, Symbol, Number]. HasPrimitiveBase is specified in 6.2.4.4.

func (*Reference) InitializeReferencedBinding

func (r *Reference) InitializeReferencedBinding(val lang.Value) errors.Error

InitializeReferencedBinding initializes this reference in its environment with the given value. InitializeReferencedBinding is specified in 6.2.4.11.

func (*Reference) IsPropertyReference

func (r *Reference) IsPropertyReference() bool

IsPropertyReference returns true if and only if the type of this referecens base component is Object or this reference has a primitive base (HasPrimitiveBase). IsPropertyReference is specified in 6.2.4.5.

func (*Reference) IsStrictReference

func (r *Reference) IsStrictReference() bool

IsStrictReference is used to determine if this reference is a strict reference. IsStrictReference is specified in 6.2.4.3.

func (*Reference) IsSuperReference

func (r *Reference) IsSuperReference() bool

IsSuperReference is used to determine if this reference has a thisValue. IsSuperReference will return true even the thisValue is Null or Undefined, since the thisValue is present. IsSuperReference is specified in 6.2.4.7.

func (*Reference) IsUnresolvableReference

func (r *Reference) IsUnresolvableReference() bool

IsUnresolvableReference is used to determine if this references base component is Undefined. IsUnresolvableReference is specified in 6.2.4.6.

func (*Reference) PutValue

func (r *Reference) PutValue(lang.Value) errors.Error

PutValue sets the value of this reference to the given one. PutValue is specified in 6.2.4.9.

type Status

type Status string

Status represents the status of a binding. Can either be 'lexical', 'initialized', 'uninitialized'.

const (
	StatusLexical       Status = "lexical"
	StatusInitialized   Status = "initialized"
	StatusUninitialized Status = "uninitialized"
)

Available binding statuses.

Jump to

Keyboard shortcuts

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