mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 08:08:34 +03:00
Convert values returned from polyglot calls into Enso Date - when isDate
This commit is contained in:
parent
fc2dca2cfd
commit
f16d07e640
@ -23,6 +23,7 @@ import org.enso.interpreter.node.callable.thunk.ThunkExecutorNode;
|
||||
import org.enso.interpreter.runtime.Context;
|
||||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
|
||||
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
|
||||
import org.enso.interpreter.runtime.callable.atom.Atom;
|
||||
import org.enso.interpreter.runtime.callable.function.Function;
|
||||
import org.enso.interpreter.runtime.data.ArrayRope;
|
||||
import org.enso.interpreter.runtime.data.text.Text;
|
||||
@ -198,6 +199,21 @@ public abstract class InvokeMethodNode extends BaseNode {
|
||||
}
|
||||
}
|
||||
Object res = hostMethodCallNode.execute(polyglotCallType, symbol.getName(), self, args);
|
||||
if (!(res instanceof Atom)) {
|
||||
if (interop.isDate(res)) {
|
||||
final Context ctx = Context.get(this);
|
||||
var dateConstructor = ctx.getDateConstructor();
|
||||
if (dateConstructor.isPresent()) {
|
||||
try {
|
||||
var hostLocalDate = interop.asDate(res);
|
||||
var guestLocalDate = ctx.getEnvironment().asGuestValue(hostLocalDate);
|
||||
res = dateConstructor.get().newInstance(guestLocalDate);
|
||||
} catch (UnsupportedMessageException ex) {
|
||||
res = dateConstructor.get().newInstance(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (anyWarnings) {
|
||||
anyWarningsProfile.enter();
|
||||
res = WithWarnings.prependTo(res, accumulatedWarnings);
|
||||
|
Loading…
Reference in New Issue
Block a user