• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2021 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
5package noder
6
7import (
8	"cmd/compile/internal/types"
9	"cmd/compile/internal/types2"
10)
11
12var basics = [...]**types.Type{
13	types2.Invalid:        new(*types.Type),
14	types2.Bool:           &types.Types[types.TBOOL],
15	types2.Int:            &types.Types[types.TINT],
16	types2.Int8:           &types.Types[types.TINT8],
17	types2.Int16:          &types.Types[types.TINT16],
18	types2.Int32:          &types.Types[types.TINT32],
19	types2.Int64:          &types.Types[types.TINT64],
20	types2.Uint:           &types.Types[types.TUINT],
21	types2.Uint8:          &types.Types[types.TUINT8],
22	types2.Uint16:         &types.Types[types.TUINT16],
23	types2.Uint32:         &types.Types[types.TUINT32],
24	types2.Uint64:         &types.Types[types.TUINT64],
25	types2.Uintptr:        &types.Types[types.TUINTPTR],
26	types2.Float32:        &types.Types[types.TFLOAT32],
27	types2.Float64:        &types.Types[types.TFLOAT64],
28	types2.Complex64:      &types.Types[types.TCOMPLEX64],
29	types2.Complex128:     &types.Types[types.TCOMPLEX128],
30	types2.String:         &types.Types[types.TSTRING],
31	types2.UnsafePointer:  &types.Types[types.TUNSAFEPTR],
32	types2.UntypedBool:    &types.UntypedBool,
33	types2.UntypedInt:     &types.UntypedInt,
34	types2.UntypedRune:    &types.UntypedRune,
35	types2.UntypedFloat:   &types.UntypedFloat,
36	types2.UntypedComplex: &types.UntypedComplex,
37	types2.UntypedString:  &types.UntypedString,
38	types2.UntypedNil:     &types.Types[types.TNIL],
39}
40
41var dirs = [...]types.ChanDir{
42	types2.SendRecv: types.Cboth,
43	types2.SendOnly: types.Csend,
44	types2.RecvOnly: types.Crecv,
45}
46
47// deref2 does a single deref of types2 type t, if it is a pointer type.
48func deref2(t types2.Type) types2.Type {
49	if ptr := types2.AsPointer(t); ptr != nil {
50		t = ptr.Elem()
51	}
52	return t
53}
54