From 3935d27f5b5ea8ffadee1d3996d5358e56620e42 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 19 Jan 2015 18:19:38 +0400 Subject: [PATCH] Fix bugs --- teavm-core/src/main/java/org/teavm/javascript/Decompiler.java | 2 +- .../java/org/teavm/javascript/UnusedVariableEliminator.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java index db467814f..ef30581e2 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java @@ -286,7 +286,7 @@ public class Decompiler { Optimizer optimizer = new Optimizer(); optimizer.optimize(methodNode, method.getProgram()); methodNode.getModifiers().addAll(mapModifiers(method.getModifiers())); - int paramCount = method.getSignature().length; + int paramCount = Math.min(method.getSignature().length, program.variableCount()); for (int i = 0; i < paramCount; ++i) { Variable var = program.variableAt(i); methodNode.getParameterDebugNames().add(new HashSet<>(var.getDebugNames())); diff --git a/teavm-core/src/main/java/org/teavm/javascript/UnusedVariableEliminator.java b/teavm-core/src/main/java/org/teavm/javascript/UnusedVariableEliminator.java index c54d531bb..9fecea076 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/UnusedVariableEliminator.java +++ b/teavm-core/src/main/java/org/teavm/javascript/UnusedVariableEliminator.java @@ -38,6 +38,7 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor { } indexes = new int[variableCount]; Arrays.fill(indexes, -1); + parameterCount = Math.min(parameterCount, indexes.length - 1); for (int i = 0; i <= parameterCount; ++i) { indexes[i] = lastIndex++; }