Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/symbol.c

    r38aaacc2 r074444f  
    4444static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol);
    4545
    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. */
    5847stree_symbol_t *symbol_xlookup_in_csi(stree_program_t *prog,
    5948    stree_csi_t *scope, stree_texpr_t *texpr)
     
    8877/** Lookup symbol reference in CSI.
    8978 *
    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.
    9584 */
    9685stree_symbol_t *symbol_lookup_in_csi(stree_program_t *prog, stree_csi_t *scope,
     
    118107 * Look for symbol in definition of a CSI and its ancestors. (But not
    119108 * 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.
    126109 */
    127110stree_symbol_t *symbol_search_csi(stree_program_t *prog,
     
    142125        while (node != NULL) {
    143126                csimbr = list_node_data(node, stree_csimbr_t *);
    144 
    145                 /* Keep compiler happy. */
    146                 mbr_name = NULL;
    147 
    148127                switch (csimbr->cc) {
    149128                case csimbr_csi: mbr_name = csimbr->u.csi->name; break;
    150                 case csimbr_deleg: mbr_name = csimbr->u.deleg->name; break;
    151129                case csimbr_fun: mbr_name = csimbr->u.fun->name; break;
    152130                case csimbr_var: mbr_name = csimbr->u.var->name; break;
    153131                case csimbr_prop: mbr_name = csimbr->u.prop->name; break;
     132                default: assert(b_false);
    154133                }
    155134
     
    159138                        case csimbr_csi:
    160139                                symbol = csi_to_symbol(csimbr->u.csi);
    161                                 break;
    162                         case csimbr_deleg:
    163                                 symbol = deleg_to_symbol(csimbr->u.deleg);
    164140                                break;
    165141                        case csimbr_fun:
     
    194170}
    195171
    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  */
    203172static stree_symbol_t *symbol_search_global(stree_program_t *prog,
    204173    stree_ident_t *name)
     
    228197}
    229198
    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. */
    239200stree_symbol_t *symbol_find_epoint(stree_program_t *prog, stree_ident_t *name)
    240201{
     
    264225}
    265226
    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  */
    275227static stree_symbol_t *symbol_find_epoint_rec(stree_program_t *prog,
    276228    stree_ident_t *name, stree_csi_t *csi)
     
    315267}
    316268
    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  */
    353269stree_csi_t *symbol_to_csi(stree_symbol_t *symbol)
    354270{
     
    359275}
    360276
    361 /** Convert CSI to symbol (derived to base).
    362  *
    363  * @param csi           CSI
    364  * @return              Symbol
    365  */
    366277stree_symbol_t *csi_to_symbol(stree_csi_t *csi)
    367278{
     
    370281}
    371282
    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  */
    377283stree_fun_t *symbol_to_fun(stree_symbol_t *symbol)
    378284{
     
    383289}
    384290
    385 /** Convert function to symbol (derived to base).
    386  *
    387  * @param fun           Function
    388  * @return              Symbol
    389  */
    390291stree_symbol_t *fun_to_symbol(stree_fun_t *fun)
    391292{
     
    394295}
    395296
    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  */
    401297stree_var_t *symbol_to_var(stree_symbol_t *symbol)
    402298{
     
    407303}
    408304
    409 /** Convert variable to symbol (derived to base).
    410  *
    411  * @param fun           Variable
    412  * @return              Symbol
    413  */
    414305stree_symbol_t *var_to_symbol(stree_var_t *var)
    415306{
     
    418309}
    419310
    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  */
    425311stree_prop_t *symbol_to_prop(stree_symbol_t *symbol)
    426312{
     
    431317}
    432318
    433 /** Convert property to symbol (derived to base).
    434  *
    435  * @param fun           Property
    436  * @return              Symbol
    437  */
    438319stree_symbol_t *prop_to_symbol(stree_prop_t *prop)
    439320{
     
    442323}
    443324
    444 /** Print fully qualified name of symbol.
    445  *
    446  * @param symbol        Symbol
    447  */
     325/** Print fully qualified name of symbol. */
    448326void symbol_print_fqn(stree_symbol_t *symbol)
    449327{
     
    461339}
    462340
    463 /** Return symbol identifier.
    464  *
    465  * @param symbol        Symbol
    466  * @return              Symbol identifier
    467  */
    468341static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol)
    469342{
     
    472345        switch (symbol->sc) {
    473346        case sc_csi: ident = symbol->u.csi->name; break;
    474         case sc_deleg: ident = symbol->u.deleg->name; break;
    475347        case sc_fun: ident = symbol->u.fun->name; break;
    476348        case sc_var: ident = symbol->u.var->name; break;
Note: See TracChangeset for help on using the changeset viewer.