mirror of
https://github.com/golang/go
synced 2024-11-26 09:48:14 -07:00
[dev.regabi] cmd/compile: remove workarounds for go/constant issues
These were fixed in CLs 273086 and 273126, which have been merged back into dev.regabi already. Passes toolstash -cmp. Change-Id: I011e9ed7062bc034496a279e21cc163267bf83fd Reviewed-on: https://go-review.googlesource.com/c/go/+/280643 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
33801cdc62
commit
171fc6f223
@ -564,20 +564,11 @@ func EvalConst(n ir.Node) ir.Node {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeInt(i *big.Int) constant.Value {
|
|
||||||
if i.IsInt64() {
|
|
||||||
return constant.Make(i.Int64()) // workaround #42640 (Int64Val(Make(big.NewInt(10))) returns (10, false), not (10, true))
|
|
||||||
}
|
|
||||||
return constant.Make(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeFloat64(f float64) constant.Value {
|
func makeFloat64(f float64) constant.Value {
|
||||||
if math.IsInf(f, 0) {
|
if math.IsInf(f, 0) {
|
||||||
base.Fatalf("infinity is not a valid constant")
|
base.Fatalf("infinity is not a valid constant")
|
||||||
}
|
}
|
||||||
v := constant.MakeFloat64(f)
|
return constant.MakeFloat64(f)
|
||||||
v = constant.ToFloat(v) // workaround #42641 (MakeFloat64(0).Kind() returns Int, not Float)
|
|
||||||
return v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeComplex(real, imag constant.Value) constant.Value {
|
func makeComplex(real, imag constant.Value) constant.Value {
|
||||||
|
@ -936,7 +936,7 @@ func (w *exportWriter) mpfloat(v constant.Value, typ *types.Type) {
|
|||||||
if acc != big.Exact {
|
if acc != big.Exact {
|
||||||
base.Fatalf("mantissa scaling failed for %f (%s)", f, acc)
|
base.Fatalf("mantissa scaling failed for %f (%s)", f, acc)
|
||||||
}
|
}
|
||||||
w.mpint(makeInt(manti), typ)
|
w.mpint(constant.Make(manti), typ)
|
||||||
if manti.Sign() != 0 {
|
if manti.Sign() != 0 {
|
||||||
w.int64(exp)
|
w.int64(exp)
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ func (p *importReader) value(typ *types.Type) constant.Value {
|
|||||||
case constant.Int:
|
case constant.Int:
|
||||||
var i big.Int
|
var i big.Int
|
||||||
p.mpint(&i, typ)
|
p.mpint(&i, typ)
|
||||||
return makeInt(&i)
|
return constant.Make(&i)
|
||||||
case constant.Float:
|
case constant.Float:
|
||||||
return p.float(typ)
|
return p.float(typ)
|
||||||
case constant.Complex:
|
case constant.Complex:
|
||||||
|
Loading…
Reference in New Issue
Block a user