File tree 3 files changed +15
-9
lines changed
3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -702,13 +702,17 @@ typefmt(Fmt *fp, Type *t)
702
702
case TSTRUCT :
703
703
// Format the bucket struct for map[x]y as map.bucket[x]y.
704
704
// This avoids a recursive print that generates very long names.
705
- if (t -> hmap != T ) {
706
- t = t -> hmap ;
707
- return fmtprint (fp , "map.bucket[%T]%T" , t -> down , t -> type );
708
- }
709
- if (t -> hiter != T ) {
710
- t = t -> hiter ;
711
- return fmtprint (fp , "map.iter[%T]%T" , t -> down , t -> type );
705
+ if (t -> map != T ) {
706
+ if (t -> map -> bucket == t ) {
707
+ return fmtprint (fp , "map.bucket[%T]%T" , t -> map -> down , t -> map -> type );
708
+ }
709
+ if (t -> map -> hmap == t ) {
710
+ return fmtprint (fp , "map.hdr[%T]%T" , t -> map -> down , t -> map -> type );
711
+ }
712
+ if (t -> map -> hiter == t ) {
713
+ return fmtprint (fp , "map.iter[%T]%T" , t -> map -> down , t -> map -> type );
714
+ }
715
+ yyerror ("unknown internal map type" );
712
716
}
713
717
714
718
if (t -> funarg ) {
Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ struct Type
191
191
Type * bucket ; // internal type representing a hash bucket
192
192
Type * hmap ; // internal type representing a Hmap (map header object)
193
193
Type * hiter ; // internal type representing hash iterator state
194
+ Type * map ; // link from the above 3 internal types back to the map type.
194
195
195
196
int32 maplineno ; // first use of TFORW as map key
196
197
int32 embedlineno ; // first use of TFORW as embedded type
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ mapbucket(Type *t)
173
173
bucket -> width = offset ;
174
174
bucket -> local = t -> local ;
175
175
t -> bucket = bucket ;
176
+ bucket -> map = t ;
176
177
return bucket ;
177
178
}
178
179
@@ -229,7 +230,7 @@ hmap(Type *t)
229
230
h -> width = offset ;
230
231
h -> local = t -> local ;
231
232
t -> hmap = h ;
232
- h -> hmap = t ;
233
+ h -> map = t ;
233
234
return h ;
234
235
}
235
236
@@ -308,7 +309,7 @@ hiter(Type *t)
308
309
if (off != 11 * widthptr )
309
310
yyerror ("hash_iter size not correct %d %d" , off , 11 * widthptr );
310
311
t -> hiter = i ;
311
- i -> hiter = t ;
312
+ i -> map = t ;
312
313
return i ;
313
314
}
314
315
You can’t perform that action at this time.
0 commit comments