@@ -4,6 +4,7 @@ use crate::cilnode::MethodKind;
4
4
use crate :: v2:: method:: LocalDef ;
5
5
6
6
use crate :: FieldDesc ;
7
+ use crate :: IntoAsmIndex ;
7
8
use crate :: {
8
9
call,
9
10
cil_root:: CILRoot ,
@@ -137,6 +138,7 @@ pub enum CILNode {
137
138
LdcF32 ( HashableF32 ) ,
138
139
LoadGlobalAllocPtr {
139
140
alloc_id : u64 ,
141
+ tpe : Interned < Type > ,
140
142
} ,
141
143
ConvU8 ( Box < Self > ) ,
142
144
ConvU16 ( Box < Self > ) ,
@@ -225,6 +227,15 @@ pub enum CILNode {
225
227
}
226
228
227
229
impl 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
+ }
228
239
pub fn stack_addr ( val : Self , tpe_idx : Interned < Type > , _asm : & mut Assembly ) -> Self {
229
240
CILNode :: TemporaryLocal ( Box :: new ( (
230
241
tpe_idx,
@@ -459,7 +470,7 @@ impl CILNode {
459
470
Self :: LocAllocAligned { ..} =>( ) ,
460
471
Self :: CastPtr { val, new_ptr : _ } =>val. allocate_tmps ( curr_loc, locals) ,
461
472
Self :: PointerToConstValue ( _arr) =>( ) ,
462
- Self :: LoadGlobalAllocPtr { alloc_id : _ } => ( ) ,
473
+ Self :: LoadGlobalAllocPtr { alloc_id : _, tpe : _ } => ( ) ,
463
474
Self :: LDLoc ( _) |
464
475
Self :: LDArg ( _) |
465
476
Self :: LDLocA ( _) |
0 commit comments