@@ -4,6 +4,7 @@ use crate::cilnode::MethodKind;
44use crate :: v2:: method:: LocalDef ;
55
66use crate :: FieldDesc ;
7+ use crate :: IntoAsmIndex ;
78use crate :: {
89 call,
910 cil_root:: CILRoot ,
@@ -137,6 +138,7 @@ pub enum CILNode {
137138 LdcF32 ( HashableF32 ) ,
138139 LoadGlobalAllocPtr {
139140 alloc_id : u64 ,
141+ tpe : Interned < Type > ,
140142 } ,
141143 ConvU8 ( Box < Self > ) ,
142144 ConvU16 ( Box < Self > ) ,
@@ -225,6 +227,15 @@ pub enum CILNode {
225227}
226228
227229impl CILNode {
230+ pub fn global_alloc_ptr (
231+ alloc_id : u64 ,
232+ tpe : impl IntoAsmIndex < Interned < Type > > ,
233+ asm : & mut Assembly ,
234+ ) -> Self {
235+ let tmp = tpe. into_idx ( asm) ;
236+ //assert!(!asm[tmp].is_ptr(), "{}", asm[tmp].mangle(asm));
237+ Self :: LoadGlobalAllocPtr { alloc_id, tpe : tmp }
238+ }
228239 pub fn stack_addr ( val : Self , tpe_idx : Interned < Type > , _asm : & mut Assembly ) -> Self {
229240 CILNode :: TemporaryLocal ( Box :: new ( (
230241 tpe_idx,
@@ -459,7 +470,7 @@ impl CILNode {
459470 Self :: LocAllocAligned { ..} =>( ) ,
460471 Self :: CastPtr { val, new_ptr : _ } =>val. allocate_tmps ( curr_loc, locals) ,
461472 Self :: PointerToConstValue ( _arr) =>( ) ,
462- Self :: LoadGlobalAllocPtr { alloc_id : _ } => ( ) ,
473+ Self :: LoadGlobalAllocPtr { alloc_id : _, tpe : _ } => ( ) ,
463474 Self :: LDLoc ( _) |
464475 Self :: LDArg ( _) |
465476 Self :: LDLocA ( _) |
0 commit comments