st_parse.c (178529) | st_parse.c (178546) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 62 unchanged lines hidden (view full) --- 71static char *id(char *cp, int *h); 72static char *whitesp(char *cp); 73static void addhash(tdesc_t *tdp, int num); 74static int tagadd(char *w, int h, tdesc_t *tdp); 75static char *tdefdecl(char *cp, int h, tdesc_t **rtdp); 76static char *intrinsic(char *cp, tdesc_t **rtdp); 77static char *arraydef(char *cp, tdesc_t **rtdp); 78 | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 62 unchanged lines hidden (view full) --- 71static char *id(char *cp, int *h); 72static char *whitesp(char *cp); 73static void addhash(tdesc_t *tdp, int num); 74static int tagadd(char *w, int h, tdesc_t *tdp); 75static char *tdefdecl(char *cp, int h, tdesc_t **rtdp); 76static char *intrinsic(char *cp, tdesc_t **rtdp); 77static char *arraydef(char *cp, tdesc_t **rtdp); 78 |
79extern int debug_level; | |
80int debug_parse = DEBUG_PARSE; 81 82/*PRINTFLIKE3*/ 83static void | 79int debug_parse = DEBUG_PARSE; 80 81/*PRINTFLIKE3*/ 82static void |
84parse_debug(int level, char *cp, char *fmt, ...) | 83parse_debug(int level, char *cp, const char *fmt, ...) |
85{ 86 va_list ap; 87 char buf[1024]; 88 char tmp[32]; 89 int i; 90 91 if (level > debug_level || !debug_parse) 92 return; --- 15 unchanged lines hidden (view full) --- 108 va_start(ap, fmt); 109 vadebug(level, buf, ap); 110 va_end(ap); 111} 112 113/* Report unexpected syntax in stabs. */ 114static void 115_expected( | 84{ 85 va_list ap; 86 char buf[1024]; 87 char tmp[32]; 88 int i; 89 90 if (level > debug_level || !debug_parse) 91 return; --- 15 unchanged lines hidden (view full) --- 107 va_start(ap, fmt); 108 vadebug(level, buf, ap); 109 va_end(ap); 110} 111 112/* Report unexpected syntax in stabs. */ 113static void 114_expected( |
116 char *who, /* what function, or part thereof, is reporting */ 117 char *what, /* what was expected */ 118 char *where, /* where we were in the line of input */ | 115 const char *who, /* what function, or part thereof, is reporting */ 116 const char *what, /* what was expected */ 117 const char *where, /* where we were in the line of input */ |
119 int line) 120{ 121 fprintf(stderr, "%s, expecting \"%s\" at \"%s\"\n", who, what, where); 122 fprintf(stderr, "code line: %d, file %s\n", line, 123 (curhdr ? curhdr : "NO FILE")); 124 reset(); 125} 126 127/*ARGSUSED*/ 128void | 118 int line) 119{ 120 fprintf(stderr, "%s, expecting \"%s\" at \"%s\"\n", who, what, where); 121 fprintf(stderr, "code line: %d, file %s\n", line, 122 (curhdr ? curhdr : "NO FILE")); 123 reset(); 124} 125 126/*ARGSUSED*/ 127void |
129parse_init(tdata_t *td) | 128parse_init(tdata_t *td __unused) |
130{ 131 int i; 132 133 for (i = 0; i < BUCKETS; i++) { 134 hash_table[i] = NULL; 135 name_table[i] = NULL; 136 } 137 --- 16 unchanged lines hidden (view full) --- 154 155 tdp = xcalloc(sizeof (*tdp)); 156 tdp->t_type = TYPEDEF_UNRES; 157 tdp->t_id = tid; 158 159 return (tdp); 160} 161 | 129{ 130 int i; 131 132 for (i = 0; i < BUCKETS; i++) { 133 hash_table[i] = NULL; 134 name_table[i] = NULL; 135 } 136 --- 16 unchanged lines hidden (view full) --- 153 154 tdp = xcalloc(sizeof (*tdp)); 155 tdp->t_type = TYPEDEF_UNRES; 156 tdp->t_id = tid; 157 158 return (tdp); 159} 160 |
162char * | 161static char * |
163read_tid(char *cp, tdesc_t **tdpp) 164{ 165 tdesc_t *tdp; 166 int tid; 167 168 cp = id(cp, &tid); 169 170 assert(tid != 0); --- 14 unchanged lines hidden (view full) --- 185 186 *tdpp = tdp; 187 return (cp); 188} 189 190static iitype_t 191parse_fun(char *cp, iidesc_t *ii) 192{ | 162read_tid(char *cp, tdesc_t **tdpp) 163{ 164 tdesc_t *tdp; 165 int tid; 166 167 cp = id(cp, &tid); 168 169 assert(tid != 0); --- 14 unchanged lines hidden (view full) --- 184 185 *tdpp = tdp; 186 return (cp); 187} 188 189static iitype_t 190parse_fun(char *cp, iidesc_t *ii) 191{ |
193 iitype_t iitype; | 192 iitype_t iitype = 0; |
194 tdesc_t *tdp; 195 tdesc_t **args = NULL; 196 int nargs = 0; 197 int va = 0; 198 199 /* 200 * name:P prototype 201 * name:F global function --- 43 unchanged lines hidden (view full) --- 245 246 return (iitype); 247} 248 249static iitype_t 250parse_sym(char *cp, iidesc_t *ii) 251{ 252 tdesc_t *tdp; | 193 tdesc_t *tdp; 194 tdesc_t **args = NULL; 195 int nargs = 0; 196 int va = 0; 197 198 /* 199 * name:P prototype 200 * name:F global function --- 43 unchanged lines hidden (view full) --- 244 245 return (iitype); 246} 247 248static iitype_t 249parse_sym(char *cp, iidesc_t *ii) 250{ 251 tdesc_t *tdp; |
253 iitype_t iitype; | 252 iitype_t iitype = 0; |
254 255 /* 256 * name:G global variable 257 * name:S static variable 258 */ 259 switch (*cp++) { 260 case 'G': 261 iitype = II_GVAR; --- 771 unchanged lines hidden (view full) --- 1033 parse_debug(3, NULL, "enum %s: %s=%d", tdesc_name(*rtdp), 1034 elp->el_name, elp->el_number); 1035 prev = &elp->el_next; 1036 if (*cp++ != ',') 1037 expected("enumdef", ",", cp - 1); 1038 } 1039} 1040 | 253 254 /* 255 * name:G global variable 256 * name:S static variable 257 */ 258 switch (*cp++) { 259 case 'G': 260 iitype = II_GVAR; --- 771 unchanged lines hidden (view full) --- 1032 parse_debug(3, NULL, "enum %s: %s=%d", tdesc_name(*rtdp), 1033 elp->el_name, elp->el_number); 1034 prev = &elp->el_next; 1035 if (*cp++ != ',') 1036 expected("enumdef", ",", cp - 1); 1037 } 1038} 1039 |
1041tdesc_t * 1042lookup_name(tdesc_t **hash, const char *name) | 1040static tdesc_t * 1041lookup_name(tdesc_t **hash, const char *name1) |
1043{ | 1042{ |
1044 int bucket = compute_sum(name); | 1043 int bucket = compute_sum(name1); |
1045 tdesc_t *tdp, *ttdp = NULL; 1046 1047 for (tdp = hash[bucket]; tdp != NULL; tdp = tdp->t_next) { | 1044 tdesc_t *tdp, *ttdp = NULL; 1045 1046 for (tdp = hash[bucket]; tdp != NULL; tdp = tdp->t_next) { |
1048 if (tdp->t_name != NULL && strcmp(tdp->t_name, name) == 0) { | 1047 if (tdp->t_name != NULL && strcmp(tdp->t_name, name1) == 0) { |
1049 if (tdp->t_type == STRUCT || tdp->t_type == UNION || 1050 tdp->t_type == ENUM || tdp->t_type == INTRINSIC) 1051 return (tdp); 1052 if (tdp->t_type == TYPEDEF) 1053 ttdp = tdp; 1054 } 1055 } 1056 return (ttdp); 1057} 1058 1059tdesc_t * | 1048 if (tdp->t_type == STRUCT || tdp->t_type == UNION || 1049 tdp->t_type == ENUM || tdp->t_type == INTRINSIC) 1050 return (tdp); 1051 if (tdp->t_type == TYPEDEF) 1052 ttdp = tdp; 1053 } 1054 } 1055 return (ttdp); 1056} 1057 1058tdesc_t * |
1060lookupname(const char *name) | 1059lookupname(const char *name1) |
1061{ | 1060{ |
1062 return (lookup_name(name_table, name)); | 1061 return (lookup_name(name_table, name1)); |
1063} 1064 1065/* 1066 * Add a node to the hash queues. 1067 */ 1068static void 1069addhash(tdesc_t *tdp, int num) 1070{ --- 75 unchanged lines hidden (view full) --- 1146 } 1147 } 1148 } 1149 printf("done\n"); 1150} 1151 1152/*ARGSUSED1*/ 1153static int | 1062} 1063 1064/* 1065 * Add a node to the hash queues. 1066 */ 1067static void 1068addhash(tdesc_t *tdp, int num) 1069{ --- 75 unchanged lines hidden (view full) --- 1145 } 1146 } 1147 } 1148 printf("done\n"); 1149} 1150 1151/*ARGSUSED1*/ 1152static int |
1154resolve_typed_bitfields_cb(mlist_t *ml, void *private) | 1153resolve_typed_bitfields_cb(void *arg, void *private __unused) |
1155{ | 1154{ |
1155 mlist_t *ml = arg; |
|
1156 tdesc_t *tdp = ml->ml_type; 1157 1158 debug(3, "Resolving typed bitfields (member %s)\n", 1159 (ml->ml_name ? ml->ml_name : "(anon)")); 1160 1161 while (tdp) { 1162 switch (tdp->t_type) { 1163 case INTRINSIC: --- 25 unchanged lines hidden (view full) --- 1189 /*NOTREACHED*/ 1190 return (0); 1191} 1192 1193void 1194resolve_typed_bitfields(void) 1195{ 1196 (void) list_iter(typedbitfldmems, | 1156 tdesc_t *tdp = ml->ml_type; 1157 1158 debug(3, "Resolving typed bitfields (member %s)\n", 1159 (ml->ml_name ? ml->ml_name : "(anon)")); 1160 1161 while (tdp) { 1162 switch (tdp->t_type) { 1163 case INTRINSIC: --- 25 unchanged lines hidden (view full) --- 1189 /*NOTREACHED*/ 1190 return (0); 1191} 1192 1193void 1194resolve_typed_bitfields(void) 1195{ 1196 (void) list_iter(typedbitfldmems, |
1197 (int (*)())resolve_typed_bitfields_cb, NULL); | 1197 resolve_typed_bitfields_cb, NULL); |
1198} | 1198} |