Implement toString() on VmReference (#1692)
This is still needed right now, because some methods call through to `toString()`.
This commit is contained in:
1 parent
8a43e51e6b
commit
15f089b275
3 files changed
+18
-7
No files matched your search
@@ -16,6 +16,7 @@
|
||||
package org.pkl.core.runtime;
|
||||
|
||||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
||||
import com.oracle.truffle.api.nodes.DirectCallNode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -470,4 +471,14 @@ public final class VmReference extends VmValue {
|
||||
result = 31 * result + referentType.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
// in-language calls _should_ all go through `ToStringNode`.
|
||||
// however, some calls escape through to here currently (e.g. `Listing.join`).
|
||||
@Override
|
||||
public String toString() {
|
||||
var toStringMethod = getVmClass().getDeclaredMethod(Identifier.TO_STRING);
|
||||
assert toStringMethod != null;
|
||||
var callNode = DirectCallNode.create(toStringMethod.getCallTarget());
|
||||
return (String) callNode.call(this, getVmClass().getPrototype());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user