Changeset 074444f in mainline for uspace/app/sbi/src/run_texpr.c


Ignore:
Timestamp:
2010-04-10T11:15:33Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1ef0fc3, 38aaacc2
Parents:
23de644
Message:

Update SBI to rev. 184.

File:
1 edited

Legend:

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

    r23de644 r074444f  
    3333#include "list.h"
    3434#include "mytypes.h"
     35#include "strtab.h"
    3536#include "symbol.h"
    3637#include "tdata.h"
     
    4647static void run_tnameref(stree_program_t *prog, stree_csi_t *ctx,
    4748    stree_tnameref_t *tnameref, tdata_item_t **res);
     49static void run_tapply(stree_program_t *prog, stree_csi_t *ctx,
     50    stree_tapply_t *tapply, tdata_item_t **res);
    4851
    4952void run_texpr(stree_program_t *prog, stree_csi_t *ctx, stree_texpr_t *texpr,
     
    6467                break;
    6568        case tc_tapply:
    66                 printf("Unimplemented: Evaluate type expression type %d.\n",
    67                     texpr->tc);
    68                 exit(1);
     69                run_tapply(prog, ctx, texpr->u.tapply, res);
     70                break;
    6971        }
    7072}
     
    8587        run_texpr(prog, ctx, taccess->arg, &targ_i);
    8688
     89        if (targ_i->tic == tic_ignore) {
     90                *res = tdata_item_new(tic_ignore);
     91                return;
     92        }
     93
    8794        if (targ_i->tic != tic_tobject) {
    8895                printf("Error: Using '.' with type which is not an object.\n");
    89                 exit(1);
     96                *res = tdata_item_new(tic_ignore);
     97                return;
    9098        }
    9199
     
    94102
    95103        sym = symbol_lookup_in_csi(prog, base_csi, taccess->member_name);
    96 
    97         /* Existence should have been verified in type checking phase. */
    98         assert(sym != NULL);
     104        if (sym == NULL) {
     105                printf("Error: CSI '");
     106                symbol_print_fqn(csi_to_symbol(base_csi));
     107                printf("' has no member named '%s'.\n",
     108                    strtab_get_str(taccess->member_name->sid));
     109                *res = tdata_item_new(tic_ignore);
     110                return;
     111        }
    99112
    100113        if (sym->sc != sc_csi) {
     
    102115                symbol_print_fqn(sym);
    103116                printf("' is not a CSI.\n");
    104                 exit(1);
     117                *res = tdata_item_new(tic_ignore);
     118                return;
    105119        }
    106120
     
    130144        /* Evaluate base type. */
    131145        run_texpr(prog, ctx, tindex->base_type, &base_ti);
     146
     147        if (base_ti->tic == tic_ignore) {
     148                *res = tdata_item_new(tic_ignore);
     149                return;
     150        }
    132151
    133152        /* Construct type item. */
     
    167186
    168187        switch (tliteral->tlc) {
     188        case tlc_bool: tpc = tpc_bool; break;
     189        case tlc_char: tpc = tpc_char; break;
    169190        case tlc_int: tpc = tpc_int; break;
    170191        case tlc_string: tpc = tpc_string; break;
     
    191212#endif
    192213        sym = symbol_lookup_in_csi(prog, ctx, tnameref->name);
    193 
    194         /* Existence should have been verified in type-checking phase. */
    195         assert(sym);
     214        if (sym == NULL) {
     215                printf("Error: Symbol '%s' not found.\n",
     216                    strtab_get_str(tnameref->name->sid));
     217                *res = tdata_item_new(tic_ignore);
     218                return;
     219        }
    196220
    197221        if (sym->sc != sc_csi) {
     
    199223                symbol_print_fqn(sym);
    200224                printf("' is not a CSI.\n");
    201                 exit(1);
     225                *res = tdata_item_new(tic_ignore);
     226                return;
    202227        }
    203228
     
    212237        *res = titem;
    213238}
     239
     240static void run_tapply(stree_program_t *prog, stree_csi_t *ctx,
     241    stree_tapply_t *tapply, tdata_item_t **res)
     242{
     243        tdata_item_t *base_ti;
     244        tdata_item_t *arg_ti;
     245        tdata_item_t *titem;
     246        tdata_object_t *tobject;
     247
     248        list_node_t *arg_n;
     249        stree_texpr_t *arg;
     250
     251#ifdef DEBUG_RUN_TRACE
     252        printf("Evaluating type apply operation.\n");
     253#endif
     254        /* Construct type item. */
     255        titem = tdata_item_new(tic_tobject);
     256        tobject = tdata_object_new();
     257        titem->u.tobject = tobject;
     258
     259        /* Evaluate base (generic) type. */
     260        run_texpr(prog, ctx, tapply->gtype, &base_ti);
     261
     262        if (base_ti->tic != tic_tobject) {
     263                printf("Error: Base type of generic application is not "
     264                    "a CSI.\n");
     265                *res = tdata_item_new(tic_ignore);
     266                return;
     267        }
     268
     269        tobject->static_ref = b_false;
     270        tobject->csi = base_ti->u.tobject->csi;
     271        list_init(&tobject->targs);
     272
     273        /* Evaluate type arguments. */
     274        arg_n = list_first(&tapply->targs);
     275        while (arg_n != NULL) {
     276                arg = list_node_data(arg_n, stree_texpr_t *);
     277                run_texpr(prog, ctx, arg, &arg_ti);
     278
     279                if (arg_ti->tic == tic_ignore) {
     280                        *res = tdata_item_new(tic_ignore);
     281                        return;
     282                }
     283
     284                list_append(&tobject->targs, arg_ti);
     285
     286                arg_n = list_next(&tapply->targs, arg_n);
     287        }
     288
     289        *res = titem;
     290}
Note: See TracChangeset for help on using the changeset viewer.