--- a/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java Mon Mar 17 15:05:18 2014 +0100
+++ b/nashorn/src/jdk/nashorn/internal/ir/LexicalContext.java Thu Mar 20 16:16:42 2014 +0100
@@ -235,7 +235,7 @@
public LexicalContextNode replace(final LexicalContextNode oldNode, final LexicalContextNode newNode) {
for (int i = sp - 1; i >= 0; i--) {
if (stack[i] == oldNode) {
- assert i == (sp - 1) : "violation of contract - we always expect to find the replacement node on top of the lexical context stack: " + newNode + " has " + stack[i + 1].getClass() + " above it";
+ assert i == sp - 1 : "violation of contract - we always expect to find the replacement node on top of the lexical context stack: " + newNode + " has " + stack[i + 1].getClass() + " above it";
stack[i] = newNode;
break;
}
@@ -269,6 +269,17 @@
return iter.hasNext() ? iter.next() : null;
}
+ /*
+ public FunctionNode getProgram() {
+ final Iterator<FunctionNode> iter = getFunctions();
+ FunctionNode last = null;
+ while (iter.hasNext()) {
+ last = iter.next();
+ }
+ assert last != null;
+ return last;
+ }*/
+
/**
* Returns an iterator over all ancestors block of the given block, with its parent block first.
* @param block the block whose ancestors are returned
@@ -381,7 +392,7 @@
* @param symbol symbol
* @return function node in which this symbol is defined, assert if no such symbol exists in context
*/
- public FunctionNode getDefiningFunction(Symbol symbol) {
+ public FunctionNode getDefiningFunction(final Symbol symbol) {
if (symbol.isTemp()) {
return null;
}
@@ -392,7 +403,7 @@
while (iter.hasNext()) {
final LexicalContextNode next2 = iter.next();
if (next2 instanceof FunctionNode) {
- return ((FunctionNode)next2);
+ return (FunctionNode)next2;
}
}
throw new AssertionError("Defining block for symbol " + name + " has no function in the context");
@@ -437,11 +448,11 @@
int n = 0;
for (final Iterator<LexicalContextNode> iter = getAllNodes(); iter.hasNext();) {
final LexicalContextNode node = iter.next();
- if(node == until) {
+ if (node == until) {
break;
}
assert !(node instanceof FunctionNode); // Can't go outside current function
- if(node instanceof WithNode || (node instanceof Block && ((Block)node).needsScope())) {
+ if (node instanceof WithNode || node instanceof Block && ((Block)node).needsScope()) {
n++;
}
}
@@ -618,7 +629,7 @@
if (next == null) {
throw new NoSuchElementException();
}
- T lnext = next;
+ final T lnext = next;
next = findNext();
return lnext;
}