From a28cf6b8b95c01d19e3b006a078ef08f0c517993 Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Sun, 16 Jan 2000 14:23:07 +0000 Subject: [PATCH] ChangeLog 20000116-15:35 GMT+1 --- harbour/ChangeLog | 26 ++++++++++++++++ harbour/include/compiler.h | 1 + harbour/include/hberrors.h | 2 ++ harbour/source/compiler/cmdcheck.c | 8 ++++- harbour/source/compiler/harbour.c | 48 ++++++++++++++++++++++++++++-- harbour/source/compiler/harbour.l | 4 +++ harbour/source/compiler/harbour.y | 28 ++++++++++++++--- harbour/source/compiler/hbgenerr.c | 6 ++-- harbour/source/pp/table.c | 3 +- 9 files changed, 114 insertions(+), 12 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cbca737717..8a31303fea 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,29 @@ +20000116-15:35 GMT+1 Ryszard Glab + + *include/hberrors.h + * added WARN_DUPL_ANNOUNCE + * added ERR_FUNC_ANNOUNCE + + *include/compiler.h + * added declaration of hb_compAnnounce( char * ) + which creates an ANNOUNCEd procedure + + *source/compiler/hbgenerr.c + * added warning when redundant ANNOUNCE statement is used + * added error message when ANNUNCEd procedure is declared STATIC + + *source/compiler/harbour.y + *source/compiler/harbour.l + *source/compiler/harbour.c + * fixed support for ANNOUNCE statement + (static variables are no longer bound to ANNOUNCEd procedure) + + *source/pp/table.c + * removed fixed translation of ANNOUNCE statement + + *source/compiler/cmdcheck.c + * restored correct support for '-w' compiler switch + 20000115-20:3 GMT+3 Luiz Rafael Culik *source/rtl/arrays.c *source/rtl/type.c diff --git a/harbour/include/compiler.h b/harbour/include/compiler.h index 1c9b4d1599..974c3b2871 100644 --- a/harbour/include/compiler.h +++ b/harbour/include/compiler.h @@ -161,6 +161,7 @@ extern void hb_compFunctionAdd( char * szFunName, HB_SYMBOLSCOPE cScope, in extern PFUNCTION hb_compFunctionFind( char * szFunName ); /* locates a previously defined function */ extern USHORT hb_compFunctionGetPos( char * szSymbolName ); /* returns the index + 1 of a function on the functions defined list */ extern PFUNCTION hb_compFunctionKill( PFUNCTION ); /* releases all memory allocated by function and returns the next one */ +extern void hb_compAnnounce( char * ); extern PFUNCTION hb_compFunCallAdd( char * szFuntionName ); extern PFUNCTION hb_compFunCallFind( char * szFunName ); /* locates a previously defined called function */ diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 88293f99fb..56526380b5 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -82,6 +82,7 @@ #define ERR_INVALID_BOUND 41 #define ERR_BAD_MACRO 42 #define ERR_INVALID_SEND 43 +#define ERR_FUNC_ANNOUNCE 44 #define WARN_AMBIGUOUS_VAR 1 #define WARN_MEMVAR_ASSUMED 2 @@ -100,6 +101,7 @@ #define WARN_NUMERIC_SUSPECT 15 #define WARN_MEANINGLESS 16 #define WARN_UNREACHABLE 17 +#define WARN_DUPL_ANNOUNCE 18 /* * Errors generated by Harbour preprocessor diff --git a/harbour/source/compiler/cmdcheck.c b/harbour/source/compiler/cmdcheck.c index dd3d7897ed..e262a81c94 100644 --- a/harbour/source/compiler/cmdcheck.c +++ b/harbour/source/compiler/cmdcheck.c @@ -408,7 +408,13 @@ void hb_compChkEnvironVar( char * szSwitch ) case 'w': case 'W': - hb_comp_bAnyWarning = TRUE; + hb_comp_iWarnings = 1; + if( s[ 1 ] ) + { /*there is -w<0,1,2,3> probably */ + hb_comp_iWarnings = s[ 1 ] - '0'; + if( hb_comp_iWarnings < 0 || hb_comp_iWarnings > 3 ) + hb_compGenError( hb_comp_szErrors, 'F', ERR_BADOPTION, s, NULL ); + } break; case 'x': diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 05e862d355..bfe5255c72 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -689,8 +689,6 @@ void hb_compFunctionAdd( char * szFunName, HB_SYMBOLSCOPE cScope, int iType ) pSym = hb_compSymbolAdd( szFunName, NULL ); if( cScope != FS_PUBLIC ) -/* pSym->cScope = FS_PUBLIC; */ -/* else */ pSym->cScope |= cScope; /* we may have a non public function and a object message */ pFunc = hb_compFunctionNew( szFunName, cScope ); @@ -723,6 +721,50 @@ void hb_compFunctionAdd( char * szFunName, HB_SYMBOLSCOPE cScope, int iType ) } } +/* create an ANNOUNCEd procedure + */ +void hb_compAnnounce( char * szFunName ) +{ + PFUNCTION pFunc; + + pFunc = hb_compFunctionFind( szFunName ); + if( pFunc ) + { + /* there is a function/procedure defined already - ANNOUNCEd procedure + * have to be a public symbol - check if existing symbol is public + */ + if( pFunc->cScope & FS_STATIC ) + hb_compGenError( hb_comp_szErrors, 'F', ERR_FUNC_ANNOUNCE, szFunName, NULL ); + } + else + { + PCOMSYMBOL pSym; + + /* create a new procedure + */ + pSym = hb_compSymbolAdd( szFunName, NULL ); + pSym->cScope = FS_PUBLIC; + + pFunc = hb_compFunctionNew( szFunName, FS_PUBLIC ); + pFunc->bFlags |= FUN_PROCEDURE; + + if( hb_comp_functions.iCount == 0 ) + { + hb_comp_functions.pFirst = pFunc; + hb_comp_functions.pLast = pFunc; + } + else + { + hb_comp_functions.pLast->pNext = pFunc; + hb_comp_functions.pLast = pFunc; + } + hb_comp_functions.iCount++; + + /* this function have a very limited functionality + */ + hb_compGenPCode1( HB_P_ENDPROC ); + } +} PFUNCTION hb_compFunctionKill( PFUNCTION pFunc ) { @@ -1721,7 +1763,7 @@ void hb_compGenPushAliasedVar( char * szVarName, } } else - /* Alias is already placed on stack + /* Alias is already placed on stack * NOTE: An alias will be determined at runtime then we cannot decide * here if passed name is either a field or a memvar */ diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index fbbafeea8d..543441b4c7 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -233,6 +233,10 @@ Separator {SpaceTab} %{ /* ************************************************************************ */ %} +"anno"("unce"|"unc"|"un"|"u")? return ANNOUNCE; +%{ +/* ************************************************************************ */ +%} "begin"{Separator}+"sequ"("ence"|"enc"|"en"|"e")? return BEGINSEQ; %{ /* ************************************************************************ */ diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 885f44f16a..cdcdfd48c8 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -127,6 +127,8 @@ USHORT hb_comp_wCaseCounter = 0; static PTR_LOOPEXIT hb_comp_pLoops = NULL; static HB_RTVAR_PTR hb_comp_rtvars = NULL; +static char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */ + %} %union /* special structure used by lex and yacc to share info */ @@ -157,7 +159,7 @@ static HB_RTVAR_PTR hb_comp_rtvars = NULL; %token FUNCTION PROCEDURE IDENTIFIER RETURN NIL NUM_DOUBLE INASSIGN NUM_INTEGER NUM_LONG %token LOCAL STATIC IIF IF ELSE ELSEIF END ENDIF LITERAL TRUEVALUE FALSEVALUE -%token EXTERN INIT EXIT AND OR NOT PUBLIC EQ NE1 NE2 +%token ANNOUNCE EXTERN INIT EXIT AND OR NOT PUBLIC EQ NE1 NE2 %token INC DEC ALIASOP DOCASE CASE OTHERWISE ENDCASE ENDDO MEMVAR %token WHILE EXIT LOOP END FOR NEXT TO STEP LE GE FIELD IN PARAMETERS %token PLUSEQ MINUSEQ MULTEQ DIVEQ POWER EXPEQ MODEQ EXITLOOP @@ -347,6 +349,21 @@ Statement : ExecFlow CrlfStmnt { } | EXITLOOP CrlfStmnt { hb_compLoopExit(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | LOOP CrlfStmnt { hb_compLoopLoop(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | EXTERN ExtList CrlfStmnt + | ANNOUNCE IDENTIFIER { + if( hb_comp_szAnnounce == NULL ) + { + /* check for reserved name + * NOTE: Clipper doesn't check for it + */ + char * szFunction = hb_compReservedName( $2 ); + if( szFunction ) + hb_compGenError( hb_comp_szErrors, 'E', ERR_FUNC_RESERVED, szFunction, $2 ); + hb_comp_szAnnounce = $2; + } + else + hb_compGenWarning( hb_comp_szWarnings, 'W', WARN_DUPL_ANNOUNCE, $2, NULL ); + } Crlf + ; CrlfStmnt : { hb_compLinePushIfInside(); } Crlf @@ -1432,6 +1449,9 @@ int hb_compYACCMain( char * szName ) ++hb_comp_functions.iCount; } + if( hb_comp_szAnnounce ) + hb_compAnnounce( hb_comp_szAnnounce ); + /* Close processed file (it is opened in hb_compInclude() function ) */ fclose( yyin ); @@ -1809,7 +1829,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) USHORT uCount = hb_compExprListLen( pInitValue ); HB_EXPR_PTR pVar = hb_compExprNewVar( szName ); HB_EXPR_PTR pAssign; - + hb_compStaticDefStart(); /* switch to statics pcode buffer */ /* create a static variable */ hb_compVariableAdd( szName, 'A' ); @@ -1827,10 +1847,10 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) else { USHORT uCount = hb_compExprListLen( pInitValue ); - + hb_compVariableAdd( szName, 'A' ); hb_compExprDelete( hb_compExprGenPush( pInitValue ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName ) ) ); } -} \ No newline at end of file +} diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 1bcd2be044..34577eb5bf 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -80,7 +80,8 @@ char * hb_comp_szErrors[] = "Invalid array index expression: \'%s\'", "Bound error: \'%s\'", "Macro of declared symbol: \'%s\'", - "Invalid selector in send: \'%s\'" + "Invalid selector in send: \'%s\'", + "ANNOUNCEd procedure \'%s\' must be a public symbol" }; /* Table with parse warnings */ @@ -105,7 +106,8 @@ char * hb_comp_szWarnings[] = "3Suspicious operand type: \'UnKnown\' expected: \'Logical\'", "3Suspicious operand type: \'UnKnown\' expected: \'Numeric\'", "0Meaningless use of expression: \'%s\'", - "1Unreachable code" + "1Unreachable code", + "1Redundant \'ANNOUNCE %s\' statement ignored" }; void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ) diff --git a/harbour/source/pp/table.c b/harbour/source/pp/table.c index fd77721087..772a7c8115 100644 --- a/harbour/source/pp/table.c +++ b/harbour/source/pp/table.c @@ -388,7 +388,6 @@ static COMMANDS sC___237 = {0,"SET","ORDER TO \1A00 [IN \1B40]","ordSetFocus( \1A00 [, \1B30] )",&sC___236 }; static COMMANDS sC___238 = {0,"SET","ORDER TO TAG \1A40 [IN \1B40]","ordSetFocus( \1A30 [, \1B30] )",&sC___237 }; static COMMANDS sC___239 = {0,"SET","ORDER TO","ordSetFocus(0)",&sC___238 }; - static COMMANDS sC___240 = {0,"ANNOUNCE","\1A10","procedure \1A00 ; return",&sC___239 }; - COMMANDS * hb_pp_topCommand = &sC___240; + COMMANDS * hb_pp_topCommand = &sC___239; COMMANDS * hb_pp_topTranslate = NULL;