@@ -329,6 +329,9 @@ struct Region {
329
329
}
330
330
331
331
impl Region {
332
+ fn size ( & self ) -> u32 {
333
+ self . end - self . offset
334
+ }
332
335
fn shortest_ident ( & self ) -> Option < String > {
333
336
let mut idents: Vec < _ > = self
334
337
. rbfs
@@ -490,12 +493,17 @@ impl FieldRegions {
490
493
. binary_search_by_key ( & new_region. offset , |r| r. offset ) ;
491
494
match idx {
492
495
Ok ( idx) => {
493
- bail ! (
494
- "we shouldn't exist in the vec, but are at idx {} {:#?}\n {:#?}" ,
495
- idx,
496
- new_region,
497
- self . regions
498
- ) ;
496
+ if new_region. size ( ) == 0 {
497
+ // add ArrayProxy
498
+ self . regions . insert ( idx, new_region) ;
499
+ } else {
500
+ bail ! (
501
+ "we shouldn't exist in the vec, but are at idx {} {:#?}\n {:#?}" ,
502
+ idx,
503
+ new_region,
504
+ self . regions
505
+ ) ;
506
+ }
499
507
}
500
508
Err ( idx) => self . regions . insert ( idx, new_region) ,
501
509
} ;
@@ -1185,6 +1193,8 @@ fn expand_register(
1185
1193
Register :: Array ( info, array_info) => {
1186
1194
let sequential_addresses = ( array_info. dim == 1 )
1187
1195
|| ( register_size == array_info. dim_increment * BITS_PER_BYTE ) ;
1196
+ let disjoint_sequential_addresses = ( array_info. dim == 1 )
1197
+ || ( register_size <= array_info. dim_increment * BITS_PER_BYTE ) ;
1188
1198
1189
1199
let convert_list = match config. keep_list {
1190
1200
true => match & array_info. dim_name {
@@ -1208,20 +1218,22 @@ fn expand_register(
1208
1218
} else {
1209
1219
"" . into ( )
1210
1220
} ;
1211
- let array_convertible = match derive_info {
1221
+ let ac = match derive_info {
1212
1222
DeriveInfo :: Implicit ( _) => {
1213
1223
ty_name = util:: replace_suffix ( & info_name, & index) ;
1214
- sequential_addresses && convert_list && sequential_indexes_from0
1224
+ convert_list && sequential_indexes_from0
1215
1225
}
1216
1226
DeriveInfo :: Explicit ( _) => {
1217
1227
ty_name = util:: replace_suffix ( & info_name, & index) ;
1218
- sequential_addresses && convert_list && sequential_indexes_from0
1228
+ convert_list && sequential_indexes_from0
1219
1229
}
1220
- _ => sequential_addresses && convert_list,
1230
+ _ => convert_list,
1221
1231
} ;
1232
+ let array_convertible = ac && sequential_addresses;
1233
+ let array_proxy_convertible = ac && disjoint_sequential_addresses;
1222
1234
let ty = name_to_ty ( & ty_name) ;
1223
1235
1224
- if array_convertible {
1236
+ if array_convertible || ( array_proxy_convertible && config . const_generic ) {
1225
1237
let accessors = if sequential_indexes_from0 {
1226
1238
Vec :: new ( )
1227
1239
} else {
@@ -1247,14 +1259,22 @@ fn expand_register(
1247
1259
}
1248
1260
accessors
1249
1261
} ;
1250
- let array_ty = new_syn_array ( ty, array_info. dim ) ;
1262
+ let array_ty = if array_convertible {
1263
+ new_syn_array ( ty, array_info. dim )
1264
+ } else {
1265
+ array_proxy_type ( ty, array_info)
1266
+ } ;
1251
1267
let syn_field =
1252
1268
new_syn_field ( ty_name. to_snake_case_ident ( Span :: call_site ( ) ) , array_ty) ;
1253
1269
register_expanded. push ( RegisterBlockField {
1254
1270
syn_field,
1255
1271
description,
1256
1272
offset : info. address_offset ,
1257
- size : register_size * array_info. dim ,
1273
+ size : if array_convertible {
1274
+ register_size * array_info. dim
1275
+ } else {
1276
+ 0
1277
+ } ,
1258
1278
accessors,
1259
1279
} ) ;
1260
1280
} else {
0 commit comments