mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 02:40:45 +00:00
loop mismatch problem fixed, do-while formatting fixed, added some code formatting properties
This commit is contained in:
@@ -43,7 +43,11 @@ public class WithAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("with(");
|
||||
writer.append("with");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesWithParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
scope.toString(writer, localData);
|
||||
writer.append(")").newLine();
|
||||
writer.append("{").newLine();
|
||||
|
||||
@@ -82,7 +82,11 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("for each (");
|
||||
writer.append("for each");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesForEachParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
expression.toString(writer, localData);
|
||||
writer.append(")").newLine();
|
||||
writer.append("{").newLine();
|
||||
|
||||
@@ -82,7 +82,11 @@ public class ForInAVM2Item extends LoopItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("for (");
|
||||
writer.append("for");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesForParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
expression.toString(writer, localData);
|
||||
writer.append(")").newLine();
|
||||
writer.append("{").newLine();
|
||||
|
||||
@@ -159,7 +159,8 @@ public class Traits implements Serializable {
|
||||
|
||||
futureResults = new ArrayList<>();
|
||||
for (int t = 0; t < traits.size(); t++) {
|
||||
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel);
|
||||
// each convert task needs a separate NulWriter, because they are executed parallel
|
||||
TraitConvertTask task = new TraitConvertTask(traits.get(t), parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, new NulWriter(), fullyQualifiedNames, t, parallel);
|
||||
Future<Void> future = executor.submit(task);
|
||||
futureResults.add(future);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,11 @@ public class ForInActionItem extends LoopActionItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("for(");
|
||||
writer.append("for");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesForParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
if ((variableName instanceof DirectValueActionItem) && (((DirectValueActionItem) variableName).value instanceof RegisterNumber)) {
|
||||
writer.append("var ");
|
||||
}
|
||||
|
||||
@@ -76,7 +76,11 @@ public class TryActionItem extends ActionItem implements Block {
|
||||
writer.append("}");
|
||||
for (int e = 0; e < catchExceptions.size(); e++) {
|
||||
writer.newLine();
|
||||
writer.append("catch(");
|
||||
writer.append("catch");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesCatchParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
catchExceptions.get(e).toStringNoQuotes(writer, localData);
|
||||
writer.append(")").newLine();
|
||||
writer.append("{").newLine();
|
||||
|
||||
@@ -48,7 +48,11 @@ public class WithActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("with(");
|
||||
writer.append("with");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesWithParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
scope.toString(writer, localData);
|
||||
writer.append(")").newLine();
|
||||
writer.append("{").newLine();
|
||||
|
||||
@@ -25,4 +25,29 @@ public class CodeFormatting {
|
||||
public String newLineChars = "\r\n";
|
||||
public String indentString = " ";
|
||||
public boolean beginBlockOnNewLine = true;
|
||||
|
||||
// spaces
|
||||
// before parentheses
|
||||
public boolean spaceBeforeParenthesesMethodCallParentheses = false;
|
||||
public boolean spaceBeforeParenthesesMethodCallEmptyParentheses = false;
|
||||
public boolean spaceBeforeArrayAccessBrackets = false;
|
||||
public boolean spaceBeforeParenthesesMethodDeclarationParentheses = false;
|
||||
public boolean spaceBeforeParenthesesMethodDeclarationEmptyParentheses = false;
|
||||
public boolean spaceBeforeParenthesesIfParentheses = false;
|
||||
public boolean spaceBeforeParenthesesWithParentheses = false;
|
||||
public boolean spaceBeforeParenthesesWhileParentheses = false;
|
||||
public boolean spaceBeforeParenthesesCatchParentheses = false;
|
||||
public boolean spaceBeforeParenthesesSwitchParentheses = false;
|
||||
public boolean spaceBeforeParenthesesForParentheses = false;
|
||||
public boolean spaceBeforeParenthesesForEachParentheses = false;
|
||||
|
||||
// around operators
|
||||
public boolean spaceAroundOperatorsAssignmentOperators = false; // =, +=,...
|
||||
public boolean spaceAroundOperatorsLogicalOperators = false; // &&, ||
|
||||
public boolean spaceAroundOperatorsEqualityOperators = false; // ==, !=
|
||||
public boolean spaceAroundOperatorsRelationalOperator = false; // <, >, <=, >=
|
||||
public boolean spaceAroundOperatorsBitwiseOperator = false; // &, |, ^
|
||||
public boolean spaceAroundOperatorsAdditiveOperator = false; // +, -
|
||||
public boolean spaceAroundOperatorsMultiplicativeOperator = false; // *, /, %
|
||||
public boolean spaceAroundOperatorsShiftOperator = false; // <<, >>
|
||||
}
|
||||
|
||||
@@ -65,14 +65,17 @@ public class DoWhileItem extends LoopItem implements Block {
|
||||
}
|
||||
writer.append("do");
|
||||
writer.startBlock();
|
||||
writer.indent();
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ti.toStringSemicoloned(writer, localData).newLine();
|
||||
}
|
||||
}
|
||||
writer.endBlock();
|
||||
writer.append("while(");
|
||||
writer.endBlock().newLine();
|
||||
writer.append("while");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesWhileParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
|
||||
for (int i = 0; i < expression.size(); i++) {
|
||||
if (expression.get(i).isEmpty()) {
|
||||
|
||||
@@ -68,7 +68,11 @@ public class ForItem extends LoopItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("for(");
|
||||
writer.append("for");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesForParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
int p = 0;
|
||||
for (int i = 0; i < firstCommands.size(); i++) {
|
||||
if (firstCommands.get(i).isEmpty()) {
|
||||
|
||||
@@ -81,7 +81,11 @@ public class IfItem extends GraphTargetItem implements Block {
|
||||
elseBranch = onTrue;
|
||||
}
|
||||
}
|
||||
writer.append("if(");
|
||||
writer.append("if");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesIfParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
expr.toString(writer, localData);
|
||||
writer.append(")").startBlock();
|
||||
for (GraphTargetItem ti : ifBranch) {
|
||||
|
||||
@@ -70,7 +70,11 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loopswitch" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("switch(");
|
||||
writer.append("switch");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesSwitchParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
switchedObject.toString(writer, localData);
|
||||
writer.append(")").startBlock();
|
||||
for (int i = 0; i < caseCommands.size(); i++) {
|
||||
|
||||
@@ -53,7 +53,11 @@ public class UniversalLoopItem extends LoopItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("while(true)").startBlock();
|
||||
writer.append("while").startBlock();
|
||||
if (writer.getFormatting().spaceBeforeParenthesesWhileParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(true)").startBlock();
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (!ti.isEmpty()) {
|
||||
ti.toStringSemicoloned(writer, localData).newLine();
|
||||
|
||||
@@ -58,7 +58,11 @@ public class WhileItem extends LoopItem implements Block {
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("while(");
|
||||
writer.append("while");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesWhileParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
for (int i = 0; i < expression.size(); i++) {
|
||||
if (expression.get(i).isEmpty()) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user