29 lines
783 B
C++

#ifndef ENVIRONMENT_HH
#define ENVIRONMENT_HH
#include "../tokenizer.hh"
#include <memory>
#include <string>
#include <unordered_map>
struct Environment {
Environment() : enclosing{nullptr}, values{} {}
Environment(std::shared_ptr<Environment> enclosing) : enclosing{enclosing}, values{} {}
Environment(const Environment &other);
Environment(Environment &&other) noexcept;
Environment &operator=(const Environment &other);
Environment &operator=(Environment &&other) noexcept;
~Environment() = default;
void define(const std::string &name, const Object &value);
void assign(const Token &name, const Object &value);
Object get(const Token &name);
private:
std::shared_ptr<Environment> enclosing;
std::unordered_map<std::string, Object> values;
};
#endif