예제 #1
0
static SYMBOL segDefineLabel(   // DEFINE LABEL FOR SEGMENT, IF REQ'D
    PC_SEGMENT *seg )           // - current segment
{
    SYMBOL label;               // - reference symbol
    char *name;                 // - label's name
    SYMBOL func;                // - function being compiled

    label = seg->label;
    if( label == NULL ) {
        func = ScopeFunctionInProgress();
        if( ( func != NULL ) && ( func->segid == seg->seg_id ) ) {
            label = func;
        }
    }
    if( label == NULL ) {
        label = SymMakeDummy( GetBasicType( TYP_CHAR ), &name );
        label->segid = seg->seg_id;
        if( label->segid == SEG_STACK ) {
            label->id = SC_AUTO;
        } else {
            label->id = SC_STATIC;
            InsertSymbol( GetFileScope(), label, name );
        }
        seg->label = label;
        _markUsed( seg, TRUE );
    }
    return label;
}
예제 #2
0
static SYMBOL makeTemporary(    // ALLOCATE A TEMPORARY
    TYPE type,                  // - type of temporary
    boolean storage )           // - allocate storage if needed
{
    SYMBOL sym;                 // - symbol for temporary
    char *name;                 // - name for temporary
    symbol_class id;            // - class for symbol

#if 0
    if( ( type->id == TYP_POINTER ) && ( type->flag & TF1_REFERENCE ) ) {
        type = type->of;
    }
#endif
    sym = SymMakeDummy( type, &name );
    switch( tempClass ) {
      case TEMP_TYPE_EXPR :
      case TEMP_TYPE_BLOCK :
        id = SC_AUTO;
        break;
      case TEMP_TYPE_STATIC :
        id = SC_STATIC;
        break;
      DbgDefault( "makeTemporary -- bad tempClass" );
    }
    sym->id = id;
    if( id == SC_STATIC ) {
        ScopeInsert( GetFileScope(), sym, name );
        if( storage ) {
            CgSegIdData( sym, SI_ALL_ZERO );
            DgSymbol( sym );
        }
    } else {
        ScopeInsert( ScopeForTemps(), sym, name );
    }
    return sym;
}