Skip to content

Commit 3e65683

Browse files
javeleonelkorchi
authored andcommitted
make sure specific type converters are attempted in specific exception type ToEspresso nodes
(cherry picked from commit 70e7668)
1 parent 166a709 commit 3e65683

File tree

1 file changed

+27
-6
lines changed
  • espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop

1 file changed

+27
-6
lines changed

Diff for: espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/ToReference.java

+27-6
Original file line numberDiff line numberDiff line change
@@ -1857,9 +1857,16 @@ public StaticObject doEspressoException(EspressoException value) {
18571857
"interop.isException(value)",
18581858
"!isEspressoException(value)"
18591859
})
1860-
StaticObject doforeign(Object value,
1860+
StaticObject doForeign(Object value,
18611861
@CachedLibrary(limit = "LIMIT") InteropLibrary interop,
1862-
@Bind("getContext()") EspressoContext context) {
1862+
@Cached LookupTypeConverterNode lookupTypeConverterNode,
1863+
@Cached LookupInternalTypeConverterNode lookupInternalTypeConverterNode,
1864+
@Cached ToReference.DynamicToReference converterToEspresso,
1865+
@Bind("getContext()") EspressoContext context) throws UnsupportedTypeException {
1866+
StaticObject result = ToReference.tryConverterForUnknownTarget(value, interop, lookupTypeConverterNode, lookupInternalTypeConverterNode, converterToEspresso, context.getMeta());
1867+
if (result != null) {
1868+
return result;
1869+
}
18631870
return StaticObject.createForeignException(context, value, interop);
18641871
}
18651872

@@ -1908,9 +1915,16 @@ public StaticObject doEspressoException(EspressoException value, @Bind("getMeta(
19081915
"interop.isException(value)",
19091916
"!isEspressoException(value)"
19101917
})
1911-
StaticObject doforeign(Object value,
1918+
StaticObject doForeign(Object value,
19121919
@CachedLibrary(limit = "LIMIT") InteropLibrary interop,
1913-
@Bind("getContext()") EspressoContext context) {
1920+
@Cached LookupTypeConverterNode lookupTypeConverterNode,
1921+
@Cached LookupInternalTypeConverterNode lookupInternalTypeConverterNode,
1922+
@Cached ToReference.DynamicToReference converterToEspresso,
1923+
@Bind("getContext()") EspressoContext context) throws UnsupportedTypeException {
1924+
StaticObject result = ToReference.tryConverterForUnknownTarget(value, interop, lookupTypeConverterNode, lookupInternalTypeConverterNode, converterToEspresso, context.getMeta());
1925+
if (result != null) {
1926+
return result;
1927+
}
19141928
return StaticObject.createForeignException(context, value, interop);
19151929
}
19161930

@@ -1959,9 +1973,16 @@ public StaticObject doEspressoException(EspressoException value, @Bind("getMeta(
19591973
"interop.isException(value)",
19601974
"!isEspressoException(value)"
19611975
})
1962-
StaticObject doforeign(Object value,
1976+
StaticObject doForeign(Object value,
19631977
@CachedLibrary(limit = "LIMIT") InteropLibrary interop,
1964-
@Bind("getContext()") EspressoContext context) {
1978+
@Bind("getContext()") EspressoContext context,
1979+
@Cached LookupTypeConverterNode lookupTypeConverterNode,
1980+
@Cached LookupInternalTypeConverterNode lookupInternalTypeConverterNode,
1981+
@Cached ToReference.DynamicToReference converterToEspresso) throws UnsupportedTypeException {
1982+
StaticObject result = ToReference.tryConverterForUnknownTarget(value, interop, lookupTypeConverterNode, lookupInternalTypeConverterNode, converterToEspresso, context.getMeta());
1983+
if (result != null) {
1984+
return result;
1985+
}
19651986
return StaticObject.createForeignException(context, value, interop);
19661987
}
19671988

0 commit comments

Comments
 (0)