Ignore:
File:
1 edited

Legend:

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

    r074444f r1ebc1a62  
    3333#include "list.h"
    3434#include "mytypes.h"
    35 #include "strtab.h"
    3635#include "symbol.h"
    3736#include "tdata.h"
     
    4746static void run_tnameref(stree_program_t *prog, stree_csi_t *ctx,
    4847    stree_tnameref_t *tnameref, tdata_item_t **res);
    49 static void run_tapply(stree_program_t *prog, stree_csi_t *ctx,
    50     stree_tapply_t *tapply, tdata_item_t **res);
    5148
    5249void run_texpr(stree_program_t *prog, stree_csi_t *ctx, stree_texpr_t *texpr,
     
    6764                break;
    6865        case tc_tapply:
    69                 run_tapply(prog, ctx, texpr->u.tapply, res);
    70                 break;
     66                printf("Unimplemented: Evaluate type expression type %d.\n",
     67                    texpr->tc);
     68                exit(1);
    7169        }
    7270}
     
    8785        run_texpr(prog, ctx, taccess->arg, &targ_i);
    8886
    89         if (targ_i->tic == tic_ignore) {
    90                 *res = tdata_item_new(tic_ignore);
    91                 return;
    92         }
    93 
    9487        if (targ_i->tic != tic_tobject) {
    9588                printf("Error: Using '.' with type which is not an object.\n");
    96                 *res = tdata_item_new(tic_ignore);
    97                 return;
     89                exit(1);
    9890        }
    9991
     
    10294
    10395        sym = symbol_lookup_in_csi(prog, base_csi, taccess->member_name);
    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         }
     96
     97        /* Existence should have been verified in type checking phase. */
     98        assert(sym != NULL);
    11299
    113100        if (sym->sc != sc_csi) {
     
    115102                symbol_print_fqn(sym);
    116103                printf("' is not a CSI.\n");
    117                 *res = tdata_item_new(tic_ignore);
    118                 return;
     104                exit(1);
    119105        }
    120106
     
    144130        /* Evaluate base type. */
    145131        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         }
    151132
    152133        /* Construct type item. */
     
    186167
    187168        switch (tliteral->tlc) {
    188         case tlc_bool: tpc = tpc_bool; break;
    189         case tlc_char: tpc = tpc_char; break;
    190169        case tlc_int: tpc = tpc_int; break;
    191170        case tlc_string: tpc = tpc_string; break;
     
    212191#endif
    213192        sym = symbol_lookup_in_csi(prog, ctx, tnameref->name);
    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         }
     193
     194        /* Existence should have been verified in type-checking phase. */
     195        assert(sym);
    220196
    221197        if (sym->sc != sc_csi) {
     
    223199                symbol_print_fqn(sym);
    224200                printf("' is not a CSI.\n");
    225                 *res = tdata_item_new(tic_ignore);
    226                 return;
     201                exit(1);
    227202        }
    228203
     
    237212        *res = titem;
    238213}
    239 
    240 static 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.