Functional-lang  0.0
An example functional programming language
Public Member Functions | Public Attributes | List of all members
Environment Class Reference

Environment for accessing variables. More...

#include <syntax.hpp>

Inheritance diagram for Environment:
GCObj

Public Member Functions

 Environment (GCMain &gc, Lexer *lexer=nullptr, Environment *parent=nullptr)
 
bool contains (const std::string &name) const noexcept
 
const Expr * get (const std::string &name) const noexcept
 
const Expr * currentGet (const std::string &name) const noexcept
 
virtual void mark (GCMain &gc) noexcept override
 If not marked mark itself and children.
 
std::map< std::string, Expr * > & getVariables () noexcept
 
Environment * getParent () const noexcept
 
- Public Member Functions inherited from GCObj
 GCObj (GCMain &main) noexcept
 Initialize as not marked.
 
virtual bool isMarked (GCMain &main) const noexcept
 

Public Attributes

Lexer * lexer
 
std::vector< Expr * > ctx
 Context to store e.g. stack variables.
 

Additional Inherited Members

- Protected Member Functions inherited from GCObj
virtual void markSelf (GCMain &main)
 Marks itself.
 

Detailed Description

Environment for accessing variables.

Member Function Documentation

◆ contains()

bool Environment::contains ( const std::string &  name) const
noexcept
Returns
Returns name if in environment, nullptr if not.

◆ currentGet()

const Expr* Environment::currentGet ( const std::string &  name) const
noexcept
Returns
Returns associated expression (to name), nullptr if not found. But only looks in current scope/environment, not in parent.

◆ get()

const Expr* Environment::get ( const std::string &  name) const
noexcept
Returns
Returns associated expression (to name). nullptr if not found.

◆ getParent()

Environment* Environment::getParent ( ) const
inlinenoexcept
Returns
Returns parent of environment/scope. May be nullptr.

The documentation for this class was generated from the following file: