From e0201e2067a625af6f341663dc4b8173307b78fe Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Mon, 1 May 2000 04:37:09 +0000 Subject: [PATCH] 20000430-21:30 GMT-8 Ron Pinkas * source/compiler/harbour.c - Removed refrence to pFunc->iFunctionIndex. * source/compiler/hbpcode.c * Enhancements to hb_compStrongType() * tests/testwarn.prg + Added code to demonstrate more warnings. * include/hberrors.h - Removed pFunctionCalls and iFunctionIndex members of _FUNC structure. --- harbour/ChangeLog | 23 +++++++++++++++++----- harbour/include/hbcomp.h | 4 +--- harbour/source/compiler/harbour.c | 2 -- harbour/source/compiler/hbpcode.c | 32 ++++++++++++++++++------------- harbour/tests/testwarn.prg | 4 ++-- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 584aefbe6b..f8e1664798 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,22 +1,35 @@ +20000430-21:30 GMT-8 Ron Pinkas + * source/compiler/harbour.c + - Removed refrence to pFunc->iFunctionIndex. + + * source/compiler/hbpcode.c + * Enhancements to hb_compStrongType() + + * tests/testwarn.prg + + Added code to demonstrate more warnings. + + * include/hberrors.h + - Removed pFunctionCalls and iFunctionIndex members of _FUNC structure. + 20000430-22:15 GMT-8 Ron Pinkas - * harbour/source/compiler/harbour.y + * source/compiler/harbour.y ! Fixed { hb_compVariableDim( $1, $2 ); } to { hb_comp_cVarType = 'A'; hb_compVariableDim( $1, $2 ); } so that correct type is saved. - * harbour/source/compiler/hbpcode.c + * source/compiler/hbpcode.c * Enhancements to hb_compStrongType() - * harbour/source/compiler/hbgenerr.c + * source/compiler/hbgenerr.c + added : "3Can\'t use array index with NON Array" "3Incompatible return value: \'%s\' expected: \'%s\'" - * harbour/include/hberrors.h + * include/hberrors.h + added : #define HB_COMP_WARN_NOT_ARRAY 13 #define HB_COMP_RETURN_TYPE 14 - * harbour/tests/testwarn.prg + * tests/testwarn.prg + Added code to demonstrate more warnings. 20000430-23:00 GMT+2 Maurilio Longo diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 63d6d7cd70..97836a30a3 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -117,10 +117,8 @@ typedef struct __FUNC ULONG * pJumps; /* pointer to the Jumps array */ int iNOOPs; /* NOOPs Counter */ BYTE iJumps; /* Jumps Counter */ - BYTE pStack[256]; /* Compile Time Stack */ + BYTE pStack[512]; /* Compile Time Stack */ SHORT iStackIndex; /* Compile Time Stack Index */ - BYTE pFunctionCalls[256]; /* Array of Function Calls Compile Time Stack Postion */ - SHORT iFunctionIndex; /* Index into Array of Function Calls Compile Time Stack Postion */ struct __FUNC * pOwner; /* pointer to the function/procedure that owns the codeblock */ struct __FUNC * pNext; /* pointer to the next defined function */ } _FUNC, * PFUNCTION; diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 51a8254786..1bf5868f39 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -710,7 +710,6 @@ static PFUNCTION hb_compFunctionNew( char * szName, HB_SYMBOLSCOPE cScope ) pFunc->pNOOPs = NULL; pFunc->pJumps = NULL; pFunc->iStackIndex = 0; - pFunc->iFunctionIndex = 0; return pFunc; } @@ -1649,7 +1648,6 @@ void hb_compLinePush( void ) /* generates the pcode with the currently compiled /* Resting Compile Time Stack */ hb_comp_functions.pLast->iStackIndex = 0; - hb_comp_functions.pLast->iFunctionIndex = 0; } /* Generates the pcode with the currently compiled source code line diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index c3177c895f..a3dec34895 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -239,16 +239,28 @@ void hb_compStrongType( int iSize ) } break; - case HB_P_DO : case HB_P_DOSHORT : - case HB_P_FUNCTION : case HB_P_FUNCTIONSHORT : - /* TODO: Add support for Function Parameters Declaration. */ + wVar = pFunc->pCode[ ulPos + 1 ]; + + /* Removing all the optional parameters. Rteurn type already pushed just prior to parameters */ + pFunc->iStackIndex -= wVar; + + /* Removing the NIL */ + pFunc->iStackIndex--; + break; + + case HB_P_DO : + case HB_P_FUNCTION : + /* TODO: Add support for Function Parameters Declaration. */ + wVar = pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256; /* Removing all the optional parameters. */ - pFunc->iStackIndex = pFunc->pFunctionCalls[ pFunc->iFunctionIndex--] ; - /* Function Type already on stack at this position. */ + pFunc->iStackIndex -= wVar; + + /* Removing the NIL */ + pFunc->iStackIndex--; break; case HB_P_DEC : @@ -485,8 +497,6 @@ void hb_compStrongType( int iSize ) case HB_P_PUSHSYM : case HB_P_MPUSHSYM : - pFunc->pFunctionCalls[ pFunc->iFunctionIndex++ ] = pFunc->iStackIndex; - pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256 ); if ( pSym ) @@ -508,7 +518,6 @@ void hb_compStrongType( int iSize ) ( pSym->cScope & HB_FS_EXIT ) == HB_FS_EXIT ) */ /* Storing a Book Mark of the last pushed symbol so we know how many bytes to pop when encountering function call. */ - pFunc->pFunctionCalls[ pFunc->iFunctionIndex++ ] = pFunc->iStackIndex; pFunc->pStack[ pFunc->iStackIndex++ ] = pSym->cType; } @@ -646,15 +655,12 @@ void hb_compStrongType( int iSize ) case HB_P_MACROPUSHALIASED : case HB_P_MACROPUSH : /* Replace the value of the macro expression with unknown result of expanded macro. */ - pFunc->pStack[ pFunc->iStackIndex ] = ' '; + pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; break; case HB_P_MACROSYMBOL : /* Replace Macro Variable Symbol Name type with unknown type of expanded macro Function Call */ - pFunc->pStack[ pFunc->iStackIndex ] = ' '; - - /* Storing a Book Mark of the last pushed symbol so we know how many bytes to pop when encountering function call. */ - pFunc->pFunctionCalls[ pFunc->iFunctionIndex++ ] = pFunc->iStackIndex; + pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; break; case HB_P_MACROTEXT : diff --git a/harbour/tests/testwarn.prg b/harbour/tests/testwarn.prg index 59875d89f8..89a4e27c20 100644 --- a/harbour/tests/testwarn.prg +++ b/harbour/tests/testwarn.prg @@ -15,6 +15,8 @@ FUNCTION Main() n := &SomeFun( 2, 3 ) + n := nMyFunc( .F., 'A' ) + n := &(cVar) n := "&SomeVar" @@ -35,8 +37,6 @@ FUNCTION Main() n := a - n := nMyFunc() - IIF( n, 2, 3 ) RETURN NIL