2004-04-06 15:40 UTC+0100 Ryszard Glab <rglab@imid.med.pl>

* include/hbapi.h
   * include/hbvm.h
   * source/vm/hvm.c
   * source/vm/macro.c
      * fixed bug introduced earlier by me in the macro compiler:
        PUBLIC &macro
        works correctly now
This commit is contained in:
Ryszard Glab
2004-04-06 13:24:11 +00:00
parent 9a91e3ecfc
commit 3b7d43dcbc
5 changed files with 62 additions and 29 deletions

View File

@@ -7,6 +7,16 @@
For example:
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2004-04-06 15:40 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* include/hbapi.h
* include/hbvm.h
* source/vm/hvm.c
* source/vm/macro.c
* fixed bug introduced earlier by me in the macro compiler:
PUBLIC &macro
works correctly now
2004-04-03 01:46 UTC-0300 Luiz Rafael Culik(culikr@brturbo.com>
* contrib/hbzlib/*
! updated to use the same core as xharbour do

View File

@@ -211,6 +211,7 @@ struct hb_struString
struct hb_struSymbol
{
BOOL macro; /* if symbol was pushed by the macro compiler */
LONG stackbase;
USHORT lineno;
USHORT paramcnt;

View File

@@ -103,6 +103,7 @@ extern void hb_vmPushString( char * szText, ULONG length ); /* pushes a stri
extern void hb_vmPushStringPcode( char * szText, ULONG length ); /* pushes a string from pcode on to the stack */
extern void hb_vmPushDate( long lDate ); /* pushes a long date onto the stack */
extern void hb_vmPushSymbol( PHB_SYMB pSym ); /* pushes a function pointer onto the stack */
extern void hb_vmPushMacroSymbol( PHB_SYMB pSym ); /* pushes a symbol created by the macro compiler onto the stack */
extern void hb_vmPushPointer( void * ); /* push an item of HB_IT_POINTER type */
/* various flags for supported features

View File

@@ -3404,27 +3404,40 @@ void hb_vmDo( USHORT uiParams )
if( pFunc )
{
if( bProfiler && pSym->pDynSym ) {
pSym->pDynSym->ulRecurse++;
}
if ( hb_bTracePrgCalls )
HB_TRACE(HB_TR_ALWAYS, ("Calling: %s", pSym->szName));
pFunc();
if( bProfiler && pSym->pDynSym )
if( pItem->item.asSymbol.macro && (pSym->cScope & HB_FS_STATIC) )
{
pSym->pDynSym->ulCalls++; /* profiler support */
/* Time spent has to be added only inside topmost call of a recursive function */
if( pSym->pDynSym->ulRecurse == 1 ) {
pSym->pDynSym->ulTime += clock() - ulClock; /* profiler support */
}
/* static functions are not allowed in macro
*/
HB_ITEM_PTR pError = hb_errRT_New( ES_ERROR, NULL, EG_NOFUNC, 1001,
NULL, pSym->szName,
0, EF_NONE );
hb_errLaunch( pError );
hb_errRelease( pError );
}
else
{
if( bProfiler && pSym->pDynSym ) {
pSym->pDynSym->ulRecurse++;
}
if( bProfiler && pSym->pDynSym ) {
pSym->pDynSym->ulRecurse--;
if ( hb_bTracePrgCalls )
HB_TRACE(HB_TR_ALWAYS, ("Calling: %s", pSym->szName));
pFunc();
if( bProfiler && pSym->pDynSym )
{
pSym->pDynSym->ulCalls++; /* profiler support */
/* Time spent has to be added only inside topmost call of a recursive function */
if( pSym->pDynSym->ulRecurse == 1 ) {
pSym->pDynSym->ulTime += clock() - ulClock; /* profiler support */
}
}
if( bProfiler && pSym->pDynSym ) {
pSym->pDynSym->ulRecurse--;
}
}
}
else
@@ -4154,6 +4167,20 @@ void hb_vmPushSymbol( PHB_SYMB pSym )
pStackTopItem->type = HB_IT_SYMBOL;
pStackTopItem->item.asSymbol.value = pSym;
pStackTopItem->item.asSymbol.stackbase = hb_stackTopOffset();
pStackTopItem->item.asSymbol.macro = FALSE;
hb_stackPush();
}
void hb_vmPushMacroSymbol( PHB_SYMB pSym )
{
PHB_ITEM pStackTopItem = hb_stackTopItem();
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushSymbol(%p)", pSym));
pStackTopItem->type = HB_IT_SYMBOL;
pStackTopItem->item.asSymbol.value = pSym;
pStackTopItem->item.asSymbol.stackbase = hb_stackTopOffset();
pStackTopItem->item.asSymbol.macro = TRUE;
hb_stackPush();
}

View File

@@ -63,6 +63,8 @@
#include "hbpp.h"
#endif
extern HB_FUNC( __MVPUBLIC );
/* .and. & .or. expressions shortcuts - the expression optimiser needs
* a global variable
*/
@@ -797,6 +799,8 @@ HB_MACRO_PTR hb_macroCompile( char * szString )
}
/* This function handles a macro function calls, e.g. var :=&macro()
* and creating memvar variables using PUBLIC/PRIVATE command
* PUBLIC &macro
*
* 'pItem' points to a ITEM that contains a string value which after
* text substitution will return a function name
@@ -822,17 +826,7 @@ void hb_macroPushSymbol( HB_ITEM_PTR pItem )
/* NOTE: checking for valid function name (valid pointer) is done
* in hb_vmDo()
*/
if( pDynSym && ((pDynSym->pSymbol->pFunPtr == NULL) || (pDynSym->pSymbol->cScope & HB_FS_STATIC)) )
{
/* static functions are not allowed in macro */
HB_ITEM_PTR pError = hb_errRT_New( ES_ERROR, NULL, EG_NOFUNC, 1001,
NULL, szString,
0, EF_NONE );
hb_errLaunch( pError );
hb_errRelease( pError );
}
hb_vmPushSymbol( pDynSym->pSymbol ); /* push compiled symbol instead of a string */
hb_vmPushMacroSymbol( pDynSym->pSymbol ); /* push compiled symbol instead of a string */
if( bNewBuffer )
hb_xfree( szString ); /* free space allocated in hb_macroTextSubst */