?? cfeinfo.c
字號:
char * pattern;
SYM_ENTRY sym;
struct aux_info * inf;
char * name;
inf = FindInfo( &sym, sym_handle );
#ifdef __SEH__
if( sym_handle == SymTryInit ||
sym_handle == SymTryFini ||
sym_handle == SymTryUnwind ||
sym_handle == SymExcept )
{
pattern = "*";
}
else
{
#endif
inf = LangInfo( sym.attrib, inf );
if( inf->objname != NULL )
{
pattern = inf->objname;
}
else if( ! (sym.flags & SYM_FUNCTION) )
{
pattern = "_*";
}
else
{
pattern = "*_"; /* for function names */
}
#ifdef __SEH__
} // close that else
#endif
name = sym.name;
if( ((sym.flags & SYM_FUNCTION)&&(sym.attrib & FLAG_LANGUAGES) == LANG_STDCALL)
&& CompFlags.use_stdcall_at_number)
{
int total_parm_size = 0;
int parm_size;
TYPEPTR fn_typ;
TYPEPTR *parm;
TYPEPTR typ;
fn_typ = sym.sym_type;
while( fn_typ->decl_type == TYPE_TYPEDEF )
fn_typ = fn_typ->object;
parm = fn_typ->u.parms;
if( parm != NULL )
{
for(; (typ = *parm); ++parm )
{
if( typ->decl_type == TYPE_DOT_DOT_DOT )
{
total_parm_size = -1;
break;
}
while( typ->decl_type == TYPE_TYPEDEF ) typ = typ->object;
if ( typ->decl_type == TYPE_VOID ) break;
parm_size = TypeSize( typ );
parm_size = (parm_size + sizeof(target_int) - 1) &
- sizeof(target_int);
total_parm_size += parm_size;
}
}
if( total_parm_size != -1 )
{
sprintf( Buffer, "%s@%d", name, total_parm_size );
name = Buffer;
}
}
*pat_ret = pattern; // return pattern string
return( name );
}
/*
// pass auxiliary information to back end
*/
VOIDPTR FEAuxInfo( CGSYM_HANDLE cgsym_handle, aux_class request )
{
SYM_HANDLE sym_handle = cgsym_handle;
struct aux_info * inf;
auto SYM_ENTRY sym;
static hw_reg_set save_set;
switch( request )
{
case SOURCE_LANGUAGE:
return( "C" );
case STACK_SIZE_8087:
return( (VOIDPTR)Stack87 );
case CODE_GROUP:
return( (VOIDPTR)GenCodeGroup );
case DATA_GROUP:
return( (VOIDPTR)DataSegName );
case OBJECT_FILE_NAME:
return( (VOIDPTR)ObjFileName( OBJ_EXT ) );
case TARGET_FILE_NAME:
return( (VOIDPTR)ForceSlash( CreateFileName( DependTarget
, OBJ_EXT, FALSE )
, DependForceSlash ) );
case DEPEND_FILE_NAME:
return( (VOIDPTR)DepFileName() );
case REVISION_NUMBER:
return( (VOIDPTR)II_REVISION );
case AUX_LOOKUP:
return( (VOIDPTR)sym_handle );
case PROEPI_DATA_SIZE:
return( (VOIDPTR)ProEpiDataSize );
case DBG_PREDEF_SYM:
return( (VOIDPTR)SymDFAbbr );
case P5_CHIP_BUG_SYM:
return( (VOIDPTR)SymChipBug ); /* 09-dec-94 */
case CODE_LABEL_ALIGNMENT:
{
static unsigned char Alignment[] = { 2, 1, 1 };
if( OptSize == 0 )
Alignment[1] = TARGET_INT;
return( Alignment );
}
case CLASS_NAME:
return( SegClassName( (unsigned)sym_handle ) );
case USED_8087:
CompFlags.pgm_used_8087 = 1;
return( NULL );
#if _CPU == 386
case P5_PROF_DATA:
return( (VOIDPTR)FunctionProfileBlock );
case P5_PROF_SEG:
return( (VOIDPTR)FunctionProfileSegment );
#endif
case SOURCE_NAME:
if( SrcFName == ModuleName )
{
return( FNameFullPath( FNames ) );
}
else
{
return( ModuleName );
}
case CALL_CLASS:
GetCallClass( sym_handle );
return( &CallClass );
case FREE_SEGMENT:
return( NULL );
case NEXT_LIBRARY:
case LIBRARY_NAME:
return( NextLibrary( (int)sym_handle, request ) );
case NEXT_IMPORT:
case IMPORT_NAME:
return( NextImport( (int)sym_handle, request ) );
case TEMP_LOC_NAME:
return( (char *)TEMP_LOC_QUIT );
case TEMP_LOC_TELL:
return( NULL );
case NEXT_DEPENDENCY: /* 03-dec-92 */
return( NextDependency( (FNAMEPTR) cgsym_handle ) );
break;
case DEPENDENCY_TIMESTAMP:
return( getFileDepTimeStamp( (FNAMEPTR) cgsym_handle ) );
case DEPENDENCY_NAME:
return( FNameFullPath( (FNAMEPTR) cgsym_handle ) );
case PEGGED_REGISTER:
return( SegPeggedReg( (unsigned)cgsym_handle ) );
default:
break;
}
inf = FindInfo( &sym, sym_handle );
switch( request )
{
case SAVE_REGS:
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
}
else
{
sym.attrib = 0;
}
save_set = inf->save;
if( sym.attrib & FLAG_SAVEREGS )
{
HW_CTurnOn( save_set, HW_SEGS );
}
#ifdef __SEH__
if( sym_handle == SymTryInit )
{
HW_CTurnOff( save_set, HW_SP );
}
#endif
return( &save_set );
case RETURN_REG:
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
}
return( &inf->returns );
case CALL_BYTES:
return( inf->code );
case PARM_REGS:
#ifdef __SEH__
if( sym_handle == SymTryInit ||
sym_handle == SymTryFini ||
sym_handle == SymTryUnwind ||
sym_handle == SymExcept )
{
return( TryParms );
}
#endif
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
if( inf->code == NULL && VarFunc( &sym ) )
{
return( DefaultVarParms );
}
}
return( inf->parms );
case STRETURN_REG:
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
}
return( &inf->streturn );
default:
break;
}
return( NULL );
}
#else
/*
// This section is NOT _MACHINE==_PC, i.e.,
// _ALPHA
// _PPC
//
// NextImport
// Called (indirectly) from the code generator to inject automagically defined symbols.
// Inputs:
// index (n-1)
// Usually called from a loop until we return 0/NULL to show no more symbols
// are required.
// request
// NEXT_IMPORT
// examines the current flags to see if any symbols should be
// automagically inserted and returns the relevant index if so.
// IMPORT_NAME
// returns the requested name. if we have returned an index for
// the current compiler settings we should be called with a valid
// index but we still perform exactly the same checks as this is
// good practise.
//
*/
static VOIDPTR NextImport( int index, aux_class request )
{
char *name;
if( request == NEXT_IMPORT )
++index;
/*-----------------------------------------------------------------------
// handle entry points
-----------------------------------------------------------------------*/
switch( index )
{
case 1:
/* wide char or MBCS entry */
if( CompFlags.has_wchar_entry )
{
name = "__DLLstartw_";
}
else
{
name = "__DLLstart_";
}
/* object has defined symbol (w)LibMain/(w)DllMain OR buildtarget == DLL*/
if( CompFlags.has_libmain || CompFlags.bd_switch_used )
break;
/* wide char or MBCS entry */
if( CompFlags.has_wchar_entry )
{
name = "_wstartw_";
}
else
{
name = "_wstart_";
}
/* symbol (w)WinMain defined */
if( CompFlags.has_winmain )
break;
/* wide char or MBCS entry */
if( CompFlags.has_wchar_entry )
{
name = "_cstartw_";
}
else
{
name = "_cstart_";
}
/* symbol (w)main defined */
if( CompFlags.has_main )
break;
++index;
/*-----------------------------------------------------------------------
// handle floating point support
-----------------------------------------------------------------------*/
case 2:
name = "_fltused_";
/* emit default library info OR -zlf emit all library info */
if( CompFlags.emit_library_with_main
|| CompFlags.emit_library_any )
{ /* 12-mar-90 */
if( CompFlags.float_used )
break;
}
++index;
/*-----------------------------------------------------------------------
// handle entry point arg passing
-----------------------------------------------------------------------*/
case 3:
name = "_argc";
/* does (w)main have any arguments (NOT int main(void)) */
if( CompFlags.main_has_parms )
break;
++index;
/*-----------------------------------------------------------------------
// handle default windowing app
-----------------------------------------------------------------------*/
case 4:
/* is target default windowing application? */
name = "__init_default_win";
if( CompFlags.bw_switch_used )
break;
++index;
/*-----------------------------------------------------------------------
// unknown / fallthrough
-----------------------------------------------------------------------*/
default:
index = 0; // indicate no more
name = NULL;
}
/*
// return the import name, or
*/
if( request == IMPORT_NAME )
return( name );
/*
// return the index
*/
return( (char *)index );
}
/*
// Return external name of symbol plus a pattern manipulator string
*/
extern char *FEExtName( CGSYM_HANDLE sym_handle, char **pat_ret )
{
char * pattern;
SYM_ENTRY sym;
struct aux_info * inf;
char * name;
inf = FindInfo( &sym, sym_handle );
#ifdef __SEH__
if( sym_handle == SymTryInit ||
sym_handle == SymTryFini ||
sym_handle == SymTryUnwind ||
sym_handle == SymExcept )
{
pattern = "*";
}
else
{
#endif
inf = LangInfo( sym.attrib, inf );
if( inf->objname != NULL )
{
pattern = inf->objname;
}
else
{
pattern = "*";
}
#ifdef __SEH__
} // close that else
#endif
name = sym.name;
*pat_ret = pattern; // return pattern string
return( name );
}
/*
// pass auxiliary information to back end
*/
VOIDPTR FEAuxInfo( CGSYM_HANDLE cgsym_handle, aux_class request )
{
SYM_HANDLE sym_handle = cgsym_handle;
struct aux_info * inf;
auto SYM_ENTRY sym;
static hw_reg_set save_set;
switch( request )
{
case SOURCE_LANGUAGE:
return( "C" );
case OBJECT_FILE_NAME:
return( (VOIDPTR)ObjFileName( OBJ_EXT ) );
case REVISION_NUMBER:
return( (VOIDPTR)II_REVISION );
case AUX_LOOKUP:
return( (VOIDPTR)sym_handle );
case SOURCE_NAME:
if( SrcFName == ModuleName )
{
return( FNameFullPath( FNames ) );
}
else
{
return( ModuleName );
}
case CALL_CLASS:
GetCallClass( sym_handle );
return( &CallClass );
case NEXT_LIBRARY:
case LIBRARY_NAME:
return( NextLibrary( (int)sym_handle, request ) );
case NEXT_IMPORT:
case IMPORT_NAME:
return( NextImport( (int)sym_handle, request ) );
case FREE_SEGMENT:
return( NULL );
case TEMP_LOC_NAME:
return( (char *)TEMP_LOC_QUIT );
case TEMP_LOC_TELL:
return( NULL );
case NEXT_DEPENDENCY: /* 03-dec-92 */
return( NextDependency( (FNAMEPTR) cgsym_handle ) );
break;
case DEPENDENCY_TIMESTAMP:
return( getFileDepTimeStamp( (FNAMEPTR) cgsym_handle ) );
case DEPENDENCY_NAME:
return( FNameFullPath( (FNAMEPTR) cgsym_handle ) );
}
inf = FindInfo( &sym, sym_handle );
switch( request )
{
case SAVE_REGS:
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
}
else
{
sym.attrib = 0;
}
save_set = inf->save;
return( &save_set );
case RETURN_REG:
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
}
return( &inf->returns );
case CALL_BYTES:
return( inf->code );
case PARM_REGS:
if( sym_handle != 0 )
{
inf = LangInfo( sym.attrib, inf );
if( inf->code == NULL && VarFunc( &sym ) )
{
return( DefaultVarParms );
}
}
return( inf->parms );
}
return( NULL );
}
#endif
extern char *SrcFullPath( char *buff, char const *name, unsigned max )
{
return _getFilenameFullPath( buff, name, max );
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -