...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package x86_64
18
19 import (
20 `reflect`
21 `unsafe`
22 )
23
24 type _GoType struct {
25 size uintptr
26 pdata uintptr
27 hash uint32
28 flags uint8
29 align uint8
30 falign uint8
31 kflags uint8
32 traits unsafe.Pointer
33 gcdata *byte
34 str int32
35 ptrx int32
36 }
37
38 const (
39 _KindMask = (1 << 5) - 1
40 )
41
42 func (self *_GoType) kind() reflect.Kind {
43 return reflect.Kind(self.kflags & _KindMask)
44 }
45
46 type _GoSlice struct {
47 ptr unsafe.Pointer
48 len int
49 cap int
50 }
51
52 type _GoEface struct {
53 vt *_GoType
54 ptr unsafe.Pointer
55 }
56
57 func (self *_GoEface) kind() reflect.Kind {
58 if self.vt != nil {
59 return self.vt.kind()
60 } else {
61 return reflect.Invalid
62 }
63 }
64
65 func (self *_GoEface) toInt64() int64 {
66 if self.vt.size == 8 {
67 return *(*int64)(self.ptr)
68 } else if self.vt.size == 4 {
69 return int64(*(*int32)(self.ptr))
70 } else if self.vt.size == 2 {
71 return int64(*(*int16)(self.ptr))
72 } else {
73 return int64(*(*int8)(self.ptr))
74 }
75 }
76
77 func efaceOf(v interface{}) _GoEface {
78 return *(*_GoEface)(unsafe.Pointer(&v))
79 }
80
View as plain text