[dev.typeparams] cmd/compile: unified importReader receiver name to r

Change-Id: Iaf8ec7665282f4f8c0cb09a652e78aa97959274b
Reviewed-on: https://go-review.googlesource.com/c/go/+/340150
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Leonard Wang 2021-08-05 23:04:16 +08:00 committed by Robert Griesemer
parent 5dcb5e2cea
commit 6dadee759c

View file

@ -412,14 +412,14 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name {
}
}
func (p *importReader) value(typ *types.Type) constant.Value {
func (r *importReader) value(typ *types.Type) constant.Value {
var kind constant.Kind
var valType *types.Type
if typ.IsTypeParam() {
// If a constant had a typeparam type, then we wrote out its
// actual constant kind as well.
kind = constant.Kind(p.int64())
kind = constant.Kind(r.int64())
switch kind {
case constant.Int:
valType = types.Types[types.TINT64]
@ -435,24 +435,24 @@ func (p *importReader) value(typ *types.Type) constant.Value {
switch kind {
case constant.Bool:
return constant.MakeBool(p.bool())
return constant.MakeBool(r.bool())
case constant.String:
return constant.MakeString(p.string())
return constant.MakeString(r.string())
case constant.Int:
var i big.Int
p.mpint(&i, valType)
r.mpint(&i, valType)
return constant.Make(&i)
case constant.Float:
return p.float(valType)
return r.float(valType)
case constant.Complex:
return makeComplex(p.float(valType), p.float(valType))
return makeComplex(r.float(valType), r.float(valType))
}
base.Fatalf("unexpected value type: %v", typ)
panic("unreachable")
}
func (p *importReader) mpint(x *big.Int, typ *types.Type) {
func (r *importReader) mpint(x *big.Int, typ *types.Type) {
signed, maxBytes := intSize(typ)
maxSmall := 256 - maxBytes
@ -463,7 +463,7 @@ func (p *importReader) mpint(x *big.Int, typ *types.Type) {
maxSmall = 256
}
n, _ := p.ReadByte()
n, _ := r.ReadByte()
if uint(n) < maxSmall {
v := int64(n)
if signed {
@ -484,30 +484,30 @@ func (p *importReader) mpint(x *big.Int, typ *types.Type) {
base.Fatalf("weird decoding: %v, %v => %v", n, signed, v)
}
b := make([]byte, v)
p.Read(b)
r.Read(b)
x.SetBytes(b)
if signed && n&1 != 0 {
x.Neg(x)
}
}
func (p *importReader) float(typ *types.Type) constant.Value {
func (r *importReader) float(typ *types.Type) constant.Value {
var mant big.Int
p.mpint(&mant, typ)
r.mpint(&mant, typ)
var f big.Float
f.SetInt(&mant)
if f.Sign() != 0 {
f.SetMantExp(&f, int(p.int64()))
f.SetMantExp(&f, int(r.int64()))
}
return constant.Make(&f)
}
func (p *importReader) mprat(orig constant.Value) constant.Value {
if !p.bool() {
func (r *importReader) mprat(orig constant.Value) constant.Value {
if !r.bool() {
return orig
}
var rat big.Rat
rat.SetString(p.string())
rat.SetString(r.string())
return constant.Make(&rat)
}