2007-03-04 14:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapifs.h
* harbour/include/hbcompdf.h
* harbour/include/hbpp.h
* harbour/source/common/hbfsapi.c
* harbour/source/compiler/cmdcheck.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/hbusage.c
* harbour/source/compiler/ppcomp.c
* harbour/source/pp/ppcore.c
* cleanup .ppo file creation
+ new compiler switch: p+ to enable preprocessor tracing
when used information about applied rules is stored in .ppt file
* harbour/include/hbdefs.h
* harbour/source/rtl/gtos2/gtos2.c
* OS2 build cleanup
This commit is contained in:
@@ -8,6 +8,23 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2007-03-04 14:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbapifs.h
|
||||
* harbour/include/hbcompdf.h
|
||||
* harbour/include/hbpp.h
|
||||
* harbour/source/common/hbfsapi.c
|
||||
* harbour/source/compiler/cmdcheck.c
|
||||
* harbour/source/compiler/harbour.c
|
||||
* harbour/source/compiler/hbusage.c
|
||||
* harbour/source/compiler/ppcomp.c
|
||||
* harbour/source/pp/ppcore.c
|
||||
* cleanup .ppo file creation
|
||||
+ new compiler switch: p+ to enable preprocessor tracing
|
||||
when used information about applied rules is stored in .ppt file
|
||||
* harbour/include/hbdefs.h
|
||||
* harbour/source/rtl/gtos2/gtos2.c
|
||||
* OS2 build cleanup
|
||||
|
||||
2007-03-02 03:30 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/rdd/dbf1.c
|
||||
* harbour/source/rdd/delim1.c
|
||||
|
||||
@@ -167,7 +167,7 @@ typedef struct
|
||||
char szBuffer[ _POSIX_PATH_MAX + HB_MAX_DRIVE_LENGTH + 4 ];
|
||||
} HB_FNAME, * PHB_FNAME, * HB_FNAME_PTR;
|
||||
|
||||
extern HB_EXPORT PHB_FNAME hb_fsFNameSplit( char * pszFileName ); /* Split given filename into path, name and extension */
|
||||
extern HB_EXPORT PHB_FNAME hb_fsFNameSplit( const char * pszFileName ); /* Split given filename into path, name and extension */
|
||||
extern HB_EXPORT char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName ); /* This function joins path, name and extension into a string with a filename */
|
||||
|
||||
/* Searchable path support */
|
||||
|
||||
@@ -567,7 +567,6 @@ typedef struct _HB_COMP
|
||||
PFUNCTION pInitFunc;
|
||||
PHB_FNAME pMainFileName;
|
||||
PHB_FNAME pFileName;
|
||||
PHB_FNAME pFilePpo;
|
||||
PHB_FNAME pOutPath;
|
||||
PHB_FNAME pPpoPath;
|
||||
|
||||
@@ -604,6 +603,7 @@ typedef struct _HB_COMP
|
||||
BOOL fExit; /* force breaking compilation process */
|
||||
BOOL fQuiet; /* be quiet during compilation (-q) */
|
||||
BOOL fPPO; /* flag indicating, is ppo output needed */
|
||||
BOOL fPPT; /* flag indicating, is ppt output needed */
|
||||
BOOL fStartProc; /* holds if we need to create the starting procedure */
|
||||
BOOL fLineNumbers; /* holds if we need pcodes with line numbers */
|
||||
BOOL fAnyWarning; /* holds if there was any warning during the compilation process */
|
||||
|
||||
@@ -197,6 +197,21 @@
|
||||
#undef TRUE
|
||||
#define TRUE (!0)
|
||||
|
||||
#else /* HB_DONT_DEFINE_BASIC_TYPES */
|
||||
|
||||
/*
|
||||
* if HB_DONT_DEFINE_BASIC_TYPES excluded some types which are not
|
||||
* defined in included platform dependent header files then please
|
||||
* add necessary definitions here.
|
||||
*/
|
||||
|
||||
/* SCHAR is needed using GCC on OS/2 */
|
||||
#if ! defined( SCHAR )
|
||||
typedef signed char SCHAR; /* 1 byte signed */
|
||||
#endif
|
||||
|
||||
#endif /* HB_DONT_DEFINE_BASIC_TYPES */
|
||||
|
||||
#ifndef HB_LONG_LONG_OFF
|
||||
|
||||
#if ! defined(_WINNT_H)
|
||||
@@ -249,23 +264,9 @@
|
||||
#define LONGLONG_MIN (-LONGLONG_MAX - 1LL)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* HB_LONG_LONG_OFF */
|
||||
|
||||
#else /* HB_DONT_DEFINE_BASIC_TYPES */
|
||||
|
||||
/*
|
||||
* if HB_DONT_DEFINE_BASIC_TYPES excluded some types which are not
|
||||
* defined in included platform dependent header files then please
|
||||
* add necessary definitions here.
|
||||
*/
|
||||
|
||||
/* SCHAR is needed using GCC on OS/2 */
|
||||
#if ! defined( SCHAR )
|
||||
typedef signed char SCHAR; /* 1 byte signed */
|
||||
#endif
|
||||
|
||||
#endif /* HB_DONT_DEFINE_BASIC_TYPES */
|
||||
|
||||
/*
|
||||
* below are some hacks which don't have to be true on some machines
|
||||
* please update it if necessary
|
||||
|
||||
@@ -566,11 +566,14 @@ typedef struct
|
||||
int iHideStrings; /* hidden string mode */
|
||||
BOOL fTracePragmas; /* display information about set pragmas */
|
||||
BOOL fWritePreprocesed; /* write preprocessed data to file (.ppo) */
|
||||
BOOL fWriteTrace; /* write translation to file (.ppt) */
|
||||
|
||||
HB_PATHNAMES * pIncludePath; /* search path(s) for included files */
|
||||
|
||||
char * szOutFileName; /* output file name */
|
||||
FILE * file_out; /* output file handle */
|
||||
char * szTraceFileName; /* trace output file name */
|
||||
FILE * file_trace; /* trace output file handle */
|
||||
|
||||
BOOL fError; /* error during preprocessing */
|
||||
BOOL fQuiet; /* do not show standard information */
|
||||
@@ -578,7 +581,6 @@ typedef struct
|
||||
int iCondCount; /* number of nested #if[n]def directive */
|
||||
int iCondStackSize; /* size of conditional compilation stack */
|
||||
int * pCondStack; /* conditional compilation stack */
|
||||
FILE * file_in; /* file handle */
|
||||
|
||||
/* used to divide line per tokens and tokens manipulations */
|
||||
PHB_MEM_BUFFER pBuffer; /* buffer for input and output line */
|
||||
@@ -639,11 +641,13 @@ extern void hb_pp_setStream( PHB_PP_STATE pState, int iMode );
|
||||
extern void hb_pp_addSearchPath( PHB_PP_STATE pState, const char * szPath, BOOL fReplace );
|
||||
extern BOOL hb_pp_inFile( PHB_PP_STATE pState, char * szFileName, BOOL fSearchPath, FILE * file_in, BOOL fError );
|
||||
extern BOOL hb_pp_outFile( PHB_PP_STATE pState, char * szOutFileName, FILE * file_out );
|
||||
extern BOOL hb_pp_traceFile( PHB_PP_STATE pState, char * szTraceFileName, FILE * file_trace );
|
||||
extern char * hb_pp_fileName( PHB_PP_STATE pState );
|
||||
extern int hb_pp_line( PHB_PP_STATE pState );
|
||||
extern BOOL hb_pp_eof( PHB_PP_STATE pState );
|
||||
extern int hb_pp_lineTot( PHB_PP_STATE pState );
|
||||
extern char * hb_pp_outFileName( PHB_PP_STATE pState );
|
||||
extern char * hb_pp_traceFileName( PHB_PP_STATE pState );
|
||||
extern char * hb_pp_nextLine( PHB_PP_STATE pState, ULONG * pulLen );
|
||||
extern char * hb_pp_parseLine( PHB_PP_STATE pState, char * pLine, ULONG * pulLen );
|
||||
extern void hb_pp_addDefine( PHB_PP_STATE pState, char * szDefName, char * szDefValue );
|
||||
|
||||
@@ -110,7 +110,7 @@ void hb_fsFreeSearchPath( HB_PATHNAMES * pSearchList )
|
||||
}
|
||||
|
||||
/* Split given filename into path, name and extension, plus determine drive */
|
||||
PHB_FNAME hb_fsFNameSplit( char * pszFileName )
|
||||
PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
|
||||
{
|
||||
PHB_FNAME pFileName;
|
||||
char * pszPos;
|
||||
|
||||
@@ -419,23 +419,26 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch )
|
||||
|
||||
HB_COMP_PARAM->pOutPath = hb_fsFNameSplit( szPath );
|
||||
hb_xfree( szPath );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Added for preprocessor needs */
|
||||
case 'p':
|
||||
case 'P':
|
||||
if( *( s + 1 ) == '-' )
|
||||
HB_COMP_PARAM->fPPO = 0;
|
||||
else if( ! HB_COMP_PARAM->fPPO )
|
||||
if( s[ 1 ] == '+' && s[ 2 ] == '\0' )
|
||||
HB_COMP_PARAM->fPPT = TRUE;
|
||||
else if( s[ 1 ] == '-' && s[ 2 ] == '\0' )
|
||||
HB_COMP_PARAM->fPPO = FALSE;
|
||||
else
|
||||
{
|
||||
/* do not set a path if option specified more then once */
|
||||
char *szPath = hb_strdup( s + 1 );
|
||||
|
||||
HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( szPath );
|
||||
hb_xfree( szPath );
|
||||
|
||||
HB_COMP_PARAM->fPPO = 1;
|
||||
if( HB_COMP_PARAM->pPpoPath )
|
||||
{
|
||||
HB_COMP_PARAM->pPpoPath = NULL;
|
||||
hb_xfree( HB_COMP_PARAM->pPpoPath );
|
||||
}
|
||||
if( s[ 1 ] )
|
||||
HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( s + 1 );
|
||||
HB_COMP_PARAM->fPPO = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -4613,30 +4613,23 @@ static void hb_compGenOutput( HB_COMP_DECL, int iLanguage )
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_compPpoFile( HB_COMP_DECL )
|
||||
static void hb_compPpoFile( HB_COMP_DECL, const char * szPrg, const char * szExt,
|
||||
char * szPpoName )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compPpoFile()"));
|
||||
PHB_FNAME pFilePpo = hb_fsFNameSplit( szPrg );
|
||||
|
||||
HB_COMP_PARAM->pFilePpo->szPath = NULL;
|
||||
HB_COMP_PARAM->pFilePpo->szExtension = NULL;
|
||||
|
||||
/* we create the output file name */
|
||||
pFilePpo->szExtension = ( char * ) szExt;
|
||||
if( HB_COMP_PARAM->pPpoPath )
|
||||
{
|
||||
if( HB_COMP_PARAM->pPpoPath->szPath )
|
||||
HB_COMP_PARAM->pFilePpo->szPath = HB_COMP_PARAM->pPpoPath->szPath;
|
||||
|
||||
pFilePpo->szPath = HB_COMP_PARAM->pPpoPath->szPath;
|
||||
if( HB_COMP_PARAM->pPpoPath->szName )
|
||||
{
|
||||
HB_COMP_PARAM->pFilePpo->szName = HB_COMP_PARAM->pPpoPath->szName;
|
||||
/*
|
||||
if( HB_COMP_PARAM->pPpoPath->szExtension )
|
||||
HB_COMP_PARAM->pFilePpo->szExtension = HB_COMP_PARAM->pPpoPath->szExtension;
|
||||
else
|
||||
*/
|
||||
pFilePpo->szName = HB_COMP_PARAM->pPpoPath->szName;
|
||||
pFilePpo->szExtension = HB_COMP_PARAM->pPpoPath->szExtension;
|
||||
}
|
||||
HB_COMP_PARAM->pFilePpo->szExtension = ".ppo";
|
||||
}
|
||||
hb_fsFNameMerge( szPpoName, pFilePpo );
|
||||
hb_xfree( pFilePpo );
|
||||
}
|
||||
|
||||
static void hb_compOutputFile( HB_COMP_DECL )
|
||||
@@ -4675,216 +4668,210 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile )
|
||||
char szFileName[ _POSIX_PATH_MAX + 1 ]; /* filename to parse */
|
||||
char szPpoName[ _POSIX_PATH_MAX + 1 ];
|
||||
|
||||
/* Add /D command line or envvar defines */
|
||||
/* hb_compChkDefines( argc, argv ); */
|
||||
|
||||
/* Initialize support variables */
|
||||
hb_compInitVars( HB_COMP_PARAM );
|
||||
|
||||
/* Clear and reinitialize preprocessor state */
|
||||
hb_pp_reset( HB_COMP_PARAM->pLex->pPP );
|
||||
|
||||
if( !HB_COMP_PARAM->pFileName->szExtension )
|
||||
HB_COMP_PARAM->pFileName->szExtension = ".prg";
|
||||
|
||||
hb_fsFNameMerge( szFileName, HB_COMP_PARAM->pFileName );
|
||||
|
||||
if( HB_COMP_PARAM->fPPO && bSingleFile )
|
||||
if( !hb_pp_inFile( HB_COMP_PARAM->pLex->pPP, szFileName, FALSE, NULL, FALSE ) )
|
||||
{
|
||||
HB_COMP_PARAM->pFilePpo = hb_fsFNameSplit( szPrg );
|
||||
hb_compPpoFile( HB_COMP_PARAM );
|
||||
/*HB_COMP_PARAM->pFileName->szExtension = ".ppo";*/
|
||||
hb_fsFNameMerge( szPpoName, HB_COMP_PARAM->pFilePpo );
|
||||
if( !hb_pp_outFile( HB_COMP_PARAM->pLex->pPP, szPpoName, NULL ) )
|
||||
iStatus = EXIT_FAILURE;
|
||||
fprintf( hb_comp_errFile, "Cannot open input file: %s\n", szFileName );
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
else if( bSingleFile )
|
||||
{
|
||||
if( HB_COMP_PARAM->fPPT )
|
||||
{
|
||||
hb_compPpoFile( HB_COMP_PARAM, szPrg, ".ppt", szPpoName );
|
||||
if( !hb_pp_traceFile( HB_COMP_PARAM->pLex->pPP, szPpoName, NULL ) )
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->fPPO && iStatus == EXIT_SUCCESS )
|
||||
{
|
||||
hb_compPpoFile( HB_COMP_PARAM, szPrg, ".ppo", szPpoName );
|
||||
if( !hb_pp_outFile( HB_COMP_PARAM->pLex->pPP, szPpoName, NULL ) )
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if( iStatus == EXIT_SUCCESS )
|
||||
if( iStatus == EXIT_SUCCESS && !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
/* Add /D command line or envvar defines */
|
||||
/* hb_compChkDefines( argc, argv ); */
|
||||
BOOL bSkipGen = FALSE ;
|
||||
|
||||
/* Initialize support variables */
|
||||
hb_compInitVars( HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->szFile = HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
if( hb_pp_inFile( HB_COMP_PARAM->pLex->pPP, szFileName, FALSE, NULL, FALSE ) )
|
||||
if( bSingleFile )
|
||||
{
|
||||
BOOL bSkipGen = FALSE ;
|
||||
|
||||
HB_COMP_PARAM->szFile = HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
if( bSingleFile )
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
{
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
{
|
||||
if( HB_COMP_PARAM->fPPO )
|
||||
printf( "Compiling '%s' and generating preprocessed output to '%s'...\n", szFileName, szPpoName );
|
||||
else
|
||||
printf( "Compiling '%s'...\n", szFileName );
|
||||
}
|
||||
|
||||
/* Generate the starting procedure frame */
|
||||
if( HB_COMP_PARAM->fStartProc )
|
||||
{
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ), HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
}
|
||||
if( HB_COMP_PARAM->fPPO )
|
||||
printf( "Compiling '%s' and generating preprocessed output to '%s'...\n", szFileName, szPpoName );
|
||||
else
|
||||
{
|
||||
/* Don't pass the name of module if the code for starting procedure
|
||||
* will be not generated. The name cannot be placed as first symbol
|
||||
* because this symbol can be used as function call or memvar's name.
|
||||
*/
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
}
|
||||
printf( "Compiling '%s'...\n", szFileName );
|
||||
}
|
||||
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
hb_compCheckUnclosedStru( HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->pFilePpo )
|
||||
{
|
||||
hb_xfree( HB_COMP_PARAM->pFilePpo );
|
||||
HB_COMP_PARAM->pFilePpo = NULL;
|
||||
}
|
||||
/* Generate the starting procedure frame */
|
||||
if( HB_COMP_PARAM->fStartProc )
|
||||
{
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ), HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Reading '%s'...\n", szFileName );
|
||||
/* Don't pass the name of module if the code for starting procedure
|
||||
* will be not generated. The name cannot be placed as first symbol
|
||||
* because this symbol can be used as function call or memvar's name.
|
||||
*/
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
}
|
||||
|
||||
/* Open refernced modules (using DO ... WITh statement
|
||||
* or from @.clp command line option
|
||||
*/
|
||||
while( HB_COMP_PARAM->autoopen && !HB_COMP_PARAM->fExit )
|
||||
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
PAUTOOPEN pAutoOpen = HB_COMP_PARAM->autoopen;
|
||||
|
||||
if( ! hb_compFunctionFind( HB_COMP_PARAM, pAutoOpen->szName ) )
|
||||
hb_compAutoOpen( HB_COMP_PARAM, pAutoOpen->szName, &bSkipGen, bSingleFile );
|
||||
|
||||
HB_COMP_PARAM->autoopen = HB_COMP_PARAM->autoopen->pNext;
|
||||
hb_xfree( pAutoOpen );
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
hb_compCheckUnclosedStru( HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
/* Begin of finalization phase. */
|
||||
|
||||
/* fix all previous function returns offsets */
|
||||
hb_compFinalizeFunction( HB_COMP_PARAM );
|
||||
|
||||
hb_compExternGen( HB_COMP_PARAM ); /* generates EXTERN symbols names */
|
||||
|
||||
if( HB_COMP_PARAM->pInitFunc )
|
||||
{
|
||||
PCOMSYMBOL pSym;
|
||||
char szNewName[ 25 ];
|
||||
|
||||
/* Fix the number of static variables */
|
||||
HB_COMP_PARAM->pInitFunc->pCode[ 3 ] = HB_LOBYTE( HB_COMP_PARAM->iStaticCnt );
|
||||
HB_COMP_PARAM->pInitFunc->pCode[ 4 ] = HB_HIBYTE( HB_COMP_PARAM->iStaticCnt );
|
||||
HB_COMP_PARAM->pInitFunc->iStaticsBase = HB_COMP_PARAM->iStaticCnt;
|
||||
/* Update pseudo function name */
|
||||
snprintf( szNewName, sizeof( szNewName ), "(_INITSTATICS%05d)", HB_COMP_PARAM->iStaticCnt );
|
||||
HB_COMP_PARAM->pInitFunc->szName = hb_compIdentifierNew( HB_COMP_PARAM, szNewName, HB_IDENT_COPY );
|
||||
|
||||
pSym = hb_compSymbolAdd( HB_COMP_PARAM, HB_COMP_PARAM->pInitFunc->szName, NULL, HB_SYM_FUNCNAME );
|
||||
pSym->cScope |= HB_COMP_PARAM->pInitFunc->cScope;
|
||||
HB_COMP_PARAM->functions.pLast->pNext = HB_COMP_PARAM->pInitFunc;
|
||||
HB_COMP_PARAM->functions.pLast = HB_COMP_PARAM->pInitFunc;
|
||||
hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM );
|
||||
++HB_COMP_PARAM->functions.iCount;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->szAnnounce )
|
||||
hb_compAnnounce( HB_COMP_PARAM, HB_COMP_PARAM->szAnnounce );
|
||||
|
||||
/* End of finalization phase. */
|
||||
|
||||
if( HB_COMP_PARAM->iErrorCount || HB_COMP_PARAM->fAnyWarning )
|
||||
{
|
||||
if( HB_COMP_PARAM->iErrorCount )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
bSkipGen = TRUE;
|
||||
printf( "\r%i error%s\n\nNo code generated\n", HB_COMP_PARAM->iErrorCount, ( HB_COMP_PARAM->iErrorCount > 1 ? "s" : "" ) );
|
||||
}
|
||||
else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_SETEXIT )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_DELTARGET )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
bSkipGen = TRUE;
|
||||
printf( "\nNo code generated.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if( ! HB_COMP_PARAM->fSyntaxCheckOnly && ! bSkipGen &&
|
||||
HB_COMP_PARAM->iErrorCount == 0 )
|
||||
{
|
||||
char * szFirstFunction = NULL;
|
||||
PFUNCTION *pFunPtr;
|
||||
|
||||
/* we create the output file name */
|
||||
hb_compOutputFile( HB_COMP_PARAM );
|
||||
|
||||
pFunPtr = &HB_COMP_PARAM->functions.pFirst;
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
{
|
||||
/* skip first non-startup procedure */
|
||||
hb_compOptimizeFrames( HB_COMP_PARAM, *pFunPtr );
|
||||
pFunPtr = &(*pFunPtr)->pNext;
|
||||
HB_COMP_PARAM->iFunctionCnt--;
|
||||
}
|
||||
|
||||
while( *pFunPtr && !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
/* remove function frames with no names */
|
||||
if( ! HB_COMP_PARAM->fStartProc && ! (*pFunPtr)->szName[0] )
|
||||
{
|
||||
*pFunPtr = hb_compFunctionKill( HB_COMP_PARAM, *pFunPtr );
|
||||
HB_COMP_PARAM->functions.iCount--;
|
||||
HB_COMP_PARAM->iFunctionCnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_compOptimizeFrames( HB_COMP_PARAM, *pFunPtr );
|
||||
|
||||
if( szFirstFunction == NULL &&
|
||||
! ( ( *pFunPtr )->cScope & (HB_FS_INIT | HB_FS_EXIT) ) )
|
||||
{
|
||||
szFirstFunction = ( *pFunPtr )->szName;
|
||||
}
|
||||
pFunPtr = &(*pFunPtr)->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
if( szFirstFunction )
|
||||
{
|
||||
PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst;
|
||||
|
||||
while( pSym )
|
||||
{
|
||||
if( strcmp( pSym->szName, szFirstFunction ) == 0 )
|
||||
{
|
||||
pSym->cScope |= HB_FS_FIRST;
|
||||
break;
|
||||
}
|
||||
pSym = pSym->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
printf( "\rLines %i, Functions/Procedures %i\n", hb_pp_lineTot( HB_COMP_PARAM->pLex->pPP ), HB_COMP_PARAM->iFunctionCnt );
|
||||
|
||||
hb_compGenOutput( HB_COMP_PARAM, HB_COMP_PARAM->iLanguage );
|
||||
}
|
||||
hb_compCompileEnd( HB_COMP_PARAM );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( hb_comp_errFile, "Cannot open input file: %s\n", szFileName );
|
||||
printf( "Reading '%s'...\n", szFileName );
|
||||
}
|
||||
|
||||
/* printf( "No code generated\n" ); */
|
||||
iStatus = EXIT_FAILURE;
|
||||
/* Open refernced modules (using DO ... WITh statement
|
||||
* or from @.clp command line option
|
||||
*/
|
||||
while( HB_COMP_PARAM->autoopen && !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
PAUTOOPEN pAutoOpen = HB_COMP_PARAM->autoopen;
|
||||
|
||||
if( ! hb_compFunctionFind( HB_COMP_PARAM, pAutoOpen->szName ) )
|
||||
hb_compAutoOpen( HB_COMP_PARAM, pAutoOpen->szName, &bSkipGen, bSingleFile );
|
||||
|
||||
HB_COMP_PARAM->autoopen = HB_COMP_PARAM->autoopen->pNext;
|
||||
hb_xfree( pAutoOpen );
|
||||
}
|
||||
|
||||
/* Begin of finalization phase. */
|
||||
|
||||
/* fix all previous function returns offsets */
|
||||
hb_compFinalizeFunction( HB_COMP_PARAM );
|
||||
|
||||
hb_compExternGen( HB_COMP_PARAM ); /* generates EXTERN symbols names */
|
||||
|
||||
if( HB_COMP_PARAM->pInitFunc )
|
||||
{
|
||||
PCOMSYMBOL pSym;
|
||||
char szNewName[ 25 ];
|
||||
|
||||
/* Fix the number of static variables */
|
||||
HB_COMP_PARAM->pInitFunc->pCode[ 3 ] = HB_LOBYTE( HB_COMP_PARAM->iStaticCnt );
|
||||
HB_COMP_PARAM->pInitFunc->pCode[ 4 ] = HB_HIBYTE( HB_COMP_PARAM->iStaticCnt );
|
||||
HB_COMP_PARAM->pInitFunc->iStaticsBase = HB_COMP_PARAM->iStaticCnt;
|
||||
/* Update pseudo function name */
|
||||
snprintf( szNewName, sizeof( szNewName ), "(_INITSTATICS%05d)", HB_COMP_PARAM->iStaticCnt );
|
||||
HB_COMP_PARAM->pInitFunc->szName = hb_compIdentifierNew( HB_COMP_PARAM, szNewName, HB_IDENT_COPY );
|
||||
|
||||
pSym = hb_compSymbolAdd( HB_COMP_PARAM, HB_COMP_PARAM->pInitFunc->szName, NULL, HB_SYM_FUNCNAME );
|
||||
pSym->cScope |= HB_COMP_PARAM->pInitFunc->cScope;
|
||||
HB_COMP_PARAM->functions.pLast->pNext = HB_COMP_PARAM->pInitFunc;
|
||||
HB_COMP_PARAM->functions.pLast = HB_COMP_PARAM->pInitFunc;
|
||||
hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM );
|
||||
++HB_COMP_PARAM->functions.iCount;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->szAnnounce )
|
||||
hb_compAnnounce( HB_COMP_PARAM, HB_COMP_PARAM->szAnnounce );
|
||||
|
||||
/* End of finalization phase. */
|
||||
|
||||
if( HB_COMP_PARAM->iErrorCount || HB_COMP_PARAM->fAnyWarning )
|
||||
{
|
||||
if( HB_COMP_PARAM->iErrorCount )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
bSkipGen = TRUE;
|
||||
printf( "\r%i error%s\n\nNo code generated\n", HB_COMP_PARAM->iErrorCount, ( HB_COMP_PARAM->iErrorCount > 1 ? "s" : "" ) );
|
||||
}
|
||||
else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_SETEXIT )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_DELTARGET )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
bSkipGen = TRUE;
|
||||
printf( "\nNo code generated.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if( ! HB_COMP_PARAM->fSyntaxCheckOnly && ! bSkipGen &&
|
||||
HB_COMP_PARAM->iErrorCount == 0 )
|
||||
{
|
||||
char * szFirstFunction = NULL;
|
||||
PFUNCTION *pFunPtr;
|
||||
|
||||
/* we create the output file name */
|
||||
hb_compOutputFile( HB_COMP_PARAM );
|
||||
|
||||
pFunPtr = &HB_COMP_PARAM->functions.pFirst;
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
{
|
||||
/* skip first non-startup procedure */
|
||||
hb_compOptimizeFrames( HB_COMP_PARAM, *pFunPtr );
|
||||
pFunPtr = &(*pFunPtr)->pNext;
|
||||
HB_COMP_PARAM->iFunctionCnt--;
|
||||
}
|
||||
|
||||
while( *pFunPtr && !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
/* remove function frames with no names */
|
||||
if( ! HB_COMP_PARAM->fStartProc && ! (*pFunPtr)->szName[0] )
|
||||
{
|
||||
*pFunPtr = hb_compFunctionKill( HB_COMP_PARAM, *pFunPtr );
|
||||
HB_COMP_PARAM->functions.iCount--;
|
||||
HB_COMP_PARAM->iFunctionCnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_compOptimizeFrames( HB_COMP_PARAM, *pFunPtr );
|
||||
|
||||
if( szFirstFunction == NULL &&
|
||||
! ( ( *pFunPtr )->cScope & (HB_FS_INIT | HB_FS_EXIT) ) )
|
||||
{
|
||||
szFirstFunction = ( *pFunPtr )->szName;
|
||||
}
|
||||
pFunPtr = &(*pFunPtr)->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
if( szFirstFunction )
|
||||
{
|
||||
PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst;
|
||||
|
||||
while( pSym )
|
||||
{
|
||||
if( strcmp( pSym->szName, szFirstFunction ) == 0 )
|
||||
{
|
||||
pSym->cScope |= HB_FS_FIRST;
|
||||
break;
|
||||
}
|
||||
pSym = pSym->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
printf( "\rLines %i, Functions/Procedures %i\n", hb_pp_lineTot( HB_COMP_PARAM->pLex->pPP ), HB_COMP_PARAM->iFunctionCnt );
|
||||
|
||||
hb_compGenOutput( HB_COMP_PARAM, HB_COMP_PARAM->iLanguage );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4894,7 +4881,7 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile )
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return iStatus;
|
||||
return HB_COMP_PARAM->fExit ? EXIT_FAILURE : iStatus;
|
||||
}
|
||||
|
||||
static void hb_compCompileEnd( HB_COMP_DECL )
|
||||
@@ -4915,12 +4902,6 @@ static void hb_compCompileEnd( HB_COMP_DECL )
|
||||
HB_COMP_PARAM->pFileName = NULL;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->pFilePpo )
|
||||
{
|
||||
hb_xfree( HB_COMP_PARAM->pFilePpo );
|
||||
HB_COMP_PARAM->pFilePpo = NULL;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->functions.pFirst )
|
||||
{
|
||||
PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst;
|
||||
@@ -5055,72 +5036,69 @@ static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * pbSkipGen, BOOL b
|
||||
|
||||
hb_fsFNameMerge( szFileName, HB_COMP_PARAM->pFileName );
|
||||
|
||||
if( HB_COMP_PARAM->fPPO )
|
||||
if( !hb_pp_inFile( HB_COMP_PARAM->pLex->pPP, szFileName, FALSE, NULL, FALSE ) )
|
||||
{
|
||||
fprintf( hb_comp_errFile, "Cannot open %s, assumed external\n", szFileName );
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
else if( HB_COMP_PARAM->fPPT )
|
||||
{
|
||||
HB_COMP_PARAM->pFileName->szExtension = ".ppt";
|
||||
hb_fsFNameMerge( szPpoName, HB_COMP_PARAM->pFileName );
|
||||
if( !hb_pp_traceFile( HB_COMP_PARAM->pLex->pPP, szPpoName, NULL ) )
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
if( HB_COMP_PARAM->fPPO && iStatus == EXIT_SUCCESS )
|
||||
{
|
||||
HB_COMP_PARAM->pFileName->szExtension = ".ppo";
|
||||
hb_fsFNameMerge( szPpoName, HB_COMP_PARAM->pFileName );
|
||||
|
||||
if( !hb_pp_outFile( HB_COMP_PARAM->pLex->pPP, szPpoName, NULL ) )
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( iStatus == EXIT_SUCCESS && !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
/* Minimal Init. */
|
||||
if( hb_pp_inFile( HB_COMP_PARAM->pLex->pPP, szFileName, FALSE, NULL, FALSE ) )
|
||||
HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
{
|
||||
HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
{
|
||||
if( HB_COMP_PARAM->fPPO )
|
||||
printf( "Compiling module '%s' and generating preprocessed output to '%s'...\n", szFileName, szPpoName );
|
||||
else
|
||||
printf( "Compiling module '%s'...\n", szFileName );
|
||||
}
|
||||
|
||||
/* Generate the starting procedure frame */
|
||||
if( HB_COMP_PARAM->fStartProc )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ), HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
else if( ! bSingleFile )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
int i = HB_COMP_PARAM->iExitLevel ;
|
||||
BOOL b = HB_COMP_PARAM->fAnyWarning;
|
||||
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
|
||||
HB_COMP_PARAM->iExitLevel = ( i > HB_COMP_PARAM->iExitLevel ? i : HB_COMP_PARAM->iExitLevel );
|
||||
HB_COMP_PARAM->fAnyWarning = ( b ? b : HB_COMP_PARAM->fAnyWarning );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->pFilePpo )
|
||||
{
|
||||
hb_xfree( HB_COMP_PARAM->pFilePpo );
|
||||
HB_COMP_PARAM->pFilePpo = NULL;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->fAnyWarning )
|
||||
{
|
||||
if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_SETEXIT )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_DELTARGET )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
*pbSkipGen = TRUE;
|
||||
printf( "\nNo code generated.\n" );
|
||||
}
|
||||
}
|
||||
if( HB_COMP_PARAM->fPPO )
|
||||
printf( "Compiling module '%s' and generating preprocessed output to '%s'...\n", szFileName, szPpoName );
|
||||
else
|
||||
printf( "Compiling module '%s'...\n", szFileName );
|
||||
}
|
||||
else
|
||||
|
||||
/* Generate the starting procedure frame */
|
||||
if( HB_COMP_PARAM->fStartProc )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ), HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
else if( ! bSingleFile )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
fprintf( hb_comp_errFile, "Cannot open %s, assumed external\n", szFileName );
|
||||
int i = HB_COMP_PARAM->iExitLevel ;
|
||||
BOOL b = HB_COMP_PARAM->fAnyWarning;
|
||||
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
|
||||
HB_COMP_PARAM->iExitLevel = ( i > HB_COMP_PARAM->iExitLevel ? i : HB_COMP_PARAM->iExitLevel );
|
||||
HB_COMP_PARAM->fAnyWarning = ( b ? b : HB_COMP_PARAM->fAnyWarning );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->fAnyWarning )
|
||||
{
|
||||
if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_SETEXIT )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_DELTARGET )
|
||||
{
|
||||
iStatus = EXIT_FAILURE;
|
||||
*pbSkipGen = TRUE;
|
||||
printf( "\nNo code generated.\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ void hb_compPrintUsage( char * szSelf )
|
||||
"\n 1=no starting procedure at all",
|
||||
"\n %co<path> object file drive and/or path",
|
||||
"\n %cp[<path>] generate pre-processed output (.ppo) file",
|
||||
"\n %cp+ generate pre-processor trace (.ppt) file",
|
||||
"\n %cq quiet",
|
||||
"\n %cq0 quiet and don't display program header",
|
||||
"\n %cr=<max> set maximum number of preprocessor iterations",
|
||||
@@ -97,7 +98,7 @@ void hb_compPrintUsage( char * szSelf )
|
||||
"\n %cy trace lex & yacc activity",
|
||||
#endif
|
||||
"\n %cz suppress shortcutting (.and. & .or.)",
|
||||
/* TODO: "\n @<file> compile list of modules in <file>", */
|
||||
"\n @<file> compile list of modules in <file>",
|
||||
"\n"
|
||||
};
|
||||
|
||||
|
||||
@@ -158,6 +158,8 @@ static BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch,
|
||||
iValue == HB_EXITLEVEL_SETEXIT ||
|
||||
iValue == HB_EXITLEVEL_DELTARGET ) )
|
||||
HB_COMP_PARAM->iExitLevel = iValue;
|
||||
else if( hb_stricmp( szSwitch, "p+" ) == 0 )
|
||||
HB_COMP_PARAM->fPPT = iValue != 0;
|
||||
else
|
||||
fError = TRUE;
|
||||
}
|
||||
@@ -203,10 +205,4 @@ void hb_compInitPP( HB_COMP_DECL, int argc, char * argv[] )
|
||||
/* mark current rules as standard ones */
|
||||
hb_pp_setStdBase( HB_COMP_PARAM->pLex->pPP );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->pFileName )
|
||||
{
|
||||
hb_xfree( ( void * ) HB_COMP_PARAM->pFileName );
|
||||
HB_COMP_PARAM->pFileName = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1690,6 +1690,17 @@ static void hb_pp_FileFree( PHB_PP_STATE pState, PHB_PP_FILE pFile,
|
||||
hb_xfree( pFile );
|
||||
}
|
||||
|
||||
static void hb_pp_InFileFree( PHB_PP_STATE pState )
|
||||
{
|
||||
while( pState->pFile )
|
||||
{
|
||||
PHB_PP_FILE pFile = pState->pFile;
|
||||
pState->pFile = pFile->pPrev;
|
||||
hb_pp_FileFree( pState, pFile, pState->pCloseFunc );
|
||||
}
|
||||
pState->iFiles = 0;
|
||||
}
|
||||
|
||||
static void hb_pp_OutFileFree( PHB_PP_STATE pState )
|
||||
{
|
||||
if( pState->file_out )
|
||||
@@ -1705,15 +1716,19 @@ static void hb_pp_OutFileFree( PHB_PP_STATE pState )
|
||||
pState->fWritePreprocesed = FALSE;
|
||||
}
|
||||
|
||||
static void hb_pp_InFileFree( PHB_PP_STATE pState )
|
||||
static void hb_pp_TraceFileFree( PHB_PP_STATE pState )
|
||||
{
|
||||
while( pState->pFile )
|
||||
if( pState->file_trace )
|
||||
{
|
||||
PHB_PP_FILE pFile = pState->pFile;
|
||||
pState->pFile = pFile->pPrev;
|
||||
hb_pp_FileFree( pState, pFile, pState->pCloseFunc );
|
||||
fclose( pState->file_trace );
|
||||
pState->file_trace = NULL;
|
||||
}
|
||||
pState->iFiles = 0;
|
||||
if( pState->szTraceFileName )
|
||||
{
|
||||
hb_xfree( pState->szTraceFileName );
|
||||
pState->szTraceFileName = NULL;
|
||||
}
|
||||
pState->fWriteTrace = FALSE;
|
||||
}
|
||||
|
||||
static PHB_PP_STATE hb_pp_stateNew( void )
|
||||
@@ -1735,6 +1750,7 @@ static void hb_pp_stateFree( PHB_PP_STATE pState )
|
||||
{
|
||||
hb_pp_InFileFree( pState );
|
||||
hb_pp_OutFileFree( pState );
|
||||
hb_pp_TraceFileFree( pState );
|
||||
|
||||
if( pState->pIncludePath )
|
||||
hb_fsFreeSearchPath( pState->pIncludePath );
|
||||
@@ -1909,22 +1925,30 @@ static BOOL hb_pp_setCompilerSwitch( PHB_PP_STATE pState, char * szSwitch,
|
||||
{
|
||||
BOOL fError = TRUE;
|
||||
|
||||
if( strlen( szSwitch ) == 1 )
|
||||
switch( szSwitch[ 0 ] )
|
||||
{
|
||||
switch( szSwitch[ 0 ] )
|
||||
{
|
||||
case 'p':
|
||||
case 'P':
|
||||
case 'p':
|
||||
case 'P':
|
||||
if( szSwitch[ 1 ] == '\0' )
|
||||
{
|
||||
pState->fWritePreprocesed = pState->file_out != NULL && iValue != 0;
|
||||
fError = FALSE;
|
||||
break;
|
||||
}
|
||||
else if( szSwitch[ 1 ] == '+' && szSwitch[ 2 ] == '\0' )
|
||||
{
|
||||
pState->fWriteTrace = pState->file_trace != NULL && iValue != 0;
|
||||
fError = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
case 'Q':
|
||||
case 'q':
|
||||
case 'Q':
|
||||
if( szSwitch[ 1 ] == '\0' )
|
||||
{
|
||||
pState->fQuiet = iValue != 0;
|
||||
fError = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( pState->pSwitchFunc )
|
||||
@@ -2172,6 +2196,14 @@ static void hb_pp_pragmaNew( PHB_PP_STATE pState, PHB_PP_TOKEN pToken )
|
||||
else
|
||||
fError = TRUE;
|
||||
}
|
||||
else if( hb_pp_tokenValueCmp( pToken, "TRACE", HB_PP_CMP_DBASE ) )
|
||||
{
|
||||
pValue = hb_pp_pragmaGetLogical( pToken->pNext, &fValue );
|
||||
if( pValue )
|
||||
fError = hb_pp_setCompilerSwitch( pState, "p+", fValue );
|
||||
else
|
||||
fError = TRUE;
|
||||
}
|
||||
else if( hb_pp_tokenValueCmp( pToken, "TRACEPRAGMAS", HB_PP_CMP_DBASE ) )
|
||||
{
|
||||
pValue = hb_pp_pragmaGetLogical( pToken->pNext, &pState->fTracePragmas );
|
||||
@@ -2199,7 +2231,7 @@ static void hb_pp_pragmaNew( PHB_PP_STATE pState, PHB_PP_TOKEN pToken )
|
||||
{
|
||||
hb_pp_error( pState, 'E', HB_PP_ERR_PRAGMA, NULL );
|
||||
}
|
||||
else if( pState->fTracePragmas )
|
||||
else if( pState->fTracePragmas || pState->fWriteTrace )
|
||||
{
|
||||
char szLine[ 12 ];
|
||||
|
||||
@@ -2216,9 +2248,16 @@ static void hb_pp_pragmaNew( PHB_PP_STATE pState, PHB_PP_TOKEN pToken )
|
||||
hb_membufAddCh( pState->pBuffer, '\'' );
|
||||
}
|
||||
hb_membufAddCh( pState->pBuffer, '\n' );
|
||||
hb_membufAddCh( pState->pBuffer, '\0' );
|
||||
|
||||
hb_pp_disp( pState, hb_membufPtr( pState->pBuffer ) );
|
||||
if( pState->fWriteTrace )
|
||||
{
|
||||
fwrite( hb_membufPtr( pState->pBuffer ), sizeof( char ),
|
||||
hb_membufLen( pState->pBuffer ), pState->file_trace );
|
||||
}
|
||||
if( pState->fTracePragmas )
|
||||
{
|
||||
hb_membufAddCh( pState->pBuffer, '\0' );
|
||||
hb_pp_disp( pState, hb_membufPtr( pState->pBuffer ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3640,27 +3679,68 @@ static PHB_PP_TOKEN * hb_pp_patternStuff( PHB_PP_STATE pState,
|
||||
return pResultPtr;
|
||||
}
|
||||
|
||||
static void hb_pp_patternReplace( PHB_PP_STATE pState, PHB_PP_RULE pRule,
|
||||
PHB_PP_TOKEN * pTokenPtr )
|
||||
static char * hb_pp_tokenListStr( PHB_PP_TOKEN pToken, PHB_PP_TOKEN pStop,
|
||||
BOOL fStop, PHB_MEM_BUFFER pBuffer,
|
||||
BOOL fQuote, BOOL fEol )
|
||||
{
|
||||
PHB_PP_TOKEN pFinalResult = NULL, * pResultPtr, pToken, pStop;
|
||||
USHORT ltype = HB_PP_TOKEN_NUL;
|
||||
BOOL fSpaces = FALSE;
|
||||
|
||||
hb_membufFlush( pBuffer );
|
||||
while( pToken && ( fStop ? pToken != pStop : !HB_PP_TOKEN_ISEOC( pToken ) ) )
|
||||
{
|
||||
hb_pp_tokenStr( pToken, pBuffer, fSpaces, fQuote, ltype );
|
||||
ltype = HB_PP_TOKEN_TYPE( pToken->type );
|
||||
fSpaces = TRUE;
|
||||
pToken = pToken->pNext;
|
||||
}
|
||||
if( fEol )
|
||||
hb_membufAddCh( pBuffer, '\n' );
|
||||
hb_membufAddCh( pBuffer, '\0' );
|
||||
|
||||
return hb_membufPtr( pBuffer );
|
||||
}
|
||||
|
||||
static void hb_pp_patternReplace( PHB_PP_STATE pState, PHB_PP_RULE pRule,
|
||||
PHB_PP_TOKEN * pTokenPtr, char * szType )
|
||||
{
|
||||
PHB_PP_TOKEN pFinalResult = NULL, * pResultPtr, pToken, pSource;
|
||||
|
||||
pResultPtr = hb_pp_patternStuff( pState, pRule, 0, pRule->pResult, &pFinalResult );
|
||||
|
||||
/* store original matched token pointer */
|
||||
pStop = * pTokenPtr;
|
||||
pSource = * pTokenPtr;
|
||||
|
||||
/* Copy number of leading spaces from the first matched token
|
||||
to the first result token */
|
||||
if( pFinalResult && pSource )
|
||||
pFinalResult->spaces = pSource->spaces;
|
||||
|
||||
/* Write trace information */
|
||||
if( pState->fWriteTrace )
|
||||
{
|
||||
fprintf( pState->file_trace, "%s(%d) >%s<\n",
|
||||
pState->pFile && pState->pFile->szFileName ? pState->pFile->szFileName : "",
|
||||
pState->pFile ? pState->pFile->iCurrentLine : 0,
|
||||
/* the source string */
|
||||
hb_pp_tokenListStr( pSource, pRule->pNextExpr, TRUE,
|
||||
pState->pBuffer, TRUE, FALSE ) );
|
||||
fprintf( pState->file_trace, "#%s%s >%s<\n",
|
||||
pRule->mode == HB_PP_CMP_STD ? "x" : "", szType,
|
||||
/* the result string */
|
||||
hb_pp_tokenListStr( pFinalResult, * pResultPtr, TRUE,
|
||||
pState->pBuffer, TRUE, FALSE ) );
|
||||
}
|
||||
|
||||
/* Replace matched tokens with result pattern */
|
||||
* pResultPtr = pRule->pNextExpr;
|
||||
* pTokenPtr = pFinalResult;
|
||||
/* Copy number of leading spaces from the first matched token
|
||||
to the first result token */
|
||||
if( pFinalResult && pStop )
|
||||
pFinalResult->spaces = pStop->spaces;
|
||||
|
||||
/* Free the matched tokens */
|
||||
while( pStop != pRule->pNextExpr )
|
||||
while( pSource != pRule->pNextExpr )
|
||||
{
|
||||
pToken = pStop;
|
||||
pStop = pStop->pNext;
|
||||
pToken = pSource;
|
||||
pSource = pSource->pNext;
|
||||
hb_pp_tokenFree( pToken );
|
||||
}
|
||||
|
||||
@@ -3711,7 +3791,7 @@ static BOOL hb_pp_processDefine( PHB_PP_STATE pState, PHB_PP_TOKEN * pFirstPtr )
|
||||
{
|
||||
if( hb_pp_patternCmp( pRule, * pFirstPtr, FALSE ) )
|
||||
{
|
||||
hb_pp_patternReplace( pState, pRule, pFirstPtr );
|
||||
hb_pp_patternReplace( pState, pRule, pFirstPtr, "define" );
|
||||
fSubst = fRepeat = TRUE;
|
||||
if( ++pState->iCycle > pState->iMaxCycles ||
|
||||
++iCycle > HB_PP_MAX_REPATS + pState->iDefinitions )
|
||||
@@ -3753,7 +3833,7 @@ static BOOL hb_pp_processTranslate( PHB_PP_STATE pState, PHB_PP_TOKEN * pFirstPt
|
||||
{
|
||||
if( hb_pp_patternCmp( pRule, * pTokenPtr, FALSE ) )
|
||||
{
|
||||
hb_pp_patternReplace( pState, pRule, pTokenPtr );
|
||||
hb_pp_patternReplace( pState, pRule, pTokenPtr, "translate" );
|
||||
fSubst = fRepeat = TRUE;
|
||||
if( ++pState->iCycle > pState->iMaxCycles ||
|
||||
++iCycle > HB_PP_MAX_REPATS + pState->iTranslations )
|
||||
@@ -3790,7 +3870,7 @@ static BOOL hb_pp_processCommand( PHB_PP_STATE pState, PHB_PP_TOKEN * pFirstPtr
|
||||
{
|
||||
if( hb_pp_patternCmp( pRule, * pFirstPtr, TRUE ) )
|
||||
{
|
||||
hb_pp_patternReplace( pState, pRule, pFirstPtr );
|
||||
hb_pp_patternReplace( pState, pRule, pFirstPtr, "command" );
|
||||
fSubst = fRepeat = TRUE;
|
||||
if( ++pState->iCycle > pState->iMaxCycles ||
|
||||
++iCycle > HB_PP_MAX_REPATS + pState->iCommands )
|
||||
@@ -3859,6 +3939,17 @@ static BOOL hb_pp_concatenateKeywords( PHB_PP_STATE pState, PHB_PP_TOKEN * pFirs
|
||||
hb_membufFlush( pState->pBuffer );
|
||||
hb_membufAddData( pState->pBuffer, pToken->value, pToken->len );
|
||||
hb_membufAddData( pState->pBuffer, pNext->value, pNext->len );
|
||||
|
||||
/* Write trace information */
|
||||
if( pState->fWriteTrace )
|
||||
{
|
||||
fprintf( pState->file_trace, "%s(%d) >%s %s<\n(concatenate) >%s%s<\n",
|
||||
pState->pFile && pState->pFile->szFileName ? pState->pFile->szFileName : "",
|
||||
pState->pFile ? pState->pFile->iCurrentLine : 0,
|
||||
pToken->value, pNext->value,
|
||||
pToken->value, pNext->value );
|
||||
}
|
||||
|
||||
hb_pp_tokenSetValue( pToken, hb_membufPtr( pState->pBuffer ),
|
||||
hb_membufLen( pState->pBuffer ) );
|
||||
pToken->pNext = pNext->pNext;
|
||||
@@ -4177,25 +4268,6 @@ static void hb_pp_condCompileElif( PHB_PP_STATE pState, PHB_PP_TOKEN pToken )
|
||||
}
|
||||
}
|
||||
|
||||
static char * hb_pp_tokenListStr( PHB_PP_TOKEN pToken, PHB_MEM_BUFFER pBuffer,
|
||||
BOOL fEol )
|
||||
{
|
||||
BOOL fSpaces = FALSE;
|
||||
|
||||
hb_membufFlush( pBuffer );
|
||||
while( !HB_PP_TOKEN_ISEOC( pToken ) )
|
||||
{
|
||||
hb_pp_tokenStr( pToken, pBuffer, fSpaces, FALSE, 0 );
|
||||
pToken = pToken->pNext;
|
||||
fSpaces = TRUE;
|
||||
}
|
||||
if( fEol )
|
||||
hb_membufAddCh( pBuffer, '\n' );
|
||||
hb_membufAddCh( pBuffer, 0 );
|
||||
|
||||
return hb_membufPtr( pBuffer );
|
||||
}
|
||||
|
||||
static void hb_pp_genLineTokens( PHB_PP_STATE pState )
|
||||
{
|
||||
pState->pNextTokenPtr = &pState->pTokenOut;
|
||||
@@ -4363,13 +4435,14 @@ static void hb_pp_preprocesToken( PHB_PP_STATE pState )
|
||||
}
|
||||
else if( hb_pp_tokenValueCmp( pToken, "STDOUT", HB_PP_CMP_DBASE ) )
|
||||
{
|
||||
hb_pp_disp( pState, hb_pp_tokenListStr( pToken->pNext,
|
||||
pState->pBuffer, TRUE ) );
|
||||
hb_pp_disp( pState, hb_pp_tokenListStr( pToken->pNext, NULL, FALSE,
|
||||
pState->pBuffer, FALSE, TRUE ) );
|
||||
}
|
||||
else if( hb_pp_tokenValueCmp( pToken, "ERROR", HB_PP_CMP_DBASE ) )
|
||||
{
|
||||
hb_pp_error( pState, 'E', HB_PP_ERR_EXPLICIT,
|
||||
hb_pp_tokenListStr( pToken->pNext, pState->pBuffer, FALSE ) );
|
||||
hb_pp_tokenListStr( pToken->pNext, NULL, FALSE,
|
||||
pState->pBuffer, FALSE, FALSE ) );
|
||||
}
|
||||
else if( hb_pp_tokenValueCmp( pToken, "DEFINE", HB_PP_CMP_DBASE ) )
|
||||
{
|
||||
@@ -4614,6 +4687,7 @@ void hb_pp_reset( PHB_PP_STATE pState )
|
||||
|
||||
hb_pp_InFileFree( pState );
|
||||
hb_pp_OutFileFree( pState );
|
||||
hb_pp_TraceFileFree( pState );
|
||||
|
||||
hb_pp_ruleNonStdFree( &pState->pDefinitions );
|
||||
hb_pp_ruleNonStdFree( &pState->pTranslations );
|
||||
@@ -4804,7 +4878,7 @@ BOOL hb_pp_inFile( PHB_PP_STATE pState, char * szFileName, BOOL fSearchPath,
|
||||
}
|
||||
|
||||
/*
|
||||
* set output (.ppo) file handle
|
||||
* set output (.ppo) file
|
||||
*/
|
||||
BOOL hb_pp_outFile( PHB_PP_STATE pState, char * szOutFileName, FILE * file_out )
|
||||
{
|
||||
@@ -4832,6 +4906,35 @@ BOOL hb_pp_outFile( PHB_PP_STATE pState, char * szOutFileName, FILE * file_out )
|
||||
return !pState->fError;
|
||||
}
|
||||
|
||||
/*
|
||||
* set trace (.ppt) file
|
||||
*/
|
||||
BOOL hb_pp_traceFile( PHB_PP_STATE pState, char * szTraceFileName, FILE * file_trace )
|
||||
{
|
||||
pState->fError = FALSE;
|
||||
hb_pp_TraceFileFree( pState );
|
||||
|
||||
if( szTraceFileName )
|
||||
{
|
||||
|
||||
if( file_trace )
|
||||
pState->file_trace = file_trace;
|
||||
else
|
||||
pState->file_trace = fopen( szTraceFileName, "w" );
|
||||
|
||||
if( pState->file_trace )
|
||||
{
|
||||
pState->szTraceFileName = hb_strdup( szTraceFileName );
|
||||
pState->fWriteTrace = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_pp_error( pState, 'F', HB_PP_ERR_CANNOT_CREATE_FILE, szTraceFileName );
|
||||
}
|
||||
}
|
||||
return !pState->fError;
|
||||
}
|
||||
|
||||
/*
|
||||
* check error status of last PP operation
|
||||
*/
|
||||
@@ -4868,13 +4971,21 @@ int hb_pp_lineTot( PHB_PP_STATE pState )
|
||||
}
|
||||
|
||||
/*
|
||||
* return currently preprocessed file name
|
||||
* return output file name (.ppo)
|
||||
*/
|
||||
char * hb_pp_outFileName( PHB_PP_STATE pState )
|
||||
{
|
||||
return pState->szOutFileName;
|
||||
}
|
||||
|
||||
/*
|
||||
* return trace output file name (.ppt)
|
||||
*/
|
||||
char * hb_pp_traceFileName( PHB_PP_STATE pState )
|
||||
{
|
||||
return pState->szTraceFileName;
|
||||
}
|
||||
|
||||
/*
|
||||
* return if EOF was reached
|
||||
*/
|
||||
|
||||
@@ -483,10 +483,20 @@ static void hb_gt_os2_GetScreenContents( void )
|
||||
hb_gt_ColdArea( 0, 0, s_vi.row, s_vi.col );
|
||||
}
|
||||
|
||||
static PVOID hb_gt_os2_allocMem( int iSize )
|
||||
{
|
||||
APIRET rc; /* return code from DosXXX api call */
|
||||
PVOID pMem;
|
||||
|
||||
rc = DosAllocMem( &pMem, iSize, PAG_COMMIT | OBJ_TILE | PAG_WRITE );
|
||||
if( rc != NO_ERROR )
|
||||
hb_errInternal( HB_EI_XGRABALLOC, "hb_gt_os2_ReadKey() memory allocation failure.", NULL, NULL );
|
||||
|
||||
return pMem;
|
||||
}
|
||||
|
||||
static void hb_gt_os2_Init( FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE hFilenoStderr )
|
||||
{
|
||||
APIRET rc; /* return code from DosXXX api call */
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_os2_Init(%p,%p,%p)", hFilenoStdin, hFilenoStdout, hFilenoStderr ) );
|
||||
|
||||
s_vi.cb = sizeof( VIOMODEINFO );
|
||||
@@ -503,22 +513,10 @@ static void hb_gt_os2_Init( FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE
|
||||
}
|
||||
|
||||
/* Alloc tileable memory for calling a 16 subsystem */
|
||||
rc = DosAllocMem( ( PPVOID ) &s_hk, sizeof( HKBD ),
|
||||
PAG_COMMIT | OBJ_TILE | PAG_WRITE );
|
||||
if( rc != NO_ERROR )
|
||||
{
|
||||
hb_errInternal( HB_EI_XGRABALLOC, "hb_gt_os2_ReadKey() memory allocation failure.", NULL, NULL );
|
||||
}
|
||||
|
||||
s_hk = ( PHKBD ) hb_gt_os2_allocMem( sizeof( HKBD ) );
|
||||
/* it is a long after all, so I set it to zero only one time since it never changes */
|
||||
memset( s_hk, 0, sizeof( HKBD ) );
|
||||
|
||||
rc = DosAllocMem( ( PPVOID ) &s_key, sizeof( KBDKEYINFO ),
|
||||
PAG_COMMIT | OBJ_TILE | PAG_WRITE);
|
||||
if( rc != NO_ERROR )
|
||||
{
|
||||
hb_errInternal( HB_EI_XGRABALLOC, "hb_gt_os2_ReadKey() memory allocation failure.", NULL, NULL);
|
||||
}
|
||||
s_key = ( PKBDKEYINFO ) hb_gt_os2_allocMem( sizeof( KBDKEYINFO ) );
|
||||
|
||||
/* TODO: Is anything else required to initialize the video subsystem?
|
||||
I (Maurilio Longo) think that we should set correct codepage
|
||||
@@ -571,7 +569,6 @@ static void hb_gt_os2_Exit( void )
|
||||
VioSetCp( 0, s_usOldCodePage, 0 );
|
||||
}
|
||||
|
||||
|
||||
static int hb_gt_os2_ReadKey( int iEventMask )
|
||||
{
|
||||
int ch; /* next char if any */
|
||||
@@ -742,7 +739,6 @@ static BOOL hb_gt_os2_GetBlink()
|
||||
return vi.fs == 0; /* 0 = blink, 1 = intens */
|
||||
}
|
||||
|
||||
|
||||
static void hb_gt_os2_SetBlink( BOOL fBlink )
|
||||
{
|
||||
VIOINTENSITY vi;
|
||||
|
||||
Reference in New Issue
Block a user