From 1e00a8a828e305bfcf8be34fd03a237da215c6df Mon Sep 17 00:00:00 2001 From: sschr15 Date: Fri, 16 Aug 2024 00:47:12 -0500 Subject: [PATCH] [Kotlin] Experimental changes to loops / statements --- .../org/vineflower/kotlin/KotlinPlugin.java | 1 + .../vineflower/kotlin/expr/KVarExprent.java | 10 +- .../kotlin/pass/ReplaceExprentsPass.java | 3 +- .../kotlin/pass/ReplaceStatsPass.java | 34 + .../vineflower/kotlin/stat/KDoStatement.java | 153 ++++ .../kotlin/stat/KSequenceStatement.java | 50 ++ .../vineflower/kotlin/stat/KStatement.java | 351 ++++++++ .../testData/results/pkg/TestForRange.dec | 783 +++++++++--------- .../testData/results/pkg/TestFunVarargs.dec | 4 +- .../testData/results/pkg/TestLabeledJumps.dec | 263 +++--- .../results/pkg/TestNonInlineLambda.dec | 2 +- .../results/pkg/TestTailrecFunctions.dec | 115 ++- .../results/pkg/TestTryCatchExpressions.dec | 587 +++++-------- .../results/pkg/TestTryFinallyExpressions.dec | 6 +- 14 files changed, 1348 insertions(+), 1014 deletions(-) create mode 100644 plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceStatsPass.java create mode 100644 plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KDoStatement.java create mode 100644 plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KSequenceStatement.java create mode 100644 plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KStatement.java diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/KotlinPlugin.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/KotlinPlugin.java index fc7122dc4..911302c65 100644 --- a/plugins/kotlin/src/main/java/org/vineflower/kotlin/KotlinPlugin.java +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/KotlinPlugin.java @@ -83,6 +83,7 @@ private static Pass makePass() { .addPass("ResugarMethods", new ResugarKotlinMethodsPass()) .addPass("ReplaceContinue", ctx -> LabelHelper.replaceContinueWithBreak(ctx.getRoot())) .addPass("CollapseStringConcat", new CollapseStringConcatPass()) + .addPass("ReplaceStats", new ReplaceStatsPass()) .build(); } diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/expr/KVarExprent.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/expr/KVarExprent.java index d03de6cb4..6ada70181 100644 --- a/plugins/kotlin/src/main/java/org/vineflower/kotlin/expr/KVarExprent.java +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/expr/KVarExprent.java @@ -12,7 +12,7 @@ import java.util.BitSet; public class KVarExprent extends VarExprent implements KExprent { - private boolean isExceptionType; + private boolean excludeVarVal; public KVarExprent(int index, VarType varType, VarProcessor processor, BitSet bytecode) { super(index, varType, processor, bytecode); @@ -47,7 +47,7 @@ public TextBuffer toJava(int indent) { buffer.addBytecodeMapping(bytecode); boolean definition = isDefinition(); - if (definition && !isExceptionType) { + if (definition && !excludeVarVal) { VarProcessor processor = getProcessor(); boolean isFinal = isEffectivelyFinal() || @@ -58,7 +58,7 @@ public TextBuffer toJava(int indent) { buffer.append(getName()); - if (definition || isExceptionType) { + if (definition || excludeVarVal) { buffer.append(": "); buffer.append(KTypes.getKotlinType(getDefinitionVarType())); } @@ -66,8 +66,8 @@ public TextBuffer toJava(int indent) { return buffer; } - public void setExceptionType(boolean isExceptionType) { - this.isExceptionType = isExceptionType; + public void setExcludeVarVal(boolean isExceptionType) { + this.excludeVarVal = isExceptionType; } @Override diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceExprentsPass.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceExprentsPass.java index 89e5c3e26..8119bc10c 100644 --- a/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceExprentsPass.java +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceExprentsPass.java @@ -2,7 +2,6 @@ import org.jetbrains.java.decompiler.api.plugin.pass.Pass; import org.jetbrains.java.decompiler.api.plugin.pass.PassContext; -import org.jetbrains.java.decompiler.main.DecompilerContext; import org.jetbrains.java.decompiler.modules.decompiler.exps.*; import org.jetbrains.java.decompiler.modules.decompiler.stats.*; import org.vineflower.kotlin.expr.KVarExprent; @@ -33,7 +32,7 @@ private static boolean replace(Statement stat) { for (int i = 0; i < vars.size(); i++) { VarExprent expr = vars.get(i); KVarExprent map = new KVarExprent(expr); - map.setExceptionType(true); + map.setExcludeVarVal(true); vars.set(i, map); } } diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceStatsPass.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceStatsPass.java new file mode 100644 index 000000000..a89b80d96 --- /dev/null +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/pass/ReplaceStatsPass.java @@ -0,0 +1,34 @@ +package org.vineflower.kotlin.pass; + +import org.jetbrains.java.decompiler.api.plugin.pass.Pass; +import org.jetbrains.java.decompiler.api.plugin.pass.PassContext; +import org.jetbrains.java.decompiler.modules.decompiler.stats.DoStatement; +import org.jetbrains.java.decompiler.modules.decompiler.stats.SequenceStatement; +import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; +import org.vineflower.kotlin.stat.KDoStatement; +import org.vineflower.kotlin.stat.KSequenceStatement; + +public class ReplaceStatsPass implements Pass { + @Override + public boolean run(PassContext ctx) { + return replace(ctx.getRoot()); + } + + private static boolean replace(Statement stat) { + boolean res = false; + + for (int i = 0; i < stat.getStats().size(); i++) { + Statement st = stat.getStats().get(i); + res |= replace(st); + if (st instanceof SequenceStatement) { + stat.getStats().set(i, new KSequenceStatement((SequenceStatement) st)); + res = true; + } else if (st instanceof DoStatement) { + stat.getStats().set(i, new KDoStatement((DoStatement) st)); + res = true; + } + } + + return res; + } +} diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KDoStatement.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KDoStatement.java new file mode 100644 index 000000000..ad5a3303b --- /dev/null +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KDoStatement.java @@ -0,0 +1,153 @@ +package org.vineflower.kotlin.stat; + +import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; +import org.jetbrains.java.decompiler.modules.decompiler.exps.*; +import org.jetbrains.java.decompiler.modules.decompiler.stats.DoStatement; +import org.jetbrains.java.decompiler.struct.gen.VarType; +import org.jetbrains.java.decompiler.util.TextBuffer; +import org.vineflower.kotlin.expr.KConstExprent; +import org.vineflower.kotlin.expr.KVarExprent; + +public class KDoStatement extends KStatement { + public KDoStatement(DoStatement statement) { + super(statement); + } + + private static boolean isIntegerType(VarType type) { + return VarType.VARTYPE_INT.equals(type) || + VarType.VARTYPE_BYTE.equals(type) || + VarType.VARTYPE_SHORT.equals(type) || + VarType.VARTYPE_CHAR.equals(type) || + VarType.VARTYPE_LONG.equals(type); + } + + @Override + public TextBuffer toJava(int indent) { + TextBuffer buf = new TextBuffer(); + boolean labeled = statement.isLabeled(); + + buf.appendIndent(indent); + + if (labeled) { + buf.append("label") + .append(this.id) + .append("@ "); + } + + switch (statement.getLooptype()) { + case INFINITE -> { + buf.append("while (true) {").appendLineSeparator(); + buf.append(ExprProcessor.jmpWrapper(statement.getFirst(), indent + 1, false)); + buf.appendIndent(indent).append("}").appendLineSeparator(); + } + case DO_WHILE -> { + buf.append("do {").appendLineSeparator(); + buf.append(ExprProcessor.jmpWrapper(statement.getFirst(), indent + 1, false)); + buf.appendIndent(indent).append("} while ("); + buf.pushNewlineGroup(indent, 1); + buf.appendPossibleNewline(); + buf.append(statement.getConditionExprent().toJava(indent)); + buf.appendPossibleNewline("", true); + buf.popNewlineGroup(); + buf.append(")").appendLineSeparator(); + } + case WHILE -> { + buf.append("while ("); + buf.pushNewlineGroup(indent, 1); + buf.appendPossibleNewline(); + buf.append(statement.getConditionExprent().toJava(indent)); + buf.appendPossibleNewline("", true); + buf.popNewlineGroup(); + buf.append(") {").appendLineSeparator(); + buf.append(ExprProcessor.jmpWrapper(statement.getFirst(), indent + 1, false)); + buf.appendIndent(indent).append("}").appendLineSeparator(); + } + case FOR_EACH -> { + buf.append("for (").append(statement.getInitExprent().toJava(indent)); + statement.getIncExprent().getInferredExprType(null); //TODO: see DoStatement + buf.append(" in ").append(statement.getIncExprent().toJava(indent)).append(") {").appendLineSeparator(); + buf.append(ExprProcessor.jmpWrapper(statement.getFirst(), indent + 1, false)); + buf.appendIndent(indent).append("}").appendLineSeparator(); + } + case FOR -> { + // This is a hard one as Kotlin has no one-to-one equivalent to Java's for loop + if ( + statement.getInitExprent() instanceof AssignmentExprent init && + init.getLeft() instanceof VarExprent varExpr && + isIntegerType(varExpr.getExprType()) && + init.getRight() instanceof ConstExprent constExpr && + + statement.getIncExprent() instanceof FunctionExprent inc && + inc.getFuncType() == FunctionExprent.FunctionType.IPP && + + statement.getConditionExprent() instanceof FunctionExprent condition && + condition.getFuncType() == FunctionExprent.FunctionType.LT && + condition.getLstOperands().get(condition.getLstOperands().size() - 1) instanceof ConstExprent conditionConst + ) { + // Turn for loop into range + varExpr = new KVarExprent(varExpr); + ((KVarExprent) varExpr).setExcludeVarVal(true); + + constExpr.setConstType(varExpr.getExprType()); + conditionConst.setConstType(varExpr.getExprType()); + if (conditionConst.getValue() instanceof Integer i) { + conditionConst = new ConstExprent(varExpr.getExprType(), i - 1, conditionConst.bytecode); + conditionConst = new KConstExprent(conditionConst); + } + + buf.append("for (") + .append(varExpr.toJava(indent)) + .append(" in ") + .append(constExpr.toJava()) + .append("..") + .append(conditionConst.toJava()) + .append(") {") + .appendLineSeparator(); + + buf.append(ExprProcessor.jmpWrapper(statement.getFirst(), indent + 1, false)); + buf.appendIndent(indent).append("}").appendLineSeparator(); + } else { + //TODO other cases + if (labeled) { + buf.setLength(0); // Clear buffer, label needs to be treated differently + buf.appendIndent(indent); + } + + buf.append("// $VF: Unable to resugar Kotlin loop from Java for loop") + .appendLineSeparator() + .appendIndent(indent); + + if (labeled) { + buf.append("run label") + .append(this.id) + .append("@{") + .appendLineSeparator() + .appendIndent(++indent); + } + + if (statement.getInitExprent() != null) { + buf.append(statement.getInitExprent().toJava(indent)).appendLineSeparator().appendIndent(indent); + } + + buf.append("while (true) {").appendLineSeparator(); + buf.appendIndent(indent + 1); + buf.append("if ("); + buf.append(statement.getConditionExprent().toJava(indent + 1)); + buf.append(") break").appendLineSeparator(); + buf.append(ExprProcessor.jmpWrapper(statement.getFirst(), indent + 1, false)); + buf.appendLineSeparator(); + buf.appendIndent(indent + 1).append(statement.getIncExprent().toJava(indent + 1)).appendLineSeparator(); + buf.appendIndent(indent).append("}").appendLineSeparator(); + + if (labeled) { + buf.appendIndent(--indent) + .append("}") + .appendLineSeparator(); + } + } + } + } + + return buf; + } +} diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KSequenceStatement.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KSequenceStatement.java new file mode 100644 index 000000000..bad169ef1 --- /dev/null +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KSequenceStatement.java @@ -0,0 +1,50 @@ +package org.vineflower.kotlin.stat; + +import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; +import org.jetbrains.java.decompiler.modules.decompiler.stats.SequenceStatement; +import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; +import org.jetbrains.java.decompiler.util.TextBuffer; + +public class KSequenceStatement extends KStatement { + public KSequenceStatement(SequenceStatement statement) { + super(statement); + } + + @Override + public TextBuffer toJava(int indent) { + TextBuffer buf = new TextBuffer(); + boolean labeled = statement.isLabeled(); + + buf.append(ExprProcessor.listToJava(statement.getVarDefinitions(), indent)); + + if (labeled) { + buf.appendIndent(indent++) + .append("run label") + .append(statement.id) + .append("@{") + .appendLineSeparator(); + } + + boolean notEmpty = false; + for (int i = 0; i < statement.getStats().size(); i++) { + Statement st = statement.getStats().get(i); + TextBuffer str = ExprProcessor.jmpWrapper(st, indent, false); + + if (i > 0 && !str.containsOnlyWhitespaces() && notEmpty) { + buf.appendLineSeparator(); + } + + buf.append(str); + + notEmpty = !str.containsOnlyWhitespaces(); + } + + if (labeled) { + buf.appendIndent(--indent) + .append("}") + .appendLineSeparator(); + } + + return buf; + } +} diff --git a/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KStatement.java b/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KStatement.java new file mode 100644 index 000000000..78cb42440 --- /dev/null +++ b/plugins/kotlin/src/main/java/org/vineflower/kotlin/stat/KStatement.java @@ -0,0 +1,351 @@ +package org.vineflower.kotlin.stat; + +import org.jetbrains.java.decompiler.modules.decompiler.StatEdge; +import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; +import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; +import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement; +import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; +import org.jetbrains.java.decompiler.struct.match.IMatchable; +import org.jetbrains.java.decompiler.struct.match.MatchEngine; +import org.jetbrains.java.decompiler.struct.match.MatchNode; +import org.jetbrains.java.decompiler.util.StartEndPair; +import org.jetbrains.java.decompiler.util.TextBuffer; +import org.jetbrains.java.decompiler.util.collections.VBStyleCollection; + +import java.util.BitSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class KStatement extends Statement { + protected final T statement; + + public KStatement(T statement) { + super(statement.type); + this.statement = statement; + } + + public abstract TextBuffer toJava(int indent); + + @Override + public void clearTempInformation() { + statement.clearTempInformation(); + } + + @Override + public void collapseNodesToStatement(Statement stat) { + statement.collapseNodesToStatement(stat); + } + + @Override + public void addLabeledEdge(StatEdge edge) { + statement.addLabeledEdge(edge); + } + + @SuppressWarnings("deprecation") + @Override + public void addEdgeInternal(EdgeDirection direction, StatEdge edge) { + statement.addEdgeInternal(direction, edge); + } + + @SuppressWarnings("deprecation") + @Override + public void removeEdgeInternal(EdgeDirection direction, StatEdge edge) { + statement.removeEdgeInternal(direction, edge); + } + + @Override + public void addPredecessor(StatEdge edge) { + statement.addPredecessor(edge); + } + + @Override + public void removePredecessor(StatEdge edge) { + statement.removePredecessor(edge); + } + + @Override + public void addSuccessor(StatEdge edge) { + statement.addSuccessor(edge); + } + + @Override + public void removeSuccessor(StatEdge edge) { + statement.removeSuccessor(edge); + } + + @Override + public void removeAllSuccessors(Statement stat) { + statement.removeAllSuccessors(stat); + } + + @Override + public HashSet buildContinueSet() { + return statement.buildContinueSet(); + } + + @Override + public void buildMonitorFlags() { + statement.buildMonitorFlags(); + } + + @Override + public void markMonitorexitDead() { + statement.markMonitorexitDead(); + } + + @Override + public List getReversePostOrderList(Statement root) { + return statement.getReversePostOrderList(root); + } + + @Override + public List getPostReversePostOrderList(List lstexits) { + return statement.getPostReversePostOrderList(lstexits); + } + + @Override + public boolean containsStatement(Statement stat) { + return statement.containsStatement(stat); + } + + @Override + public boolean containsStatementStrict(Statement stat) { + return statement.containsStatementStrict(stat); + } + + @Override + public List getSequentialObjects() { + return statement.getSequentialObjects(); + } + + @Override + public void initExprents() { + statement.initExprents(); + } + + @Override + public void replaceExprent(Exprent oldexpr, Exprent newexpr) { + statement.replaceExprent(oldexpr, newexpr); + } + + @Override + public Statement getSimpleCopy() { + return statement.getSimpleCopy(); + } + + @Override + public void initSimpleCopy() { + statement.initSimpleCopy(); + } + + @Override + public void replaceStatement(Statement oldstat, Statement newstat) { + statement.replaceStatement(oldstat, newstat); + } + + @Override + public List getImplicitlyDefinedVars() { + return statement.getImplicitlyDefinedVars(); + } + + @Override + public void changeEdgeNode(EdgeDirection direction, StatEdge edge, Statement value) { + statement.changeEdgeNode(direction, edge, value); + } + + @Override + public void changeEdgeType(EdgeDirection direction, StatEdge edge, int newtype) { + statement.changeEdgeType(direction, edge, newtype); + } + + @Override + public List getNeighbours(int type, EdgeDirection direction) { + return statement.getNeighbours(type, direction); + } + + @Override + public Set getNeighboursSet(int type, EdgeDirection direction) { + return statement.getNeighboursSet(type, direction); + } + + @Override + public List getSuccessorEdges(int type) { + return statement.getSuccessorEdges(type); + } + + @Override + public List getSuccessorEdgeView(int type) { + return statement.getSuccessorEdgeView(type); + } + + @Override + public List getPredecessorEdges(int type) { + return statement.getPredecessorEdges(type); + } + + @Override + public List getAllSuccessorEdges() { + return statement.getAllSuccessorEdges(); + } + + @Override + public List getAllDirectSuccessorEdges() { + return statement.getAllDirectSuccessorEdges(); + } + + @Override + public boolean hasAnySuccessor() { + return statement.hasAnySuccessor(); + } + + @Override + public boolean hasAnyDirectSuccessor() { + return statement.hasAnyDirectSuccessor(); + } + + @Override + public boolean hasSuccessor(int type) { + return statement.hasSuccessor(type); + } + + @Override + public StatEdge getFirstSuccessor() { + return statement.getFirstSuccessor(); + } + + @Override + public StatEdge getFirstDirectSuccessor() { + return statement.getFirstDirectSuccessor(); + } + + @Override + public List getAllPredecessorEdges() { + return statement.getAllPredecessorEdges(); + } + + @Override + public Statement getFirst() { + return statement.getFirst(); + } + + @Override + public void setFirst(Statement first) { + statement.setFirst(first); + } + + @Override + public Statement getPost() { + return statement.getPost(); + } + + @Override + public VBStyleCollection getStats() { + return statement.getStats(); + } + + @Override + public LastBasicType getLastBasicType() { + return statement.getLastBasicType(); + } + + @Override + public HashSet getContinueSet() { + return statement.getContinueSet(); + } + + @Override + public boolean containsMonitorExit() { + return statement.containsMonitorExit(); + } + + @Override + public boolean containsMonitorExitOrAthrow() { + return statement.containsMonitorExitOrAthrow(); + } + + @Override + public boolean isLabeled() { + return statement.isLabeled(); + } + + @Override + public boolean hasBasicSuccEdge() { + return statement.hasBasicSuccEdge(); + } + + @Override + public Statement getParent() { + return statement.getParent(); + } + + @Override + public void setParent(Statement parent) { + statement.setParent(parent); + } + + @Override + public RootStatement getTopParent() { + return statement.getTopParent(); + } + + @Override + public HashSet getLabelEdges() { + return statement.getLabelEdges(); + } + + @Override + public List getVarDefinitions() { + return statement.getVarDefinitions(); + } + + @Override + public List getExprents() { + return statement.getExprents(); + } + + @Override + public boolean isCopied() { + return statement.isCopied(); + } + + @Override + public void setCopied(boolean copied) { + statement.setCopied(copied); + } + + @Override + public boolean isPhantom() { + return statement.isPhantom(); + } + + @Override + public void setPhantom(boolean phantom) { + statement.setPhantom(phantom); + } + + @Override + public String toString() { + return statement.toString(); + } + + @Override + public void getOffset(BitSet values) { + statement.getOffset(values); + } + + @Override + public StartEndPair getStartEndRange() { + return statement.getStartEndRange(); + } + + @Override + public IMatchable findObject(MatchNode matchNode, int index) { + return statement.findObject(matchNode, index); + } + + @Override + public boolean match(MatchNode matchNode, MatchEngine engine) { + return statement.match(matchNode, engine); + } +} diff --git a/plugins/kotlin/testData/results/pkg/TestForRange.dec b/plugins/kotlin/testData/results/pkg/TestForRange.dec index 440ecbc77..d433ec5d5 100644 --- a/plugins/kotlin/testData/results/pkg/TestForRange.dec +++ b/plugins/kotlin/testData/results/pkg/TestForRange.dec @@ -4,13 +4,13 @@ import kotlin.internal.ProgressionUtilKt public class TestForRange { public fun testInt() { - for (int i = 1; i < 11; i++) {// 5 + for (i: Int in 1..10) {// 5 System.out.println(i);// 6 } }// 8 public fun testChar() { - for (char c = 'a'; c < '{'; c++) {// 11 + for (c: Char in 'a'..'z') {// 11 System.out.println(c);// 12 } }// 14 @@ -50,8 +50,13 @@ public class TestForRange { }// 26 public fun testIntDownTo() { - for (int i = 10; 0 < i; i--) {// 29 + // $VF: Unable to resugar Kotlin loop from Java for loop + int i = 10 + while (true) { + if (0 < i) break System.out.println(i);// 30 + + i--// 29 } }// 32 @@ -91,7 +96,7 @@ public class TestForRange { }// 44 public fun testUntil() { - for (int i = 1; i < 10; i++) {// 47 + for (i: Int in 1..9) {// 47 System.out.println(i);// 48 } }// 50 @@ -183,12 +188,8 @@ class 'pkg/TestForRange' { method 'testInt ()V' { 0 6 1 6 - 2 6 3 6 4 6 - 5 6 - 6 6 - 7 6 8 7 9 7 a 7 @@ -196,9 +197,6 @@ class 'pkg/TestForRange' { c 7 d 7 e 7 - f 6 - 10 6 - 11 6 15 9 } @@ -206,12 +204,8 @@ class 'pkg/TestForRange' { 0 12 1 12 2 12 - 3 12 4 12 5 12 - 6 12 - 7 12 - 8 12 9 13 a 13 b 13 @@ -219,8 +213,6 @@ class 'pkg/TestForRange' { d 13 e 13 f 13 - 10 12 - 12 12 18 15 } @@ -303,389 +295,382 @@ class 'pkg/TestForRange' { } method 'testIntDownTo ()V' { - 0 52 - 1 52 - 2 52 - 3 52 - 4 52 - 5 52 - 6 52 - 7 52 - 8 53 - 9 53 - a 53 - b 53 - c 53 - d 53 - e 53 - f 52 - 10 52 - 11 52 - 15 55 + 0 53 + 1 53 + 2 53 + 3 55 + 4 55 + 5 55 + 6 55 + 7 55 + 8 56 + 9 56 + a 56 + b 56 + c 56 + d 56 + e 56 + f 58 + 10 58 + 11 58 + 15 60 } method 'testIntDownToStep ()V' { - 0 58 - 1 58 - 2 58 - 3 59 - 4 59 - 5 59 - 6 59 - 7 59 - 8 59 - 9 59 - a 59 - b 59 - c 60 - d 60 - e 60 - f 60 - 10 60 - 11 62 - 12 62 - 13 62 - 14 62 - 15 62 - 16 62 - 17 62 - 18 63 - 19 63 - 1a 63 - 1b 63 - 1c 63 - 1d 67 - 1e 67 - 1f 67 - 23 70 + 0 63 + 1 63 + 2 63 + 3 64 + 4 64 + 5 64 + 6 64 + 7 64 + 8 64 + 9 64 + a 64 + b 64 + c 65 + d 65 + e 65 + f 65 + 10 65 + 11 67 + 12 67 + 13 67 + 14 67 + 15 67 + 16 67 + 17 67 + 18 68 + 19 68 + 1a 68 + 1b 68 + 1c 68 + 1d 72 + 1e 72 + 1f 72 + 23 75 } method 'testIntDownToStepX (I)V' { - 0 73 - 1 73 - 2 73 - 3 73 - 8 74 - 9 74 - a 74 - b 74 - c 74 - d 74 - 11 74 - 12 76 - 13 76 - 14 76 - 15 77 - 16 77 - 17 77 - 18 78 - 19 78 - 1a 78 - 1b 78 - 1c 78 - 1d 78 - 1e 78 - 1f 78 - 20 78 - 21 79 - 22 79 - 23 79 - 24 79 - 25 79 - 26 79 - 27 81 - 28 81 - 29 81 - 2a 81 - 2b 81 - 2c 81 - 2d 81 - 2e 82 - 2f 82 - 30 82 - 31 82 - 32 82 - 33 82 - 35 86 - 37 86 - 3b 90 + 0 78 + 1 78 + 2 78 + 3 78 + 8 79 + 9 79 + a 79 + b 79 + c 79 + d 79 + 11 79 + 12 81 + 13 81 + 14 81 + 15 82 + 16 82 + 17 82 + 18 83 + 19 83 + 1a 83 + 1b 83 + 1c 83 + 1d 83 + 1e 83 + 1f 83 + 20 83 + 21 84 + 22 84 + 23 84 + 24 84 + 25 84 + 26 84 + 27 86 + 28 86 + 29 86 + 2a 86 + 2b 86 + 2c 86 + 2d 86 + 2e 87 + 2f 87 + 30 87 + 31 87 + 32 87 + 33 87 + 35 91 + 37 91 + 3b 95 } method 'testUntil ()V' { - 0 93 - 1 93 - 2 93 - 3 93 - 4 93 - 5 93 - 6 93 - 7 93 - 8 94 - 9 94 - a 94 - b 94 - c 94 - d 94 - e 94 - f 93 - 10 93 - 11 93 - 15 96 - } - - method 'testUntilStep ()V' { - 0 99 - 1 99 - 2 99 - 3 99 - 4 99 - 5 99 - 6 99 - 7 99 + 0 98 + 1 98 + 3 98 + 4 98 8 99 9 99 a 99 b 99 c 99 d 99 - e 100 - f 100 - 10 100 - 11 100 - 12 100 - 13 101 - 14 101 + e 99 15 101 - 16 101 - 17 101 - 18 102 - 19 102 - 1a 102 - 1b 102 - 1c 102 - 1d 102 - 1e 103 - 1f 103 - 20 103 - 21 103 - 22 103 - 23 103 - 24 103 - 25 103 - 26 103 - 27 103 - 28 103 - 29 103 - 2a 103 - 2b 103 - 2c 103 - 2d 103 - 2e 103 - 2f 103 - 30 103 - 31 103 - 32 105 - 33 105 - 34 105 - 35 105 - 36 105 - 37 105 - 38 105 - 39 106 - 3a 106 - 3b 106 - 3c 106 - 3d 106 - 3f 110 - 40 110 - 42 110 - 46 113 + } + + method 'testUntilStep ()V' { + 0 104 + 1 104 + 2 104 + 3 104 + 4 104 + 5 104 + 6 104 + 7 104 + 8 104 + 9 104 + a 104 + b 104 + c 104 + d 104 + e 105 + f 105 + 10 105 + 11 105 + 12 105 + 13 106 + 14 106 + 15 106 + 16 106 + 17 106 + 18 107 + 19 107 + 1a 107 + 1b 107 + 1c 107 + 1d 107 + 1e 108 + 1f 108 + 20 108 + 21 108 + 22 108 + 23 108 + 24 108 + 25 108 + 26 108 + 27 108 + 28 108 + 29 108 + 2a 108 + 2b 108 + 2c 108 + 2d 108 + 2e 108 + 2f 108 + 30 108 + 31 108 + 32 110 + 33 110 + 34 110 + 35 110 + 36 110 + 37 110 + 38 110 + 39 111 + 3a 111 + 3b 111 + 3c 111 + 3d 111 + 3f 115 + 40 115 + 42 115 + 46 118 } method 'testUntilStepX (I)V' { - 0 116 - 1 116 - 2 116 - 3 116 - 4 116 - 5 116 - 6 116 - 7 116 - 8 116 - 9 116 - a 116 - b 116 - c 116 - d 116 - e 117 - f 117 - 10 117 - 11 117 - 12 117 - 13 118 - 14 118 - 15 118 - 16 118 - 17 118 - 18 118 - 19 119 - 1a 119 - 1b 119 - 1c 119 - 1d 119 - 1e 119 - 1f 120 - 20 120 - 21 120 - 22 120 - 23 120 - 24 120 - 25 120 - 26 120 - 27 120 - 28 120 - 29 120 - 2a 120 - 2b 120 - 2c 120 - 2d 120 - 2e 120 - 2f 120 - 30 120 - 31 120 - 32 120 - 33 120 - 34 120 - 35 122 - 36 122 - 37 122 - 38 122 - 39 122 - 3a 122 - 3b 122 - 3c 123 - 3d 123 - 3e 123 - 3f 123 - 40 123 - 41 123 - 43 127 - 44 127 - 46 127 - 4a 130 + 0 121 + 1 121 + 2 121 + 3 121 + 4 121 + 5 121 + 6 121 + 7 121 + 8 121 + 9 121 + a 121 + b 121 + c 121 + d 121 + e 122 + f 122 + 10 122 + 11 122 + 12 122 + 13 123 + 14 123 + 15 123 + 16 123 + 17 123 + 18 123 + 19 124 + 1a 124 + 1b 124 + 1c 124 + 1d 124 + 1e 124 + 1f 125 + 20 125 + 21 125 + 22 125 + 23 125 + 24 125 + 25 125 + 26 125 + 27 125 + 28 125 + 29 125 + 2a 125 + 2b 125 + 2c 125 + 2d 125 + 2e 125 + 2f 125 + 30 125 + 31 125 + 32 125 + 33 125 + 34 125 + 35 127 + 36 127 + 37 127 + 38 127 + 39 127 + 3a 127 + 3b 127 + 3c 128 + 3d 128 + 3e 128 + 3f 128 + 40 128 + 41 128 + 43 132 + 44 132 + 46 132 + 4a 135 } method 'testIntY (II)V' { - 0 133 - 1 133 - 2 134 - 3 134 - 4 134 - 5 134 - 6 134 - 7 136 - 8 136 - 9 136 - a 136 - b 136 - c 136 - d 136 - e 137 - f 137 - 10 137 - 11 137 - 12 137 - 13 141 - 14 141 - 15 141 - 19 144 + 0 138 + 1 138 + 2 139 + 3 139 + 4 139 + 5 139 + 6 139 + 7 141 + 8 141 + 9 141 + a 141 + b 141 + c 141 + d 141 + e 142 + f 142 + 10 142 + 11 142 + 12 142 + 13 146 + 14 146 + 15 146 + 19 149 } method 'testIntYStep (II)V' { - 0 147 - 1 147 - 2 148 - 3 148 - 4 148 - 5 148 - 6 148 - 7 148 - 8 148 - 9 148 - a 149 - b 149 - c 149 - d 149 - e 149 - f 149 - 10 151 - 11 151 - 12 151 - 13 151 - 14 151 - 15 151 - 16 151 - 17 152 - 18 152 - 19 152 - 1a 152 - 1b 152 - 1c 152 - 1d 156 - 1e 156 - 1f 156 - 23 159 + 0 152 + 1 152 + 2 153 + 3 153 + 4 153 + 5 153 + 6 153 + 7 153 + 8 153 + 9 153 + a 154 + b 154 + c 154 + d 154 + e 154 + f 154 + 10 156 + 11 156 + 12 156 + 13 156 + 14 156 + 15 156 + 16 156 + 17 157 + 18 157 + 19 157 + 1a 157 + 1b 157 + 1c 157 + 1d 161 + 1e 161 + 1f 161 + 23 164 } method 'testIntYStepX (III)V' { - 0 162 - 1 162 - 2 162 - 3 162 - 8 163 - 9 163 - a 163 - b 163 - c 163 - d 163 - 11 163 - 12 165 - 13 165 - 14 165 - 15 166 - 16 166 - 17 166 - 18 166 - 19 166 - 1a 166 - 1b 166 - 1c 166 - 1d 167 - 1e 167 - 1f 167 - 20 167 - 21 167 - 22 167 - 23 167 - 24 169 - 25 169 - 26 169 - 27 169 - 28 169 - 29 169 - 2a 169 - 2b 169 - 2c 170 - 2d 170 - 2e 170 - 2f 170 - 30 170 - 31 170 - 32 170 - 35 174 - 37 174 - 38 174 - 3c 178 + 0 167 + 1 167 + 2 167 + 3 167 + 8 168 + 9 168 + a 168 + b 168 + c 168 + d 168 + 11 168 + 12 170 + 13 170 + 14 170 + 15 171 + 16 171 + 17 171 + 18 171 + 19 171 + 1a 171 + 1b 171 + 1c 171 + 1d 172 + 1e 172 + 1f 172 + 20 172 + 21 172 + 22 172 + 23 172 + 24 174 + 25 174 + 26 174 + 27 174 + 28 174 + 29 174 + 2a 174 + 2b 174 + 2c 175 + 2d 175 + 2e 175 + 2f 175 + 30 175 + 31 175 + 32 175 + 35 179 + 37 179 + 38 179 + 3c 183 } } @@ -702,30 +687,30 @@ Lines mapping: 23 <-> 42 24 <-> 41 26 <-> 50 -29 <-> 53 -30 <-> 54 -32 <-> 56 -35 <-> 64 -36 <-> 63 -38 <-> 71 -41 <-> 83 -42 <-> 82 -44 <-> 91 -47 <-> 94 -48 <-> 95 -50 <-> 97 -53 <-> 107 -54 <-> 106 -56 <-> 114 -59 <-> 124 -60 <-> 123 -62 <-> 131 -65 <-> 138 -66 <-> 137 -68 <-> 145 -71 <-> 153 -72 <-> 152 -74 <-> 160 -77 <-> 171 -78 <-> 170 -80 <-> 179 +29 <-> 59 +30 <-> 57 +32 <-> 61 +35 <-> 69 +36 <-> 68 +38 <-> 76 +41 <-> 88 +42 <-> 87 +44 <-> 96 +47 <-> 99 +48 <-> 100 +50 <-> 102 +53 <-> 112 +54 <-> 111 +56 <-> 119 +59 <-> 129 +60 <-> 128 +62 <-> 136 +65 <-> 143 +66 <-> 142 +68 <-> 150 +71 <-> 158 +72 <-> 157 +74 <-> 165 +77 <-> 176 +78 <-> 175 +80 <-> 184 diff --git a/plugins/kotlin/testData/results/pkg/TestFunVarargs.dec b/plugins/kotlin/testData/results/pkg/TestFunVarargs.dec index 6675a5e75..7d1493a26 100644 --- a/plugins/kotlin/testData/results/pkg/TestFunVarargs.dec +++ b/plugins/kotlin/testData/results/pkg/TestFunVarargs.dec @@ -4,13 +4,13 @@ import java.util.Arrays public class TestFunVarargs { public fun printAll(vararg messages: String) { - for (java.lang.String m : messages) {// 5 + for (java.lang.String m in messages) {// 5 System.out.println(m); } }// 6 public fun printAllArray(messages: Array) { - for (java.lang.String m : messages) {// 9 + for (java.lang.String m in messages) {// 9 System.out.println(m); } }// 10 diff --git a/plugins/kotlin/testData/results/pkg/TestLabeledJumps.dec b/plugins/kotlin/testData/results/pkg/TestLabeledJumps.dec index b7e7d0440..94fb838ab 100644 --- a/plugins/kotlin/testData/results/pkg/TestLabeledJumps.dec +++ b/plugins/kotlin/testData/results/pkg/TestLabeledJumps.dec @@ -2,9 +2,8 @@ package pkg public class TestLabeledJumps { public fun testContinue(tester: (Int) -> Boolean) { - label24: - for (int i = 1; i < 101; i++) {// 5 - for (int j = 1; j < 101; j++) {// 6 + label35@ for (i: Int in 1..100) {// 5 + for (j: Int in 1..100) {// 6 if (tester.invoke(j) as java.lang.Boolean) {// 7 continue label24; } @@ -17,8 +16,7 @@ public class TestLabeledJumps { }// 16 public fun testBreak(tester: (Int) -> Boolean) { - label22: - for (int i = 1; i < 101; i++) {// 19 + label32@ for (i: Int in 1..100) {// 19 for (int j = 1; j < 101; j++) {// 20 if (tester.invoke(j) as java.lang.Boolean) {// 21 break label22; @@ -34,151 +32,130 @@ public class TestLabeledJumps { class 'pkg/TestLabeledJumps' { method 'testContinue (Lkotlin/jvm/functions/Function1;)V' { - 6 5 - 7 5 - 8 5 - 9 5 - a 5 - b 5 - c 5 - d 5 - e 6 - f 6 - 10 6 - 11 6 - 12 6 - 13 6 - 14 6 - 15 6 - 16 7 - 17 7 - 18 7 - 19 7 - 1a 7 - 1b 7 - 1c 7 - 1d 7 - 1e 7 - 1f 7 - 20 7 - 21 7 - 22 7 - 23 7 - 24 7 - 25 7 - 26 7 - 27 7 - 28 7 - 2c 11 - 2d 11 - 2e 11 - 2f 11 - 30 11 - 31 11 - 32 11 - 33 11 - 34 11 - 35 11 - 37 11 - 38 11 - 39 11 - 3a 6 - 3b 6 - 3c 6 - 40 14 - 41 14 - 42 14 - 43 14 - 44 14 - 46 14 - 47 14 - 48 14 - 49 5 - 4a 5 - 4b 5 - 4f 16 + 6 4 + 7 4 + 9 4 + a 4 + e 5 + f 5 + 11 5 + 12 5 + 16 6 + 17 6 + 18 6 + 19 6 + 1a 6 + 1b 6 + 1c 6 + 1d 6 + 1e 6 + 1f 6 + 20 6 + 21 6 + 22 6 + 23 6 + 24 6 + 25 6 + 26 6 + 27 6 + 28 6 + 2c 10 + 2d 10 + 2e 10 + 2f 10 + 30 10 + 31 10 + 32 10 + 33 10 + 34 10 + 35 10 + 37 10 + 38 10 + 39 10 + 40 13 + 41 13 + 42 13 + 43 13 + 44 13 + 46 13 + 47 13 + 48 13 + 4f 15 } method 'testBreak (Lkotlin/jvm/functions/Function1;)V' { - 6 20 - 7 20 - 8 20 - 9 20 - a 20 - b 20 - c 20 - d 20 - e 21 - f 21 - 10 21 - 11 21 - 12 21 - 13 21 - 14 21 - 15 21 - 16 22 - 17 22 - 18 22 - 19 22 - 1a 22 - 1b 22 - 1c 22 - 1d 22 - 1e 22 - 1f 22 - 20 22 - 21 22 - 22 22 - 23 22 - 24 22 - 25 22 - 26 22 - 27 22 - 28 22 - 2c 26 - 2d 26 - 2e 26 - 2f 26 - 30 26 - 31 26 - 32 26 - 33 26 - 34 26 - 35 26 - 37 26 - 38 26 - 39 26 - 3a 21 - 3b 21 - 3c 21 - 40 20 - 41 20 - 42 20 - 46 30 - 47 30 - 48 30 - 49 30 - 4a 30 - 4c 30 - 4d 30 - 4e 30 - 4f 31 + 6 18 + 7 18 + 9 18 + a 18 + e 19 + f 19 + 10 19 + 11 19 + 12 19 + 13 19 + 14 19 + 15 19 + 16 20 + 17 20 + 18 20 + 19 20 + 1a 20 + 1b 20 + 1c 20 + 1d 20 + 1e 20 + 1f 20 + 20 20 + 21 20 + 22 20 + 23 20 + 24 20 + 25 20 + 26 20 + 27 20 + 28 20 + 2c 24 + 2d 24 + 2e 24 + 2f 24 + 30 24 + 31 24 + 32 24 + 33 24 + 34 24 + 35 24 + 37 24 + 38 24 + 39 24 + 3a 19 + 3b 19 + 3c 19 + 46 28 + 47 28 + 48 28 + 49 28 + 4a 28 + 4c 28 + 4d 28 + 4e 28 + 4f 29 } } Lines mapping: -5 <-> 6 -6 <-> 7 -7 <-> 8 -11 <-> 12 -14 <-> 15 -16 <-> 17 -19 <-> 21 -20 <-> 22 -21 <-> 23 -25 <-> 27 -29 <-> 31 -30 <-> 32 +5 <-> 5 +6 <-> 6 +7 <-> 7 +11 <-> 11 +14 <-> 14 +16 <-> 16 +19 <-> 19 +20 <-> 20 +21 <-> 21 +25 <-> 25 +29 <-> 29 +30 <-> 30 Not mapped: 8 22 diff --git a/plugins/kotlin/testData/results/pkg/TestNonInlineLambda.dec b/plugins/kotlin/testData/results/pkg/TestNonInlineLambda.dec index 8b356ecb7..a0dc534e7 100644 --- a/plugins/kotlin/testData/results/pkg/TestNonInlineLambda.dec +++ b/plugins/kotlin/testData/results/pkg/TestNonInlineLambda.dec @@ -29,7 +29,7 @@ public open class TestNonInlineLambda { }// 26 public fun testCaptureObjectIterationValue(x: Iterable) { - for (java.lang.String i : x) {// 29 + for (java.lang.String i in x) {// 29 this.execute(TestNonInlineLambda::testCaptureObjectIterationValue$lambda$3);// 30 } }// 34 diff --git a/plugins/kotlin/testData/results/pkg/TestTailrecFunctions.dec b/plugins/kotlin/testData/results/pkg/TestTailrecFunctions.dec index 4d30f1672..bc76599c1 100644 --- a/plugins/kotlin/testData/results/pkg/TestTailrecFunctions.dec +++ b/plugins/kotlin/testData/results/pkg/TestTailrecFunctions.dec @@ -46,7 +46,7 @@ public class TestTailrecFunctions { public tailrec fun testTryCatchFinally() { label31: { - label32: { + run label32@{ try { try { this.testTryCatchFinally();// 35 @@ -103,7 +103,6 @@ public class TestTailrecFunctions { public tailrec fun fastPow(x: Long, n: Long): Long { var var5: TestTailrecFunctions = this;// 49 - var var10000: Long; while (true) { if (n == 0L) {// 50 var10000 = 1L; @@ -324,58 +323,58 @@ class 'pkg/TestTailrecFunctions' { 0 103 1 103 2 103 - 3 107 - 4 107 - 5 107 - 6 107 - 7 107 - 8 107 - 9 108 - a 109 - d 112 - e 112 - f 112 - 10 112 - 11 112 - 12 112 - 13 112 - 14 112 - 15 112 - 16 119 - 17 119 - 1a 117 - 1b 117 - 1c 117 - 1d 117 - 1e 117 - 1f 118 - 20 118 - 21 118 - 22 118 - 23 118 - 24 118 - 25 119 - 26 119 - 27 119 - 28 119 - 29 120 - 2a 120 - 2b 120 - 2c 121 - 2d 121 - 2e 121 - 32 113 - 33 113 - 34 113 - 35 113 - 36 113 - 37 113 - 38 113 - 39 113 - 3a 113 - 3b 113 - 3c 113 - 3d 124 + 3 106 + 4 106 + 5 106 + 6 106 + 7 106 + 8 106 + 9 107 + a 108 + d 111 + e 111 + f 111 + 10 111 + 11 111 + 12 111 + 13 111 + 14 111 + 15 111 + 16 118 + 17 118 + 1a 116 + 1b 116 + 1c 116 + 1d 116 + 1e 116 + 1f 117 + 20 117 + 21 117 + 22 117 + 23 117 + 24 117 + 25 118 + 26 118 + 27 118 + 28 118 + 29 119 + 2a 119 + 2b 119 + 2c 120 + 2d 120 + 2e 120 + 32 112 + 33 112 + 34 112 + 35 112 + 36 112 + 37 112 + 38 112 + 39 112 + 3a 112 + 3b 112 + 3c 112 + 3d 123 } } @@ -398,10 +397,10 @@ Lines mapping: 45 <-> 73 46 <-> 83 49 <-> 104 -50 <-> 108 -51 <-> 113 -52 <-> 114 -53 <-> 125 +50 <-> 107 +51 <-> 112 +52 <-> 113 +53 <-> 124 Not mapped: 10 14 diff --git a/plugins/kotlin/testData/results/pkg/TestTryCatchExpressions.dec b/plugins/kotlin/testData/results/pkg/TestTryCatchExpressions.dec index 699e06cf0..04ba61585 100644 --- a/plugins/kotlin/testData/results/pkg/TestTryCatchExpressions.dec +++ b/plugins/kotlin/testData/results/pkg/TestTryCatchExpressions.dec @@ -6,411 +6,196 @@ import kotlin.jvm.internal.SourceDebugExtension @SourceDebugExtension(["SMAP\nTestTryCatchExpressions.kt\nKotlin\n*S Kotlin\n*F\n+ 1 TestTryCatchExpressions.kt\npkg/TestTryCatchExpressions\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,59:1\n1#2:60\n*E\n"]) public class TestTryCatchExpressions { public fun test0(s: String) { - var var2: java.lang.String; - try { - var2 = StringsKt.repeat(s as java.lang.CharSequence, 5);// 9 - } catch (var4: RuntimeException) {// 10 - var var10000: java.lang.String = var4.getMessage();// 11 - if (var10000 == null) { - var10000 = "ERROR"; - } - - var2 = var10000; - } - - System.out.print(var2);// 7 - }// 14 - - public fun test1(a: String, b: String) { - var x: java.lang.String = a;// 17 - var var6: TestTryCatchExpressions = this;// 19 - - var var4: java.lang.String; - var var10000: TestTryCatchExpressions; - try { - var10000 = var6; - var4 = StringsKt.repeat(x as java.lang.CharSequence, 5);// 20 - } catch (var9: RuntimeException) {// 21 - var10000 = this; - x = b;// 22 - var var10001: java.lang.String = var9.getMessage();// 23 - if (var10001 == null) { - var10001 = "ERROR"; - } - - var4 = var10001; - } - - val var7: java.lang.String = var4;// 24 - var6 = var10000; - - var var13: java.lang.String; - try { - var10000 = var6; - var13 = var7; - var4 = StringsKt.repeat(x as java.lang.CharSequence, 5);// 25 - } catch (var8: RuntimeException) {// 26 - var10000 = var10000; - var13 = var4; - var var10002: java.lang.String = var8.getMessage();// 27 - if (var10002 == null) { - var10002 = "ERROR"; - } - - var4 = var10002; - } - - var10000.test0("$var13$var4");// 18 - }// 30 - - public fun test2(a: String, b: String) { - var var15: java.lang.String = a;// 33 - var var7: TestTryCatchExpressions = this; - - var var4: java.lang.String; - var var10000: TestTryCatchExpressions; - try { - var10000 = var7; - if (a.length() != b.length()) {// 35 - return;// 36 - } - - var15 = b;// 38 - this.test0(b);// 39 - var4 = b;// 40 - } catch (var13: IOException) {// 41 - var10000 = this; - var15 = a;// 42 - this.test1(a, a);// 43 - var4 = a;// 44 - } catch (var14: RuntimeException) {// 46 - var10000 = this;// 45 - var15 = if (var15 == a) b else a;// 47 49 - var4 = var15;// 51 - } - - val var8: java.lang.String = var4;// 52 - var7 = var10000; - - var var10001: java.lang.String; - try { - var4 = StringsKt.repeat(var15 as java.lang.CharSequence, 5); - var15 = var4; - var10000 = var7; - var10001 = var8; - var4 = var4;// 53 - } catch (var12: RuntimeException) {// 54 - var10000 = var10000; - var10001 = var4; - System.out.println(var15);// 55 - var var10003: java.lang.String = var12.getMessage(); - if (var10003 == null) { - var10003 = ""; - } - - var4 = "$var15!!$var10003";// 56 - } - - var10000.test1(var10001, var4);// 34 - }// 58 -} - -class 'pkg/TestTryCatchExpressions' { - method 'test0 (Ljava/lang/String;)V' { - 7 10 - 8 10 - 9 10 - a 10 - b 10 - c 10 - d 10 - e 10 - f 10 - 13 11 - 14 12 - 15 12 - 16 12 - 17 12 - 19 13 - 1a 13 - 1b 13 - 1d 14 - 1e 14 - 1f 17 - 20 20 - 22 20 - 23 20 - 24 20 - 25 20 - 26 20 - 27 20 - 28 20 - 29 21 + // $VF: Couldn't be decompiled + // Bytecode: + // 00: aload 1 + // 01: ldc "s" + // 03: invokestatic kotlin/jvm/internal/Intrinsics.checkNotNullParameter (Ljava/lang/Object;Ljava/lang/String;)V + // 06: nop + // 07: aload 1 + // 08: checkcast java/lang/CharSequence + // 0b: bipush 5 + // 0c: invokestatic kotlin/text/StringsKt.repeat (Ljava/lang/CharSequence;I)Ljava/lang/String; + // 0f: astore 2 + // 10: goto 20 + // 13: astore 3 + // 14: aload 3 + // 15: invokevirtual java/lang/RuntimeException.getMessage ()Ljava/lang/String; + // 18: dup + // 19: ifnonnull 1f + // 1c: pop + // 1d: ldc "ERROR" + // 1f: astore 2 + // 20: aload 2 + // 21: astore 2 + // 22: getstatic java/lang/System.out Ljava/io/PrintStream; + // 25: aload 2 + // 26: invokevirtual java/io/PrintStream.print (Ljava/lang/Object;)V + // 29: return } - method 'test1 (Ljava/lang/String;Ljava/lang/String;)V' { - c 24 - d 24 - e 25 - f 25 - 10 25 - 12 30 - 13 30 - 14 31 - 15 31 - 16 31 - 17 31 - 18 31 - 19 31 - 1a 31 - 1b 31 - 1c 31 - 1d 31 - 21 32 - 23 33 - 24 33 - 25 34 - 26 34 - 27 35 - 28 35 - 29 35 - 2a 35 - 2b 35 - 2d 36 - 2e 36 - 2f 36 - 31 37 - 32 37 - 33 40 - 34 40 - 35 43 - 36 43 - 37 43 - 38 43 - 39 44 - 3a 44 - 3c 48 - 3d 48 - 3e 49 - 3f 49 - 40 50 - 41 50 - 42 50 - 43 50 - 44 50 - 45 50 - 46 50 - 47 50 - 48 50 - 49 50 - 4d 51 - 4f 52 - 50 52 - 51 53 - 52 53 - 53 54 - 54 54 - 55 54 - 56 54 - 57 54 - 59 55 - 5a 55 - 5b 55 - 5d 56 - 5e 56 - 5f 59 - 60 59 - 61 62 - 62 62 - 63 62 - 64 62 - 65 62 - 66 62 - 67 62 - 68 62 - 69 62 - 6a 62 - 6b 63 + public fun test1(a: String, b: String) { + // $VF: Couldn't be decompiled + // Bytecode: + // 00: aload 1 + // 01: ldc "a" + // 03: invokestatic kotlin/jvm/internal/Intrinsics.checkNotNullParameter (Ljava/lang/Object;Ljava/lang/String;)V + // 06: aload 2 + // 07: ldc "b" + // 09: invokestatic kotlin/jvm/internal/Intrinsics.checkNotNullParameter (Ljava/lang/Object;Ljava/lang/String;)V + // 0c: aload 1 + // 0d: astore 3 + // 0e: aload 0 + // 0f: astore 6 + // 11: nop + // 12: aload 6 + // 14: aload 3 + // 15: checkcast java/lang/CharSequence + // 18: bipush 5 + // 19: invokestatic kotlin/text/StringsKt.repeat (Ljava/lang/CharSequence;I)Ljava/lang/String; + // 1c: astore 4 + // 1e: goto 35 + // 21: astore 5 + // 23: aload 6 + // 25: aload 2 + // 26: astore 3 + // 27: aload 5 + // 29: invokevirtual java/lang/RuntimeException.getMessage ()Ljava/lang/String; + // 2c: dup + // 2d: ifnonnull 33 + // 30: pop + // 31: ldc "ERROR" + // 33: astore 4 + // 35: aload 4 + // 37: astore 7 + // 39: astore 6 + // 3b: nop + // 3c: aload 6 + // 3e: aload 7 + // 40: aload 3 + // 41: checkcast java/lang/CharSequence + // 44: bipush 5 + // 45: invokestatic kotlin/text/StringsKt.repeat (Ljava/lang/CharSequence;I)Ljava/lang/String; + // 48: astore 4 + // 4a: goto 61 + // 4d: astore 5 + // 4f: aload 6 + // 51: aload 7 + // 53: aload 5 + // 55: invokevirtual java/lang/RuntimeException.getMessage ()Ljava/lang/String; + // 58: dup + // 59: ifnonnull 5f + // 5c: pop + // 5d: ldc "ERROR" + // 5f: astore 4 + // 61: aload 4 + // 63: invokedynamic makeConcatWithConstants (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001" ] + // 68: invokevirtual pkg/TestTryCatchExpressions.test0 (Ljava/lang/String;)V + // 6b: return } - method 'test2 (Ljava/lang/String;Ljava/lang/String;)V' { - e 66 - f 66 - 10 67 - 11 67 - 12 67 - 14 72 - 15 72 - 16 73 - 17 73 - 18 73 - 19 73 - 1a 73 - 1b 73 - 1c 73 - 1d 73 - 1e 73 - 1f 73 - 20 73 - 21 74 - 22 77 - 23 77 - 24 78 - 25 78 - 26 78 - 27 78 - 28 78 - 29 79 - 2a 79 - 2b 79 - 2f 80 - 31 81 - 32 81 - 33 82 - 34 82 - 35 83 - 36 83 - 37 83 - 38 83 - 39 83 - 3a 83 - 3b 83 - 3c 83 - 3d 83 - 3e 84 - 3f 84 - 40 84 - 41 84 - 42 84 - 43 84 - 49 86 - 4a 86 - 4b 87 - 4c 87 - 50 87 - 51 87 - 52 87 - 53 87 - 57 87 - 58 85 - 59 88 - 5a 88 - 5b 88 - 5c 88 - 5d 88 - 5e 88 - 5f 91 - 60 91 - 61 91 - 62 91 - 63 92 - 64 92 - 66 98 - 67 98 - 68 99 - 69 99 - 6a 96 - 6b 96 - 6c 96 - 6d 96 - 6e 96 - 6f 96 - 70 96 - 71 96 - 72 96 - 73 96 - 74 97 - 75 97 - 7f 97 - 80 97 - 81 97 - 87 98 - 88 98 - 89 99 - 8a 99 - 8b 100 - 8c 100 - 8d 100 - 8e 100 - 92 101 - 94 102 - 95 102 - 96 103 - 97 103 - 98 104 - 99 104 - 9a 104 - 9b 104 - 9d 104 - 9e 104 - 9f 104 - a0 110 - a1 105 - a2 105 - a3 105 - a4 105 - a5 105 - a7 106 - a8 106 - a9 106 - ab 107 - ac 107 - ad 110 - ae 110 - af 110 - b0 110 - b1 110 - b2 110 - b3 110 - b4 113 - b5 113 - b6 113 - b7 113 - b8 113 - b9 114 + public fun test2(a: String, b: String) { + // $VF: Couldn't be decompiled + // Bytecode: + // 00: aload 1 + // 01: ldc "a" + // 03: invokestatic kotlin/jvm/internal/Intrinsics.checkNotNullParameter (Ljava/lang/Object;Ljava/lang/String;)V + // 06: aload 2 + // 07: ldc "b" + // 09: invokestatic kotlin/jvm/internal/Intrinsics.checkNotNullParameter (Ljava/lang/Object;Ljava/lang/String;)V + // 0c: aconst_null + // 0d: astore 3 + // 0e: aload 1 + // 0f: astore 3 + // 10: aload 0 + // 11: astore 7 + // 13: nop + // 14: aload 7 + // 16: aload 1 + // 17: invokevirtual java/lang/String.length ()I + // 1a: aload 2 + // 1b: invokevirtual java/lang/String.length ()I + // 1e: if_icmpeq 22 + // 21: return + // 22: aload 2 + // 23: astore 3 + // 24: aload 0 + // 25: aload 3 + // 26: invokevirtual pkg/TestTryCatchExpressions.test0 (Ljava/lang/String;)V + // 29: aload 3 + // 2a: astore 4 + // 2c: goto 5f + // 2f: astore 5 + // 31: aload 7 + // 33: aload 1 + // 34: astore 3 + // 35: aload 0 + // 36: aload 1 + // 37: aload 3 + // 38: checkcast java/lang/String + // 3b: invokevirtual pkg/TestTryCatchExpressions.test1 (Ljava/lang/String;Ljava/lang/String;)V + // 3e: aload 3 + // 3f: checkcast java/lang/String + // 42: astore 4 + // 44: goto 5f + // 47: astore 5 + // 49: aload 7 + // 4b: aload 3 + // 4c: aload 1 + // 4d: invokestatic kotlin/jvm/internal/Intrinsics.areEqual (Ljava/lang/Object;Ljava/lang/Object;)Z + // 50: ifeq 57 + // 53: aload 2 + // 54: goto 58 + // 57: aload 1 + // 58: astore 3 + // 59: aload 3 + // 5a: checkcast java/lang/String + // 5d: astore 4 + // 5f: aload 4 + // 61: astore 8 + // 63: astore 7 + // 65: nop + // 66: aload 7 + // 68: aload 8 + // 6a: aload 3 + // 6b: checkcast java/lang/CharSequence + // 6e: bipush 5 + // 6f: invokestatic kotlin/text/StringsKt.repeat (Ljava/lang/CharSequence;I)Ljava/lang/String; + // 72: astore 4 + // 74: aload 4 + // 76: astore 5 + // 78: astore 10 + // 7a: astore 9 + // 7c: bipush 0 + // 7d: istore 6 + // 7f: aload 5 + // 81: astore 3 + // 82: getstatic kotlin/Unit.INSTANCE Lkotlin/Unit; + // 85: astore 11 + // 87: aload 9 + // 89: aload 10 + // 8b: aload 4 + // 8d: astore 4 + // 8f: goto b4 + // 92: astore 5 + // 94: aload 7 + // 96: aload 8 + // 98: aload 3 + // 99: getstatic java/lang/System.out Ljava/io/PrintStream; + // 9c: swap + // 9d: invokevirtual java/io/PrintStream.println (Ljava/lang/Object;)V + // a0: aload 3 + // a1: aload 5 + // a3: invokevirtual java/lang/RuntimeException.getMessage ()Ljava/lang/String; + // a6: dup + // a7: ifnonnull ad + // aa: pop + // ab: ldc "" + // ad: invokedynamic makeConcatWithConstants (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001!!\u0001" ] + // b2: astore 4 + // b4: aload 4 + // b6: invokevirtual pkg/TestTryCatchExpressions.test1 (Ljava/lang/String;Ljava/lang/String;)V + // b9: return } } -Lines mapping: -7 <-> 21 -9 <-> 11 -10 <-> 12 -11 <-> 13 -14 <-> 22 -17 <-> 25 -18 <-> 63 -19 <-> 26 -20 <-> 32 -21 <-> 33 -22 <-> 35 -23 <-> 36 -24 <-> 44 -25 <-> 51 -26 <-> 52 -27 <-> 55 -30 <-> 64 -33 <-> 67 -34 <-> 114 -35 <-> 74 -36 <-> 75 -38 <-> 78 -39 <-> 79 -40 <-> 80 -41 <-> 81 -42 <-> 83 -43 <-> 84 -44 <-> 85 -45 <-> 87 -46 <-> 86 -47 <-> 88 -49 <-> 88 -51 <-> 89 -52 <-> 92 -53 <-> 101 -54 <-> 102 -55 <-> 105 -56 <-> 111 -58 <-> 115 -Not mapped: -8 -60 diff --git a/plugins/kotlin/testData/results/pkg/TestTryFinallyExpressions.dec b/plugins/kotlin/testData/results/pkg/TestTryFinallyExpressions.dec index b78b85e77..05c8835e9 100644 --- a/plugins/kotlin/testData/results/pkg/TestTryFinallyExpressions.dec +++ b/plugins/kotlin/testData/results/pkg/TestTryFinallyExpressions.dec @@ -43,9 +43,9 @@ public class TestTryFinallyExpressions { label68: { var var19: java.lang.String = a;// 28 - label69: { - label70: { - label71: { + run label69@{ + run label70@{ + run label71@{ try { try { if (a == b) {// 30