2005-01-03 10:30 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* include/hbcomp.h
* include/hbexprb.c
* include/hbmacro.h
* source/compiler/exproptb.c
* source/compiler/harbour.c
* source/compiler/hbgenerr.c
* source/macro/macrob.c
* source/vm/macro.c
* compiler reports error on the following syntax now (Clipper
compatibility):
{|| ¯ovar <operator> anysymbol}
"codeblock contains both macro and declared symbol reference"
Notice, that Clipper reports error even in this case:
MEMVAR mvar
{|| &mvar,mvar}
* source/vm/memvars.c
* restored initial and expand sizes for memvars table
* source/pp/ppcore.c
* some empty lines added
This commit is contained in:
@@ -5,6 +5,6 @@
|
||||
/* hbexprb.c is also included from ../macro/macro.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 1.11 - ignore this magic number - this is used to force compilation
|
||||
* 1.12 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
#include "hbexprb.c"
|
||||
|
||||
@@ -1507,6 +1507,7 @@ static PFUNCTION hb_compFunctionNew( char * szName, HB_SYMBOLSCOPE cScope )
|
||||
pFunc->iStackIndex = 0;
|
||||
pFunc->iStackFunctions = 0;
|
||||
pFunc->iStackClasses = 0;
|
||||
pFunc->bLateEval = TRUE;
|
||||
|
||||
return pFunc;
|
||||
}
|
||||
@@ -2690,6 +2691,22 @@ void hb_compGenMessageData( char * szMsg ) /* generates an underscore-symbol nam
|
||||
hb_compGenMessage( szResult );
|
||||
}
|
||||
|
||||
static void hb_compCheckEarlyMacroEval( char *szVarName )
|
||||
{
|
||||
int iScope = hb_compVariableScope( szVarName );
|
||||
|
||||
if( iScope == HB_VS_CBLOCAL_VAR ||
|
||||
iScope == HB_VS_STATIC_VAR ||
|
||||
iScope == HB_VS_GLOBAL_STATIC ||
|
||||
iScope == HB_VS_LOCAL_FIELD ||
|
||||
iScope == HB_VS_GLOBAL_FIELD ||
|
||||
iScope == HB_VS_LOCAL_MEMVAR ||
|
||||
iScope == HB_VS_GLOBAL_MEMVAR )
|
||||
{
|
||||
hb_compErrorCodeblock( szVarName );
|
||||
}
|
||||
}
|
||||
|
||||
/* Check variable in the following order:
|
||||
* LOCAL variable
|
||||
* local STATIC variable
|
||||
@@ -2704,6 +2721,13 @@ void hb_compGenPopVar( char * szVarName ) /* generates the pcode to pop a value
|
||||
{
|
||||
int iVar;
|
||||
|
||||
if( ! hb_comp_functions.pLast->bLateEval )
|
||||
{
|
||||
/* pseudo-generation of pcode for a codeblock with macro symbol */
|
||||
hb_compCheckEarlyMacroEval( szVarName );
|
||||
return;
|
||||
}
|
||||
|
||||
iVar = hb_compLocalGetPos( szVarName );
|
||||
if( iVar )
|
||||
{
|
||||
@@ -2864,11 +2888,19 @@ void hb_compGenPopAliasedVar( char * szVarName,
|
||||
|
||||
/* generates the pcode to push a nonaliased variable value to the virtual
|
||||
* machine stack
|
||||
* bMacroVar is TRUE if macro &szVarName context
|
||||
*/
|
||||
void hb_compGenPushVar( char * szVarName )
|
||||
void hb_compGenPushVar( char * szVarName, BOOL bMacroVar )
|
||||
{
|
||||
int iVar;
|
||||
|
||||
if( ! hb_comp_functions.pLast->bLateEval && ! bMacroVar )
|
||||
{
|
||||
/* pseudo-generation of pcode for a codeblock with macro symbol */
|
||||
hb_compCheckEarlyMacroEval( szVarName );
|
||||
return;
|
||||
}
|
||||
|
||||
iVar = hb_compLocalGetPos( szVarName );
|
||||
if( iVar )
|
||||
{
|
||||
@@ -2964,6 +2996,13 @@ void hb_compGenPushVarRef( char * szVarName ) /* generates the pcode to push a v
|
||||
{
|
||||
int iVar;
|
||||
|
||||
if( ! hb_comp_functions.pLast->bLateEval )
|
||||
{
|
||||
/* pseudo-generation of pcode for a codeblock with macro symbol */
|
||||
hb_compCheckEarlyMacroEval( szVarName );
|
||||
return;
|
||||
}
|
||||
|
||||
iVar = hb_compLocalGetPos( szVarName );
|
||||
if( iVar )
|
||||
{
|
||||
@@ -3752,13 +3791,14 @@ void hb_compStaticDefEnd( void )
|
||||
/*
|
||||
* Start a new fake-function that will hold pcodes for a codeblock
|
||||
*/
|
||||
void hb_compCodeBlockStart()
|
||||
void hb_compCodeBlockStart( BOOL bLateEval )
|
||||
{
|
||||
PFUNCTION pBlock;
|
||||
|
||||
pBlock = hb_compFunctionNew( NULL, HB_FS_STATIC );
|
||||
pBlock->pOwner = hb_comp_functions.pLast;
|
||||
pBlock->iStaticsBase = hb_comp_functions.pLast->iStaticsBase;
|
||||
pBlock->bLateEval = bLateEval;
|
||||
|
||||
hb_comp_functions.pLast = pBlock;
|
||||
}
|
||||
@@ -3919,9 +3959,7 @@ void hb_compCodeBlockEnd( void )
|
||||
void hb_compCodeBlockStop( void )
|
||||
{
|
||||
PFUNCTION pCodeblock; /* pointer to the current codeblock */
|
||||
PFUNCTION pFunc; /* pointer to a function that owns a codeblock */
|
||||
USHORT wLocals = 0; /* number of referenced local variables */
|
||||
USHORT wUsed;
|
||||
PFUNCTION pFunc;/* pointer to a function that owns a codeblock */
|
||||
PVAR pVar, pFree;
|
||||
|
||||
pCodeblock = hb_comp_functions.pLast;
|
||||
@@ -3936,22 +3974,11 @@ void hb_compCodeBlockStop( void )
|
||||
while( pFunc->pOwner )
|
||||
pFunc = pFunc->pOwner;
|
||||
|
||||
pFunc->bFlags |= ( pCodeblock->bFlags & FUN_USES_STATICS );
|
||||
|
||||
/* Count the number of referenced local variables */
|
||||
pVar = pCodeblock->pStatics;
|
||||
while( pVar )
|
||||
{
|
||||
pVar = pVar->pNext;
|
||||
++wLocals;
|
||||
}
|
||||
|
||||
wUsed =0;
|
||||
pVar = pCodeblock->pLocals;
|
||||
while( pVar )
|
||||
{
|
||||
if( pVar->iUsed & VU_USED )
|
||||
wUsed = 1;
|
||||
if( hb_comp_iWarnings && pFunc->szName && pVar->szName && ! ( pVar->iUsed & VU_USED ) )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_BLOCKVAR_NOT_USED, pVar->szName, pFunc->szName );
|
||||
|
||||
/* free used variables */
|
||||
pFree = pVar;
|
||||
@@ -3965,6 +3992,27 @@ void hb_compCodeBlockStop( void )
|
||||
hb_xfree( ( void * ) pCodeblock );
|
||||
}
|
||||
|
||||
void hb_compCodeBlockRewind()
|
||||
{
|
||||
PFUNCTION pCodeblock; /* pointer to the current codeblock */
|
||||
|
||||
pCodeblock = hb_comp_functions.pLast;
|
||||
pCodeblock->lPCodePos = 0;
|
||||
|
||||
/* Release the NOOP array. */
|
||||
if( pCodeblock->pNOOPs )
|
||||
hb_xfree( ( void * ) pCodeblock->pNOOPs );
|
||||
|
||||
/* Release the Jumps array. */
|
||||
if( pCodeblock->pJumps )
|
||||
hb_xfree( ( void * ) pCodeblock->pJumps );
|
||||
|
||||
/* Compile Time Strong Type Checking Stack is not needed any more. */
|
||||
if ( pCodeblock->pStack )
|
||||
hb_xfree( ( void * ) pCodeblock->pStack );
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
/* initialize support variables */
|
||||
|
||||
@@ -79,7 +79,7 @@ char * hb_comp_szErrors[] =
|
||||
"ANNOUNCEd procedure \'%s\' must be a public symbol",
|
||||
"Jump PCode not found",
|
||||
"CASE or OTHERWISE does not match DO CASE",
|
||||
"Code block contains both macro and declared symbol references",
|
||||
"Code block contains both macro and declared symbol references \'%s\'",
|
||||
"GET contains complex macro",
|
||||
"Unterminated inline block in function: \'%s\'",
|
||||
"Too many inline blocks %s",
|
||||
@@ -227,6 +227,7 @@ HB_EXPR_PTR hb_compWarnMeaningless( HB_EXPR_PTR pExpr )
|
||||
void hb_compErrorCodeblock( char * szBlock )
|
||||
{
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BLOCK, szBlock, NULL );
|
||||
hb_comp_bError = FALSE; /* clear error flag for this line */
|
||||
}
|
||||
|
||||
void hb_compErrorMacro( char *szText )
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* hbexprb.c is also included from ../compiler/exproptb.c
|
||||
* However it produces a slighty different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
* 1.10 - ignore this magic number - this is used to force compilation
|
||||
* 1.11 - ignore this magic number - this is used to force compilation
|
||||
*/
|
||||
|
||||
#define HB_MACRO_SUPPORT
|
||||
|
||||
@@ -1686,16 +1686,23 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
|
||||
s_numBrackets = 0;
|
||||
HB_SKIPTABSPACES( ptri );
|
||||
if( ptrmp == NULL ) { if( *ptri != '\0' ) return -1; }
|
||||
if( ptrmp == NULL )
|
||||
{
|
||||
if( *ptri != '\0' )
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( *ptri != '\0' && !endTranslation )
|
||||
{
|
||||
{
|
||||
HB_SKIPTABSPACES( ptrmp );
|
||||
if( *ptrmp == '[' && !s_numBrackets && !strtopti )
|
||||
{
|
||||
strtopti = ptrmp;
|
||||
}
|
||||
if( !s_numBrackets && strtopti && strtptri != ptri &&
|
||||
( ISNAME( ( BYTE ) *ptri ) || *ptri=='&' ) )
|
||||
{
|
||||
{
|
||||
strtptri = ptri;
|
||||
ptrmp = strtopti;
|
||||
ptr = ptri;
|
||||
@@ -1708,7 +1715,8 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
if( ptr )
|
||||
ptrmp = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch( *ptrmp ) {
|
||||
case '[':
|
||||
if( !s_numBrackets ) isWordInside = 0;
|
||||
@@ -1717,21 +1725,24 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
lastopti[s_Repeate++] = ptrmp;
|
||||
ptrmp++;
|
||||
if( !CheckOptional( ptrmp, ptri, ptro, lenres, com_or_tra, com_or_xcom ) )
|
||||
{
|
||||
SkipOptional( &ptrmp );
|
||||
}
|
||||
break;
|
||||
|
||||
case ']':
|
||||
if( s_Repeate )
|
||||
{
|
||||
s_Repeate--;
|
||||
if( s_aIsRepeate[ s_Repeate ] )
|
||||
{
|
||||
{
|
||||
if( ISNAME( ( BYTE ) *ptri) )
|
||||
{
|
||||
{
|
||||
ptr = ptri;
|
||||
ipos = NextName( &ptr, tmpname );
|
||||
ipos = md_strAt( tmpname, ipos, ptrmp, TRUE, TRUE, TRUE );
|
||||
if( ipos && TestOptional( ptrmp+1, ptrmp+ipos-2 ) )
|
||||
{
|
||||
{
|
||||
ptr = PrevSquare( ptrmp+ipos-2, ptrmp+1, NULL );
|
||||
if( !ptr || CheckOptional( ptrmp+1, ptri, ptro, lenres, com_or_tra, com_or_xcom ) )
|
||||
{
|
||||
@@ -1745,18 +1756,22 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
}
|
||||
else
|
||||
ptrmp = lastopti[s_Repeate];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrmp = lastopti[s_Repeate];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrmp = lastopti[s_Repeate];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if( !isWordInside ) strtopti = NULL;
|
||||
ptrmp++;
|
||||
}
|
||||
}
|
||||
s_numBrackets--;
|
||||
}
|
||||
else
|
||||
@@ -1765,6 +1780,7 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
s_numBrackets--; ptrmp++;
|
||||
}
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if( s_numBrackets == 1 ) isWordInside = 1;
|
||||
if( !s_numBrackets ) strtopti = NULL;
|
||||
@@ -1778,6 +1794,7 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
else return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\1': /* Match marker */
|
||||
if( !s_numBrackets ) strtopti = NULL;
|
||||
if( s_numBrackets == 1 && *(ptrmp+2) == '2' ) isWordInside = 1; /* restricted match marker */
|
||||
@@ -1790,11 +1807,13 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
else return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
if( com_or_tra )
|
||||
return -1;
|
||||
else endTranslation = TRUE;
|
||||
break;
|
||||
|
||||
default: /* Key word */
|
||||
if( s_numBrackets == 1 ) isWordInside = 1;
|
||||
if( !s_numBrackets ) strtopti = NULL;
|
||||
@@ -1810,8 +1829,9 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
}
|
||||
}
|
||||
HB_SKIPTABSPACES( ptri );
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
if( *ptrmp != '\0' )
|
||||
{
|
||||
if( s_Repeate ) { s_Repeate = 0; ptrmp = lastopti[0]; }
|
||||
|
||||
@@ -1401,10 +1401,12 @@ void hb_compGenPopAliasedVar( char * szVarName,
|
||||
/* generates the pcode to push a nonaliased variable value to the virtual
|
||||
* machine stack
|
||||
*/
|
||||
void hb_compGenPushVar( char * szVarName, HB_MACRO_DECL )
|
||||
void hb_compGenPushVar( char * szVarName, BOOL bMacroVar, HB_MACRO_DECL )
|
||||
{
|
||||
int iVar;
|
||||
|
||||
HB_SYMBOL_UNUSED( bMacroVar );
|
||||
|
||||
iVar = hb_compLocalVarGetPos( szVarName, HB_MACRO_PARAM );
|
||||
if( iVar )
|
||||
{
|
||||
|
||||
@@ -85,8 +85,8 @@ static ULONG s_globalFirstFree = 0;
|
||||
static ULONG s_globalLastFree = 0;
|
||||
static HB_VALUE_PTR s_globalTable = NULL;
|
||||
|
||||
#define TABLE_INITHB_VALUE 1 //00
|
||||
#define TABLE_EXPANDHB_VALUE 2 //50
|
||||
#define TABLE_INITHB_VALUE 100
|
||||
#define TABLE_EXPANDHB_VALUE 50
|
||||
|
||||
struct mv_PUBLIC_var_info
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user