diff --git a/pom.xml b/pom.xml
index d754bbf3..653bbc80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -137,7 +137,7 @@ SOFTWARE.
org.eolang
jeo-maven-plugin
- 0.2.15
+ 0.2.16
com.jcabi
diff --git a/src/it/decompile-compile/target/generated-sources/xmir/org/eolang/jeo/Bar.xmir b/src/it/decompile-compile/target/generated-sources/xmir/org/eolang/jeo/Bar.xmir
index 8057a05d..2e021dc3 100644
--- a/src/it/decompile-compile/target/generated-sources/xmir/org/eolang/jeo/Bar.xmir
+++ b/src/it/decompile-compile/target/generated-sources/xmir/org/eolang/jeo/Bar.xmir
@@ -59,7 +59,6 @@
-
00 00 00 00 00 00 00 01
@@ -105,7 +104,6 @@
-
diff --git a/src/main/java/org/eolang/opeo/ast/Add.java b/src/main/java/org/eolang/opeo/ast/Add.java
index 5b062a37..485cb22c 100644
--- a/src/main/java/org/eolang/opeo/ast/Add.java
+++ b/src/main/java/org/eolang/opeo/ast/Add.java
@@ -23,6 +23,9 @@
*/
package org.eolang.opeo.ast;
+import java.util.ArrayList;
+import java.util.List;
+import org.objectweb.asm.Opcodes;
import org.xembly.Directive;
import org.xembly.Directives;
@@ -65,4 +68,13 @@ public Iterable toXmir() {
.append(this.right.toXmir())
.up();
}
+
+ @Override
+ public List opcodes() {
+ final List res = new ArrayList<>(0);
+ res.addAll(this.left.opcodes());
+ res.addAll(this.right.opcodes());
+ res.add(new Opcode(Opcodes.IADD));
+ return res;
+ }
}
diff --git a/src/main/java/org/eolang/opeo/ast/AstNode.java b/src/main/java/org/eolang/opeo/ast/AstNode.java
index bdd63fb0..3eb0d28b 100644
--- a/src/main/java/org/eolang/opeo/ast/AstNode.java
+++ b/src/main/java/org/eolang/opeo/ast/AstNode.java
@@ -23,6 +23,7 @@
*/
package org.eolang.opeo.ast;
+import java.util.List;
import org.xembly.Directive;
/**
@@ -42,4 +43,10 @@ public interface AstNode {
* @return XMIR XML.
*/
Iterable toXmir();
+
+ /**
+ * Bytecode instructions.
+ * @return List of opcodes.
+ */
+ List opcodes();
}
diff --git a/src/main/java/org/eolang/opeo/ast/Constructor.java b/src/main/java/org/eolang/opeo/ast/Constructor.java
index 6703e860..ca4b71cd 100644
--- a/src/main/java/org/eolang/opeo/ast/Constructor.java
+++ b/src/main/java/org/eolang/opeo/ast/Constructor.java
@@ -86,6 +86,11 @@ public Iterable toXmir() {
return directives.up();
}
+ @Override
+ public List opcodes() {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
/**
* Print arguments.
* @return Arguments string.
diff --git a/src/main/java/org/eolang/opeo/ast/InstanceField.java b/src/main/java/org/eolang/opeo/ast/InstanceField.java
index 11a37f1f..d2b21c66 100644
--- a/src/main/java/org/eolang/opeo/ast/InstanceField.java
+++ b/src/main/java/org/eolang/opeo/ast/InstanceField.java
@@ -23,6 +23,7 @@
*/
package org.eolang.opeo.ast;
+import java.util.List;
import org.xembly.Directive;
import org.xembly.Directives;
@@ -65,4 +66,9 @@ public Iterable toXmir() {
.append(this.source.toXmir())
.up();
}
+
+ @Override
+ public List opcodes() {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
}
diff --git a/src/main/java/org/eolang/opeo/ast/Invocation.java b/src/main/java/org/eolang/opeo/ast/Invocation.java
index 82aee8f1..50027944 100644
--- a/src/main/java/org/eolang/opeo/ast/Invocation.java
+++ b/src/main/java/org/eolang/opeo/ast/Invocation.java
@@ -111,6 +111,11 @@ public Iterable toXmir() {
return directives.up();
}
+ @Override
+ public List opcodes() {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+
/**
* Print arguments.
* @return Arguments
diff --git a/src/main/java/org/eolang/opeo/ast/Label.java b/src/main/java/org/eolang/opeo/ast/Label.java
new file mode 100644
index 00000000..d8402848
--- /dev/null
+++ b/src/main/java/org/eolang/opeo/ast/Label.java
@@ -0,0 +1,68 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016-2023 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.opeo.ast;
+
+import java.util.Collections;
+import java.util.List;
+import org.xembly.Directive;
+import org.xembly.Directives;
+
+/**
+ * Label ast node.
+ * @since 0.1
+ */
+public final class Label implements AstNode {
+
+ /**
+ * Label identifier.
+ */
+ private final AstNode identifier;
+
+ /**
+ * Constructor.
+ * @param identifier Label identifier.
+ */
+ public Label(final AstNode identifier) {
+ this.identifier = identifier;
+ }
+
+ @Override
+ public String print() {
+ return String.format(": %s", this.identifier.print());
+ }
+
+ @Override
+ public Iterable toXmir() {
+ return new Directives()
+ .add("o")
+ .attr("base", "label")
+ .append(this.identifier.toXmir())
+ .up();
+ }
+
+ @Override
+ public List opcodes() {
+ return Collections.singletonList(this);
+ }
+}
diff --git a/src/main/java/org/eolang/opeo/ast/Literal.java b/src/main/java/org/eolang/opeo/ast/Literal.java
index 6084fddf..5e8d4ea1 100644
--- a/src/main/java/org/eolang/opeo/ast/Literal.java
+++ b/src/main/java/org/eolang/opeo/ast/Literal.java
@@ -23,7 +23,10 @@
*/
package org.eolang.opeo.ast;
+import java.util.Collections;
+import java.util.List;
import org.eolang.jeo.representation.directives.DirectivesData;
+import org.objectweb.asm.Opcodes;
import org.xembly.Directive;
/**
@@ -50,6 +53,19 @@ public Iterable toXmir() {
return new DirectivesData(this.object);
}
+ @Override
+ public List opcodes() {
+ final List result;
+ if (this.object instanceof Integer) {
+ result = Collections.singletonList(Literal.opcode((Integer) this.object));
+ } else if (this.object instanceof String) {
+ result = Collections.singletonList(Literal.opcode((String) this.object));
+ } else {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+ return result;
+ }
+
@Override
public String print() {
final String result;
@@ -60,4 +76,46 @@ public String print() {
}
return result;
}
+
+ /**
+ * Convert string into an opcode.
+ * @param value String value.
+ * @return Opcode.
+ */
+ private static Opcode opcode(final String value) {
+ return new Opcode(Opcodes.LDC, value);
+ }
+
+ /**
+ * Convert integer into an opcode.
+ * @param value Integer value.
+ * @return Opcode.
+ */
+ private static Opcode opcode(final int value) {
+ final Opcode res;
+ switch (value) {
+ case 0:
+ res = new Opcode(Opcodes.ICONST_0);
+ break;
+ case 1:
+ res = new Opcode(Opcodes.ICONST_1);
+ break;
+ case 2:
+ res = new Opcode(Opcodes.ICONST_2);
+ break;
+ case 3:
+ res = new Opcode(Opcodes.ICONST_3);
+ break;
+ case 4:
+ res = new Opcode(Opcodes.ICONST_4);
+ break;
+ case 5:
+ res = new Opcode(Opcodes.ICONST_5);
+ break;
+ default:
+ res = new Opcode(Opcodes.BIPUSH, value);
+ break;
+ }
+ return res;
+ }
}
diff --git a/src/main/java/org/eolang/opeo/ast/Mul.java b/src/main/java/org/eolang/opeo/ast/Mul.java
index 7d493547..b966bc63 100644
--- a/src/main/java/org/eolang/opeo/ast/Mul.java
+++ b/src/main/java/org/eolang/opeo/ast/Mul.java
@@ -23,6 +23,7 @@
*/
package org.eolang.opeo.ast;
+import java.util.List;
import org.xembly.Directive;
import org.xembly.Directives;
@@ -65,4 +66,9 @@ public Iterable toXmir() {
.append(this.right.toXmir())
.up();
}
+
+ @Override
+ public List opcodes() {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
}
diff --git a/src/main/java/org/eolang/opeo/ast/Opcode.java b/src/main/java/org/eolang/opeo/ast/Opcode.java
index d30c9ae4..ecd247a6 100644
--- a/src/main/java/org/eolang/opeo/ast/Opcode.java
+++ b/src/main/java/org/eolang/opeo/ast/Opcode.java
@@ -26,6 +26,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.eolang.jeo.representation.directives.DirectivesInstruction;
import org.eolang.parser.XMIR;
import org.xembly.Directive;
@@ -38,6 +39,11 @@
*/
public final class Opcode implements AstNode {
+ /**
+ * Opcodes counting.
+ */
+ private static final AtomicBoolean COUNTING = new AtomicBoolean(true);
+
/**
* Opcode.
*/
@@ -82,7 +88,7 @@ public Opcode(final int opcode, final boolean counting) {
* @param operands Opcode operands
*/
public Opcode(final int opcode, final List