From 9ec83178875942ee31c29a788640527766d97a0f Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 20 Oct 2011 20:04:04 +0000 Subject: [PATCH] 2011-10-20 22:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbpp.h * harbour/include/hbcomp.h * harbour/src/pp/ppcore.c * harbour/src/compiler/hbmain.c * harbour/src/compiler/hbcmplib.c + added support for setting starting line number in code compiled from memory buffer ! removed unnecessary EF_CANDEFULT flag from recently added compiler RTE --- harbour/ChangeLog | 11 +++++++++++ harbour/include/hbcomp.h | 2 +- harbour/include/hbpp.h | 2 +- harbour/src/compiler/hbcmplib.c | 10 +++++----- harbour/src/compiler/hbmain.c | 16 ++++++++-------- harbour/src/pp/ppcore.c | 6 ++++-- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2eca489c66..51bbd76fb3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2011-10-20 22:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbpp.h + * harbour/include/hbcomp.h + * harbour/src/pp/ppcore.c + * harbour/src/compiler/hbmain.c + * harbour/src/compiler/hbcmplib.c + + added support for setting starting line number in code compiled + from memory buffer + ! removed unnecessary EF_CANDEFULT flag from recently added + compiler RTE + 2011-10-20 20:19 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbpp.h * harbour/include/hbcomp.h diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 5d707a6d77..e00c786e3d 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -266,7 +266,7 @@ extern HB_BOOL hb_compCheckUnclosedStru( HB_COMP_DECL, PFUNCTION ); #define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_compGen##func( p1, p2, p3, p4, HB_COMP_PARAM ) extern int hb_compMain( int argc, const char * const argv[] ); -extern int hb_compMainExt( int argc, const char * const argv[], HB_BYTE ** pBufPtr, HB_SIZE * pnSize, const char * szSource, void * cargo, PHB_PP_OPEN_FUNC pOpenFunc, PHB_PP_MSG_FUNC pMsgFunc ); +extern int hb_compMainExt( int argc, const char * const argv[], HB_BYTE ** pBufPtr, HB_SIZE * pnSize, const char * szSource, int iStartLine, void * cargo, PHB_PP_OPEN_FUNC pOpenFunc, PHB_PP_MSG_FUNC pMsgFunc ); extern void hb_compOutStd( HB_COMP_DECL, const char * szMessage ); extern void hb_compOutErr( HB_COMP_DECL, const char * szMessage ); diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h index e51db2ebdd..4bd6f21a3b 100644 --- a/harbour/include/hbpp.h +++ b/harbour/include/hbpp.h @@ -664,7 +664,7 @@ extern HB_EXPORT void hb_pp_setStdRules( PHB_PP_STATE pState ); extern HB_EXPORT void hb_pp_setStdBase( PHB_PP_STATE pState ); extern HB_EXPORT void hb_pp_setStream( PHB_PP_STATE pState, int iMode ); extern HB_EXPORT void hb_pp_addSearchPath( PHB_PP_STATE pState, const char * szPath, HB_BOOL fReplace ); -extern HB_EXPORT HB_BOOL hb_pp_inBuffer( PHB_PP_STATE pState, const char * pBuffer, HB_SIZE nLen ); +extern HB_EXPORT HB_BOOL hb_pp_inBuffer( PHB_PP_STATE pState, const char * pBuffer, HB_SIZE nLen, int iStartLine ); extern HB_EXPORT HB_BOOL hb_pp_inFile( PHB_PP_STATE pState, const char * szFileName, HB_BOOL fSearchPath, FILE * file_in, HB_BOOL fError ); extern HB_EXPORT HB_BOOL hb_pp_outFile( PHB_PP_STATE pState, const char * szOutFileName, FILE * file_out ); extern HB_EXPORT HB_BOOL hb_pp_traceFile( PHB_PP_STATE pState, const char * szTraceFileName, FILE * file_trace ); diff --git a/harbour/src/compiler/hbcmplib.c b/harbour/src/compiler/hbcmplib.c index 5b98c523b2..48bfbaca36 100644 --- a/harbour/src/compiler/hbcmplib.c +++ b/harbour/src/compiler/hbcmplib.c @@ -74,8 +74,8 @@ static void s_pp_msg( void * cargo, int iErrorFmt, int iLine, hb_snprintf( szLine, sizeof( szLine ), iErrorFmt == HB_ERRORFMT_CLIPPER ? "%s(%i)" : "%s:%i", szModule, iLine ); - pError = hb_errRT_New( ES_ERROR, "COMPILER", 1001, ( HB_ERRCODE ) iValue, szMsgBuf, - szLine, 0 /*OsCode*/, EF_NONE | EF_CANDEFAULT ); + pError = hb_errRT_New( ES_ERROR, "COMPILER", 1001, ( HB_ERRCODE ) iValue, + szMsgBuf, szLine, 0 /*OsCode*/, EF_NONE ); hb_errLaunch( pError ); hb_errRelease( pError ); } @@ -210,7 +210,7 @@ HB_FUNC( HB_COMPILE ) PHB_PP_MSG_FUNC pMsgFunc; hb_compGenArgList( 1, hb_pcount(), &argc, &argv, &pIncItem, &pOpenFunc, &pMsgFunc ); - hb_retni( hb_compMainExt( argc, argv, NULL, NULL, NULL, pIncItem, pOpenFunc, pMsgFunc ) ); + hb_retni( hb_compMainExt( argc, argv, NULL, NULL, NULL, 0, pIncItem, pOpenFunc, pMsgFunc ) ); hb_xfree( argv ); } @@ -225,7 +225,7 @@ HB_FUNC( HB_COMPILEBUF ) HB_SIZE nLen; hb_compGenArgList( 1, hb_pcount(), &argc, &argv, &pIncItem, &pOpenFunc, &pMsgFunc ); - iResult = hb_compMainExt( argc, argv, &pBuffer, &nLen, NULL, pIncItem, pOpenFunc, pMsgFunc ); + iResult = hb_compMainExt( argc, argv, &pBuffer, &nLen, NULL, 0, pIncItem, pOpenFunc, pMsgFunc ); hb_xfree( argv ); if( iResult == EXIT_SUCCESS && pBuffer ) @@ -247,7 +247,7 @@ HB_FUNC( HB_COMPILEFROMBUF ) if( szSource ) { hb_compGenArgList( 2, hb_pcount(), &argc, &argv, &pIncItem, &pOpenFunc, &pMsgFunc ); - iResult = hb_compMainExt( argc, argv, &pBuffer, &nLen, szSource, pIncItem, pOpenFunc, pMsgFunc ); + iResult = hb_compMainExt( argc, argv, &pBuffer, &nLen, szSource, 0, pIncItem, pOpenFunc, pMsgFunc ); hb_xfree( argv ); if( iResult == EXIT_SUCCESS && pBuffer ) diff --git a/harbour/src/compiler/hbmain.c b/harbour/src/compiler/hbmain.c index 61b083964c..23148c1d91 100644 --- a/harbour/src/compiler/hbmain.c +++ b/harbour/src/compiler/hbmain.c @@ -54,14 +54,14 @@ #include "hbcomp.h" #include "hbhash.h" -static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuffer ); +static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuffer, int iStartLine ); static HB_BOOL hb_compRegisterFunc( HB_COMP_DECL, PFUNCTION pFunc, HB_BOOL fError ); /* ************************************************************************* */ int hb_compMainExt( int argc, const char * const argv[], HB_BYTE ** pBufPtr, HB_SIZE * pnSize, - const char * szSource, + const char * szSource, int iStartLine, void * cargo, PHB_PP_OPEN_FUNC pOpenFunc, PHB_PP_MSG_FUNC pMsgFunc ) { @@ -138,7 +138,7 @@ int hb_compMainExt( int argc, const char * const argv[], if( szSource ) { bAnyFiles = HB_TRUE; - iStatus = hb_compCompile( HB_COMP_PARAM, "{SOURCE}", szSource ); + iStatus = hb_compCompile( HB_COMP_PARAM, "{SOURCE}", szSource, iStartLine ); } else { @@ -149,7 +149,7 @@ int hb_compMainExt( int argc, const char * const argv[], if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) ) { bAnyFiles = HB_TRUE; - iStatus = hb_compCompile( HB_COMP_PARAM, argv[ i ], NULL ); + iStatus = hb_compCompile( HB_COMP_PARAM, argv[ i ], NULL, 0 ); if( iStatus != EXIT_SUCCESS ) break; } @@ -183,7 +183,7 @@ int hb_compMainExt( int argc, const char * const argv[], int hb_compMain( int argc, const char * const argv[] ) { - return hb_compMainExt( argc, argv, NULL, NULL, NULL, NULL, NULL, NULL ); + return hb_compMainExt( argc, argv, NULL, NULL, NULL, 0, NULL, NULL, NULL ); } static int hb_compReadClpFile( HB_COMP_DECL, const char * szClpFile ) @@ -4054,7 +4054,7 @@ static void hb_compRestoreSwitches( HB_COMP_DECL, PHB_COMP_SWITCHES pSwitches ) HB_COMP_PARAM->supported = pSwitches->supported; } -static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuffer ) +static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuffer, int iStartLine ) { char buffer[ HB_PATH_MAX * 2 + 80 ]; HB_COMP_SWITCHES switches; @@ -4063,7 +4063,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff PHB_MODULE pModule; HB_BOOL fGenCode = HB_TRUE; - HB_TRACE(HB_TR_DEBUG, ("hb_compCompile(%s,%p)", szPrg, szBuffer)); + HB_TRACE(HB_TR_DEBUG, ("hb_compCompile(%s,%p,%d)", szPrg, szBuffer, iStartLine)); hb_compSaveSwitches( HB_COMP_PARAM, &switches ); /* Initialize support variables */ @@ -4113,7 +4113,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff if( szBuffer ) { - if( !hb_pp_inBuffer( HB_COMP_PARAM->pLex->pPP, szBuffer, strlen( szBuffer ) ) ) + if( !hb_pp_inBuffer( HB_COMP_PARAM->pLex->pPP, szBuffer, strlen( szBuffer ), iStartLine ) ) { hb_compOutErr( HB_COMP_PARAM, "Cannot create preprocessor buffer." ); iStatus = EXIT_FAILURE; diff --git a/harbour/src/pp/ppcore.c b/harbour/src/pp/ppcore.c index 6f7b83de2b..d2c6c2694f 100644 --- a/harbour/src/pp/ppcore.c +++ b/harbour/src/pp/ppcore.c @@ -5316,7 +5316,7 @@ static void hb_pp_preprocessToken( PHB_PP_STATE pState ) { hb_pp_directiveNew( pState, pToken, HB_PP_CMP_CASE, HB_TRUE, fDirect, HB_TRUE ); } - /* Clipper PP does not accept #line and generate error */ + /* Clipper PP does not accept #line and generates error */ else if( hb_pp_tokenValueCmp( pToken, "LINE", HB_PP_CMP_DBASE ) ) { /* ignore #line directives */ @@ -5694,13 +5694,15 @@ void hb_pp_readRules( PHB_PP_STATE pState, const char * szRulesFile ) /* * close all open input files and set the given buffer as input stream */ -HB_BOOL hb_pp_inBuffer( PHB_PP_STATE pState, const char * pBuffer, HB_SIZE nLen ) +HB_BOOL hb_pp_inBuffer( PHB_PP_STATE pState, const char * pBuffer, HB_SIZE nLen, int iStartLine ) { hb_pp_InFileFree( pState ); pState->fError = HB_FALSE; pState->pFile = hb_pp_FileBufNew( pBuffer, nLen ); + pState->pFile->iCurrentLine = iStartLine; + pState->pFile->iLastLine = iStartLine + 1; pState->iFiles++; return HB_TRUE; }