-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionEntry.cpp
More file actions
66 lines (53 loc) · 1.45 KB
/
FunctionEntry.cpp
File metadata and controls
66 lines (53 loc) · 1.45 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
#include "FunctionEntry.h"
#include <sstream>
string FunctionEntry::signatureString()
{
std::stringstream ss;
for (std::tuple<string, string, vector<int>> parameter : parameterVarList) {
ss << std::get<0>(parameter);
for (int arrayInd : std::get<2>(parameter)) {
if (arrayInd == -1) {
ss << "[]";
}
else {
ss << "[" + std::to_string(arrayInd) + "]";
}
}
ss << ", ";
}
return ss.str();
}
FunctionEntry::FunctionEntry()
{
}
string FunctionEntry::toString()
{
return "function-" + name + "-" + signatureString();
}
string FunctionEntry::toDotString()
{
return "<TR><TD>" + name + "</TD><TD>function</TD><TD>" + returnType + ":" + signatureString() + "</TD><TD>" + std::to_string(computeSize()) + "</TD><TD>" + std::to_string(offset) + "</TD><TD PORT=\"" + "function-" + name + "-" + signatureString() + "\">+</TD></TR>\n";
}
bool FunctionEntry::compare(FunctionEntry* e)
{
if (name == e->name && returnType == e->returnType && parameterVarList.size() == e->parameterVarList.size()) {
bool fullMatch = true;
for (int i = 0; i < parameterVarList.size(); i++) {
auto t1 = parameterVarList[i];
auto t2 = e->parameterVarList[i];
if (!(std::get<0>(t1) == std::get<0>(t2) && std::get<2>(t1).size() == std::get<2>(t2).size())) {
fullMatch = false;
}
}
return fullMatch;
}
return false;
}
int FunctionEntry::computeSize()
{
int baseSize = 0;
if (link != nullptr) {
baseSize = link->computeSize();
}
return baseSize;
}