Constructor
new Environment(parent)
Creates an instance of Environment.
Parameters:
Name | Type | Description |
---|---|---|
parent |
Object | Environment | extended env |
- Source:
Methods
def(name, value) → {any}
this function creates (or shadows, or overwrites) a variable in the current scope
Parameters:
Name | Type | Description |
---|---|---|
name |
String | variable |
value |
any | variable's value |
- Source:
Returns:
value
- Type
- any
extend() → {Environment}
to create a subscope
- Source:
Returns:
extended env
- Type
- Environment
get(name) → {any}
to get the current value of a variable
Parameters:
Name | Type | Description |
---|---|---|
name |
String | variable |
- Source:
Returns:
value
- Type
- any
lookup(name) → {Environment}
to find the scope where the variable
with the given name is defined
Parameters:
Name | Type | Description |
---|---|---|
name |
String | variable |
- Source:
Returns:
scope
- Type
- Environment
set(name, value) → {any}
to set the value of a variable. This needs to lookup
the actual scope where the variable is defined.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | varaible |
value |
any | vraible's value |
- Source:
Returns:
value
- Type
- any