...
1
2
3
4
5
6
7
8 package typecheck
9
10 import (
11 "cmd/compile/internal/base"
12 "cmd/compile/internal/ir"
13 "cmd/compile/internal/types"
14 )
15
16
17
18
19
20
21 var HaveInlineBody = func(fn *ir.Func) bool {
22 base.Fatalf("HaveInlineBody not overridden")
23 panic("unreachable")
24 }
25
26 func SetBaseTypeIndex(t *types.Type, i, pi int64) {
27 if t.Obj() == nil {
28 base.Fatalf("SetBaseTypeIndex on non-defined type %v", t)
29 }
30 if i != -1 && pi != -1 {
31 typeSymIdx[t] = [2]int64{i, pi}
32 }
33 }
34
35
36
37
38 var typeSymIdx = make(map[*types.Type][2]int64)
39
40 func BaseTypeIndex(t *types.Type) int64 {
41 tbase := t
42 if t.IsPtr() && t.Sym() == nil && t.Elem().Sym() != nil {
43 tbase = t.Elem()
44 }
45 i, ok := typeSymIdx[tbase]
46 if !ok {
47 return -1
48 }
49 if t != tbase {
50 return i[1]
51 }
52 return i[0]
53 }
54
View as plain text