github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/ir/val.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 ir
     6  
     7  import (
     8  	"github.com/shogo82148/std/go/constant"
     9  
    10  	"github.com/shogo82148/std/cmd/compile/internal/types"
    11  )
    12  
    13  func ConstType(n Node) constant.Kind
    14  
    15  // IntVal returns v converted to int64.
    16  // Note: if t is uint64, very large values will be converted to negative int64.
    17  func IntVal(t *types.Type, v constant.Value) int64
    18  
    19  func AssertValidTypeForConst(t *types.Type, v constant.Value)
    20  
    21  func ValidTypeForConst(t *types.Type, v constant.Value) bool
    22  
    23  var OKForConst [types.NTYPE]bool
    24  
    25  // Int64Val returns n as an int64.
    26  // n must be an integer or rune constant.
    27  func Int64Val(n Node) int64
    28  
    29  // Uint64Val returns n as a uint64.
    30  // n must be an integer or rune constant.
    31  func Uint64Val(n Node) uint64
    32  
    33  // BoolVal returns n as a bool.
    34  // n must be a boolean constant.
    35  func BoolVal(n Node) bool
    36  
    37  // StringVal returns the value of a literal string Node as a string.
    38  // n must be a string constant.
    39  func StringVal(n Node) string