cmd/compile: change Mp{int,flt} functions into methods

Also give them more idiomatic Go names. Adding godocs is outside the
scope of this CL. (Besides, the method names almost all directly
parallel an underlying math/big.Int or math/big.Float method.)

CL prepared mechanically with sed (for rewriting mpint.go/mpfloat.go)
and gofmt (for rewriting call sites).

Passes toolstash -cmp.

Change-Id: Id76f4aee476ba740f48db33162463e7978c2083d
Reviewed-on: https://go-review.googlesource.com/20909
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2016-03-20 13:55:42 -07:00 committed by Robert Griesemer
parent 5fb6aa3e09
commit d3253876f2
20 changed files with 315 additions and 315 deletions

View file

@ -3269,14 +3269,14 @@ func (p *parser) hidden_literal() *Node {
p.next()
switch ss.Val().Ctype() {
case CTINT, CTRUNE:
mpnegfix(ss.Val().U.(*Mpint))
ss.Val().U.(*Mpint).Neg()
break
case CTFLT:
mpnegflt(ss.Val().U.(*Mpflt))
ss.Val().U.(*Mpflt).Neg()
break
case CTCPLX:
mpnegflt(&ss.Val().U.(*Mpcplx).Real)
mpnegflt(&ss.Val().U.(*Mpcplx).Imag)
ss.Val().U.(*Mpcplx).Real.Neg()
ss.Val().U.(*Mpcplx).Imag.Neg()
break
default:
Yyerror("bad negated constant")
@ -3318,11 +3318,11 @@ func (p *parser) hidden_constant() *Node {
if s2.Val().Ctype() == CTRUNE && s4.Val().Ctype() == CTINT {
ss := s2
mpaddfixfix(s2.Val().U.(*Mpint), s4.Val().U.(*Mpint), 0)
s2.Val().U.(*Mpint).Add(s4.Val().U.(*Mpint), 0)
return ss
}
s4.Val().U.(*Mpcplx).Real = s4.Val().U.(*Mpcplx).Imag
Mpmovecflt(&s4.Val().U.(*Mpcplx).Imag, 0.0)
s4.Val().U.(*Mpcplx).Imag.SetFloat64(0.0)
return nodcplxlit(s2.Val(), s4.Val())
}
}