github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types2/context.go (about)

     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  
     5  package types2
     6  
     7  import (
     8  	"github.com/shogo82148/std/sync"
     9  )
    10  
    11  // A Context is an opaque type checking context. It may be used to share
    12  // identical type instances across type-checked packages or calls to
    13  // Instantiate. Contexts are safe for concurrent use.
    14  //
    15  // The use of a shared context does not guarantee that identical instances are
    16  // deduplicated in all cases.
    17  type Context struct {
    18  	mu        sync.Mutex
    19  	typeMap   map[string][]ctxtEntry
    20  	nextID    int
    21  	originIDs map[Type]int
    22  }
    23  
    24  // NewContext creates a new Context.
    25  func NewContext() *Context