Fixed #1842 AS - Do not display §§dup when the value has no sideeffect

This commit is contained in:
Jindra Petřík
2023-01-15 17:10:23 +01:00
parent b73832f51e
commit 125e8d29cd
3 changed files with 7 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ public class DuplicateItem extends GraphTargetItem implements SimpleValue {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (((value instanceof SimpleValue) && (((SimpleValue) value).isSimpleValue())) || !Configuration.displayDupInstructions.get()) {
if (!value.hasSideEffect() || !Configuration.displayDupInstructions.get()) {
return value.appendTry(writer, localData);
}
writer.append("§§dup(");

View File

@@ -62,4 +62,9 @@ public class PopItem extends GraphTargetItem {
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return generator.generate(localData, this);
}
@Override
public boolean hasSideEffect() {
return true; //?
}
}