diff --git a/src/main/java/org/eolang/opeo/SelectiveDecompiler.java b/src/main/java/org/eolang/opeo/SelectiveDecompiler.java index d28b72d7..6f22ef07 100644 --- a/src/main/java/org/eolang/opeo/SelectiveDecompiler.java +++ b/src/main/java/org/eolang/opeo/SelectiveDecompiler.java @@ -25,8 +25,10 @@ import com.jcabi.log.Logger; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import org.eolang.opeo.decompilation.Decompiler; import org.eolang.opeo.decompilation.WithoutAliases; @@ -118,8 +120,8 @@ public void decompile() { this.storage.all().parallel().forEach( entry -> { final XmirEntry res; - final List opcodes = entry.xpath(this.unsupportedOpcodes()); final List trycatches = entry.xpath(SelectiveDecompiler.trycatches()); + final Set opcodes = this.unsupported(entry); if (opcodes.isEmpty() && trycatches.isEmpty()) { res = entry.transform( xml -> new WithoutAliases( @@ -143,16 +145,20 @@ public void decompile() { } /** - * Xpath to find all opcodes that are not supported. - * @return Xpath. + * Find all opcodes that are not supported. + * @param entry XMIR entry. + * @return Set of unsupported opcodes. */ - private String unsupportedOpcodes() { - return String.format( - "//o[@base='opcode' and not(%s)]/@name", - Arrays.stream(this.supported) - .map(s -> String.format("substring-before(concat(@name, '-'), '-') = '%s'", s)) - .collect(Collectors.joining(" or ")) - ); + private Set unsupported(final XmirEntry entry) { + final Set all = entry.xpath( + "//o[@base='opcode']/@name") + .stream() + .map(s -> String.format("%s%s", s, "-")) + .map(s -> s.substring(0, s.indexOf('-'))) + .collect(Collectors.toSet()); + final Set sup = Arrays.stream(this.supported).collect(Collectors.toSet()); + all.removeAll(sup); + return all; } /** diff --git a/src/test/resources/xmir/disassembled/ArrayBuilders$ByteBuilder.xmir b/src/test/resources/xmir/disassembled/ArrayBuilders$ByteBuilder.xmir index 5834c3b8..b95b1f60 100644 --- a/src/test/resources/xmir/disassembled/ArrayBuilders$ByteBuilder.xmir +++ b/src/test/resources/xmir/disassembled/ArrayBuilders$ByteBuilder.xmir @@ -51,7 +51,7 @@ 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 01 - + 00 00 00 00 00 00 00 BC 00 00 00 00 00 00 00 08