Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/stype.c
- Timestamp:
- 2010-03-29T20:30:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a95310e
- Parents:
- 5da468e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/stype.c
r5da468e r1ebc1a62 61 61 static void stype_raise(stype_t *stype, stree_raise_t *raise_s); 62 62 static void stype_return(stype_t *stype, stree_return_t *return_s); 63 static void stype_exps(stype_t *stype, stree_exps_t *exp_s );63 static void stype_exps(stype_t *stype, stree_exps_t *exp_s, bool_t want_value); 64 64 static void stype_wef(stype_t *stype, stree_wef_t *wef_s); 65 65 … … 164 164 if (titem->tic != tic_tarray) { 165 165 printf("Error: Packed argument is not an array.\n"); 166 exit(1);166 stype_note_error(stype); 167 167 } 168 168 } … … 240 240 while (stat_n != NULL) { 241 241 stat = list_node_data(stat_n, stree_stat_t *); 242 stype_stat(stype, stat );242 stype_stat(stype, stat, b_false); 243 243 244 244 stat_n = list_next(&block->stats, stat_n); … … 251 251 } 252 252 253 /** Type statement */ 254 void stype_stat(stype_t *stype, stree_stat_t *stat) 253 /** Type statement 254 * 255 * Types a statement. If @a want_value is @c b_true, then warning about 256 * ignored expression value will be supressed for this statement (but not 257 * for nested statemens). This is used in interactive mode. 258 * 259 * @param stype Static typer object. 260 * @param stat Statement to type. 261 * @param want_value @c b_true to allow ignoring expression value. 262 */ 263 void stype_stat(stype_t *stype, stree_stat_t *stat, bool_t want_value) 255 264 { 256 265 #ifdef DEBUG_TYPE_TRACE … … 264 273 case st_raise: stype_raise(stype, stat->u.raise_s); break; 265 274 case st_return: stype_return(stype, stat->u.return_s); break; 266 case st_exps: stype_exps(stype, stat->u.exp_s ); break;275 case st_exps: stype_exps(stype, stat->u.exp_s, want_value); break; 267 276 case st_wef: stype_wef(stype, stat->u.wef_s); break; 268 277 } … … 285 294 printf("Error: Duplicate variable declaration '%s'.\n", 286 295 strtab_get_str(vdecl_s->name->sid)); 287 exit(1);296 stype_note_error(stype); 288 297 } 289 298 … … 387 396 printf("Error: Return statement in " 388 397 "setter.\n"); 389 exit(1);398 stype_note_error(stype); 390 399 } 391 400 … … 406 415 407 416 /** Type expression statement */ 408 static void stype_exps(stype_t *stype, stree_exps_t *exp_s )417 static void stype_exps(stype_t *stype, stree_exps_t *exp_s, bool_t want_value) 409 418 { 410 419 #ifdef DEBUG_TYPE_TRACE … … 413 422 stype_expr(stype, exp_s->expr); 414 423 415 if ( exp_s->expr->titem != NULL)424 if (want_value == b_false && exp_s->expr->titem != NULL) 416 425 printf("Warning: Expression value ignored.\n"); 417 426 } … … 468 477 if (dest == NULL) { 469 478 printf("Error: Conversion destination is not valid.\n"); 470 exit(1); 479 stype_note_error(stype); 480 return expr; 471 481 } 472 482 473 483 if (src == NULL) { 474 484 printf("Error: Conversion source is not valid.\n"); 475 exit(1); 485 stype_note_error(stype); 486 return expr; 476 487 } 477 488 … … 519 530 tdata_item_print(dest); 520 531 printf("'.\n"); 521 exit(1);532 stype_note_error(stype); 522 533 } 523 534 … … 531 542 printf(".\n"); 532 543 533 /* XXX We should rather return a bogus expression of type @a dest */534 exit(1);544 stype_note_error(stype); 545 return expr; 535 546 } 536 547 … … 659 670 } 660 671 672 /** Note a static typing error that has been immediately recovered. */ 673 void stype_note_error(stype_t *stype) 674 { 675 stype->error = b_true; 676 } 677 678 /** Construct a special type item for recovery. */ 679 tdata_item_t *stype_recovery_titem(stype_t *stype) 680 { 681 tdata_item_t *titem; 682 tdata_primitive_t *tprimitive; 683 684 (void) stype; 685 686 titem = tdata_item_new(tic_tprimitive); 687 tprimitive = tdata_primitive_new(tpc_int); 688 689 titem->u.tprimitive = tprimitive; 690 691 return titem; 692 } 693 661 694 /** Get current block visit record. */ 662 695 stype_block_vr_t *stype_get_current_block_vr(stype_t *stype)
Note:
See TracChangeset
for help on using the changeset viewer.