Change-Id: Ifdc41f6c77c83d22b9ad8811280f1e1db051c781
Reviewed-on: https://go-review.googlesource.com/39951
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
// if it is an unsafe.Pointer
case TUINTPTR:
if n.Type.Etype == TUNSAFEPTR {
- n.SetVal(Val{new(Mpint)})
- n.Val().U.(*Mpint).SetInt64(0)
+ i := new(Mpint)
+ i.SetInt64(0)
+ n.SetVal(Val{i})
} else {
goto bad
}
case *Mpflt:
i := new(Mpint)
if !i.SetFloat(u) {
- if i.Ovf {
+ if i.checkOverflow(0) {
yyerror("integer too large")
} else {
// The value of u cannot be represented as an integer;
// Mpint, so we still have to guard the conversion.
v := toint(n.Val())
vi, ok := v.U.(*Mpint)
- if !ok || vi.Val.Sign() < 0 || vi.Cmp(maxintval[TINT32]) > 0 {
+ if !ok || vi.CmpInt64(0) < 0 || vi.Cmp(maxintval[TINT32]) > 0 {
return -1
}
}
func (a *Mpflt) SetInt(b *Mpint) {
- if b.Ovf {
+ if b.checkOverflow(0) {
// sign doesn't really matter but copy anyway
a.Val.SetInf(b.Val.Sign() < 0)
return
package gc
import (
- "math/big"
"testing"
)
func nodrune(r rune) *Node {
- return nodlit(Val{&Mpint{Val: *big.NewInt(int64(r)), Rune: true}})
+ v := new(Mpint)
+ v.SetInt64(int64(r))
+ v.Rune = true
+ return nodlit(Val{v})
}
func nodflt(f float64) *Node {
- return nodlit(Val{&Mpflt{Val: *big.NewFloat(f)}})
+ v := new(Mpflt)
+ v.SetFloat64(f)
+ return nodlit(Val{v})
}
func TestCaseClauseByConstVal(t *testing.T) {