From 371aa23d104237fe72d84618210c5d61da8019aa Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 29 Mar 2017 21:00:55 -0700 Subject: [PATCH] cmd/compile: convert Type.Trecur to a boolean flag Change-Id: I162e86e5f92c8b827a74ee860d16abadf83bc43e Reviewed-on: https://go-review.googlesource.com/38910 Run-TryBot: Josh Bleecher Snyder Reviewed-by: Brad Fitzpatrick --- src/cmd/compile/internal/gc/subr.go | 12 ++++++------ src/cmd/compile/internal/gc/type.go | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index f6690e0f1b..96f97cec24 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -1426,10 +1426,10 @@ func lookdot0(s *Sym, t *Type, save **Field, ignorecase bool) int { // embedded fields at depth d, so callers can decide whether to retry at // a greater depth. func adddot1(s *Sym, t *Type, d int, save **Field, ignorecase bool) (c int, more bool) { - if t.Trecur != 0 { + if t.Recur() { return } - t.Trecur = 1 + t.SetRecur(true) var u *Type d-- @@ -1471,7 +1471,7 @@ func adddot1(s *Sym, t *Type, d int, save **Field, ignorecase bool) (c int, more } out: - t.Trecur = 0 + t.SetRecur(false) return c, more } @@ -1585,10 +1585,10 @@ func expand0(t *Type, followptr bool) { } func expand1(t *Type, top, followptr bool) { - if t.Trecur != 0 { + if t.Recur() { return } - t.Trecur = 1 + t.SetRecur(true) if !top { expand0(t, followptr) @@ -1615,7 +1615,7 @@ func expand1(t *Type, top, followptr bool) { } out: - t.Trecur = 0 + t.SetRecur(false) } func expandmeth(t *Type) { diff --git a/src/cmd/compile/internal/gc/type.go b/src/cmd/compile/internal/gc/type.go index 7f4796d60c..74285e5d3b 100644 --- a/src/cmd/compile/internal/gc/type.go +++ b/src/cmd/compile/internal/gc/type.go @@ -153,9 +153,8 @@ type Type struct { Sym *Sym // symbol containing name, for named types Vargen int32 // unique name for OTYPE/ONAME - Etype EType // kind of type - Trecur uint8 // to detect loops - Align uint8 // the required alignment of this type, in bytes + Etype EType // kind of type + Align uint8 // the required alignment of this type, in bytes flags bitset8 } @@ -166,6 +165,7 @@ const ( typeBroke // broken type definition typeNoalg // suppress hash and eq algorithm generation typeDeferwidth + typeRecur ) func (t *Type) Local() bool { return t.flags&typeLocal != 0 } @@ -173,12 +173,14 @@ func (t *Type) NotInHeap() bool { return t.flags&typeNotInHeap != 0 } func (t *Type) Broke() bool { return t.flags&typeBroke != 0 } func (t *Type) Noalg() bool { return t.flags&typeNoalg != 0 } func (t *Type) Deferwidth() bool { return t.flags&typeDeferwidth != 0 } +func (t *Type) Recur() bool { return t.flags&typeRecur != 0 } func (t *Type) SetLocal(b bool) { t.flags.set(typeLocal, b) } func (t *Type) SetNotInHeap(b bool) { t.flags.set(typeNotInHeap, b) } func (t *Type) SetBroke(b bool) { t.flags.set(typeBroke, b) } func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) } func (t *Type) SetDeferwidth(b bool) { t.flags.set(typeDeferwidth, b) } +func (t *Type) SetRecur(b bool) { t.flags.set(typeRecur, b) } // MapType contains Type fields specific to maps. type MapType struct {