class Kaze::Environment
- Kaze::Environment
- Reference
- Object
Overview
Environment where variable bindings are to be stored.
Defined in:
environment.crConstructors
-
.new(enclosing : Environment | Nil = nil)
Initialize an environment instance.
Instance Method Summary
-
#ancestor(distance : Int32) : Environment
Returns the ancestor environment at a particular distance of scopes away.
-
#assign(name : Token, value : VG)
Assigns a value to an existing variable.
-
#assign_at(distance : Int32, name : Token, value : VG)
Does the same thing as
Environment#assign
, except from a specific ancestor environment. -
#define(name : String, value : VG)
Defines a new variable binding.
-
#enclosing : Kaze::Environment?
The environment enclosing a new instance.
-
#enclosing=(enclosing : Nil | Kaze::Environment)
The environment enclosing a new instance.
-
#get(name : Token) : VG
Returns the value of the variable matching
name
's lexeme. -
#get_at(distance : Int32, name : String)
Does the same thing as
Environment#get
, except from a specific ancestor environment. -
#values : Hash(String, Bool | Float64 | Kaze::Callable | Kaze::Instance | String | Nil)
The values in the environment.
-
#values=(values : Hash(String, Bool | Float64 | Kaze::Callable | Kaze::Instance | String | Nil))
The values in the environment.
Constructor Detail
Initialize an environment instance.
The enclosing environment is nil
if no argument is provided, indicating that that environment is global.
Instance Method Detail
Returns the ancestor environment at a particular distance of scopes away.
Assigns a value to an existing variable. If the enclosing environment exists, it assigns the variable present there. Raises an exception if the requested variable doesn't exist.
Does the same thing as Environment#assign
, except from a specific ancestor environment.
Defines a new variable binding.
If the variable name is _
, no definition is done.
Returns the value of the variable matching name
's lexeme.
If an enclosing environment exists, it fetches the variable from there.
Raises an exception if the requested variable has a value of nil, or if it doesn't exist.
Does the same thing as Environment#get
, except from a specific ancestor environment.
The values in the environment.
The values in the environment.