blob: 983a10d327cea917e8ead30bb8fd66847437c1a3 (
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
|
#ifndef BINDINGS_HPP
#define BINDINGS_HPP
#include <cstdint>
#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;
int32_t stack_position;
};
// stores bindings for the current scope and where they are in the stack
class VariableStackBindings
{
private:
std::map<std::string, DeclarationData> bindings;
int32_t stack_counter;
public:
VariableStackBindings();
void insertBinding(std::string id, TypePtr type, int32_t stack_position);
void increaseStackPosition();
int32_t getCurrentStackPosition() const;
int32_t getStackPosition(const std::string& id) const;
bool bindingExists(const std::string& id) const;
};
#endif
|