Skip to content

Commit

Permalink
feat(objectionary#627): add suffix for method names
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jul 2, 2024
1 parent 1319333 commit 4fcda28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Iterator<Directive> iterator() {
final Directives directives = new Directives();
final String eoname;
if ("<init>".equals(this.name)) {
eoname = "new";
eoname = "new" + "-" + this.properties.suffix();
} else {
eoname = this.name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
package org.eolang.jeo.representation.directives;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Iterator;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -117,6 +119,10 @@ public void maxs(final int stack, final int locals) {
this.max.set(new DirectivesMaxs(stack, locals));
}

public String suffix() {
return Base64.getEncoder().encodeToString(this.descriptor.getBytes(StandardCharsets.UTF_8));
}

@Override
public Iterator<Directive> iterator() {
return new Directives()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,17 @@ public String name() {
final String original = this.node.attribute("name").orElseThrow(
() -> new IllegalStateException("Method 'name' attribute is not present")
);
if ("new".equals(original)) {
if (original.contains("new")) {
result = "<init>";
} else {
result = original;
}
return result;
final int endIndex = result.lastIndexOf('-');
if (endIndex > 0) {
return result.substring(0, endIndex);
} else {
return result;
}
}

/**
Expand Down

0 comments on commit 4fcda28

Please sign in to comment.