Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(655)

Side by Side Diff: src/cmd/cgo/gcc.go

Issue 4291070: code review 4291070: go/scanner: return literal as string instead of []byte (Closed)
Patch Set: diff -r 4073ecdfc054 https://go.googlecode.com/hg/ Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/cmd/godoc/spec.go » ('j') | src/cmd/govet/govet.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Annotate Ref in Prog with C types by parsing gcc debug output. 5 // Annotate Ref in Prog with C types by parsing gcc debug output.
6 // Conversion of debug output to Go types. 6 // Conversion of debug output to Go types.
7 7
8 package main 8 package main
9 9
10 import ( 10 import (
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 return &ast.ArrayType{ 1149 return &ast.ArrayType{
1150 Len: c.intExpr(n), 1150 Len: c.intExpr(n),
1151 Elt: c.byte, 1151 Elt: c.byte,
1152 } 1152 }
1153 } 1153 }
1154 1154
1155 // Expr for integer n. 1155 // Expr for integer n.
1156 func (c *typeConv) intExpr(n int64) ast.Expr { 1156 func (c *typeConv) intExpr(n int64) ast.Expr {
1157 return &ast.BasicLit{ 1157 return &ast.BasicLit{
1158 Kind: token.INT, 1158 Kind: token.INT,
1159 » » Value: []byte(strconv.Itoa64(n)), 1159 » » Value: strconv.Itoa64(n),
1160 } 1160 }
1161 } 1161 }
1162 1162
1163 // Add padding of given size to fld. 1163 // Add padding of given size to fld.
1164 func (c *typeConv) pad(fld []*ast.Field, size int64) []*ast.Field { 1164 func (c *typeConv) pad(fld []*ast.Field, size int64) []*ast.Field {
1165 n := len(fld) 1165 n := len(fld)
1166 fld = fld[0 : n+1] 1166 fld = fld[0 : n+1]
1167 fld[n] = &ast.Field{Names: []*ast.Ident{c.Ident("_")}, Type: c.Opaque(si ze)} 1167 fld[n] = &ast.Field{Names: []*ast.Ident{c.Ident("_")}, Type: c.Opaque(si ze)}
1168 return fld 1168 return fld
1169 } 1169 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 off = dt.ByteSize 1229 off = dt.ByteSize
1230 } 1230 }
1231 if off != dt.ByteSize { 1231 if off != dt.ByteSize {
1232 fatal("struct size calculation error") 1232 fatal("struct size calculation error")
1233 } 1233 }
1234 buf.WriteString("}") 1234 buf.WriteString("}")
1235 csyntax = buf.String() 1235 csyntax = buf.String()
1236 expr = &ast.StructType{Fields: &ast.FieldList{List: fld}} 1236 expr = &ast.StructType{Fields: &ast.FieldList{List: fld}}
1237 return 1237 return
1238 } 1238 }
OLDNEW
« no previous file with comments | « no previous file | src/cmd/godoc/spec.go » ('j') | src/cmd/govet/govet.go » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b