-
Notifications
You must be signed in to change notification settings - Fork 0
/
variable.h
50 lines (37 loc) · 1.53 KB
/
variable.h
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
49
50
//
// Created by erthax on 14.01.2021.
//
#ifndef CULTIVATED_COMPILER_VARIABLE_H
#define CULTIVATED_COMPILER_VARIABLE_H
#include <iostream>
#include <utility>
enum eVariableType {
ARRAY, SINGLE, CONSTANT, ITERATOR
};
struct Variable {
// Single variable declaration
Variable(uint tAddress, std::string tPid) : address(tAddress),
pid(std::move(tPid)) { this->variableType = eVariableType::SINGLE; }
// Array variable declaration
Variable(uint tAddress, std::string tPid, uint tStart, uint tEnd) : address(tAddress), pid(std::move(tPid)),
start(tStart),
end(tEnd) { this->variableType = eVariableType::ARRAY; }
// Constant variable declaration
Variable(uint tAddress, std::string tPid, eVariableType tType) : address(tAddress),
pid(tPid),
variableType(tType) {}
eVariableType variableType;
uint address;
std::string pid;
// needed for arrays
uint start{0};
uint end{0};
// needed for costants
uint value{0}; //TODO probably should be deleted, we will se if its needed, same with CONSTANT type
// needed for error checks
bool bInitialized{false};
bool bDeclared{true};
// need for iterator
bool isInsideLoop{true};
};
#endif //CULTIVATED_COMPILER_VARIABLE_H