...
Run Format

Source file src/runtime/type.go

     1	// Copyright 2009 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	// Runtime type representation.
     6	
     7	package runtime
     8	
     9	import "unsafe"
    10	
    11	// Needs to be in sync with ../cmd/compile/internal/ld/decodesym.go:/^func.commonsize,
    12	// ../cmd/compile/internal/gc/reflect.go:/^func.dcommontype and
    13	// ../reflect/type.go:/^type.rtype.
    14	type _type struct {
    15		size       uintptr
    16		ptrdata    uintptr // size of memory prefix holding all pointers
    17		hash       uint32
    18		_unused    uint8
    19		align      uint8
    20		fieldalign uint8
    21		kind       uint8
    22		alg        *typeAlg
    23		// gcdata stores the GC type data for the garbage collector.
    24		// If the KindGCProg bit is set in kind, gcdata is a GC program.
    25		// Otherwise it is a ptrmask bitmap. See mbitmap.go for details.
    26		gcdata  *byte
    27		_string *string
    28		x       *uncommontype
    29		ptrto   *_type
    30	}
    31	
    32	type method struct {
    33		name    *string
    34		pkgpath *string
    35		mtyp    *_type
    36		typ     *_type
    37		ifn     unsafe.Pointer
    38		tfn     unsafe.Pointer
    39	}
    40	
    41	type uncommontype struct {
    42		name    *string
    43		pkgpath *string
    44		mhdr    []method
    45	}
    46	
    47	type imethod struct {
    48		name    *string
    49		pkgpath *string
    50		_type   *_type
    51	}
    52	
    53	type interfacetype struct {
    54		typ  _type
    55		mhdr []imethod
    56	}
    57	
    58	type maptype struct {
    59		typ           _type
    60		key           *_type
    61		elem          *_type
    62		bucket        *_type // internal type representing a hash bucket
    63		hmap          *_type // internal type representing a hmap
    64		keysize       uint8  // size of key slot
    65		indirectkey   bool   // store ptr to key instead of key itself
    66		valuesize     uint8  // size of value slot
    67		indirectvalue bool   // store ptr to value instead of value itself
    68		bucketsize    uint16 // size of bucket
    69		reflexivekey  bool   // true if k==k for all keys
    70		needkeyupdate bool   // true if we need to update key on an overwrite
    71	}
    72	
    73	type arraytype struct {
    74		typ   _type
    75		elem  *_type
    76		slice *_type
    77		len   uintptr
    78	}
    79	
    80	type chantype struct {
    81		typ  _type
    82		elem *_type
    83		dir  uintptr
    84	}
    85	
    86	type slicetype struct {
    87		typ  _type
    88		elem *_type
    89	}
    90	
    91	type functype struct {
    92		typ       _type
    93		dotdotdot bool
    94		in        []*_type
    95		out       []*_type
    96	}
    97	
    98	type ptrtype struct {
    99		typ  _type
   100		elem *_type
   101	}
   102	
   103	type structfield struct {
   104		name    *string
   105		pkgpath *string
   106		typ     *_type
   107		tag     *string
   108		offset  uintptr
   109	}
   110	
   111	type structtype struct {
   112		typ    _type
   113		fields []structfield
   114	}
   115	

View as plain text