mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
4bbd7ae8e0
commit
bed1f90d08
22 changed files with 179 additions and 289 deletions
|
|
@ -217,9 +217,9 @@ type EscState struct {
|
|||
recursive bool
|
||||
}
|
||||
|
||||
var tags [16]*Strlit
|
||||
var tags [16]*string
|
||||
|
||||
func mktag(mask int) *Strlit {
|
||||
func mktag(mask int) *string {
|
||||
switch mask & EscMask {
|
||||
case EscNone,
|
||||
EscReturn:
|
||||
|
|
@ -235,22 +235,18 @@ func mktag(mask int) *Strlit {
|
|||
return tags[mask]
|
||||
}
|
||||
|
||||
buf := fmt.Sprintf("esc:0x%x", mask)
|
||||
s := newstrlit(buf)
|
||||
s := fmt.Sprintf("esc:0x%x", mask)
|
||||
if mask < len(tags) {
|
||||
tags[mask] = s
|
||||
tags[mask] = &s
|
||||
}
|
||||
return s
|
||||
return &s
|
||||
}
|
||||
|
||||
func parsetag(note *Strlit) int {
|
||||
if note == nil {
|
||||
func parsetag(note *string) int {
|
||||
if note == nil || !strings.HasPrefix(*note, "esc:") {
|
||||
return EscUnknown
|
||||
}
|
||||
if !strings.HasPrefix(note.S, "esc:") {
|
||||
return EscUnknown
|
||||
}
|
||||
em := atoi(note.S[4:])
|
||||
em := atoi((*note)[4:])
|
||||
if em == 0 {
|
||||
return EscNone
|
||||
}
|
||||
|
|
@ -941,7 +937,7 @@ func escassign(e *EscState, dst *Node, src *Node) {
|
|||
lineno = int32(lno)
|
||||
}
|
||||
|
||||
func escassignfromtag(e *EscState, note *Strlit, dsts *NodeList, src *Node) int {
|
||||
func escassignfromtag(e *EscState, note *string, dsts *NodeList, src *Node) int {
|
||||
var em int
|
||||
|
||||
em = parsetag(note)
|
||||
|
|
@ -969,7 +965,7 @@ func escassignfromtag(e *EscState, note *Strlit, dsts *NodeList, src *Node) int
|
|||
}
|
||||
|
||||
if em != 0 && dsts == nil {
|
||||
Fatal("corrupt esc tag %v or messed up escretval list\n", Zconv(note, 0))
|
||||
Fatal("corrupt esc tag %q or messed up escretval list\n", note)
|
||||
}
|
||||
return em0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue