blob: 1104bb8fddaf607285f26109aa93441ca72eeef7 (
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
|
#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_;
int expression_stack_;
public:
VariableStackBindings();
void insertBinding(std::string id, TypePtr type, int stack_position);
void increaseStackPosition();
void setStackPosition(int stack_counter);
void nextExpressionStackPosition();
int currentStackPosition() const;
int stackPosition(const std::string& id) const;
int currentExpressionStackPosition() const;
bool bindingExists(const std::string& id) const;
};
#endif
|