@@ -233,6 +233,7 @@ class JavaAPISettings(AbstractAPISettings):
233233 "PointerBase" ,
234234 "Pointer" ,
235235 "VoidPointer" ,
236+ "WordPointer" ,
236237 "CCharPointer" ,
237238 "CCharPointerPointer" ,
238239 "CDoublePointer" ,
@@ -628,12 +629,12 @@ def ni_reference_type(self, the_type: CompiledType) -> str:
628629 (T .Bool , lambda _ : "CCharPointer" ),
629630 (T .Int , lambda _ : "CIntPointer" ),
630631 (T .Character , lambda _ : "CIntPointer" ),
631- (T .BigInt , lambda _ : "Pointer " ),
632- (T .String , lambda _ : "Pointer " ),
633- (T .AnalysisUnit , lambda _ : "Pointer " ),
634- (T .AnalysisContext , lambda _ : "Pointer " ),
635- (ct .ArrayType , lambda _ : "Pointer " ),
636- (ct .IteratorType , lambda _ : "Pointer " ),
632+ (T .BigInt , lambda _ : "WordPointer " ),
633+ (T .String , lambda _ : "WordPointer " ),
634+ (T .AnalysisUnit , lambda _ : "WordPointer " ),
635+ (T .AnalysisContext , lambda _ : "WordPointer " ),
636+ (ct .ArrayType , lambda _ : "WordPointer " ),
637+ (ct .IteratorType , lambda _ : "WordPointer " ),
637638 (ct .EnumType , lambda _ : "CIntPointer" ),
638639 (object , lambda t : self .ni_type (t ))
639640 ])
@@ -646,7 +647,7 @@ def ni_stack_value(self, the_type: CompiledType) -> str:
646647 """
647648 ref_type = self .ni_reference_type (the_type )
648649 if ref_type in self .ni_pointer_types :
649- return "StackValue.get(SizeOf.get(VoidPointer .class))"
650+ return "StackValue.get(SizeOf.get(WordPointer .class))"
650651 else :
651652 return f"StackValue.get({ ref_type } .class)"
652653
@@ -718,8 +719,9 @@ def ni_unwrap(self,
718719 (T .Character , lambda _ : f"{ source } .value;" ),
719720 (
720721 T .BigInt , lambda t : (
721- f"{ self .ni_stack_value (t )} ;"
722- f"BigIntegerWrapper.unwrap({ source } , { export } );"
722+ f"StackValue.get(SizeOf.get(WordPointer.class));"
723+ f"BigIntegerWrapper.unwrap({ source } ,"
724+ f"(WordPointer) { export } );"
723725 )
724726 ),
725727 (ct .EnumType , lambda _ : f"{ source } .toC();" ),
@@ -771,21 +773,19 @@ def object_unwrap(self,
771773 ref_type = self .ni_reference_type (the_type )
772774
773775 if ref_type not in self .ni_pointer_types :
774- res = (
775- f"{ self . ni_stack_value ( the_type ) } ;"
776+ return (
777+ f"StackValue.get( { ref_type } .class) ;"
776778 f"{ source } .unwrap({ export } );"
777779 )
778780
779781 else :
780782 if the_type .is_ada_record :
781- res = (
782- f"{ self . ni_stack_value ( the_type ) } ;"
783+ return (
784+ f"StackValue.get( { ref_type } .class) ;"
783785 f"{ source } .unwrap({ export } );"
784786 )
785787 else :
786- res = f"{ source } .unwrap();"
787-
788- return res
788+ return f"{ source } .unwrap();"
789789
790790 def ni_write (self ,
791791 the_type : CompiledType ,
@@ -799,6 +799,7 @@ def ni_write(self,
799799 :param source: The source Java expression to write.
800800 :param pointer: The pointer to write in.
801801 """
802+
802803 return dispatch_on_type (the_type , [
803804 (
804805 T .Bool , lambda _ :
@@ -821,15 +822,15 @@ def ni_write(self,
821822 ),
822823 (
823824 T .AnalysisContext , lambda _ :
824- f"{ pointer } .writeWord(0, { source } .unwrap());"
825+ f"{ pointer } .write( { source } .unwrap());"
825826 ),
826827 (
827828 T .AnalysisUnit , lambda _ :
828- f"{ pointer } .writeWord(0, { source } .unwrap());"
829+ f"{ pointer } .write( { source } .unwrap());"
829830 ),
830831 (
831832 ct .IteratorType , lambda _ :
832- f"{ pointer } .writeWord(0, { source } .unwrap());"
833+ f"{ pointer } .write( { source } .unwrap());"
833834 ),
834835 (
835836 ct .ArrayType , lambda t :
@@ -925,7 +926,7 @@ def ni_field_unwrap(self, flat: FlatStructField) -> str:
925926 (ct .StructType , lambda _ : f"{ getter } .unwrap({ to_write } );" ),
926927 (
927928 object , lambda t :
928- f"{ to_write } .writeWord(0, { getter } .unwrap());"
929+ f"{ to_write } .write( { getter } .unwrap());"
929930 ),
930931 ])
931932
0 commit comments