-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.cpp
More file actions
73 lines (60 loc) · 1.3 KB
/
Copy pathtypes.cpp
File metadata and controls
73 lines (60 loc) · 1.3 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
#include "types.h"
#include <string>
bool contains(const std::string arr[], std::string str) {
int i = 0;
while (arr[i] != "") {
if ( arr[i] == str)
return true;
i++;
}
return false;
}
bool isWhitespace(char c) {
return c == ' ' || c == '\t' || c == '\n';
}
bool isOperand(char c) {
return operands.find(c,0) != operands.npos;
}
bool isPunct(char c) {
return punctuations.find(c,0) != punctuations.npos;
}
bool isRegister(std::string str) {
return contains(registers, str);
}
bool isJmpInstr(std::string str) {
return contains(jumps, str);
}
bool isKeyword(std::string str) {
return contains(keywords, str);
}
bool isConversionKword(std::string str) {
return contains(conversionKwords, str);
}
bool isLoaded(Type t) {
return t == NUM || t == REG;
}
bool isAdditive(std::string str) {
return str == "+" || str == "-";
}
std::string toRealRegister(std::string reg) {
int i = 0;
while (registers[i] != "") {
if (registers[i] == reg)
return registers32[i];
i++;
}
return "";
}
std::string toRealRegister(std::string reg, int size) {
int i = 0;
while (registers[i] != "") {
if (registers[i] == reg) {
if (size == 8) return registers64[i];
if (size == 4) return registers32[i];
if (size == 2) return registers16[i];
if (size == 1) return registers8[i];
}
i++;
}
return "";
}