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 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Portable half of code generator; mainly statements and control flow.
package gc package gc
import ( import (
...@@ -9,11 +11,8 @@ import ( ...@@ -9,11 +11,8 @@ import (
"fmt" "fmt"
) )
// portable half of code generator. // TODO: labellist should become part of a "compilation state" for functions.
// mainly statements and control flow. var labellist []*Label
var labellist *Label
var lastlabel *Label
func Sysfunc(name string) *Node { func Sysfunc(name string) *Node {
n := newname(Pkglookup(name, Runtimepkg)) n := newname(Pkglookup(name, Runtimepkg))
...@@ -106,12 +105,10 @@ func addrescapes(n *Node) { ...@@ -106,12 +105,10 @@ func addrescapes(n *Node) {
} }
func clearlabels() { func clearlabels() {
for l := labellist; l != nil; l = l.Link { for _, l := range labellist {
l.Sym.Label = nil l.Sym.Label = nil
} }
labellist = labellist[:0]
labellist = nil
lastlabel = nil
} }
func newlab(n *Node) *Label { func newlab(n *Node) *Label {
...@@ -119,14 +116,9 @@ func newlab(n *Node) *Label { ...@@ -119,14 +116,9 @@ func newlab(n *Node) *Label {
lab := s.Label lab := s.Label
if lab == nil { if lab == nil {
lab = new(Label) lab = new(Label)
if lastlabel == nil {
labellist = lab
} else {
lastlabel.Link = lab
}
lastlabel = lab
lab.Sym = s lab.Sym = s
s.Label = lab s.Label = lab
labellist = append(labellist, lab)
} }
if n.Op == OLABEL { if n.Op == OLABEL {
...@@ -974,7 +966,7 @@ func CgenTemp(n *Node) *Node { ...@@ -974,7 +966,7 @@ func CgenTemp(n *Node) *Node {
} }
func checklabels() { func checklabels() {
for lab := labellist; lab != nil; lab = lab.Link { for _, lab := range labellist {
if lab.Def == nil { if lab.Def == nil {
for _, n := range lab.Use { for _, n := range lab.Use {
yyerrorl(n.Lineno, "label %v not defined", lab.Sym) yyerrorl(n.Lineno, "label %v not defined", lab.Sym)
......
...@@ -86,10 +86,9 @@ type Sym struct { ...@@ -86,10 +86,9 @@ type Sym struct {
} }
type Label struct { type Label struct {
Sym *Sym Sym *Sym
Def *Node Def *Node
Use []*Node Use []*Node
Link *Label
// for use during gen // for use during gen
Gotopc *obj.Prog // pointer to unresolved gotos 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