KeySymbol::~KeySymbol() //--------------------- { WBRFree( _nameProg ); WBRFree( _contClassProg ); WBRFree( _contFunctionProg ); delete _fileFilter; }
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 ); } }
static int ClassLattice::deriveHook( dr_sym_type, dr_handle handle, char * name, dr_handle inheritHandle, void * obj ) //------------------------------------------------------------------------- { ClassLattice * addnode; dr_access effAccess; dr_access access; dr_virtuality virtuality; ClassLattice * me = (ClassLattice *) obj; access = DRGetAccess( inheritHandle ); virtuality = DRGetVirtuality( inheritHandle ); if( access > me->_effAccess ) { effAccess = access; } else { effAccess = me->_effAccess; } addnode = me->joinTo( handle, virtuality, effAccess, me->_level + 1 ); if( addnode != NULL ) { WBRFree( name ); } else { addnode = me->newLattice( handle, me->_module, name, me->_flatClasses, access, (dr_virtuality) VIRT_NOT_SET, me->_level + 1 ); } DerivationPtr * ptr = me->ClassLattice::newPtr( addnode, access, virtuality ); me->_deriveds.add( ptr ); return TRUE; }
static int ClassLattice::baseHook( dr_sym_type, dr_handle handle, char * name, dr_handle inheritHandle, void * obj ) //---------------------------------------------------------------------------- { dr_access access; dr_access effAccess; dr_virtuality virtuality; ClassLattice * addnode = NULL; ClassLattice * me = (ClassLattice *) obj; access = DRGetAccess( inheritHandle ); virtuality = DRGetVirtuality( inheritHandle ); if( access > me->_effAccess ) { effAccess = access; } else { effAccess = me->_effAccess; } addnode = me->joinTo( handle, virtuality, effAccess, me->_level - 1 ); if( addnode != NULL ) { WBRFree( name ); } else { // NYI - _module isn't necessarily what we want it to be! addnode = me->newLattice( handle, me->_module, name, me->_flatClasses, effAccess, virtuality, me->_level - 1 ); } DerivationPtr * ptr = me->newPtr( addnode, access, virtuality ); me->_bases.add( ptr ); return TRUE; }
static bool searchHook( dr_sym_context * symctxt, void *data ) //------------------------------------------------------------ { FindSymData * info; bool accept; Symbol * sym; info = (FindSymData *) data; if( symctxt->name == NULL ) { symctxt->name = DRGetName( symctxt->handle ); } accept = info->keysym->matches( symctxt ); if( accept ) { if( info->numItems == 0 ) { WBRFree( symctxt->name ); symctxt->name = NULL; info->context = new SearchContext( *symctxt->context ); return false; // <----- early return -- stop search } if( info->numItems > 0 ) { info->numItems -= 1; } sym = Symbol::defineSymbol( symctxt->type, symctxt->handle, symctxt->context->classhdl, info->call_module, symctxt->name ); info->data->add( sym ); #if DEBUG if( !(info->data->count() % 10) ) { WString stat; stat.printf( "Loading - %d found", info->data->count() ); browseTop->statusText( stat.gets() ); } #endif } else { WBRFree( symctxt->name ); } return true; // continue searching }
void KeySymbol::setSearchString( String & str, void ** prog, const char * name ) //------------------------------------------------------------ { WBRFree( *prog ); // free existing program str = name; // assign to the string try { *prog = WBRRegComp( name ); } catch( CauseOfDeath cause ) { IdentifyAssassin( cause ); } }
ClassLattice::~ClassLattice( void ) //--------------------------------- { int i; WBRFree( _name ); for( i = _bases.count(); i > 0; i -= 1 ) { delete _bases[ i - 1 ]; } _bases.reset(); for( i = _deriveds.count(); i > 0; i -= 1 ) { delete _deriveds[ i - 1 ]; } _deriveds.reset(); }
static bool referenceHook( drmem_hdl, dr_ref_info * refinfo, char * name, void * info ) //----------------------------------------------------------------------- { Reference * ref; WVList * list = (WVList *) info; for( int i = 0; i < list->count(); i++ ) { ref = (Reference *) (*list)[i]; if( ref->line() == refinfo->line && ref->column() == refinfo->column && strcmp( ref->sourceFile(), refinfo->file ) == 0 ) { WBRFree( name ); return true; } } list->add( new Reference( refinfo, name ) ); return true; // keep going }
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 }
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 }
bool Scanner::error( const char * err ) /*************************************/ { WString msg; WString title; char * name = _scanStream->name(); msgRetType ret; msg.printf( "%s near '%s'\n\nContinue?", err, _buffer ); title.printf( "Syntax error in %s", name ); ret = WMessageDialog::message( browseTop, MsgError, MsgOkCancel, msg, title ); WBRFree( name ); if( ret == MsgRetCancel ) { return true; } else { return false; } }
void DTViewClass::addDescriptions() //--------------------------------- // add the non-symbol lines { int i; ClassMember * mem; dr_access prevAccess = (dr_access) 0; dr_handle prevParent = _symbol->getHandle(); char * tmpName; WCPtrOrderedVector<ClassMember> desc; for( i = 0; i < _members->entries(); i += 1 ) { mem = (*_members)[ i ]; if( mem->_parent != prevParent ) { prevAccess = (dr_access) 0; prevParent = mem->_parent; if( mem->_parent ) { tmpName = DRGetName( mem->_parent ); } else { tmpName = NULL; } desc.append( new ClassMember( mem->_parent, (dr_access) 0, tmpName ) ); WBRFree( tmpName ); } if( mem->_access != prevAccess ) { prevAccess = mem->_access; desc.append( new ClassMember( mem->_parent, mem->_access, AccessStr[ mem->_access ] ) ); } } for( i = 0; i < desc.entries(); i += 1 ) { _members->insert( desc[ i ] ); } desc.clear(); // don't own elements, so don't destroy }
bool KeySymbol::matches( dr_sym_context * ctxt ) //---------------------------------------------- { bool accept; char * container; if( !(SymTypeConvert[ ctxt->type ] & _searchFor) ) { return( FALSE ); } if( !_anonymous ) { if( ctxt->name == NULL || *ctxt->name == 0 ) { return( FALSE ); } } if( !_artificial ) { if( DRIsArtificial( ctxt->handle ) ) { return( FALSE ); } } if( !_declaration ) { if( !DRIsSymDefined( ctxt->handle ) ) { return( FALSE ); } } if( _nameProg && ctxt->name ) { if( ctxt->name ) { if( !RegExec( (regexp *) _nameProg, ctxt->name, TRUE ) ) { return( FALSE ); } } else { if( !RegExec( (regexp *) _nameProg, "", TRUE ) ) { return( FALSE ); } } } if( _contClassProg ) { if( ctxt->context->classhdl ) { container = DRGetName( ctxt->context->classhdl ); if( container ) { accept = (bool) RegExec( (regexp *) _contClassProg, container, TRUE ); WBRFree( container ); if( !accept ) { return( FALSE ); } } else { if( !RegExec( (regexp *) _contClassProg, "", TRUE ) ) { return( FALSE ); } } } else { return( FALSE ); // not local to anything } } if( _contFunctionProg ) { if( ctxt->context->functionhdl ) { container = DRGetName( ctxt->context->functionhdl ); if( container ) { accept = (bool) RegExec( (regexp *) _contFunctionProg, container, TRUE ); WBRFree( container ); if( !accept ) { return( FALSE ); } } else { if( !RegExec( (regexp *) _contFunctionProg, "", TRUE ) ) { return( FALSE ); } } } else { return( FALSE ); // not local to anything } } if( !_fileFilter->matches( ctxt->handle ) ) { return FALSE; } return( TRUE ); }
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; }
TreeFuncNode::~TreeFuncNode() { WBRFree( _name ); WBRFree( _decName ); }
int Scanner::getToken( YYSTYPE & lval ) /*************************************/ { int c; int count; int fnd; bool flush = false; bool inquoted = false; bool escaped = false; if( _stutter ) { _stutter = false; return _lastToken; } c = _scanStream->get(); for(;;) { if( isspace( c ) ) { c = _scanStream->get(); } else if( strchr( StartComments, c ) ) { do { c = _scanStream->get(); } while( c != EOF && !strchr( EndComments, c ) ); c = _scanStream->get(); } else { break; } } if( c == '"' ) { inquoted = true; c = _scanStream->get(); // skip the quote } for( count = 0; ; count += 1 ) { if(( c == '\\' ) && ( _lookFor == LF_MagicString )) { c = _scanStream->get(); if( isspace( c )) { _scanStream->unget( c ); c = '\\'; } else { escaped = true; } } if( c == EOF ) { if( count == 0 ) { if( CurrentScanner > 0 ) { if( _lastToken == T_FileSync || _lastToken == EOF ) { delete this; return yylex(); } else { _lastToken = T_FileSync; return T_FileSync; } } else { return 0; // done } } else { flush = true; } } else if( inquoted && !escaped ) { if( c == '"' ) { c = _scanStream->get(); // skip the quote flush = true; } } else if( isspace( c ) || strchr( StartComments, c ) ) { flush = true; } else if( strchr( Special, c ) && !escaped ) { if( count == 0 ) { _lastToken = c; return c; } else { flush = true; } } if( count >= BufSize - 1 ) { flush = true; } if( flush ) { _scanStream->unget( c ); _buffer[ count ] = '\0'; if(( _lookFor != LF_String ) && ( _lookFor != LF_MagicString )) { fnd = tryToken( _lookFor, _buffer ); if( fnd > 0 ) { lval = fnd; return fnd; } else { if( _recovering ) { flush = false; count = -1; } else { WString msg; char * ambigs; ambigs = tryAmbig( _lookFor, _buffer ); if( ambigs != NULL ) { msg.printf( "[%s] is ambiguous -- try %s --", _buffer, ambigs ); WBRFree( ambigs ); } else { msg.printf( "Unrecognized symbol [%s]", _buffer ); } if( error( msg ) ) { return 0; } _recovering = true; flush = false; count = -1; } } } else { _stringTable.add( strdup( _buffer )); lval = _stringTable.count() - 1; if( _lookFor == LF_String ) { _lastToken = T_String; } else { _lastToken = T_MagicString; } return _lastToken; } } else { _buffer[ count ] = (char) c; } escaped = false; c = _scanStream->get(); } }
bool KeySymbol::matches( Symbol * sym ) //------------------------------------- // FIXME -- check the parent against both // functions and classes { bool accept; char * container; if( !(SymTypeConvert[ sym->symtype() ] & _searchFor) ) { return( FALSE ); } if( !_anonymous ) { if( sym->isAnonymous() ) { return( FALSE ); } } if( !_artificial ) { if( sym->isArtificial() ) { return( FALSE ); } } if( !_declaration ) { if( !sym->isDefined() ) { return( FALSE ); } } if( _nameProg ) { if( sym->name() ) { if( !RegExec( (regexp *) _nameProg, (char *) sym->name(), TRUE ) ) { return( FALSE ); } } else { if( !RegExec( (regexp *) _nameProg, "", TRUE ) ) { return( FALSE ); } } } if( _contClassProg ) { if( sym->getParent() ) { container = DRGetName( sym->getParent() ); if( container ) { accept = (bool) RegExec( (regexp *) _contClassProg, container, TRUE ); WBRFree( container ); if( !accept ) { return( FALSE ); } } else { if( !RegExec( (regexp *) _contClassProg, "", TRUE ) ) { return( FALSE ); } } } else { return( FALSE ); // not local to anything } } // NYI -- can't check for containing function as this is not // stored in the symbol if( !_fileFilter->matches( sym->getHandle() ) ) { return FALSE; } return( TRUE ); }