|
|
@ -15,13 +15,11 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.jetbrains.java.decompiler.modules.decompiler.stats; |
|
|
|
package org.jetbrains.java.decompiler.modules.decompiler.stats; |
|
|
|
|
|
|
|
|
|
|
|
import org.jetbrains.java.decompiler.main.DecompilerContext; |
|
|
|
|
|
|
|
import org.jetbrains.java.decompiler.main.TextBuffer; |
|
|
|
import org.jetbrains.java.decompiler.main.TextBuffer; |
|
|
|
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; |
|
|
|
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; |
|
|
|
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; |
|
|
|
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; |
|
|
|
import org.jetbrains.java.decompiler.modules.decompiler.StatEdge; |
|
|
|
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.Exprent; |
|
|
|
import org.jetbrains.java.decompiler.util.InterpreterUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -94,51 +92,48 @@ public class DoStatement extends Statement { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { |
|
|
|
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) { |
|
|
|
String indstr = InterpreterUtil.getIndentString(indent); |
|
|
|
|
|
|
|
TextBuffer buf = new TextBuffer(); |
|
|
|
TextBuffer buf = new TextBuffer(); |
|
|
|
|
|
|
|
|
|
|
|
String new_line_separator = DecompilerContext.getNewLineSeparator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer)); |
|
|
|
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer)); |
|
|
|
|
|
|
|
|
|
|
|
if (isLabeled()) { |
|
|
|
if (isLabeled()) { |
|
|
|
buf.append(indstr).append("label").append(this.id.toString()).append(":").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("label").append(this.id.toString()).append(":").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (looptype) { |
|
|
|
switch (looptype) { |
|
|
|
case LOOP_DO: |
|
|
|
case LOOP_DO: |
|
|
|
buf.append(indstr).append("while(true) {").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("while(true) {").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(indstr).append("}").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("}").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case LOOP_DOWHILE: |
|
|
|
case LOOP_DOWHILE: |
|
|
|
buf.append(indstr).append("do {").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("do {").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(indstr).append("} while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(");").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("} while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(");").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case LOOP_WHILE: |
|
|
|
case LOOP_WHILE: |
|
|
|
buf.append(indstr).append("while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(") {").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(") {").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(indstr).append("}").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("}").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case LOOP_FOR: |
|
|
|
case LOOP_FOR: |
|
|
|
buf.append(indstr).append("for("); |
|
|
|
buf.appendIndent(indent).append("for("); |
|
|
|
if (initExprent.get(0) != null) { |
|
|
|
if (initExprent.get(0) != null) { |
|
|
|
buf.append(initExprent.get(0).toJava(indent, tracer)); |
|
|
|
buf.append(initExprent.get(0).toJava(indent, tracer)); |
|
|
|
} |
|
|
|
} |
|
|
|
buf.append("; ") |
|
|
|
buf.append("; ") |
|
|
|
.append(conditionExprent.get(0).toJava(indent, tracer)).append("; ").append(incExprent.get(0).toJava(indent, tracer)).append(") {") |
|
|
|
.append(conditionExprent.get(0).toJava(indent, tracer)).append("; ").append(incExprent.get(0).toJava(indent, tracer)).append(") {") |
|
|
|
.append(new_line_separator); |
|
|
|
.appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer)); |
|
|
|
buf.append(indstr).append("}").append(new_line_separator); |
|
|
|
buf.appendIndent(indent).append("}").appendLineSeparator(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
tracer.incrementCurrentSourceLine(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|