blob: 512e426888d5d2ca195d1b0544c10e787aa91258 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#ifndef BINDINGS_HPP
#define BINDINGS_HPP
#include <map>
#include <memory>
#include <string>
class Type;
typedef std::shared_ptr<Type> TypePtr;
// struct containing information on the variable declaration
struct DeclarationData
{
TypePtr type;
int stack_position;
};
// stores bindings for the current scope and where they are in the stack
class VariableStackBindings
{
private:
std::map<std::string, DeclarationData> bindings_;
int stack_counter_;
unsigned expression_stack_;
public:
VariableStackBindings();
void insertBinding(std::string id, TypePtr type, int32_t stack_position);
void increaseStackPosition();
void resetExpressionStack();
void nextExpressionStackPosition();
int currentStackPosition() const;
int stackPosition(const std::string& id) const;
unsigned currentExpressionStackPosition() const;
bool bindingExists(const std::string& id) const;
};
#endif
|