@@ -233,6 +233,7 @@ class JavaAPISettings(AbstractAPISettings):
233
233
"PointerBase" ,
234
234
"Pointer" ,
235
235
"VoidPointer" ,
236
+ "WordPointer" ,
236
237
"CCharPointer" ,
237
238
"CCharPointerPointer" ,
238
239
"CDoublePointer" ,
@@ -628,12 +629,12 @@ def ni_reference_type(self, the_type: CompiledType) -> str:
628
629
(T .Bool , lambda _ : "CCharPointer" ),
629
630
(T .Int , lambda _ : "CIntPointer" ),
630
631
(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 " ),
637
638
(ct .EnumType , lambda _ : "CIntPointer" ),
638
639
(object , lambda t : self .ni_type (t ))
639
640
])
@@ -646,7 +647,7 @@ def ni_stack_value(self, the_type: CompiledType) -> str:
646
647
"""
647
648
ref_type = self .ni_reference_type (the_type )
648
649
if ref_type in self .ni_pointer_types :
649
- return "StackValue.get(SizeOf.get(VoidPointer .class))"
650
+ return "StackValue.get(SizeOf.get(WordPointer .class))"
650
651
else :
651
652
return f"StackValue.get({ ref_type } .class)"
652
653
@@ -718,8 +719,9 @@ def ni_unwrap(self,
718
719
(T .Character , lambda _ : f"{ source } .value;" ),
719
720
(
720
721
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 } );"
723
725
)
724
726
),
725
727
(ct .EnumType , lambda _ : f"{ source } .toC();" ),
@@ -771,21 +773,19 @@ def object_unwrap(self,
771
773
ref_type = self .ni_reference_type (the_type )
772
774
773
775
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) ;"
776
778
f"{ source } .unwrap({ export } );"
777
779
)
778
780
779
781
else :
780
782
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) ;"
783
785
f"{ source } .unwrap({ export } );"
784
786
)
785
787
else :
786
- res = f"{ source } .unwrap();"
787
-
788
- return res
788
+ return f"{ source } .unwrap();"
789
789
790
790
def ni_write (self ,
791
791
the_type : CompiledType ,
@@ -799,6 +799,7 @@ def ni_write(self,
799
799
:param source: The source Java expression to write.
800
800
:param pointer: The pointer to write in.
801
801
"""
802
+
802
803
return dispatch_on_type (the_type , [
803
804
(
804
805
T .Bool , lambda _ :
@@ -821,15 +822,15 @@ def ni_write(self,
821
822
),
822
823
(
823
824
T .AnalysisContext , lambda _ :
824
- f"{ pointer } .writeWord(0, { source } .unwrap());"
825
+ f"{ pointer } .write( { source } .unwrap());"
825
826
),
826
827
(
827
828
T .AnalysisUnit , lambda _ :
828
- f"{ pointer } .writeWord(0, { source } .unwrap());"
829
+ f"{ pointer } .write( { source } .unwrap());"
829
830
),
830
831
(
831
832
ct .IteratorType , lambda _ :
832
- f"{ pointer } .writeWord(0, { source } .unwrap());"
833
+ f"{ pointer } .write( { source } .unwrap());"
833
834
),
834
835
(
835
836
ct .ArrayType , lambda t :
@@ -925,7 +926,7 @@ def ni_field_unwrap(self, flat: FlatStructField) -> str:
925
926
(ct .StructType , lambda _ : f"{ getter } .unwrap({ to_write } );" ),
926
927
(
927
928
object , lambda t :
928
- f"{ to_write } .writeWord(0, { getter } .unwrap());"
929
+ f"{ to_write } .write( { getter } .unwrap());"
929
930
),
930
931
])
931
932
0 commit comments