static bool RefHook( dr_ref_info * reg, void * data )
/***************************************************/
{
    RefData * info = (RefData *) data;

    return( DRGetSymType( reg->dependent ) == info->search );
}
Exemple #2
0
bool KeySymbol::matches( dr_handle hdl, const char * name )
//---------------------------------------------------------
// perform a partial comparison (no containers)
{
    dr_sym_type type;

    type = DRGetSymType( hdl );
    if( !(SymTypeConvert[ type ] & _searchFor) ) {
        return( FALSE );
    }

    if( !_anonymous ) {
        if( name == NULL || *name == 0 ) {
            return( FALSE );
        }
    }

    if( !_artificial ) {
        if( DRIsArtificial( hdl ) ) {
            return( FALSE );
        }
    }

    if( !_declaration ) {
        if( !DRIsSymDefined( hdl ) ) {
            return( FALSE );
        }
    }

    if( _nameProg ) {
        if( name ) {
            if( !RegExec( (regexp *) _nameProg, (char *) name, TRUE ) ) {
                return( FALSE );
            }
        } else {
            if( !RegExec( (regexp *) _nameProg, "", TRUE ) ) {
                return( FALSE );
            }
        }
    }

    if( !_fileFilter->matches( hdl ) ) {
        return FALSE;
    }

    return( TRUE );
}
static bool FunctionSym::callHook( dr_handle, dr_ref_info * ref, char * name,
                                   void * info )
//---------------------------------------------------------------------------
{
    Symbol *         sym;
    callSearchData * data = (callSearchData *) info;
    dr_handle        other;
    dr_sym_type      stype;

    other = ref->dependent;
    stype = DRGetSymType( other );
    if( stype == DR_SYM_FUNCTION ) {
        sym = Symbol::defineSymbol(stype, other, DR_HANDLE_NUL, data->me->getModule(),name);
        data->list->add( sym );
    } else {
        WBRFree( name );
    }
    return TRUE;    // continue
}
Exemple #4
0
static bool refSymHook( drmem_hdl drhdl, dr_ref_info *, char * name,
                        void * info )
//-------------------------------------------------------------------
{
    RefSymData *data = (RefSymData *) info;
    dr_sym_type stype;
    Symbol *    sym;
    int         i;

    for( i = 0; i < data->list->count(); i += 1 ) {
        if( ((Symbol *)(*data->list)[ i ])->getHandle() == drhdl ) {
            WBRFree( name );
            return true;        // <---- early return
        }
    }

    stype = DRGetSymType( drhdl );
    sym = Symbol::defineSymbol( stype, drhdl, DRMEM_HDL_NULL, data->me, name );
    data->list->add( sym );

    return true;    // continue
}
Exemple #5
0
bool TreeFuncNode::TreeFuncHook( drmem_hdl owner, dr_ref_info * ref,
                                 char* ownerName, void * info )
//------------------------------------------------------------------
// this function really needs to be split up
{
    int             parentIndex;
    int             parentRoot;
    TreeFuncNode *  parent = NULL;
    int             childIndex;
    int             childRoot;
    TreeFuncNode *  child = NULL;
    FuncSearchData* data = (FuncSearchData *) info;
    char *          depName;
    bool            accept;

    #if DEBUG
    data->funcsFound += 1;

    if( !(data->funcsFound % 10) ) {
        WString stat;
        stat.printf( "Loading - %d found", data->funcsFound );
        browseTop->statusText( stat.gets() );
    }
    #endif

    // find if the symbol matches the filter

    depName = DRGetName( ref->dependent );
    accept = data->key->matches( ref->dependent, depName );
    WBRFree( depName ); // OPTIMIZE -- could use this later

    if( !accept ) {
        return true;    // <---- early return -- discard symbol, keep looking
    }


    for( int i = data->roots->count(); i > 0; i -= 1 ) {
        TreeFuncNode * rt = (TreeFuncNode*) (*data->roots)[ i - 1 ];
        parentIndex = rt->findNode( owner );
        if( !parent ) {
            if( parentIndex >= 0 ) {
                parent = (TreeFuncNode *)(*rt->_flatNodes)[ parentIndex ];
                parentRoot = i - 1;
            }
        }

        if( !child ) {
            childIndex = rt->findNode( ref->dependent );
            if( childIndex >= 0 ) {
                child = (TreeFuncNode *)(*rt->_flatNodes)[ childIndex ];
                childRoot = i - 1;
            }
        }

        if( child != NULL && parent != NULL ) {
            break;
        }
    }

    if( child != NULL && parent != NULL ) {
        WBRFree( ownerName );

        if( parentRoot == childRoot ) {
            int prtIdx = child->findParent( parent );
            if( prtIdx < 0 ) {
                if( ref->dependent == owner ) {     // direct recursion -- a->a
                    bool inReferences = false;

                    for( int refIdx = 0; refIdx < child->_flatReferences->count(); refIdx += 1 ) {
                        if( (*child->_flatReferences)[ refIdx ]->getHandle() == owner ) {
                            TreeNode * node = (*child->_flatReferences)[ refIdx ];
                            for( int ref2idx = 0; ref2idx < node->getCount( ParentList ); ref2idx += 1 ) {
                                if( node->getNode( ParentList, ref2idx )->getHandle() == owner ) {
                                    TreePtr * ptr = node->getPtr( ParentList, ref2idx );
                                    ((TreeRefPtr*)ptr)->incRefs();
                                    inReferences = true;
                                    break;
                                }
                            }
                        }
                        if( inReferences ) {
                            break;
                        }
                    }

                    if( !inReferences ) {
                        TreeRefNode * newRef;
                        newRef = new TreeRefNode( data->parentWin, parent, parent );
                        parent->_children.add( newRef );
                        parent->_hasRef = true;

                        parent->_flatReferences->add( newRef );
                    }
                } else {
                    parent->_children.add( child );
                    child->_parents.add(
                        new TreeFuncPtr( data->parentWin, child, parent, *ref ) );
                }
            } else {
                TreePtr * ptr = child->getPtr( ParentList, prtIdx );
                ((TreeFuncPtr *)ptr)->incRefs();
            }
        } else {
            int     i;

            for( i = child->_flatNodes->count(); i > 0; i -= 1 ) {
                parent->_flatNodes->add( (*child->_flatNodes)[ i - 1 ] );
            }

            data->roots->removeAt( childRoot );
            parent->_children.add( child );
            child->_parents.add(
                    new TreeFuncPtr( data->parentWin, child, parent, *ref ) );

            TreeCycleList * fList = child->_flatNodes;
            TreeRefList * rList = child->_flatReferences;

            for( i = fList->count(); i > 0; i -= 1 ) {
                TreeFuncNode * node = (TreeFuncNode *) (*fList)[ i - 1 ];
                node->_flatNodes = parent->_flatNodes;
                node->_flatReferences = parent->_flatReferences;
            }

            for( i = rList->count(); i > 0; i -= 1 ) {
                parent->_flatReferences->add( (*rList)[ i - 1 ] );
            }

            delete fList;
            delete rList;
        }
    } else {
        if( child != NULL ) {
            parent = new TreeFuncNode( data->parentWin, DRGetSymType( owner ),
                                       owner, data->mod, ownerName,
                                       child->_flatNodes,
                                       child->_flatReferences );

            parent->_children.add( child );
            child->_parents.add(
                    new TreeFuncPtr( data->parentWin, child, parent, *ref ) );
        } else {
            if( parent != NULL ) {
                WBRFree( ownerName );

                child = new TreeFuncNode( data->parentWin,
                                          DRGetSymType( ref->dependent ),
                                          ref->dependent, data->mod,
                                          DRGetName( ref->dependent ),
                                          parent->_flatNodes,
                                          parent->_flatReferences );
                parent->_children.add( child );
                child->_parents.add(
                    new TreeFuncPtr( data->parentWin, child, parent, *ref ) );

            } else {    // child == parent == NULL

                parent = new TreeFuncNode( data->parentWin,
                                           DRGetSymType( owner ),
                                           owner, data->mod, ownerName );

                if( ref->dependent == owner ) {
                    TreeRefNode * newRef;
                    newRef = new TreeRefNode( data->parentWin, parent, parent );
                    parent->_children.add( newRef );
                    parent->_hasRef = true;

                    parent->_flatReferences->add( newRef );
                } else {
                    child = new TreeFuncNode( data->parentWin,
                                              DRGetSymType( ref->dependent ),
                                              ref->dependent, data->mod,
                                              DRGetName( ref->dependent ),
                                              parent->_flatNodes,
                                              parent->_flatReferences );

                    child->_parents.add(
                        new TreeFuncPtr( data->parentWin, child, parent, *ref ) );
                    parent->_children.add( child );
                }

                data->roots->add( parent );
            }
        }
    }

    return true;
}