-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTreeNode.cpp
More file actions
114 lines (91 loc) · 3.13 KB
/
Copy pathTreeNode.cpp
File metadata and controls
114 lines (91 loc) · 3.13 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
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
// Copyright (c) 2014 Rusty Wagner
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
#include "TreeNode.h"
using namespace std;
TreeNode::TreeNode(TreeNodeClass cls): m_class(cls), m_sizeFlags(REG_MATCH_ALL)
{
}
TreeNode::TreeNode(const TreeNode& copy)
{
m_class = copy.m_class;
m_name = copy.m_name;
m_typeName = copy.m_typeName;
m_sizeFlags = copy.m_sizeFlags;
for (vector< Ref<TreeNode> >::const_iterator i = copy.m_children.begin(); i != copy.m_children.end(); ++i)
m_children.push_back(new TreeNode(**i));
}
TreeNode* TreeNode::CreateRegNode(const std::string& name, const std::string& typeName, uint32_t sizeFlags)
{
TreeNode* result = new TreeNode(NODE_REG);
result->SetName(name);
result->SetTypeName(typeName);
result->SetSizeFlags(sizeFlags);
return result;
}
TreeNode* TreeNode::CreateLoadNode(TreeNode* src, uint32_t sizeFlags)
{
TreeNode* result = new TreeNode(NODE_LOAD);
result->SetSizeFlags(sizeFlags);
result->AddChildNode(src);
return result;
}
TreeNode* TreeNode::CreateStoreNode(TreeNode* dest, TreeNode* val, uint32_t sizeFlags)
{
TreeNode* result = new TreeNode(NODE_STORE);
result->SetSizeFlags(sizeFlags);
result->AddChildNode(dest);
result->AddChildNode(val);
return result;
}
TreeNode* TreeNode::CreateNode(TreeNodeClass cls)
{
TreeNode* result = new TreeNode(cls);
return result;
}
TreeNode* TreeNode::CreateNode(TreeNodeClass cls, TreeNode* a)
{
TreeNode* result = new TreeNode(cls);
result->AddChildNode(a);
return result;
}
TreeNode* TreeNode::CreateNode(TreeNodeClass cls, TreeNode* a, TreeNode* b)
{
TreeNode* result = new TreeNode(cls);
result->AddChildNode(a);
result->AddChildNode(b);
return result;
}
TreeNode* TreeNode::CreateNode(TreeNodeClass cls, TreeNode* a, TreeNode* b, TreeNode* c)
{
TreeNode* result = new TreeNode(cls);
result->AddChildNode(a);
result->AddChildNode(b);
result->AddChildNode(c);
return result;
}
TreeNode* TreeNode::CreateNode(TreeNodeClass cls, TreeNode* a, TreeNode* b, TreeNode* c, TreeNode* d)
{
TreeNode* result = new TreeNode(cls);
result->AddChildNode(a);
result->AddChildNode(b);
result->AddChildNode(c);
result->AddChildNode(d);
return result;
}