20000503-21:30 GMT-8 Ron Pinkas <Ron@Profit-Master.com>

* include/hbcomp.h
     + Added:
	#define VU_NOT_USED    0
	#define VU_INITIALIZED 1
	#define VU_USED        2

   * source/compiler/harbour.c
      * Modified refrences to pVar->iUsed to use new VU_* constants.

   * source/compiler/hbpcode.c
     * Enhanced hb_compStrongType() to check and set pVar->iUsed with new VU_*constants.
This commit is contained in:
Ron Pinkas
2000-05-04 04:35:54 +00:00
parent f6cc8be651
commit eec5c93ec1
5 changed files with 48 additions and 14 deletions

View File

@@ -1,3 +1,17 @@
20000503-21:30 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* include/hbcomp.h
+ Added:
#define VU_NOT_USED 0
#define VU_INITIALIZED 1
#define VU_USED 2
* source/compiler/harbour.c
* Modified refrences to pVar->iUsed to use new VU_* constants.
* source/compiler/hbpcode.c
* Enhanced hb_compStrongType() to check and set pVar->iUsed with new VU_*constants.
20000503-19:25 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/harbour.c

View File

@@ -175,6 +175,10 @@ void hb_compPCodeEval( PFUNCTION, HB_PCODE_FUNC_PTR *, void * );
#define VS_PUBLIC 128
#define VS_MEMVAR ( VS_PUBLIC | VS_PRIVATE )
#define VU_NOT_USED 0
#define VU_INITIALIZED 1
#define VU_USED 2
/*
* flags for bFlags member
*/

View File

@@ -522,13 +522,16 @@ void hb_compVariableAdd( char * szVarName, char cValueType )
pVar->szName = szVarName;
pVar->szAlias = NULL;
pVar->cType = hb_comp_cVarType;
pVar->iUsed = 0;
pVar->iUsed = VU_NOT_USED;
pVar->pNext = NULL;
/* Correct Type was previously stored in the CodeBlock. */
if( ! pFunc->szName )
pVar->cType = cValueType;
if ( hb_comp_iVarScope & VS_PARAMETER )
pVar->iUsed = VU_INITIALIZED;
if( hb_comp_iVarScope & VS_MEMVAR )
{
PCOMSYMBOL pSym;
@@ -1099,8 +1102,10 @@ USHORT hb_compVariableGetPos( PVAR pVars, char * szVarName ) /* returns the orde
{
if( pVars->szName && ! strcmp( pVars->szName, szVarName ) )
{
/* Might be set to -1 by StrongType if so leave without change, otherwise set to 1. */
pVars->iUsed |= 1;
/* Might be set to -1 by StrongType if so leave without change, otherwise set to 1.
Handled by hb_compStrongType()
pVars->iUsed |= VU_USED;
*/
return wVar;
}
else
@@ -1212,7 +1217,7 @@ static int hb_compLocalGetPos( char * szVarName ) /* returns the order + 1 of a
pVar = ( PVAR ) hb_xgrab( sizeof( VAR ) );
pVar->szName = szVarName;
pVar->cType = ' ';
pVar->iUsed = 0;
pVar->iUsed = VU_NOT_USED;
pVar->pNext = NULL;
/* Use negative order to signal that we are accessing a local
@@ -2497,7 +2502,7 @@ void hb_compFinalizeFunction( void ) /* fixes all last defined function returns
pVar = pFunc->pLocals;
while( pVar )
{
if( pVar->szName && pFunc->szName && pFunc->szName[0] && ! pVar->iUsed )
if( pVar->szName && pFunc->szName && pFunc->szName[0] && ! ( pVar->iUsed & VU_USED ) )
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_VAR_NOT_USED, pVar->szName, pFunc->szName );
pVar = pVar->pNext;
@@ -2506,7 +2511,7 @@ void hb_compFinalizeFunction( void ) /* fixes all last defined function returns
pVar = pFunc->pStatics;
while( pVar )
{
if( pVar->szName && pFunc->szName && pFunc->szName[0] && ! pVar->iUsed )
if( pVar->szName && pFunc->szName && pFunc->szName[0] && ! ( pVar->iUsed & VU_USED ) )
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_VAR_NOT_USED, pVar->szName, pFunc->szName );
pVar = pVar->pNext;
@@ -3007,7 +3012,7 @@ void hb_compCodeBlockEnd( void )
pVar = pCodeblock->pLocals;
while( pVar )
{
if( hb_comp_iWarnings && pFunc->szName && pVar->szName && ! pVar->iUsed )
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 */

View File

@@ -653,9 +653,12 @@ void hb_compStrongType( int iSize )
if ( pVar )
{
if ( pVar->iUsed >= 0 )
if ( ! ( pVar->iUsed & VU_INITIALIZED ) )
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
/* Mark as used */
pVar->iUsed |= VU_USED;
/* Review with Ryszard. */
if ( pVar->cType == 'U' )
pVar->cType = ' ';
@@ -692,9 +695,12 @@ void hb_compStrongType( int iSize )
if ( pVar )
{
if ( pVar->iUsed >= 0 )
if ( ! ( pVar->iUsed & VU_INITIALIZED ) )
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
/* Mark as used */
pVar->iUsed |= VU_USED;
pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType;
}
else
@@ -715,9 +721,12 @@ void hb_compStrongType( int iSize )
if ( pVar )
{
if ( pVar->iUsed >= 0 )
if ( ! ( pVar->iUsed & VU_INITIALIZED ) )
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL );
/* Mark as used */
pVar->iUsed |= VU_USED;
pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType;
}
else
@@ -919,7 +928,7 @@ void hb_compStrongType( int iSize )
pVar = hb_compVariableFind( pFunc->pLocals, wVar );
if ( pVar )
pVar->iUsed = -1;
pVar->iUsed |= VU_INITIALIZED;
if ( pVar && pVar->cType != ' ' )
{
@@ -959,7 +968,7 @@ void hb_compStrongType( int iSize )
pVar = hb_compVariableFind( pFunc->pLocals, iVar );
if ( pVar )
pVar->iUsed = -1;
pVar->iUsed |= VU_INITIALIZED;
if ( pVar && pVar->cType != ' ' )
{
@@ -990,7 +999,7 @@ void hb_compStrongType( int iSize )
pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase );
if ( pVar )
pVar->iUsed = -1;
pVar->iUsed |= VU_INITIALIZED;
if ( pVar && pVar->cType != ' ' )
{

View File

@@ -19,9 +19,11 @@ DECLARE FUNCTION int( n AS NUMERIC ) AS NUMERIC
DECLARE FUNCTION TEST AS NUMERIC
PROCEDURE MAIN
PROCEDURE MAIN( Param1 )
LOCAL RPT, APARAMS
Rpt := IIF( Param1, 1 , 0 )
Rpt := Array( Len( AParams ) - 2 )
RETURN