Beispiel #1
0
local ENUMPTR EnumLkAdd( TAGPTR tag )
{
    ENUMPTR     esym;
    int         len;

    VfyNewSym( HashValue, Buffer );
    len = sizeof(ENUMDEFN) + strlen(Buffer);
    if( len > EnumRecSize ) EnumRecSize = len;
    esym = (ENUMPTR) CPermAlloc( len );
    strcpy( esym->name, Buffer );
    esym->parent = tag;
    esym->hash = HashValue;
    esym->src_loc = TokenLoc;
    esym->next_enum = EnumTable[ esym->hash ];
    ++EnumCount;
    if( tag->u.enum_list == NULL ) {
        tag->u.enum_list = esym;
    }
#if 0
    if( CompFlags.emit_browser_info ) {
        esym->xref = NewXref( NULL );
    }
#endif
    return( esym );
}
Beispiel #2
0
pch_status PCHReadSegments( void )
{
    char *src_suffix;
    char *dest_suffix;
    char *class_name;
    size_t class_name_len;
    size_t suffix_len;
    size_t len;
    size_t old_module_len;
    size_t curr_module_len;
    size_t extra;
    fe_seg_id sib_id;
    PC_SEGMENT *curr;

    curr_module_len = strlen( ModuleName );
    old_module_len = PCHReadUInt();
    extra = 0;
    if( curr_module_len > old_module_len ) {
        extra = curr_module_len - old_module_len;
    }
    PCHRead( &seg_max, sizeof( seg_max ) );
    PCHRead( &dgroup_size, sizeof( dgroup_size ) );
    RingFree( &seg_list );
    for(;;) {
        len = PCHReadUInt();
        if( len == 0 ) break;
        curr = CMemAlloc( len + extra );
        PCHRead( curr, len );
        if( curr->module_prefix ) {
            if( old_module_len != curr_module_len ) {
                suffix_len = len;
                suffix_len -= sizeof( PC_SEGMENT ) - sizeof( char );
                suffix_len -= old_module_len;
                src_suffix = &(curr->name[old_module_len]);
                dest_suffix = &(curr->name[curr_module_len]);
                memmove( dest_suffix, src_suffix, suffix_len );
            }
            memcpy( curr->name, ModuleName, curr_module_len );
        }
        curr->label = SymbolMapIndex( curr->label );
        class_name_len = (size_t) curr->class_name;
        if( class_name_len != 0 ) {
            class_name = CPermAlloc( class_name_len );
            PCHRead( class_name, class_name_len );
        } else {
            class_name = NULL;
        }
        curr->class_name = class_name;
        RingAppend( &seg_list, curr );
    }
    RingIterBeg( seg_list, curr ) {
        sib_id = (fe_seg_id) curr->sibling;
        if( sib_id != curr->seg_id ) {
            curr->sibling = segIdLookup( sib_id );
        } else {
            curr->sibling = curr;
        }
    }
Beispiel #3
0
char *strpermsave(              // ALLOCATE AND SAVE A STRING IN PERMANENT STORAGE
    const char *str )           // - source string
{
    size_t len;
    char *save;

    len = strlen( str );
    save = CPermAlloc( len + 1 );
    return( memcpy( save, str, len + 1 ) );
}
Beispiel #4
0
static void pushPrag( PRAG_STACK **h, unsigned value )
{
    PRAG_STACK *stack_entry;

    stack_entry = StackPop( &FreePrags );
    if( stack_entry == NULL ) {
        stack_entry = CPermAlloc( sizeof( *stack_entry ) );
    }
    stack_entry->value = value;
    StackPush( h, stack_entry );
}
Beispiel #5
0
void OpenErrFile( void )
{
    char        *name;

    if( SrcFName != NULL ) {
        name = ErrFileName();
        if( name != NULL ) {
            ErrFile = fopen( name, "w" );
            if( ErrFile != NULL ) {
                setvbuf( ErrFile, CPermAlloc( 32 ), _IOFBF, 32 );
            }
        }
    }
}
Beispiel #6
0
POOL_CON *ConPoolFloatAdd       // ADD AN ITEM TO THE CONSTANTS POOL
    ( PTREE node )              // - node for floating constant
{
    POOL_CON *pool;
    unsigned len;
    char *stg;
    auto char buff[128];

    len = PTreeGetFPRaw( node, buff, sizeof( buff ) );
    stg = CPermAlloc( len );
    stg = memcpy( stg, buff, len );
    pool = allocPoolCon( &pool_float );
    pool->u.s.len = len;
    pool->u.s.fp_constant = stg;
    pool->flt  = true;
    return( pool );
}
Beispiel #7
0
LINKAGE LinkageAdd( char *name, AUX_INFO *defn )
/**********************************************/
{
    LINKAGE p;
    size_t len;

    p = findLinkage( name );
    if( p != NULL ) {
        p->pragma = defn;
        return( p );
    }
    len = strlen( name );
    p = CPermAlloc( offsetof( linkage_name, name ) + len + 1 );
    memcpy( p->name, name, len + 1 );
    p->pragma = defn;
    p->next = validLinkages;
    validLinkages = p;
    return( p );
}
Beispiel #8
0
pch_status PCHReadConstantPool( void )
{
    unsigned len;
    POOL_CON *c;
    auto cvinit_t data;

    pool_float = ConstantPoolPCHRead();
    pool_int64 = ConstantPoolPCHRead();
    CarveInitStart( carvePOOL_CON, &data );
    for( ; (c = PCHReadCVIndexElement( &data )) != NULL; ) {
        PCHReadVar( *c );
        c->next = ConstantPoolMapIndex( c->next );
        if( c->flt ) {
            len = c->u.s.len;
            c->u.s.fp_constant = CPermAlloc( len );
            PCHRead( c->u.s.fp_constant, len );
        }
    }
    return( PCHCB_OK );
}
Beispiel #9
0
static NAME nameAdd( idname **head, unsigned bucket, unsigned xhash, const char *id, unsigned len )
{
    idname  *name;

#ifdef XTRA_RPT
    if( *head == NULL ) {
        ExtraRptIncrementCtr( ctr_chains );
    }
#endif
    ExtraRptIncrementCtr( ctr_names );
    DbgVerify( !nameFlags.no_creates_allowed, "name create occurred during precompiled header processing" );
    name = CPermAlloc( NAME_SIZE + len + 1 );
    memcpy( name->name, id, len + 1 );
    name->xhash = xhash;
    name->hash = bucket;
    name->next = *head;
    *head = name;
    ++nameCount;
    return( NAME_RETVAL( name ) );
}
Beispiel #10
0
pch_status PCHReadNames( void )
{
    unsigned len;
    idname **p;
    idname **head;
    idname *name;

    memset( hashTable, 0, sizeof( hashTable ) );
    PCHReadVar( nameCount );
    PCHReadVar( nameDummyIndex );
    nameTranslateTable = CMemAlloc( nameCount * sizeof( idname * ) );
    p = nameTranslateTable;
    for( ; (len = PCHReadUInt()) != 0; ) {
        name = CPermAlloc( NAME_SIZE + len + 1 );
        PCHRead( &(name->xhash), NAME_SIZE_PCH + len + 1 );
        head = &hashTable[ name->hash ];
        name->next = *head;
        *head = name;
        *p++ = name;
    }
    return( PCHCB_OK );
}