20000503-01:00 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/hbpcode.c
* Fixed hb_compStrongType() to difrentiate between a MEMVAR and a DECLARED FUNCTION with the same name.
+ Added support for HB_P_ARRAYPUSH
* source/compiler/hbgenerr.c
* Minor correction to "Incompatibe return type"
* tests/testwarn.prg
+ Added code to demonstrate more warnings.
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
20000503-01:00 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
* source/compiler/hbpcode.c
|
||||
* Fixed hb_compStrongType() to difrentiate between a MEMVAR and a DECLARED FUNCTION with the same name.
|
||||
+ Added support for HB_P_ARRAYPUSH
|
||||
|
||||
* source/compiler/hbgenerr.c
|
||||
* Minor correction to "Incompatibe return type"
|
||||
|
||||
* tests/testwarn.prg
|
||||
+ Added code to demonstrate more warnings.
|
||||
|
||||
20000502-23:15 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
|
||||
* include/hbcomp.h
|
||||
|
||||
@@ -104,7 +104,7 @@ char * hb_comp_szWarnings[] =
|
||||
"3Suspicious type in assignment to: \'%s\' expected: \'%s\'",
|
||||
"3Suspicious operand type: \'unknown\' expected: \'%s\'",
|
||||
"3Can\'t use array index with non-array",
|
||||
"3Incompatible return value: \'%s\' expected: \'%s\'",
|
||||
"3Incompatible return type: \'%s\' expected: \'%s\'",
|
||||
"3Invalid number of parameters: %s expected: %s",
|
||||
"3Incompatible parameter number %s expected: \'%s\'",
|
||||
"3Duplicate Declaration of Function %s",
|
||||
|
||||
@@ -584,41 +584,51 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
case HB_P_PUSHSYM :
|
||||
case HB_P_MPUSHSYM :
|
||||
pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256 );
|
||||
|
||||
if ( pSym && pSym->szName )
|
||||
pDeclared = hb_compDeclaredFind( pSym->szName );
|
||||
|
||||
if ( pDeclared )
|
||||
{
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pDeclared->cType;
|
||||
|
||||
/* Storing, will be checked by FUNCTION* */
|
||||
hb_comp_cParamTypes = pDeclared->cParamTypes;
|
||||
hb_comp_iParamCount = pDeclared->iParamCount;
|
||||
}
|
||||
else
|
||||
/* In Private or Public statement can't be a declared function */
|
||||
if( ( hb_comp_iVarScope == VS_PRIVATE || hb_comp_iVarScope == VS_PUBLIC ) )
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
else
|
||||
{
|
||||
pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256 );
|
||||
|
||||
if ( pSym && pSym->szName )
|
||||
pDeclared = hb_compDeclaredFind( pSym->szName );
|
||||
|
||||
if ( pDeclared )
|
||||
{
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pDeclared->cType;
|
||||
|
||||
/* Storing, will be checked by FUNCTION* */
|
||||
hb_comp_cParamTypes = pDeclared->cParamTypes;
|
||||
hb_comp_iParamCount = pDeclared->iParamCount;
|
||||
}
|
||||
else
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_PUSHSYMNEAR :
|
||||
pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] );
|
||||
|
||||
if ( pSym && pSym->szName )
|
||||
pDeclared = hb_compDeclaredFind( pSym->szName );
|
||||
|
||||
if ( pDeclared )
|
||||
{
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pDeclared->cType;
|
||||
|
||||
/* Storing, will be checked by FUNCTION* */
|
||||
hb_comp_cParamTypes = pDeclared->cParamTypes;
|
||||
hb_comp_iParamCount = pDeclared->iParamCount;
|
||||
}
|
||||
/* In Private or Public statement can't be a declared function */
|
||||
if( ( hb_comp_iVarScope == VS_PRIVATE || hb_comp_iVarScope == VS_PUBLIC ) )
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
else
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
{
|
||||
pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] );
|
||||
|
||||
if ( pSym && pSym->szName )
|
||||
pDeclared = hb_compDeclaredFind( pSym->szName );
|
||||
|
||||
if ( pDeclared )
|
||||
{
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = pDeclared->cType;
|
||||
|
||||
/* Storing, will be checked by FUNCTION* */
|
||||
hb_comp_cParamTypes = pDeclared->cParamTypes;
|
||||
hb_comp_iParamCount = pDeclared->iParamCount;
|
||||
}
|
||||
else
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
}
|
||||
break;
|
||||
|
||||
/* Local Variables */
|
||||
@@ -776,8 +786,22 @@ void hb_compStrongType( int iSize )
|
||||
break;
|
||||
|
||||
case HB_P_ARRAYPUSH :
|
||||
/* TODO: Deal with Array Elements. */
|
||||
pFunc->pStack[ pFunc->iStackIndex++ ] = ' ';
|
||||
/* Poping the Array Index. */
|
||||
pFunc->iStackIndex--;
|
||||
|
||||
if ( pFunc->iStackIndex < 0 )
|
||||
/* TODO Error Message after finalizing all possible pcodes. */
|
||||
break;
|
||||
|
||||
if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' )
|
||||
;
|
||||
else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'A' )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_ARRAY, NULL, NULL );
|
||||
|
||||
/* TODO: allow declaration of the Array Elements Type. */
|
||||
|
||||
/* Now we have the array elent on the stack.*/
|
||||
pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' ';
|
||||
break;
|
||||
|
||||
/* Macros type unknown */
|
||||
@@ -990,7 +1014,6 @@ void hb_compStrongType( int iSize )
|
||||
/* TODO Error Message after finalizing all possible pcodes. */
|
||||
break;
|
||||
|
||||
/* TODO: Deal with Array Elements. */
|
||||
if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' )
|
||||
;
|
||||
else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'A' )
|
||||
|
||||
@@ -17,6 +17,23 @@ DECLARE FUNCTION seconds() AS NUM
|
||||
|
||||
DECLARE FUNCTION int( n AS NUMERIC ) AS NUMERIC
|
||||
|
||||
DECLARE FUNCTION TEST AS NUMERIC
|
||||
|
||||
PROC MAIN0()
|
||||
PRIVATE OTHER, TEST AS CHAR
|
||||
|
||||
Var1 := M->TEST
|
||||
Var2 := Test()
|
||||
|
||||
M->TEST := 1
|
||||
M->TEST := "incorrect warning"
|
||||
test[ 1 ][ 2 ] := "incorrect warning"
|
||||
|
||||
RETURN
|
||||
|
||||
Function Test()
|
||||
return .t.
|
||||
|
||||
Function Main()
|
||||
Local n As Numeric, lVar AS LOGICAL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user