Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: objectionary/opeo-maven-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8c8f848f94e05e54b6eaf06f95637ddb187ed73b
Choose a base ref
..
head repository: objectionary/opeo-maven-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5ecfab743f79b8a6b744053377b35e036736101c
Choose a head ref
Showing with 604 additions and 266 deletions.
  1. +1 −1 .github/workflows/codecov.yaml
  2. +1 −1 .github/workflows/maven.test.yaml
  3. +1 −1 .github/workflows/site.yaml
  4. +1 −1 README.md
  5. +3 −3 pom.xml
  6. +22 −1 src/it/benchmark/pom.xml
  7. +19 −0 src/it/decompile-compile/pom.xml
  8. +5 −5 src/it/decompile-compile/target/generated-sources/{xmir → jeo-xmir}/org/eolang/jeo/Bar.xmir
  9. +5 −0 src/it/decompile-compile/verify.groovy
  10. +27 −5 src/main/java/org/eolang/opeo/CompileMojo.java
  11. +24 −5 src/main/java/org/eolang/opeo/DecompileMojo.java
  12. +2 −0 src/main/java/org/eolang/opeo/ast/Attributes.java
  13. +1 −1 src/main/java/org/eolang/opeo/ast/Constructor.java
  14. +1 −4 src/main/java/org/eolang/opeo/ast/Opcode.java
  15. +1 −1 src/main/java/org/eolang/opeo/ast/Root.java
  16. +116 −25 src/main/java/org/eolang/opeo/ast/Variable.java
  17. +33 −1 src/main/java/org/eolang/opeo/ast/WriteField.java
  18. +42 −33 src/main/java/org/eolang/opeo/compilation/OpeoNodes.java
  19. +0 −9 src/main/java/org/eolang/opeo/decompilation/Decompiler.java
  20. +33 −11 src/main/java/org/eolang/opeo/decompilation/DecompilerMachine.java
  21. +14 −52 src/main/java/org/eolang/opeo/decompilation/LocalVariables.java
  22. +1 −1 src/main/java/org/eolang/opeo/jeo/JeoDecompiler.java
  23. +22 −3 src/main/java/org/eolang/opeo/jeo/JeoInstructions.java
  24. +73 −0 src/main/java/org/eolang/opeo/jeo/JeoLabel.java
  25. +4 −4 src/test/java/it/TrasformationPacksTest.java
  26. +8 −0 src/test/java/org/eolang/opeo/ast/OpcodeTest.java
  27. +1 −1 src/test/java/org/eolang/opeo/ast/VariableTest.java
  28. +30 −2 src/test/java/org/eolang/opeo/ast/WriteFieldTest.java
  29. +7 −3 src/test/java/org/eolang/opeo/decompilation/DecompilerMachineTest.java
  30. +8 −36 src/test/java/org/eolang/opeo/decompilation/LocalVariablesTest.java
  31. +5 −5 src/test/resources/opeo-xmir/B.xmir
  32. +61 −29 src/test/resources/packs/simple_objects.yaml
  33. +18 −8 src/test/resources/simple.eo
  34. +14 −14 src/test/resources/xmir/Bar.xmir
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ jobs:
with:
distribution: 'temurin'
java-version: 11
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
2 changes: 1 addition & 1 deletion .github/workflows/maven.test.yaml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ jobs:
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
2 changes: 1 addition & 1 deletion .github/workflows/site.yaml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:
with:
distribution: 'zulu'
java-version: 11
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ Another way to use the plugin is to add it directly to your `pom.xml` file:
<plugin>
<groupId>org.eolang</groupId>
<artifactId>opeo-maven-plugin</artifactId>
<version>0.0.5</version>
<version>0.1.3</version>
<executions>
<execution>
<id>opeo-decompile</id>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -132,12 +132,12 @@ SOFTWARE.
<dependency>
<groupId>org.eolang</groupId>
<artifactId>eo-parser</artifactId>
<version>0.35.0</version>
<version>0.35.1</version>
</dependency>
<dependency>
<groupId>org.eolang</groupId>
<artifactId>jeo-maven-plugin</artifactId>
<version>0.2.16</version>
<version>0.2.18</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
@@ -295,7 +295,7 @@ SOFTWARE.
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.73</minimum>
<minimum>0.71</minimum>
</limit>
<limit>
<counter>METHOD</counter>
23 changes: 22 additions & 1 deletion src/it/benchmark/pom.xml
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>jeo-maven-plugin</artifactId>
<version>0.2.16</version>
<version>0.2.18</version>
<executions>
<execution>
<id>bytecode-to-eo</id>
@@ -69,6 +69,27 @@ SOFTWARE.
<goals>
<goal>compile</goal>
</goals>
<configuration>
<outputDir>opeo-compile</outputDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>eo-to-bytecode</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<commandlineArgs>org.eolang:jeo-maven-plugin:0.2.18:assemble -e -DsourcesDir=opeo-compile</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
19 changes: 19 additions & 0 deletions src/it/decompile-compile/pom.xml
Original file line number Diff line number Diff line change
@@ -50,12 +50,31 @@ SOFTWARE.
<goal>decompile</goal>
</goals>
</execution>
<execution>
<id>opeo-decompile-to-other-dir</id>
<goals>
<goal>decompile</goal>
</goals>
<configuration>
<outputDir>${project.build.directory}/generated-sources/opeo-xmir-second-try</outputDir>
</configuration>
</execution>
<execution>
<id>opeo-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>opeo-compile-from-other-dir</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDir>${project.build.directory}/generated-sources/opeo-xmir-second-try</sourceDir>
<outputDir>${project.build.directory}/generated-sources/jeo-xmir-second-try</outputDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Original file line number Diff line number Diff line change
@@ -30,14 +30,14 @@
<o abstract="" name="j$Bar">
<o base="int" data="bytes" name="access">00 00 00 00 00 00 00 21</o>
<o base="string" data="bytes" name="supername">6A 61 76 61 2F 6C 61 6E 67 2F 4F 62 6A 65 63 74</o>
<o base="tuple" data="tuple" name="interfaces"/>
<o base="tuple" star="" name="interfaces"/>
<o abstract="" name="new">
<o base="int" data="bytes" name="access">00 00 00 00 00 00 00 01</o>
<o base="string" data="bytes" name="descriptor">28 29 56</o>
<o base="string" data="bytes" name="signature"/>
<o base="tuple" data="tuple" name="exceptions"/>
<o base="tuple" star="" name="exceptions"/>
<o base="seq" name="@">
<o base="tuple">
<o base="tuple" star="">
<o base="label">
<o base="string" data="bytes">38 63 33 33 31 33 39 37 2D 32 35 39 35 2D 34 66 35 64 2D 38 65 62 30 2D 33 62 30 63 34 62 35 34 36 35 66 32</o>
</o>
@@ -64,10 +64,10 @@
<o base="int" data="bytes" name="access">00 00 00 00 00 00 00 01</o>
<o base="string" data="bytes" name="descriptor">28 49 29 49</o>
<o base="string" data="bytes" name="signature"/>
<o base="tuple" data="tuple" name="exceptions"/>
<o base="tuple" star="" name="exceptions"/>
<o abstract="" name="arg__I__0"/>
<o base="seq" name="@">
<o base="tuple">
<o base="tuple" star="">
<o base="label">
<o base="string" data="bytes">62 39 63 64 62 64 63 65 2D 38 35 38 65 2D 34 30 36 32 2D 61 38 39 30 2D 62 32 65 34 30 62 34 36 31 36 61 37</o>
</o>
5 changes: 5 additions & 0 deletions src/it/decompile-compile/verify.groovy
Original file line number Diff line number Diff line change
@@ -33,6 +33,11 @@ assert log.contains("Compiling EO sources from")
assert log.contains("Saving new compiled EO sources to")
assert log.contains("Compiled")
assert log.contains("Compiled 1 sources")
// Check compiled files.
assert new File(basedir, 'target/generated-sources/jeo-xmir').exists()
assert new File(basedir, 'target/generated-sources/jeo-xmir-second-try').exists()
assert new File(basedir, 'target/generated-sources/opeo-xmir').exists()
assert new File(basedir, 'target/generated-sources/opeo-xmir-second-try').exists()
// Check success.
assert log.contains("BUILD SUCCESS")

32 changes: 27 additions & 5 deletions src/main/java/org/eolang/opeo/CompileMojo.java
Original file line number Diff line number Diff line change
@@ -41,14 +41,36 @@
public final class CompileMojo extends AbstractMojo {

/**
* Project default target directory.
* @since 0.1.0
* Source directory.
* Where to take opeo xmir from.
*
* @since 0.2.0
* @checkstyle MemberNameCheck (6 lines)
*/
@Parameter(defaultValue = "${project.build.directory}/generated-sources")
private File generated;
@Parameter(
property = "opeo.compile.sourcesDir",
defaultValue = "${project.build.directory}/generated-sources/opeo-xmir"
)
private File sourcesDir;

/**
* Target directory.
* Where to save jeo representations to.
*
* @since 0.2.0
* @checkstyle MemberNameCheck (6 lines)
*/
@Parameter(
property = "opeo.compile.outputDir",
defaultValue = "${project.build.directory}/generated-sources/jeo-xmir"
)
private File outputDir;

@Override
public void execute() {
new Compiler(this.generated).compile();
new Compiler(
this.sourcesDir.toPath(),
this.outputDir.toPath()
).compile();
}
}
29 changes: 24 additions & 5 deletions src/main/java/org/eolang/opeo/DecompileMojo.java
Original file line number Diff line number Diff line change
@@ -41,14 +41,33 @@
public final class DecompileMojo extends AbstractMojo {

/**
* Project default target directory.
* @since 0.1.0
* Source directory.
* Where to take jeo xmir from.
*
* @since 0.2.0
* @checkstyle MemberNameCheck (6 lines)
*/
@Parameter(defaultValue = "${project.build.directory}/generated-sources")
private File generated;
@Parameter(
property = "opeo.decompile.sourcesDir",
defaultValue = "${project.build.directory}/generated-sources/jeo-xmir"
)
private File sourcesDir;

/**
* Target directory.
* Where to save opeo decompiler representations to.
*
* @since 0.2.0
* @checkstyle MemberNameCheck (6 lines)
*/
@Parameter(
property = "opeo.decompile.outputDir",
defaultValue = "${project.build.directory}/generated-sources/opeo-xmir"
)
private File outputDir;

@Override
public void execute() {
new Decompiler(this.generated).decompile();
new Decompiler(this.sourcesDir.toPath(), this.outputDir.toPath()).decompile();
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/eolang/opeo/ast/Attributes.java
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.EqualsAndHashCode;
import org.cactoos.map.MapEntry;

/**
@@ -35,6 +36,7 @@
* @since 0.1
*/
@SuppressWarnings("PMD.TooManyMethods")
@EqualsAndHashCode
public final class Attributes {

/**
2 changes: 1 addition & 1 deletion src/main/java/org/eolang/opeo/ast/Constructor.java
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ public List<AstNode> opcodes() {
res.add(new Opcode(Opcodes.NEW, this.type));
res.add(new Opcode(Opcodes.DUP));
this.arguments.stream().map(AstNode::opcodes).forEach(res::addAll);
res.add(new Opcode(Opcodes.INVOKESPECIAL, this.type, "<init>", "V()"));
res.add(new Opcode(Opcodes.INVOKESPECIAL, this.type, "<init>", "()V"));
return res;
}

5 changes: 1 addition & 4 deletions src/main/java/org/eolang/opeo/ast/Opcode.java
Original file line number Diff line number Diff line change
@@ -28,10 +28,7 @@
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;
import org.xembly.Transformers;
import org.xembly.Xembler;

/**
* Opcode output node.
@@ -105,7 +102,7 @@ public Opcode(final int bytecode, final List<Object> operands, final boolean cou

@Override
public String print() {
return new XMIR(new Xembler(this.toXmir(), new Transformers.Node()).xmlQuietly()).toEO();
return "opcode";
}

@Override
2 changes: 1 addition & 1 deletion src/main/java/org/eolang/opeo/ast/Root.java
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ public Iterable<Directive> toXmir() {
result = Collections.emptyList();
} else {
final Directives directives = new Directives();
directives.add("o").attr("base", "tuple");
directives.add("o").attr("base", "tuple").attr("star", "");
this.children.stream().map(AstNode::toXmir).forEach(directives::append);
directives.up();
result = directives;
Loading