github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/abi/switch.go (about) 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 type InterfaceSwitch struct { 8 Cache *InterfaceSwitchCache 9 NCases int 10 11 // Array of NCases elements. 12 // Each case must be a non-empty interface type. 13 Cases [1]*InterfaceType 14 } 15 16 type InterfaceSwitchCache struct { 17 Mask uintptr 18 Entries [1]InterfaceSwitchCacheEntry 19 } 20 21 type InterfaceSwitchCacheEntry struct { 22 // type of source value (a *Type) 23 Typ uintptr 24 // case # to dispatch to 25 Case int 26 // itab to use for resulting case variable (a *runtime.itab) 27 Itab uintptr 28 } 29 30 func UseInterfaceSwitchCache(goarch string) bool 31 32 type TypeAssert struct { 33 Cache *TypeAssertCache 34 Inter *InterfaceType 35 CanFail bool 36 } 37 type TypeAssertCache struct { 38 Mask uintptr 39 Entries [1]TypeAssertCacheEntry 40 } 41 type TypeAssertCacheEntry struct { 42 // type of source value (a *runtime._type) 43 Typ uintptr 44 // itab to use for result (a *runtime.itab) 45 // nil if CanFail is set and conversion would fail. 46 Itab uintptr 47 }