Mercurial > hg > truffle
annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterator.java @ 19579:3df56ce39922
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 24 Feb 2015 12:33:32 +0100 |
parents | ef1494ece1a8 |
children |
rev | line source |
---|---|
16925
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.graph; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 class NodeUsageIterator implements Iterator<Node> { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 final Node node; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 int index = -1; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 Node current; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 void advance() { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 current = null; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 index++; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 if (index == 0) { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 current = node.usage0; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 } else if (index == 1) { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 current = node.usage1; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 } else { |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18163
diff
changeset
|
41 int relativeIndex = index - Node.INLINE_USAGE_COUNT; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18163
diff
changeset
|
42 if (relativeIndex < node.extraUsagesCount) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18163
diff
changeset
|
43 current = node.extraUsages[relativeIndex]; |
16925
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 public NodeUsageIterator(Node node) { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 this.node = node; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 advance(); |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 public boolean hasNext() { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 return current != null; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 public Node next() { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 Node result = current; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 if (result == null) { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 throw new NoSuchElementException(); |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 advance(); |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 return result; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 @Override |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 public void remove() { |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 throw new UnsupportedOperationException(); |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 } |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16925
diff
changeset
|
70 } |