@@ -902,11 +902,11 @@ Object O_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @Suppres
902
902
@ Shared @ Cached PointerNodes .ReadPointerNode readPointerNode ,
903
903
@ Cached PointerNodes .ReadPythonObject readPythonObject ,
904
904
@ Cached PRaiseNode raiseNode ) {
905
- if (ptr .isNull ()) {
905
+ Pointer valuePtr = readPointerNode .execute (inliningTarget , ptr );
906
+ if (valuePtr .isNull ()) {
906
907
throw raiseNode .raise (ValueError , ErrorMessages .PY_OBJ_IS_NULL );
907
908
}
908
- Pointer value = readPointerNode .execute (inliningTarget , ptr );
909
- return readPythonObject .execute (inliningTarget , value );
909
+ return readPythonObject .execute (inliningTarget , valuePtr );
910
910
}
911
911
912
912
@ Specialization (guards = "getfunc == c_get" )
@@ -956,14 +956,13 @@ static Object z_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @
956
956
@ Shared @ Cached PythonObjectFactory factory ,
957
957
@ Shared @ Cached PointerNodes .StrLenNode strLenNode ,
958
958
@ Shared @ Cached PointerNodes .ReadBytesNode readBytesNode ) {
959
- if (!ptr .isNull ()) {
960
- // ptr is a char**, we need to deref it to get char*
961
- Pointer valuePtr = readPointerNode .execute (inliningTarget , ptr );
962
- byte [] bytes = readBytesNode .execute (inliningTarget , valuePtr , strLenNode .execute (inliningTarget , valuePtr ));
963
- return factory .createBytes (bytes );
964
- } else {
959
+ // ptr is a char**, we need to deref it to get char*
960
+ Pointer valuePtr = readPointerNode .execute (inliningTarget , ptr );
961
+ if (valuePtr .isNull ()) {
965
962
return PNone .NONE ;
966
963
}
964
+ byte [] bytes = readBytesNode .execute (inliningTarget , valuePtr , strLenNode .execute (inliningTarget , valuePtr ));
965
+ return factory .createBytes (bytes );
967
966
}
968
967
969
968
@ Specialization (guards = "getfunc == Z_get" )
@@ -974,14 +973,13 @@ static Object Z_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @
974
973
@ Shared @ Cached PointerNodes .ReadBytesNode readBytesNode ,
975
974
@ Cached TruffleString .FromByteArrayNode fromByteArrayNode ,
976
975
@ Cached TruffleString .SwitchEncodingNode switchEncodingNode ) {
977
- if (!ptr .isNull ()) {
978
- // ptr is a char**, we need to deref it to get char*
979
- Pointer valuePtr = readPointerNode .execute (inliningTarget , ptr );
980
- byte [] bytes = readBytesNode .execute (inliningTarget , valuePtr , wCsLenNode .execute (inliningTarget , valuePtr , size ) * WCHAR_T_SIZE );
981
- return switchEncodingNode .execute (fromByteArrayNode .execute (bytes , WCHAR_T_ENCODING , false ), TS_ENCODING );
982
- } else {
976
+ // ptr is a char**, we need to deref it to get char*
977
+ Pointer valuePtr = readPointerNode .execute (inliningTarget , ptr );
978
+ if (valuePtr .isNull ()) {
983
979
return PNone .NONE ;
984
980
}
981
+ byte [] bytes = readBytesNode .execute (inliningTarget , valuePtr , wCsLenNode .execute (inliningTarget , valuePtr , size ) * WCHAR_T_SIZE );
982
+ return switchEncodingNode .execute (fromByteArrayNode .execute (bytes , WCHAR_T_ENCODING , false ), TS_ENCODING );
985
983
}
986
984
987
985
@ Specialization (guards = "getfunc == P_get" )
@@ -990,10 +988,11 @@ static Object P_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @
990
988
@ Shared @ Cached PointerNodes .ReadPointerNode readPointerNode ,
991
989
@ Cached PointerNodes .GetPointerValueAsObjectNode getPointerValueAsObjectNode ,
992
990
@ Shared @ Cached PythonObjectFactory factory ) {
993
- if (ptr .isNull ()) {
991
+ Pointer valuePtr = readPointerNode .execute (inliningTarget , ptr );
992
+ if (valuePtr .isNull ()) {
994
993
return 0L ;
995
994
}
996
- Object p = getPointerValueAsObjectNode .execute (inliningTarget , readPointerNode . execute ( inliningTarget , ptr ) );
995
+ Object p = getPointerValueAsObjectNode .execute (inliningTarget , valuePtr );
997
996
if (p instanceof Long ) {
998
997
long val = (long ) p ;
999
998
return val < 0 ? factory .createInt (PInt .longToUnsignedBigInteger (val )) : val ;
0 commit comments