Skip to content

Commit

Permalink
feat(objectionary#122): remove the puzzle for the objectionary#122 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Oct 3, 2023
1 parent 4adf595 commit 9054e2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 9 additions & 12 deletions src/main/java/org/eolang/jeo/representation/asm/XmlBytecode.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
/**
* XML to Java bytecode.
* @since 0.1.0
* @todo #115:90min Use BytecodeClass instead of ASM library.
* Right now we are using ASM library to generate bytecode from XML.
* We should use BytecodeClass instead in order to reduce code duplication between
* XmlBytecode and BytecodeClass implementations.
*/
public final class XmlBytecode {

Expand All @@ -52,19 +48,20 @@ public XmlBytecode(final XML xml) {

/**
* Traverse XML and build bytecode class.
* @return Bytecode.
*/
public Bytecode bytecode() {
final XmlClass clazz = new XmlClass(this.xml);
final BytecodeClass bytecode = new BytecodeClass(clazz.name(), clazz.access());
for (final XmlMethod method : clazz.methods()) {
final BytecodeMethod bytecodeMethod = bytecode.withMethod(
method.name(),
method.descriptor(),
method.access()
for (final XmlMethod xmlmethod : clazz.methods()) {
final BytecodeMethod method = bytecode.withMethod(
xmlmethod.name(),
xmlmethod.descriptor(),
xmlmethod.access()
);
for (final XmlInstruction instruction : method.instructions()) {
bytecodeMethod.instruction(instruction.code(), instruction.arguments());
}
xmlmethod.instructions()
.stream()
.forEach(inst -> method.instruction(inst.code(), inst.arguments()));
}
return bytecode.bytecode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public final class BytecodeClass {
*/
private final Collection<BytecodeMethod> methods;

/**
* Access modifiers.
*/
private final int access;

/**
Expand Down Expand Up @@ -174,5 +177,4 @@ public BytecodeClass helloWorldMethod() {
.instruction(Opcodes.RETURN)
.up();
}

}

0 comments on commit 9054e2e

Please sign in to comment.