Ignore:
File:
1 edited

Legend:

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

    rc5cb943d r051bc69a  
    4242static stree_symbol_t *symbol_find_epoint_rec(stree_program_t *prog,
    4343    stree_ident_t *name, stree_csi_t *csi);
     44static stree_symbol_t *csimbr_to_symbol(stree_csimbr_t *csimbr);
    4445static stree_ident_t *symbol_get_ident(stree_symbol_t *symbol);
    4546
     
    131132    stree_csi_t *scope, stree_ident_t *name)
    132133{
     134        stree_symbol_t *base_csi_sym;
    133135        stree_csi_t *base_csi;
    134136        stree_symbol_t *symbol;
     
    140142
    141143        /* Try inherited members. */
    142         base_csi = symbol_get_base_class(prog, scope);
    143         if (base_csi != NULL)
     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
    144150                return symbol_search_csi(prog, base_csi, name);
     151        }
    145152
    146153        /* No match */
     
    205212                modm = list_node_data(node, stree_modm_t *);
    206213
    207                 /* Make compiler happy. */
    208                 mbr_name = NULL;
    209 
    210214                switch (modm->mc) {
    211215                case mc_csi: mbr_name = modm->u.csi->name; break;
     
    213217                }
    214218
    215                 /* The Clang static analyzer is just too picky. */
    216                 assert(mbr_name != NULL);
    217 
    218219                if (name->sid == mbr_name->sid) {
    219                         /* Make compiler happy. */
    220                         symbol = NULL;
    221 
    222220                        /* Match */
    223221                        switch (modm->mc) {
     
    233231                node = list_next(&prog->module->members, node);
    234232        }
    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;
    306233
    307234        return NULL;
     
    359286        stree_csimbr_t *csimbr;
    360287        stree_symbol_t *entry, *etmp;
    361         stree_symbol_t *fun_sym;
    362288
    363289        entry = NULL;
     
    379305                        break;
    380306                case csimbr_fun:
    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)) {
     307                        if (csimbr->u.fun->name->sid == name->sid) {
    385308                                if (entry != NULL) {
    386309                                        printf("Error: Duplicate entry point.\n");
    387310                                        exit(1);
    388311                                }
    389                                 entry = fun_sym;
     312                                entry = fun_to_symbol(csimbr->u.fun);
    390313                        }
    391314                default:
     
    571494 * @return              Symbol
    572495 */
    573 stree_symbol_t *csimbr_to_symbol(stree_csimbr_t *csimbr)
     496static stree_symbol_t *csimbr_to_symbol(stree_csimbr_t *csimbr)
    574497{
    575498        stree_symbol_t *symbol;
     
    645568{
    646569        stree_ident_t *ident;
    647 
    648         /* Make compiler happy. */
    649         ident = NULL;
    650570
    651571        switch (symbol->sc) {
Note: See TracChangeset for help on using the changeset viewer.