]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: move compiler-specific flags into compiler-spec. export data section
authorRobert Griesemer <gri@golang.org>
Tue, 12 Apr 2016 18:31:16 +0000 (11:31 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 12 Apr 2016 18:57:51 +0000 (18:57 +0000)
Also: Adjust go/importer accordingly.

Change-Id: Ia6669563793e218946af45b9fba1cf986a21c031
Reviewed-on: https://go-review.googlesource.com/21896
Reviewed-by: Alan Donovan <adonovan@google.com>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/bimport.go
src/go/internal/gcimporter/bimport.go

index 15e5e3ada600be68fb06c53eb08c75bda109e698..cb438d7573f081b2b6dddcf53a44892a547d45b2 100644 (file)
@@ -182,22 +182,12 @@ func export(out *bufio.Writer, trace bool) int {
                Fatalf("exporter: local package path not empty: %q", localpkg.Path)
        }
        p.pkg(localpkg)
-
-       // write compiler-specific flags
-       // TODO(gri) move this into the compiler-specific export data section
-       {
-               var flags string
-               if safemode != 0 {
-                       flags = "safe"
-               }
-               p.string(flags)
-       }
        if p.trace {
                p.tracef("\n")
        }
 
        // export objects
-
+       //
        // First, export all exported (package-level) objects; i.e., all objects
        // in the current exportlist. These objects represent all information
        // required to import this package and type-check against it; i.e., this
@@ -270,6 +260,12 @@ func export(out *bufio.Writer, trace bool) int {
                }
        }
 
+       // write compiler-specific flags
+       p.bool(safemode != 0)
+       if p.trace {
+               p.tracef("\n")
+       }
+
        // Phase 2: Export objects added to exportlist during phase 1.
        // Don't use range since exportlist may grow during this phase
        // and we want to export all remaining objects.
index 7ad4d9dbb01fa2c2d7e159e845563501d2282f7b..9cebafcaefb40f6e738df14edbc28072a2d0fd9a 100644 (file)
@@ -62,9 +62,6 @@ func Import(in *bufio.Reader) {
                Fatalf("importer: imported package not found in pkgList[0]")
        }
 
-       // read compiler-specific flags
-       importpkg.Safe = p.string() == "safe"
-
        // defer some type-checking until all types are read in completely
        // (parser.go:import_package)
        tcok := typecheckok
@@ -73,7 +70,7 @@ func Import(in *bufio.Reader) {
 
        // read objects
 
-       // Phase 1
+       // phase 1
        objcount := 0
        for {
                tag := p.tagOrIndex()
@@ -91,7 +88,10 @@ func Import(in *bufio.Reader) {
 
        // --- compiler-specific export data ---
 
-       // Phase 2
+       // read compiler-specific flags
+       importpkg.Safe = p.bool()
+
+       // phase 2
        objcount = 0
        for {
                tag := p.tagOrIndex()
@@ -264,7 +264,7 @@ func (p *importer) obj(tag int) {
                }
 
        default:
-               Fatalf("importer: unexpected object tag")
+               Fatalf("importer: unexpected object (tag = %d)", tag)
        }
 }
 
index aa9569de52582478326edcabcb22853a28b9ea0b..a9d678b0216aed1498fc18eefb8256872b47f9c7 100644 (file)
@@ -78,9 +78,6 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i
                panic("imported packaged not found in pkgList[0]")
        }
 
-       // read compiler-specific flags
-       p.string() // discard
-
        // read objects of phase 1 only (see cmd/compiler/internal/gc/bexport.go)
        objcount := 0
        for {
@@ -193,7 +190,7 @@ func (p *importer) obj(tag int) {
                p.declare(types.NewFunc(token.NoPos, pkg, name, sig))
 
        default:
-               panic("unexpected object tag")
+               panic(fmt.Sprintf("unexpected object tag %d", tag))
        }
 }