From e1c3237af560de116e1bc0f7510014f92c3c89c1 Mon Sep 17 00:00:00 2001 From: volodya-lombrozo Date: Mon, 12 Aug 2024 16:39:03 +0300 Subject: [PATCH] feat(#376): fix several code offences --- .../opeo/decompilation/DecompilerState.java | 2 +- .../opeo/decompilation/OperandStack.java | 2 - .../opeo/decompilation/agents/AddAgent.java | 2 +- .../opeo/decompilation/agents/AllAgents.java | 4 +- .../decompilation/agents/BipushAgent.java | 2 +- .../opeo/decompilation/agents/CastAgent.java | 64 ++++++++++--------- .../decompilation/agents/CheckCastAgent.java | 7 +- .../opeo/decompilation/agents/ConstAgent.java | 2 +- .../opeo/decompilation/agents/DupAgent.java | 2 +- .../decompilation/agents/GetFieldAgent.java | 2 +- .../decompilation/agents/GetStaticAgent.java | 2 +- .../opeo/decompilation/agents/IfAgent.java | 2 +- .../agents/InvokedynamicAgent.java | 2 +- .../agents/InvokeinterfaceAgent.java | 2 +- .../agents/InvokespecialAgent.java | 2 +- .../agents/InvokestaticAgent.java | 2 +- .../agents/InvokevirtualAgent.java | 2 +- .../opeo/decompilation/agents/LabelAgent.java | 2 +- .../opeo/decompilation/agents/LdcAgent.java | 2 +- .../opeo/decompilation/agents/LoadAgent.java | 27 ++++++-- .../opeo/decompilation/agents/MulAgent.java | 2 +- .../opeo/decompilation/agents/NewAgent.java | 2 +- .../decompilation/agents/NewArrayAgent.java | 2 +- .../opeo/decompilation/agents/PopAgent.java | 4 +- .../decompilation/agents/PutFieldAgent.java | 2 +- .../decompilation/agents/ReturnAgent.java | 2 +- .../opeo/decompilation/agents/StoreAgent.java | 2 +- .../agents/StoreToArrayAgent.java | 2 +- .../agents/SubstractionAgent.java | 2 +- .../eolang/opeo/ast/ArrayConstructorTest.java | 8 ++- .../decompilation/DecompilerMachineTest.java | 1 - 31 files changed, 93 insertions(+), 70 deletions(-) diff --git a/src/main/java/org/eolang/opeo/decompilation/DecompilerState.java b/src/main/java/org/eolang/opeo/decompilation/DecompilerState.java index 6cb1bd10..8f832f0c 100644 --- a/src/main/java/org/eolang/opeo/decompilation/DecompilerState.java +++ b/src/main/java/org/eolang/opeo/decompilation/DecompilerState.java @@ -112,7 +112,7 @@ public boolean hasInstructions() { * Remove current instruction from the list. * This is used when we decompile an instruction. */ - public void decompileInstruction() { + public void popInstruction() { if (!this.opcodes.isEmpty()) { this.opcodes.pop(); } diff --git a/src/main/java/org/eolang/opeo/decompilation/OperandStack.java b/src/main/java/org/eolang/opeo/decompilation/OperandStack.java index da100ddd..37ebdfcd 100644 --- a/src/main/java/org/eolang/opeo/decompilation/OperandStack.java +++ b/src/main/java/org/eolang/opeo/decompilation/OperandStack.java @@ -24,8 +24,6 @@ package org.eolang.opeo.decompilation; import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Collections; import java.util.Deque; import java.util.Iterator; import java.util.LinkedList; diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/AddAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/AddAgent.java index 66b0064b..072b8442 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/AddAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/AddAgent.java @@ -54,7 +54,7 @@ public void handle(final DecompilerState state) { final AstNode right = state.stack().pop(); final AstNode left = state.stack().pop(); state.stack().push(new Addition(left, right)); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/AllAgents.java b/src/main/java/org/eolang/opeo/decompilation/agents/AllAgents.java index 79719671..248a37b6 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/AllAgents.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/AllAgents.java @@ -173,7 +173,7 @@ public String[] supportedOpcodes() { * Unimplemented instruction handler. * @since 0.1 */ - private final static class UnimplementedAgent implements DecompilationAgent { + private static final class UnimplementedAgent implements DecompilationAgent { /** * Do we put numbers to opcodes? @@ -198,7 +198,7 @@ public void handle(final DecompilerState state) { this.counting ) ); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/BipushAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/BipushAgent.java index 3f37884a..209edbaa 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/BipushAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/BipushAgent.java @@ -47,7 +47,7 @@ public final class BipushAgent implements DecompilationAgent { public void handle(final DecompilerState state) { if (BipushAgent.SUPPORTED.contains(state.instruction().opcode())) { state.stack().push(new Literal(state.operand(0))); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/CastAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/CastAgent.java index 42dba666..72f77967 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/CastAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/CastAgent.java @@ -29,6 +29,7 @@ import org.eolang.opeo.ast.Cast; import org.eolang.opeo.decompilation.DecompilationAgent; import org.eolang.opeo.decompilation.DecompilerState; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; /** @@ -42,21 +43,21 @@ public final class CastAgent implements DecompilationAgent { */ private static final Set SUPPROTED = new HashSet<>( Arrays.asList( - org.objectweb.asm.Opcodes.I2B, - org.objectweb.asm.Opcodes.I2C, - org.objectweb.asm.Opcodes.I2S, - org.objectweb.asm.Opcodes.I2L, - org.objectweb.asm.Opcodes.I2F, - org.objectweb.asm.Opcodes.I2D, - org.objectweb.asm.Opcodes.L2I, - org.objectweb.asm.Opcodes.L2F, - org.objectweb.asm.Opcodes.L2D, - org.objectweb.asm.Opcodes.F2I, - org.objectweb.asm.Opcodes.F2L, - org.objectweb.asm.Opcodes.F2D, - org.objectweb.asm.Opcodes.D2I, - org.objectweb.asm.Opcodes.D2L, - org.objectweb.asm.Opcodes.D2F + Opcodes.I2B, + Opcodes.I2C, + Opcodes.I2S, + Opcodes.I2L, + Opcodes.I2F, + Opcodes.I2D, + Opcodes.L2I, + Opcodes.L2F, + Opcodes.L2D, + Opcodes.F2I, + Opcodes.F2L, + Opcodes.F2D, + Opcodes.D2I, + Opcodes.D2L, + Opcodes.D2F ) ); @@ -70,7 +71,7 @@ public void handle(final DecompilerState state) { state.stack().pop() ) ); - state.decompileInstruction(); + state.popInstruction(); } } @@ -78,37 +79,38 @@ public void handle(final DecompilerState state) { * Target type. * @param opcode Opcode to handle. * @return Target type. + * @checkstyle CyclomaticComplexityCheck (100 lines) */ private static Type target(final int opcode) { final Type result; switch (opcode) { - case org.objectweb.asm.Opcodes.I2B: + case Opcodes.I2B: result = Type.BYTE_TYPE; break; - case org.objectweb.asm.Opcodes.I2C: + case Opcodes.I2C: result = Type.CHAR_TYPE; break; - case org.objectweb.asm.Opcodes.I2S: + case Opcodes.I2S: result = Type.SHORT_TYPE; break; - case org.objectweb.asm.Opcodes.I2L: - case org.objectweb.asm.Opcodes.F2L: - case org.objectweb.asm.Opcodes.D2L: + case Opcodes.I2L: + case Opcodes.F2L: + case Opcodes.D2L: result = Type.LONG_TYPE; break; - case org.objectweb.asm.Opcodes.I2F: - case org.objectweb.asm.Opcodes.L2F: - case org.objectweb.asm.Opcodes.D2F: + case Opcodes.I2F: + case Opcodes.L2F: + case Opcodes.D2F: result = Type.FLOAT_TYPE; break; - case org.objectweb.asm.Opcodes.I2D: - case org.objectweb.asm.Opcodes.L2D: - case org.objectweb.asm.Opcodes.F2D: + case Opcodes.I2D: + case Opcodes.L2D: + case Opcodes.F2D: result = Type.DOUBLE_TYPE; break; - case org.objectweb.asm.Opcodes.L2I: - case org.objectweb.asm.Opcodes.F2I: - case org.objectweb.asm.Opcodes.D2I: + case Opcodes.L2I: + case Opcodes.F2I: + case Opcodes.D2I: result = Type.INT_TYPE; break; default: diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/CheckCastAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/CheckCastAgent.java index 479be296..31cceeaf 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/CheckCastAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/CheckCastAgent.java @@ -28,8 +28,8 @@ import java.util.Set; import org.eolang.opeo.ast.AstNode; import org.eolang.opeo.ast.CheckCast; -import org.eolang.opeo.decompilation.DecompilerState; import org.eolang.opeo.decompilation.DecompilationAgent; +import org.eolang.opeo.decompilation.DecompilerState; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; @@ -40,6 +40,9 @@ */ public final class CheckCastAgent implements DecompilationAgent { + /** + * Supported opcodes. + */ private static final Set SUPPORTED = new HashSet<>( Arrays.asList( Opcodes.CHECKCAST @@ -52,7 +55,7 @@ public void handle(final DecompilerState state) { final AstNode value = state.stack().pop(); final Object type = state.operand(0); state.stack().push(new CheckCast(Type.getObjectType((String) type), value)); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/ConstAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/ConstAgent.java index 44eaf172..4ac77a76 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/ConstAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/ConstAgent.java @@ -90,7 +90,7 @@ public void handle(final DecompilerState state) { state.stack().push(res); break; } - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/DupAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/DupAgent.java index 6388830e..d2748c1a 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/DupAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/DupAgent.java @@ -49,7 +49,7 @@ public void handle(final DecompilerState state) { if (DupAgent.SUPPORTED.contains(state.instruction().opcode())) { final OperandStack stack = state.stack(); stack.push(new Duplicate(stack.pop())); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/GetFieldAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/GetFieldAgent.java index 8b3d3f71..40dc496b 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/GetFieldAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/GetFieldAgent.java @@ -51,7 +51,7 @@ public void handle(final DecompilerState state) { .type("field") ) ); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/GetStaticAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/GetStaticAgent.java index b3d47a72..f3cd1d56 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/GetStaticAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/GetStaticAgent.java @@ -40,7 +40,7 @@ public void handle(final DecompilerState state) { final String method = (String) state.operand(1); final String descriptor = (String) state.operand(2); state.stack().push(new ClassField(klass, method, descriptor)); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/IfAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/IfAgent.java index 5f15a75f..9f8cc430 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/IfAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/IfAgent.java @@ -57,7 +57,7 @@ public void handle(final DecompilerState state) { final AstNode first = stack.pop(); final Label operand = (Label) state.operand(0); stack.push(new If(first, second, operand)); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/InvokedynamicAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/InvokedynamicAgent.java index 5e465e2e..8db9906e 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/InvokedynamicAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/InvokedynamicAgent.java @@ -54,7 +54,7 @@ public void handle(final DecompilerState state) { args ); state.stack().push(node); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/InvokeinterfaceAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/InvokeinterfaceAgent.java index 4f598c4e..43823505 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/InvokeinterfaceAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/InvokeinterfaceAgent.java @@ -73,7 +73,7 @@ public void handle(final DecompilerState state) { args ) ); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/InvokespecialAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/InvokespecialAgent.java index ab8438e7..f2529eb9 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/InvokespecialAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/InvokespecialAgent.java @@ -103,7 +103,7 @@ public void handle(final DecompilerState state) { new Super(target, args, descriptor, type, name) ); } - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/InvokestaticAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/InvokestaticAgent.java index 27c4b28d..1cdbe835 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/InvokestaticAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/InvokestaticAgent.java @@ -60,7 +60,7 @@ public void handle(final DecompilerState state) { args ) ); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/InvokevirtualAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/InvokevirtualAgent.java index 28f8e71a..3be53879 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/InvokevirtualAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/InvokevirtualAgent.java @@ -73,7 +73,7 @@ public void handle(final DecompilerState state) { args ) ); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/LabelAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/LabelAgent.java index 9f22868e..d9190d3c 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/LabelAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/LabelAgent.java @@ -43,7 +43,7 @@ public void handle(final DecompilerState state) { new Label(String.class.cast(state.operand(0))) ); state.stack().push(node); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/LdcAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/LdcAgent.java index d8dc0081..e255084c 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/LdcAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/LdcAgent.java @@ -39,7 +39,7 @@ public void handle(final DecompilerState state) { if (state.instruction().opcode() == Opcodes.LDC) { final Object operand = state.operand(0); state.stack().push(new Constant(operand)); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/LoadAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/LoadAgent.java index 019cb326..54d00d02 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/LoadAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/LoadAgent.java @@ -41,6 +41,9 @@ */ public final class LoadAgent implements DecompilationAgent { + /** + * Supported opcodes. + */ private static final Set SUPPORTED = new HashSet<>( Arrays.asList( Opcodes.ILOAD, @@ -59,26 +62,38 @@ public void handle(final DecompilerState state) { state.stack().push( state.variable(index, LoadAgent.type(opcode)) ); - state.decompileInstruction(); + state.popInstruction(); } } + /** + * Infer type from opcode. + * @param opcode Opcode + * @return Type + */ private static Type type(final int opcode) { + final Type result; switch (opcode) { case Opcodes.ILOAD: - return Type.INT_TYPE; + result = Type.INT_TYPE; + break; case Opcodes.LLOAD: - return Type.LONG_TYPE; + result = Type.LONG_TYPE; + break; case Opcodes.FLOAD: - return Type.FLOAT_TYPE; + result = Type.FLOAT_TYPE; + break; case Opcodes.DLOAD: - return Type.DOUBLE_TYPE; + result = Type.DOUBLE_TYPE; + break; case Opcodes.ALOAD: - return Type.getType(Object.class); + result = Type.getType(Object.class); + break; default: throw new IllegalArgumentException( String.format("Unsupported opcode: %d", opcode) ); } + return result; } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/MulAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/MulAgent.java index 7c135614..00b03b7b 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/MulAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/MulAgent.java @@ -53,7 +53,7 @@ public void handle(final DecompilerState state) { final AstNode right = state.stack().pop(); final AstNode left = state.stack().pop(); state.stack().push(new Multiplication(left, right)); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/NewAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/NewAgent.java index 1b63ebdd..f27415ca 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/NewAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/NewAgent.java @@ -48,7 +48,7 @@ public final class NewAgent implements DecompilationAgent { public void handle(final DecompilerState state) { if (NewAgent.SUPPORTED.contains(state.instruction().opcode())) { state.stack().push(new NewAddress(state.operand(0).toString())); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/NewArrayAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/NewArrayAgent.java index 4d99aa08..eed9bcac 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/NewArrayAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/NewArrayAgent.java @@ -53,7 +53,7 @@ public void handle(final DecompilerState state) { final OperandStack stack = state.stack(); final AstNode size = stack.pop(); stack.push(new Reference(new ArrayConstructor(size, type))); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/PopAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/PopAgent.java index 9bb5bf5b..3ae38915 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/PopAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/PopAgent.java @@ -24,8 +24,8 @@ package org.eolang.opeo.decompilation.agents; import org.eolang.opeo.ast.Popped; -import org.eolang.opeo.decompilation.DecompilerState; import org.eolang.opeo.decompilation.DecompilationAgent; +import org.eolang.opeo.decompilation.DecompilerState; import org.eolang.opeo.decompilation.OperandStack; import org.objectweb.asm.Opcodes; @@ -40,7 +40,7 @@ public void handle(final DecompilerState state) { if (state.instruction().opcode() == Opcodes.POP) { final OperandStack stack = state.stack(); stack.push(new Popped(stack.pop())); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/PutFieldAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/PutFieldAgent.java index 12c7fa1b..06dda56a 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/PutFieldAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/PutFieldAgent.java @@ -57,7 +57,7 @@ public void handle(final DecompilerState state) { value ) ); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/ReturnAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/ReturnAgent.java index 98acb9b5..37cb27ac 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/ReturnAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/ReturnAgent.java @@ -72,7 +72,7 @@ public void handle(final DecompilerState state) { String.format("Unexpected opcode: %d", opcode) ); } - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/StoreAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/StoreAgent.java index 7997e727..4e0f1d0b 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/StoreAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/StoreAgent.java @@ -68,7 +68,7 @@ public void handle(final DecompilerState state) { value ) ); - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/StoreToArrayAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/StoreToArrayAgent.java index 81c3b32f..4c621de7 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/StoreToArrayAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/StoreToArrayAgent.java @@ -67,7 +67,7 @@ public void handle(final DecompilerState state) { } catch (final IllegalStateException exception) { state.stack().push(new StoreArray(array, index, value)); } - state.decompileInstruction(); + state.popInstruction(); } } diff --git a/src/main/java/org/eolang/opeo/decompilation/agents/SubstractionAgent.java b/src/main/java/org/eolang/opeo/decompilation/agents/SubstractionAgent.java index 66109407..781fdd0e 100644 --- a/src/main/java/org/eolang/opeo/decompilation/agents/SubstractionAgent.java +++ b/src/main/java/org/eolang/opeo/decompilation/agents/SubstractionAgent.java @@ -54,7 +54,7 @@ public void handle(final DecompilerState state) { final AstNode right = state.stack().pop(); final AstNode left = state.stack().pop(); state.stack().push(new Substraction(left, right)); - state.decompileInstruction(); + state.popInstruction(); } } } diff --git a/src/test/java/org/eolang/opeo/ast/ArrayConstructorTest.java b/src/test/java/org/eolang/opeo/ast/ArrayConstructorTest.java index dfbaa515..eaf6bae8 100644 --- a/src/test/java/org/eolang/opeo/ast/ArrayConstructorTest.java +++ b/src/test/java/org/eolang/opeo/ast/ArrayConstructorTest.java @@ -62,7 +62,13 @@ void createsArrayConstructorFromXmir() { node -> new Addition(new Literal(1), new Literal(2)) ), Matchers.equalTo( - new ArrayConstructor(new Addition(new Literal(1), new Literal(2)), "java/lang/Integer") + new ArrayConstructor( + new Addition( + new Literal(1), + new Literal(2) + ), + "java/lang/Integer" + ) ) ); } diff --git a/src/test/java/org/eolang/opeo/decompilation/DecompilerMachineTest.java b/src/test/java/org/eolang/opeo/decompilation/DecompilerMachineTest.java index c7b61c16..1db3a020 100644 --- a/src/test/java/org/eolang/opeo/decompilation/DecompilerMachineTest.java +++ b/src/test/java/org/eolang/opeo/decompilation/DecompilerMachineTest.java @@ -23,7 +23,6 @@ */ package org.eolang.opeo.decompilation; -import com.jcabi.xml.XMLDocument; import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import org.eolang.jeo.matchers.SameXml;