@@ -404,19 +404,13 @@ long doLongNativeWrapper(LongNativeWrapper object) {
404404 return object .getValue ();
405405 }
406406
407- @ Specialization (guards = {"isPrimitiveNativeWrapper (object)" , "object.isNative()" })
407+ @ Specialization (guards = {"!isBoolNativeWrapper (object)" , "object.isNative()" })
408408 Object doPrimitiveNativeWrapper (PrimitiveNativeWrapper object ) {
409409 return getMaterializeNode ().execute (object );
410410 }
411411
412- @ Specialization (guards = {"!isPrimitiveNativeWrapper(object)" , "object.getClass() == cachedClass" }, limit = "3" )
413- Object doNativeWrapper (PythonNativeWrapper object ,
414- @ SuppressWarnings ("unused" ) @ Cached ("object.getClass()" ) Class <? extends PythonNativeWrapper > cachedClass ) {
415- return CompilerDirectives .castExact (object , cachedClass ).getDelegate ();
416- }
417-
418- @ Specialization (guards = "!isPrimitiveNativeWrapper(object)" , replaces = "doNativeWrapper" )
419- Object doNativeWrapperGeneric (PythonNativeWrapper object ) {
412+ @ Specialization (guards = "!isPrimitiveNativeWrapper(object)" )
413+ Object doNativeWrapper (PythonNativeWrapper object ) {
420414 return object .getDelegate ();
421415 }
422416
@@ -473,7 +467,11 @@ Object run(Object obj) {
473467 }
474468
475469 protected static boolean isPrimitiveNativeWrapper (PythonNativeWrapper object ) {
476- return object instanceof PrimitiveNativeWrapper && !(object instanceof BoolNativeWrapper );
470+ return object instanceof PrimitiveNativeWrapper ;
471+ }
472+
473+ protected static boolean isBoolNativeWrapper (PythonNativeWrapper object ) {
474+ return object instanceof BoolNativeWrapper ;
477475 }
478476
479477 protected boolean isForeignObject (TruffleObject obj , GetLazyClassNode getClassNode , IsBuiltinClassProfile isForeignClassProfile ) {
@@ -598,16 +596,41 @@ public abstract static class ToJavaNode extends CExtBaseNode {
598596
599597 public abstract Object execute (Object value );
600598
599+ public abstract boolean executeBool (boolean value );
600+
601+ public abstract byte executeByte (byte value );
602+
603+ public abstract int executeInt (int value );
604+
605+ public abstract long executeLong (long value );
606+
607+ public abstract double executeDouble (double value );
608+
601609 @ Specialization
602610 PythonAbstractObject doPythonObject (PythonAbstractObject value ) {
603611 return value ;
604612 }
605613
606614 @ Specialization
607- Object doWrapper (PythonObjectNativeWrapper value ) {
615+ Object doWrapper (PythonNativeWrapper value ) {
608616 return toJavaNode .execute (value );
609617 }
610618
619+ @ Specialization
620+ String doString (String object ) {
621+ return object ;
622+ }
623+
624+ @ Specialization
625+ boolean doBoolean (boolean b ) {
626+ return b ;
627+ }
628+
629+ @ Specialization
630+ byte doLong (byte b ) {
631+ return b ;
632+ }
633+
611634 @ Fallback
612635 Object doForeign (Object value ) {
613636 if (callNativeNode == null ) {
0 commit comments