OLD | NEW |
| (Empty) |
1 // Copyright 2009 The Go Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style | |
3 // license that can be found in the LICENSE file. | |
4 | |
5 #include <u.h> | |
6 #include <libc.h> | |
7 #include <bio.h> | |
8 | |
9 enum | |
10 { | |
11 Void = 1, | |
12 Int8, | |
13 Uint8, | |
14 Int16, | |
15 Uint16, | |
16 Int32, | |
17 Uint32, | |
18 Int64, | |
19 Uint64, | |
20 Float32, | |
21 Float64, | |
22 Ptr, | |
23 Struct, | |
24 Array, | |
25 Union, | |
26 Typedef, | |
27 }; | |
28 | |
29 typedef struct Field Field; | |
30 typedef struct Type Type; | |
31 | |
32 struct Type | |
33 { | |
34 Type *next; // next in hash table | |
35 | |
36 // stabs name and two-integer id | |
37 char *name; | |
38 int n1; | |
39 int n2; | |
40 | |
41 // int kind | |
42 int kind; | |
43 | |
44 // sub-type for ptr, array | |
45 Type *type; | |
46 | |
47 // struct fields | |
48 Field *f; | |
49 int nf; | |
50 int size; | |
51 | |
52 int saved; // recorded in typ array | |
53 int warned; // warned about needing type | |
54 int printed; // has the definition been printed yet? | |
55 }; | |
56 | |
57 struct Field | |
58 { | |
59 char *name; | |
60 Type *type; | |
61 int offset; | |
62 int size; | |
63 }; | |
64 | |
65 // Constants | |
66 typedef struct Const Const; | |
67 struct Const | |
68 { | |
69 char *name; | |
70 vlong value; | |
71 }; | |
72 | |
73 // Recorded constants and types, to be printed. | |
74 extern Const *con; | |
75 extern int ncon; | |
76 extern Type **typ; | |
77 extern int ntyp; | |
78 extern int kindsize[]; | |
79 | |
80 // Language output | |
81 typedef struct Lang Lang; | |
82 struct Lang | |
83 { | |
84 char *constbegin; | |
85 char *constfmt; | |
86 char *constend; | |
87 | |
88 char *typdef; | |
89 char *typdefend; | |
90 | |
91 char *structbegin; | |
92 char *unionbegin; | |
93 char *structpadfmt; | |
94 char *structend; | |
95 | |
96 int (*typefmt)(Fmt*); | |
97 }; | |
98 | |
99 extern Lang go, c; | |
100 | |
101 void* emalloc(int); | |
102 char* estrdup(char*); | |
103 void* erealloc(void*, int); | |
104 void parsestabtype(char*); | |
OLD | NEW |