// // SYMBOL-TABLE FUNCTIONS // void DumpSymbol( // DUMP SYMBOL ENTRY void *_sym ) // - symbol { SYMBOL sym = _sym; VBUF vbuf; static char const *ids[] = { #define SC_DEF(a) #a SC_DEFS #undef SC_DEF }; if( sym != NULL ) { printf( "SYMBOL" F_BADDR " next" F_PTR " thread" F_PTR " sym_type" F_PTR " name" F_PTR " cg_handle" F_PTR F_NL " u" F_PTR " id=" F_STRING " flag" F_HEX_1 " flag2" F_HEX_1 " segid" F_HEX_2 F_NL " symbol-name=" F_QSTRING F_EOL , sym , sym->next , sym->thread , sym->sym_type , sym->name , ( sym->flag2 & SF2_TOKEN_LOCN ) ? sym->locn->u.cg_handle : 0 , sym->u.tinfo , ids[sym->id] , sym->flag , sym->flag2 , sym->segid , FormatSym( sym, &vbuf ) ); if( sym->sym_type != NULL ) { DumpFullType( sym->sym_type ); } VbufFree( &vbuf ); if( sym->flag2 & SF2_TOKEN_LOCN ) { dumpLocation( &sym->locn->tl ); } switch( sym->id ) { case SC_CLASS_TEMPLATE: DumpTemplateInfo( sym->u.tinfo ); break; case SC_NAMESPACE: dumpNameSpaceInfo( sym->u.ns ); break; } } }
void PrintFnovResolution( FNOV_RESULT result, arg_list *args, /***********************************************************/ FNOV_LIST *match, FNOV_LIST *reject, SYMBOL sym ) // pseudo pretty display of overloaded ranking information { int length; VBUF name; if( sym != NULL ) { FormatSym( sym, &name ); } else if( match != NULL ) { FormatSym( match->sym, &name ); } else if( reject != NULL ) { FormatSym( reject->sym, &name ); } else { VbufInit( &name ); } printf( " Result: %s\n", resultNames[result] ); if( VbufLen( &name ) > 0 ) { printf( "Symbol: '%s'", VbufString( &name ) ); VbufFree( &name ); length = RingCount( match ) + RingCount( reject ); if( length > 0 ) { printf( " occurs %d time%s", length, (length != 1 ? "s " : " " ) ); } } printf( "\n" ); if( sym == NULL && args != NULL ) { printf( "Ranked Arguments:\n" ); printArgs( args ); } if( match != NULL ) { printf( "Matching Functions:\n" ); PrintFnovList( match ); } if( reject != NULL ) { printf( "Rejected Functions:\n" ); PrintFnovList( reject ); } }
void FormatTemplateParmScope( VBUF *parms, SCOPE parm_scope ) /***********************************************************/ { SYMBOL stop; SYMBOL curr; SYMBOL sym; const char *delim; TYPE type; auto VBUF sym_parm; auto VBUF type_parm_prefix; auto VBUF type_parm_suffix; VbufInit( parms ); if( parm_scope == NULL ) { makeUnknownTemplate( parms ); return; } delim = templateParmStart; curr = NULL; stop = ScopeOrderedStart( parm_scope ); for(;;) { curr = ScopeOrderedNext( stop, curr ); if( curr == NULL ) break; VbufConcStr( parms, delim ); type = curr->sym_type; if( SymIsConstantInt( curr ) ) { if( UnsignedIntType( type ) ) { VbufConcDecimal( parms, curr->u.uval ); } else { VbufConcInteger( parms, curr->u.sval ); } } else if( SymIsTypedef( curr ) ) { FormatType( type, &type_parm_prefix, &type_parm_suffix ); VbufTruncWhite( &type_parm_prefix ); VbufTruncWhite( &type_parm_suffix ); VbufConcVbuf( parms, &type_parm_prefix ); VbufConcVbuf( parms, &type_parm_suffix ); VbufFree( &type_parm_prefix ); VbufFree( &type_parm_suffix ); } else { sym = SymAddressOf( curr ); if( sym != NULL ) { FormatSym( sym, &sym_parm ); VbufConcVbuf( parms, &sym_parm ); VbufFree( &sym_parm ); } } delim = templateParmNext; } if( delim == templateParmStart ) { VbufConcStr( parms, templateParmStart ); } VbufConcStr( parms, templateParmStop ); }
char *DbgSymNameFull( // GET FULL SYMBOL NAME SYMBOL sym, // - symbol VBUF *vbuf ) // - variable-sized buffer { if( sym != NULL ) { return( FormatSym( sym, vbuf ) ); } VbufInit( vbuf ); VbufConcStr( vbuf, "**NULL**" ); return( VbufString( vbuf ) ); }
void PrintFnovList( FNOV_LIST *root ) /***********************************/ // pretty display of list of overloaded function rankings { int i; FNOV_LIST *entry; VBUF name; i = 1; RingIterBeg( root, entry ) { printf( "[%d]: '%s'", i++, FormatSym( entry->sym, &name ) ); VbufFree( &name ); if( entry->member || entry->stdops ) { printf( " flags=( " ); if( entry->member ) { printf( "member " ); } if( entry->stdops ) { printf( "stdops " ); } printf( ")" ); } printf( "\n" ); if( SymIsThisFuncMember( entry->sym ) ) { printRank( 1, &entry->thisrank, PRINT_THIS ); } if( entry->rankvector == NULL ) { printf( " (no rank available)\n" ); } else { if( entry->rankvector->control & FNC_RANK_RETURN ) { printRank( 1, entry->rankvector, PRINT_RETURN ); } else { printRank( entry->alist->num_args , entry->rankvector , PRINT_DEFAULT ); } } } RingIterEnd( entry )
SYMBOL FormatMsg( VBUF *pbuf, char *fmt, va_list arg ) /****************************************************/ // this function assumes that pbuf is initialized // all information is concatenated to the end of pbuf { VBUF prefix, suffix; char cfmt; char local_buf[ 1 + sizeof( int ) * 2 + 1 ]; unsigned len; SYMBOL retn_symbol; retn_symbol = NULL; cfmt = *fmt; while( cfmt ) { if( cfmt == '%' ) { fmt++; cfmt = *fmt; switch( cfmt ) { case '1': /* %01d */ case '2': /* %02d */ case '3': /* %03d */ case '4': /* %04d */ case '5': /* %05d */ case '6': /* %06d */ case '7': /* %07d */ case '8': /* %08d */ case '9': /* %09d */ len = sticpy( local_buf, va_arg( arg, int ) ) - local_buf; leading( pbuf, '0', ( cfmt - '0' ) - len ); VbufConcStr( pbuf, local_buf ); break; case 'c': /* %c */ VbufConcChr( pbuf, va_arg( arg, int ) ); break; case 's': /* %s */ VbufConcStr( pbuf, va_arg( arg, char * ) ); break; case 'u': /* %u */ VbufConcDecimal( pbuf, va_arg( arg, unsigned int ) ); break; case 'd': /* %d */ VbufConcInteger( pbuf, va_arg( arg, int ) ); break; case 'L': /* token location */ { TOKEN_LOCN *locn; locn = va_arg( arg, TOKEN_LOCN * ); if( locn == NULL ) { VbufConcStr( pbuf, "by compiler" ); } else { char *src_file = SrcFileName( locn->src_file ); if( src_file == NULL ) { VbufConcStr( pbuf, "on the command line" ); } else { if( ( CompFlags.ew_switch_used ) &&( locn->src_file == SrcFileTraceBackFile() ) ) { VbufConcStr( pbuf, "at: " ); } else { VbufConcStr( pbuf, "in: " ); VbufConcStr( pbuf, SrcFileName( locn->src_file ) ); } VbufConcChr( pbuf, '(' ); VbufConcInteger( pbuf, locn->line ); if( locn->column ) { if( CompFlags.ew_switch_used ) { VbufConcChr( pbuf, ',' ); VbufConcInteger( pbuf, locn->column ); } else { VbufConcStr( pbuf, ") (col " ); VbufConcInteger( pbuf, locn->column ); } } VbufConcChr( pbuf, ')' ); } } } break; case 'N': /* name */ FormatName( va_arg( arg, NAME ), &prefix ); VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); break; case 'F': /* symbol name (decorated) */ { SYMBOL sym; sym = va_arg( arg, SYMBOL ); FormatSym( sym, &prefix ); VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); } break; case 'S': /* symbol name (abbreviated) */ { SYMBOL sym; SYMBOL_NAME sn; NAME name; sym = va_arg( arg, SYMBOL ); if( sym == NULL ) { VbufConcStr( pbuf, "module data" ); } else { if( formatClassForSym( sym, pbuf ) ) { VbufConcStr( pbuf, "::" ); } if( SymIsCtor( sym ) ) { formatClassForSym( sym, pbuf ); } else if( SymIsDtor( sym ) ) { VbufConcChr( pbuf, '~' ); formatClassForSym( sym, pbuf ); } else { sn = sym->name; #ifndef NDEBUG if( sn == NULL ) { CFatal( "FormatMsg -- %S symbol has NULL SYMBOL_NAME" ); } #endif name = sn->name; #ifndef NDEBUG if( name == NULL ) { CFatal( "FormatMsg -- %S SYMBOL_NAME has NULL name" ); } #endif if( name == CppConversionName() ) { VbufConcStr( pbuf, "operator " ); FormatType( SymFuncReturnType( sym ) , &prefix , &suffix ); VbufFree( &suffix ); } else { FormatName( name, &prefix ); } VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); } if( sym->flag2 & SF2_TOKEN_LOCN ) { DbgVerify( retn_symbol == NULL, "too many symbols" ); retn_symbol = sym; } } } break; case 'T': /* type name */ { TYPE type = va_arg( arg, TYPE ); TYPE refed = TypeReference( type ); if( NULL != refed ) { type = refed; } FormatType( type, &prefix, &suffix ); VbufConcVbuf( pbuf, &prefix ); VbufConcVbuf( pbuf, &suffix ); VbufFree( &prefix ); VbufFree( &suffix ); VbufTruncWhite( pbuf ); if( NULL != refed ) { VbufConcStr( pbuf, " (lvalue)" ); } } break; case 'P': /* PTREE list */ { const PTREE p = va_arg( arg, PTREE ); FormatPTreeList( p, &prefix ); VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); } break; case 'I': /* PTREE id */ { const PTREE p = va_arg( arg, PTREE ); FormatPTreeId( p, &prefix ); VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); } break; case 'M': /* template info */ { TEMPLATE_INFO * const tinfo = va_arg( arg, TEMPLATE_INFO * ); const SYMBOL sym = tinfo->sym; FormatTemplateInfo( tinfo, &prefix ); VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); if( sym->flag2 & SF2_TOKEN_LOCN ) { DbgVerify( retn_symbol == NULL, "too many symbols" ); retn_symbol = sym; } } break; case 'C': /* template specialisation */ { TEMPLATE_SPECIALIZATION * const tspec = va_arg( arg, TEMPLATE_SPECIALIZATION * ); FormatTemplateSpecialization( tspec, &prefix ); VbufConcVbuf( pbuf, &prefix ); VbufFree( &prefix ); } break; default: VbufConcChr( pbuf, cfmt ); } } else {