From fc1f6778a87c8bbbea45759b38aaab60862a9215 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Tue, 10 Apr 2001 03:42:27 +0000 Subject: [PATCH] 2001-04-09 22:40 UTC-0800 Ron Pinkas * source/compiler/hbgenerr.c * Corrected spelling for suspicious. * source/compiler/hbpcode.c * Commented one debung printf() * include/hbcomp.h + Added extern PCOMCLASS hb_comp_pReleaseClass * source/compiler/genc.c + Added logic to release declared classes after compilation. * source/compiler/harbour.c + Added logic for standard classes declaration to hb_compDeclaredInit() + Added ERROR class declaration and started GET class declaration --- harbour/ChangeLog | 20 +++++++- harbour/include/hbcomp.h | 3 +- harbour/source/compiler/genc.c | 35 ++++++++++---- harbour/source/compiler/harbour.c | 78 ++++++++++++++++++++++++++---- harbour/source/compiler/hbgenerr.c | 4 +- harbour/source/compiler/hbpcode.c | 2 + 6 files changed, 118 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cf38791461..6721dc2c27 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,20 @@ +2001-04-09 22:40 UTC-0800 Ron Pinkas + * source/compiler/hbgenerr.c + * Corrected spelling for suspicious. + + * source/compiler/hbpcode.c + * Commented one debung printf() + + * include/hbcomp.h + + Added extern PCOMCLASS hb_comp_pReleaseClass + + * source/compiler/genc.c + + Added logic to release declared classes after compilation. + + * source/compiler/harbour.c + + Added logic for standard classes declaration to hb_compDeclaredInit() + + Added ERROR class declaration and started GET class declaration + 2001-04-09 02:20 UTC-0800 Brian Hays * source/compiler/genc.c * Posted a fix from Ron to pDeclared handling @@ -6,11 +23,10 @@ * contrib/rdd_ads/ads1.c * added scope optimization to DBOI_KEYCOUNT - 2001-04-09 11:50 UTC-0800 Ron Pinkas * include/hberrors.h * source/compiler/hbgenerr.c - + Added #define HB_COMP_WARN_PARAM_SUSPECT 18 -> "4Suspecious parameter: %s expected: \'%s\'" + + Added #define HB_COMP_WARN_PARAM_SUSPECT 18 -> "4Suspicious parameter: %s expected: \'%s\'" * include/hbcomp.h + Added extern PCOMDECLARED hb_comp_pReleaseDeclared; diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index bc6b654abf..de8b17fa79 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -104,8 +104,8 @@ typedef struct _COMCLASS { char * szName; PCOMDECLARED pMethod; + PCOMDECLARED pLastMethod; struct _COMCLASS * pNext; - PCOMDECLARED pLast; } COMCLASS, * PCOMCLASS; /* locals, static, public variables support */ @@ -410,6 +410,7 @@ extern PCOMDECLARED hb_comp_pLastDeclared; extern PCOMDECLARED hb_comp_pReleaseDeclared; extern PCOMCLASS hb_comp_pFirstClass; extern PCOMCLASS hb_comp_pLastClass; +extern PCOMCLASS hb_comp_pReleaseClass; extern char * hb_comp_szFromClass; extern PCOMDECLARED hb_comp_pLastMethod; extern PATHNAMES * hb_comp_pIncludePath; diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index ee7ecebf52..1ff2cf790e 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -51,6 +51,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou PFUNCTION pFunc = hb_comp_functions.pFirst, pFTemp; PCOMSYMBOL pSym = hb_comp_symbols.pFirst; PCOMDECLARED pDeclared; + PCOMCLASS pClass; FILE * yyc; /* file handle for C output */ PINLINE pInline = hb_comp_inlines.pFirst; @@ -282,16 +283,32 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou pInline = hb_comp_inlines.pFirst; } - if ( hb_comp_pReleaseDeclared ) - pDeclared = hb_comp_pReleaseDeclared->pNext; - else - pDeclared = NULL; - - while( pDeclared ) + if ( hb_comp_iWarnings >= 3 ) { - hb_comp_pFirstDeclared = pDeclared->pNext; - hb_xfree( ( void * ) pDeclared ); - pDeclared = hb_comp_pFirstDeclared; + pDeclared = hb_comp_pReleaseDeclared->pNext; + while( pDeclared ) + { + hb_comp_pFirstDeclared = pDeclared->pNext; + hb_xfree( ( void * ) pDeclared ); + pDeclared = hb_comp_pFirstDeclared; + } + + pClass = hb_comp_pReleaseClass->pNext; + while( pClass ) + { + hb_comp_pFirstClass = pClass->pNext; + + pDeclared = pClass->pMethod; + while ( pDeclared ) + { + hb_comp_pFirstDeclared = pDeclared->pNext; + hb_xfree( ( void * ) pDeclared ); + pDeclared = hb_comp_pFirstDeclared; + } + + hb_xfree( ( void * ) pClass ); + pClass = hb_comp_pFirstClass; + } } pSym = hb_comp_symbols.pFirst; diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index eb093c6fb3..88f1c56fbc 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -91,6 +91,7 @@ PCOMDECLARED hb_comp_pReleaseDeclared; PCOMCLASS hb_comp_pFirstClass; PCOMCLASS hb_comp_pLastClass; +PCOMCLASS hb_comp_pReleaseClass; char * hb_comp_szFromClass; PCOMDECLARED hb_comp_pLastMethod; @@ -215,7 +216,9 @@ int main( int argc, char * argv[] ) /* Load standard Declarations. */ if ( hb_comp_iWarnings >= 3 ) + { hb_compDeclaredInit(); + } /* Process all files passed via the command line. */ @@ -862,9 +865,9 @@ PCOMDECLARED hb_compMethodAdd( PCOMCLASS pClass, char * szMethodName ) if ( pClass->pMethod == NULL ) pClass->pMethod = pMethod; else - pClass->pLast->pNext = pMethod; + pClass->pLastMethod->pNext = pMethod; - pClass->pLast = pMethod; + pClass->pLastMethod = pMethod; hb_comp_pLastMethod = pMethod; @@ -899,30 +902,85 @@ 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 + ' ' -> 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 + '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 + '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 + /* ------------------------------------------------- Standard Functions -------------------------------------------------- */ + + /* 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. */ + /* TODO: Add all functions. */ + + /* ------------------------------------------------- Standard Classes -------------------------------------------------- */ + + static COMCLASS s_ERROR = { "ERROR" , NULL, NULL, NULL }; + static COMCLASS s_GET = { "GET" , NULL, NULL, NULL }; + static COMCLASS s_TBCOLUMN = { "TBCOLUMN", NULL, NULL, NULL }; + static COMCLASS s_TBROWSE = { "TBROWSE" , NULL, NULL, NULL }; + + /* Name Ret Param Types # of Prams Class Param Classes Next + -------------- --- ----------------------- ---------- ------ ------------- ------------ */ + static COMDECLARED s_ERROR_01 = { "ARGS" , 'A', NULL , 0 , NULL , NULL , NULL }; + static COMDECLARED s_ERROR_02 = { "CANDEFAULT" , 'B', NULL , 0 , NULL , NULL , &s_ERROR_01 }; + static COMDECLARED s_ERROR_03 = { "CANRETRY" , 'B', NULL , 0 , NULL , NULL , &s_ERROR_02 }; + static COMDECLARED s_ERROR_04 = { "CANSUBSTITUTE", 'B', NULL , 0 , NULL , NULL , &s_ERROR_03 }; + static COMDECLARED s_ERROR_05 = { "CARGO" , ' ', NULL , 0 , NULL , NULL , &s_ERROR_04 }; + static COMDECLARED s_ERROR_06 = { "DESCRIPTION" , 'S', NULL , 0 , NULL , NULL , &s_ERROR_05 }; + static COMDECLARED s_ERROR_07 = { "FILENAME" , 'S', NULL , 0 , NULL , NULL , &s_ERROR_06 }; + static COMDECLARED s_ERROR_08 = { "GENCODE" , 'N', NULL , 0 , NULL , NULL , &s_ERROR_07 }; + static COMDECLARED s_ERROR_09 = { "OPERATION" , 'S', NULL , 0 , NULL , NULL , &s_ERROR_08 }; + static COMDECLARED s_ERROR_10 = { "OSCODE" , 'N', NULL , 0 , NULL , NULL , &s_ERROR_09 }; + static COMDECLARED s_ERROR_11 = { "SEVERITY" , 'N', NULL , 0 , NULL , NULL , &s_ERROR_10 }; + static COMDECLARED s_ERROR_12 = { "SUBCODE" , 'N', NULL , 0 , NULL , NULL , &s_ERROR_11 }; + static COMDECLARED s_ERROR_13 = { "SUBSYSTEM" , 'S', NULL , 0 , NULL , NULL , &s_ERROR_12 }; + static COMDECLARED s_ERROR_14 = { "TRIES" , 'N', NULL , 0 , NULL , NULL , &s_ERROR_13 }; + + + /* Name Ret Param Types # of Prams Class Param Classes Next + ---------- --- ----------------------- ---------- ------ ------------- --------- */ + static COMDECLARED s_GET_01 = { "ASSIGN" , ' ', NULL , 0 , NULL , NULL , NULL }; + static COMDECLARED s_GET_02 = { "COLORDISP", 'S', "\x9d" , 1 , &s_GET, NULL , &s_GET_01 }; + + /* ------- */ + + /* First (bottom) Method */ + s_ERROR.pMethod = &s_ERROR_14; + /* Last (top) Method. */ + s_ERROR.pLastMethod = &s_ERROR_01; + + /* ------- */ + + /* First (bottom) Method */ + s_GET.pMethod = &s_GET_02; /* Change to BOTTOM Method. */ + /* Last (top) Method. */ + s_GET.pLastMethod = &s_GET_01; + + /* ------- */ + + hb_comp_pFirstDeclared = &s_003; /* Change to BOTTOM Function. */ hb_comp_pLastDeclared = &s_001; hb_comp_pReleaseDeclared = &s_001; + + hb_comp_pFirstClass = &s_TBROWSE; + hb_comp_pLastClass = &s_ERROR; + hb_comp_pReleaseClass = &s_ERROR; } PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName ) diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index f5a7697426..06a940e18c 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -113,10 +113,10 @@ char * hb_comp_szWarnings[] = "4Suspicious type in assignment to: \'%s\' expected: \'%s\'", "3Can\'t use array index with non-array", "3Incompatible return type: \'%s\' expected: \'%s\'", - "4Suspecious return type: \'%s\' expected: \'%s\'", + "4Suspicious return type: \'%s\' expected: \'%s\'", "3Invalid number of parameters: %s expected: %s", "3Incompatible parameter: %s expected: \'%s\'", - "4Suspecious parameter: %s expected: \'%s\'", + "4Suspicious parameter: %s expected: \'%s\'", "3Duplicate declaration of %s \'%s\'", "3Function \'%s\' conflicting with its declaration", "3Variable \'%s\' used but never initialized", diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index eeb6a81f19..da54012a1d 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -690,7 +690,9 @@ void hb_compStrongType( int iSize ) iParamCount = hb_comp_iParamCount; + /* printf( "\nExec Method: %s of Class: %s Parameters: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]->szName, pFunc->pStackFunctions[ pFunc->iStackFunctions ]->iParamCount ); + */ /* First, find how many optionals. */ while ( --iParamCount >= 0 )