-
Notifications
You must be signed in to change notification settings - Fork 0
/
Computer.hpp
61 lines (60 loc) · 2.04 KB
/
Computer.hpp
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
51
52
53
54
55
56
57
58
59
60
61
#ifndef COMPUTER_HPP
# define COMPUTER_HPP
#include "Symbol.hpp"
#include "utils.hpp"
#include <array>
class Computer
{
public:
static Computer& init()
{
return single_instance;
}
bool isDeclaredFunction(string func) const;
bool isDeclaredVariable(string var) const;
bool canAdd(int type1, int type2);
bool canSubtract(int type1, int type2);
bool canMultiply(int type1, int type2);
bool canDivide(int type1, int type2);
bool canMod(int type1, int type2);
bool canPow(int type1, int type2);
void addVariable(string name, Symbol* value);
void addFunction(string name, Symbol* value);
void getVariables() const;
void getFunctions() const;
void clearVars();
void clearFunctions();
Symbol* getFunctionSymbol(string func);
Symbol* getVariableSymbol(string var);
wchar_t getExponent(int e) const;
wstring getWithRep() const;
string displayRoot() const;
string getSyntaxErrorFlag() const;
string getErrorFlag() const;
string getSemanticErrorFlag() const;
string getType(int type) const;
bool isSystem(string const &c) const;
void printError(string const &tmp) const;
void addAllocatedAddress(void* ptr);
void removeAllocatedAddress(void* ptr);
void freeMemory();
wstring_convert<std::codecvt_utf8<wchar_t>,wchar_t> convert;
stringstream history;
void getHistory() const;
private:
Computer() {}
static Computer single_instance;
map<string, Symbol*> _internalFunctions;
map<string, Symbol*> _declaredVariables;
map<string, Symbol*> _declaredFunctions;
array<void*,1000000> allocatedAddresses;
int _pos;
static int addition[5][5];
static int subtraction[5][5];
static int multiplication[5][5];
static int division[5][5];
static int modulo[5][5];
static int power[5][5];
static wstring utfExp;
};
#endif