]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: update callers to Linkline{fmt,hist} and remove
authorMatthew Dempsky <mdempsky@google.com>
Mon, 20 Apr 2015 20:32:40 +0000 (13:32 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 May 2015 17:45:39 +0000 (17:45 +0000)
Does the TODOs added by https://golang.org/cl/7623.

Passes rsc.io/toolstash/buildall.

Change-Id: I23913a8f03834640e9795d48318febb3f88c10f9
Reviewed-on: https://go-review.googlesource.com/9160
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/asm/internal/lex/input.go
src/cmd/asm/internal/lex/tokenizer.go
src/cmd/internal/asm/lexbody.go
src/cmd/internal/asm/macbody.go
src/cmd/internal/gc/lex.go
src/cmd/internal/gc/subr.go
src/cmd/internal/gc/util.go
src/cmd/internal/obj/line_test.go
src/cmd/internal/obj/obj.go
src/cmd/internal/obj/util.go

index 730042b14961cc71bf9620e4ac0e68e4c8c65dc6..7e495b8edf99552ffeeafb41c6d07cb5d2846e02 100644 (file)
@@ -13,7 +13,6 @@ import (
        "text/scanner"
 
        "cmd/asm/internal/flags"
-       "cmd/internal/obj"
 )
 
 // Input is the main input: a stack of readers and some macro definitions.
@@ -436,7 +435,7 @@ func (in *Input) line() {
        if tok != '\n' {
                in.Error("unexpected token at end of #line: ", tok)
        }
-       obj.Linklinehist(linkCtxt, histLine, file, line)
+       linkCtxt.LineHist.Update(histLine, file, line)
        in.Stack.SetPos(line, file)
 }
 
index 28a4b852534d440d2f211cbe6b8d7eb9c779bfed..6a4d95491f32fd5e521b22739ce717bc3df50a7c 100644 (file)
@@ -10,8 +10,6 @@ import (
        "strings"
        "text/scanner"
        "unicode"
-
-       "cmd/internal/obj"
 )
 
 // A Tokenizer is a simple wrapping of text/scanner.Scanner, configured
@@ -40,7 +38,7 @@ func NewTokenizer(name string, r io.Reader, file *os.File) *Tokenizer {
        s.Position.Filename = name
        s.IsIdentRune = isIdentRune
        if file != nil {
-               obj.Linklinehist(linkCtxt, histLine, name, 0)
+               linkCtxt.LineHist.Push(histLine, name)
        }
        return &Tokenizer{
                s:        &s,
@@ -149,6 +147,6 @@ func (t *Tokenizer) Close() {
        if t.file != nil {
                t.file.Close()
                // It's an open file, so pop the line history.
-               obj.Linklinehist(linkCtxt, histLine, "<pop>", 0)
+               linkCtxt.LineHist.Pop(histLine)
        }
 }
index b5e5d1eee24fba35530f4ebec6458b666aae6b3e..a1519c8566de962b92b60dd7e909dbfb365856f6 100644 (file)
@@ -149,7 +149,7 @@ func newfile(s string, f *os.File) {
        }
 
        fi.P = nil
-       obj.Linklinehist(Ctxt, int(Lineno), s, 0)
+       Ctxt.LineHist.Push(int(Lineno), s)
 }
 
 var thetext *obj.LSym
@@ -630,7 +630,7 @@ loop:
        n, _ = i.F.Read(i.B[:])
        if n == 0 {
                i.F.Close()
-               obj.Linklinehist(Ctxt, int(Lineno), "<pop>", 0)
+               Ctxt.LineHist.Pop(int(Lineno))
                goto pop
        }
        fi.P = i.B[1:n]
index c488ea1e56845d8888cec0786c5af0a2d252b0f8..4565d3a37f0c7d1f77599743896f9cb70fc7a77d 100644 (file)
@@ -32,7 +32,6 @@ package asm
 
 import (
        "bytes"
-       "cmd/internal/obj"
        "fmt"
        "os"
        "strings"
@@ -683,7 +682,7 @@ func maclin() {
        }
 
 nn:
-       obj.Linklinehist(Ctxt, int(Lineno), symb, int(n))
+       Ctxt.LineHist.Update(int(Lineno), symb, int(n))
        return
 
 bad:
@@ -796,7 +795,7 @@ func macprag() {
                /*
                 * put pragma-line in as a funny history
                 */
-               obj.Linklinehist(Ctxt, int(Lineno), symb, -1)
+               Ctxt.AddImport(symb)
                return
        }
        if s != nil && s.Name == "pack" {
index 9e2baec220331ef31639dfd358a5b4a633000269..92c079e1546c0087c150557c280b5d573271ff7b 100644 (file)
@@ -313,7 +313,7 @@ func Main() {
        lexlineno = 1
 
        for _, infile = range flag.Args() {
-               linehist(infile, 0, 0)
+               linehistpush(infile)
 
                curio.infile = infile
                var err error
@@ -344,7 +344,7 @@ func Main() {
                        errorexit()
                }
 
-               linehist("<pop>", 0, 0)
+               linehistpop()
                if curio.bin != nil {
                        obj.Bterm(curio.bin)
                }
@@ -763,7 +763,7 @@ func importfile(f *Val, line int) {
 
        // assume files move (get installed)
        // so don't record the full path.
-       linehist(file[len(file)-len(path_)-2:], -1, 1) // acts as #pragma lib
+       linehistpragma(file[len(file)-len(path_)-2:]) // acts as #pragma lib
 
        /*
         * position the input right
@@ -1654,7 +1654,7 @@ func getlinepragma() int {
        }
 
        name = text[:linep-1]
-       linehist(name, int32(n), 0)
+       linehistupdate(name, n)
        return c
 
 out:
index 74415be49acbc08202cc300f0b86b319f234f21e..33741c3baf514e472743210a68faa98b78c9ca20 100644 (file)
@@ -199,26 +199,32 @@ func Fatal(fmt_ string, args ...interface{}) {
        errorexit()
 }
 
-func linehist(file string, off int32, relative int) {
+func linehistpragma(file string) {
        if Debug['i'] != 0 {
-               if file != "" {
-                       if off < 0 {
-                               fmt.Printf("pragma %s", file)
-                       } else if off > 0 {
-                               fmt.Printf("line %s", file)
-                       } else {
-                               fmt.Printf("import %s", file)
-                       }
-               } else {
-                       fmt.Printf("end of import")
-               }
-               fmt.Printf(" at line %v\n", Ctxt.Line(int(lexlineno)))
+               fmt.Printf("pragma %s at line %v\n", file, Ctxt.Line(int(lexlineno)))
+       }
+       Ctxt.AddImport(file)
+}
+
+func linehistpush(file string) {
+       if Debug['i'] != 0 {
+               fmt.Printf("import %s at line %v\n", file, Ctxt.Line(int(lexlineno)))
        }
+       Ctxt.LineHist.Push(int(lexlineno), file)
+}
 
-       if off < 0 && file[0] != '/' && relative == 0 {
-               file = fmt.Sprintf("%s/%s", Ctxt.Pathname, file)
+func linehistpop() {
+       if Debug['i'] != 0 {
+               fmt.Printf("end of import at line %v\n", Ctxt.Line(int(lexlineno)))
+       }
+       Ctxt.LineHist.Pop(int(lexlineno))
+}
+
+func linehistupdate(file string, off int) {
+       if Debug['i'] != 0 {
+               fmt.Printf("line %s at line %v\n", file, Ctxt.Line(int(lexlineno)))
        }
-       obj.Linklinehist(Ctxt, int(lexlineno), file, int(off))
+       Ctxt.LineHist.Update(int(lexlineno), file, off)
 }
 
 func setlineno(n *Node) int32 {
@@ -2345,7 +2351,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
        lineno = lexlineno
        if genwrapper_linehistdone == 0 {
                // All the wrappers can share the same linehist entry.
-               linehist("<autogenerated>", 0, 0)
+               linehistpush("<autogenerated>")
 
                genwrapper_linehistdone = 1
        }
index 5dc6561b48c50053709e37a5e3ab349aa2ebe140..c59af0665b7d61bdf79d59388bd924b4c79d4733 100644 (file)
@@ -1,7 +1,6 @@
 package gc
 
 import (
-       "cmd/internal/obj"
        "os"
        "runtime"
        "runtime/pprof"
@@ -10,7 +9,7 @@ import (
 )
 
 func (n *Node) Line() string {
-       return obj.Linklinefmt(Ctxt, int(n.Lineno), false, false)
+       return Ctxt.LineHist.LineString(int(n.Lineno))
 }
 
 func atoi(s string) int {
index dde5d64e17bd6ddbe8defd9e12d6d2e263aa85e8..5486f0d6485e848136c7c6b1c67da638ecb3abc8 100644 (file)
@@ -13,13 +13,13 @@ func TestLineHist(t *testing.T) {
        ctxt := new(Link)
        ctxt.Hash = make(map[SymVer]*LSym)
 
-       Linklinehist(ctxt, 1, "a.c", 0)
-       Linklinehist(ctxt, 3, "a.h", 0)
-       Linklinehist(ctxt, 5, "<pop>", 0)
-       Linklinehist(ctxt, 7, "linedir", 2)
-       Linklinehist(ctxt, 9, "<pop>", 0)
-       Linklinehist(ctxt, 11, "b.c", 0)
-       Linklinehist(ctxt, 13, "<pop>", 0)
+       ctxt.LineHist.Push(1, "a.c")
+       ctxt.LineHist.Push(3, "a.h")
+       ctxt.LineHist.Pop(5)
+       ctxt.LineHist.Update(7, "linedir", 2)
+       ctxt.LineHist.Pop(9)
+       ctxt.LineHist.Push(11, "b.c")
+       ctxt.LineHist.Pop(13)
 
        var expect = []string{
                0:  "??:0",
index 39db2396e7d7355d7d48c874ae07de271518fdd5..af3290d3a599d0c19c54d1d83d297ae0afcc89d2 100644 (file)
@@ -241,12 +241,6 @@ func (h *LineHist) LineString(lineno int) string {
        return text
 }
 
-// TODO(rsc): Replace call sites with use of ctxt.LineHist.
-// Note that all call sites use showAll=false, showFullPath=false.
-func Linklinefmt(ctxt *Link, lineno int, showAll, showFullPath bool) string {
-       return ctxt.LineHist.LineString(lineno)
-}
-
 // FileLine returns the file name and line number
 // at the top of the stack for the given lineno.
 func (h *LineHist) FileLine(lineno int) (file string, line int) {
@@ -287,30 +281,3 @@ func linkgetline(ctxt *Link, lineno int32, f **LSym, l *int32) {
 func Linkprfile(ctxt *Link, line int) {
        fmt.Printf("%s ", ctxt.LineHist.LineString(line))
 }
-
-// Linklinehist pushes, amends, or pops an entry on the line history stack.
-// If f != "<pop>" and n == 0, the call pushes the start of a new file named f at lineno.
-// If f != "<pop>" and n > 0, the call amends the top of the stack to record that lineno
-// now corresponds to f at line n.
-// If f == "<pop>", the call pops the topmost entry from the stack, picking up
-// the parent file at the line following the one where the corresponding push occurred.
-//
-// If n < 0, linklinehist records f as a package required by the current compilation
-// (nothing to do with line numbers).
-//
-// TODO(rsc): Replace uses with direct calls to ctxt.Hist methods.
-func Linklinehist(ctxt *Link, lineno int, f string, n int) {
-       switch {
-       case n < 0:
-               ctxt.AddImport(f)
-
-       case f == "<pop>":
-               ctxt.LineHist.Pop(lineno)
-
-       case n == 0:
-               ctxt.LineHist.Push(lineno, f)
-
-       default:
-               ctxt.LineHist.Update(lineno, f, n)
-       }
-}
index ac49543fdf586e517f71346bf184e12d5e38f3cd..317ee4f14da7896675e6b0ddb2e08f553568c0e1 100644 (file)
@@ -241,7 +241,7 @@ func Atoi(s string) int {
 }
 
 func (p *Prog) Line() string {
-       return Linklinefmt(p.Ctxt, int(p.Lineno), false, false)
+       return p.Ctxt.LineHist.LineString(int(p.Lineno))
 }
 
 var armCondCode = []string{
@@ -340,7 +340,7 @@ func (ctxt *Link) NewProg() *Prog {
 }
 
 func (ctxt *Link) Line(n int) string {
-       return Linklinefmt(ctxt, n, false, false)
+       return ctxt.LineHist.LineString(n)
 }
 
 func Getcallerpc(interface{}) uintptr {