Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 7530:5e3d1a68664e
applied mx eclipseformat to all Java files
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 23 Jan 2013 16:34:57 +0100 |
parents | a4b84ba6dc2e |
children | 4497235516df |
comparison
equal
deleted
inserted
replaced
7529:4a11124a3563 | 7530:5e3d1a68664e |
---|---|
52 @Target({ElementType.FIELD}) | 52 @Target({ElementType.FIELD}) |
53 public @interface Child { | 53 public @interface Child { |
54 } | 54 } |
55 | 55 |
56 /** | 56 /** |
57 * Method that updates the link to the parent in the array of specified new child nodes to this node. | 57 * Method that updates the link to the parent in the array of specified new child nodes to this |
58 * | 58 * node. |
59 * | |
59 * @param newChildren the array of new children whose parent should be updated | 60 * @param newChildren the array of new children whose parent should be updated |
60 * @return the array of new children | 61 * @return the array of new children |
61 */ | 62 */ |
62 protected final <T extends Node> T[] adoptChildren(T[] newChildren) { | 63 protected final <T extends Node> T[] adoptChildren(T[] newChildren) { |
63 if (newChildren != null) { | 64 if (newChildren != null) { |
68 return newChildren; | 69 return newChildren; |
69 } | 70 } |
70 | 71 |
71 /** | 72 /** |
72 * Method that updates the link to the parent in the specified new child node to this node. | 73 * Method that updates the link to the parent in the specified new child node to this node. |
73 * | 74 * |
74 * @param newChild the new child whose parent should be updated | 75 * @param newChild the new child whose parent should be updated |
75 * @return the new child | 76 * @return the new child |
76 */ | 77 */ |
77 protected final <T extends Node> T adoptChild(T newChild) { | 78 protected final <T extends Node> T adoptChild(T newChild) { |
78 if (newChild != null) { | 79 if (newChild != null) { |
80 } | 81 } |
81 return newChild; | 82 return newChild; |
82 } | 83 } |
83 | 84 |
84 /** | 85 /** |
85 * Returns properties of this node interesting for debugging and can be overwritten by subclasses to add their own | 86 * Returns properties of this node interesting for debugging and can be overwritten by |
86 * custom properties. | 87 * subclasses to add their own custom properties. |
87 * | 88 * |
88 * @return the properties as a key/value hash map | 89 * @return the properties as a key/value hash map |
89 */ | 90 */ |
90 public Map<String, Object> getDebugProperties() { | 91 public Map<String, Object> getDebugProperties() { |
91 Map<String, Object> properties = new HashMap<>(); | 92 Map<String, Object> properties = new HashMap<>(); |
92 return properties; | 93 return properties; |
93 } | 94 } |
94 | 95 |
95 /** | 96 /** |
96 * The current parent node of this node. | 97 * The current parent node of this node. |
97 * | 98 * |
98 * @return the parent node | 99 * @return the parent node |
99 */ | 100 */ |
100 public final Node getParent() { | 101 public final Node getParent() { |
101 return parent; | 102 return parent; |
102 } | 103 } |
103 | 104 |
104 /** | 105 /** |
105 * Replaces one child of this node with another node. | 106 * Replaces one child of this node with another node. |
106 * | 107 * |
107 * @param oldChild the old child | 108 * @param oldChild the old child |
108 * @param newChild the new child that should replace the old child | 109 * @param newChild the new child that should replace the old child |
109 * @return the new child | 110 * @return the new child |
110 */ | 111 */ |
111 public final <T extends Node> T replaceChild(T oldChild, T newChild) { | 112 public final <T extends Node> T replaceChild(T oldChild, T newChild) { |
114 return newChild; | 115 return newChild; |
115 } | 116 } |
116 | 117 |
117 /** | 118 /** |
118 * Replaces this node with another node. | 119 * Replaces this node with another node. |
119 * | 120 * |
120 * @param newNode the new node that is the replacement | 121 * @param newNode the new node that is the replacement |
121 * @param reason a description of the reason for the replacement | 122 * @param reason a description of the reason for the replacement |
122 * @return the new node | 123 * @return the new node |
123 */ | 124 */ |
124 @SuppressWarnings({"unchecked"}) | 125 @SuppressWarnings({"unchecked"}) |
127 return (T) this.getParent().replaceChild(this, newNode); | 128 return (T) this.getParent().replaceChild(this, newNode); |
128 } | 129 } |
129 | 130 |
130 /** | 131 /** |
131 * Replaces this node with another node. | 132 * Replaces this node with another node. |
132 * | 133 * |
133 * @param newNode the new node that is the replacement | 134 * @param newNode the new node that is the replacement |
134 * @return the new node | 135 * @return the new node |
135 */ | 136 */ |
136 public <T extends Node> T replace(T newNode) { | 137 public <T extends Node> T replace(T newNode) { |
137 return replace(newNode, ""); | 138 return replace(newNode, ""); |
138 } | 139 } |
139 | 140 |
140 /** | 141 /** |
141 * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all child nodes. | 142 * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all |
142 * | 143 * child nodes. |
144 * | |
143 * @param nodeVisitor the visitor | 145 * @param nodeVisitor the visitor |
144 */ | 146 */ |
145 public final void accept(NodeVisitor nodeVisitor) { | 147 public final void accept(NodeVisitor nodeVisitor) { |
146 if (nodeVisitor.visit(this)) { | 148 if (nodeVisitor.visit(this)) { |
147 for (Node child : this.getChildren()) { | 149 for (Node child : this.getChildren()) { |
152 } | 154 } |
153 } | 155 } |
154 | 156 |
155 /** | 157 /** |
156 * Iterator over the children of this node. | 158 * Iterator over the children of this node. |
157 * | 159 * |
158 * @return the iterator | 160 * @return the iterator |
159 */ | 161 */ |
160 public final Iterable<Node> getChildren() { | 162 public final Iterable<Node> getChildren() { |
161 final Node node = this; | 163 final Node node = this; |
162 return new Iterable<Node>() { | 164 return new Iterable<Node>() { |
167 }; | 169 }; |
168 } | 170 } |
169 | 171 |
170 /** | 172 /** |
171 * Creates a shallow copy of this node. | 173 * Creates a shallow copy of this node. |
172 * | 174 * |
173 * @return the new copy | 175 * @return the new copy |
174 */ | 176 */ |
175 public Node copy() { | 177 public Node copy() { |
176 try { | 178 try { |
177 return (Node) super.clone(); | 179 return (Node) super.clone(); |
179 return null; | 181 return null; |
180 } | 182 } |
181 } | 183 } |
182 | 184 |
183 /** | 185 /** |
184 * This method must never be called. It enforces that {@link Object#clone} is not directly called by subclasses. | 186 * This method must never be called. It enforces that {@link Object#clone} is not directly |
185 * Use the {@link #copy()} method instead. | 187 * called by subclasses. Use the {@link #copy()} method instead. |
186 */ | 188 */ |
187 @Override | 189 @Override |
188 @Deprecated | 190 @Deprecated |
189 protected final Object clone() throws CloneNotSupportedException { | 191 protected final Object clone() throws CloneNotSupportedException { |
190 throw new IllegalStateException("This method should never be called, use the copy method instead!"); | 192 throw new IllegalStateException("This method should never be called, use the copy method instead!"); |