Changes in uspace/app/sbi/src/symbol.c [38aaacc2:074444f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/symbol.c
r38aaacc2 r074444f 44 44 static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol); 45 45 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 */ 46 /** Lookup symbol in CSI using a type expression. */ 58 47 stree_symbol_t *symbol_xlookup_in_csi(stree_program_t *prog, 59 48 stree_csi_t *scope, stree_texpr_t *texpr) … … 88 77 /** Lookup symbol reference in CSI. 89 78 * 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 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. 95 84 */ 96 85 stree_symbol_t *symbol_lookup_in_csi(stree_program_t *prog, stree_csi_t *scope, … … 118 107 * Look for symbol in definition of a CSI and its ancestors. (But not 119 108 * in lexically enclosing CSI.) 120 *121 * @param prog Program to look in122 * @param scope CSI in which to look123 * @param name Identifier of the symbol124 *125 * @return Symbol or @c NULL if symbol not found.126 109 */ 127 110 stree_symbol_t *symbol_search_csi(stree_program_t *prog, … … 142 125 while (node != NULL) { 143 126 csimbr = list_node_data(node, stree_csimbr_t *); 144 145 /* Keep compiler happy. */146 mbr_name = NULL;147 148 127 switch (csimbr->cc) { 149 128 case csimbr_csi: mbr_name = csimbr->u.csi->name; break; 150 case csimbr_deleg: mbr_name = csimbr->u.deleg->name; break;151 129 case csimbr_fun: mbr_name = csimbr->u.fun->name; break; 152 130 case csimbr_var: mbr_name = csimbr->u.var->name; break; 153 131 case csimbr_prop: mbr_name = csimbr->u.prop->name; break; 132 default: assert(b_false); 154 133 } 155 134 … … 159 138 case csimbr_csi: 160 139 symbol = csi_to_symbol(csimbr->u.csi); 161 break;162 case csimbr_deleg:163 symbol = deleg_to_symbol(csimbr->u.deleg);164 140 break; 165 141 case csimbr_fun: … … 194 170 } 195 171 196 /** Look for symbol in global scope.197 *198 * @param prog Program to look in199 * @param name Identifier of the symbol200 *201 * @return Symbol or @c NULL if symbol not found.202 */203 172 static stree_symbol_t *symbol_search_global(stree_program_t *prog, 204 173 stree_ident_t *name) … … 228 197 } 229 198 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 */ 199 /** Find entry point. */ 239 200 stree_symbol_t *symbol_find_epoint(stree_program_t *prog, stree_ident_t *name) 240 201 { … … 264 225 } 265 226 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 in271 * @param name Name of entry point272 *273 * @return Symbol or @c NULL if symbol not found.274 */275 227 static stree_symbol_t *symbol_find_epoint_rec(stree_program_t *prog, 276 228 stree_ident_t *name, stree_csi_t *csi) … … 315 267 } 316 268 317 /*318 * The notion of symbol is designed as a common base class for several319 * types of declarations with global and CSI scope. Here we simulate320 * 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 Symbol327 * @return Delegate or @c NULL if symbol is not a delegate328 */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 Delegate340 * @return Symbol341 */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 Symbol351 * @return CSI or @c NULL if symbol is not a CSI352 */353 269 stree_csi_t *symbol_to_csi(stree_symbol_t *symbol) 354 270 { … … 359 275 } 360 276 361 /** Convert CSI to symbol (derived to base).362 *363 * @param csi CSI364 * @return Symbol365 */366 277 stree_symbol_t *csi_to_symbol(stree_csi_t *csi) 367 278 { … … 370 281 } 371 282 372 /** Convert symbol to function (base to derived).373 *374 * @param symbol Symbol375 * @return Function or @c NULL if symbol is not a function376 */377 283 stree_fun_t *symbol_to_fun(stree_symbol_t *symbol) 378 284 { … … 383 289 } 384 290 385 /** Convert function to symbol (derived to base).386 *387 * @param fun Function388 * @return Symbol389 */390 291 stree_symbol_t *fun_to_symbol(stree_fun_t *fun) 391 292 { … … 394 295 } 395 296 396 /** Convert symbol to member variable (base to derived).397 *398 * @param symbol Symbol399 * @return Variable or @c NULL if symbol is not a member variable400 */401 297 stree_var_t *symbol_to_var(stree_symbol_t *symbol) 402 298 { … … 407 303 } 408 304 409 /** Convert variable to symbol (derived to base).410 *411 * @param fun Variable412 * @return Symbol413 */414 305 stree_symbol_t *var_to_symbol(stree_var_t *var) 415 306 { … … 418 309 } 419 310 420 /** Convert symbol to property (base to derived).421 *422 * @param symbol Symbol423 * @return Property or @c NULL if symbol is not a property424 */425 311 stree_prop_t *symbol_to_prop(stree_symbol_t *symbol) 426 312 { … … 431 317 } 432 318 433 /** Convert property to symbol (derived to base).434 *435 * @param fun Property436 * @return Symbol437 */438 319 stree_symbol_t *prop_to_symbol(stree_prop_t *prop) 439 320 { … … 442 323 } 443 324 444 /** Print fully qualified name of symbol. 445 * 446 * @param symbol Symbol 447 */ 325 /** Print fully qualified name of symbol. */ 448 326 void symbol_print_fqn(stree_symbol_t *symbol) 449 327 { … … 461 339 } 462 340 463 /** Return symbol identifier.464 *465 * @param symbol Symbol466 * @return Symbol identifier467 */468 341 static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol) 469 342 { … … 472 345 switch (symbol->sc) { 473 346 case sc_csi: ident = symbol->u.csi->name; break; 474 case sc_deleg: ident = symbol->u.deleg->name; break;475 347 case sc_fun: ident = symbol->u.fun->name; break; 476 348 case sc_var: ident = symbol->u.var->name; break;
Note:
See TracChangeset
for help on using the changeset viewer.