2001-04-09 11:50 UTC-0800 Ron Pinkas <ron@profit-master.com>
* include/hberrors.h
* source/compiler/hbgenerr.c
+ Added #define HB_COMP_WARN_PARAM_SUSPECT 18 -> "4Suspecious parameter: %s expected: \'%s\'"
* include/hbcomp.h
+ Added extern PCOMDECLARED hb_comp_pReleaseDeclared;
* source/compiler/harbour.c
+ Added static void hb_compDeclaredInit( void ) initializes decalaration of standard functions;
* source/compiler/genc.c
* Changed release code from hb_comp_pFirstDeclared to hb_comp_pReleaseDeclared.
* source/compiler/hbpcode.c
* Many refinments.
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
2001-04-09 11:50 UTC-0800 Ron Pinkas <ron@profit-master.com>
|
||||
* include/hberrors.h
|
||||
* source/compiler/hbgenerr.c
|
||||
+ Added #define HB_COMP_WARN_PARAM_SUSPECT 18 -> "4Suspecious parameter: %s expected: \'%s\'"
|
||||
|
||||
* include/hbcomp.h
|
||||
+ Added extern PCOMDECLARED hb_comp_pReleaseDeclared;
|
||||
|
||||
* source/compiler/harbour.c
|
||||
+ Added static void hb_compDeclaredInit( void ) initializes decalaration of standard functions;
|
||||
|
||||
* source/compiler/genc.c
|
||||
* Changed release code from hb_comp_pFirstDeclared to hb_comp_pReleaseDeclared.
|
||||
|
||||
* source/compiler/hbpcode.c
|
||||
* Many refinments.
|
||||
|
||||
2001-04-08 16:15 UTC-0800 Ron Pinkas <ron@profit-master.com>
|
||||
* include/hberrors.h
|
||||
! Corrected typo.
|
||||
|
||||
@@ -407,6 +407,7 @@ extern FUNCTIONS hb_comp_funcalls;
|
||||
extern SYMBOLS hb_comp_symbols;
|
||||
extern PCOMDECLARED hb_comp_pFirstDeclared;
|
||||
extern PCOMDECLARED hb_comp_pLastDeclared;
|
||||
extern PCOMDECLARED hb_comp_pReleaseDeclared;
|
||||
extern PCOMCLASS hb_comp_pFirstClass;
|
||||
extern PCOMCLASS hb_comp_pLastClass;
|
||||
extern char * hb_comp_szFromClass;
|
||||
|
||||
@@ -111,21 +111,21 @@ extern "C" {
|
||||
#define HB_COMP_WARN_OPERAND_SUSPECT 12
|
||||
#define HB_COMP_WARN_NOT_ARRAY 13
|
||||
#define HB_COMP_WARN_RETURN_TYPE 14
|
||||
#define HB_COMP_WARN_PARAM_COUNT 15
|
||||
#define HB_COMP_WARN_PARAM_TYPE 16
|
||||
#define HB_COMP_WARN_DUP_DECLARATION 17
|
||||
#define HB_COMP_WARN_DECLARATION_CONFLICT 18
|
||||
#define HB_COMP_WARN_NOT_INITIALIZED 19
|
||||
#define HB_COMP_WARN_VAL_NOT_USED 20
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_TYPE 21
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT 22
|
||||
#define HB_COMP_WARN_CLASS_NOT_FOUND 23
|
||||
#define HB_COMP_WARN_MESSAGE_NOT_FOUND 24
|
||||
#define HB_COMP_WARN_MEANINGLESS 25
|
||||
#define HB_COMP_WARN_UNREACHABLE 26
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 27
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 27
|
||||
#define HB_COMP_WARN_RETURN_SUSPECT 28
|
||||
#define HB_COMP_WARN_RETURN_SUSPECT 15
|
||||
#define HB_COMP_WARN_PARAM_COUNT 16
|
||||
#define HB_COMP_WARN_PARAM_TYPE 17
|
||||
#define HB_COMP_WARN_PARAM_SUSPECT 18
|
||||
#define HB_COMP_WARN_DUP_DECLARATION 19
|
||||
#define HB_COMP_WARN_DECLARATION_CONFLICT 20
|
||||
#define HB_COMP_WARN_NOT_INITIALIZED 21
|
||||
#define HB_COMP_WARN_VAL_NOT_USED 22
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_TYPE 23
|
||||
#define HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT 24
|
||||
#define HB_COMP_WARN_CLASS_NOT_FOUND 25
|
||||
#define HB_COMP_WARN_MESSAGE_NOT_FOUND 26
|
||||
#define HB_COMP_WARN_MEANINGLESS 27
|
||||
#define HB_COMP_WARN_UNREACHABLE 28
|
||||
#define HB_COMP_WARN_DUPL_ANNOUNCE 29
|
||||
|
||||
/*
|
||||
* Errors generated by Harbour preprocessor
|
||||
|
||||
@@ -282,7 +282,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
pInline = hb_comp_inlines.pFirst;
|
||||
}
|
||||
|
||||
pDeclared = hb_comp_pFirstDeclared;
|
||||
pDeclared = hb_comp_pReleaseDeclared->pNext;
|
||||
while( pDeclared )
|
||||
{
|
||||
hb_comp_pFirstDeclared = pDeclared->pNext;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
* hb_compMethodAdd()
|
||||
* hb_compMethodFind()
|
||||
* hb_compDeclaredAdd()
|
||||
* hb_compDeclaredInit()
|
||||
*
|
||||
* See doc/license.txt for licensing terms.
|
||||
*
|
||||
@@ -77,6 +78,8 @@ static void hb_compOptimizeJumps( void );
|
||||
static void hb_compPrepareOptimize( void );
|
||||
static void hb_compOptimizeFrames( PFUNCTION pFunc );
|
||||
|
||||
static void hb_compDeclaredInit( void );
|
||||
|
||||
/* global variables */
|
||||
FILES hb_comp_files;
|
||||
FUNCTIONS hb_comp_functions;
|
||||
@@ -84,6 +87,7 @@ FUNCTIONS hb_comp_funcalls;
|
||||
SYMBOLS hb_comp_symbols;
|
||||
PCOMDECLARED hb_comp_pFirstDeclared;
|
||||
PCOMDECLARED hb_comp_pLastDeclared;
|
||||
PCOMDECLARED hb_comp_pReleaseDeclared;
|
||||
|
||||
PCOMCLASS hb_comp_pFirstClass;
|
||||
PCOMCLASS hb_comp_pLastClass;
|
||||
@@ -209,6 +213,10 @@ int main( int argc, char * argv[] )
|
||||
/* Prepare the table of identifiers */
|
||||
hb_compIdentifierOpen();
|
||||
|
||||
/* Load standard Declarations. */
|
||||
if ( hb_comp_iWarnings >= 3 )
|
||||
hb_compDeclaredInit();
|
||||
|
||||
/* Process all files passed via the command line. */
|
||||
|
||||
bAnyFiles = FALSE;
|
||||
@@ -885,6 +893,38 @@ PCOMDECLARED hb_compMethodFind( PCOMCLASS pClass, char * szMethodName )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hb_compDeclaredInit( void )
|
||||
{
|
||||
/*
|
||||
\x5c -> ByRef (+60) '-' -> NIL
|
||||
\x7a -> Optional (+90) 'U' -> Undefined
|
||||
|
||||
' ' -> AnyType 'A' -> Array 'B' -> Array
|
||||
'A' -> Array of AnyType 'a' -> Array of Arrays 'b' -> Array of Blocks
|
||||
\x7a -> Optional AnyType \x9b -> Optional Array \x9c -> Optional Block
|
||||
\x94 -> Optional Array of AnyType \xb5 -> Optional Array of Arrays \xb6 -> Optional Array of Blocks
|
||||
|
||||
'C' -> Character/String 'D' -> Date 'L' -> Logical
|
||||
'c' -> Array of Strings 'd' -> Array of Dates 'l' -> Array of Logicals
|
||||
\x9d -> Optional Character \x9e -> Optional Date \xa6 -> Optional Logical
|
||||
\xb7 -> Optional Array of Strings \xb8 -> Optional Array of Dates \xc0 -> Optional Array of Logicals
|
||||
|
||||
'N' -> Numeric 'O' -> Object 'S' -> Class
|
||||
'n' -> Array of Numerics 'o' -> Array of Objects 's' -> Array of Classes
|
||||
\xa8 -> Optional Numeric \xa9 -> Optional Object \xad -> Optional Class
|
||||
\xc2 -> Optional Array of Numerics \xc3 -> Optional Array of Objects \xc7 -> Optional Array of Classes
|
||||
|
||||
Name Ret Param Types # of Prams Class Param Classes Next
|
||||
---------- --- ----------------------- ---------- ----- ------------- ------ */
|
||||
static COMDECLARED s_001 = { "AADD" , ' ', "A " , 2 , NULL , NULL , NULL };
|
||||
static COMDECLARED s_002 = { "ABS" , 'N', "N" , 1 , NULL , NULL , &s_001 };
|
||||
static COMDECLARED s_003 = { "ACHOICE" , 'N', "NNNNc\x7a\x9d\xa8\xa8", 9 , NULL , NULL , &s_002 };
|
||||
|
||||
hb_comp_pFirstDeclared = &s_003; /* Change to BOTTOM item. */
|
||||
hb_comp_pLastDeclared = &s_001;
|
||||
hb_comp_pReleaseDeclared = &s_001;
|
||||
}
|
||||
|
||||
PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName )
|
||||
{
|
||||
PCOMDECLARED pDeclared;
|
||||
@@ -916,12 +956,7 @@ PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName )
|
||||
pDeclared->pParamClasses = NULL;
|
||||
pDeclared->pNext = NULL;
|
||||
|
||||
/* First Declare */
|
||||
if ( hb_comp_pFirstDeclared == NULL )
|
||||
hb_comp_pFirstDeclared = pDeclared;
|
||||
else
|
||||
hb_comp_pLastDeclared->pNext = pDeclared;
|
||||
|
||||
hb_comp_pLastDeclared->pNext = pDeclared;
|
||||
hb_comp_pLastDeclared = pDeclared;
|
||||
|
||||
return pDeclared;
|
||||
|
||||
@@ -108,13 +108,15 @@ char * hb_comp_szWarnings[] =
|
||||
"1Function \'%s\' does not end with RETURN statement",
|
||||
"3Incompatible type in assignment to: \'%s\' expected: \'%s\'",
|
||||
"3Incompatible operand type: \'%s\' expected: \'%s\'",
|
||||
"4Suspicious operand type: \'unknown\' expected: \'%s\'",
|
||||
"3Incompatible operand types: \'%s\' and: \'%s\'",
|
||||
"4Suspicious type in assignment to: \'%s\' expected: \'%s\'",
|
||||
"4Suspicious operand type: \'unknown\' expected: \'%s\'",
|
||||
"3Can\'t use array index with non-array",
|
||||
"3Incompatible return type: \'%s\' expected: \'%s\'",
|
||||
"4Suspecious return type: \'%s\' expected: \'%s\'",
|
||||
"3Invalid number of parameters: %s expected: %s",
|
||||
"3Incompatible parameter # %s expected: \'%s\'",
|
||||
"3Incompatible parameter: %s expected: \'%s\'",
|
||||
"4Suspecious parameter: %s expected: \'%s\'",
|
||||
"3Duplicate declaration of %s \'%s\'",
|
||||
"3Function \'%s\' conflicting with its declaration",
|
||||
"3Variable \'%s\' used but never initialized",
|
||||
@@ -125,8 +127,7 @@ char * hb_comp_szWarnings[] =
|
||||
"3Message \'%s\' not known in class \'%s\'",
|
||||
"0Meaningless use of expression: \'%s\'",
|
||||
"2Unreachable code",
|
||||
"1Redundant \'ANNOUNCE %s\' statement ignored",
|
||||
"4Suspecious return type: \'%s\' expected: \'%s\'"
|
||||
"1Redundant \'ANNOUNCE %s\' statement ignored"
|
||||
};
|
||||
|
||||
void hb_compGenError( char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
|
||||
|
||||
@@ -385,6 +385,8 @@ void hb_compStrongType( int iSize )
|
||||
/*
|
||||
printf( "\nNeeded %i values, found %i!\n", wVar + 1, pFunc->iStackIndex - 1 );
|
||||
*/
|
||||
pFunc->iStackIndex = 1;
|
||||
pFunc->pStack[ 0 ] = ' ';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -406,9 +408,10 @@ void hb_compStrongType( int iSize )
|
||||
break;
|
||||
}
|
||||
|
||||
/*printf( "\nOptionals: %i\n", iOptionals );*/
|
||||
|
||||
printf( "\nExec Function: %s, wVar: %i Parameters: %i Optionals: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName,wVar, hb_comp_iParamCount, iOptionals );
|
||||
/*
|
||||
printf( "\nOptionals: %i\n", iOptionals );
|
||||
printf( "\nExec Function: %s, wVar: %i Parameters: %i Optionals: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, wVar, hb_comp_iParamCount, iOptionals );
|
||||
*/
|
||||
|
||||
/* Now, check the types. */
|
||||
if( wVar >= ( hb_comp_iParamCount - iOptionals ) && wVar <= hb_comp_iParamCount )
|
||||
@@ -418,6 +421,8 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
while ( --iOffset >= 0 )
|
||||
{
|
||||
BOOL bByRef = FALSE;
|
||||
|
||||
cParamType = pFunc->pStack[ iParamBase + iOffset ];
|
||||
if( ( cParamType == '-' + VT_OFFSET_VARIANT ) || cParamType >= ( 'A' + VT_OFFSET_VARIANT ) )
|
||||
{
|
||||
@@ -425,28 +430,24 @@ void hb_compStrongType( int iSize )
|
||||
}
|
||||
|
||||
cFormalType = hb_comp_cParamTypes[ iOffset ];
|
||||
|
||||
if( cFormalType == ( ' ' + VT_OFFSET_OPTIONAL ) || cFormalType >= ( 'A' + VT_OFFSET_OPTIONAL ) )
|
||||
{
|
||||
cFormalType -= VT_OFFSET_OPTIONAL;
|
||||
}
|
||||
|
||||
if( cFormalType == ' ' + VT_OFFSET_BYREF )
|
||||
if( cFormalType == ' ' + VT_OFFSET_BYREF || cFormalType >= ( 'A' + VT_OFFSET_BYREF ) )
|
||||
{
|
||||
cFormalType = '@';
|
||||
bByRef = TRUE;
|
||||
cFormalType -= VT_OFFSET_BYREF;
|
||||
}
|
||||
|
||||
if( cFormalType == ' ' )
|
||||
/* --- */
|
||||
|
||||
if( cFormalType == ' ' && ! bByRef )
|
||||
{
|
||||
/* Declared is Variant, accept anything. */
|
||||
}
|
||||
else if( cParamType == '-' )
|
||||
{
|
||||
/* Parameter is NIL, always accepted. */
|
||||
}
|
||||
else if( cFormalType == '@' && cParamType >= ( 'A' + VT_OFFSET_BYREF ) )
|
||||
{
|
||||
/* Prameter is ANY REFERENCE, and Parameter is SOME REFERENCE. */
|
||||
}
|
||||
else if( cFormalType == 'S' && cParamType == 'S' && pFunc->iStackClasses )
|
||||
{
|
||||
PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ];
|
||||
@@ -454,7 +455,7 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
if( hb_comp_pFormalClass != hb_comp_pParamClass )
|
||||
{
|
||||
sprintf( ( char * ) szType1, "%i", iOffset + 1 );
|
||||
sprintf( ( char * ) szType1, "%s %i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, iOffset + 1 );
|
||||
sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName );
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 );
|
||||
}
|
||||
@@ -466,7 +467,7 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
if( hb_comp_pFormalClass != hb_comp_pParamClass )
|
||||
{
|
||||
sprintf( ( char * ) szType1, "%i", iOffset + 1 );
|
||||
sprintf( ( char * ) szType1, "%s %i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, iOffset + 1 );
|
||||
sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName );
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 );
|
||||
}
|
||||
@@ -485,30 +486,54 @@ void hb_compStrongType( int iSize )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( cFormalType > ( 'A' + VT_OFFSET_BYREF ) )
|
||||
{
|
||||
sprintf( ( char * ) szType2, "@%c", cFormalType - VT_OFFSET_BYREF );
|
||||
}
|
||||
else if( toupper( pFunc->pStack[ iParamBase + iOffset ] ) == 'S' && pFunc->iStackClasses )
|
||||
{
|
||||
/* Cleanup. */
|
||||
if( toupper( cParamType ) == 'S' && pFunc->iStackClasses )
|
||||
{
|
||||
--pFunc->iStackClasses;
|
||||
}
|
||||
|
||||
if( bByRef )
|
||||
{
|
||||
sprintf( ( char * ) szType2, "@%c", cFormalType );
|
||||
}
|
||||
else
|
||||
else if( islower( cFormalType ) )
|
||||
{
|
||||
sprintf( ( char * ) szType2, "ARRAY OF %c", toupper( cFormalType ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) szType2, "%c", cFormalType );
|
||||
}
|
||||
}
|
||||
|
||||
sprintf( ( char * ) szType1, "%i", iOffset + 1 );
|
||||
sprintf( ( char * ) szType1, "%s #%i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, iOffset + 1 );
|
||||
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 );
|
||||
if( cParamType == ' ' || cParamType == '-' || cParamType == 'U' )
|
||||
{
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_SUSPECT, ( char * ) szType1, ( char * ) szType2 );
|
||||
}
|
||||
else if( bByRef && cParamType == ( ' ' + VT_OFFSET_BYREF ) || cParamType >= ( 'A' + VT_OFFSET_BYREF ) )
|
||||
{
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_SUSPECT, ( char * ) szType1, ( char * ) szType2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) szType1, "%i", wVar );
|
||||
sprintf( ( char * ) szType2, "%i", hb_comp_iParamCount - iOptionals );
|
||||
sprintf( ( char * ) szType1, "%s got %i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, wVar );
|
||||
if( iOptionals )
|
||||
{
|
||||
sprintf( ( char * ) szType2, "%i-%i", hb_comp_iParamCount - iOptionals, hb_comp_iParamCount );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( ( char * ) szType2, "%i", hb_comp_iParamCount - iOptionals );
|
||||
}
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_COUNT, ( char * ) szType1, ( char * ) szType2 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user