8015674: CodeGenerator.initSymbols mutates a list

Reviewed-by: jlaskey, lagergren
This commit is contained in:
Attila Szegedi 2013-05-31 12:57:44 +02:00
parent 9617ee41ca
commit 102a06fdef

View File

@ -456,17 +456,18 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
}
private void initSymbols(final LinkedList<Symbol> symbols, final Type type) {
if (symbols.isEmpty()) {
return;
}
method.loadUndefined(type);
while (!symbols.isEmpty()) {
final Symbol symbol = symbols.removeFirst();
if (!symbols.isEmpty()) {
method.dup();
}
method.store(symbol);
final Iterator<Symbol> it = symbols.iterator();
if(it.hasNext()) {
method.loadUndefined(type);
boolean hasNext;
do {
final Symbol symbol = it.next();
hasNext = it.hasNext();
if(hasNext) {
method.dup();
}
method.store(symbol);
} while(hasNext);
}
}