-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.hpp
More file actions
29 lines (28 loc) · 805 Bytes
/
environment.hpp
File metadata and controls
29 lines (28 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef ENVIRONMENT_HPP
#define ENVIRONMENT_HPP
#include "token.cpp"
#include "deferred_ptr.hpp"
#include <any>
#include <string>
#include <unordered_map>
#include <memory>
class environment {
std::unordered_map<std::string, std::any> values;
public:
deferred_ptr<environment> enclosing;
environment(deferred_ptr<environment> &enclosing) : enclosing(enclosing) {}
environment(const environment &other)
{
this->values = other.values;
this->enclosing = other.enclosing;
}
environment() {};
void assign(token name, std::any value);
void define(std::string , std::any);
std::any get(token &);
std::any get_at(int distance, std::string name);
void assign_at(int distance, std::string name, std::any value);
environment &ancestor(int distance);
void operator=(const environment &);
};
#endif