OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |