Skip to content

Commit

Permalink
feat(objectionary#284): calculate maxs only for org.eolang classes
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed May 29, 2024
1 parent b0f00e9 commit 5feda39
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/org/eolang/opeo/compilation/JeoCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ public JeoCompiler(final XML opeo) {
*/
public XML compile() {
final XmlProgram program = new XmlProgram(this.opeo.node());
final String pckg = program.toXml().xpath("//meta[head='package']/tail/text()").stream()
.findFirst()
.orElse("");
final XmlClass clazz = program.top();
final XmlMethod[] methods = clazz.methods().stream()
.map(JeoCompiler::compile)
.map(method -> JeoCompiler.compile(method, pckg))
.toArray(XmlMethod[]::new);
return program.replaceTopClass(
clazz.replaceMethods(methods)
Expand Down Expand Up @@ -90,15 +93,19 @@ public XML compile() {
* @checkstyle IllegalCatch (50 lines)
*/
@SuppressWarnings({"PMD.AvoidCatchingGenericException", "PMD.IdenticalCatchBranches"})
private static XmlMethod compile(final XmlMethod method) {
private static XmlMethod compile(final XmlMethod method, final String pckg) {
try {
new AllLabels().clearCache();
//@todo: explain!
if (pckg.contains("org.eolang")) {
return method.withoutMaxs().withInstructions(
new XmirParser(method.nodes()).toJeoNodes().toArray(XmlNode[]::new)
);
// return method.withoutMaxs().withInstructions(
// new XmirParser(method.nodes()).toJeoNodes().toArray(XmlNode[]::new)
// );
} else {
return method.withInstructions(
new XmirParser(method.nodes()).toJeoNodes().toArray(XmlNode[]::new)
);
}
} catch (final ClassCastException exception) {
throw new IllegalArgumentException(
String.format(
Expand Down

0 comments on commit 5feda39

Please sign in to comment.