Alien-TinyCCx

 view release on metacpan or  search on metacpan

src/tccpp.c  view on Meta::CPAN

            if (t == '\0')
                break;
            else if (t >= 'a')
                t = t - 'a' + 10;
            else if (t >= 'A')
                t = t - 'A' + 10;
            else
                t = t - '0';
            if (t >= b)
                tcc_error("invalid digit");
            n1 = n;
            n = n * b + t;
            /* detect overflow */
            /* XXX: this test is not reliable */
            if (n < n1)
                tcc_error("integer constant overflow");
        }

        /* Determine the characteristics (unsigned and/or 64bit) the type of
           the constant must have according to the constant suffix(es) */
        lcount = ucount = must_64bit = 0;
        p1 = p;
        for(;;) {
            t = toup(ch);
            if (t == 'L') {
                if (lcount >= 2)
                    tcc_error("three 'l's in integer constant");
                if (lcount && *(p - 1) != ch)
                    tcc_error("incorrect integer suffix: %s", p1);
                lcount++;
#if !defined TCC_TARGET_X86_64 || defined TCC_TARGET_PE
                if (lcount == 2)
#endif
                    must_64bit = 1;
                ch = *p++;
            } else if (t == 'U') {
                if (ucount >= 1)
                    tcc_error("two 'u's in integer constant");
                ucount++;
                ch = *p++;
            } else {
                break;
            }
        }

        /* Whether 64 bits are needed to hold the constant's value */
        if (n & 0xffffffff00000000LL || must_64bit) {
            tok = TOK_CLLONG;
            n1 = n >> 32;
	} else {
            tok = TOK_CINT;
            n1 = n;
        }

        /* Whether type must be unsigned to hold the constant's value */
        if (ucount || ((n1 >> 31) && (b != 10))) {
            if (tok == TOK_CLLONG)
                tok = TOK_CULLONG;
            else
                tok = TOK_CUINT;
        /* If decimal and no unsigned suffix, bump to 64 bits or throw error */
        } else if (n1 >> 31) {
            if (tok == TOK_CINT)
                tok = TOK_CLLONG;
            else
                tcc_error("integer constant overflow");
        }

        tokc.i = n;
    }
    if (ch)
        tcc_error("invalid number\n");
}

/* #ifdef CONFIG_TCC_EXSYMTAB */
/* MUST NEVER RETURN NULL (or if it does, call sites must be updated to handle that) */
TokenSym * get_local_ts_for_extended_ts(TokenSym* orig_symtab_ts, extended_symtab* orig_symtab) {
       /* Look up the original tokensym in the extended symbol and see if an
        * identically named symbol is already present in the current compiling
        * context's symbol table. */
       TokenSym **local_pts, *local_ts;
       local_pts = symtab_tok_find(orig_symtab_ts->str, orig_symtab_ts->len);
       local_ts = *local_pts;

       /* If not, find it in the extended symbol table. Notice that I perform
        * another search by name, rather than simply using curr_from, since the
        * extended symbol table manager might consider this to be overridden.
        * Fallback to original (and warn) if we get nothing. */
       if (local_ts == NULL) {
               extended_symtab * highest_precedent_symtab;
               TokenSym* highest_precedent_ts;
               highest_precedent_ts = tcc_state->symtab_name_callback(
                       orig_symtab_ts->str, orig_symtab_ts->len,
                       tcc_state->symtab_callback_data, &highest_precedent_symtab);

               /* Shouldn't happen, but use orig_symtab_ts if we get nothing */
               if (highest_precedent_ts == NULL) {
                       /* Issue a warning, though */
                       char symbol_name[1024];
                       strncpy(symbol_name, orig_symtab_ts->str,
                               orig_symtab_ts->len < 1024 ? orig_symtab_ts->len : 1024);
                        symbol_name[1023] = '\0';
                       tcc_warning("Internal inconsistency: could not find extended symbol table entry for %s; defaulting to previous value",
                               symbol_name);

                       highest_precedent_ts = orig_symtab_ts;
                       highest_precedent_symtab = orig_symtab;
               }
               /* Allocate new TokenSym and copy it over. */
               local_ts = tok_alloc_new(local_pts, highest_precedent_ts->str,
                       highest_precedent_ts->len);
               copy_extended_tokensym(highest_precedent_symtab, highest_precedent_ts,
                       local_ts);
       }
       return local_ts;
}
/* #endif CONFIG_TCC_EXSYMTAB */

#define PARSE2(c1, tok1, c2, tok2)              \
    case c1:                                    \
        PEEKC(c, p);                            \



( run in 0.883 second using v1.01-cache-2.11-cpan-f6376fbd888 )