diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e1b12ec3e6..401f61c319 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,61 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-04 19:14 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapifs.h + * harbour/src/rtl/filebuf.c + * harbour/contrib/hbmemio/memio.c + * harbour/contrib/hbnetio/netiocli.c + + added new method: + void Flush( PHB_FILE pFile, HB_BOOL fDirty ); + to replaceable RDD IO structure (HB_FILE) + + added new function: + void hb_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ); + + * harbour/src/rdd/dbfntx/dbfntx1.c + * harbour/src/rdd/dbfnsx/dbfnsx1.c + * harbour/src/rdd/dbfcdx/dbfcdx1.c + * harbour/src/rdd/dbffpt/dbffpt1.c + * use hb_fileFlush() + + * harbour/src/vm/hvm.c + * harbour/include/hbxvm.h + ! fixed hb_xvm{Local,Static,Module}Name() to use 'const char *' + instead of 'char *' - modifications by Xavi (jarabal) + + * harbour/include/hbapi.h + * harbour/include/hbxvm.h + * harbour/include/hbmacro.h + * harbour/include/hbcompdf.h + * harbour/src/vm/hvm.c + * harbour/src/vm/macro.c + * harbour/src/vm/memvars.c + * replaced some 'BYTE' types with 'unsigned char' or 'int' types + * cleanup some other casting and types to reduce conversions + between function calls + + * harbour/src/common/expropt1.c + ; updated comments + + * harbour/include/hbpp.h + * harbour/include/hbexprop.h + * harbour/include/hbexpra.c + * harbour/include/hbexprb.c + * eliminated HB_EXPR_PCODE?() macros + ! fixed potential GPF trap during compilation of _GET_() functions + which can be exploited by strange code using some special expressions + as get variable. + TODO: eliminate hb_compExprClone() used in hb_compExprSetGetBlock(), + our optimization module does not care about shared expressions + so it can be source of serious problems in the future if someone + use this functions for non optimized expression which will be + reduced later. + * emulate clipper behavior for codeblock optimizations and do + not optimize all codeblocks if -kc switch is used and codeblocks + is inside non optimized part of code like (Clipper has such + places) + % simplified and optimized some functions like hb_compExprReduceList() + 2010-02-04 18:11 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbfbird/tests/test.prg ! Fixed to work at all. This code was complete nonsense. diff --git a/harbour/contrib/hbmemio/memio.c b/harbour/contrib/hbmemio/memio.c index d5dc760b9b..dfa1a3a7da 100644 --- a/harbour/contrib/hbmemio/memio.c +++ b/harbour/contrib/hbmemio/memio.c @@ -646,6 +646,14 @@ HB_MEMFS_EXPORT HB_FOFFSET hb_memfsSeek( HB_FHANDLE hFile, HB_FOFFSET llOffset, } +HB_MEMFS_EXPORT void hb_memfsFlush( HB_FHANDLE hFile, HB_BOOL fDirty ) +{ + HB_SYMBOL_UNUSED( hFile ); + HB_SYMBOL_UNUSED( fDirty ); + return; +} + + HB_MEMFS_EXPORT void hb_memfsCommit( HB_FHANDLE hFile ) { HB_SYMBOL_UNUSED( hFile ); @@ -808,6 +816,12 @@ static HB_FOFFSET s_fileSize( PHB_FILE pFile ) } +static void s_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ) +{ + hb_memfsFlush( pFile->hFile, fDirty ); +} + + static void s_fileCommit( PHB_FILE pFile ) { hb_memfsCommit( pFile->hFile ); @@ -833,6 +847,7 @@ static const HB_FILE_FUNCS s_fileFuncs = s_fileWriteAt, s_fileTruncAt, s_fileSize, + s_fileFlush, s_fileCommit, s_fileHandle }; diff --git a/harbour/contrib/hbnetio/netiocli.c b/harbour/contrib/hbnetio/netiocli.c index b2b6fd0fd6..20da48d646 100644 --- a/harbour/contrib/hbnetio/netiocli.c +++ b/harbour/contrib/hbnetio/netiocli.c @@ -1176,6 +1176,12 @@ static HB_FOFFSET s_fileSize( PHB_FILE pFile ) return llOffset; } +void s_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ) +{ + HB_SYMBOL_UNUSED( pFile ); + HB_SYMBOL_UNUSED( fDirty ); +} + static void s_fileCommit( PHB_FILE pFile ) { if( s_fileConLock( pFile->conn ) ) @@ -1211,6 +1217,7 @@ static const HB_FILE_FUNCS * s_fileMethods( void ) s_fileWriteAt, s_fileTruncAt, s_fileSize, + s_fileFlush, s_fileCommit, s_fileHandle }; diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index e56ba6ae98..7a034da6d8 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -1049,7 +1049,7 @@ extern void hb_memvarSetPrivatesBase( ULONG ulBase ); /* release PRIVATE v extern void hb_memvarUpdatePrivatesBase( void ); /* Update PRIVATE base ofsset so they will not be removed when function return */ extern void hb_memvarNewParameter( PHB_SYMB pSymbol, PHB_ITEM pValue ); extern char * hb_memvarGetStrValuePtr( char * szVarName, ULONG *pulLen ); -extern void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue ); +extern void hb_memvarCreateFromItem( PHB_ITEM pMemvar, int iScope, PHB_ITEM pValue ); extern int hb_memvarScope( const char * szVarName, ULONG ulLength ); /* retrieve scope of a dynamic variable symbol */ extern PHB_ITEM hb_memvarDetachLocal( HB_ITEM_PTR pLocal ); /* Detach a local variable from the eval stack */ extern PHB_ITEM hb_memvarGetValueBySym( PHB_DYNS pDynSym ); @@ -1091,8 +1091,8 @@ typedef struct HB_MACRO_ * HB_MACRO_PTR; #else typedef void * HB_MACRO_PTR; #endif -extern void hb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags ); /* retrieve results of a macro expansion */ -extern void hb_macroSetValue( HB_ITEM_PTR pItem, BYTE flags ); /* assign a value to a macro-expression item */ +extern void hb_macroGetValue( HB_ITEM_PTR pItem, int iContext, int flags ); /* retrieve results of a macro expansion */ +extern void hb_macroSetValue( HB_ITEM_PTR pItem, int flags ); /* assign a value to a macro-expression item */ extern void hb_macroPushReference( HB_ITEM_PTR pItem ); /* push reference to given expression */ extern void hb_macroTextValue( HB_ITEM_PTR pItem ); /* macro text substitution */ extern void hb_macroPushSymbol( HB_ITEM_PTR pItem ); /* handle a macro function calls, e.g. var := ¯o() */ @@ -1101,8 +1101,8 @@ extern HB_MACRO_PTR hb_macroCompile( const char * szString ); /* compile a strin extern void hb_macroDelete( HB_MACRO_PTR pMacro ); /* release all memory allocated for macro evaluation */ extern char * hb_macroTextSymbol( const char * szString, HB_SIZE ulLength, HB_BOOL * pfNewString ); /* substitute macro variables occurences within a given string and check if result is a valid function or variable name */ extern char * hb_macroExpandString( const char * szString, HB_SIZE ulLength, HB_BOOL * pfNewString ); /* expands valid '&' operator */ -extern void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ); /* compiles and evaluates an aliased macro expression */ -extern void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ); /* compiles and evaluates an aliased macro expression */ +extern void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int flags ); /* compiles and evaluates an aliased macro expression */ +extern void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int flags ); /* compiles and evaluates an aliased macro expression */ extern const char * hb_macroGetType( HB_ITEM_PTR pItem ); /* determine the type of an expression */ /* idle states */ diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index fe05927c20..c5e503384f 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -337,6 +337,7 @@ extern HB_EXPORT const char * hb_fsNameConv( const char * szFileName, char ** ps ULONG (* WriteAt ) ( PHB_FILE pFile, const void * buffer, ULONG ulSize, HB_FOFFSET llOffset ); HB_BOOL (* TruncAt ) ( PHB_FILE pFile, HB_FOFFSET llOffset ); HB_FOFFSET (* Size ) ( PHB_FILE pFile ); + void (* Flush ) ( PHB_FILE pFile, HB_BOOL fDirty ); void (* Commit ) ( PHB_FILE pFile ); HB_FHANDLE (* Handle ) ( PHB_FILE pFile ); } @@ -366,6 +367,7 @@ extern HB_EXPORT ULONG hb_fileReadAt( PHB_FILE pFile, void * buffer, ULON extern HB_EXPORT ULONG hb_fileWriteAt( PHB_FILE pFile, const void * buffer, ULONG ulSize, HB_FOFFSET llOffset ); extern HB_EXPORT HB_BOOL hb_fileTruncAt( PHB_FILE pFile, HB_FOFFSET llOffset ); extern HB_EXPORT HB_FOFFSET hb_fileSize( PHB_FILE pFile ); +extern HB_EXPORT void hb_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ); extern HB_EXPORT void hb_fileCommit( PHB_FILE pFile ); extern HB_EXPORT HB_FHANDLE hb_fileHandle( PHB_FILE pFile ); diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index 9a76c309ae..76893cd67c 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -531,7 +531,7 @@ typedef struct _HB_COMMON { /* common to macro compiler members */ int mode; /* HB_MODE_* */ - ULONG supported; /* various flags for supported capabilities */ + int supported; /* various flags for supported capabilities */ const struct _HB_COMP_FUNCS * funcs; } HB_COMMON, * HB_COMMON_PTR; @@ -558,7 +558,7 @@ typedef struct HB_MACRO_ /* a macro compiled pcode container */ { /* common to compiler members */ int mode; /* HB_MODE_* */ - ULONG supported; /* various flags for supported capabilities */ + int supported; /* various flags for supported capabilities */ const struct _HB_COMP_FUNCS * funcs; /* macro compiler only members */ @@ -635,7 +635,7 @@ typedef struct _HB_COMP { /* common to macro compiler members */ int mode; /* HB_MODE_* */ - ULONG supported; /* various flags for supported capabilities */ + int supported; /* various flags for supported capabilities */ const struct _HB_COMP_FUNCS * funcs; /* compiler only members */ diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index f4ffa05c96..e855e3bf44 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -60,12 +60,13 @@ ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC_PTR pE { ULONG ulLen = 0; - if( pEval && ((pExpr->ExprType == HB_ET_LIST) || (pExpr->ExprType == HB_ET_ARGLIST)) ) + if( pEval && ( pExpr->ExprType == HB_ET_LIST || + pExpr->ExprType == HB_ET_ARGLIST ) ) { pExpr = pExpr->value.asList.pExprList; while( pExpr ) { - (pEval)( HB_COMP_PARAM, (void *) pExpr ); + ( pEval )( HB_COMP_PARAM, ( void * ) pExpr ); pExpr = pExpr->pNext; ++ulLen; } @@ -80,26 +81,26 @@ ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2 if( !pEval ) return ulLen; - if( (pExpr1->ExprType == HB_ET_LIST || pExpr1->ExprType == HB_ET_ARGLIST) + if( ( pExpr1->ExprType == HB_ET_LIST || pExpr1->ExprType == HB_ET_ARGLIST ) && - (pExpr2->ExprType == HB_ET_LIST || pExpr2->ExprType == HB_ET_ARGLIST) ) + ( pExpr2->ExprType == HB_ET_LIST || pExpr2->ExprType == HB_ET_ARGLIST ) ) { pExpr1 = pExpr1->value.asList.pExprList; pExpr2 = pExpr2->value.asList.pExprList; while( pExpr1 && pExpr2 ) { - (pEval)( HB_COMP_PARAM, (void *) pExpr1, (void *)pExpr2 ); + ( pEval )( HB_COMP_PARAM, ( void * ) pExpr1, ( void * ) pExpr2 ); pExpr1 = pExpr1->pNext; pExpr2 = pExpr2->pNext; ++ulLen; } } - else if( pExpr1->ExprType == HB_ET_LIST || pExpr1->ExprType == HB_ET_ARGLIST) + else if( pExpr1->ExprType == HB_ET_LIST || pExpr1->ExprType == HB_ET_ARGLIST ) { pExpr1 = pExpr1->value.asList.pExprList; while( pExpr1 ) { - (pEval)( HB_COMP_PARAM, (void *) pExpr1, (void *)pExpr2 ); + ( pEval )( HB_COMP_PARAM, ( void * ) pExpr1, ( void * ) pExpr2 ); pExpr1 = pExpr1->pNext; ++ulLen; } @@ -179,7 +180,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_COMP_EXPR_DELETE( pParms ); HB_COMP_EXPR_DELETE( pName ); return hb_compExprNewMethodCall( hb_compExprNewSend( - hb_compExprNewVar( szName, HB_COMP_PARAM ), + hb_compExprNewVar( szName, HB_COMP_PARAM ), szMessage, NULL, HB_COMP_PARAM ), NULL ); } } @@ -194,6 +195,8 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM { HB_EXPR_PTR pEval; /* Optimize Eval( bBlock, [ArgList] ) to: bBlock:Eval( [ArgList] ) */ + if( !HB_SUPPORT_HARBOUR ) + pParms = HB_EXPR_USE( pParms, HB_EA_REDUCE ); #ifdef HB_MACRO_SUPPORT pEval = hb_compExprNewMethodCall( hb_macroExprNewSend( pParms->value.asList.pExprList, "EVAL", NULL, HB_COMP_PARAM ), @@ -215,18 +218,22 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_EXPR_PTR pArg, pNext; USHORT uiCount; - pParms->value.asList.pExprList = HB_EXPR_USE( pParms->value.asList.pExprList, HB_EA_REDUCE ); - pArg = pParms->value.asList.pExprList; - - /* When -kc switch is used expression list is not stripped - * in reduce operation + /* pArg has to be reduced to eliminate possible problems with + * cloned expressions in SETGET block */ - if( !HB_SUPPORT_HARBOUR && pArg->ExprType == HB_ET_LIST ) + if( HB_SUPPORT_HARBOUR ) { + pParms = HB_EXPR_USE( pParms, HB_EA_REDUCE ); + pArg = pParms->value.asList.pExprList; + } + else + { + pArg = pParms->value.asList.pExprList; pNext = pArg->pNext; pArg->pNext = NULL; - pArg = pParms->value.asList.pExprList = hb_compExprListStrip( pArg, HB_COMP_PARAM ); + pArg = hb_compExprListStrip( HB_EXPR_USE( pArg, HB_EA_REDUCE ), HB_COMP_PARAM ); pArg->pNext = pNext; + pParms->value.asList.pExprList = pArg; } if( pArg->ExprType == HB_ET_ARRAYAT ) @@ -282,7 +289,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_COMP_EXPR_CLEAR( pArg ); /* Create an array with index elements */ - pIndex = HB_EXPR_PCODE1( hb_compExprNewArray, hb_compExprNewList( pIndex, HB_COMP_PARAM ) ); + pIndex = hb_compExprNewArray( hb_compExprNewList( pIndex, HB_COMP_PARAM ), HB_COMP_PARAM ); /* The array with index elements have to be the sixth argument * of __GETA() call */ @@ -403,7 +410,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM { /* Undeclared variable name - create a set/get codeblock * at runtime - */ + */ HB_COMP_EXPR_FREE( pArg ); pArg = hb_compExprNewNil( HB_COMP_PARAM ); } @@ -435,6 +442,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM { /* My&var.1() executed by macro compiler */ + /* NOTE: direct type change */ pName->ExprType = HB_ET_FUNNAME; } #endif @@ -597,9 +605,9 @@ static void hb_compExprCheckStaticListInitializers( HB_EXPR_PTR pLeftExpr, HB_EX * new one - this will break the linked list of expressions. * (classical case of replacing an item in a linked list) */ - HB_EXPR_PTR pNext = (*pExpr)->pNext; /* store next expression in case the current will be reduced */ + HB_EXPR_PTR pNext = ( *pExpr )->pNext; /* store next expression in case the current will be reduced */ *pExpr = hb_compExprListStrip( *pExpr, HB_COMP_PARAM ); - (*pExpr)->pNext = pNext; /* restore the link to next expression */ + ( *pExpr )->pNext = pNext; /* restore the link to next expression */ } if( (*pExpr)->ExprType == HB_ET_ARRAY || @@ -611,7 +619,7 @@ static void hb_compExprCheckStaticListInitializers( HB_EXPR_PTR pLeftExpr, HB_EX { hb_compExprCheckStaticInitializer( pLeftExpr, *pExpr, HB_COMP_PARAM ); } - pExpr = &(*pExpr)->pNext; + pExpr = &( *pExpr )->pNext; } } @@ -698,8 +706,7 @@ HB_EXPR_PTR hb_macroExprGenPush( HB_EXPR_PTR pExpr, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_macroExprGenPush(%i)", pExpr->ExprType)); pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); - return pExpr; + return HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); } /* Generates pcode to pop an expressions @@ -723,8 +730,7 @@ HB_EXPR_PTR hb_compExprGenPush( HB_EXPR_PTR pExpr, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprGenPush(%i)", pExpr->ExprType)); pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); - return pExpr; + return HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); } /* Generates pcode to pop an expressions diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index dafc875619..401086743a 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -433,6 +433,7 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) switch( iMessage ) { case HB_EA_REDUCE: + pSelf->value.asCodeblock.flags |= HB_BLOCK_REDUCE; break; case HB_EA_ARRAY_AT: HB_COMP_ERROR_TYPE( pSelf ); @@ -446,7 +447,7 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) case HB_EA_PUSH_PCODE: { #if defined( HB_MACRO_SUPPORT ) - HB_EXPR_PCODE1( hb_compExprCodeblockPush, pSelf ); + hb_compExprCodeblockPush( pSelf, HB_COMP_PARAM ); #else if( pSelf->value.asCodeblock.flags & HB_BLOCK_EXT ) hb_compExprCodeblockExtPush( pSelf, HB_COMP_PARAM ); @@ -469,8 +470,7 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) case HB_EA_DELETE: { - HB_EXPR_PTR pExp = pSelf->value.asCodeblock.pExprList; - HB_EXPR_PTR pNext; + HB_EXPR_PTR pExpr = pSelf->value.asCodeblock.pExprList; hb_compExprCBVarDel( pSelf->value.asCodeblock.pLocals ); @@ -478,13 +478,12 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) hb_xfree( pSelf->value.asCodeblock.string ); /* Delete all expressions of the block. */ - while( pExp ) + while( pExpr ) { - pNext = pExp->pNext; - HB_COMP_EXPR_DELETE( pExp ); - pExp = pNext; + HB_EXPR_PTR pNext = pExpr->pNext; + HB_COMP_EXPR_DELETE( pExpr ); + pExpr = pNext; } - break; } } @@ -601,12 +600,12 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) if( fArgsList ) { HB_GEN_FUNC3( PCode3, HB_P_MACROARRAYGEN, - HB_LOBYTE( usItems ), HB_HIBYTE( usItems ) ); + HB_LOBYTE( usItems ), HB_HIBYTE( usItems ) ); } else { HB_GEN_FUNC3( PCode3, HB_P_ARRAYGEN, - HB_LOBYTE( usItems ), HB_HIBYTE( usItems ) ); + HB_LOBYTE( usItems ), HB_HIBYTE( usItems ) ); } } break; @@ -637,10 +636,9 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) HB_EXPR_PTR pElem = pSelf->value.asList.pExprList; /* Delete all elements of the array */ - HB_EXPR_PTR pNext; while( pElem ) { - pNext = pElem->pNext; + HB_EXPR_PTR pNext = pElem->pNext; HB_COMP_EXPR_DELETE( pElem ); pElem = pNext; } @@ -707,12 +705,11 @@ static HB_EXPR_FUNC( hb_compExprUseHash ) case HB_EA_DELETE: { HB_EXPR_PTR pElem = pSelf->value.asList.pExprList; - /* Delete all elements of the array + /* Delete all elements of the hash array */ - HB_EXPR_PTR pNext; while( pElem ) { - pNext = pElem->pNext; + HB_EXPR_PTR pNext = pElem->pNext; HB_COMP_EXPR_DELETE( pElem ); pElem = pNext; } @@ -811,8 +808,8 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) pFalse = hb_compExprNewRef( pCond->pNext->pNext, HB_COMP_PARAM ); pCond->pNext = hb_compExprNewRef( pCond->pNext, HB_COMP_PARAM ); pCond->pNext->pNext = pFalse; - memcpy( pSelf, pIIF, sizeof( HB_EXPR ) ); - HB_COMP_EXPR_CLEAR( pIIF ); + HB_COMP_EXPR_CLEAR( pSelf ); + pSelf = pIIF; } break; case HB_EA_ARRAY_AT: @@ -850,8 +847,10 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) } else if( pExp->ExprType == HB_ET_VARIABLE ) { + /* Note: direct type change */ pExp->ExprType = HB_ET_VARREF; HB_EXPR_USE( pExp, HB_EA_PUSH_PCODE ); + /* restore original expression type */ pExp->ExprType = HB_ET_VARIABLE; break; } @@ -1001,12 +1000,12 @@ static HB_EXPR_FUNC( hb_compExprUseIIF ) case HB_EA_DELETE: if( pSelf->value.asList.pExprList ) { - HB_EXPR_PTR pTmp, pExpr = pSelf->value.asList.pExprList; + HB_EXPR_PTR pNext, pExpr = pSelf->value.asList.pExprList; while( pExpr ) { - pTmp = pExpr->pNext; /* store next expression */ + pNext = pExpr->pNext; /* store next expression */ HB_COMP_EXPR_DELETE( pExpr ); - pExpr =pTmp; + pExpr = pNext; } pSelf->value.asList.pExprList = NULL; } @@ -1124,12 +1123,12 @@ static HB_EXPR_FUNC( hb_compExprUseList ) case HB_EA_DELETE: if( pSelf->value.asList.pExprList ) { - HB_EXPR_PTR pTmp, pExpr = pSelf->value.asList.pExprList; + HB_EXPR_PTR pNext, pExpr = pSelf->value.asList.pExprList; while( pExpr ) { - pTmp = pExpr->pNext; /* store next expression */ + pNext = pExpr->pNext; /* store next expression */ HB_COMP_EXPR_DELETE( pExpr ); - pExpr =pTmp; + pExpr =pNext; } pSelf->value.asList.pExprList = NULL; } @@ -1187,12 +1186,12 @@ static HB_EXPR_FUNC( hb_compExprUseArgList ) case HB_EA_DELETE: if( pSelf->value.asList.pExprList ) { - HB_EXPR_PTR pTmp, pExpr = pSelf->value.asList.pExprList; + HB_EXPR_PTR pNext, pExpr = pSelf->value.asList.pExprList; while( pExpr ) { - pTmp = pExpr->pNext; /* store next expression */ + pNext = pExpr->pNext; /* store next expression */ HB_COMP_EXPR_DELETE( pExpr ); - pExpr =pTmp; + pExpr =pNext; } pSelf->value.asList.pExprList = NULL; } @@ -1255,12 +1254,12 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList ) case HB_EA_DELETE: if( pSelf->value.asList.pExprList ) { - HB_EXPR_PTR pTmp, pExpr = pSelf->value.asList.pExprList; + HB_EXPR_PTR pNext, pExpr = pSelf->value.asList.pExprList; while( pExpr ) { - pTmp = pExpr->pNext; /* store next expression */ + pNext = pExpr->pNext; /* store next expression */ HB_COMP_EXPR_DELETE( pExpr ); - pExpr =pTmp; + pExpr =pNext; } pSelf->value.asList.pExprList = NULL; } @@ -1406,8 +1405,10 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) HB_EXPR_PTR pList = pSelf->value.asList.pExprList; if( pList->ExprType == HB_ET_VARIABLE ) { + /* Note: direct type change */ pList->ExprType = HB_ET_VARREF; HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + /* restore original expression type */ pList->ExprType = HB_ET_VARIABLE; } else if( pList->ExprType == HB_ET_ALIASVAR && @@ -1477,8 +1478,10 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) HB_EXPR_PTR pList = pSelf->value.asList.pExprList; if( pList->ExprType == HB_ET_VARIABLE ) { + /* Note: direct type change */ pList->ExprType = HB_ET_VARREF; HB_EXPR_USE( pList, HB_EA_PUSH_PCODE ); + /* restore original expression type */ pList->ExprType = HB_ET_VARIABLE; } else if( pList->ExprType == HB_ET_ALIASVAR && @@ -2211,7 +2214,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) /* Macro operator is used on the left or right side of an alias * operator - handle it with a special care */ - HB_EXPR_PCODE2( hb_compExprUseAliasMacro, pSelf, HB_EA_PUSH_PCODE ); + hb_compExprUseAliasMacro( pSelf, HB_EA_PUSH_PCODE, HB_COMP_PARAM ); } else if( pAlias->ExprType == HB_ET_ALIAS ) { @@ -2260,7 +2263,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) * operator - handle it with a special care * (we need convert to a string the whole expression) */ - HB_EXPR_PCODE2( hb_compExprUseAliasMacro, pSelf, HB_EA_POP_PCODE ); + hb_compExprUseAliasMacro( pSelf, HB_EA_POP_PCODE, HB_COMP_PARAM ); } else if( pAlias->ExprType == HB_ET_ALIAS ) { @@ -2648,7 +2651,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostInc ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushPostOp, pSelf, HB_P_INC ); + hb_compExprPushPostOp( pSelf, HB_P_INC, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -2658,7 +2661,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostInc ) case HB_EA_STATEMENT: /* a++ used standalone as a statement is the same as ++a */ - HB_EXPR_PCODE2( hb_compExprUsePreOp, pSelf, HB_P_INC ); + hb_compExprUsePreOp( pSelf, HB_P_INC, HB_COMP_PARAM ); break; case HB_EA_DELETE: @@ -2686,7 +2689,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostDec ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushPostOp, pSelf, HB_P_DEC ); + hb_compExprPushPostOp( pSelf, HB_P_DEC, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -2694,7 +2697,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostDec ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUsePreOp, pSelf, HB_P_DEC ); + hb_compExprPushPostOp( pSelf, HB_P_DEC, HB_COMP_PARAM ); break; case HB_EA_DELETE: @@ -2813,7 +2816,7 @@ static HB_EXPR_FUNC( hb_compExprUseAssign ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -2841,7 +2844,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlusEq ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushOperEq, pSelf, HB_P_PLUS ); + hb_compExprPushOperEq( pSelf, HB_P_PLUS, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -2849,11 +2852,11 @@ static HB_EXPR_FUNC( hb_compExprUsePlusEq ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUseOperEq, pSelf, HB_P_PLUS ); + hb_compExprUseOperEq( pSelf, HB_P_PLUS, HB_COMP_PARAM ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -2881,7 +2884,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinusEq ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushOperEq, pSelf, HB_P_MINUS ); + hb_compExprPushOperEq( pSelf, HB_P_MINUS, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -2889,11 +2892,11 @@ static HB_EXPR_FUNC( hb_compExprUseMinusEq ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUseOperEq, pSelf, HB_P_MINUS ); + hb_compExprUseOperEq( pSelf, HB_P_MINUS, HB_COMP_PARAM ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -2921,7 +2924,7 @@ static HB_EXPR_FUNC( hb_compExprUseMultEq ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushOperEq, pSelf, HB_P_MULT ); + hb_compExprPushOperEq( pSelf, HB_P_MULT, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -2929,11 +2932,11 @@ static HB_EXPR_FUNC( hb_compExprUseMultEq ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUseOperEq, pSelf, HB_P_MULT ); + hb_compExprUseOperEq( pSelf, HB_P_MULT, HB_COMP_PARAM ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -2961,7 +2964,7 @@ static HB_EXPR_FUNC( hb_compExprUseDivEq ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushOperEq, pSelf, HB_P_DIVIDE ); + hb_compExprPushOperEq( pSelf, HB_P_DIVIDE, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -2969,11 +2972,11 @@ static HB_EXPR_FUNC( hb_compExprUseDivEq ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUseOperEq, pSelf, HB_P_DIVIDE ); + hb_compExprUseOperEq( pSelf, HB_P_DIVIDE, HB_COMP_PARAM ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3001,7 +3004,7 @@ static HB_EXPR_FUNC( hb_compExprUseModEq ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushOperEq, pSelf, HB_P_MODULUS ); + hb_compExprPushOperEq( pSelf, HB_P_MODULUS, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -3009,11 +3012,11 @@ static HB_EXPR_FUNC( hb_compExprUseModEq ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUseOperEq, pSelf, HB_P_MODULUS ); + hb_compExprUseOperEq( pSelf, HB_P_MODULUS, HB_COMP_PARAM ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3041,7 +3044,7 @@ static HB_EXPR_FUNC( hb_compExprUseExpEq ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushOperEq, pSelf, HB_P_POWER ); + hb_compExprPushOperEq( pSelf, HB_P_POWER, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -3049,11 +3052,11 @@ static HB_EXPR_FUNC( hb_compExprUseExpEq ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUseOperEq, pSelf, HB_P_POWER ); + hb_compExprUseOperEq( pSelf, HB_P_POWER, HB_COMP_PARAM ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3138,7 +3141,7 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3223,7 +3226,7 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3243,8 +3246,7 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) if( pExpr->ExprType == HB_ET_LOGICAL ) { pExpr->value.asLogical = ! pExpr->value.asLogical; - pSelf->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */ - HB_COMP_EXPR_DELETE( pSelf ); + HB_COMP_EXPR_CLEAR( pSelf ); pSelf = pExpr; } else if( pExpr->ExprType == HB_EO_NOT && HB_SUPPORT_EXTOPT ) @@ -3357,7 +3359,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3415,7 +3417,7 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3471,7 +3473,7 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3527,7 +3529,7 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3584,7 +3586,7 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3641,7 +3643,7 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3698,7 +3700,7 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3755,7 +3757,7 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3856,7 +3858,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3936,7 +3938,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -3993,7 +3995,7 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -4050,7 +4052,7 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -4107,7 +4109,7 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -4165,7 +4167,7 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelOperator, pSelf ); + hb_compExprDelOperator( pSelf, HB_COMP_PARAM ); break; } return pSelf; @@ -4247,7 +4249,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreInc ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushPreOp, pSelf, HB_P_INC ); + hb_compExprPushPreOp( pSelf, HB_P_INC, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -4255,7 +4257,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreInc ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUsePreOp, pSelf, HB_P_INC ); + hb_compExprUsePreOp( pSelf, HB_P_INC, HB_COMP_PARAM ); break; case HB_EA_DELETE: @@ -4287,7 +4289,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreDec ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compExprPushPreOp, pSelf, HB_P_DEC ); + hb_compExprPushPreOp( pSelf, HB_P_DEC, HB_COMP_PARAM ); break; case HB_EA_POP_PCODE: @@ -4295,7 +4297,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreDec ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compExprUsePreOp, pSelf, HB_P_DEC ); + hb_compExprUsePreOp( pSelf, HB_P_DEC, HB_COMP_PARAM ); break; case HB_EA_DELETE: @@ -4344,8 +4346,9 @@ static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, HB_BOOL bLateEval, HB_C } } - HB_EXPR_PCODE0( hb_compLinePushIfDebugger ); + hb_compLinePushIfDebugger( HB_COMP_PARAM ); #endif + pExpr = pSelf->value.asCodeblock.pExprList; pPrev = &pSelf->value.asCodeblock.pExprList; while( pExpr ) @@ -4366,8 +4369,14 @@ static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, HB_BOOL bLateEval, HB_C * NOTE: During reduction the expression can be replaced by the * new one - this will break the linked list of expressions. */ - pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ - pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); + pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ + if( ( pSelf->value.asCodeblock.flags & HB_BLOCK_REDUCE ) != 0 || + HB_SUPPORT_HARBOUR ) + { + * pPrev = pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); + pExpr->pNext = pNext; /* restore the link to next expression */ + } + /* Generate push/pop pcodes for all expresions except the last one * The value of the last expression is used as a return value * of a codeblock evaluation @@ -4377,8 +4386,6 @@ static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, HB_BOOL bLateEval, HB_C * e.g. * EVAL( {|| 3+5, func()} ) */ - *pPrev = pExpr; /* store a new expression into the previous one */ - pExpr->pNext = pNext; /* restore the link to next expression */ #if defined( HB_MACRO_SUPPORT ) if( pNext ) HB_EXPR_USE( pExpr, HB_EA_PUSH_POP ); @@ -4418,7 +4425,8 @@ static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf, HB_COMP_DECL ) /* check first expression */ pExpr = pSelf->value.asCodeblock.pExprList; - if( pExpr->ExprType == HB_ET_MACRO && pExpr->value.asMacro.cMacroOp ) + if( pExpr->ExprType == HB_ET_MACRO && pExpr->value.asMacro.cMacroOp && + pExpr->pNext == NULL ) { /* simple macro variable expansion: &variable * 'szMacro' is a variable name @@ -4439,12 +4447,10 @@ static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf, HB_COMP_DECL ) /* everything else is macro compiled at runtime * {|| &variable+1} => &( '{|| &variable+1}' ) */ - HB_EXPR_PTR pNew; - hb_compExprCodeblockPush( pSelf, HB_FALSE, HB_COMP_PARAM ); - pNew = hb_compExprNewMacro( hb_compExprNewString( pSelf->value.asCodeblock.string, pSelf->ulLength, HB_FALSE, HB_COMP_PARAM ), 0, NULL, HB_COMP_PARAM ); - HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE ); - HB_COMP_EXPR_DELETE( pNew ); + pExpr = hb_compExprNewMacro( hb_compExprNewString( pSelf->value.asCodeblock.string, pSelf->ulLength, HB_FALSE, HB_COMP_PARAM ), 0, NULL, HB_COMP_PARAM ); + HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); + HB_COMP_EXPR_DELETE( pExpr ); hb_compCodeBlockStop( HB_COMP_PARAM ); } } @@ -4896,6 +4902,7 @@ static void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); HB_GEN_FUNC1( PCode1, bNewOp ); + /* restore original expression type */ pSelf->value.asOperator.pLeft->ExprType = iOldType; return; } @@ -4994,6 +5001,7 @@ static void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_GEN_FUNC1( PCode1, ( BYTE ) ( bOper == HB_P_INC ? HB_P_INCEQ : HB_P_DECEQ ) ); + /* restore original expression type */ pSelf->value.asOperator.pLeft->ExprType = iOldType; } return; @@ -5103,6 +5111,7 @@ static void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_GEN_FUNC1( PCode1, HB_P_DUPLUNREF ); HB_GEN_FUNC1( PCode1, ( BYTE ) ( bOper == HB_P_INC ? HB_P_INCEQPOP : HB_P_DECEQPOP ) ); + /* restore original expression type */ pSelf->value.asOperator.pLeft->ExprType = iOldType; } return; @@ -5199,6 +5208,7 @@ static void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_GEN_FUNC1( PCode1, ( BYTE ) ( bOper == HB_P_INC ? HB_P_INCEQPOP : HB_P_DECEQPOP ) ); + /* restore original expression type */ pSelf->value.asOperator.pLeft->ExprType = iOldType; } return; @@ -5276,25 +5286,19 @@ static void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_ */ static HB_EXPR_PTR hb_compExprReduceList( HB_EXPR_PTR pList, HB_COMP_DECL ) { - HB_EXPR_PTR pNext, pExpr; - HB_EXPR_PTR * pPrev; + HB_EXPR_PTR * pExpr; /* NOTE: During optimalization an expression on the list can be * replaced by the new one */ - pPrev = &pList->value.asList.pExprList; - pExpr = pList->value.asList.pExprList; - while( pExpr ) + pExpr = &pList->value.asList.pExprList; + while( *pExpr ) { - pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ - pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - if( HB_SUPPORT_HARBOUR ) - pExpr = hb_compExprListStrip( pExpr, HB_COMP_PARAM ); - *pPrev = pExpr; /* store a new expression into the previous one */ - pExpr->pNext = pNext; /* restore the link to next expression */ - pPrev = &pExpr->pNext; - pExpr = pNext; + HB_EXPR_PTR pNext = ( *pExpr )->pNext; /* store next expression in case the current will be reduced */ + *pExpr = HB_EXPR_USE( *pExpr, HB_EA_REDUCE ); + ( *pExpr )->pNext = pNext; /* restore the link to next expression */ + pExpr = &( *pExpr )->pNext; } return pList; } diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index a63898d650..cc3ac799ea 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -65,11 +65,6 @@ typedef HB_EXPR_FUNC( HB_EXPR_FUNC_ ); typedef HB_EXPR_FUNC_ *HB_EXPR_FUNC_PTR; typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage, HB_COMP_DECL ); -#define HB_EXPR_PCODE0( action ) action( HB_COMP_PARAM ) -#define HB_EXPR_PCODE1( action, p1 ) action( (p1), HB_COMP_PARAM ) -#define HB_EXPR_PCODE2( action, p1, p2 ) action( (p1), (p2), HB_COMP_PARAM ) -#define HB_EXPR_PCODE3( action, p1, p2, p3 ) action( (p1), (p2), (p3), HB_COMP_PARAM ) -#define HB_EXPR_PCODE4( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4), HB_COMP_PARAM ) #if defined( HB_MACRO_SUPPORT ) #define hb_comp_ExprTable hb_macro_ExprTable diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index 55a31fcb7c..9f1693158c 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -98,7 +98,7 @@ HB_EXTERN_BEGIN */ extern void hb_macroError( int iError, HB_COMP_DECL ); extern int hb_macroYYParse( HB_MACRO_PTR pMacro ); -extern ULONG hb_macroSetMacro( HB_BOOL bSet, ULONG ulFlag ); +extern int hb_macroSetMacro( HB_BOOL fSet, int flag ); extern ULONG hb_macroAutoSetMacro( ULONG ulFlag ); extern HB_BOOL hb_macroLexNew( HB_MACRO_PTR pMacro ); extern void hb_macroLexDelete( HB_MACRO_PTR pMacro ); diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h index f4f5a319d6..933da0f2b4 100644 --- a/harbour/include/hbpp.h +++ b/harbour/include/hbpp.h @@ -62,6 +62,7 @@ HB_EXTERN_BEGIN #define HB_BLOCK_LATEEVAL 2 #define HB_BLOCK_VPARAMS 4 #define HB_BLOCK_EXT 8 +#define HB_BLOCK_REDUCE 16 /* #pragma {__text,__stream,__cstream}|functionOut|functionEnd|functionStart */ #define HB_PP_STREAM_OFF 0 /* standard preprocessing */ diff --git a/harbour/include/hbxvm.h b/harbour/include/hbxvm.h index 3570efd5fd..1f2cb571d6 100644 --- a/harbour/include/hbxvm.h +++ b/harbour/include/hbxvm.h @@ -84,7 +84,7 @@ extern HB_EXPORT HB_BOOL hb_xvmAlwaysBegin( void ); extern HB_EXPORT HB_BOOL hb_xvmAlwaysEnd( void ); extern HB_EXPORT HB_BOOL hb_xvmSeqBlock( void ); -extern HB_EXPORT HB_BOOL hb_xvmEnumStart( BYTE, BYTE ); /* prepare FOR EACH loop */ +extern HB_EXPORT HB_BOOL hb_xvmEnumStart( int, int ); /* prepare FOR EACH loop */ extern HB_EXPORT HB_BOOL hb_xvmEnumNext( void ); /* increment FOR EACH loop counter */ extern HB_EXPORT HB_BOOL hb_xvmEnumPrev( void ); /* decrement FOR EACH loop counter */ extern HB_EXPORT void hb_xvmEnumEnd( void ); /* rewind the stack after FOR EACH loop counter */ @@ -189,23 +189,23 @@ extern HB_EXPORT HB_BOOL hb_xvmArrayPushRef( void ); /* pushes a r extern HB_EXPORT HB_BOOL hb_xvmArrayPop( void ); /* pops a value from the stack */ extern HB_EXPORT void hb_xvmHashGen( HB_SIZE ulElements ); /* generates an ulElements Hash and fills it from the stack values */ -extern HB_EXPORT void hb_xvmLocalName( USHORT uiLocal, char * szLocalName ); -extern HB_EXPORT void hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ); -extern HB_EXPORT void hb_xvmModuleName( char * szModuleName ); +extern HB_EXPORT void hb_xvmLocalName( USHORT uiLocal, const char * szLocalName ); +extern HB_EXPORT void hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, const char * szStaticName ); +extern HB_EXPORT void hb_xvmModuleName( const char * szModuleName ); extern HB_EXPORT HB_BOOL hb_xvmMacroDo( USHORT uiArgSets ); extern HB_EXPORT HB_BOOL hb_xvmMacroFunc( USHORT uiArgSets ); extern HB_EXPORT HB_BOOL hb_xvmMacroSend( USHORT uiArgSets ); extern HB_EXPORT HB_BOOL hb_xvmMacroArrayGen( USHORT uiArgSets ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPush( BYTE bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPush( int bFlags ); extern HB_EXPORT HB_BOOL hb_xvmMacroPushRef( void ); extern HB_EXPORT HB_BOOL hb_xvmMacroPushIndex( void ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPushArg( PHB_SYMB pSymbol, BYTE bFlags ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPushList( BYTE bFlags ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPushAliased( BYTE bFlags ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPushPare( BYTE bFlags ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPop( BYTE bFlags ); -extern HB_EXPORT HB_BOOL hb_xvmMacroPopAliased( BYTE bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPushArg( PHB_SYMB pSymbol, int bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPushList( int bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPushAliased( int bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPushPare( int bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPop( int bFlags ); +extern HB_EXPORT HB_BOOL hb_xvmMacroPopAliased( int bFlags ); extern HB_EXPORT HB_BOOL hb_xvmMacroSymbol( void ); extern HB_EXPORT HB_BOOL hb_xvmMacroText( void ); diff --git a/harbour/src/common/expropt1.c b/harbour/src/common/expropt1.c index eeabe94ee0..016d3f68f8 100644 --- a/harbour/src/common/expropt1.c +++ b/harbour/src/common/expropt1.c @@ -1421,9 +1421,15 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL ) HB_EXPR_PTR pIIF; HB_EXPR_PTR pSet; + /* NOTE: this is the only code which uses hb_compExprClone(). + * It's important to reduce pExpr before because it should + * not be changed later and our expression optimizer does + * not respect cloned expressions. + */ + /* create {|var| expression - * NOTE: this is not a valid variable name so there will be no collisions - */ + * NOTE: "~1" is not a valid variable name so there will be no collisions + */ /* create var==NIL */ pIIF = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "~1", HB_COMP_PARAM ), HB_COMP_PARAM ), hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ); @@ -1439,8 +1445,7 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL ) pIIF = hb_compExprAddListExpr( pIIF, pSet ); /* create IIF() expression */ pIIF = hb_compExprNewIIF( pIIF ); - /* create a codeblock - */ + /* create a codeblock */ return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd( hb_compExprNewCodeBlock( NULL, 0, 0, HB_COMP_PARAM ), "~1", ' ', HB_COMP_PARAM ), pIIF ); diff --git a/harbour/src/rdd/dbfcdx/dbfcdx1.c b/harbour/src/rdd/dbfcdx/dbfcdx1.c index 9835c2f118..db97393241 100644 --- a/harbour/src/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/src/rdd/dbfcdx/dbfcdx1.c @@ -1364,6 +1364,7 @@ static HB_BOOL hb_cdxIndexUnLockWrite( LPCDXINDEX pIndex ) pIndex->fFlush = HB_TRUE; pIndex->fChanged = HB_FALSE; } + hb_fileFlush( pIndex->pFile, TRUE ); #ifdef HB_CDX_DBGCODE if( ! pIndex->WrLck || pIndex->RdLck ) hb_errInternal( 9108, "hb_cdxIndexUnLockWrite: unlock error (*)", NULL, NULL ); @@ -1431,6 +1432,7 @@ static void hb_cdxIndexDiscardBuffers( LPCDXINDEX pIndex ) pTag->CurKey->rec = 0; pTag = pTag->pNext; } + hb_fileFlush( pIndex->pFile, FALSE ); } /* diff --git a/harbour/src/rdd/dbffpt/dbffpt1.c b/harbour/src/rdd/dbffpt/dbffpt1.c index e56080b0c4..1fbcd22956 100644 --- a/harbour/src/rdd/dbffpt/dbffpt1.c +++ b/harbour/src/rdd/dbffpt/dbffpt1.c @@ -191,11 +191,31 @@ static HB_BOOL hb_fptFileLockSh( FPTAREAP pArea, HB_BOOL fWait ) } /* - * Unlock memo file. + * Unlock memo file - exclusive lock. */ -static HB_BOOL hb_fptFileUnLock( FPTAREAP pArea ) +static HB_BOOL hb_fptFileUnLockEx( FPTAREAP pArea ) { - return !pArea->fShared || hb_fileLock( pArea->pMemoFile, FPT_LOCKPOS, FPT_LOCKSIZE, FL_UNLOCK ); + if( pArea->fShared ) + { + hb_fileFlush( pArea->pMemoFile, FALSE ); + return hb_fileLock( pArea->pMemoFile, FPT_LOCKPOS, FPT_LOCKSIZE, FL_UNLOCK ); + } + else + return HB_TRUE; +} + +/* + * Unlock memo file - shared lock + */ +static HB_BOOL hb_fptFileUnLockSh( FPTAREAP pArea ) +{ + if( pArea->fShared ) + { + hb_fileFlush( pArea->pMemoFile, FALSE ); + return hb_fileLock( pArea->pMemoFile, FPT_LOCKPOS, FPT_LOCKSIZE, FL_UNLOCK ); + } + else + return HB_TRUE; } /* @@ -228,8 +248,13 @@ static HB_BOOL hb_fptRootBlockLock( FPTAREAP pArea ) */ static HB_BOOL hb_fptRootBlockUnLock( FPTAREAP pArea ) { - return !pArea->fShared || - hb_fileLock( pArea->pMemoFile, FPT_ROOTBLOCK_OFFSET, 4, FL_UNLOCK ); + if( pArea->fShared ) + { + hb_fileFlush( pArea->pMemoFile, FALSE ); + return hb_fileLock( pArea->pMemoFile, FPT_ROOTBLOCK_OFFSET, 4, FL_UNLOCK ); + } + else + return HB_TRUE; } /* @@ -3362,7 +3387,7 @@ static HB_ERRCODE hb_fptGetVarField( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pI } if( fUnLock ) - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockSh( pArea ); return errCode; } @@ -3433,7 +3458,7 @@ static ULONG hb_fptPutVarFile( FPTAREAP pArea, ULONG ulBlock, const char * szFil { errCode = hb_fptWriteMemo( pArea, ulBlock, 0, NULL, hFile, 0, ulSize, &ulBlock ); - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockEx( pArea ); } else { @@ -3501,7 +3526,7 @@ static HB_ERRCODE hb_fptPutVarField( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pI SELF_GOCOLD( ( AREAP ) pArea ); } #endif - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockEx( pArea ); } else if( pField->uiLen == 3 ) { @@ -3676,7 +3701,7 @@ static HB_ERRCODE hb_fptPutVarField( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pI SELF_GOCOLD( ( AREAP ) pArea ); #endif } - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockEx( pArea ); } } if( pAlloc ) @@ -3734,7 +3759,7 @@ static HB_ERRCODE hb_fptGetVarLen( FPTAREAP pArea, USHORT uiIndex, ULONG * pLeng *pLength = 0; if( fUnLock ) - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockSh( pArea ); return errCode; } @@ -4161,7 +4186,7 @@ static HB_ERRCODE hb_fptOpenMemFile( FPTAREAP pArea, LPDBOPENINFO pOpenInfo ) } } } - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockSh( pArea ); } } @@ -4285,7 +4310,7 @@ static HB_ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, const char SELF_GOCOLD( ( AREAP ) pArea ); } #endif - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockEx( pArea ); hb_fsClose( hFile ); } /* Exit if any error */ @@ -4793,7 +4818,7 @@ static HB_ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( hb_fptFileLockEx( pArea, HB_TRUE ) ) { errCode = hb_fptPutMemo( pArea, 0, pValue, &ulBlock, FPT_DIRECT_TRANS( pArea ) ); - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockEx( pArea ); } else errCode = EDBF_LOCK; @@ -4838,7 +4863,7 @@ static HB_ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( hb_fptFileLockEx( pArea, HB_TRUE ) ) { errCode = hb_fptPutMemo( pArea, 0, pItem, &ulBlock, FPT_DIRECT_TRANS( pArea ) ); - hb_fptFileUnLock( pArea ); + hb_fptFileUnLockEx( pArea ); if( errCode == HB_SUCCESS ) errCode = hb_fptPutRootBlock( pArea, ulBlock ); } diff --git a/harbour/src/rdd/dbfnsx/dbfnsx1.c b/harbour/src/rdd/dbfnsx/dbfnsx1.c index bb783d3ea3..586632ab4e 100644 --- a/harbour/src/rdd/dbfnsx/dbfnsx1.c +++ b/harbour/src/rdd/dbfnsx/dbfnsx1.c @@ -1246,6 +1246,7 @@ static void hb_nsxDiscardBuffers( LPNSXINDEX pIndex ) pIndex->lpTags[ i ]->stackLevel = 0; pIndex->lpTags[ i ]->CurKeyOffset = 0; } + hb_fileFlush( pIndex->pFile, FALSE ); } /* @@ -2277,6 +2278,7 @@ static HB_BOOL hb_nsxIndexUnLockWrite( LPNSXINDEX pIndex ) } else { + hb_fileFlush( pIndex->pFile, TRUE ); pIndex->fValidHeader = HB_FALSE; fOK = hb_dbfLockIdxFile( pIndex->pFile, pIndex->pArea->dbfarea.bLockType, FL_UNLOCK, &pIndex->ulLockPos ); diff --git a/harbour/src/rdd/dbfntx/dbfntx1.c b/harbour/src/rdd/dbfntx/dbfntx1.c index 60fdd4d122..e023a17767 100644 --- a/harbour/src/rdd/dbfntx/dbfntx1.c +++ b/harbour/src/rdd/dbfntx/dbfntx1.c @@ -1012,6 +1012,7 @@ static void hb_ntxDiscardBuffers( LPNTXINDEX pIndex ) if( pIndex->iTags ) pIndex->lpTags[ 0 ]->stackLevel = 0; } + hb_fileFlush( pIndex->DiskFile, FALSE ); } /* @@ -2169,6 +2170,7 @@ static HB_BOOL hb_ntxIndexUnLockWrite( LPNTXINDEX pIndex ) } else { + hb_fileFlush( pIndex->DiskFile, TRUE ); pIndex->fValidHeader = HB_FALSE; fOK = hb_dbfLockIdxFile( pIndex->DiskFile, pIndex->Owner->dbfarea.bLockType, FL_UNLOCK, &pIndex->ulLockPos ); diff --git a/harbour/src/rtl/filebuf.c b/harbour/src/rtl/filebuf.c index cc2b82c6f1..9c77fdfdf0 100644 --- a/harbour/src/rtl/filebuf.c +++ b/harbour/src/rtl/filebuf.c @@ -538,6 +538,12 @@ static HB_FOFFSET s_fileSize( PHB_FILE pFile ) return hb_fsSeekLarge( pFile->hFile, 0, FS_END ); } +static void s_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ) +{ + HB_SYMBOL_UNUSED( pFile ); + HB_SYMBOL_UNUSED( fDirty ); +} + static void s_fileCommit( PHB_FILE pFile ) { hb_fsCommit( pFile->hFile ); @@ -564,6 +570,7 @@ static const HB_FILE_FUNCS * s_fileMethods( void ) s_fileWriteAt, s_fileTruncAt, s_fileSize, + s_fileFlush, s_fileCommit, s_fileHandle }; @@ -684,6 +691,11 @@ HB_FOFFSET hb_fileSize( PHB_FILE pFile ) return pFile->pFuncs->Size( pFile ); } +void hb_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ) +{ + pFile->pFuncs->Flush( pFile, fDirty ); +} + void hb_fileCommit( PHB_FILE pFile ) { pFile->pFuncs->Commit( pFile ); diff --git a/harbour/src/vm/hvm.c b/harbour/src/vm/hvm.c index 54782303c8..e69d826950 100644 --- a/harbour/src/vm/hvm.c +++ b/harbour/src/vm/hvm.c @@ -127,7 +127,7 @@ static void hb_vmInstring( void ); /* check whether string 1 is contai static void hb_vmForTest( void ); /* test for end condition of for */ static void hb_vmSeqBlock( void ); /* set begin sequence WITH codeblock */ static void hb_vmWithObjectStart( void ); /* prepare WITH OBJECT block */ -static void hb_vmEnumStart( BYTE nVars, BYTE nDescend ); /* prepare FOR EACH loop */ +static void hb_vmEnumStart( int nVars, int nDescend ); /* prepare FOR EACH loop */ static void hb_vmEnumNext( void ); /* increment FOR EACH loop counter */ static void hb_vmEnumPrev( void ); /* decrement FOR EACH loop counter */ static void hb_vmEnumEnd( void ); /* rewind the stack after FOR EACH loop counter */ @@ -159,8 +159,8 @@ static void hb_vmSwapAlias( void ); /* swaps items on the eval s /* Execution */ static HARBOUR hb_vmDoBlock( void ); /* executes a codeblock */ -static void hb_vmFrame( USHORT usLocals, BYTE bParams ); /* increases the stack pointer for the amount of locals and params suplied */ -static void hb_vmVFrame( USHORT usLocals, BYTE bParams ); /* increases the stack pointer for the amount of locals and variable number of params suplied */ +static void hb_vmFrame( USHORT usLocals, unsigned char ucParams ); /* increases the stack pointer for the amount of locals and params suplied */ +static void hb_vmVFrame( USHORT usLocals, unsigned char ucParams ); /* increases the stack pointer for the amount of locals and variable number of params suplied */ static void hb_vmSFrame( PHB_SYMB pSym ); /* sets the statics frame for a function */ static void hb_vmStatics( PHB_SYMB pSym, USHORT uiStatics ); /* increases the global statics array to hold a PRG statics */ static void hb_vmInitThreadStatics( USHORT uiCount, const BYTE * pCode ); /* mark thread static variables */ @@ -193,7 +193,7 @@ static void hb_vmPushVParams( void ); /* pusges variable parameters */ static void hb_vmPushUnRef( void ); /* push the unreferenced latest value on the stack */ static void hb_vmDuplicate( void ); /* duplicates the latest value on the stack */ static void hb_vmDuplUnRef( void ); /* duplicates the latest value on the stack and unref the source one */ -static void hb_vmSwap( BYTE bCount ); /* swap bCount+1 time two items on HVM stack starting from the most top one */ +static void hb_vmSwap( int iCount ); /* swap bCount+1 time two items on HVM stack starting from the most top one */ /* Pop */ static HB_BOOL hb_vmPopLogical( void ); /* pops the stack latest value and returns its logical value */ @@ -212,9 +212,9 @@ static void hb_vmReleaseLocalSymbols( void ); /* releases the memory of the static void hb_vmMsgIndexReference( PHB_ITEM pRefer, PHB_ITEM pObject, PHB_ITEM pIndex ); /* create object index reference */ #ifndef HB_NO_DEBUG -static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ); /* locals and parameters index and name information for the debugger */ -static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ); /* statics vars information for the debugger */ -static void hb_vmModuleName( char * szModuleName ); /* PRG and function name information for the debugger */ +static void hb_vmLocalName( USHORT uiLocal, const char * szLocalName ); /* locals and parameters index and name information for the debugger */ +static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, const char * szStaticName ); /* statics vars information for the debugger */ +static void hb_vmModuleName( const char * szModuleName ); /* PRG and function name information for the debugger */ static void hb_vmDebugEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ); static void hb_vmDebuggerExit( HB_BOOL fRemove ); /* shuts down the debugger */ @@ -1520,7 +1520,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) break; case HB_P_ENUMSTART: - hb_vmEnumStart( pCode[ 1 ], pCode[ 2 ] ); + hb_vmEnumStart( ( unsigned char ) pCode[ 1 ], ( unsigned char ) pCode[ 2 ] ); pCode += 3; break; @@ -1681,22 +1681,22 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) break; case HB_P_FRAME: - hb_vmFrame( pCode[ 1 ], pCode[ 2 ] ); + hb_vmFrame( ( unsigned char ) pCode[ 1 ], ( unsigned char ) pCode[ 2 ] ); pCode += 3; break; case HB_P_VFRAME: - hb_vmVFrame( pCode[ 1 ], pCode[ 2 ] ); + hb_vmVFrame( ( unsigned char ) pCode[ 1 ], ( unsigned char ) pCode[ 2 ] ); pCode += 3; break; case HB_P_LARGEFRAME: - hb_vmFrame( HB_PCODE_MKUSHORT( &pCode[ 1 ] ), pCode[ 3 ] ); + hb_vmFrame( HB_PCODE_MKUSHORT( &pCode[ 1 ] ), ( unsigned char ) pCode[ 3 ] ); pCode += 4; break; case HB_P_LARGEVFRAME: - hb_vmVFrame( HB_PCODE_MKUSHORT( &pCode[ 1 ] ), pCode[ 3 ] ); + hb_vmVFrame( HB_PCODE_MKUSHORT( &pCode[ 1 ] ), ( unsigned char ) pCode[ 3 ] ); pCode += 4; break; @@ -1721,7 +1721,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_LOCALNAME: #ifndef HB_NO_DEBUG hb_vmLocalName( HB_PCODE_MKUSHORT( &pCode[ 1 ] ), - ( char * ) pCode + 3 ); + ( const char * ) pCode + 3 ); #endif pCode += 3; while( *pCode++ ) {}; @@ -1730,7 +1730,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_STATICNAME: #ifndef HB_NO_DEBUG hb_vmStaticName( pCode[ 1 ], HB_PCODE_MKUSHORT( &pCode[ 2 ] ), - ( char * ) pCode + 4 ); + ( const char * ) pCode + 4 ); #endif pCode += 4; while( *pCode++ ) {}; @@ -1738,7 +1738,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_MODULENAME: #ifndef HB_NO_DEBUG - hb_vmModuleName( ( char * ) pCode + 1 ); + hb_vmModuleName( ( const char * ) pCode + 1 ); #endif pCode++; while( *pCode++ ) {}; @@ -1968,7 +1968,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) /* Jumps */ case HB_P_JUMPNEAR: - pCode += (signed char) pCode[ 1 ]; + pCode += ( signed char ) pCode[ 1 ]; break; case HB_P_JUMP: @@ -1981,7 +1981,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_JUMPFALSENEAR: if( ! hb_vmPopLogical() ) - pCode += (signed char) pCode[ 1 ]; + pCode += ( signed char ) pCode[ 1 ]; else pCode += 2; break; @@ -2002,7 +2002,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_JUMPTRUENEAR: if( hb_vmPopLogical() ) - pCode += (signed char) pCode[ 1 ]; + pCode += ( signed char ) pCode[ 1 ]; else pCode += 2; break; @@ -2121,16 +2121,16 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_PUSHDOUBLE: hb_vmPushDoubleConst( HB_PCODE_MKDOUBLE( &pCode[ 1 ] ), - ( int ) * ( UCHAR * ) &pCode[ 1 + sizeof( double ) ], - ( int ) * ( UCHAR * ) &pCode[ 2 + sizeof( double ) ] ); + ( int ) * ( unsigned char * ) &pCode[ 1 + sizeof( double ) ], + ( int ) * ( unsigned char * ) &pCode[ 2 + sizeof( double ) ] ); pCode += 3 + sizeof( double ); break; case HB_P_PUSHSTRSHORT: if( bDynCode ) - hb_vmPushString( ( char * ) pCode + 2, ( HB_SIZE ) pCode[ 1 ] - 1 ); + hb_vmPushString( ( const char * ) pCode + 2, ( HB_SIZE ) pCode[ 1 ] - 1 ); else - hb_vmPushStringPcode( ( char * ) pCode + 2, ( HB_SIZE ) pCode[ 1 ] - 1 ); + hb_vmPushStringPcode( ( const char * ) pCode + 2, ( HB_SIZE ) pCode[ 1 ] - 1 ); pCode += 2 + pCode[ 1 ]; break; @@ -2138,9 +2138,9 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) { USHORT uiSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] ); if( bDynCode ) - hb_vmPushString( ( char * ) pCode + 3, uiSize - 1 ); + hb_vmPushString( ( const char * ) pCode + 3, uiSize - 1 ); else - hb_vmPushStringPcode( ( char * ) pCode + 3, uiSize - 1 ); + hb_vmPushStringPcode( ( const char * ) pCode + 3, uiSize - 1 ); pCode += 3 + uiSize; break; } @@ -2149,9 +2149,9 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) { HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] ); if( bDynCode ) - hb_vmPushString( ( char * ) pCode + 4, ulSize - 1 ); + hb_vmPushString( ( const char * ) pCode + 4, ulSize - 1 ); else - hb_vmPushStringPcode( ( char * ) pCode + 4, ulSize - 1 ); + hb_vmPushStringPcode( ( const char * ) pCode + 4, ulSize - 1 ); pCode += 4 + ulSize; break; } @@ -2159,7 +2159,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_PUSHSTRHIDDEN: { HB_SIZE ulSize = ( HB_SIZE ) HB_PCODE_MKUSHORT( &pCode[ 2 ] ); - char * szText = hb_compDecodeString( pCode[ 1 ], ( char * ) pCode + 4, &ulSize ); + char * szText = hb_compDecodeString( pCode[ 1 ], ( const char * ) pCode + 4, &ulSize ); hb_itemPutCLPtr( hb_stackAllocItem(), szText, ulSize ); pCode += ( 4 + ulSize ); break; @@ -2198,7 +2198,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) * +7 -> start of table with referenced local variables */ HB_SIZE ulSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] ); - hb_vmPushBlock( ( const BYTE * ) ( pCode + 3 ), pSymbols, bDynCode ? ulSize - 7 : 0 ); + hb_vmPushBlock( pCode + 3, pSymbols, bDynCode ? ulSize - 7 : 0 ); pCode += ulSize; break; } @@ -2211,7 +2211,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) * +8 -> start of table with referenced local variables */ HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] ); - hb_vmPushBlock( ( const BYTE * ) ( pCode + 4 ), pSymbols, bDynCode ? ulSize - 8 : 0 ); + hb_vmPushBlock( pCode + 4, pSymbols, bDynCode ? ulSize - 8 : 0 ); pCode += ulSize; break; } @@ -2221,7 +2221,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) * +1 -> size of codeblock */ HB_SIZE ulSize = pCode[ 1 ]; - hb_vmPushBlockShort( ( const BYTE * ) ( pCode + 2 ), pSymbols, bDynCode ? ulSize - 2 : 0 ); + hb_vmPushBlockShort( pCode + 2, pSymbols, bDynCode ? ulSize - 2 : 0 ); pCode += ulSize; break; } @@ -2340,7 +2340,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) break; case HB_P_SWAP: - hb_vmSwap( pCode[ 1 ] ); + hb_vmSwap( ( unsigned char ) pCode[ 1 ] ); pCode += 2; break; @@ -2613,7 +2613,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) * +5 -> pcode bytes */ HB_SIZE ulSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] ); - hb_vmPushMacroBlock( ( BYTE * ) ( pCode + 5 ), ulSize - 5, + hb_vmPushMacroBlock( pCode + 5, ulSize - 5, HB_PCODE_MKUSHORT( &pCode[ 3 ] ) ); pCode += ulSize; break; @@ -2631,7 +2631,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) * +6 -> pcode bytes */ HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] ); - hb_vmPushMacroBlock( ( BYTE * ) ( pCode + 6 ), ulSize - 6, + hb_vmPushMacroBlock( pCode + 6, ulSize - 6, HB_PCODE_MKUSHORT( &pCode[ 4 ] ) ); pCode += ulSize; break; @@ -2686,7 +2686,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) { USHORT uiSize = HB_PCODE_MKUSHORT( &pCode[ 1 ] ); - hb_vmPushString( ( char * ) ( pCode + 3 ), uiSize - 1 ); + hb_vmPushString( ( const char * ) ( pCode + 3 ), uiSize - 1 ); pCode += 3 + uiSize; break; } @@ -2695,7 +2695,7 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) { HB_SIZE ulSize = HB_PCODE_MKUINT24( &pCode[ 1 ] ); - hb_vmPushString( ( char * ) ( pCode + 3 ), ulSize - 1 ); + hb_vmPushString( ( const char * ) ( pCode + 3 ), ulSize - 1 ); pCode += 4 + ulSize; break; } @@ -4543,7 +4543,7 @@ static void hb_vmEnumReference( PHB_ITEM pBase ) * -1 -> */ /* Test to check the start point of the FOR EACH loop */ -static void hb_vmEnumStart( BYTE nVars, BYTE nDescend ) +static void hb_vmEnumStart( int nVars, int nDescend ) { HB_STACK_TLS_PRELOAD HB_BOOL fStart = HB_TRUE; @@ -4867,8 +4867,7 @@ static const BYTE * hb_vmSwitch( const BYTE * pCode, USHORT casesCnt ) { /*fFound = hb_itemStrCmp( pItem1, pItem2, bExact );*/ fFound = ( HB_SIZE ) pCode[ 1 ] - 1 == pSwitch->item.asString.length && - memcmp( pSwitch->item.asString.value, - ( char * ) &pCode[ 2 ], + memcmp( pSwitch->item.asString.value, &pCode[ 2 ], pSwitch->item.asString.length ) == 0; } pCode += 2 + pCode[ 1 ]; @@ -6167,7 +6166,7 @@ static void hb_vmDebuggerShowLine( USHORT uiLine ) /* makes the debugger shows a s_pFunDbgEntry( HB_DBG_SHOWLINE, uiLine, NULL, 0, NULL ); } -static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ) /* locals and parameters index and name information for the debugger */ +static void hb_vmLocalName( USHORT uiLocal, const char * szLocalName ) /* locals and parameters index and name information for the debugger */ { HB_STACK_TLS_PRELOAD @@ -6177,7 +6176,7 @@ static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ) /* locals and p s_pFunDbgEntry( HB_DBG_LOCALNAME, 0, szLocalName, uiLocal, NULL ); } -static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ) /* statics vars information for the debugger */ +static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, const char * szStaticName ) /* statics vars information for the debugger */ { HB_STACK_TLS_PRELOAD @@ -6189,7 +6188,7 @@ static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticNam s_pFunDbgEntry( HB_DBG_STATICNAME, 0, szStaticName, uiStatic, ( PHB_ITEM ) hb_stackGetStaticsBase() ); } -static void hb_vmModuleName( char * szModuleName ) /* PRG and function name information for the debugger */ +static void hb_vmModuleName( const char * szModuleName ) /* PRG and function name information for the debugger */ { HB_TRACE(HB_TR_DEBUG, ("hb_vmModuleName(%s)", szModuleName)); @@ -6202,13 +6201,13 @@ static void hb_vmModuleName( char * szModuleName ) /* PRG and function name info } #endif -static void hb_vmFrame( USHORT usLocals, BYTE bParams ) +static void hb_vmFrame( USHORT usLocals, unsigned char ucParams ) { HB_STACK_TLS_PRELOAD PHB_ITEM pBase; int iTotal; - HB_TRACE(HB_TR_DEBUG, ("hb_vmFrame(%d, %d)", (int) usLocals, (int) bParams)); + HB_TRACE(HB_TR_DEBUG, ("hb_vmFrame(%d, %d)", (int) usLocals, (int) ucParams)); pBase = hb_stackBaseItem(); @@ -6216,16 +6215,16 @@ static void hb_vmFrame( USHORT usLocals, BYTE bParams ) /* This old code which clears additional parameters to make space for * local variables without updating pBase->item.asSymbol.paramdeclcnt */ - iTotal = pBase->item.asSymbol.paramcnt - bParams; + iTotal = pBase->item.asSymbol.paramcnt - ucParams; if( iTotal > 0 ) { - pBase->item.asSymbol.paramcnt = bParams; + pBase->item.asSymbol.paramcnt = ucParams; do hb_itemClear( hb_stackItemFromTop( -iTotal ) ); while( --iTotal > 0 ); } - iTotal = usLocals + bParams; + iTotal = usLocals + ucParams; if( iTotal ) { iTotal -= pBase->item.asSymbol.paramcnt; @@ -6233,9 +6232,9 @@ static void hb_vmFrame( USHORT usLocals, BYTE bParams ) hb_vmPushNil(); } #else - pBase->item.asSymbol.paramdeclcnt = bParams; + pBase->item.asSymbol.paramdeclcnt = ucParams; - iTotal = bParams - pBase->item.asSymbol.paramcnt; + iTotal = ucParams - pBase->item.asSymbol.paramcnt; if( iTotal < 0 ) iTotal = 0; iTotal += usLocals; @@ -6249,19 +6248,19 @@ static void hb_vmFrame( USHORT usLocals, BYTE bParams ) #endif } -static void hb_vmVFrame( USHORT usLocals, BYTE bParams ) +static void hb_vmVFrame( USHORT usLocals, unsigned char ucParams ) { HB_STACK_TLS_PRELOAD PHB_ITEM pBase; int iTotal; - HB_TRACE(HB_TR_DEBUG, ("hb_vmVFrame(%d, %d)", (int) usLocals, (int) bParams)); + HB_TRACE(HB_TR_DEBUG, ("hb_vmVFrame(%d, %d)", (int) usLocals, (int) ucParams)); pBase = hb_stackBaseItem(); - pBase->item.asSymbol.paramdeclcnt = bParams; + pBase->item.asSymbol.paramdeclcnt = ucParams; - iTotal = bParams - pBase->item.asSymbol.paramcnt; + iTotal = ucParams - pBase->item.asSymbol.paramcnt; if( iTotal < 0 ) iTotal = 0; iTotal += usLocals; @@ -6878,7 +6877,7 @@ static void hb_vmPushAliasedVar( PHB_SYMB pSym ) if( HB_IS_STRING( pAlias ) ) { - char * szAlias = pAlias->item.asString.value; + const char * szAlias = pAlias->item.asString.value; if( szAlias[ 0 ] == 'M' || szAlias[ 0 ] == 'm' ) { @@ -7067,19 +7066,19 @@ static void hb_vmPushUnRef( void ) HB_IS_BYREF( pItem ) ? hb_itemUnRef( pItem ) : pItem ); } -static void hb_vmSwap( BYTE bCount ) +static void hb_vmSwap( int iCount ) { HB_STACK_TLS_PRELOAD int i = -1; - HB_TRACE(HB_TR_DEBUG, ("hb_vmSwap(%d)", bCount)); + HB_TRACE(HB_TR_DEBUG, ("hb_vmSwap(%d)", iCount)); do { hb_itemSwap( hb_stackItemFromTop( i ), hb_stackItemFromTop( i - 1 ) ); --i; } - while( bCount-- ); + while( iCount-- ); } /* ------------------------------- */ @@ -7166,7 +7165,7 @@ static void hb_vmPopAliasedVar( PHB_SYMB pSym ) */ if( HB_IS_STRING( pAlias ) ) { - char * szAlias = pAlias->item.asString.value; + const char * szAlias = pAlias->item.asString.value; if( szAlias[ 0 ] == 'M' || szAlias[ 0 ] == 'm' ) { @@ -8823,7 +8822,7 @@ HB_BOOL hb_xvmSeqBlock( void ) HB_XVM_RETURN } -HB_BOOL hb_xvmEnumStart( BYTE nVars, BYTE nDescend ) +HB_BOOL hb_xvmEnumStart( int nVars, int nDescend ) { HB_STACK_TLS_PRELOAD @@ -8891,14 +8890,14 @@ void hb_xvmFrame( int iLocals, int iParams ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmFrame(%d, %d)", iLocals, iParams)); - hb_vmFrame( ( USHORT ) iLocals, ( BYTE ) iParams ); + hb_vmFrame( ( USHORT ) iLocals, ( unsigned char ) iParams ); } void hb_xvmVFrame( int iLocals, int iParams ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmVFrame(%d, %d)", iLocals, iParams)); - hb_vmVFrame( ( USHORT ) iLocals, ( BYTE ) iParams ); + hb_vmVFrame( ( USHORT ) iLocals, ( unsigned char ) iParams ); } void hb_xvmSFrame( PHB_SYMB pSymbol ) @@ -9494,7 +9493,7 @@ void hb_xvmSwap( int iCount ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmSwap(%d)", iCount)); - hb_vmSwap( ( BYTE ) iCount ); + hb_vmSwap( iCount ); } HB_BOOL hb_xvmForTest( void ) @@ -10946,7 +10945,7 @@ void hb_xvmPushStringHidden( int iMethod, const char * szText, HB_SIZE ulSize ) hb_itemPutCLPtr( hb_stackAllocItem(), szString, ulSize ); } -void hb_xvmLocalName( USHORT uiLocal, char * szLocalName ) +void hb_xvmLocalName( USHORT uiLocal, const char * szLocalName ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalName(%hu, %s)", uiLocal, szLocalName)); @@ -10958,7 +10957,7 @@ void hb_xvmLocalName( USHORT uiLocal, char * szLocalName ) #endif } -void hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ) +void hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, const char * szStaticName ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmStaticName(%d, %hu, %s)", (int)bIsGlobal, uiStatic, szStaticName)); @@ -10971,7 +10970,7 @@ void hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ) #endif } -void hb_xvmModuleName( char * szModuleName ) +void hb_xvmModuleName( const char * szModuleName ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmModuleName(%s)", szModuleName)); @@ -11026,13 +11025,13 @@ HB_BOOL hb_xvmMacroSend( USHORT uiArgSets ) HB_XVM_RETURN } -HB_BOOL hb_xvmMacroPush( BYTE bFlags ) +HB_BOOL hb_xvmMacroPush( int iFlags ) { HB_STACK_TLS_PRELOAD - HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPush(%d)", bFlags)); + HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPush(%d)", iFlags)); - hb_macroGetValue( hb_stackItemFromTop( -1 ), 0, bFlags ); + hb_macroGetValue( hb_stackItemFromTop( -1 ), 0, iFlags ); HB_XVM_RETURN } @@ -11062,57 +11061,57 @@ HB_BOOL hb_xvmMacroPushIndex( void ) HB_XVM_RETURN } -HB_BOOL hb_xvmMacroPushList( BYTE bFlags ) +HB_BOOL hb_xvmMacroPushList( int iFlags ) { HB_STACK_TLS_PRELOAD - HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushList(%d)", bFlags)); + HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushList(%d)", iFlags)); - hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHLIST, bFlags ); + hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHLIST, iFlags ); HB_XVM_RETURN } -HB_BOOL hb_xvmMacroPushPare( BYTE bFlags ) +HB_BOOL hb_xvmMacroPushPare( int iFlags ) { HB_STACK_TLS_PRELOAD - HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushPare(%d)", bFlags)); + HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushPare(%d)", iFlags)); - hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHPARE, bFlags ); + hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHPARE, iFlags ); HB_XVM_RETURN } -HB_BOOL hb_xvmMacroPushAliased( BYTE bFlags ) +HB_BOOL hb_xvmMacroPushAliased( int iFlags ) { HB_STACK_TLS_PRELOAD - HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushAliased(%d)", bFlags)); + HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushAliased(%d)", iFlags)); - hb_macroPushAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), bFlags ); + hb_macroPushAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), iFlags ); HB_XVM_RETURN } -HB_BOOL hb_xvmMacroPop( BYTE bFlags ) +HB_BOOL hb_xvmMacroPop( int iFlags ) { HB_STACK_TLS_PRELOAD - HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPop(%d)", bFlags)); + HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPop(%d)", iFlags)); - hb_macroSetValue( hb_stackItemFromTop( -1 ), bFlags ); + hb_macroSetValue( hb_stackItemFromTop( -1 ), iFlags ); HB_XVM_RETURN } -HB_BOOL hb_xvmMacroPopAliased( BYTE bFlags ) +HB_BOOL hb_xvmMacroPopAliased( int iFlags ) { HB_STACK_TLS_PRELOAD - HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPopAliased(%d)", bFlags)); + HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPopAliased(%d)", iFlags)); - hb_macroPopAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), bFlags ); + hb_macroPopAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), iFlags ); HB_XVM_RETURN } diff --git a/harbour/src/vm/macro.c b/harbour/src/vm/macro.c index 83a96267cf..a290db0d33 100644 --- a/harbour/src/vm/macro.c +++ b/harbour/src/vm/macro.c @@ -77,21 +77,21 @@ static void hb_macroFlagsInit( void * pFlags ) * ( ( ULONG * ) pFlags ) = HB_SM_DEFAULT; } -static HB_TSD_NEW( s_macroFlags, sizeof( ULONG ), hb_macroFlagsInit, NULL ); +static HB_TSD_NEW( s_macroFlags, sizeof( int ), hb_macroFlagsInit, NULL ); -static ULONG hb_macroFlags( void ) +static int hb_macroFlags( void ) { - return * ( ( ULONG * ) hb_stackGetTSD( &s_macroFlags ) ); + return * ( ( int * ) hb_stackGetTSD( &s_macroFlags ) ); } -static void hb_macroFlagsSet( ULONG flag ) +static void hb_macroFlagsSet( int flag ) { - * ( ( ULONG * ) hb_stackGetTSD( &s_macroFlags ) ) = flag; + * ( ( int * ) hb_stackGetTSD( &s_macroFlags ) ) = flag; } #else - static ULONG s_macroFlags = HB_SM_DEFAULT; + static int s_macroFlags = HB_SM_DEFAULT; # define hb_macroFlags() s_macroFlags # define hb_macroFlagsSet(f) do { s_macroFlags = (f); } while(0) @@ -413,7 +413,7 @@ static char * hb_macroTextSubst( const char * szString, HB_SIZE *pulStringLen ) * */ -void hb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags ) +void hb_macroGetValue( HB_ITEM_PTR pItem, int iContext, int flags ) { HB_STACK_TLS_PRELOAD @@ -497,7 +497,7 @@ void hb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags ) * placed on the left side of the assignment * POP operation */ -void hb_macroSetValue( HB_ITEM_PTR pItem, BYTE flags ) +void hb_macroSetValue( HB_ITEM_PTR pItem, int flags ) { HB_STACK_TLS_PRELOAD @@ -587,7 +587,7 @@ void hb_macroPushReference( HB_ITEM_PTR pItem ) * instead of * &( "M + M" ) -> &( "M + M" ) */ -static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, BYTE bSupported ) +static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, int iSupported ) { HB_STACK_TLS_PRELOAD @@ -607,7 +607,7 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, szString[ ulLen ] = '\0'; struMacro.mode = HB_MODE_MACRO; - struMacro.supported = (bSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : bSupported; + struMacro.supported = (iSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : iSupported; struMacro.Flags = iFlag; struMacro.uiNameLen = HB_SYMBOL_NAME_LEN; struMacro.status = HB_MACRO_CONT; @@ -641,7 +641,7 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, int iStatus; struMacro.mode = HB_MODE_MACRO; - struMacro.supported = (bSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : bSupported; + struMacro.supported = (iSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : iSupported; struMacro.Flags = iFlag | HB_MACRO_GEN_ALIASED; struMacro.uiNameLen = HB_SYMBOL_NAME_LEN; struMacro.status = HB_MACRO_CONT; @@ -667,7 +667,7 @@ static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, * &alias->var := any * alias->&var := any */ -void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ) +void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int flags ) { HB_TRACE(HB_TR_DEBUG, ("hb_macroPopAliasedValue(%p, %p)", pAlias, pVar)); @@ -679,7 +679,7 @@ void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ) * any := &alias->var * any := alias->&var */ -void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ) +void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int flags ) { HB_TRACE(HB_TR_DEBUG, ("hb_macroPushAliasedValue(%p, %p)", pAlias, pVar)); @@ -1025,19 +1025,19 @@ const char * hb_macroGetType( HB_ITEM_PTR pItem ) * Set macro capabilities if flag > 0 or get current macro capabilities * if flag == 0 */ -ULONG hb_macroSetMacro( HB_BOOL bSet, ULONG flag ) +int hb_macroSetMacro( HB_BOOL fSet, int flag ) { - ULONG ulCurrentFlags = hb_macroFlags(); + int currentFlags = hb_macroFlags(); if( flag > 0 ) { - if( bSet ) - hb_macroFlagsSet( ulCurrentFlags | flag ); + if( fSet ) + hb_macroFlagsSet( currentFlags | flag ); else - hb_macroFlagsSet( ulCurrentFlags & ~flag ); + hb_macroFlagsSet( currentFlags & ~flag ); } - return ulCurrentFlags; + return currentFlags; } HB_FUNC( HB_SETMACRO ) @@ -1047,10 +1047,10 @@ HB_FUNC( HB_SETMACRO ) if( iPrmCnt > 0 ) { - ULONG ulFlags = ( ULONG ) hb_parnl( 1 ); + int flags = hb_parni( 1 ); PHB_ITEM pValue; - switch( ulFlags ) + switch( flags ) { case HB_SM_HARBOUR: /* enable/disable extended Harbour compatibility */ @@ -1060,10 +1060,10 @@ HB_FUNC( HB_SETMACRO ) /* enable/disable processing of strings as an array of bytes */ case HB_SM_SHORTCUTS: /* enable/disable support for shortcut logical operators */ - hb_retl( hb_macroFlags() & ulFlags ); + hb_retl( hb_macroFlags() & flags ); pValue = hb_param( 2, HB_IT_LOGICAL ); if( pValue ) - hb_macroSetMacro( hb_itemGetL( pValue ), ulFlags ); + hb_macroSetMacro( hb_itemGetL( pValue ), flags ); break; default: @@ -1256,7 +1256,7 @@ void hb_macroGenPushLong( HB_LONG lNumber, HB_COMP_DECL ) } else if( HB_LIM_INT8( lNumber ) ) { - hb_macroGenPCode2( HB_P_PUSHBYTE, (BYTE) lNumber, HB_COMP_PARAM ); + hb_macroGenPCode2( HB_P_PUSHBYTE, ( BYTE ) lNumber, HB_COMP_PARAM ); } else if( HB_LIM_INT16( lNumber ) ) { diff --git a/harbour/src/vm/memvars.c b/harbour/src/vm/memvars.c index f15a8e58fa..3de2658a2d 100644 --- a/harbour/src/vm/memvars.c +++ b/harbour/src/vm/memvars.c @@ -100,7 +100,7 @@ struct mv_memvarArray_info int iScope; }; -static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITEM pValue ); +static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, int iScope, PHB_ITEM pValue ); static PHB_ITEM hb_memvarValueNew( void ) { @@ -623,18 +623,18 @@ char * hb_memvarGetStrValuePtr( char * szVarName, ULONG *pulLen ) * pMemvar - an item that stores the name of variable - it can be either * the HB_IT_SYMBOL (if created by PUBLIC statement) or HB_IT_STRING * (if created by direct call to __MVPUBLIC function) - * bScope - the scope of created variable - if a variable with the same name + * iScope - the scope of created variable - if a variable with the same name * exists already then it's value is hidden by new variable with * passed scope * pValue - optional item used to initialize the value of created variable * or NULL * */ -void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue ) +void hb_memvarCreateFromItem( PHB_ITEM pMemvar, int iScope, PHB_ITEM pValue ) { PHB_DYNS pDynVar = NULL; - HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromItem(%p, %d, %p)", pMemvar, bScope, pValue)); + HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromItem(%p, %d, %p)", pMemvar, iScope, pValue)); /* find dynamic symbol or creeate one */ if( HB_IS_SYMBOL( pMemvar ) ) @@ -644,16 +644,16 @@ void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue ) pDynVar = hb_dynsymGet( pMemvar->item.asString.value ); if( pDynVar ) - hb_memvarCreateFromDynSymbol( pDynVar, bScope, pValue ); + hb_memvarCreateFromDynSymbol( pDynVar, iScope, pValue ); else hb_errRT_BASE( EG_ARG, 3008, NULL, "&", HB_ERR_ARGS_BASEPARAMS ); } -static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITEM pValue ) +static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, int iScope, PHB_ITEM pValue ) { - HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromDynSymbol(%p, %d, %p)", pDynVar, bScope, pValue)); + HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromDynSymbol(%p, %d, %p)", pDynVar, iScope, pValue)); - if( bScope & VS_PUBLIC ) + if( iScope & VS_PUBLIC ) { /* If the variable with the same name exists already * then the current value have to be unchanged