mirror of
https://github.com/golang/go
synced 2024-11-19 11:44:45 -07:00
cmd/compile: remove Label.Link field and lastlabel global var
Change-Id: If2a174f482ecd56dee43f921d13fef98439872fc Reviewed-on: https://go-review.googlesource.com/20559 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
637e1aad5c
commit
def9c0b06d
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Portable half of code generator; mainly statements and control flow.
|
||||
|
||||
package gc
|
||||
|
||||
import (
|
||||
@ -9,11 +11,8 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// portable half of code generator.
|
||||
// mainly statements and control flow.
|
||||
var labellist *Label
|
||||
|
||||
var lastlabel *Label
|
||||
// TODO: labellist should become part of a "compilation state" for functions.
|
||||
var labellist []*Label
|
||||
|
||||
func Sysfunc(name string) *Node {
|
||||
n := newname(Pkglookup(name, Runtimepkg))
|
||||
@ -106,12 +105,10 @@ func addrescapes(n *Node) {
|
||||
}
|
||||
|
||||
func clearlabels() {
|
||||
for l := labellist; l != nil; l = l.Link {
|
||||
for _, l := range labellist {
|
||||
l.Sym.Label = nil
|
||||
}
|
||||
|
||||
labellist = nil
|
||||
lastlabel = nil
|
||||
labellist = labellist[:0]
|
||||
}
|
||||
|
||||
func newlab(n *Node) *Label {
|
||||
@ -119,14 +116,9 @@ func newlab(n *Node) *Label {
|
||||
lab := s.Label
|
||||
if lab == nil {
|
||||
lab = new(Label)
|
||||
if lastlabel == nil {
|
||||
labellist = lab
|
||||
} else {
|
||||
lastlabel.Link = lab
|
||||
}
|
||||
lastlabel = lab
|
||||
lab.Sym = s
|
||||
s.Label = lab
|
||||
labellist = append(labellist, lab)
|
||||
}
|
||||
|
||||
if n.Op == OLABEL {
|
||||
@ -974,7 +966,7 @@ func CgenTemp(n *Node) *Node {
|
||||
}
|
||||
|
||||
func checklabels() {
|
||||
for lab := labellist; lab != nil; lab = lab.Link {
|
||||
for _, lab := range labellist {
|
||||
if lab.Def == nil {
|
||||
for _, n := range lab.Use {
|
||||
yyerrorl(n.Lineno, "label %v not defined", lab.Sym)
|
||||
|
@ -86,10 +86,9 @@ type Sym struct {
|
||||
}
|
||||
|
||||
type Label struct {
|
||||
Sym *Sym
|
||||
Def *Node
|
||||
Use []*Node
|
||||
Link *Label
|
||||
Sym *Sym
|
||||
Def *Node
|
||||
Use []*Node
|
||||
|
||||
// for use during gen
|
||||
Gotopc *obj.Prog // pointer to unresolved gotos
|
||||
|
Loading…
Reference in New Issue
Block a user