diff --git a/src/main/java/org/eolang/jeo/representation/bytecode/BytecodeMethod.java b/src/main/java/org/eolang/jeo/representation/bytecode/BytecodeMethod.java index 0189e87d2..9aa2ad82c 100644 --- a/src/main/java/org/eolang/jeo/representation/bytecode/BytecodeMethod.java +++ b/src/main/java/org/eolang/jeo/representation/bytecode/BytecodeMethod.java @@ -439,14 +439,6 @@ private int computeStack() { * @return Max local variables. */ private int computeLocals() { -// return new MaxLocals( -// this.properties, -// this.instructions, -// this.tryblocks.stream() -// .filter(BytecodeTryCatchBlock.class::isInstance) -// .map(BytecodeTryCatchBlock.class::cast) -// .collect(Collectors.toList()) -// ).value(); return new MaxLocals( this.properties, this.instructions, diff --git a/src/main/java/org/eolang/jeo/representation/bytecode/DataFlow.java b/src/main/java/org/eolang/jeo/representation/bytecode/DataFlow.java deleted file mode 100644 index b440662b9..000000000 --- a/src/main/java/org/eolang/jeo/representation/bytecode/DataFlow.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2024 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.eolang.jeo.representation.bytecode; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import org.objectweb.asm.Label; - -/** - * Data-flow analysis. - * This class knows how to compute the maximum value of a reducible element based - * on the instruction flow. - * @param Type of the reducible element. - * @since 0.6 - */ -public final class DataFlow> { - private final InstructionsFlow instructions; - private final List blocks; - - DataFlow(final InstructionsFlow instr, final List catches) { - this.instructions = instr; - this.blocks = new ArrayList<>(catches); - } - - public T max(T initial, Function generator) { - final Map visited = new HashMap<>(0); - final Map worklist = new HashMap<>(0); - worklist.put(0, initial); - final int total = this.instructions.size(); - T current; - while (!worklist.isEmpty()) { - final Map.Entry curr = worklist.entrySet() - .stream() - .findFirst() - .orElseThrow(() -> new IllegalStateException("Cannot find first worklist element")); - int index = curr.getKey(); - current = curr.getValue(); - worklist.remove(index); - if (visited.get(index) != null || visited.get(index).compareTo(current) >= 0) { - continue; - } - while (index < total) { - final BytecodeEntry entry = this.instructions.get(index); - if (entry instanceof BytecodeInstruction) { - final BytecodeInstruction instruction = BytecodeInstruction.class.cast(entry); - current = current.add(generator.apply(instruction)); - final T updated = current; - if (instruction.isSwitch()) { - final List