Scope
A scope is the most basic interpretation class. You can think of it as a glorified hashmap which can inherit. It's structure is:
What is each part?:
scope
: a hashmap. The key is the variable name, the value is the value of the variable (this is usually aCheddarVariable
, described later).inheritance chain
: this is either another Scope class, ornull
. If this exists, itsscope
will also be navigated, acting as inheritance. This is so the class being inherited from is modified itself, rather than a copy of it.interface
: this provides a very raw interface forget
ting a variable,set
ting a variable, or checking if ithas
a variable. These can be overwritten, but these methods are not to be confused with getters and setters.
All together this class can implement scopes. Here's an (psuedo-code) example of what is called when (the path the program takes is highlighted with +
):
Last updated