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