Revision | aba28c7a09dcd0a89f1553aca63a956483c7a825 (tree) |
---|---|
Time | 2020-11-20 22:00:33 |
Author | dhrname <dhrname@user...> |
Commiter | dhrname |
Add this pointer
@@ -4,7 +4,7 @@ NODEBUGMODE = -std=c++20 | ||
4 | 4 | SHELL = /bin/sh |
5 | 5 | |
6 | 6 | |
7 | -all : main joestar.exe | |
7 | +all : joestar.exe | |
8 | 8 | .PHONY : all |
9 | 9 | |
10 | 10 |
@@ -35,9 +35,10 @@ public: | ||
35 | 35 | virtual Node* getPrev() = 0; |
36 | 36 | virtual Node* getFirstChild() = 0; |
37 | 37 | virtual Node* getLastChild() = 0; |
38 | + virtual Node* removeChild(Node*) = 0; | |
38 | 39 | virtual Node* insertBefore(Node*) = 0; |
39 | 40 | virtual Node* appendChild(Node*) = 0; |
40 | - virtual bool isNode() const = 0; | |
41 | + virtual bool isNode() = 0; | |
41 | 42 | }; |
42 | 43 | |
43 | 44 | /*空のノードクラス*/ |
@@ -49,9 +50,10 @@ public: | ||
49 | 50 | Node* getPrev(){return this;}; |
50 | 51 | Node* getFirstChild(){return this;}; |
51 | 52 | Node* getLastChild(){return this;}; |
53 | + Node* removeChild(Node*){return this;}; | |
52 | 54 | Node* insertBefore(Node*){return this;}; |
53 | 55 | Node* appendChild(Node*){return this;}; |
54 | - bool isNode() const | |
56 | + bool isNode() | |
55 | 57 | { |
56 | 58 | return false; |
57 | 59 | } |
@@ -61,7 +63,7 @@ Node* const emptynode = new EmptyNode(); | ||
61 | 63 | |
62 | 64 | /*BaseNodeの基底クラス |
63 | 65 | * Node抽象クラスに対する内部実装*/ |
64 | -class BaseNode: public Node | |
66 | +class BaseNode: public EmptyNode | |
65 | 67 | { |
66 | 68 | private: |
67 | 69 | Node* parentNode; |
@@ -86,7 +88,15 @@ public: | ||
86 | 88 | virtual void setPrev(Node* node); |
87 | 89 | virtual void setFirstChild(Node* node); |
88 | 90 | virtual void setLastChild(Node* node); |
89 | - bool isNode() | |
91 | + virtual Node* getParent(); | |
92 | + virtual Node* getNext(); | |
93 | + virtual Node* getPrev(); | |
94 | + virtual Node* getFirstChild(); | |
95 | + virtual Node* getLastChild(); | |
96 | + virtual Node* removeChild(Node*); | |
97 | + virtual Node* insertBefore(Node*); | |
98 | + virtual Node* appendChild(Node*); | |
99 | + virtual bool isNode() | |
90 | 100 | { |
91 | 101 | return true; |
92 | 102 | } |
@@ -95,24 +105,57 @@ public: | ||
95 | 105 | |
96 | 106 | |
97 | 107 | void BaseNode::setParent(Node* node){ |
98 | - parentNode = node; | |
108 | + this->parentNode = node; | |
99 | 109 | } |
100 | 110 | void BaseNode::setNext(Node* node){ |
101 | - nextSibling = node; | |
111 | + this->nextSibling = node; | |
102 | 112 | } |
103 | 113 | void BaseNode::setPrev(Node* node){ |
104 | - previousSibling = node; | |
114 | + this->previousSibling = node; | |
105 | 115 | } |
106 | 116 | void BaseNode::setFirstChild(Node* node){ |
107 | - firstChild = node; | |
117 | + this->firstChild = node; | |
108 | 118 | } |
109 | 119 | void BaseNode::setLastChild(Node* node){ |
110 | - lastChild = node; | |
120 | + this->lastChild = node; | |
121 | +} | |
122 | + | |
123 | +Node* BaseNode::getParent() | |
124 | +{ | |
125 | + return this->parentNode; | |
126 | +} | |
127 | +Node* BaseNode::getNext() | |
128 | +{ | |
129 | + return this->nextSibling; | |
130 | +} | |
131 | +Node* BaseNode::getPrev() | |
132 | +{ | |
133 | + return this->previousSibling; | |
134 | +} | |
135 | +Node* BaseNode::getFirstChild() | |
136 | +{ | |
137 | + return this->firstChild; | |
138 | +} | |
139 | +Node* BaseNode::getLastChild() | |
140 | +{ | |
141 | + return this->lastChild; | |
142 | +} | |
143 | +Node* BaseNode::removeChild(Node* const node) | |
144 | +{ | |
145 | + return this->parentNode; | |
146 | +} | |
147 | +Node* BaseNode::insertBefore(Node* const node) | |
148 | +{ | |
149 | + return this->parentNode; | |
150 | +} | |
151 | +Node* BaseNode::appendChild(Node* const node) | |
152 | +{ | |
153 | + return this->parentNode; | |
111 | 154 | } |
112 | 155 | |
113 | 156 | int main(int argc, char **argv) |
114 | 157 | { |
115 | - std::string str1 = "ABCDE"; | |
158 | + std::string str1 = "ABCD"; | |
116 | 159 | std::cout << str1 << std::endl; |
117 | 160 | return 0; |
118 | 161 | } |
@@ -101,7 +101,6 @@ void *ST_emalloc(size_t n) | ||
101 | 101 | p = calloc(1, n); |
102 | 102 | if (p == NULL) |
103 | 103 | { |
104 | - errno = ENOBUFS; | |
105 | 104 | eprintf("%u bytes failed on the function ST_emalloc:", n); |
106 | 105 | } |
107 | 106 | return p; |
@@ -1,136 +0,0 @@ | ||
1 | -Flat profile: | |
2 | - | |
3 | -Each sample counts as 0.01 seconds. | |
4 | - % cumulative self self total | |
5 | - time seconds seconds calls Ts/call Ts/call name | |
6 | - | |
7 | - % the percentage of the total running time of the | |
8 | -time program used by this function. | |
9 | - | |
10 | -cumulative a running sum of the number of seconds accounted | |
11 | - seconds for by this function and those listed above it. | |
12 | - | |
13 | - self the number of seconds accounted for by this | |
14 | -seconds function alone. This is the major sort for this | |
15 | - listing. | |
16 | - | |
17 | -calls the number of times this function was invoked, if | |
18 | - this function is profiled, else blank. | |
19 | - | |
20 | - self the average number of milliseconds spent in this | |
21 | -ms/call function per call, if this function is profiled, | |
22 | - else blank. | |
23 | - | |
24 | - total the average number of milliseconds spent in this | |
25 | -ms/call function and its descendents per call, if this | |
26 | - function is profiled, else blank. | |
27 | - | |
28 | -name the name of the function. This is the minor sort | |
29 | - for this listing. The index shows the location of | |
30 | - the function in the gprof listing. If the index is | |
31 | - in parenthesis it shows where it would appear in | |
32 | - the gprof listing if it were to be printed. | |
33 | - | |
34 | -Copyright (C) 2012-2014 Free Software Foundation, Inc. | |
35 | - | |
36 | -Copying and distribution of this file, with or without modification, | |
37 | -are permitted in any medium without royalty provided the copyright | |
38 | -notice and this notice are preserved. | |
39 | - | |
40 | - Call graph (explanation follows) | |
41 | - | |
42 | - | |
43 | -granularity: each sample hit covers 4 byte(s) no time propagated | |
44 | - | |
45 | -index % time self children called name | |
46 | - | |
47 | - This table describes the call tree of the program, and was sorted by | |
48 | - the total amount of time spent in each function and its children. | |
49 | - | |
50 | - Each entry in this table consists of several lines. The line with the | |
51 | - index number at the left hand margin lists the current function. | |
52 | - The lines above it list the functions that called this function, | |
53 | - and the lines below it list the functions this one called. | |
54 | - This line lists: | |
55 | - index A unique number given to each element of the table. | |
56 | - Index numbers are sorted numerically. | |
57 | - The index number is printed next to every function name so | |
58 | - it is easier to look up where the function is in the table. | |
59 | - | |
60 | - % time This is the percentage of the `total' time that was spent | |
61 | - in this function and its children. Note that due to | |
62 | - different viewpoints, functions excluded by options, etc, | |
63 | - these numbers will NOT add up to 100%. | |
64 | - | |
65 | - self This is the total amount of time spent in this function. | |
66 | - | |
67 | - children This is the total amount of time propagated into this | |
68 | - function by its children. | |
69 | - | |
70 | - called This is the number of times the function was called. | |
71 | - If the function called itself recursively, the number | |
72 | - only includes non-recursive calls, and is followed by | |
73 | - a `+' and the number of recursive calls. | |
74 | - | |
75 | - name The name of the current function. The index number is | |
76 | - printed after it. If the function is a member of a | |
77 | - cycle, the cycle number is printed between the | |
78 | - function's name and the index number. | |
79 | - | |
80 | - | |
81 | - For the function's parents, the fields have the following meanings: | |
82 | - | |
83 | - self This is the amount of time that was propagated directly | |
84 | - from the function into this parent. | |
85 | - | |
86 | - children This is the amount of time that was propagated from | |
87 | - the function's children into this parent. | |
88 | - | |
89 | - called This is the number of times this parent called the | |
90 | - function `/' the total number of times the function | |
91 | - was called. Recursive calls to the function are not | |
92 | - included in the number after the `/'. | |
93 | - | |
94 | - name This is the name of the parent. The parent's index | |
95 | - number is printed after it. If the parent is a | |
96 | - member of a cycle, the cycle number is printed between | |
97 | - the name and the index number. | |
98 | - | |
99 | - If the parents of the function cannot be determined, the word | |
100 | - `<spontaneous>' is printed in the `name' field, and all the other | |
101 | - fields are blank. | |
102 | - | |
103 | - For the function's children, the fields have the following meanings: | |
104 | - | |
105 | - self This is the amount of time that was propagated directly | |
106 | - from the child into the function. | |
107 | - | |
108 | - children This is the amount of time that was propagated from the | |
109 | - child's children to the function. | |
110 | - | |
111 | - called This is the number of times the function called | |
112 | - this child `/' the total number of times the child | |
113 | - was called. Recursive calls by the child are not | |
114 | - listed in the number after the `/'. | |
115 | - | |
116 | - name This is the name of the child. The child's index | |
117 | - number is printed after it. If the child is a | |
118 | - member of a cycle, the cycle number is printed | |
119 | - between the name and the index number. | |
120 | - | |
121 | - If there are any cycles (circles) in the call graph, there is an | |
122 | - entry for the cycle-as-a-whole. This entry shows who called the | |
123 | - cycle (as parents) and the members of the cycle (as children.) | |
124 | - The `+' recursive calls entry shows the number of function calls that | |
125 | - were internal to the cycle, and the calls entry for each member shows, | |
126 | - for that member, how many times it was called from other members of | |
127 | - the cycle. | |
128 | - | |
129 | -Copyright (C) 2012-2014 Free Software Foundation, Inc. | |
130 | - | |
131 | -Copying and distribution of this file, with or without modification, | |
132 | -are permitted in any medium without royalty provided the copyright | |
133 | -notice and this notice are preserved. | |
134 | - | |
135 | -Index by function name | |
136 | - |
@@ -19,8 +19,6 @@ | ||
19 | 19 | #include <float.h> |
20 | 20 | #include <assert.h> |
21 | 21 | #include <setjmp.h> |
22 | -#include <unistd.h> | |
23 | -#include <sys/time.h> | |
24 | 22 | #include <fcntl.h> |
25 | 23 | #include <signal.h> |
26 | 24 |