Source file src/internal/abi/iface.go

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package abi
     6  
     7  import "unsafe"
     8  
     9  // The first word of every non-empty interface type contains an *ITab.
    10  // It records the underlying concrete type (Type), the interface type it
    11  // is implementing (Inter), and some ancillary information.
    12  //
    13  // allocated in non-garbage-collected memory
    14  type ITab struct {
    15  	Inter *InterfaceType
    16  	Type  *Type
    17  	Hash  uint32     // copy of Type.Hash. Used for type switches.
    18  	Fun   [1]uintptr // variable sized. fun[0]==0 means Type does not implement Inter.
    19  }
    20  
    21  // EmptyInterface describes the layout of a "interface{}" or a "any."
    22  // These are represented differently than non-empty interface, as the first
    23  // word always points to an abi.Type.
    24  type EmptyInterface struct {
    25  	Type *Type
    26  	Data unsafe.Pointer
    27  }
    28  

View as plain text