diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 49b2bcdc50..86c3df1abb 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,30 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-09 10:38 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/eval.c + * update number of parameters in HB_EXECMSG() to keep the HVM stack + clean for any external code which can try to make some HVM stack + tracing/scanning + + * harbour/source/vm/evalhb.c + ! use hb_vmSend() instead of hb_vmDo() + + * harbour/source/pp/pplib.c + * harbour/source/pp/pplib3.c + * harbour/source/vm/runner.c + * harbour/source/vm/hvm.c + * harbour/source/vm/thread.c + * harbour/source/vm/eval.c + * harbour/source/vm/dynlibhb.c + * harbour/source/vm/classes.c + * harbour/source/rtl/do.c + * harbour/source/rtl/xhelp.c + * harbour/source/rdd/workarea.c + * harbour/source/rdd/dbf1.c + % use hb_vmProc() instead of hb_vmDo() in all places where context is + well known as function or procedure call + 2009-06-08 22:36 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/wvgcore.c * harbour/contrib/gtwvg/wvgcuig.c diff --git a/harbour/source/pp/pplib.c b/harbour/source/pp/pplib.c index f300f1f014..e23c8714d8 100644 --- a/harbour/source/pp/pplib.c +++ b/harbour/source/pp/pplib.c @@ -126,7 +126,7 @@ static void hb_pp_StdRules( PHB_ITEM ppItem ) hb_vmPushDynSym( s_pDynSym ); hb_vmPushNil(); hb_vmPush( ppItem ); - hb_vmDo( 1 ); + hb_vmProc( 1 ); } } diff --git a/harbour/source/pp/pplib3.c b/harbour/source/pp/pplib3.c index 11c53628f7..c611fafdd0 100644 --- a/harbour/source/pp/pplib3.c +++ b/harbour/source/pp/pplib3.c @@ -93,7 +93,7 @@ static PHB_ITEM hb_pp_Get( void ) { hb_vmPushDynSym( s_pDynSym ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); } if( hb_param( -1, HB_IT_POINTER ) ) s_pp = hb_itemNew( hb_param( -1, HB_IT_POINTER ) ); @@ -120,11 +120,11 @@ HB_FUNC( __PPADDRULE ) hb_vmPush( pLine ); else hb_vmPushNil(); - hb_vmDo( 2 ); + hb_vmProc( 2 ); } } } - + HB_FUNC( __PREPROCESS ) { static PHB_DYNS s_pDynSym = NULL; @@ -143,7 +143,7 @@ HB_FUNC( __PREPROCESS ) hb_vmPush( pLine ); else hb_vmPushNil(); - hb_vmDo( 2 ); + hb_vmProc( 2 ); } } } diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 03fe82132e..060a03cd13 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -479,12 +479,12 @@ static BOOL hb_dbfTriggerDo( DBFAREAP pArea, int iEvent, #else hb_vmPush( pItem ); #endif - hb_vmDo( 4 ); + hb_vmProc( 4 ); } else { /* SIx3 makes: hb_vmPushInteger( 0 ); */ - hb_vmDo( 3 ); + hb_vmProc( 3 ); } fResult = hb_parl( -1 ); hb_vmRequestRestore(); diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index 8038d8fbc6..91461761d3 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -2143,7 +2143,7 @@ int hb_rddRegister( const char * szDriver, USHORT uiType ) hb_vmPushPointer( ( void * ) &pRddNewNode->pTable ); hb_vmPushPointer( ( void * ) &pRddNewNode->pSuperTable ); hb_vmPushInteger( s_uiRddCount ); - hb_vmDo( 4 ); + hb_vmProc( 4 ); if( hb_parni( -1 ) != HB_SUCCESS ) iResult = 3; /* Invalid FUNCTABLE */ else diff --git a/harbour/source/rtl/do.c b/harbour/source/rtl/do.c index 70db6ce814..9918171a79 100644 --- a/harbour/source/rtl/do.c +++ b/harbour/source/rtl/do.c @@ -69,33 +69,26 @@ HB_FUNC( DO ) if( uiPCount > 0 ) { - PHB_ITEM pItem = hb_param( 1, HB_IT_ANY ); + PHB_ITEM pItem = hb_param( 1, HB_IT_ANY ), pSelf = NULL; if( HB_IS_STRING( pItem ) ) { PHB_DYNS pDynSym = hb_dynsymFindName( hb_itemGetCPtr( pItem ) ); - if( pDynSym ) - { - hb_vmPushDynSym( pDynSym ); - hb_vmPushNil(); - } - else + if( !pDynSym ) { hb_errRT_BASE( EG_NOFUNC, 1001, NULL, hb_itemGetCPtr( pItem ), HB_ERR_ARGS_BASEPARAMS ); return; } + hb_vmPushDynSym( pDynSym ); } else if( HB_IS_BLOCK( pItem ) ) { hb_vmPushSymbol( &hb_symEval ); - hb_vmPush( pItem ); + pSelf = pItem; } else if( HB_IS_SYMBOL( pItem ) ) - { hb_vmPush( pItem ); - hb_vmPushNil(); - } else uiPCount = 0; } @@ -103,9 +96,19 @@ HB_FUNC( DO ) if( uiPCount > 0 ) { USHORT uiParam; + + if( pSelf ) + hb_vmPush( pSelf ); + else + hb_vmPushNil(); + for( uiParam = 2; uiParam <= uiPCount; ++uiParam ) hb_vmPush( hb_stackItemFromBase( uiParam ) ); - hb_vmDo( ( USHORT ) ( uiPCount - 1 ) ); + + if( pSelf ) + hb_vmSend( ( USHORT ) ( uiPCount - 1 ) ); + else + hb_vmProc( ( USHORT ) ( uiPCount - 1 ) ); } else hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); diff --git a/harbour/source/rtl/xhelp.c b/harbour/source/rtl/xhelp.c index 7dcf93c8a2..894d5fea2f 100644 --- a/harbour/source/rtl/xhelp.c +++ b/harbour/source/rtl/xhelp.c @@ -76,7 +76,7 @@ HB_FUNC( __XHELP ) for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) hb_vmPush( hb_stackItemFromBase( uiParam ) ); - hb_vmDo( uiPCount ); + hb_vmProc( uiPCount ); /* NOTE: Leave the return value as it is. */ } } diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 7e1ff94844..61f900019b 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -1090,7 +1090,7 @@ void hb_clsDoInit( void ) hb_itemSetNil( pReturn ); hb_vmPushDynSym( pFuncSym ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); if( HB_IS_OBJECT( pReturn ) ) *( s_puiHandles[i] ) = pReturn->item.asArray.value->uiClass; } @@ -3788,7 +3788,7 @@ HB_FUNC( __CLSINSTSUPER ) { hb_vmPushSymbol( pClassFuncSym ); hb_vmPushNil(); - hb_vmDo( 0 ); /* Execute super class */ + hb_vmProc( 0 ); /* Execute super class */ if( hb_vmRequestQuery() == 0 ) { diff --git a/harbour/source/vm/dynlibhb.c b/harbour/source/vm/dynlibhb.c index c61d96ee10..e66d8849a5 100644 --- a/harbour/source/vm/dynlibhb.c +++ b/harbour/source/vm/dynlibhb.c @@ -186,7 +186,7 @@ HB_FUNC( HB_LIBDO ) hb_vmPush( hb_stackItemFromBase( uiParam ) ); } - hb_vmDo( ( USHORT ) ( uiPCount - 1 ) ); + hb_vmProc( ( USHORT ) ( uiPCount - 1 ) ); } } } diff --git a/harbour/source/vm/eval.c b/harbour/source/vm/eval.c index 99033cda06..54db30526b 100644 --- a/harbour/source/vm/eval.c +++ b/harbour/source/vm/eval.c @@ -156,7 +156,7 @@ PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo ) if( pItem ) hb_vmSend( uiParam ); else - hb_vmDo( uiParam ); + hb_vmProc( uiParam ); pResult = hb_itemNew( hb_stackReturnItem() ); } } @@ -252,7 +252,7 @@ PHB_ITEM hb_itemDo( PHB_ITEM pItem, ULONG ulPCount, ... ) if( pItem ) hb_vmSend( ( USHORT ) ulPCount ); else - hb_vmDo( ( USHORT ) ulPCount ); + hb_vmProc( ( USHORT ) ulPCount ); pResult = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); @@ -295,7 +295,7 @@ PHB_ITEM hb_itemDoC( const char * szFunc, ULONG ulPCount, ... ) hb_vmPush( va_arg( va, PHB_ITEM ) ); va_end( va ); } - hb_vmDo( ( unsigned short ) ulPCount ); + hb_vmProc( ( unsigned short ) ulPCount ); pResult = hb_itemNew( hb_stackReturnItem() ); hb_vmRequestRestore(); } @@ -496,7 +496,7 @@ HB_FUNC( HB_EXECFROMARRAY ) if( pSelf ) hb_vmSend( usPCount ); else - hb_vmDo( usPCount ); + hb_vmProc( usPCount ); } else hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -558,7 +558,7 @@ BOOL hb_execFromArray( PHB_ITEM pParam ) if( pSelf ) hb_vmSend( usPCount ); else - hb_vmDo( usPCount ); + hb_vmProc( usPCount ); return TRUE; } @@ -577,7 +577,11 @@ HB_FUNC( HB_EXECMSG ) int iParams = hb_pcount(); if( iParams >= 2 && ISSYMBOL( 1 ) ) + { + PHB_ITEM pBase = hb_stackBaseItem(); + pBase->item.asSymbol.paramcnt = pBase->item.asSymbol.paramdeclcnt = 0; hb_vmProc( ( USHORT ) ( iParams - 2 ) ); + } else hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/vm/evalhb.c b/harbour/source/vm/evalhb.c index 7eaa01e112..0c07430fab 100644 --- a/harbour/source/vm/evalhb.c +++ b/harbour/source/vm/evalhb.c @@ -77,7 +77,7 @@ HB_FUNC( EVAL ) hb_vmPush( hb_stackItemFromBase( uiParam ) ); } - hb_vmDo( ( USHORT ) ( uiPCount - 1 ) ); + hb_vmSend( ( USHORT ) ( uiPCount - 1 ) ); } else { diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 28a1b3cba5..580b961da5 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -377,7 +377,7 @@ static void hb_vmDoInitClip( void ) { hb_vmPushSymbol( pDynSym->pSymbol ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); } } @@ -1029,7 +1029,7 @@ void hb_vmInit( BOOL bStartMainProc ) } } - hb_vmDo( ( USHORT ) iArgCount ); /* invoke it with number of supplied parameters */ + hb_vmProc( ( USHORT ) iArgCount ); /* invoke it with number of supplied parameters */ } } @@ -1569,25 +1569,25 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) /* Execution */ case HB_P_DO: - hb_vmDo( HB_PCODE_MKUSHORT( &pCode[ 1 ] ) ); + hb_vmProc( HB_PCODE_MKUSHORT( &pCode[ 1 ] ) ); pCode += 3; break; case HB_P_DOSHORT: - hb_vmDo( pCode[ 1 ] ); + hb_vmProc( pCode[ 1 ] ); pCode += 2; break; case HB_P_FUNCTION: hb_itemSetNil( hb_stackReturnItem() ); - hb_vmDo( HB_PCODE_MKUSHORT( &pCode[ 1 ] ) ); + hb_vmProc( HB_PCODE_MKUSHORT( &pCode[ 1 ] ) ); hb_stackPushReturn(); pCode += 3; break; case HB_P_FUNCTIONSHORT: hb_itemSetNil( hb_stackReturnItem() ); - hb_vmDo( pCode[ 1 ] ); + hb_vmProc( pCode[ 1 ] ); hb_stackPushReturn(); pCode += 2; break; @@ -5426,7 +5426,7 @@ static void hb_vmMacroDo( USHORT uiArgSets ) lArgs = hb_vmArgsJoin( -1, uiArgSets ); hb_stackDecrease( uiArgSets ); - hb_vmDo( ( USHORT ) lArgs ); + hb_vmProc( ( USHORT ) lArgs ); } static void hb_vmMacroFunc( USHORT uiArgSets ) @@ -5439,7 +5439,7 @@ static void hb_vmMacroFunc( USHORT uiArgSets ) lArgs = hb_vmArgsJoin( -1, uiArgSets ); hb_stackDecrease( uiArgSets ); hb_itemSetNil( hb_stackReturnItem() ); - hb_vmDo( ( USHORT ) lArgs ); + hb_vmProc( ( USHORT ) lArgs ); hb_stackPushReturn(); } @@ -5989,7 +5989,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB hb_vmPushNil(); hb_vmPushInteger( HB_DBG_MODULENAME ); hb_vmPushString( szName, strlen( szName ) ); - hb_vmDo( 2 ); + hb_vmProc( 2 ); break; case HB_DBG_LOCALNAME: @@ -5998,7 +5998,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB hb_vmPushInteger( HB_DBG_LOCALNAME ); hb_vmPushInteger( nIndex ); hb_vmPushString( szName, strlen( szName ) ); - hb_vmDo( 3 ); + hb_vmProc( 3 ); break; case HB_DBG_STATICNAME: @@ -6008,7 +6008,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB hb_vmPush( pFrame ); /* current static frame */ hb_vmPushInteger( nIndex ); /* variable index */ hb_vmPushString( szName, strlen( szName ) ); - hb_vmDo( 4 ); + hb_vmProc( 4 ); break; case HB_DBG_SHOWLINE: @@ -6016,7 +6016,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB hb_vmPushNil(); hb_vmPushInteger( HB_DBG_SHOWLINE ); hb_vmPushInteger( nLine ); - hb_vmDo( 2 ); + hb_vmProc( 2 ); break; case HB_DBG_ENDPROC: @@ -6024,7 +6024,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB hb_vmPushDynSym( s_pDynsDbgEntry ); hb_vmPushNil(); hb_vmPushInteger( HB_DBG_ENDPROC ); - hb_vmDo( 1 ); + hb_vmProc( 1 ); hb_stackPopReturn(); /* restores the previous returned value */ break; @@ -6033,14 +6033,14 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB hb_vmPushDynSym( s_pDynsDbgEntry ); hb_vmPushNil(); hb_vmPushInteger( HB_DBG_GETENTRY ); - hb_vmDo( 1 ); + hb_vmProc( 1 ); break; case HB_DBG_VMQUIT: hb_vmPushDynSym( s_pDynsDbgEntry ); hb_vmPushNil(); hb_vmPushInteger( HB_DBG_VMQUIT ); - hb_vmDo( 1 ); + hb_vmProc( 1 ); break; } } @@ -7477,7 +7477,7 @@ void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] ) { hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); } } pLastSymbols->fInitStatics = FALSE; @@ -7510,7 +7510,7 @@ void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] ) { hb_vmPushString( argv[i], strlen( argv[i] ) ); } - hb_vmDo( ( USHORT ) argc ); + hb_vmProc( ( USHORT ) argc ); } } } @@ -7546,7 +7546,7 @@ void hb_vmExitSymbolGroup( void * hDynLib ) { hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); } } } @@ -7837,7 +7837,7 @@ static void hb_vmDoInitStatics( void ) { hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); } } pLastSymbols->fInitStatics = FALSE; @@ -7884,7 +7884,7 @@ static void hb_vmDoInitFunctions( void ) } } - hb_vmDo( ( USHORT ) iArgCount ); + hb_vmProc( ( USHORT ) iArgCount ); } } } @@ -7920,7 +7920,7 @@ static void hb_vmDoExitFunctions( void ) { hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); if( hb_stackGetActionRequest() ) /* QUIT or BREAK was issued - stop processing */ @@ -8780,7 +8780,7 @@ BOOL hb_xvmDo( USHORT uiParams ) HB_TRACE(HB_TR_DEBUG, ("hb_xvmDo(%hu)", uiParams)); - hb_vmDo( uiParams ); + hb_vmProc( uiParams ); HB_XVM_RETURN } @@ -8792,7 +8792,7 @@ BOOL hb_xvmFunction( USHORT uiParams ) HB_TRACE(HB_TR_DEBUG, ("hb_xvmFunction(%hu)", uiParams)); hb_itemSetNil( hb_stackReturnItem() ); - hb_vmDo( uiParams ); + hb_vmProc( uiParams ); hb_stackPushReturn(); HB_XVM_RETURN diff --git a/harbour/source/vm/runner.c b/harbour/source/vm/runner.c index b0fede3366..c65dded686 100644 --- a/harbour/source/vm/runner.c +++ b/harbour/source/vm/runner.c @@ -192,7 +192,7 @@ static void hb_hrbInitStatic( PHRB_BODY pHrbBody ) hb_vmPushSymbol( &(pHrbBody->pSymRead[ ul ]) ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); } } @@ -219,7 +219,7 @@ static void hb_hrbInit( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams ) hb_vmPushNil(); for( i = 0; i < iPCount; i++ ) hb_vmPush( pParams[ i ] ); - hb_vmDo( ( USHORT ) iPCount ); + hb_vmProc( ( USHORT ) iPCount ); if( hb_vmRequestQuery() != 0 ) break; } @@ -247,7 +247,7 @@ static void hb_hrbExit( PHRB_BODY pHrbBody ) { hb_vmPushSymbol( pHrbBody->pSymRead + ul ); hb_vmPushNil(); - hb_vmDo( 0 ); + hb_vmProc( 0 ); if( hb_vmRequestQuery() != 0 ) break; } @@ -584,7 +584,7 @@ static void hb_hrbDo( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams ) for( i = 0; i < iPCount; i++ ) hb_vmPush( pParams[ i ] ); - hb_vmDo( ( USHORT ) iPCount ); + hb_vmProc( ( USHORT ) iPCount ); pRetVal = hb_itemNew( NULL ); hb_itemMove( pRetVal, hb_stackReturnItem() ); diff --git a/harbour/source/vm/thread.c b/harbour/source/vm/thread.c index 84d844949d..ac0c1ef87c 100644 --- a/harbour/source/vm/thread.c +++ b/harbour/source/vm/thread.c @@ -822,7 +822,7 @@ static HB_THREAD_STARTFUNC( hb_threadStartVM ) if( fSend ) hb_vmSend( ( USHORT ) ( ulPCount - 1 ) ); else - hb_vmDo( ( USHORT ) ( ulPCount - 1 ) ); + hb_vmProc( ( USHORT ) ( ulPCount - 1 ) ); } else {