Exemple #1
0
TreeFuncNode::TreeFuncNode( TreeWindow * prt, dr_sym_type stp,
                            drmem_hdl drhdl, Module * mod, char * nm,
                            TreeCycleList * flatNode, TreeRefList * flatRef )
                :TreeCycleNode(prt, flatNode, flatRef )
                ,_symType(stp)
                ,_drhandle(drhdl)
                ,_module(mod)
                ,_name(nm)
                ,_decName(NULL)
//------------------------------------------------------------
{
    drmem_hdl   container;
    char *      name;
    String      accum;

    container = DRGetContaining( drhdl );
    if( container != DRMEM_HDL_NULL ) {
        accum = strrev( _name );
        strrev( _name );

        while( container != DRMEM_HDL_NULL ) {
            Symbol contSym( drhdl, NULL, mod, DRGetName( container ) );
            name = WBRStrDup( contSym.name() );
            accum += "::";
            accum += strrev( name );
            WBRFree( name );

            container = DRGetContaining( container );
        }

        _decName = WBRStrDup( (const char *)accum );
        strrev( _decName );
    }
}
char * ScanStreamFile::name( void )
//---------------------------------
{
    WString val;

    val.printf( "file \"%s\" (line %d)", _fileName, _line );
    return WBRStrDup( val );
}
ClassLattice::ClassLattice( Symbol * sym, bool relax )
        : _handle( sym->getHandle() )
        , _module( sym->getModule() )
        , _name( WBRStrDup( sym->name() ) )
        , _basesLoaded( FALSE )
        , _derivedsLoaded( FALSE )
        , _effAccess( (dr_access) 0 )
        , _virtual( VIRT_NOT_SET )
        , _relaxedVirt( relax )
        , _level( 0 )
//----------------------------------------------------
{
    _flatClasses = new ClassList;
    _flatClasses->add( this );
}
char * ClassLattice::derivation( ClassLattice *cls )
//--------------------------------------------------
{
    char            buf[ 18 ];  // long enough for "protected virtual"
    DerivationPtr * ptr;
    int             i;
    bool            found = FALSE;

    for( i = _deriveds.count(); i > 0 && !found; i -= 1 ) {
        ptr = _deriveds[ i - 1 ];
        if( cls == ptr->_class ) {
            found = TRUE;
        }
    }

    for( i = _bases.count(); i > 0 && !found; i -= 1 ) {
        ptr = _bases[ i - 1 ];
        if( cls == ptr->_class ) {
            found = TRUE;
        }
    }

    REQUIRE( found, "ClassLattice::derivation -- couldn't find cls!" );

    switch( ptr->_access ) {
    case DR_ACCESS_PUBLIC:
        strcpy( buf, "public" );
        break;
    case DR_ACCESS_PROTECTED:
        strcpy( buf, "protected" );
        break;
    default:
        REQUIRE( ptr->_access == DR_ACCESS_PRIVATE,
                 "ClassLattice::derivation -- _access out of range!" );
        buf[ 0 ] = '\0';
    }

    if( ptr->_virtuality != DR_VIRTUALITY_NONE ) {
        strcat( buf, " virtual" );
    }
    if( buf[0] != '\0' ) {
        return WBRStrDup( buf );
    }
    return NULL;
}
// Internal ctor, used to create non-root nodes
ClassLattice::ClassLattice( dr_handle hdl, Module * mod, char * name,
                            ClassList * vlist, dr_access acc,
                            dr_virtuality virt, bool relaxVirt, int level )
        : _handle( hdl )
        , _module( mod )
        , _name( name )
        , _basesLoaded( FALSE )
        , _derivedsLoaded( FALSE )
        , _flatClasses( vlist )
        , _effAccess( acc )
        , _virtual( (VirtLevel)virt )
        , _relaxedVirt(relaxVirt)
        , _level( level )
//-------------------------------------------------------------------------
{
    _flatClasses->add( this );

    if( _name == NULL ) {               /* OPTME this is expensive */
        Symbol * sym = makeSymbol();
        _name = WBRStrDup( sym->name() );
        delete sym;
    }
}
Exemple #6
0
Symbol * TreeFuncNode::makeSymbol( void )
//---------------------------------------
{
    char * name = WBRStrDup( _name );
    return Symbol::defineSymbol( _symType, _drhandle, DRMEM_HDL_NULL, _module, name );
}
Symbol * ClassLattice::makeSymbol( void )
//---------------------------------------
{
    char * name = WBRStrDup( _name );
    return Symbol::defineSymbol( DR_SYM_CLASS, _handle, 0L, _module, name );
}
char * ScanStreamMem::name( void )
//--------------------------------
{
    return WBRStrDup( "command line" );
}