1 // Copyright 2020 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.
5 // Package typesinternal provides access to internal go/types APIs that are not
16 func SetUsesCgo(conf *types.Config) bool {
17 v := reflect.ValueOf(conf).Elem()
19 f := v.FieldByName("go115UsesCgo")
21 f = v.FieldByName("UsesCgo")
27 addr := unsafe.Pointer(f.UnsafeAddr())
33 func ReadGo116ErrorData(terr types.Error) (ErrorCode, token.Pos, token.Pos, bool) {
35 // By coincidence all of these fields are ints, which simplifies things.
36 v := reflect.ValueOf(terr)
37 for i, name := range []string{"go116code", "go116start", "go116end"} {
38 f := v.FieldByName(name)
42 data[i] = int(f.Int())
44 return ErrorCode(data[0]), token.Pos(data[1]), token.Pos(data[2]), true