tests fix

This commit is contained in:
Jindra Petřík
2025-08-22 20:05:29 +02:00
parent 4b48b8408a
commit b2c4b437a4
4 changed files with 41 additions and 13 deletions
@@ -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);
}