github.com/chenzhuoyu/iasm@v0.9.1/x86_64/eface.go (about)

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