author | iignatyev |
Fri, 11 Oct 2019 09:43:41 -0700 | |
changeset 58564 | 218a1a642c6f |
parent 50366 | 4d85990f9c4a |
permissions | -rw-r--r-- |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
58564 | 2 |
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
4 |
* |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
8 |
* |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
14 |
* |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
18 |
* |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
22 |
*/ |
58564 | 23 |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
24 |
package jit.graph; |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
25 |
|
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
26 |
// This class define the tree node. |
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
27 |
|
58564 | 28 |
public class Node { |
29 |
public final static int Black = 0; // constants used to define the |
|
30 |
public final static int Red = 1; // node color |
|
31 |
public final static int Left_son = 2; // constants used to identify |
|
32 |
public final static int Right_son = 3;// the node parent and sons. |
|
33 |
public final static int Parent = 4; |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
34 |
|
58564 | 35 |
private int color; |
36 |
private int key; |
|
37 |
private Node L, R, P; // L-left son,R-right son,P-parent |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
38 |
|
58564 | 39 |
// constructor create a new node the default color is red |
40 |
// the default appearance (bold) is regular. |
|
41 |
// initialize the key field. |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
42 |
|
58564 | 43 |
public Node(int k) { |
44 |
color = Red; |
|
45 |
key = k; |
|
46 |
L = null; |
|
47 |
R = null; |
|
48 |
P = null; |
|
49 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
50 |
|
58564 | 51 |
// constructor for constructing a tree null object, is color |
52 |
// is black. |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
53 |
|
58564 | 54 |
public Node() { |
55 |
color = Black; |
|
56 |
key = -1; |
|
57 |
L = null; |
|
58 |
R = null; |
|
59 |
P = null; |
|
60 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
61 |
|
58564 | 62 |
// This method set the node key. |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
63 |
|
58564 | 64 |
public void setKey(int k) { |
65 |
key = k; |
|
66 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
67 |
|
58564 | 68 |
// This method return the node key. |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
69 |
|
58564 | 70 |
public int getKey() { |
71 |
return (key); |
|
72 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
73 |
|
58564 | 74 |
// This method set the node color. |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
75 |
|
58564 | 76 |
public void setColor(int c) { |
77 |
if (c == Black) { |
|
78 |
color = Black; |
|
79 |
} else if (c == Red) { |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
80 |
color = Red; |
58564 | 81 |
} |
82 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
83 |
|
58564 | 84 |
// This method return the node color. |
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
85 |
|
58564 | 86 |
public int getColor() { |
87 |
return (color); |
|
88 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
89 |
|
58564 | 90 |
// This method set the node parent or childs acording to the who |
91 |
// parameter. |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
92 |
|
58564 | 93 |
public void setNode(int who, Node n) { |
94 |
switch (who) { |
|
95 |
case Left_son: |
|
96 |
L = n; |
|
97 |
break; |
|
98 |
case Right_son: |
|
99 |
R = n; |
|
100 |
break; |
|
101 |
case Parent: |
|
102 |
P = n; |
|
103 |
break; |
|
104 |
} |
|
105 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
106 |
|
58564 | 107 |
// This method return the node parent or childs acording to the who |
108 |
// parameter. |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
109 |
|
58564 | 110 |
public Node getNode(int who) { |
111 |
switch (who) { |
|
112 |
case Left_son: |
|
113 |
return L; |
|
114 |
case Right_son: |
|
115 |
return R; |
|
116 |
case Parent: |
|
117 |
return P; |
|
118 |
} |
|
119 |
return null; |
|
120 |
} |
|
50366
4d85990f9c4a
8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff
changeset
|
121 |
} |