static SYMBOL getSymInScope( // GET A SYMBOL IN A SCOPE SCOPE scope, // - the scope SYMBOL orig ) // - original symbol { SEARCH_RESULT *result; // - search result for symbol SYMBOL sym; // - the symbol arg_list *alist; // - arguments for function NAME name; // - symbol name name = orig->name->name; alist = SymFuncArgList( orig ); if( name == CppConversionName() ) { result = ScopeFindScopedMemberConversion( scope , scope , SymFuncReturnType( orig ) , alist->qualifier ); if( result == NULL ) { sym = NULL; } else { sym = result->sym; ScopeFreeResult( result ); if( sym != NULL ) { if( SymScope( sym ) != scope ) { sym = NULL; } } } } else { result = ScopeContainsMember( scope, name ); if( result == NULL ) { sym = NULL; } else { sym = result->sym_name->name_syms; // we may have found a type-name, so check for NULL if( sym != NULL && SymIsFunction( sym ) ) { switch( FuncOverloaded( &sym , result , sym , alist , NULL ) ) { case FNOV_NONAMBIGUOUS : break; default : sym = NULL; break; } } else { sym = NULL; } ScopeFreeResult( result ); } } return( sym ); }
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 {