github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/ir/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 ir 6 7 import ( 8 "github.com/shogo82148/std/go/constant" 9 "github.com/shogo82148/std/math/big" 10 11 "github.com/shogo82148/std/cmd/compile/internal/types" 12 "github.com/shogo82148/std/cmd/internal/src" 13 ) 14 15 // NewBool returns an OLITERAL representing b as an untyped boolean. 16 func NewBool(pos src.XPos, b bool) Node 17 18 // NewInt returns an OLITERAL representing v as an untyped integer. 19 func NewInt(pos src.XPos, v int64) Node 20 21 // NewString returns an OLITERAL representing s as an untyped string. 22 func NewString(pos src.XPos, s string) Node 23 24 // NewUintptr returns an OLITERAL representing v as a uintptr. 25 func NewUintptr(pos src.XPos, v int64) Node 26 27 // NewZero returns a zero value of the given type. 28 func NewZero(pos src.XPos, typ *types.Type) Node 29 30 // NewOne returns an OLITERAL representing 1 with the given type. 31 func NewOne(pos src.XPos, typ *types.Type) Node 32 33 const ( 34 // Maximum size in bits for big.Ints before signaling 35 // overflow and also mantissa precision for big.Floats. 36 ConstPrec = 512 37 ) 38 39 func BigFloat(v constant.Value) *big.Float 40 41 // ConstOverflow reports whether constant value v is too large 42 // to represent with type t. 43 func ConstOverflow(v constant.Value, t *types.Type) bool 44 45 // IsConstNode reports whether n is a Go language constant (as opposed to a 46 // compile-time constant). 47 // 48 // Expressions derived from nil, like string([]byte(nil)), while they 49 // may be known at compile time, are not Go language constants. 50 func IsConstNode(n Node) bool 51 52 func IsSmallIntConst(n Node) bool