mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: replace Ctype switches with type switches
Instead of switching on Ctype (which internally uses a type switch) and then scattering lots of type assertions throughout the CTFOO case clauses, just use type switches directly on the underlying constant value. Passes toolstash/buildall. Change-Id: I9bc172cc67e5f391cddc15539907883b4010689e Reviewed-on: https://go-review.googlesource.com/22384 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
2d342fba78
commit
97360096e5
9 changed files with 146 additions and 168 deletions
|
|
@ -430,28 +430,28 @@ func Naddr(a *obj.Addr, n *Node) {
|
|||
if Thearch.LinkArch.Family == sys.I386 {
|
||||
a.Width = 0
|
||||
}
|
||||
switch n.Val().Ctype() {
|
||||
switch u := n.Val().U.(type) {
|
||||
default:
|
||||
Fatalf("naddr: const %v", Tconv(n.Type, FmtLong))
|
||||
|
||||
case CTFLT:
|
||||
case *Mpflt:
|
||||
a.Type = obj.TYPE_FCONST
|
||||
a.Val = n.Val().U.(*Mpflt).Float64()
|
||||
a.Val = u.Float64()
|
||||
|
||||
case CTINT, CTRUNE:
|
||||
case *Mpint:
|
||||
a.Sym = nil
|
||||
a.Type = obj.TYPE_CONST
|
||||
a.Offset = n.Int64()
|
||||
a.Offset = u.Int64()
|
||||
|
||||
case CTSTR:
|
||||
datagostring(n.Val().U.(string), a)
|
||||
case string:
|
||||
datagostring(u, a)
|
||||
|
||||
case CTBOOL:
|
||||
case bool:
|
||||
a.Sym = nil
|
||||
a.Type = obj.TYPE_CONST
|
||||
a.Offset = int64(obj.Bool2int(n.Val().U.(bool)))
|
||||
a.Offset = int64(obj.Bool2int(u))
|
||||
|
||||
case CTNIL:
|
||||
case *NilVal:
|
||||
a.Sym = nil
|
||||
a.Type = obj.TYPE_CONST
|
||||
a.Offset = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue