Commit def9c0b0 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: remove Label.Link field and lastlabel global var

Change-Id: If2a174f482ecd56dee43f921d13fef98439872fc
Reviewed-on: https://go-review.googlesource.com/20559Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 637e1aad
......@@ -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)
......
......@@ -89,7 +89,6 @@ type Label struct {
Sym *Sym
Def *Node
Use []*Node
Link *Label
// for use during gen
Gotopc *obj.Prog // pointer to unresolved gotos
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment