mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-09 17:01:52 +00:00
tests fix
This commit is contained in:
@@ -37,20 +37,21 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* AVM2 dialect.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2GraphTargetDialect extends GraphTargetDialect {
|
||||
|
||||
public static final GraphTargetDialect INSTANCE = new AVM2GraphTargetDialect();
|
||||
|
||||
|
||||
private AVM2GraphTargetDialect() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AVM2";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem valToItem(Object r) {
|
||||
@@ -101,4 +102,9 @@ public class AVM2GraphTargetDialect extends GraphTargetDialect {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesAllowMultilevelBreaks() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* AVM1 dialect.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionGraphTargetDialect extends GraphTargetDialect {
|
||||
@@ -106,4 +107,9 @@ public class ActionGraphTargetDialect extends GraphTargetDialect {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesAllowMultilevelBreaks() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,21 +18,31 @@ package com.jpexs.decompiler.graph;
|
||||
|
||||
/**
|
||||
* Dialect - high level language type.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class GraphTargetDialect {
|
||||
|
||||
/**
|
||||
* Identifier of the dialect.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
|
||||
/**
|
||||
* Conversion of ECMA value (that's used in simplifications)
|
||||
* back to GraphTarget item.
|
||||
* Conversion of ECMA value (that's used in simplifications) back to
|
||||
* GraphTarget item.
|
||||
*
|
||||
* @param value Ecma value
|
||||
* @return GraphTarget item
|
||||
*/
|
||||
public abstract GraphTargetItem valToItem(Object value);
|
||||
|
||||
/**
|
||||
* Checks whether this dialect allows multi level breaks
|
||||
*
|
||||
* @return True when allows
|
||||
*/
|
||||
public abstract boolean doesAllowMultilevelBreaks();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BreakItem extends GraphTargetItem {
|
||||
* Is placed at end of the script (or function)
|
||||
*/
|
||||
public boolean isScriptEnd = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -64,18 +64,24 @@ public class BreakItem extends GraphTargetItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
if (isScriptEnd) {
|
||||
writer.append("return");
|
||||
return writer;
|
||||
}
|
||||
writer.append("break");
|
||||
if (writer instanceof NulWriter) {
|
||||
NulWriter nulWriter = (NulWriter) writer;
|
||||
labelRequired = loopId != nulWriter.getLoop();
|
||||
if (labelRequired) {
|
||||
if (!dialect.doesAllowMultilevelBreaks() && isScriptEnd) {
|
||||
writer.append("return");
|
||||
return writer;
|
||||
}
|
||||
nulWriter.setLoopUsed(loopId);
|
||||
}
|
||||
}
|
||||
if (labelRequired) {
|
||||
if (!dialect.doesAllowMultilevelBreaks() && isScriptEnd) {
|
||||
writer.append("return");
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
writer.append("break");
|
||||
if (labelRequired) {
|
||||
writer.append(" loop").append(loopId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user