@@ -260,6 +260,7 @@ static HPy (*original_Global_Load)(HPyContext *ctx, HPyGlobal global);
260
260
static void (* original_Field_Store )(HPyContext * ctx , HPy target_object , HPyField * target_field , HPy h );
261
261
static HPy (* original_Field_Load )(HPyContext * ctx , HPy source_object , HPyField source_field );
262
262
static int (* original_Is )(HPyContext * ctx , HPy a , HPy b );
263
+ static HPy (* original_Type )(HPyContext * , HPy );
263
264
264
265
static int augment_Is (HPyContext * ctx , HPy a , HPy b ) {
265
266
long bitsA = toBits (a );
@@ -577,6 +578,17 @@ HPy augment_GetItem_s(HPyContext *ctx, HPy target, const char *name) {
577
578
return DO_UPCALL_HPY (CONTEXT_INSTANCE (ctx ), GetItems , target , jname );
578
579
}
579
580
581
+ HPy augment_Type (HPyContext * ctx , HPy h ) {
582
+ uint64_t bits = toBits (h );
583
+ if (isBoxedInt (bits )) {
584
+ return ctx -> h_LongType ;
585
+ } else if (isBoxedDouble (bits )) {
586
+ return ctx -> h_FloatType ;
587
+ } else {
588
+ return original_Type (ctx , h );
589
+ }
590
+ }
591
+
580
592
void initDirectFastPaths (HPyContext * context ) {
581
593
LOG ("%p" , context );
582
594
context -> name = "HPy Universal ABI (GraalVM backend, JNI)" ;
@@ -633,6 +645,8 @@ void initDirectFastPaths(HPyContext *context) {
633
645
634
646
AUGMENT (Is );
635
647
648
+ AUGMENT (Type );
649
+
636
650
#undef AUGMENT
637
651
638
652
context -> ctx_SetItem_s = augment_SetItem_s ;
0 commit comments