Changes in uspace/app/sbi/src/symbol.c [074444f:38aaacc2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/symbol.c
r074444f r38aaacc2 44 44 static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol); 45 45 46 /** Lookup symbol in CSI using a type expression. */ 46 /** Lookup symbol in CSI using a type expression. 47 * 48 * XXX This should be removed in favor of full type expression evaluation 49 * (run_texpr). This cannot work properly with generics. 50 * 51 * @param prog Program 52 * @param scope CSI used as base for relative references 53 * @param texpr Type expression 54 * 55 * @return Symbol referenced by type expression or @c NULL 56 * if not found 57 */ 47 58 stree_symbol_t *symbol_xlookup_in_csi(stree_program_t *prog, 48 59 stree_csi_t *scope, stree_texpr_t *texpr) … … 77 88 /** Lookup symbol reference in CSI. 78 89 * 79 * @param prog Program to look in .80 * @param scope CSI in @a prog which is the base for references .81 * @param name Identifier of the symbol .82 * 83 * @return Symbol or @c NULL if symbol not found .90 * @param prog Program to look in 91 * @param scope CSI in @a prog which is the base for references 92 * @param name Identifier of the symbol 93 * 94 * @return Symbol or @c NULL if symbol not found 84 95 */ 85 96 stree_symbol_t *symbol_lookup_in_csi(stree_program_t *prog, stree_csi_t *scope, … … 107 118 * Look for symbol in definition of a CSI and its ancestors. (But not 108 119 * in lexically enclosing CSI.) 120 * 121 * @param prog Program to look in 122 * @param scope CSI in which to look 123 * @param name Identifier of the symbol 124 * 125 * @return Symbol or @c NULL if symbol not found. 109 126 */ 110 127 stree_symbol_t *symbol_search_csi(stree_program_t *prog, … … 125 142 while (node != NULL) { 126 143 csimbr = list_node_data(node, stree_csimbr_t *); 144 145 /* Keep compiler happy. */ 146 mbr_name = NULL; 147 127 148 switch (csimbr->cc) { 128 149 case csimbr_csi: mbr_name = csimbr->u.csi->name; break; 150 case csimbr_deleg: mbr_name = csimbr->u.deleg->name; break; 129 151 case csimbr_fun: mbr_name = csimbr->u.fun->name; break; 130 152 case csimbr_var: mbr_name = csimbr->u.var->name; break; 131 153 case csimbr_prop: mbr_name = csimbr->u.prop->name; break; 132 default: assert(b_false);133 154 } 134 155 … … 138 159 case csimbr_csi: 139 160 symbol = csi_to_symbol(csimbr->u.csi); 161 break; 162 case csimbr_deleg: 163 symbol = deleg_to_symbol(csimbr->u.deleg); 140 164 break; 141 165 case csimbr_fun: … … 170 194 } 171 195 196 /** Look for symbol in global scope. 197 * 198 * @param prog Program to look in 199 * @param name Identifier of the symbol 200 * 201 * @return Symbol or @c NULL if symbol not found. 202 */ 172 203 static stree_symbol_t *symbol_search_global(stree_program_t *prog, 173 204 stree_ident_t *name) … … 197 228 } 198 229 199 /** Find entry point. */ 230 /** Find entry point. 231 * 232 * Perform a walk of all CSIs and look for a function with the name @a name. 233 * 234 * @param prog Program to look in 235 * @param name Name of entry point 236 * 237 * @return Symbol or @c NULL if symbol not found. 238 */ 200 239 stree_symbol_t *symbol_find_epoint(stree_program_t *prog, stree_ident_t *name) 201 240 { … … 225 264 } 226 265 266 /** Find entry point under CSI. 267 * 268 * Internal part of symbol_find_epoint() that recursively walks CSIs. 269 * 270 * @param prog Program to look in 271 * @param name Name of entry point 272 * 273 * @return Symbol or @c NULL if symbol not found. 274 */ 227 275 static stree_symbol_t *symbol_find_epoint_rec(stree_program_t *prog, 228 276 stree_ident_t *name, stree_csi_t *csi) … … 267 315 } 268 316 317 /* 318 * The notion of symbol is designed as a common base class for several 319 * types of declarations with global and CSI scope. Here we simulate 320 * conversion from this base class (symbol) to derived classes (CSI, 321 * fun, ..) and vice versa. 322 */ 323 324 /** Convert symbol to delegate (base to derived). 325 * 326 * @param symbol Symbol 327 * @return Delegate or @c NULL if symbol is not a delegate 328 */ 329 stree_deleg_t *symbol_to_deleg(stree_symbol_t *symbol) 330 { 331 if (symbol->sc != sc_deleg) 332 return NULL; 333 334 return symbol->u.deleg; 335 } 336 337 /** Convert delegate to symbol (derived to base). 338 * 339 * @param deleg Delegate 340 * @return Symbol 341 */ 342 stree_symbol_t *deleg_to_symbol(stree_deleg_t *deleg) 343 { 344 assert(deleg->symbol); 345 return deleg->symbol; 346 } 347 348 /** Convert symbol to CSI (base to derived). 349 * 350 * @param symbol Symbol 351 * @return CSI or @c NULL if symbol is not a CSI 352 */ 269 353 stree_csi_t *symbol_to_csi(stree_symbol_t *symbol) 270 354 { … … 275 359 } 276 360 361 /** Convert CSI to symbol (derived to base). 362 * 363 * @param csi CSI 364 * @return Symbol 365 */ 277 366 stree_symbol_t *csi_to_symbol(stree_csi_t *csi) 278 367 { … … 281 370 } 282 371 372 /** Convert symbol to function (base to derived). 373 * 374 * @param symbol Symbol 375 * @return Function or @c NULL if symbol is not a function 376 */ 283 377 stree_fun_t *symbol_to_fun(stree_symbol_t *symbol) 284 378 { … … 289 383 } 290 384 385 /** Convert function to symbol (derived to base). 386 * 387 * @param fun Function 388 * @return Symbol 389 */ 291 390 stree_symbol_t *fun_to_symbol(stree_fun_t *fun) 292 391 { … … 295 394 } 296 395 396 /** Convert symbol to member variable (base to derived). 397 * 398 * @param symbol Symbol 399 * @return Variable or @c NULL if symbol is not a member variable 400 */ 297 401 stree_var_t *symbol_to_var(stree_symbol_t *symbol) 298 402 { … … 303 407 } 304 408 409 /** Convert variable to symbol (derived to base). 410 * 411 * @param fun Variable 412 * @return Symbol 413 */ 305 414 stree_symbol_t *var_to_symbol(stree_var_t *var) 306 415 { … … 309 418 } 310 419 420 /** Convert symbol to property (base to derived). 421 * 422 * @param symbol Symbol 423 * @return Property or @c NULL if symbol is not a property 424 */ 311 425 stree_prop_t *symbol_to_prop(stree_symbol_t *symbol) 312 426 { … … 317 431 } 318 432 433 /** Convert property to symbol (derived to base). 434 * 435 * @param fun Property 436 * @return Symbol 437 */ 319 438 stree_symbol_t *prop_to_symbol(stree_prop_t *prop) 320 439 { … … 323 442 } 324 443 325 /** Print fully qualified name of symbol. */ 444 /** Print fully qualified name of symbol. 445 * 446 * @param symbol Symbol 447 */ 326 448 void symbol_print_fqn(stree_symbol_t *symbol) 327 449 { … … 339 461 } 340 462 463 /** Return symbol identifier. 464 * 465 * @param symbol Symbol 466 * @return Symbol identifier 467 */ 341 468 static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol) 342 469 { … … 345 472 switch (symbol->sc) { 346 473 case sc_csi: ident = symbol->u.csi->name; break; 474 case sc_deleg: ident = symbol->u.deleg->name; break; 347 475 case sc_fun: ident = symbol->u.fun->name; break; 348 476 case sc_var: ident = symbol->u.var->name; break;
Note:
See TracChangeset
for help on using the changeset viewer.