mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
[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:
parent
5dcb5e2cea
commit
6dadee759c
|
@ -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 kind constant.Kind
|
||||||
var valType *types.Type
|
var valType *types.Type
|
||||||
|
|
||||||
if typ.IsTypeParam() {
|
if typ.IsTypeParam() {
|
||||||
// If a constant had a typeparam type, then we wrote out its
|
// If a constant had a typeparam type, then we wrote out its
|
||||||
// actual constant kind as well.
|
// actual constant kind as well.
|
||||||
kind = constant.Kind(p.int64())
|
kind = constant.Kind(r.int64())
|
||||||
switch kind {
|
switch kind {
|
||||||
case constant.Int:
|
case constant.Int:
|
||||||
valType = types.Types[types.TINT64]
|
valType = types.Types[types.TINT64]
|
||||||
|
@ -435,24 +435,24 @@ func (p *importReader) value(typ *types.Type) constant.Value {
|
||||||
|
|
||||||
switch kind {
|
switch kind {
|
||||||
case constant.Bool:
|
case constant.Bool:
|
||||||
return constant.MakeBool(p.bool())
|
return constant.MakeBool(r.bool())
|
||||||
case constant.String:
|
case constant.String:
|
||||||
return constant.MakeString(p.string())
|
return constant.MakeString(r.string())
|
||||||
case constant.Int:
|
case constant.Int:
|
||||||
var i big.Int
|
var i big.Int
|
||||||
p.mpint(&i, valType)
|
r.mpint(&i, valType)
|
||||||
return constant.Make(&i)
|
return constant.Make(&i)
|
||||||
case constant.Float:
|
case constant.Float:
|
||||||
return p.float(valType)
|
return r.float(valType)
|
||||||
case constant.Complex:
|
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)
|
base.Fatalf("unexpected value type: %v", typ)
|
||||||
panic("unreachable")
|
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)
|
signed, maxBytes := intSize(typ)
|
||||||
|
|
||||||
maxSmall := 256 - maxBytes
|
maxSmall := 256 - maxBytes
|
||||||
|
@ -463,7 +463,7 @@ func (p *importReader) mpint(x *big.Int, typ *types.Type) {
|
||||||
maxSmall = 256
|
maxSmall = 256
|
||||||
}
|
}
|
||||||
|
|
||||||
n, _ := p.ReadByte()
|
n, _ := r.ReadByte()
|
||||||
if uint(n) < maxSmall {
|
if uint(n) < maxSmall {
|
||||||
v := int64(n)
|
v := int64(n)
|
||||||
if signed {
|
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)
|
base.Fatalf("weird decoding: %v, %v => %v", n, signed, v)
|
||||||
}
|
}
|
||||||
b := make([]byte, v)
|
b := make([]byte, v)
|
||||||
p.Read(b)
|
r.Read(b)
|
||||||
x.SetBytes(b)
|
x.SetBytes(b)
|
||||||
if signed && n&1 != 0 {
|
if signed && n&1 != 0 {
|
||||||
x.Neg(x)
|
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
|
var mant big.Int
|
||||||
p.mpint(&mant, typ)
|
r.mpint(&mant, typ)
|
||||||
var f big.Float
|
var f big.Float
|
||||||
f.SetInt(&mant)
|
f.SetInt(&mant)
|
||||||
if f.Sign() != 0 {
|
if f.Sign() != 0 {
|
||||||
f.SetMantExp(&f, int(p.int64()))
|
f.SetMantExp(&f, int(r.int64()))
|
||||||
}
|
}
|
||||||
return constant.Make(&f)
|
return constant.Make(&f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *importReader) mprat(orig constant.Value) constant.Value {
|
func (r *importReader) mprat(orig constant.Value) constant.Value {
|
||||||
if !p.bool() {
|
if !r.bool() {
|
||||||
return orig
|
return orig
|
||||||
}
|
}
|
||||||
var rat big.Rat
|
var rat big.Rat
|
||||||
rat.SetString(p.string())
|
rat.SetString(r.string())
|
||||||
return constant.Make(&rat)
|
return constant.Make(&rat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue