blob: 4315407e0c87f315e9e0ba5fdbd287a65cb1f5aa (
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
47
48
|
#include "bindings.hpp"
// VariableStackBindings definition
VariableStackBindings::VariableStackBindings()
: stack_counter(4)
{}
void VariableStackBindings::insertBinding(std::string id, TypePtr type, int32_t stack_position)
{
DeclarationData decl_data;
decl_data.type = type;
decl_data.stack_position = stack_position;
bindings.insert(std::pair<std::string, DeclarationData>(id, decl_data));
}
void VariableStackBindings::increaseStackPosition()
{
stack_counter += 4;
}
int32_t VariableStackBindings::getCurrentStackPosition() const
{
return stack_counter;
}
int32_t VariableStackBindings::getStackPosition(const std::string &id) const
{
auto binding = bindings.find(id);
if(binding != bindings.end())
return (*binding).second.stack_position;
else return 0;
}
bool VariableStackBindings::bindingExists(const std::string &id) const
{
auto binding = bindings.find(id);
if(binding == bindings.end())
return false;
else
return true;
}
|