logo
pub trait EnvironmentRecordTrait: Debug + Trace + Finalize {
Show 22 methods fn has_binding(&self, name: &str, context: &mut Context) -> JsResult<bool>; fn create_mutable_binding(
        &self,
        name: &str,
        deletion: bool,
        allow_name_reuse: bool,
        context: &mut Context
    ) -> JsResult<()>; fn create_immutable_binding(
        &self,
        name: &str,
        strict: bool,
        context: &mut Context
    ) -> JsResult<()>; fn initialize_binding(
        &self,
        name: &str,
        value: JsValue,
        context: &mut Context
    ) -> JsResult<()>; fn set_mutable_binding(
        &self,
        name: &str,
        value: JsValue,
        strict: bool,
        context: &mut Context
    ) -> JsResult<()>; fn get_binding_value(
        &self,
        name: &str,
        strict: bool,
        context: &mut Context
    ) -> JsResult<JsValue>; fn delete_binding(&self, name: &str, context: &mut Context) -> JsResult<bool>; fn has_this_binding(&self) -> bool; fn get_this_binding(&self, context: &mut Context) -> JsResult<JsValue>; fn has_super_binding(&self) -> bool; fn with_base_object(&self) -> Option<JsObject>; fn get_outer_environment_ref(&self) -> Option<&Environment>; fn set_outer_environment(&mut self, env: Environment); fn get_environment_type(&self) -> EnvironmentType; fn get_outer_environment(&self) -> Option<Environment> { ... } fn recursive_get_this_binding(
        &self,
        context: &mut Context
    ) -> JsResult<JsValue> { ... } fn recursive_create_mutable_binding(
        &self,
        name: &str,
        deletion: bool,
        scope: VariableScope,
        context: &mut Context
    ) -> JsResult<()> { ... } fn recursive_create_immutable_binding(
        &self,
        name: &str,
        deletion: bool,
        scope: VariableScope,
        context: &mut Context
    ) -> JsResult<()> { ... } fn recursive_set_mutable_binding(
        &self,
        name: &str,
        value: JsValue,
        strict: bool,
        context: &mut Context
    ) -> JsResult<()> { ... } fn recursive_initialize_binding(
        &self,
        name: &str,
        value: JsValue,
        context: &mut Context
    ) -> JsResult<()> { ... } fn recursive_has_binding(
        &self,
        name: &str,
        context: &mut Context
    ) -> JsResult<bool> { ... } fn recursive_get_binding_value(
        &self,
        name: &str,
        context: &mut Context
    ) -> JsResult<JsValue> { ... }
}
Expand description

https://tc39.es/ecma262/#sec-environment-records

In the ECMAScript specification Environment Records are hierachical and have a base class with abstract methods. In this implementation we have a trait which represents the behaviour of all EnvironmentRecord types.

Required Methods

Determine if an Environment Record has a binding for the String value N. Return true if it does and false if it does not.

Create a new but uninitialized mutable binding in an Environment Record. The String value N is the text of the bound name. If the Boolean argument deletion is true the binding may be subsequently deleted.

  • allow_name_reuse - specifies whether or not reusing binding names is allowed.

Most variable names cannot be reused, but functions in JavaScript are allowed to have multiple paraments with the same name.

Create a new but uninitialized immutable binding in an Environment Record. The String value N is the text of the bound name. If strict is true then attempts to set it after it has been initialized will always throw an exception, regardless of the strict mode setting of operations that reference that binding.

Set the value of an already existing but uninitialized binding in an Environment Record. The String value N is the text of the bound name. V is the value for the binding and is a value of any ECMAScript language type.

Set the value of an already existing mutable binding in an Environment Record. The String value name is the text of the bound name. value is the value for the binding and may be a value of any ECMAScript language type. S is a Boolean flag. If strict is true and the binding cannot be set throw a TypeError exception.

Returns the value of an already existing binding from an Environment Record. The String value N is the text of the bound name. S is used to identify references originating in strict mode code or that otherwise require strict mode reference semantics.

Delete a binding from an Environment Record. The String value name is the text of the bound name. If a binding for name exists, remove the binding and return true. If the binding exists but cannot be removed return false. If the binding does not exist return true.

Determine if an Environment Record establishes a this binding. Return true if it does and false if it does not.

Return the this binding from the environment

Determine if an Environment Record establishes a super method binding. Return true if it does and false if it does not.

If this Environment Record is associated with a with statement, return the with object. Otherwise, return None.

Get the next environment up

Set the next environment up

Get the type of environment this is

Provided Methods

Return the this binding from the environment or try to get it from outer environments

Create mutable binding while handling outer environments

Create immutable binding while handling outer environments

Set mutable binding while handling outer environments

Initialize binding while handling outer environments

Check if a binding exists in current or any outer environment

Retrieve binding from current or any outer environment

Implementors