-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.hh
executable file
·120 lines (98 loc) · 2.75 KB
/
node.hh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef __NODE_H_INCLUDED__
#define __NODE_H_INCLUDED__
#include <iostream>
#include <vector>
#include "pattern.hh"
/**
* PMC Mapping = Predicate Mode Constraint Mapping *
*/
class BNode;
class PmcMapping{
private:
int childLocation;
Operand op;
public:
enum Type { pmc, mode, predicate, constraint };
int getChildLocation () { return childLocation; }
Operand getOperand () { return op; }
void setChildLocation (int cl) { childLocation = cl; }
void setPmc (Operand o) { op = o; }
Type getType () { return type; }
PmcMapping (int cL, Type t, Operand o) {
childLocation = cL;
op = o;
type = t;
}
private:
Type type;
};
class Node {
private:
static unsigned int count;
bool leafNode;
std::vector<Node*> children;
std::string name;
std::string mode;
unsigned int nodeId;
Node* parent;
std::vector<PmcMapping> pmcReplacements;
static const std::string DUMMYNODE;
public:
BNode* container;
Node (std::string name, bool leafNode);
Node (std::string name, std::string mode, bool leafNode);
~Node ();
std::string getName () const { return name; }
void setName (std::string n) { name = n; }
bool isLeafNode () { return leafNode; }
void addChild (Node* node);
void replaceNode (Node *node, std::vector<int>* position);
void replaceMode (std::string m, std::vector<int>* position);
void replacePmc (Operand op, std::vector<int>* position);
void replacePredicate (Operand op, std::vector<int>* position);
void replaceConstraint (Operand op, std::vector<int>* position);
void replaceSingleNode (Node *node, int position);
/* Temporary stub names should be recieved from
* srtl-driver */
int searchKnownNames (std::string nameToSearch);
void printChildren ();
void traverseTree (Node* tn = 0);
int traverseTree (std::vector<Operand>* operands, Node* tn = 0);
std::vector<Node*> getChildren();
static void setCounter(int aCounter){
count = aCounter;
}
void setId(int id){
nodeId = id;
}
int getId(){
return nodeId;
}
void setParent(Node* aNode){
parent = aNode;
}
Node* getParent(){
return parent;
}
void setMode (std::string m){
mode = m;
}
void addPmcReplacement(PmcMapping pm) {
pmcReplacements.push_back (pm);
}
PmcMapping getPmcMapping (unsigned int i) {
if (i < pmcReplacements.size ()) {
return pmcReplacements[i];
}else {
// TODO RETURN ERROR:
return pmcReplacements[0];
}
}
std::vector<PmcMapping> getPmcMappings(){
return pmcReplacements;
}
std::string getMode(){
return mode;
}
};
#endif