コード例 #1
0
static void fmtSymScope( SCOPE scope, VBUF *pvbuf, boolean include_function )
/***************************************************************************/
{
    TYPE    class_type;
    NAME    name;
    char    *sname;
    SYMBOL  sym;
    VBUF    prefix;

    while( scope != NULL ) {
        switch( scope->id ) {
        case SCOPE_FILE:
            sname = ScopeNameSpaceFormatName( scope );
            if( sname != NULL ) {
                VbufConcStrRev( pvbuf, scopeSep );
                VbufConcStrRev( pvbuf, sname );
            }
            break;
        case SCOPE_CLASS:
            class_type = ScopeClass( scope );
            name = SimpleTypeName( class_type );
            if( name != NULL ) {
                VbufConcStrRev( pvbuf, scopeSep );
                if( class_type->flag & TF1_INSTANTIATION ) {
                    fmtTemplateParms( pvbuf, class_type );
                }
                VbufConcStrRev( pvbuf, NameStr( name ) );
            }
            break;
        case SCOPE_FUNCTION:
            if( include_function ) {
                VbufInit( &prefix );
                sym = ScopeFunction( scope );
                formatScopedSym( sym, &prefix, FF_NULL );
                if( VbufLen( &prefix ) > 0 ) {
                    VbufConcStrRev( &prefix, functionDelim );
                    VbufPrepVbuf( pvbuf, &prefix );
                }
                VbufFree( &prefix );
            }
            return;             // function scope resolved on function name
        case SCOPE_BLOCK:
        case SCOPE_TEMPLATE_DECL:
        case SCOPE_TEMPLATE_INST:
        case SCOPE_TEMPLATE_PARM:
        case SCOPE_TEMPLATE_SPEC_PARM:
            break;
        case SCOPE_MAX:
        default:
            VbufConcStrRev( pvbuf, scopeSep );
            VbufConcStrRev( pvbuf, scopeError );
            break;
        }
        scope = scope->enclosing;
    }
}
コード例 #2
0
ファイル: fmtsym.c プロジェクト: Azarien/open-watcom-v2
static bool fmtSymName( SYMBOL sym, NAME name, VBUF *pvprefix, VBUF *pvbuf, FMT_CONTROL control )
/***********************************************************************************************/
// returns true if sym is CTOR/DTOR so that the caller drop the return type
{
    VBUF    prefix, suffix, op_name;
    CGOP    oper;
    bool    ctordtor = false;

    if( CppLookupOperatorName( name, &oper ) ) {
        switch( oper ) {
        case CO_CONVERT:
            if( sym == NULL ) {
                VbufConcStrRev( pvbuf, operatorSuffix );
                VbufConcStrRev( pvbuf, operatorUnknown );
            } else {
                fmtSymOpName( sym, &op_name );
                fmtSymFunction( sym, &prefix, &suffix, (FormatTypeDefault & ~FF_USE_VOID) | FF_DROP_RETURN );
                VbufConcVbufRev( pvbuf, &suffix );
                VbufConcVbuf( pvbuf, &op_name );
                VbufConcStrRev( pvbuf, operatorPrefix );
                VbufConcVbufRev( pvbuf, &prefix );
                VbufFree( &op_name );
                VbufFree( &prefix );
                VbufFree( &suffix );
            }
            break;
        case CO_CTOR:
            if( sym == NULL ) {
                VbufConcStrRev( pvbuf, constructorName );
            } else {
                name = SimpleTypeName( ScopeClass( SymScope( sym ) ) );
                ctordtor = true;
                fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault );
                VbufConcVbufRev( pvbuf, &suffix );
                if( name != NULL ) {
                    VbufConcStrRev( pvbuf, NameStr( name ) );
                }
                VbufConcVbufRev( pvprefix, &prefix );
                VbufFree( &prefix );
                VbufFree( &suffix );
            }
            break;
        case CO_DTOR:
            if( sym == NULL ) {
                VbufConcStrRev( pvbuf, destructorName );
            } else {
                name = SimpleTypeName( ScopeClass( SymScope( sym ) ) );
                ctordtor = true;
                fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault );
                VbufConcVbufRev( pvbuf, &suffix );
                if( name != NULL ) {
                    VbufConcStrRev( pvbuf, NameStr( name ) );
                }
                VbufConcStrRev( pvbuf, dtorPrefix );
                VbufConcVbufRev( pvprefix, &prefix );
                VbufFree( &prefix );
                VbufFree( &suffix );
            }
            break;
        default:
            if( sym == NULL ) {
                VbufConcStrRev( pvbuf, fmtSymCgop( oper ) );
                VbufConcStrRev( pvbuf, operatorPrefix );
            } else {
                fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault | control );
                VbufConcVbufRev( pvbuf, &suffix );
                VbufConcStrRev( pvbuf, fmtSymCgop( oper ) );
                VbufConcStrRev( pvbuf, operatorPrefix );
                VbufConcVbufRev( pvprefix, &prefix );
                VbufFree( &prefix );
                VbufFree( &suffix );
            }
            break;
        }
    } else if( sym != NULL ) {
        if( SymIsFunction( sym ) ) {
            fmtSymFunction( sym, &prefix, &suffix, FormatTypeDefault | control );
        } else if( !SymIsTypedef( sym ) ) {
            FormatType( sym->sym_type, &prefix, &suffix );
        } else {
            VbufInit( &prefix );
            VbufInit( &suffix );
        }
        VbufConcVbufRev( pvbuf, &suffix );
        if( name == NULL ) {
            VbufConcStrRev( pvbuf, nullSymname );
        } else {
            VbufConcStrRev( pvbuf, NameStr( name ) );
        }
        VbufConcVbufRev( pvprefix, &prefix );
        VbufFree( &prefix );
        VbufFree( &suffix );
    } else if( name != NULL ) {
        VbufConcStrRev( pvbuf, NameStr( name ) );
    } else {
        VbufConcStrRev( pvbuf, nullSymname );
    }
    return( ctordtor );
}