mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 16:30:45 +00:00
Default clause position in switch fixed
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.jpexs.decompiler.graph.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
|
||||
public class DefaultItem extends GraphTargetItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
return writer.append("default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,8 +42,6 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
|
||||
public List<List<GraphTargetItem>> caseCommands;
|
||||
|
||||
public List<GraphTargetItem> defaultCommands;
|
||||
|
||||
public List<Integer> valuesMapping;
|
||||
|
||||
private boolean labelUsed;
|
||||
@@ -52,18 +50,14 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
public List<List<GraphTargetItem>> getSubs() {
|
||||
List<List<GraphTargetItem>> ret = new ArrayList<>();
|
||||
ret.addAll(caseCommands);
|
||||
if (defaultCommands != null) {
|
||||
ret.add(defaultCommands);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SwitchItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, GraphTargetItem switchedObject, List<GraphTargetItem> caseValues, List<List<GraphTargetItem>> caseCommands, List<GraphTargetItem> defaultCommands, List<Integer> valuesMapping) {
|
||||
public SwitchItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, Loop loop, GraphTargetItem switchedObject, List<GraphTargetItem> caseValues, List<List<GraphTargetItem>> caseCommands, List<Integer> valuesMapping) {
|
||||
super(instruction, lineStartIns, loop);
|
||||
this.switchedObject = switchedObject;
|
||||
this.caseValues = caseValues;
|
||||
this.caseCommands = caseCommands;
|
||||
this.defaultCommands = defaultCommands;
|
||||
this.valuesMapping = valuesMapping;
|
||||
}
|
||||
|
||||
@@ -90,7 +84,9 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
for (int i = 0; i < caseCommands.size(); i++) {
|
||||
for (int k = 0; k < valuesMapping.size(); k++) {
|
||||
if (valuesMapping.get(k) == i) {
|
||||
writer.append("case ");
|
||||
if (!(caseValues.get(k) instanceof DefaultItem)) {
|
||||
writer.append("case ");
|
||||
}
|
||||
caseValues.get(k).toString(writer, localData);
|
||||
writer.append(":").newLine();
|
||||
}
|
||||
@@ -103,19 +99,6 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
}
|
||||
writer.unindent();
|
||||
}
|
||||
if (defaultCommands != null) {
|
||||
if (defaultCommands.size() > 0) {
|
||||
writer.append("default");
|
||||
writer.append(":").newLine();
|
||||
writer.indent();
|
||||
for (int j = 0; j < defaultCommands.size(); j++) {
|
||||
if (!defaultCommands.get(j).isEmpty()) {
|
||||
defaultCommands.get(j).toStringSemicoloned(writer, localData).newLine();
|
||||
}
|
||||
}
|
||||
writer.unindent();
|
||||
}
|
||||
}
|
||||
writer.endBlock();
|
||||
if (writer instanceof NulWriter) {
|
||||
LoopWithType loopOjb = ((NulWriter) writer).endLoop(loop.id);
|
||||
@@ -138,16 +121,6 @@ public class SwitchItem extends LoopItem implements Block {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defaultCommands != null) {
|
||||
for (GraphTargetItem ti : defaultCommands) {
|
||||
if (ti instanceof ContinueItem) {
|
||||
ret.add((ContinueItem) ti);
|
||||
}
|
||||
if (ti instanceof Block) {
|
||||
ret.addAll(((Block) ti).getContinues());
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user