@@ -25,114 +25,6 @@ import (
2525type Kind = abi.Kind
2626type Type = abi.Type
2727
28- // -----------------------------------------------------------------------------
29- var (
30- tyBasic [abi .UnsafePointer + 1 ]* Type
31- )
32-
33- func basicEqual (kind Kind , size uintptr ) func (a , b unsafe.Pointer ) bool {
34- switch kind {
35- case abi .Bool , abi .Int , abi .Int8 , abi .Int16 , abi .Int32 , abi .Int64 ,
36- abi .Uint , abi .Uint8 , abi .Uint16 , abi .Uint32 , abi .Uint64 , abi .Uintptr :
37- switch size {
38- case 1 :
39- return memequal8
40- case 2 :
41- return memequal16
42- case 4 :
43- return memequal32
44- case 8 :
45- return memequal64
46- }
47- case abi .Float32 :
48- return f32equal
49- case abi .Float64 :
50- return f64equal
51- case abi .Complex64 :
52- return c64equal
53- case abi .Complex128 :
54- return c128equal
55- case abi .String :
56- return strequal
57- case abi .UnsafePointer :
58- return memequalptr
59- }
60- panic ("unreachable" )
61- }
62-
63- func basicFlags (kind Kind ) abi.TFlag {
64- switch kind {
65- case abi .Float32 , abi .Float64 , abi .Complex64 , abi .Complex128 , abi .String :
66- return 0
67- }
68- return abi .TFlagRegularMemory
69- }
70-
71- func Basic (_kind Kind ) * Type {
72- kind := _kind & abi .KindMask
73- if tyBasic [kind ] == nil {
74- name , size , align := basicTypeInfo (kind )
75- var ptrBytes uintptr
76- if kind == abi .String || kind == abi .UnsafePointer {
77- ptrBytes = pointerSize
78- }
79- tyBasic [kind ] = & Type {
80- Size_ : size ,
81- PtrBytes : ptrBytes ,
82- Hash : uint32 (kind ),
83- Align_ : uint8 (align ),
84- FieldAlign_ : uint8 (align ),
85- Kind_ : uint8 (_kind ),
86- Equal : basicEqual (kind , size ),
87- TFlag : basicFlags (kind ),
88- Str_ : name ,
89- }
90- }
91- return tyBasic [kind ]
92- }
93-
94- func basicTypeInfo (kind abi.Kind ) (string , uintptr , uintptr ) {
95- switch kind {
96- case abi .Bool :
97- return "bool" , unsafe .Sizeof (false ), unsafe .Alignof (false )
98- case abi .Int :
99- return "int" , unsafe .Sizeof (0 ), unsafe .Alignof (0 )
100- case abi .Int8 :
101- return "int8" , 1 , 1
102- case abi .Int16 :
103- return "int16" , 2 , 2
104- case abi .Int32 :
105- return "int32" , 4 , 4
106- case abi .Int64 :
107- return "int64" , 8 , 8
108- case abi .Uint :
109- return "uint" , unsafe .Sizeof (uint (0 )), unsafe .Alignof (uint (0 ))
110- case abi .Uint8 :
111- return "uint8" , 1 , 1
112- case abi .Uint16 :
113- return "uint16" , 2 , 2
114- case abi .Uint32 :
115- return "uint32" , 4 , 4
116- case abi .Uint64 :
117- return "uint64" , 8 , 8
118- case abi .Uintptr :
119- return "uintptr" , unsafe .Sizeof (uintptr (0 )), unsafe .Alignof (uintptr (0 ))
120- case abi .Float32 :
121- return "float32" , 4 , 4
122- case abi .Float64 :
123- return "float64" , 8 , 8
124- case abi .Complex64 :
125- return "complex64" , 8 , 4
126- case abi .Complex128 :
127- return "complex128" , 16 , 8
128- case abi .String :
129- return "string" , unsafe .Sizeof (String {}), unsafe .Alignof ("" )
130- case abi .UnsafePointer :
131- return "unsafe.Pointer" , unsafe .Sizeof (unsafe .Pointer (nil )), unsafe .Alignof (unsafe .Pointer (nil ))
132- }
133- panic ("unreachable" )
134- }
135-
13628// -----------------------------------------------------------------------------
13729
13830// StructField returns a struct field.
@@ -579,10 +471,6 @@ func (r *rtypes) addType(typ *Type) {
579471
580472var rtypeList rtypes
581473
582- func addType (typ * abi.Type ) {
583- rtypeList .addType (typ )
584- }
585-
586474func initTypes (typs * []* abi.Type ) {
587475 rtypeList .types = * typs
588476}
0 commit comments