# HG changeset patch # User Doug Simon # Date 1409061428 -7200 # Node ID d569f2fafb6a7e0f0e036e61df846a9c8a31bbef # Parent 7dbe1207fccfe30e382841eea6053b366dddc30b more refactorings to workaround javac symbol issue (JDK-7101822) diff -r 7dbe1207fccf -r d569f2fafb6a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Tue Aug 26 15:56:46 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Tue Aug 26 15:57:08 2014 +0200 @@ -42,12 +42,12 @@ /** * The set of nodes in the graph, ordered by {@linkplain #register(Node) registration} time. */ - private Node[] nodes; + Node[] nodes; /** * The number of valid entries in {@link #nodes}. */ - private int nodesSize; + int nodesSize; /** * Records the modification count for nodes. This is only used in assertions. @@ -562,56 +562,6 @@ return new Mark(this); } - private class NodeIterator implements Iterator { - - private int index; - - public NodeIterator() { - this(0); - } - - public NodeIterator(int index) { - this.index = index - 1; - forward(); - } - - private void forward() { - if (index < nodesSize) { - do { - index++; - } while (index < nodesSize && nodes[index] == null); - } - } - - @Override - public boolean hasNext() { - checkForDeletedNode(); - return index < nodesSize; - } - - private void checkForDeletedNode() { - if (index < nodesSize) { - while (index < nodesSize && nodes[index] == null) { - index++; - } - } - } - - @Override - public Node next() { - try { - return nodes[index]; - } finally { - forward(); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - /** * Returns an {@link Iterable} providing all nodes added since the last {@link Graph#getMark() * mark}. @@ -622,7 +572,7 @@ @Override public Iterator iterator() { - return new NodeIterator(index); + return new GraphNodeIterator(Graph.this, index); } }; } @@ -637,7 +587,7 @@ @Override public Iterator iterator() { - return new NodeIterator(); + return new GraphNodeIterator(Graph.this); } @Override diff -r 7dbe1207fccf -r d569f2fafb6a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraphNodeIterator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraphNodeIterator.java Tue Aug 26 15:57:08 2014 +0200 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph; + +import java.util.*; + +/** + * Iterates over the nodes in a given graph. + */ +class GraphNodeIterator implements Iterator { + + private final Graph graph; + private int index; + + public GraphNodeIterator(Graph graph) { + this(graph, 0); + } + + public GraphNodeIterator(Graph graph, int index) { + this.graph = graph; + this.index = index - 1; + forward(); + } + + private void forward() { + if (index < graph.nodesSize) { + do { + index++; + } while (index < graph.nodesSize && graph.nodes[index] == null); + } + } + + @Override + public boolean hasNext() { + checkForDeletedNode(); + return index < graph.nodesSize; + } + + private void checkForDeletedNode() { + if (index < graph.nodesSize) { + while (index < graph.nodesSize && graph.nodes[index] == null) { + index++; + } + } + } + + @Override + public Node next() { + try { + return graph.nodes[index]; + } finally { + forward(); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file