?? cfeinfo.c
字號:
}
void GetCallClass( SYM_HANDLE sym_handle )
{
struct aux_info *inf;
auto SYM_ENTRY sym;
CallClass = DefaultInfo.class;
if( sym_handle != 0 )
{
inf = FindInfo( &sym, sym_handle );
if( sym.flags & SYM_FUNCTION )
{
switch( sym.attrib & FLAG_LANGUAGES )
{
case LANG_CDECL:
if( inf != &DefaultInfo )
{
CallClass = inf->class;
}
else
{
CallClass = CdeclInfo.class;
}
#if _CPU == 8086 /* 18-nov-94 */
if( TargSys == TS_WINDOWS )
{
CallClass |= FAT_WINDOWS_PROLOG;
}
#endif
break;
case LANG_PASCAL:
if( inf != &DefaultInfo )
{
CallClass = inf->class;
}
else
{
CallClass = PascalInfo.class;
}
#if _CPU == 8086 /* 21-jan-93 */
if( TargSys == TS_WINDOWS )
{ /* 01-mar-91 */
CallClass |= FAT_WINDOWS_PROLOG;
}
#endif
break;
case LANG_FORTRAN:
CallClass = FortranInfo.class;
break;
case LANG_SYSCALL:
CallClass = SyscallInfo.class;
break;
case LANG_STDCALL:
CallClass = StdcallInfo.class;
break;
case LANG_OPTLINK:
CallClass = OptlinkInfo.class;
break;
default:
CallClass = inf->class;
}
#if _MACHINE == _PC
if( CompFlags.emit_names )
{
CallClass |= EMIT_FUNCTION_NAME;
}
if( sym.attrib & FLAG_FAR )
{
CallClass |= FAR;
if( sym.attrib & FLAG_NEAR )
{
CallClass |= INTERRUPT;
}
}
else if( sym.attrib & FLAG_NEAR )
{
CallClass &= ~ FAR;
}
#endif
#ifdef DLL_EXPORT
if( sym.attrib & FLAG_EXPORT )
{ /* 12-mar-90 */
CallClass |= DLL_EXPORT;
}
#endif
#ifdef LOAD_DS_ON_ENTRY
if( sym.attrib & FLAG_LOADDS )
{ /* 26-apr-90 */
#if 0 /* John - 11-mar-93 */ /* 21-feb-93 */
if( TargSys == TS_WINDOWS )
{
CallClass |= FAT_WINDOWS_PROLOG;
}
else
{
CallClass |= LOAD_DS_ON_ENTRY;
}
#else
CallClass |= LOAD_DS_ON_ENTRY;
#endif
}
#endif
#ifdef MAKE_CALL_INLINE
if( IsInLineFunc( sym_handle ) )
{
CallClass |= MAKE_CALL_INLINE;
}
#endif
}
if( /* inf == &DefaultInfo && */ VarFunc( &sym ) )
{/* 19-dec-88*/
CallClass |= CALLER_POPS | HAS_VARARGS;
}
}
#ifdef REVERSE
CallClass &= ~ REVERSE_PARMS; /* 28-may-89 */
#endif
#if _MACHINE == _PC
if( sym.flags & SYM_FUNC_NEEDS_THUNK )
{
CallClass |= THUNK_PROLOG;
}
#endif
#ifdef PROLOG_HOOKS
if( CompFlags.ep_switch_used != 0 )
{
CallClass |= PROLOG_HOOKS;
}
#endif
#ifdef EPILOG_HOOKS
if( CompFlags.ee_switch_used != 0 )
{
CallClass |= EPILOG_HOOKS;
}
#endif
#ifdef GROW_STACK
if( CompFlags.sg_switch_used )
{
CallClass |= GROW_STACK;
}
#endif
#ifdef TOUCH_STACK
if( CompFlags.st_switch_used )
{
CallClass |= TOUCH_STACK;
}
#endif
}
static time_t *getFileDepTimeStamp( FNAMEPTR flist )
{
static time_t stamp;
#if _MACHINE == _PC && COMP_CFG_COFF == 0
stamp = _timet2dos( flist->mtime );
#else
stamp = flist->mtime;
#endif
return( &stamp );
}
#ifdef __LARGE__
#define PTR(x) (VOIDPTR)MK_FP((x),0)
#else
#define PTR(x) (VOIDPTR)(x)
#endif
static FNAMEPTR NextDependency( FNAMEPTR curr )
{
if( !CompFlags.emit_dependencies ) {
return( NULL );
}
if( curr == NULL ) {
curr = FNames;
} else {
curr = curr->next;
}
while( curr != NULL ) {
if( curr->rwflag && !SrcFileInRDir( curr ) )
break;
curr = curr->next;
}
return( curr );
}
/*
// NextLibrary
// 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 libraries
// request
// NEXT_LIBRARY
// examines the current flags to see if any libraries should be
// automagically referenced and returns the relevant index if so.
// LIBRARY_NAME
// returns the requested name.
//
*/
static VOIDPTR NextLibrary( int index, aux_class request )
{
struct library_list *liblist;
char *name = NULL;
int i;
i = 0;
if( request == NEXT_LIBRARY )
++index;
for( liblist = HeadLibs; liblist; liblist = liblist->next )
{
name = &liblist->prio;
++i;
if( i == index )
break;
}
if( liblist == NULL )
{
switch( index - i )
{
case 1: /* return 1 for CLIB */
name = CLIB_Name;
if( CompFlags.emit_library_any )
break;
if( CompFlags.emit_library_with_main )
{
if( CompFlags.has_main )
break;
if( CompFlags.has_winmain )
break;
if( CompFlags.bd_switch_used )
break;
if( CompFlags.has_libmain )
break;
if( CompFlags.bm_switch_used )
break; /* JBS */
++index;
}
else
{
name = NULL;
index = 0; // indicate all done
}
break;
/*
// MATHLIB is always referenced as a default library because
// the linker wont include anything without a 'real' referenced
// symbol
*/
case 2: /* return 2 for MATHLIB */
name = MATHLIB_Name;
break;
case 3: /* return 3 for EMULIB */
name = EmuLib_Name;
if( EmuLib_Name != NULL )
break;
++index;
case 4: /* return 4 for PCODE */
#ifdef __PCODE__
name = PcodeLib_Name;
if( CompFlags.pcode_generated )
break;
#endif
name = NULL;
index = 0; // indicate all done
}
}
/*
// return library name, or
*/
if( request == LIBRARY_NAME )
return( name );
/*
// library index
*/
return( (char *)index );
}
#if _MACHINE == _PC
/*
// 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(!CompFlags.emit_targimp_symbols)
return (NULL);
if( request == NEXT_IMPORT )
++index;
switch( index )
{
/*-----------------------------------------------------------------------
// handle entry points
-----------------------------------------------------------------------*/
case 1:
/* wide char or MBCS entry */
if( CompFlags.has_wchar_entry )
{
name = "__DLLstartw_";
}
else
{
name = "__DLLstart_";
}
if( CompFlags.bd_switch_used ) /* build target == DLL ? */
break;
if( CompFlags.has_libmain ) /* object has defined symbol (w)LibMain/(w)DllMain */
{ /* build target == console or gui application ? */
if( !(CompFlags.bc_switch_used || CompFlags.bg_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 )
{
/* gui application */
if( CompFlags.bg_switch_used )
break;
/* target == DLL or target == console*/
if( !(CompFlags.bd_switch_used || CompFlags.bc_switch_used ) )
break;
}
#if _CPU == 8086
/* is target windows AND symbol (w)main is defined */
if( TargetSwitches & WINDOWS && CompFlags.has_main )
break;
#endif
/* wide char or MBCS entry */
if( CompFlags.has_wchar_entry )
{
name = "_cstartw_";
}
else
{
name = "_cstart_";
}
/* is symbol (w)main is defined ? */
if( CompFlags.has_main )
{
/* build target == console ? */
if( CompFlags.bc_switch_used )
break;
/* target == DLL or target = GUI app ? */
if( !(CompFlags.bd_switch_used || CompFlags.bg_switch_used ) )
break;
}
++index;
/*-----------------------------------------------------------------------
// handle floating point support
-----------------------------------------------------------------------*/
case 2:
/* floating point used */
name = "_fltused_";
if( CompFlags.emit_library_with_main /* emit default library info? */
|| CompFlags.emit_library_any ) /* -zlf emit all library info? */
{ /* 12-mar-90 */
if( CompFlags.float_used ) /* has this object used any floating point code? */
break;
}
++index;
/*-----------------------------------------------------------------------
// handle code model library support
-----------------------------------------------------------------------*/
case 3:
#if _CPU == 8086
name = "_small_code_";
if( TargetSwitches & BIG_CODE ) /* big code model ? */
{
name = "_big_code_";
}
if( CompFlags.emit_library_with_main /* emit default library info? */
|| CompFlags.emit_library_any ) /* -zlf emit all library info? */
{ /* 12-mar-90 */
if( FirstStmt != 0 )
break;
}
#endif
++index;
/*-----------------------------------------------------------------------
// handle floating point emulator
-----------------------------------------------------------------------*/
case 4:
/* generating FPU instructions OR this object used floats ?*/
if( CompFlags.pgm_used_8087 || CompFlags.float_used )
{
#if _CPU == 386
name = "__init_387_emulator";
#else
name = "__init_87_emulator";
#endif
if( GET_FPU( ProcRevision ) & FPU_EMU ) /* using emulated FPU code? */
break;
}
++index;
/*-----------------------------------------------------------------------
// handle FPU requirement
-----------------------------------------------------------------------*/
case 5:
/* (emit default library info OR -zlf emit all library info) AND use backward compatible FPU code? */
if( (CompFlags.emit_library_with_main || CompFlags.emit_library_any )
&& Stack87 == 4 )
{
name = "__old_8087";
}
else
{
name = "__8087";
}
/* generating FPU instructions OR this object used floats? */
if( CompFlags.pgm_used_8087 || CompFlags.float_used )
{
if( GET_FPU(ProcRevision) > FPU_NONE )
break;
}
++index;
/*-----------------------------------------------------------------------
// handle entry point arg passing
-----------------------------------------------------------------------*/
case 6:
/* wide char or MBCS entry */
if( CompFlags.has_wchar_entry )
{
name = "__wargc";
}
else
{
name = "__argc";
}
#if _CPU == 386
/* NOT using register convention arg passing? */
if( ! CompFlags.register_conventions )
{
++name; // change from __wargc , __argc to _wargc..
}
#endif
/* does (w)main have any arguments (NOT int main(void)) */
if( CompFlags.main_has_parms )
break;
++index;
/*-----------------------------------------------------------------------
// handle default windowing app
-----------------------------------------------------------------------*/
case 7:
/* is target default windowing application? */
name = "__init_default_win";
if( CompFlags.bw_switch_used )
break;
++index;
/*-----------------------------------------------------------------------
// handle NetWare
-----------------------------------------------------------------------*/
case 8:
/* is target NETWARE or NETWARE5? */
name = "__WATCOM_Prelude";
if( TargSys == TS_NETWARE )
break;
if( TargSys == TS_NETWARE5 )
break;
++index;
/*-----------------------------------------------------------------------
// handle 'old' profiling
-----------------------------------------------------------------------*/
case 9:
/* is profiling enabled (-et)? */
name = "__p5_profile";
if( TargetSwitches & P5_PROFILING )
break;
/*-----------------------------------------------------------------------
// handle 'new' profiling
-----------------------------------------------------------------------*/
case 10:
/* is profiling enabled (-etp)? */
name = "__new_p5_profile";
if( TargetSwitches & NEW_P5_PROFILING )
break;
/*-----------------------------------------------------------------------
// 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 )
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -