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

     1  // Copyright 2009 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 typecheck
     6  
     7  import (
     8  	"github.com/shogo82148/std/go/constant"
     9  
    10  	"github.com/shogo82148/std/cmd/compile/internal/ir"
    11  	"github.com/shogo82148/std/cmd/compile/internal/types"
    12  )
    13  
    14  func DefaultLit(n ir.Node, t *types.Type) ir.Node
    15  
    16  // ConvertVal converts v into a representation appropriate for t. If
    17  // no such representation exists, it returns constant.MakeUnknown()
    18  // instead.
    19  //
    20  // If explicit is true, then conversions from integer to string are
    21  // also allowed.
    22  func ConvertVal(v constant.Value, t *types.Type, explicit bool) constant.Value
    23  
    24  // IndexConst checks if Node n contains a constant expression
    25  // representable as a non-negative int and returns its value.
    26  // If n is not a constant expression, not representable as an
    27  // integer, or negative, it returns -1. If n is too large, it
    28  // returns -2.
    29  func IndexConst(n ir.Node) int64