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/walk.go b/src/cmd/internal/gc/walk.go
index 22f1ea7..ed46809 100644
--- a/src/cmd/internal/gc/walk.go
+++ b/src/cmd/internal/gc/walk.go
@@ -1154,7 +1154,7 @@
Yyerror("index out of bounds")
}
} else if Isconst(n.Left, CTSTR) {
- n.Bounded = bounded(r, int64(len(n.Left.Val.U.Sval.S)))
+ n.Bounded = bounded(r, int64(len(n.Left.Val.U.Sval)))
if Debug['m'] != 0 && n.Bounded && !Isconst(n.Right, CTINT) {
Warn("index bounds check elided")
}
@@ -1167,7 +1167,7 @@
// an ideal constant.
v := Mpgetfix(n.Right.Val.U.Xval)
- Nodconst(n, n.Type, int64(n.Left.Val.U.Sval.S[v]))
+ Nodconst(n, n.Type, int64(n.Left.Val.U.Sval[v]))
n.Typecheck = 1
}
}
@@ -1308,7 +1308,7 @@
// comparing the lengths instead will yield the same result
// without the function call.
case OCMPSTR:
- if (Isconst(n.Left, CTSTR) && len(n.Left.Val.U.Sval.S) == 0) || (Isconst(n.Right, CTSTR) && len(n.Right.Val.U.Sval.S) == 0) {
+ if (Isconst(n.Left, CTSTR) && len(n.Left.Val.U.Sval) == 0) || (Isconst(n.Right, CTSTR) && len(n.Right.Val.U.Sval) == 0) {
r := Nod(int(n.Etype), Nod(OLEN, n.Left, nil), Nod(OLEN, n.Right, nil))
typecheck(&r, Erv)
walkexpr(&r, init)
@@ -2862,7 +2862,7 @@
sz := int64(0)
for l := n.List; l != nil; l = l.Next {
if n.Op == OLITERAL {
- sz += int64(len(n.Val.U.Sval.S))
+ sz += int64(len(n.Val.U.Sval))
}
}
@@ -4100,7 +4100,7 @@
if field == nil {
Fatal("usefield %v %v without paramfld", Tconv(n.Left.Type, 0), Sconv(n.Right.Sym, 0))
}
- if field.Note == nil || !strings.Contains(field.Note.S, "go:\"track\"") {
+ if field.Note == nil || !strings.Contains(*field.Note, "go:\"track\"") {
return
}