Skip to content

Commit

Permalink
#3460: more messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 10, 2024
1 parent cf36bc8 commit 11e786f
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOrust.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,17 @@ public Phi lambda() {
final String name = Optional.ofNullable(NAMES.get(locator))
.orElseThrow(() -> new ExNative("No native function for %s", locator));
final Method method;
final String type = String.format("EOrust.natives.%s", name);
try {
method = Class.forName(
String.format(
"EOrust.natives.%s",
name
)
).getDeclaredMethod(name, Universe.class);
method = Class.forName(type).getDeclaredMethod(name, Universe.class);
} catch (final NoSuchMethodException | ClassNotFoundException ex) {
throw new IllegalArgumentException(ex);
throw new IllegalArgumentException(
String.format(
"Can't instantiate class %s or find %s() method in it",
type, name
),
ex
);
}
if (method.getReturnType() != byte[].class) {
throw new ExFailure(
Expand All @@ -168,22 +170,25 @@ public Phi lambda() {
);
}
final Phi portal = this.take("portal");
final UniverseSafe uni = new UniverseSafe(
new UniverseDefault(
portal, this.phis
),
this.error
);
final byte[] bytes;
try {
return this.translate(
(byte[]) method.invoke(
null,
new UniverseSafe(
new UniverseDefault(
portal, this.phis
),
this.error
)
),
this.take("code").locator()
);
bytes = (byte[]) method.invoke(null, uni);
} catch (final IllegalAccessException | InvocationTargetException ex) {
throw new IllegalArgumentException(ex);
throw new IllegalArgumentException(
String.format("Failed to invoke %s", method),
ex
);
}
return this.translate(
bytes,
this.take("code").locator()
);
}

/**
Expand Down

0 comments on commit 11e786f

Please sign in to comment.