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-go file. 4 5package deepequal 6 7import "unsafe" 8 9type value struct { 10 // typ holds the type of the value represented by a Value. 11 typ *rtype 12 13 // Pointer-valued data or, if flagIndir is set, pointer to data. 14 // Valid when either flagIndir is set or typ.pointers() is true. 15 ptr unsafe.Pointer 16 17 // flag holds metadata about the value. 18 // The lowest bits are flag bits: 19 // - flagStickyRO: obtained via unexported not embedded field, so read-only 20 // - flagEmbedRO: obtained via unexported embedded field, so read-only 21 // - flagIndir: val holds a pointer to the data 22 // - flagAddr: v.CanAddr is true (implies flagIndir) 23 // - flagMethod: v is a method value. 24 // The next five bits give the Kind of the value. 25 // This repeats typ.Kind() except for method values. 26 // The remaining 23+ bits give a method number for method values. 27 // If flag.kind() != Func, code can assume that flagMethod is unset. 28 // If ifaceIndir(typ), code can assume that flagIndir is set. 29 flag 30 31 // A method value represents a curried method invocation 32 // like r.Read for some receiver r. The typ+val+flag bits describe 33 // the receiver r, but the flag's Kind bits say Func (methods are 34 // functions), and the top bits of the flag give the method number 35 // in r's type's method table. 36} 37 38type flag uintptr 39 40const ( 41 flagKindWidth = 5 // there are 27 kinds 42 flagKindMask flag = 1<<flagKindWidth - 1 43 flagStickyRO flag = 1 << 5 44 flagEmbedRO flag = 1 << 6 45 flagIndir flag = 1 << 7 46 flagAddr flag = 1 << 8 47 flagMethod flag = 1 << 9 48 flagMethodShift = 10 49 flagRO flag = flagStickyRO | flagEmbedRO 50) 51