From 5feda3931a9b3a0d3cadf27b7a5a9eeefe4f6402 Mon Sep 17 00:00:00 2001 From: volodya-lombrozo Date: Wed, 29 May 2024 17:27:37 +0300 Subject: [PATCH] feat(#284): calculate maxs only for org.eolang classes --- .../eolang/opeo/compilation/JeoCompiler.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/eolang/opeo/compilation/JeoCompiler.java b/src/main/java/org/eolang/opeo/compilation/JeoCompiler.java index c770b6fb..e3edf5a5 100644 --- a/src/main/java/org/eolang/opeo/compilation/JeoCompiler.java +++ b/src/main/java/org/eolang/opeo/compilation/JeoCompiler.java @@ -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) @@ -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(