cmd/internal/gc: delete Strlit, Zconv
Strlit was just a poor excuse for a Go string.
Use a Go string.
In the one case where it was a string-or-nil (Type.Note), use a *string.
Zconv was a poor excuse for %q. Use %q.
The only important part about Zconv's implementation
was that the compiler and linker agreed on the quoting rules.
Now they both use %q instead of having two Zconvs.
This CL *does* change the generated object files, because the
quoted strings end up in symbol names.
For example the string "\r\n" used to be named go.string."\r\n"
and is now go.string."\x0d\n".
Change-Id: I5c0d38e1570ffc495f0db1a20273c9564104a7e8
Reviewed-on: https://go-review.googlesource.com/6519
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/src/cmd/internal/gc/dcl.go b/src/cmd/internal/gc/dcl.go
index 97271ba..8ea5d8d 100644
--- a/src/cmd/internal/gc/dcl.go
+++ b/src/cmd/internal/gc/dcl.go
@@ -132,14 +132,14 @@
func redeclare(s *Sym, where string) {
if s.Lastlineno == 0 {
- var tmp *Strlit
+ var tmp string
if s.Origpkg != nil {
tmp = s.Origpkg.Path
} else {
tmp = s.Pkg.Path
}
pkgstr := tmp
- Yyerror("%v redeclared %s\n"+"\tprevious declaration during import \"%v\"", Sconv(s, 0), where, Zconv(pkgstr, 0))
+ Yyerror("%v redeclared %s\n"+"\tprevious declaration during import %q", Sconv(s, 0), where, pkgstr)
} else {
line1 := parserline()
line2 := int(s.Lastlineno)
@@ -823,7 +823,8 @@
switch n.Val.Ctype {
case CTSTR:
- f.Note = n.Val.U.Sval
+ f.Note = new(string)
+ *f.Note = n.Val.U.Sval
default:
Yyerror("field annotation must be string")
@@ -1284,7 +1285,7 @@
if spkg == nil {
if methodsym_toppkg == nil {
- methodsym_toppkg = mkpkg(newstrlit("go"))
+ methodsym_toppkg = mkpkg("go")
}
spkg = methodsym_toppkg
}