mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 02:21:54 +03:00
Implement toDisplayString on some truffle objects
This commit is contained in:
parent
06d1d4c950
commit
62aefe54cc
@ -772,10 +772,17 @@ public final class EnsoFile extends EnsoObject {
|
||||
return fromString(context, System.getProperty("user.home"));
|
||||
}
|
||||
|
||||
@ExportMessage
|
||||
@TruffleBoundary
|
||||
@Override
|
||||
public String toDisplayString(boolean allowSideEffects) {
|
||||
return "(File " + truffleFile.getPath() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
@TruffleBoundary
|
||||
public String toString() {
|
||||
return "(File " + truffleFile.getPath() + ")";
|
||||
return toDisplayString(false);
|
||||
}
|
||||
|
||||
@ExportMessage
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.enso.interpreter.runtime.data;
|
||||
|
||||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
||||
import com.oracle.truffle.api.dsl.Bind;
|
||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||
import com.oracle.truffle.api.library.ExportLibrary;
|
||||
@ -93,4 +94,11 @@ public final class ManagedResource extends EnsoObject {
|
||||
Type getType(@Bind("$node") Node node) {
|
||||
return EnsoContext.get(node).getBuiltins().managedResource();
|
||||
}
|
||||
|
||||
@ExportMessage
|
||||
@TruffleBoundary
|
||||
@Override
|
||||
public String toDisplayString(boolean allowSideEffects) {
|
||||
return resource.toString();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.enso.interpreter.runtime.data;
|
||||
|
||||
import com.oracle.truffle.api.dsl.Bind;
|
||||
import com.oracle.truffle.api.interop.InteropLibrary;
|
||||
import com.oracle.truffle.api.library.CachedLibrary;
|
||||
import com.oracle.truffle.api.library.ExportLibrary;
|
||||
import com.oracle.truffle.api.library.ExportMessage;
|
||||
import com.oracle.truffle.api.nodes.Node;
|
||||
@ -68,4 +69,10 @@ public final class Ref extends EnsoObject {
|
||||
Type getType(@Bind("$node") Node node) {
|
||||
return EnsoContext.get(node).getBuiltins().ref();
|
||||
}
|
||||
|
||||
@ExportMessage
|
||||
Object toDisplayString(
|
||||
boolean allowSideEffects, @CachedLibrary(limit = "3") InteropLibrary interop) {
|
||||
return interop.toDisplayString(value, allowSideEffects);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user