Changes in uspace/app/sbi/src/run_texpr.c [1ebc1a62:074444f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/run_texpr.c
r1ebc1a62 r074444f 33 33 #include "list.h" 34 34 #include "mytypes.h" 35 #include "strtab.h" 35 36 #include "symbol.h" 36 37 #include "tdata.h" … … 46 47 static void run_tnameref(stree_program_t *prog, stree_csi_t *ctx, 47 48 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); 48 51 49 52 void run_texpr(stree_program_t *prog, stree_csi_t *ctx, stree_texpr_t *texpr, … … 64 67 break; 65 68 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; 69 71 } 70 72 } … … 85 87 run_texpr(prog, ctx, taccess->arg, &targ_i); 86 88 89 if (targ_i->tic == tic_ignore) { 90 *res = tdata_item_new(tic_ignore); 91 return; 92 } 93 87 94 if (targ_i->tic != tic_tobject) { 88 95 printf("Error: Using '.' with type which is not an object.\n"); 89 exit(1); 96 *res = tdata_item_new(tic_ignore); 97 return; 90 98 } 91 99 … … 94 102 95 103 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 } 99 112 100 113 if (sym->sc != sc_csi) { … … 102 115 symbol_print_fqn(sym); 103 116 printf("' is not a CSI.\n"); 104 exit(1); 117 *res = tdata_item_new(tic_ignore); 118 return; 105 119 } 106 120 … … 130 144 /* Evaluate base type. */ 131 145 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 } 132 151 133 152 /* Construct type item. */ … … 167 186 168 187 switch (tliteral->tlc) { 188 case tlc_bool: tpc = tpc_bool; break; 189 case tlc_char: tpc = tpc_char; break; 169 190 case tlc_int: tpc = tpc_int; break; 170 191 case tlc_string: tpc = tpc_string; break; … … 191 212 #endif 192 213 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 } 196 220 197 221 if (sym->sc != sc_csi) { … … 199 223 symbol_print_fqn(sym); 200 224 printf("' is not a CSI.\n"); 201 exit(1); 225 *res = tdata_item_new(tic_ignore); 226 return; 202 227 } 203 228 … … 212 237 *res = titem; 213 238 } 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.