Changes in uspace/app/sbi/src/symbol.c [051bc69a:c5cb943d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/symbol.c
r051bc69a rc5cb943d 42 42 static stree_symbol_t *symbol_find_epoint_rec(stree_program_t *prog, 43 43 stree_ident_t *name, stree_csi_t *csi); 44 static stree_symbol_t *csimbr_to_symbol(stree_csimbr_t *csimbr);45 44 static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol); 46 45 … … 132 131 stree_csi_t *scope, stree_ident_t *name) 133 132 { 134 stree_symbol_t *base_csi_sym;135 133 stree_csi_t *base_csi; 136 134 stree_symbol_t *symbol; … … 142 140 143 141 /* Try inherited members. */ 144 if (scope->base_csi_ref != NULL) { 145 base_csi_sym = symbol_xlookup_in_csi(prog, 146 csi_to_symbol(scope)->outer_csi, scope->base_csi_ref); 147 base_csi = symbol_to_csi(base_csi_sym); 148 assert(base_csi != NULL); 149 142 base_csi = symbol_get_base_class(prog, scope); 143 if (base_csi != NULL) 150 144 return symbol_search_csi(prog, base_csi, name); 151 }152 145 153 146 /* No match */ … … 212 205 modm = list_node_data(node, stree_modm_t *); 213 206 207 /* Make compiler happy. */ 208 mbr_name = NULL; 209 214 210 switch (modm->mc) { 215 211 case mc_csi: mbr_name = modm->u.csi->name; break; … … 217 213 } 218 214 215 /* The Clang static analyzer is just too picky. */ 216 assert(mbr_name != NULL); 217 219 218 if (name->sid == mbr_name->sid) { 219 /* Make compiler happy. */ 220 symbol = NULL; 221 220 222 /* Match */ 221 223 switch (modm->mc) { … … 231 233 node = list_next(&prog->module->members, node); 232 234 } 235 236 return NULL; 237 } 238 239 /** Get explicit base class for a CSI. 240 * 241 * Note that if there is no explicit base class (class is derived implicitly 242 * from @c object, then @c NULL is returned. 243 * 244 * @param prog Program to look in 245 * @param csi CSI 246 * 247 * @return Base class (CSI) or @c NULL if no explicit base class. 248 */ 249 stree_csi_t *symbol_get_base_class(stree_program_t *prog, stree_csi_t *csi) 250 { 251 list_node_t *pred_n; 252 stree_texpr_t *pred; 253 stree_symbol_t *pred_sym; 254 stree_csi_t *pred_csi; 255 stree_csi_t *outer_csi; 256 257 outer_csi = csi_to_symbol(csi)->outer_csi; 258 259 pred_n = list_first(&csi->inherit); 260 if (pred_n == NULL) 261 return NULL; 262 263 pred = list_node_data(pred_n, stree_texpr_t *); 264 pred_sym = symbol_xlookup_in_csi(prog, outer_csi, pred); 265 pred_csi = symbol_to_csi(pred_sym); 266 assert(pred_csi != NULL); /* XXX! */ 267 268 if (pred_csi->cc == csi_class) 269 return pred_csi; 270 271 return NULL; 272 } 273 274 /** Get type expression referencing base class for a CSI. 275 * 276 * Note that if there is no explicit base class (class is derived implicitly 277 * from @c object, then @c NULL is returned. 278 * 279 * @param prog Program to look in 280 * @param csi CSI 281 * 282 * @return Type expression or @c NULL if no explicit base class. 283 */ 284 stree_texpr_t *symbol_get_base_class_ref(stree_program_t *prog, 285 stree_csi_t *csi) 286 { 287 list_node_t *pred_n; 288 stree_texpr_t *pred; 289 stree_symbol_t *pred_sym; 290 stree_csi_t *pred_csi; 291 stree_csi_t *outer_csi; 292 293 outer_csi = csi_to_symbol(csi)->outer_csi; 294 295 pred_n = list_first(&csi->inherit); 296 if (pred_n == NULL) 297 return NULL; 298 299 pred = list_node_data(pred_n, stree_texpr_t *); 300 pred_sym = symbol_xlookup_in_csi(prog, outer_csi, pred); 301 pred_csi = symbol_to_csi(pred_sym); 302 assert(pred_csi != NULL); /* XXX! */ 303 304 if (pred_csi->cc == csi_class) 305 return pred; 233 306 234 307 return NULL; … … 286 359 stree_csimbr_t *csimbr; 287 360 stree_symbol_t *entry, *etmp; 361 stree_symbol_t *fun_sym; 288 362 289 363 entry = NULL; … … 305 379 break; 306 380 case csimbr_fun: 307 if (csimbr->u.fun->name->sid == name->sid) { 381 fun_sym = fun_to_symbol(csimbr->u.fun); 382 383 if (csimbr->u.fun->name->sid == name->sid && 384 stree_symbol_has_attr(fun_sym, sac_static)) { 308 385 if (entry != NULL) { 309 386 printf("Error: Duplicate entry point.\n"); 310 387 exit(1); 311 388 } 312 entry = fun_ to_symbol(csimbr->u.fun);389 entry = fun_sym; 313 390 } 314 391 default: … … 494 571 * @return Symbol 495 572 */ 496 st atic stree_symbol_t *csimbr_to_symbol(stree_csimbr_t *csimbr)573 stree_symbol_t *csimbr_to_symbol(stree_csimbr_t *csimbr) 497 574 { 498 575 stree_symbol_t *symbol; … … 569 646 stree_ident_t *ident; 570 647 648 /* Make compiler happy. */ 649 ident = NULL; 650 571 651 switch (symbol->sc) { 572 652 case sc_csi: ident = symbol->u.csi->name; break;
Note:
See TracChangeset
for help on using the changeset viewer.