@@ -836,39 +836,22 @@ func TypeLinksym(t *types.Type) *obj.LSym {
836
836
}
837
837
838
838
func TypePtr (t * types.Type ) * ir.AddrExpr {
839
- s := TypeSym (t )
840
- if s .Def == nil {
841
- n := ir .NewNameAt (src .NoXPos , s )
842
- n .SetType (types .Types [types .TUINT8 ])
843
- n .Class = ir .PEXTERN
844
- n .SetTypecheck (1 )
845
- s .Def = n
846
- }
847
-
848
- n := typecheck .NodAddr (ir .AsNode (s .Def ))
849
- n .SetType (types .NewPtr (s .Def .Type ()))
850
- n .SetTypecheck (1 )
851
- return n
839
+ n := ir .NewLinksymExpr (base .Pos , TypeLinksym (t ), types .Types [types .TUINT8 ])
840
+ return typecheck .Expr (typecheck .NodAddr (n )).(* ir.AddrExpr )
852
841
}
853
842
854
843
func ITabAddr (t , itype * types.Type ) * ir.AddrExpr {
855
844
if t == nil || (t .IsPtr () && t .Elem () == nil ) || t .IsUntyped () || ! itype .IsInterface () || itype .IsEmptyInterface () {
856
845
base .Fatalf ("ITabAddr(%v, %v)" , t , itype )
857
846
}
858
- s := ir .Pkgs .Itab .Lookup (t .ShortString () + "," + itype .ShortString ())
859
- if s .Def == nil {
860
- n := typecheck .NewName (s )
861
- n .SetType (types .Types [types .TUINT8 ])
862
- n .Class = ir .PEXTERN
863
- n .SetTypecheck (1 )
864
- s .Def = n
865
- itabs = append (itabs , itabEntry {t : t , itype : itype , lsym : n .Linksym ()})
866
- }
867
-
868
- n := typecheck .NodAddr (ir .AsNode (s .Def ))
869
- n .SetType (types .NewPtr (s .Def .Type ()))
870
- n .SetTypecheck (1 )
871
- return n
847
+ s , existed := ir .Pkgs .Itab .LookupOK (t .ShortString () + "," + itype .ShortString ())
848
+ if ! existed {
849
+ itabs = append (itabs , itabEntry {t : t , itype : itype , lsym : s .Linksym ()})
850
+ }
851
+
852
+ lsym := s .Linksym ()
853
+ n := ir .NewLinksymExpr (base .Pos , lsym , types .Types [types .TUINT8 ])
854
+ return typecheck .Expr (typecheck .NodAddr (n )).(* ir.AddrExpr )
872
855
}
873
856
874
857
// needkeyupdate reports whether map updates with t as a key
0 commit comments