Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/stype.c


Ignore:
Timestamp:
2010-03-29T20:30:29Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a95310e
Parents:
5da468e
Message:

Update SBI to rev. 157.

File:
1 edited

Legend:

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

    r5da468e r1ebc1a62  
    6161static void stype_raise(stype_t *stype, stree_raise_t *raise_s);
    6262static void stype_return(stype_t *stype, stree_return_t *return_s);
    63 static void stype_exps(stype_t *stype, stree_exps_t *exp_s);
     63static void stype_exps(stype_t *stype, stree_exps_t *exp_s, bool_t want_value);
    6464static void stype_wef(stype_t *stype, stree_wef_t *wef_s);
    6565
     
    164164                if (titem->tic != tic_tarray) {
    165165                        printf("Error: Packed argument is not an array.\n");
    166                         exit(1);
     166                        stype_note_error(stype);
    167167                }
    168168        }
     
    240240        while (stat_n != NULL) {
    241241                stat = list_node_data(stat_n, stree_stat_t *);
    242                 stype_stat(stype, stat);
     242                stype_stat(stype, stat, b_false);
    243243
    244244                stat_n = list_next(&block->stats, stat_n);
     
    251251}
    252252
    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 */
     263void stype_stat(stype_t *stype, stree_stat_t *stat, bool_t want_value)
    255264{
    256265#ifdef DEBUG_TYPE_TRACE
     
    264273        case st_raise: stype_raise(stype, stat->u.raise_s); break;
    265274        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;
    267276        case st_wef: stype_wef(stype, stat->u.wef_s); break;
    268277        }
     
    285294                printf("Error: Duplicate variable declaration '%s'.\n",
    286295                    strtab_get_str(vdecl_s->name->sid));
    287                 exit(1);
     296                stype_note_error(stype);
    288297        }
    289298
     
    387396                        printf("Error: Return statement in "
    388397                            "setter.\n");
    389                         exit(1);
     398                        stype_note_error(stype);
    390399                }
    391400
     
    406415
    407416/** Type expression statement */
    408 static void stype_exps(stype_t *stype, stree_exps_t *exp_s)
     417static void stype_exps(stype_t *stype, stree_exps_t *exp_s, bool_t want_value)
    409418{
    410419#ifdef DEBUG_TYPE_TRACE
     
    413422        stype_expr(stype, exp_s->expr);
    414423
    415         if (exp_s->expr->titem != NULL)
     424        if (want_value == b_false && exp_s->expr->titem != NULL)
    416425                printf("Warning: Expression value ignored.\n");
    417426}
     
    468477        if (dest == NULL) {
    469478                printf("Error: Conversion destination is not valid.\n");
    470                 exit(1);
     479                stype_note_error(stype);
     480                return expr;
    471481        }
    472482
    473483        if (src == NULL) {
    474484                printf("Error: Conversion source is not valid.\n");
    475                 exit(1);
     485                stype_note_error(stype);
     486                return expr;
    476487        }
    477488
     
    519530                tdata_item_print(dest);
    520531                printf("'.\n");
    521                 exit(1);
     532                stype_note_error(stype);
    522533        }
    523534
     
    531542        printf(".\n");
    532543
    533         /* XXX We should rather return a bogus expression of type @a dest */
    534         exit(1);
     544        stype_note_error(stype);
     545        return expr;
    535546}
    536547
     
    659670}
    660671
     672/** Note a static typing error that has been immediately recovered. */
     673void stype_note_error(stype_t *stype)
     674{
     675        stype->error = b_true;
     676}
     677
     678/** Construct a special type item for recovery. */
     679tdata_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
    661694/** Get current block visit record. */
    662695stype_block_vr_t *stype_get_current_block_vr(stype_t *stype)
Note: See TracChangeset for help on using the changeset viewer.