From d4f042a2a5b29c4eceb416e28a421b11db428fc6 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 27 Feb 2007 11:03:59 +0000 Subject: [PATCH] 2007-02-27 12:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbcomp.h * harbour/include/hbexpra.c * harbour/include/hbexprb.c * harbour/include/hbexprc.c * harbour/include/hbmacro.h * harbour/include/hbpcode.h * harbour/include/hbxvm.h * harbour/source/common/hbdate.c * harbour/source/compiler/genc.c * harbour/source/compiler/gencc.c * harbour/source/compiler/harbour.c * harbour/source/compiler/harbour.y * harbour/source/compiler/harbour.yyc * harbour/source/compiler/hbdead.c * harbour/source/compiler/hbfix.c * harbour/source/compiler/hblbl.c * harbour/source/compiler/hbopt.c * harbour/source/compiler/hbpcode.c * harbour/source/compiler/hbstripl.c * harbour/source/rtl/abs.c * harbour/source/rtl/at.c * harbour/source/rtl/chrasc.c * harbour/source/rtl/datec.c * harbour/source/rtl/dateshb.c * harbour/source/rtl/diskspac.c * harbour/source/rtl/disksphb.c * harbour/source/rtl/gtfunc.c * harbour/source/rtl/left.c * harbour/source/rtl/len.c * harbour/source/rtl/math.c * harbour/source/rtl/minmax.c * harbour/source/rtl/mod.c * harbour/source/rtl/philes.c * harbour/source/rtl/philesx.c * harbour/source/rtl/replic.c * harbour/source/rtl/round.c * harbour/source/rtl/set.c * harbour/source/rtl/space.c * harbour/source/rtl/strcase.c * harbour/source/rtl/strpeek.c * harbour/source/rtl/transfrm.c * harbour/source/rtl/trim.c * harbour/source/rtl/type.c * harbour/source/rtl/val.c * harbour/source/rtl/word.c * harbour/source/vm/hvm.c * harbour/source/vm/macro.c * added some PCODEs to cover all possible combination of ++, --, = operations in the same way and keep Clipper compatible RT errors. * added some other PCODEs to optimize some commonly used expressions/ statements * use HB_ERR_ARGS_BASEPARAMS instead of hb_paramError() * some other cleanups and minor optimizations * harbour/utils/hbtest/rt_math.prg * update expected result for MOD() - it was not Clipper compatible and it will be hard to make it compatible without introducing some Clipper's side effects --- harbour/ChangeLog | 59 ++++ harbour/include/hbcomp.h | 1 + harbour/include/hbexpra.c | 34 +-- harbour/include/hbexprb.c | 63 +++-- harbour/include/hbexprc.c | 146 ++++++---- harbour/include/hbmacro.h | 2 + harbour/include/hbpcode.h | 10 +- harbour/include/hbxvm.h | 7 + harbour/source/common/hbdate.c | 2 +- harbour/source/compiler/genc.c | 102 ++++++- harbour/source/compiler/gencc.c | 89 +++++- harbour/source/compiler/harbour.c | 33 ++- harbour/source/compiler/harbour.y | 3 +- harbour/source/compiler/harbour.yyc | 3 +- harbour/source/compiler/hbdead.c | 10 +- harbour/source/compiler/hbfix.c | 10 +- harbour/source/compiler/hblbl.c | 10 +- harbour/source/compiler/hbopt.c | 10 +- harbour/source/compiler/hbpcode.c | 20 +- harbour/source/compiler/hbstripl.c | 10 +- harbour/source/rtl/abs.c | 2 +- harbour/source/rtl/at.c | 4 +- harbour/source/rtl/chrasc.c | 22 +- harbour/source/rtl/datec.c | 4 +- harbour/source/rtl/dateshb.c | 14 +- harbour/source/rtl/diskspac.c | 2 +- harbour/source/rtl/disksphb.c | 4 +- harbour/source/rtl/gtfunc.c | 2 +- harbour/source/rtl/left.c | 2 +- harbour/source/rtl/len.c | 2 +- harbour/source/rtl/math.c | 6 +- harbour/source/rtl/minmax.c | 4 +- harbour/source/rtl/mod.c | 4 +- harbour/source/rtl/philes.c | 2 +- harbour/source/rtl/philesx.c | 2 +- harbour/source/rtl/replic.c | 4 +- harbour/source/rtl/round.c | 4 +- harbour/source/rtl/set.c | 30 +- harbour/source/rtl/space.c | 2 +- harbour/source/rtl/strcase.c | 4 +- harbour/source/rtl/strpeek.c | 4 +- harbour/source/rtl/transfrm.c | 2 +- harbour/source/rtl/trim.c | 6 +- harbour/source/rtl/type.c | 2 +- harbour/source/rtl/val.c | 2 +- harbour/source/rtl/word.c | 2 +- harbour/source/vm/hvm.c | 416 +++++++++++++++++++--------- harbour/source/vm/macro.c | 9 +- harbour/utils/hbtest/rt_math.prg | 2 +- 49 files changed, 865 insertions(+), 324 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0a593c5509..7442823446 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,65 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-02-27 12:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbcomp.h + * harbour/include/hbexpra.c + * harbour/include/hbexprb.c + * harbour/include/hbexprc.c + * harbour/include/hbmacro.h + * harbour/include/hbpcode.h + * harbour/include/hbxvm.h + * harbour/source/common/hbdate.c + * harbour/source/compiler/genc.c + * harbour/source/compiler/gencc.c + * harbour/source/compiler/harbour.c + * harbour/source/compiler/harbour.y + * harbour/source/compiler/harbour.yyc + * harbour/source/compiler/hbdead.c + * harbour/source/compiler/hbfix.c + * harbour/source/compiler/hblbl.c + * harbour/source/compiler/hbopt.c + * harbour/source/compiler/hbpcode.c + * harbour/source/compiler/hbstripl.c + * harbour/source/rtl/abs.c + * harbour/source/rtl/at.c + * harbour/source/rtl/chrasc.c + * harbour/source/rtl/datec.c + * harbour/source/rtl/dateshb.c + * harbour/source/rtl/diskspac.c + * harbour/source/rtl/disksphb.c + * harbour/source/rtl/gtfunc.c + * harbour/source/rtl/left.c + * harbour/source/rtl/len.c + * harbour/source/rtl/math.c + * harbour/source/rtl/minmax.c + * harbour/source/rtl/mod.c + * harbour/source/rtl/philes.c + * harbour/source/rtl/philesx.c + * harbour/source/rtl/replic.c + * harbour/source/rtl/round.c + * harbour/source/rtl/set.c + * harbour/source/rtl/space.c + * harbour/source/rtl/strcase.c + * harbour/source/rtl/strpeek.c + * harbour/source/rtl/transfrm.c + * harbour/source/rtl/trim.c + * harbour/source/rtl/type.c + * harbour/source/rtl/val.c + * harbour/source/rtl/word.c + * harbour/source/vm/hvm.c + * harbour/source/vm/macro.c + * added some PCODEs to cover all possible combination of ++, --, = + operations in the same way and keep Clipper compatible RT errors. + * added some other PCODEs to optimize some commonly used expressions/ + statements + * use HB_ERR_ARGS_BASEPARAMS instead of hb_paramError() + * some other cleanups and minor optimizations + * harbour/utils/hbtest/rt_math.prg + * update expected result for MOD() - it was not Clipper compatible and + it will be hard to make it compatible without introducing some Clipper's + side effects + 2007-02-25 19:25 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/expropt2.c % strip nested parenthesis in expressions like: ((())) diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 4fb6f79c44..dcd61160b3 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -203,6 +203,7 @@ extern void hb_compGenMessageData( char * szMsg, BOOL bIsObject, HB_COMP_DECL ); extern void hb_compGenPopVar( char * szVarName, HB_COMP_DECL ); /* generates the pcode to pop a value from the virtual machine stack onto a variable */ extern void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ); /* Pushes a number on the virtual machine stack */ extern void hb_compGenPushFunCall( char *, HB_COMP_DECL ); /* generates the pcode to push function's call */ +extern void hb_compGenPushFunSym( char *, HB_COMP_DECL ); /* generates the pcode to push function's symbol */ extern void hb_compGenPushFunRef( char *, HB_COMP_DECL ); /* generates the pcode to push function's reference symbol */ extern void hb_compGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ); /* generates the pcode to push a variable value to the virtual machine stack */ extern void hb_compGenPushVarRef( char * szVarName, HB_COMP_DECL ); /* generates the pcode to push a variable by reference to the virtual machine stack */ diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index aa4409fd94..aaa7a22f33 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -794,22 +794,9 @@ HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR pExpr, HB_EXPR_PTR pItem, HB_COMP * precedence rules */ BYTE ucLeft = s_PrecedTable[ pExpr->ExprType ]; - if( ucLeft >= ucRight ) - { - /* Left operator has the same or lower precedence then the right one - * e.g. a * b + c - * pItem -> b + c -> L=b R=c O=+ - * pExpr -> a * -> l=a r= o=* - * - * -> (a * b) + c -> Lelf=(a * b) Right=c Oper=+ - * Left := l (o) L - * Right := R - * Oper := O - */ - pItem->value.asOperator.pLeft = hb_compExprSetOperand( pExpr, pItem->value.asOperator.pLeft, HB_COMP_PARAM ); - pExpr = pItem; - } - else + if( ucLeft < ucRight || + ( ucLeft == ucRight && HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) && + ( ucLeft == HB_EO_OR || ucLeft == HB_EO_AND ) ) ) { /* Left operator has a lower precedence then the right one * e.g. a + b * c @@ -823,6 +810,21 @@ HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR pExpr, HB_EXPR_PTR pItem, HB_COMP */ pExpr->value.asOperator.pRight = pItem; } + else + { + /* Left operator has the same or higer precedence then the right one + * e.g. a * b + c + * pItem -> b + c -> L=b R=c O=+ + * pExpr -> a * -> l=a r= o=* + * + * -> (a * b) + c -> Lelf=(a * b) Right=c Oper=+ + * Left := l (o) L + * Right := R + * Oper := O + */ + pItem->value.asOperator.pLeft = hb_compExprSetOperand( pExpr, pItem->value.asOperator.pLeft, HB_COMP_PARAM ); + pExpr = pItem; + } } return pExpr; diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 304b560c62..78209fea38 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1599,8 +1599,15 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) BOOL fArgsList = FALSE; USHORT usCount = 0; - HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME ) + { + hb_compGenPushFunCall( pSelf->value.asFunCall.pFunName->value.asSymbol, HB_COMP_PARAM ); + } + else + { + HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); + HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + } /* NOTE: pParms will be NULL in 'DO procname' (if there is * no WITH keyword) @@ -1634,8 +1641,15 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) BOOL fArgsList = FALSE; USHORT usCount = 0; - HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME ) + { + hb_compGenPushFunCall( pSelf->value.asFunCall.pFunName->value.asSymbol, HB_COMP_PARAM ); + } + else + { + HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); + HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + } if( pSelf->value.asFunCall.pParms ) { @@ -1919,7 +1933,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunName ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPushFunCall, pSelf->value.asSymbol ); + HB_EXPR_PCODE1( hb_compGenPushFunSym, pSelf->value.asSymbol ); break; case HB_EA_POP_PCODE: @@ -2549,7 +2563,7 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) break; case HB_EA_PUSH_POP: - if( HB_SUPPORT_HARBOUR && HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) ) + if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) ) { LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); @@ -2624,7 +2638,7 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) break; case HB_EA_PUSH_POP: - if( HB_SUPPORT_HARBOUR && HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) ) + if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) ) { LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); @@ -2658,22 +2672,31 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) switch( iMessage ) { case HB_EA_REDUCE: + { + HB_EXPR_PTR pExpr; + + pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pExpr = pSelf->value.asOperator.pLeft; + + if( pExpr->ExprType == HB_ET_LOGICAL ) { - HB_EXPR_PTR pExpr; - - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pExpr = pSelf->value.asOperator.pLeft; - - 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_EXPR_PCODE1( hb_compExprDelete, pSelf ); - pSelf = pExpr; - } + pExpr->value.asLogical = ! pExpr->value.asLogical; + pSelf->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */ + HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + pSelf = pExpr; + } + else if( pExpr->ExprType == HB_EO_NOT && HB_SUPPORT_HARBOUR ) + { + /* NOTE: This will not generate a runtime error if incompatible + * data type is used + */ + pExpr->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */ + pExpr = pExpr->value.asOperator.pLeft; + HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + pSelf = pExpr; } break; - + } case HB_EA_ARRAY_AT: hb_compErrorType( HB_COMP_PARAM, pSelf ); break; diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index e1df813c9e..9e8e0fc92b 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -556,15 +556,8 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) { hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); - /* increase/decrease operation, leave unreferenced value on stack */ - /* We have to unreference the item on the stack, because we do not have - such PCODE(s) then I'll trnaslate HB_P_INC/HB_P_DEC into - HB_P_[PLUS|MINUS]EQ, Maybe in the future we will make it - in differ way [druzus] */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); } #endif else @@ -586,9 +579,7 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; /* increase/decrease operation, leave unreferenced value on stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); return; } #ifdef HB_USE_ARRAYAT_REF @@ -602,30 +593,41 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; /* increase/decrease operation, leave unreferenced value on stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); return; } #endif #if !defined( HB_MACRO_SUPPORT ) else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) { - if( hb_compVariableScope( HB_COMP_PARAM, - pSelf->value.asOperator.pLeft->value.asSymbol ) == HB_VS_LOCAL_VAR ) - { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ), - iValue = ( bOper == HB_P_INC ) ? 1 : -1; - BYTE buffer[ 5 ]; + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - buffer[ 0 ] = HB_P_LOCALADDINT; - buffer[ 1 ] = HB_LOBYTE( iLocal ); - buffer[ 2 ] = HB_HIBYTE( iLocal ); - buffer[ 3 ] = HB_LOBYTE( iValue ); - buffer[ 4 ] = HB_HIBYTE( iValue ); - hb_compGenPCodeN( buffer, 5, HB_COMP_PARAM ); - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + if( bOper == HB_P_INC ) + { + hb_compGenPCode3( HB_P_LOCALINCPUSH, HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); + } + else + { + hb_compGenPCode3( HB_P_LOCALDEC, HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + } + } + else + { + /* NOTE: direct type change */ + HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + } return; } } @@ -665,9 +667,7 @@ void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) */ HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); /* increment/decrement the value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); } #endif else @@ -693,9 +693,7 @@ void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) */ HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); /* increase/decrease operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); return; } #ifdef HB_USE_ARRAYAT_REF @@ -713,31 +711,37 @@ void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) */ HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); /* increase/decrease operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); return; } #endif #if !defined( HB_MACRO_SUPPORT ) else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) { - if( hb_compVariableScope( HB_COMP_PARAM, - pSelf->value.asOperator.pLeft->value.asSymbol ) == HB_VS_LOCAL_VAR ) + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ), - iValue = ( bOper == HB_P_INC ) ? 1 : -1; - BYTE buffer[ 5 ]; + if( iScope == HB_VS_LOCAL_VAR ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - - buffer[ 0 ] = HB_P_LOCALADDINT; - buffer[ 1 ] = HB_LOBYTE( iLocal ); - buffer[ 2 ] = HB_HIBYTE( iLocal ); - buffer[ 3 ] = HB_LOBYTE( iValue ); - buffer[ 4 ] = HB_HIBYTE( iValue ); - hb_compGenPCodeN( buffer, 5, HB_COMP_PARAM ); + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + hb_compGenPCode3( ( bOper == HB_P_INC ) ? HB_P_LOCALINC : HB_P_LOCALDEC, + HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); + } + else + { + /* NOTE: direct type change */ + HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + } return; } } @@ -774,9 +778,7 @@ void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); /* increment/decrement the value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); } #endif else @@ -800,9 +802,7 @@ void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; /* increase/decrease operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); return; } #ifdef HB_USE_ARRAYAT_REF @@ -815,11 +815,37 @@ void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; /* increase/decrease operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE ); - bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP; - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); return; } +#endif +#if !defined( HB_MACRO_SUPPORT ) + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) + { + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + hb_compGenPCode3( ( bOper == HB_P_INC ) ? HB_P_LOCALINC : HB_P_LOCALDEC, + HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); + } + else + { + /* NOTE: direct type change */ + HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + } + return; + } + } #endif } diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index d0e067df61..dd4c68e5d7 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -144,6 +144,8 @@ extern void hb_compGenPushAliasedVar( char * szVarName, extern void hb_compGenPushLogical( int iTrueFalse, HB_COMP_DECL ); extern void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ); extern void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ); +extern void hb_compGenPushFunSym( char * szFunName, HB_COMP_DECL ); +extern void hb_compGenPushFunRef( char * szFunName, HB_COMP_DECL ); extern void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_COMP_DECL ); extern void hb_compCodeBlockStart( HB_COMP_DECL ); extern void hb_compCodeBlockEnd( HB_COMP_DECL ); diff --git a/harbour/include/hbpcode.h b/harbour/include/hbpcode.h index 16a2471077..ecf030928d 100644 --- a/harbour/include/hbpcode.h +++ b/harbour/include/hbpcode.h @@ -240,7 +240,15 @@ typedef enum HB_P_SEQALWAYS, /* 166 set BEGIN SEQUENCE/ALWAYS section */ HB_P_ALWAYSBEGIN, /* 167 start ALWAYS section */ HB_P_ALWAYSEND, /* 168 finish ALWAYS section */ - HB_P_LAST_PCODE /* 169 this defines the number of defined pcodes */ + HB_P_DECEQPOP, /* 169 decrements the var reference */ + HB_P_INCEQPOP, /* 170 increments the var reference */ + HB_P_DECEQ, /* 171 decrements the var reference, leave result on the stack */ + HB_P_INCEQ, /* 172 increments the var reference, leave result on the stack */ + HB_P_LOCALDEC, /* 173 decrements the local variable */ + HB_P_LOCALINC, /* 174 increments the local variable */ + HB_P_LOCALINCPUSH, /* 175 increments the local variable, push result on the stack */ + HB_P_PUSHFUNCSYM, /* 176 places a symbol on the virtual machine stack */ + HB_P_LAST_PCODE /* 177 this defines the number of defined pcodes */ } HB_PCODE; #endif /* HB_PCODE_H_ */ diff --git a/harbour/include/hbxvm.h b/harbour/include/hbxvm.h index 6a9ddc2aff..83919fc2a9 100644 --- a/harbour/include/hbxvm.h +++ b/harbour/include/hbxvm.h @@ -131,6 +131,9 @@ extern HB_EXPORT BOOL hb_xvmPopAlias( void ); /* select the extern HB_EXPORT BOOL hb_xvmPopLogical( BOOL * ); /* pops the stack latest value and returns its logical value */ extern HB_EXPORT BOOL hb_xvmSwapAlias( void ); /* swaps items on the eval stack and pops the workarea number */ extern HB_EXPORT BOOL hb_xvmLocalAddInt( int iLocal, LONG lAdd ); /* add integer to given local variable */ +extern HB_EXPORT BOOL hb_xvmLocalInc( int iLocal ); /* increment given local variable */ +extern HB_EXPORT BOOL hb_xvmLocalDec( int iLocal ); /* decrement given local variable */ +extern HB_EXPORT BOOL hb_xvmLocalIncPush( int iLocal ); /* increment given local variable and pussh it on HVM stack */ extern HB_EXPORT BOOL hb_xvmAnd( void ); extern HB_EXPORT BOOL hb_xvmOr( void ); @@ -170,7 +173,11 @@ extern HB_EXPORT BOOL hb_xvmPower( void ); extern HB_EXPORT BOOL hb_xvmExpEq( void ); extern HB_EXPORT BOOL hb_xvmExpEqPop( void ); extern HB_EXPORT BOOL hb_xvmInc( void ); +extern HB_EXPORT BOOL hb_xvmIncEq( void ); +extern HB_EXPORT BOOL hb_xvmIncEqPop( void ); extern HB_EXPORT BOOL hb_xvmDec( void ); +extern HB_EXPORT BOOL hb_xvmDecEq( void ); +extern HB_EXPORT BOOL hb_xvmDecEqPop( void ); extern HB_EXPORT void hb_xvmArrayDim( USHORT uiDimensions ); /* generates an uiDimensions Array and initialize those dimensions from the stack values */ extern HB_EXPORT void hb_xvmArrayGen( ULONG ulElements ); /* generates an ulElements Array and fills it from the stack values */ diff --git a/harbour/source/common/hbdate.c b/harbour/source/common/hbdate.c index 8c48a52cf7..b74d877bfa 100644 --- a/harbour/source/common/hbdate.c +++ b/harbour/source/common/hbdate.c @@ -93,7 +93,7 @@ HB_EXPORT LONG hb_dateEncode( int iYear, int iMonth, int iDay ) { /* Month, year, and lower day limits are simple, but upper day limit is dependent upon month and leap year */ - static int auiDayLimit[ 12 ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + static const int auiDayLimit[ 12 ] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if( iDay <= auiDayLimit[ iMonth - 1 ] || ( iDay == 29 && iMonth == 2 && diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 8238c348e6..1856cf2132 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -1736,6 +1736,17 @@ static HB_GENC_FUNC( hb_p_pushsymnear ) return 2; } +static HB_GENC_FUNC( hb_p_pushfuncsym ) +{ + fprintf( cargo->yyc, "\tHB_P_PUSHFUNCSYM, %i, %i,", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ] ); + if( cargo->bVerbose ) + fprintf( cargo->yyc, "\t/* %s */", hb_compSymbolGetPos( cargo->HB_COMP_PARAM, HB_PCODE_MKUSHORT( &( pFunc->pCode[ lPCodePos + 1 ] ) ) )->szName ); + fprintf( cargo->yyc, "\n" ); + return 3; +} + static HB_GENC_FUNC( hb_p_pushvariable ) { fprintf( cargo->yyc, "\tHB_P_PUSHVARIABLE, %i, %i,", @@ -2076,6 +2087,51 @@ static HB_GENC_FUNC( hb_p_localaddint ) return 5; } +static HB_GENC_FUNC( hb_p_localinc ) +{ + fprintf( cargo->yyc, "\tHB_P_LOCALINC, %i, %i,", pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ] ); + + if( cargo->bVerbose ) + { + fprintf( cargo->yyc, "\t/* %s*/", hb_compLocalVariableFind( pFunc, HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) )->szName ); + } + + fprintf( cargo->yyc, "\n" ); + + return 3; +} + +static HB_GENC_FUNC( hb_p_localdec ) +{ + fprintf( cargo->yyc, "\tHB_P_LOCALDEC, %i, %i,", pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ] ); + + if( cargo->bVerbose ) + { + fprintf( cargo->yyc, "\t/* %s*/", hb_compLocalVariableFind( pFunc, HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) )->szName ); + } + + fprintf( cargo->yyc, "\n" ); + + return 3; +} + +static HB_GENC_FUNC( hb_p_localincpush ) +{ + fprintf( cargo->yyc, "\tHB_P_LOCALINCPUSH, %i, %i,", pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ] ); + + if( cargo->bVerbose ) + { + fprintf( cargo->yyc, "\t/* %s*/", hb_compLocalVariableFind( pFunc, HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) )->szName ); + } + + fprintf( cargo->yyc, "\n" ); + + return 3; +} + static HB_GENC_FUNC( hb_p_pluseqpop ) { HB_SYMBOL_UNUSED( pFunc ); @@ -2130,6 +2186,24 @@ static HB_GENC_FUNC( hb_p_expeqpop ) return 1; } +static HB_GENC_FUNC( hb_p_inceqpop ) +{ + HB_SYMBOL_UNUSED( pFunc ); + HB_SYMBOL_UNUSED( lPCodePos ); + + fprintf( cargo->yyc, "\tHB_P_INCEQPOP,\n" ); + return 1; +} + +static HB_GENC_FUNC( hb_p_deceqpop ) +{ + HB_SYMBOL_UNUSED( pFunc ); + HB_SYMBOL_UNUSED( lPCodePos ); + + fprintf( cargo->yyc, "\tHB_P_DECEQPOP,\n" ); + return 1; +} + static HB_GENC_FUNC( hb_p_pluseq ) { HB_SYMBOL_UNUSED( pFunc ); @@ -2184,6 +2258,24 @@ static HB_GENC_FUNC( hb_p_expeq ) return 1; } +static HB_GENC_FUNC( hb_p_inceq ) +{ + HB_SYMBOL_UNUSED( pFunc ); + HB_SYMBOL_UNUSED( lPCodePos ); + + fprintf( cargo->yyc, "\tHB_P_INCEQ,\n" ); + return 1; +} + +static HB_GENC_FUNC( hb_p_deceq ) +{ + HB_SYMBOL_UNUSED( pFunc ); + HB_SYMBOL_UNUSED( lPCodePos ); + + fprintf( cargo->yyc, "\tHB_P_DECEQ,\n" ); + return 1; +} + static HB_GENC_FUNC( hb_p_withobjectstart ) { HB_SYMBOL_UNUSED( pFunc ); @@ -2430,7 +2522,15 @@ static HB_GENC_FUNC_PTR s_verbose_table[] = { hb_p_pushunref, hb_p_seqalways, hb_p_alwaysbegin, - hb_p_alwaysend + hb_p_alwaysend, + hb_p_deceqpop, + hb_p_inceqpop, + hb_p_deceq, + hb_p_inceq, + hb_p_localdec, + hb_p_localinc, + hb_p_localincpush, + hb_p_pushfuncsym }; static void hb_compGenCReadable( HB_COMP_DECL, PFUNCTION pFunc, FILE * yyc ) diff --git a/harbour/source/compiler/gencc.c b/harbour/source/compiler/gencc.c index 058c1c1b1f..bb5110b20a 100644 --- a/harbour/source/compiler/gencc.c +++ b/harbour/source/compiler/gencc.c @@ -1324,6 +1324,15 @@ static HB_GENC_FUNC( hb_p_pushsymnear ) return 2; } +static HB_GENC_FUNC( hb_p_pushfuncsym ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\thb_xvmPushFuncSymbol( symbols + %hu );\n", + HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) ); + return 3; +} + static HB_GENC_FUNC( hb_p_pushvariable ) { HB_GENC_LABEL(); @@ -1636,6 +1645,44 @@ static HB_GENC_FUNC( hb_p_localaddint ) return 5; } +static HB_GENC_FUNC( hb_p_localinc ) +{ + int iLocal = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ); + HB_GENC_LABEL(); + + if( HB_GENC_GETLABEL( lPCodePos + 3 ) == 0 && + ( ( pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHLOCAL && + iLocal == HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 4 ] ) ) || + ( pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHLOCALNEAR && + iLocal == pFunc->pCode[ lPCodePos + 4 ] ) ) ) + { + fprintf( cargo->yyc, "\tif( hb_xvmLocalIncPush( %d ) ) break;\n", iLocal ); + return ( pFunc->pCode[ lPCodePos + 3 ] == HB_P_PUSHLOCAL ) ? 6 : 5; + } + + fprintf( cargo->yyc, "\tif( hb_xvmLocalInc( %d ) ) break;\n", iLocal ); + return 3; +} + +static HB_GENC_FUNC( hb_p_localdec ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\tif( hb_xvmLocalDec( %d ) ) break;\n", + HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) ); + return 3; +} + +static HB_GENC_FUNC( hb_p_localincpush ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\tif( hb_xvmLocalIncPush( %d ) ) break;\n", + HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) ); + + return 3; +} + static HB_GENC_FUNC( hb_p_pluseqpop ) { HB_GENC_LABEL(); @@ -1684,6 +1731,22 @@ static HB_GENC_FUNC( hb_p_expeqpop ) return 1; } +static HB_GENC_FUNC( hb_p_deceqpop ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\tif( hb_xvmDecEqPop() ) break;\n" ); + return 1; +} + +static HB_GENC_FUNC( hb_p_inceqpop ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\tif( hb_xvmIncEqPop() ) break;\n" ); + return 1; +} + static HB_GENC_FUNC( hb_p_pluseq ) { HB_GENC_LABEL(); @@ -1732,6 +1795,22 @@ static HB_GENC_FUNC( hb_p_expeq ) return 1; } +static HB_GENC_FUNC( hb_p_deceq ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\tif( hb_xvmDecEq() ) break;\n" ); + return 1; +} + +static HB_GENC_FUNC( hb_p_inceq ) +{ + HB_GENC_LABEL(); + + fprintf( cargo->yyc, "\tif( hb_xvmIncEq() ) break;\n" ); + return 1; +} + static HB_GENC_FUNC( hb_p_withobjectstart ) { HB_GENC_LABEL(); @@ -1977,7 +2056,15 @@ static HB_GENC_FUNC_PTR s_verbose_table[] = { hb_p_pushunref, hb_p_seqalways, hb_p_alwaysbegin, - hb_p_alwaysend + hb_p_alwaysend, + hb_p_deceqpop, + hb_p_inceqpop, + hb_p_deceq, + hb_p_inceq, + hb_p_localdec, + hb_p_localinc, + hb_p_localincpush, + hb_p_pushfuncsym }; void hb_compGenCRealCode( HB_COMP_DECL, PFUNCTION pFunc, FILE * yyc ) diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index b14967c87b..4553d14e52 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -1938,9 +1938,9 @@ void hb_compFunctionAdd( HB_COMP_DECL, char * szFunName, HB_SYMBOLSCOPE cScope, hb_compGenPCode3( HB_P_SFRAME, 0, 0, HB_COMP_PARAM ); /* frame for statics variables */ if( HB_COMP_PARAM->fDebugInfo ) - { hb_compGenModuleName( HB_COMP_PARAM, szFunName ); - } + else + HB_COMP_PARAM->lastLine = -1; } PINLINE hb_compInlineAdd( HB_COMP_DECL, char * szFunName, int iLine ) @@ -3310,6 +3310,35 @@ void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL } void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ) +{ + char * szFunction; + PCOMSYMBOL pSym; + USHORT wSym; + + /* if abbreviated function name was used - change it for whole name */ + szFunction = hb_compReservedName( szFunName ); + if( szFunction ) + szFunName = szFunction; + + if( ( pSym = hb_compSymbolFind( HB_COMP_PARAM, szFunName, &wSym, TRUE ) ) != NULL ) + { + if( ! hb_compFunCallFind( HB_COMP_PARAM, szFunName ) ) + hb_compFunCallAdd( HB_COMP_PARAM, szFunName ); + } + else + { + pSym = hb_compSymbolAdd( HB_COMP_PARAM, szFunName, &wSym, TRUE ); + if( pSym ) + { + /* reset symbol scope because the real scope is unknown now */ + pSym->cScope = 0; + } + hb_compFunCallAdd( HB_COMP_PARAM, szFunName ); + } + hb_compGenPCode3( HB_P_PUSHFUNCSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ), HB_COMP_PARAM ); +} + +void hb_compGenPushFunSym( char * szFunName, HB_COMP_DECL ) { char * szFunction; diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 4ae79f65eb..8abb2f3410 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -2140,8 +2140,7 @@ static void hb_compRTVariableGen( HB_COMP_DECL, char * szCreateFun ) HB_RTVAR_PTR pDel; /* generate the function call frame */ - hb_compGenPushSymbol( szCreateFun, TRUE, FALSE, HB_COMP_PARAM ); - hb_compGenPushNil( HB_COMP_PARAM ); + hb_compGenPushFunCall( szCreateFun, HB_COMP_PARAM ); /* push variable names to create */ while( pVar->pNext ) diff --git a/harbour/source/compiler/harbour.yyc b/harbour/source/compiler/harbour.yyc index 8f03519485..388a006cf2 100644 --- a/harbour/source/compiler/harbour.yyc +++ b/harbour/source/compiler/harbour.yyc @@ -7300,8 +7300,7 @@ static void hb_compRTVariableGen( HB_COMP_DECL, char * szCreateFun ) HB_RTVAR_PTR pDel; /* generate the function call frame */ - hb_compGenPushSymbol( szCreateFun, TRUE, FALSE, HB_COMP_PARAM ); - hb_compGenPushNil( HB_COMP_PARAM ); + hb_compGenPushFunCall( szCreateFun, HB_COMP_PARAM ); /* push variable names to create */ while( pVar->pNext ) diff --git a/harbour/source/compiler/hbdead.c b/harbour/source/compiler/hbdead.c index 3521ba2705..197cd9dcce 100644 --- a/harbour/source/compiler/hbdead.c +++ b/harbour/source/compiler/hbdead.c @@ -526,7 +526,15 @@ static PHB_CODETRACE_FUNC s_codeTraceFuncTable[ HB_P_LAST_PCODE ] = hb_p_default, /* HB_P_PUSHUNREF */ hb_p_seqalways, /* HB_P_SEQALWAYS */ hb_p_alwaysbegin, /* HB_P_ALWAYSBEGIN */ - hb_p_default /* HB_P_ALWAYSEND */ + hb_p_default, /* HB_P_ALWAYSEND */ + hb_p_default, /* HB_P_DECEQPOP */ + hb_p_default, /* HB_P_INCEQPOP */ + hb_p_default, /* HB_P_DECEQ */ + hb_p_default, /* HB_P_INCEQ */ + hb_p_default, /* HB_P_LOCALDEC */ + hb_p_default, /* HB_P_LOCALINC */ + hb_p_default, /* HB_P_LOCALINCPUSH */ + hb_p_default /* HB_P_PUSHFUNCSYM */ }; void hb_compCodeTraceMarkDead( HB_COMP_DECL, PFUNCTION pFunc ) diff --git a/harbour/source/compiler/hbfix.c b/harbour/source/compiler/hbfix.c index effdd3f810..dd8286a3db 100644 --- a/harbour/source/compiler/hbfix.c +++ b/harbour/source/compiler/hbfix.c @@ -388,7 +388,15 @@ static HB_FIX_FUNC_PTR s_fixlocals_table[] = NULL, /* HB_P_PUSHUNREF */ NULL, /* HB_P_SEQALWAYS */ NULL, /* HB_P_ALWAYSBEGIN */ - NULL /* HB_P_ALWAYSEND */ + NULL, /* HB_P_ALWAYSEND */ + NULL, /* HB_P_DECEQPOP */ + NULL, /* HB_P_INCEQPOP */ + NULL, /* HB_P_DECEQ */ + NULL, /* HB_P_INCEQ */ + NULL, /* HB_P_LOCALDEC */ + NULL, /* HB_P_LOCALINC */ + NULL, /* HB_P_LOCALINCPUSH */ + NULL /* HB_P_PUSHFUNCSYM */ }; void hb_compFixFuncPCode( HB_COMP_DECL, PFUNCTION pFunc ) diff --git a/harbour/source/compiler/hblbl.c b/harbour/source/compiler/hblbl.c index 6355008c30..45db67f317 100644 --- a/harbour/source/compiler/hblbl.c +++ b/harbour/source/compiler/hblbl.c @@ -362,7 +362,15 @@ static PHB_LABEL_FUNC s_GenLabelFuncTable[ HB_P_LAST_PCODE ] = NULL, /* HB_P_PUSHUNREF */ hb_p_seqalways, /* HB_P_SEQALWAYS */ hb_p_alwaysbegin, /* HB_P_ALWAYSBEGIN */ - NULL /* HB_P_ALWAYSEND */ + NULL, /* HB_P_ALWAYSEND */ + NULL, /* HB_P_DECEQPOP */ + NULL, /* HB_P_INCEQPOP */ + NULL, /* HB_P_DECEQ */ + NULL, /* HB_P_INCEQ */ + NULL, /* HB_P_LOCALDEC */ + NULL, /* HB_P_LOCALINC */ + NULL, /* HB_P_LOCALINCPUSH */ + NULL /* HB_P_PUSHFUNCSYM */ }; void hb_compGenLabelTable( PFUNCTION pFunc, PHB_LABEL_INFO label_info ) diff --git a/harbour/source/compiler/hbopt.c b/harbour/source/compiler/hbopt.c index d6ccf602f2..03719c47a6 100644 --- a/harbour/source/compiler/hbopt.c +++ b/harbour/source/compiler/hbopt.c @@ -711,7 +711,15 @@ static HB_OPT_FUNC_PTR s_opt_table[] = NULL, /* HB_P_PUSHUNREF */ NULL, /* HB_P_SEQALWAYS */ NULL, /* HB_P_ALWAYSBEGIN */ - NULL /* HB_P_ALWAYSEND */ + NULL, /* HB_P_ALWAYSEND */ + NULL, /* HB_P_DECEQPOP */ + NULL, /* HB_P_INCEQPOP */ + NULL, /* HB_P_DECEQ */ + NULL, /* HB_P_INCEQ */ + NULL, /* HB_P_LOCALDEC */ + NULL, /* HB_P_LOCALINC */ + NULL, /* HB_P_LOCALINCPUSH */ + NULL /* HB_P_PUSHFUNCSYM */ }; void hb_compOptimizePCode( HB_COMP_DECL, PFUNCTION pFunc ) diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index 4e6d23ae15..e937efa08e 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -293,7 +293,15 @@ const BYTE hb_comp_pcode_len[] = { 1, /* HB_P_PUSHUNREF */ 4, /* HB_P_SEQALWAYS */ 4, /* HB_P_ALWAYSBEGIN */ - 1 /* HB_P_ALWAYSEND */ + 1, /* HB_P_ALWAYSEND */ + 1, /* HB_P_DECEQPOP */ + 1, /* HB_P_INCEQPOP */ + 1, /* HB_P_DECEQ */ + 1, /* HB_P_INCEQ */ + 3, /* HB_P_LOCALDEC */ + 3, /* HB_P_LOCALINC */ + 3, /* HB_P_LOCALINCPUSH */ + 3 /* HB_P_PUSHFUNCSYM */ }; /* @@ -473,7 +481,15 @@ static HB_PCODE_FUNC_PTR s_psize_table[] = NULL, /* HB_P_PUSHUNREF */ NULL, /* HB_P_SEQALWAYS */ NULL, /* HB_P_ALWAYSBEGIN */ - NULL /* HB_P_ALWAYSEND */ + NULL, /* HB_P_ALWAYSEND */ + NULL, /* HB_P_DECEQPOP */ + NULL, /* HB_P_INCEQPOP */ + NULL, /* HB_P_DECEQ */ + NULL, /* HB_P_INCEQ */ + NULL, /* HB_P_LOCALDEC */ + NULL, /* HB_P_LOCALINC */ + NULL, /* HB_P_LOCALINCPUSH */ + NULL /* HB_P_PUSHFUNCSYM */ }; LONG hb_compPCodeSize( PFUNCTION pFunc, ULONG ulOffset ) diff --git a/harbour/source/compiler/hbstripl.c b/harbour/source/compiler/hbstripl.c index e347df5f44..9ad0cba516 100644 --- a/harbour/source/compiler/hbstripl.c +++ b/harbour/source/compiler/hbstripl.c @@ -247,7 +247,15 @@ static PHB_STRIP_FUNC s_stripLines_table[] = NULL, /* HB_P_PUSHUNREF */ NULL, /* HB_P_SEQALWAYS */ NULL, /* HB_P_ALWAYSBEGIN */ - NULL /* HB_P_ALWAYSEND */ + NULL, /* HB_P_ALWAYSEND */ + NULL, /* HB_P_DECEQPOP */ + NULL, /* HB_P_INCEQPOP */ + NULL, /* HB_P_DECEQ */ + NULL, /* HB_P_INCEQ */ + NULL, /* HB_P_LOCALDEC */ + NULL, /* HB_P_LOCALINC */ + NULL, /* HB_P_LOCALINCPUSH */ + NULL /* HB_P_PUSHFUNCSYM */ }; void hb_compStripFuncLines( PFUNCTION pFunc ) diff --git a/harbour/source/rtl/abs.c b/harbour/source/rtl/abs.c index 125c15080d..6a86e3f44c 100644 --- a/harbour/source/rtl/abs.c +++ b/harbour/source/rtl/abs.c @@ -103,6 +103,6 @@ HB_FUNC( ABS ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, "ABS", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, "ABS", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/at.c b/harbour/source/rtl/at.c index 515fd05be3..86e0b4dfb9 100644 --- a/harbour/source/rtl/at.c +++ b/harbour/source/rtl/at.c @@ -69,7 +69,7 @@ HB_FUNC( AT ) hb_itemGetCPtr( pText ), hb_itemGetCLen( pText ) ) ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, "AT", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, "AT", HB_ERR_ARGS_BASEPARAMS ); } #else @@ -100,7 +100,7 @@ HB_FUNC( AT ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, "AT", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, "AT", HB_ERR_ARGS_BASEPARAMS ); } #endif diff --git a/harbour/source/rtl/chrasc.c b/harbour/source/rtl/chrasc.c index 244b34df50..2bdeb53204 100644 --- a/harbour/source/rtl/chrasc.c +++ b/harbour/source/rtl/chrasc.c @@ -61,36 +61,34 @@ HB_FUNC( CHR ) { if( ISNUM( 1 ) ) { - char szChar[ 2 ]; - /* NOTE: CA-Cl*pper's compiler optimizer will be wrong for those CHR() cases where the passed parameter is a constant which can be divided by 256 but it's not zero, in this case it will return an empty string instead of a Chr(0). [vszakats] */ /* Believe it or not, clipper does this! */ +#ifdef HB_C52_STRICT + char szChar[ 2 ]; szChar[ 0 ] = hb_parnl( 1 ) % 256; szChar[ 1 ] = '\0'; - hb_retclen( szChar, 1 ); +#else + hb_retclen( hb_szAscii[ hb_parni( 1 ) & 0xff ], 1 ); +#endif } else - hb_errRT_BASE_SubstR( EG_ARG, 1104, NULL, "CHR", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1104, NULL, "CHR", HB_ERR_ARGS_BASEPARAMS ); } /* converts a character value to an ASCII code */ HB_FUNC( ASC ) { - PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); + char * szValue = hb_parc( 1 ); - if( pText ) + if( szValue ) { - if( hb_itemGetCLen( pText ) > 0 ) - hb_retni( ( BYTE ) * ( hb_itemGetCPtr( pText ) ) ); - else - hb_retni( 0 ); + hb_retni( ( UCHAR ) szValue[ 0 ] ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1107, NULL, "ASC", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1107, NULL, "ASC", HB_ERR_ARGS_BASEPARAMS ); } - diff --git a/harbour/source/rtl/datec.c b/harbour/source/rtl/datec.c index ee66cbda95..73f336c5d7 100644 --- a/harbour/source/rtl/datec.c +++ b/harbour/source/rtl/datec.c @@ -82,7 +82,7 @@ HB_FUNC( CMONTH ) hb_retc( hb_dateCMonth( iMonth ) ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1116, NULL, "CMONTH", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1116, NULL, "CMONTH", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( CDOW ) @@ -104,6 +104,6 @@ HB_FUNC( CDOW ) hb_retc( NULL ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1117, NULL, "CDOW", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1117, NULL, "CDOW", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/dateshb.c b/harbour/source/rtl/dateshb.c index 6b493410dc..58c10ddc40 100644 --- a/harbour/source/rtl/dateshb.c +++ b/harbour/source/rtl/dateshb.c @@ -172,7 +172,7 @@ HB_FUNC( CTOD ) hb_retd( y_value, m_value, d_value ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1119, NULL, "CTOD", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1119, NULL, "CTOD", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( DTOC ) @@ -185,7 +185,7 @@ HB_FUNC( DTOC ) hb_retc( hb_dateFormat( hb_pardsbuff( szDate, 1 ), szFormatted, hb_set.HB_SET_DATEFORMAT ) ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1118, NULL, "DTOC", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1118, NULL, "DTOC", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( DTOS ) @@ -197,7 +197,7 @@ HB_FUNC( DTOS ) hb_retc( hb_pardsbuff( szDate, 1 ) ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1120, NULL, "DTOS", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1120, NULL, "DTOS", HB_ERR_ARGS_BASEPARAMS ); } /* NOTE: Harbour extension, exactly the same as STOD(). */ @@ -224,7 +224,7 @@ HB_FUNC( YEAR ) hb_retnllen( iYear, 5 ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1112, NULL, "YEAR", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1112, NULL, "YEAR", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( MONTH ) @@ -240,7 +240,7 @@ HB_FUNC( MONTH ) hb_retnilen( iMonth, 3 ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1113, NULL, "MONTH", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1113, NULL, "MONTH", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( DAY ) @@ -256,7 +256,7 @@ HB_FUNC( DAY ) hb_retnilen( iDay, 3 ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1114, NULL, "DAY", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1114, NULL, "DAY", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( TIME ) @@ -282,5 +282,5 @@ HB_FUNC( DOW ) hb_retnilen( hb_dateJulianDOW( hb_itemGetDL( pDate ) ), 3 ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1115, NULL, "DOW", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1115, NULL, "DOW", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index 877fcb7573..ed344320ac 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -230,7 +230,7 @@ HB_FUNC( DISKSPACE ) #endif if( bError ) - hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT, 1, hb_paramError( 1 ) ); + hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); hb_retnlen( dSpace, -1, 0 ); } diff --git a/harbour/source/rtl/disksphb.c b/harbour/source/rtl/disksphb.c index 83c6339db9..c2017c8045 100644 --- a/harbour/source/rtl/disksphb.c +++ b/harbour/source/rtl/disksphb.c @@ -126,7 +126,7 @@ HB_FUNC( HB_DISKSPACE ) } else { - if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, ( EF_CANDEFAULT | EF_CANRETRY ), 2, hb_paramError( 1 ), hb_paramError( 2 ) ) == E_RETRY ) + if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, ( EF_CANDEFAULT | EF_CANRETRY ), HB_ERR_ARGS_BASEPARAMS ) == E_RETRY ) continue; } break; @@ -277,7 +277,7 @@ HB_FUNC( HB_DISKSPACE ) /* Query level 1 info from filesystem */ while( ( rc = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) ) != 0 ) { - if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, (EF_CANDEFAULT | EF_CANRETRY), 2, hb_paramError( 1 ), hb_paramError( 2 ) ) != E_RETRY ) + if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, (EF_CANDEFAULT | EF_CANRETRY), HB_ERR_ARGS_BASEPARAMS ) != E_RETRY ) break; } diff --git a/harbour/source/rtl/gtfunc.c b/harbour/source/rtl/gtfunc.c index 54d39ee2fb..6a12d13a08 100644 --- a/harbour/source/rtl/gtfunc.c +++ b/harbour/source/rtl/gtfunc.c @@ -97,7 +97,7 @@ HB_FUNC( HB_SETTERMCP ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, "HB_SETTERMCP", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, "HB_SETTERMCP", HB_ERR_ARGS_BASEPARAMS ); hb_ret(); /* return NIL */ } diff --git a/harbour/source/rtl/left.c b/harbour/source/rtl/left.c index dce6cc9b89..33b4005900 100644 --- a/harbour/source/rtl/left.c +++ b/harbour/source/rtl/left.c @@ -75,6 +75,6 @@ HB_FUNC( LEFT ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1124, NULL, "LEFT", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1124, NULL, "LEFT", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/len.c b/harbour/source/rtl/len.c index 22676933f5..576e2482ac 100644 --- a/harbour/source/rtl/len.c +++ b/harbour/source/rtl/len.c @@ -76,5 +76,5 @@ HB_FUNC( LEN ) } } - hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, "LEN", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, "LEN", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/math.c b/harbour/source/rtl/math.c index 28a77f6411..9f0594fee1 100644 --- a/harbour/source/rtl/math.c +++ b/harbour/source/rtl/math.c @@ -661,7 +661,7 @@ HB_FUNC( EXP ) } else { - hb_errRT_BASE_SubstR( EG_ARG, 1096, NULL, "EXP", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1096, NULL, "EXP", HB_ERR_ARGS_BASEPARAMS ); } } @@ -714,7 +714,7 @@ HB_FUNC( LOG ) } else { - hb_errRT_BASE_SubstR( EG_ARG, 1095, NULL, "LOG", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1095, NULL, "LOG", HB_ERR_ARGS_BASEPARAMS ); } } @@ -755,6 +755,6 @@ HB_FUNC( SQRT ) } else { - hb_errRT_BASE_SubstR( EG_ARG, 1097, NULL, "SQRT", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1097, NULL, "SQRT", HB_ERR_ARGS_BASEPARAMS ); } } diff --git a/harbour/source/rtl/minmax.c b/harbour/source/rtl/minmax.c index c461520730..b076ed7922 100644 --- a/harbour/source/rtl/minmax.c +++ b/harbour/source/rtl/minmax.c @@ -103,7 +103,7 @@ HB_FUNC( MAX ) return; } } - hb_errRT_BASE_SubstR( EG_ARG, 1093, NULL, "MAX", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1093, NULL, "MAX", HB_ERR_ARGS_BASEPARAMS ); } /* returns the minimum of two date or numerics */ @@ -156,6 +156,6 @@ HB_FUNC( MIN ) } } - hb_errRT_BASE_SubstR( EG_ARG, 1092, NULL, "MIN", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1092, NULL, "MIN", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/mod.c b/harbour/source/rtl/mod.c index 53d2d925f7..8b1d81055d 100644 --- a/harbour/source/rtl/mod.c +++ b/harbour/source/rtl/mod.c @@ -84,7 +84,7 @@ HB_FUNC( MOD ) } else { - PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", HB_ERR_ARGS_BASEPARAMS ); if( pResult ) { @@ -99,7 +99,7 @@ HB_FUNC( MOD ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1085, NULL, "%", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1085, NULL, "%", HB_ERR_ARGS_BASEPARAMS ); } /* diff --git a/harbour/source/rtl/philes.c b/harbour/source/rtl/philes.c index 3273154e5b..b9cb19da26 100644 --- a/harbour/source/rtl/philes.c +++ b/harbour/source/rtl/philes.c @@ -62,7 +62,7 @@ HB_FUNC( FOPEN ) hb_retni( hb_fsOpen( ( BYTE * ) hb_parc( 1 ), ISNUM( 2 ) ? hb_parni( 2 ) : FO_READ | FO_COMPAT ) ); else - hb_errRT_BASE( EG_ARG, 2021, NULL, "FOPEN", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); /* NOTE: Undocumented but existing Clipper Run-time error */ + hb_errRT_BASE( EG_ARG, 2021, NULL, "FOPEN", HB_ERR_ARGS_BASEPARAMS ); /* NOTE: Undocumented but existing Clipper Run-time error */ } HB_FUNC( FCREATE ) diff --git a/harbour/source/rtl/philesx.c b/harbour/source/rtl/philesx.c index f91601d096..3ebcb6de7f 100644 --- a/harbour/source/rtl/philesx.c +++ b/harbour/source/rtl/philesx.c @@ -72,7 +72,7 @@ HB_FUNC( CURDRIVE ) { while( hb_fsChDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) != 0 ) { - USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 9999, "Operating system error", "CURDRIVE", 0, EF_CANDEFAULT | EF_CANRETRY, 1, hb_paramError( 1 ) ); + USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 9999, "Operating system error", "CURDRIVE", 0, EF_CANDEFAULT | EF_CANRETRY, HB_ERR_ARGS_BASEPARAMS ); if( uiAction != E_RETRY ) break; diff --git a/harbour/source/rtl/replic.c b/harbour/source/rtl/replic.c index 30faa67468..afb2db1535 100644 --- a/harbour/source/rtl/replic.c +++ b/harbour/source/rtl/replic.c @@ -82,12 +82,12 @@ HB_FUNC( REPLICATE ) hb_retclen_buffer( szResult, ulLen * lTimes ); } else - hb_errRT_BASE_SubstR( EG_STROVERFLOW, 1234, NULL, "REPLICATE", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_STROVERFLOW, 1234, NULL, "REPLICATE", HB_ERR_ARGS_BASEPARAMS ); } else hb_retc( NULL ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1106, NULL, "REPLICATE", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1106, NULL, "REPLICATE", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/round.c b/harbour/source/rtl/round.c index 5e617393db..091ab42303 100644 --- a/harbour/source/rtl/round.c +++ b/harbour/source/rtl/round.c @@ -87,7 +87,7 @@ HB_FUNC( INT ) } } else - hb_errRT_BASE_SubstR( EG_ARG, 1090, NULL, "INT", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1090, NULL, "INT", HB_ERR_ARGS_BASEPARAMS ); } HB_FUNC( ROUND ) @@ -104,5 +104,5 @@ HB_FUNC( ROUND ) hb_retnlen( hb_numRound( hb_itemGetND( pNumber ), iDec ), 0, HB_MAX( iDec, 0 ) ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1094, NULL, "ROUND", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1094, NULL, "ROUND", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 29b9a0c011..530858ee58 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -460,7 +460,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_AUTORDER ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_AUTORDER = set_number( pArg2, hb_set.HB_SET_AUTORDER ); } @@ -470,7 +470,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_AUTOSHARE ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_MARGIN = set_number( pArg2, hb_set.HB_SET_AUTOSHARE ); } @@ -542,7 +542,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_DECIMALS ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_DECIMALS = set_number( pArg2, hb_set.HB_SET_DECIMALS ); } @@ -586,7 +586,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_EPOCH ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_EPOCH = set_number( pArg2, hb_set.HB_SET_EPOCH ); } @@ -662,7 +662,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_MARGIN ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_MARGIN = set_number( pArg2, hb_set.HB_SET_MARGIN ); } @@ -672,7 +672,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_MBLOCKSIZE ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_MBLOCKSIZE = set_number( pArg2, hb_set.HB_SET_MBLOCKSIZE ); } @@ -686,7 +686,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_MESSAGE ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_MESSAGE = set_number( pArg2, hb_set.HB_SET_MESSAGE ); } @@ -774,7 +774,7 @@ HB_FUNC( SET ) if( args > 1 ) { if( set_number( pArg2, hb_set.HB_SET_VIDEOMODE ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_VIDEOMODE = set_number( pArg2, hb_set.HB_SET_VIDEOMODE ); } @@ -807,17 +807,17 @@ HB_FUNC( SET ) else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) ) hb_set.HB_SET_FILECASE = HB_SET_CASE_MIXED; else - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); } else if( HB_IS_NUMERIC( pArg2 ) ) { if( set_number( pArg2, hb_set.HB_SET_FILECASE ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_FILECASE = set_number( pArg2, hb_set.HB_SET_FILECASE ); } else - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); } /* if( hb_set.HB_SET_FILECASE ) @@ -841,17 +841,17 @@ HB_FUNC( SET ) else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) ) hb_set.HB_SET_DIRCASE = HB_SET_CASE_MIXED; else - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); } else if( HB_IS_NUMERIC( pArg2 ) ) { if( set_number( pArg2, hb_set.HB_SET_DIRCASE ) < 0 ) - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); else hb_set.HB_SET_DIRCASE = set_number( pArg2, hb_set.HB_SET_DIRCASE ); } else - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); } break; case HB_SET_DIRSEPARATOR : @@ -869,7 +869,7 @@ HB_FUNC( SET ) { if( set_number( pArg2, hb_set.HB_SET_DBFLOCKSCHEME ) < 0 ) { - hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", HB_ERR_ARGS_BASEPARAMS ); } else { diff --git a/harbour/source/rtl/space.c b/harbour/source/rtl/space.c index acb303d2b7..503089d3e4 100644 --- a/harbour/source/rtl/space.c +++ b/harbour/source/rtl/space.c @@ -80,5 +80,5 @@ HB_FUNC( SPACE ) hb_retc( NULL ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1105, NULL, "SPACE", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1105, NULL, "SPACE", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/strcase.c b/harbour/source/rtl/strcase.c index d55e8d6524..700dc1f31e 100644 --- a/harbour/source/rtl/strcase.c +++ b/harbour/source/rtl/strcase.c @@ -122,7 +122,7 @@ HB_FUNC( LOWER ) hb_retclen_buffer( hb_strLower( pszBuffer, ulLen ), ulLen ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1103, NULL, "LOWER", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1103, NULL, "LOWER", HB_ERR_ARGS_BASEPARAMS ); } /* converts string to upper case */ @@ -138,5 +138,5 @@ HB_FUNC( UPPER ) hb_retclen_buffer( hb_strUpper( pszBuffer, ulLen ), ulLen ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1102, NULL, "UPPER", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1102, NULL, "UPPER", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/strpeek.c b/harbour/source/rtl/strpeek.c index 5ed7c21e96..ee1c39cc06 100644 --- a/harbour/source/rtl/strpeek.c +++ b/harbour/source/rtl/strpeek.c @@ -70,7 +70,7 @@ HB_FUNC( STRPEEK ) hb_retni( 0 ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "STRPEEK", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "STRPEEK", HB_ERR_ARGS_BASEPARAMS ); } @@ -90,7 +90,7 @@ HB_FUNC( STRPOKE ) hb_itemReturn( pText ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "STRPOKE", 3, hb_paramError( 1 ), hb_paramError( 2 ), hb_paramError( 3 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "STRPOKE", HB_ERR_ARGS_BASEPARAMS ); } #endif /* HB_COMPAT_FLAGSHIP */ diff --git a/harbour/source/rtl/transfrm.c b/harbour/source/rtl/transfrm.c index 1dda6c2db6..29146763c7 100644 --- a/harbour/source/rtl/transfrm.c +++ b/harbour/source/rtl/transfrm.c @@ -852,5 +852,5 @@ HB_FUNC( TRANSFORM ) /* If there was any parameter error, launch a runtime error */ if( bError ) - hb_errRT_BASE_SubstR( EG_ARG, 1122, NULL, "TRANSFORM", 2, pValue, hb_paramError( 2 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1122, NULL, "TRANSFORM", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/trim.c b/harbour/source/rtl/trim.c index 92acb36633..9856fc343c 100644 --- a/harbour/source/rtl/trim.c +++ b/harbour/source/rtl/trim.c @@ -102,7 +102,7 @@ HB_FUNC( LTRIM ) hb_retclen( szText, ulLen ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1101, NULL, "LTRIM", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1101, NULL, "LTRIM", HB_ERR_ARGS_BASEPARAMS ); } /* trims trailing spaces from a string */ @@ -126,7 +126,7 @@ HB_FUNC( RTRIM ) } else /* NOTE: "TRIM" is right here [vszakats] */ - hb_errRT_BASE_SubstR( EG_ARG, 1100, NULL, "TRIM", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1100, NULL, "TRIM", HB_ERR_ARGS_BASEPARAMS ); } /* synonymn for RTRIM */ @@ -154,7 +154,7 @@ HB_FUNC( ALLTRIM ) } else #ifdef HB_COMPAT_C53 - hb_errRT_BASE_SubstR( EG_ARG, 2022, NULL, "ALLTRIM", 1, hb_paramError( 1 ) ); /* NOTE: This appeared in CA-Cl*pper 5.3 [vszakats] */ + hb_errRT_BASE_SubstR( EG_ARG, 2022, NULL, "ALLTRIM", HB_ERR_ARGS_BASEPARAMS ); /* NOTE: This appeared in CA-Cl*pper 5.3 [vszakats] */ #else hb_retc( NULL ); #endif diff --git a/harbour/source/rtl/type.c b/harbour/source/rtl/type.c index 8e0fa16574..5ce104f55a 100644 --- a/harbour/source/rtl/type.c +++ b/harbour/source/rtl/type.c @@ -63,6 +63,6 @@ HB_FUNC( TYPE ) hb_memvarUpdatePrivatesBase(); } else - hb_errRT_BASE_SubstR( EG_ARG, 1121, NULL, "TYPE", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1121, NULL, "TYPE", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/val.c b/harbour/source/rtl/val.c index 14e578d591..30a4fb4d0b 100644 --- a/harbour/source/rtl/val.c +++ b/harbour/source/rtl/val.c @@ -75,5 +75,5 @@ HB_FUNC( VAL ) hb_retnlen( dValue, iWidth, iDec ); } else - hb_errRT_BASE_SubstR( EG_ARG, 1098, NULL, "VAL", 1, hb_paramError( 1 ) ); + hb_errRT_BASE_SubstR( EG_ARG, 1098, NULL, "VAL", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/rtl/word.c b/harbour/source/rtl/word.c index 45bffa6cf7..1143afd768 100644 --- a/harbour/source/rtl/word.c +++ b/harbour/source/rtl/word.c @@ -62,5 +62,5 @@ HB_FUNC( WORD ) if( ISNUM( 1 ) ) hb_retni( hb_parni( 1 ) ); else - hb_errRT_BASE( EG_ARG, 1091, NULL, "WORD", 1, hb_paramError( 1 ) ); + hb_errRT_BASE( EG_ARG, 1091, NULL, "WORD", HB_ERR_ARGS_BASEPARAMS ); } diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 7936f21946..42a3cb3915 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -102,8 +102,8 @@ HB_FUNC_EXTERN( SYSINIT ); /* Operators (mathematical / character / misc) */ static void hb_vmNegate( void ); /* negates (-) the latest value on the stack */ -static void hb_vmInc( void ); /* increment the latest numeric value on the stack */ -static void hb_vmDec( void ); /* decrements the latest numeric value on the stack */ +static void hb_vmInc( HB_ITEM_PTR pItem ); /* increment the latest numeric value on the stack */ +static void hb_vmDec( HB_ITEM_PTR pItem ); /* decrements the latest numeric value on the stack */ static void hb_vmFuncPtr( void ); /* pushes a function address pointer. Removes the symbol from the satck */ static void hb_vmAddInt( HB_ITEM_PTR pResult, LONG lAdd ); /* add integer to given item */ static void hb_vmPlus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 ); /* sums given values */ @@ -200,8 +200,6 @@ static void hb_vmSwap( BYTE bCount ); /* swap bCount+1 time two items /* Pop */ static BOOL hb_vmPopLogical( void ); /* pops the stack latest value and returns its logical value */ -static long hb_vmPopDate( void ); /* pops the stack latest value and returns its date value as a long */ -static HB_LONG hb_vmPopHBLong( void ); /* pops the stack latest value and returns its HB_LONG value */ static double hb_vmPopNumber( void ); /* pops the stack latest value and returns its numeric value */ static void hb_vmPopAlias( void ); /* pops the workarea number form the eval stack */ static void hb_vmPopAliasedField( PHB_SYMB ); /* pops an aliased field from the eval stack*/ @@ -814,12 +812,52 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) break; case HB_P_INC: - hb_vmInc(); + hb_vmInc( hb_stackItemFromTop( -1 ) ); + w++; + break; + + case HB_P_INCEQ: + { + HB_ITEM_PTR pResult, pValue, pTemp; + pResult = hb_stackItemFromTop( -1 ); + pValue = hb_itemUnRef( pResult ); + hb_vmInc( pValue ); + pTemp = hb_stackAllocItem(); + hb_itemCopy( pTemp, pValue ); + hb_itemMove( pResult, pTemp ); + hb_stackDec(); + w++; + } + break; + + case HB_P_INCEQPOP: + hb_vmInc( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) ); + hb_stackPop(); w++; break; case HB_P_DEC: - hb_vmDec(); + hb_vmDec( hb_stackItemFromTop( -1 ) ); + w++; + break; + + case HB_P_DECEQ: + { + HB_ITEM_PTR pResult, pValue, pTemp; + pResult = hb_stackItemFromTop( -1 ); + pValue = hb_itemUnRef( pResult ); + hb_vmDec( pValue ); + pTemp = hb_stackAllocItem(); + hb_itemCopy( pTemp, pValue ); + hb_itemMove( pResult, pTemp ); + hb_stackDec(); + w++; + } + break; + + case HB_P_DECEQPOP: + hb_vmDec( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) ); + hb_stackPop(); w++; break; @@ -1529,6 +1567,12 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) w += 2; break; + case HB_P_PUSHFUNCSYM: + hb_vmPushSymbol( pSymbols + HB_PCODE_MKUSHORT( &( pCode[ w + 1 ] ) ) ); + hb_stackAllocItem()->type = HB_IT_NIL; + w += 3; + break; + case HB_P_PUSHALIAS: hb_vmPushAlias(); w++; @@ -2010,7 +2054,7 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_LOCALADDINT: { - int iLocal = HB_PCODE_MKSHORT( &pCode[ w + 1 ] ); + int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ); HB_TRACE( HB_TR_DEBUG, ("HB_P_LOCALADDINT") ); hb_vmAddInt( hb_stackLocalVariable( &iLocal ), @@ -2019,8 +2063,38 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) break; } + case HB_P_LOCALINC: + { + int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ); + PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal ); + hb_vmInc( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal ); + w += 3; + break; + } + + case HB_P_LOCALDEC: + { + int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ); + PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal ); + hb_vmDec( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal ); + w += 3; + break; + } + + case HB_P_LOCALINCPUSH: + { + int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ); + PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal ); + if( HB_IS_BYREF( pLocal ) ) + pLocal = hb_itemUnRef( pLocal ); + hb_vmInc( pLocal ); + hb_itemCopy( hb_stackAllocItem(), pLocal ); + w += 3; + break; + } + /* WITH OBJECT */ - + case HB_P_WITHOBJECTMESSAGE: { USHORT wSymPos = HB_PCODE_MKUSHORT( &( pCode[ w + 1 ] ) ); @@ -2212,29 +2286,11 @@ static void hb_vmAddInt( HB_ITEM_PTR pResult, LONG lAdd ) { PHB_ITEM pSubst; - if( lAdd == 1 ) - { - pSubst = hb_errRT_BASE_Subst( EG_ARG, 1086, NULL, "++", 1, pResult ); - } - else if( lAdd == -1 ) - { - pSubst = hb_errRT_BASE_Subst( EG_ARG, 1087, NULL, "--", 1, pResult ); - } - else if( lAdd > 0 ) - { - hb_vmPushLong( lAdd ); - pSubst = hb_errRT_BASE_Subst( EG_ARG, 1081, NULL, "+", 2, pResult, hb_stackItemFromTop( -1 ) ); - hb_stackPop(); - } - else - { - hb_vmPushLong( -lAdd ); - pSubst = hb_errRT_BASE_Subst( EG_ARG, 1082, NULL, "-", 2, pResult, hb_stackItemFromTop( -1 ) ); - hb_stackPop(); - } - + hb_vmPushLong( lAdd ); + pSubst = hb_errRT_BASE_Subst( EG_ARG, 1081, NULL, "+", 2, pResult, hb_stackItemFromTop( -1 ) ); if( pSubst ) { + hb_stackPop(); hb_itemMove( pResult, pSubst ); hb_itemRelease( pSubst ); } @@ -2656,13 +2712,9 @@ static void hb_vmPower( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pIt } } -static void hb_vmInc( void ) +static void hb_vmInc( PHB_ITEM pItem ) { - PHB_ITEM pItem; - - HB_TRACE(HB_TR_DEBUG, ("hb_vmInc()")); - - pItem = hb_stackItemFromTop( -1 ); + HB_TRACE(HB_TR_DEBUG, ("hb_vmInc(%p)", pItem)); if( HB_IS_NUMINT( pItem ) ) { @@ -2721,13 +2773,9 @@ static void hb_vmInc( void ) } } -static void hb_vmDec( void ) +static void hb_vmDec( PHB_ITEM pItem ) { - PHB_ITEM pItem; - - HB_TRACE(HB_TR_DEBUG, ("hb_vmDec()")); - - pItem = hb_stackItemFromTop( -1 ); + HB_TRACE(HB_TR_DEBUG, ("hb_vmDec(%p)", pItem)); if( HB_IS_NUMINT( pItem ) ) { @@ -2844,11 +2892,21 @@ static void hb_vmExactlyEqual( void ) hb_vmPushLogical( fResult ); } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) - hb_vmPushLogical( hb_vmPopHBLong() == hb_vmPopHBLong() ); + { + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) == + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); + } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) hb_vmPushLogical( hb_vmPopNumber() == hb_vmPopNumber() ); else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) - hb_vmPushLogical( hb_vmPopDate() == hb_vmPopDate() ); + { + pItem1->item.asLogical.value = ( pItem1->item.asDate.value == + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); + } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) hb_vmPushLogical( hb_vmPopLogical() == hb_vmPopLogical() ); else if( HB_IS_POINTER( pItem1 ) && HB_IS_POINTER( pItem2 ) ) @@ -2913,11 +2971,21 @@ static void hb_vmEqual( void ) hb_vmPushLogical( fResult ); } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) - hb_vmPushLogical( hb_vmPopHBLong() == hb_vmPopHBLong() ); + { + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) == + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); + } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) hb_vmPushLogical( hb_vmPopNumber() == hb_vmPopNumber() ); else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) - hb_vmPushLogical( hb_vmPopDate() == hb_vmPopDate() ); + { + pItem1->item.asLogical.value = ( pItem1->item.asDate.value == + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); + } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) hb_vmPushLogical( hb_vmPopLogical() == hb_vmPopLogical() ); else if( HB_IS_POINTER( pItem1 ) && HB_IS_POINTER( pItem2 ) ) @@ -2973,11 +3041,21 @@ static void hb_vmNotEqual( void ) hb_vmPushLogical( i != 0 ); } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) - hb_vmPushLogical( hb_vmPopHBLong() != hb_vmPopHBLong() ); + { + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) != + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); + } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) hb_vmPushLogical( hb_vmPopNumber() != hb_vmPopNumber() ); else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) - hb_vmPushLogical( hb_vmPopDate() != hb_vmPopDate() ); + { + pItem1->item.asLogical.value = ( pItem1->item.asDate.value != + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); + } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) hb_vmPushLogical( hb_vmPopLogical() != hb_vmPopLogical() ); else if( HB_IS_POINTER( pItem1 ) && HB_IS_POINTER( pItem2 ) ) @@ -3022,9 +3100,10 @@ static void hb_vmLess( void ) } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) { - HB_LONG lNumber2 = hb_vmPopHBLong(); - HB_LONG lNumber1 = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber1 < lNumber2 ); + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) < + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) { @@ -3034,9 +3113,10 @@ static void hb_vmLess( void ) } else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) { - long lDate2 = hb_vmPopDate(); - long lDate1 = hb_vmPopDate(); - hb_vmPushLogical( lDate1 < lDate2 ); + pItem1->item.asLogical.value = ( pItem1->item.asDate.value < + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) { @@ -3079,9 +3159,10 @@ static void hb_vmLessEqual( void ) } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) { - HB_LONG lNumber2 = hb_vmPopHBLong(); - HB_LONG lNumber1 = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber1 <= lNumber2 ); + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) <= + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) { @@ -3091,9 +3172,10 @@ static void hb_vmLessEqual( void ) } else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) { - long lDate2 = hb_vmPopDate(); - long lDate1 = hb_vmPopDate(); - hb_vmPushLogical( lDate1 <= lDate2 ); + pItem1->item.asLogical.value = ( pItem1->item.asDate.value <= + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) { @@ -3136,9 +3218,10 @@ static void hb_vmGreater( void ) } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) { - HB_LONG lNumber2 = hb_vmPopHBLong(); - HB_LONG lNumber1 = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber1 > lNumber2 ); + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) > + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) { @@ -3148,9 +3231,10 @@ static void hb_vmGreater( void ) } else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) { - long lDate2 = hb_vmPopDate(); - long lDate1 = hb_vmPopDate(); - hb_vmPushLogical( lDate1 > lDate2 ); + pItem1->item.asLogical.value = ( pItem1->item.asDate.value > + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) { @@ -3193,9 +3277,10 @@ static void hb_vmGreaterEqual( void ) } else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) ) { - HB_LONG lNumber2 = hb_vmPopHBLong(); - HB_LONG lNumber1 = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber1 >= lNumber2 ); + pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) >= + HB_ITEM_GET_NUMINTRAW( pItem2 ) ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) ) { @@ -3205,9 +3290,10 @@ static void hb_vmGreaterEqual( void ) } else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) ) { - long lDate2 = hb_vmPopDate(); - long lDate1 = hb_vmPopDate(); - hb_vmPushLogical( lDate1 >= lDate2 ); + pItem1->item.asLogical.value = ( pItem1->item.asDate.value >= + pItem2->item.asDate.value ); + pItem1->type = HB_IT_LOGICAL; + hb_stackDec(); } else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) ) { @@ -3255,7 +3341,7 @@ static void hb_vmInstring( void ) #if defined( HB_COMPAT_XHB ) else if( HB_IS_ARRAY( pItem2 ) ) { - BOOL fResult = hb_arrayScan( pItem2, pItem1, NULL, NULL, TRUE ); + BOOL fResult = hb_arrayScan( pItem2, pItem1, NULL, NULL, TRUE ) != 0; hb_stackPop(); hb_stackPop(); @@ -5555,20 +5641,6 @@ static BOOL hb_vmPopLogical( void ) /* NOTE: Type checking should be done by the caller. */ -static long hb_vmPopDate( void ) -{ - long lDate; - - HB_TRACE(HB_TR_DEBUG, ("hb_vmPopDate()")); - - lDate = hb_stackItemFromTop( -1 )->item.asDate.value; - hb_stackDec(); - - return lDate; -} - -/* NOTE: Type checking should be done by the caller. */ - static double hb_vmPopNumber( void ) { PHB_ITEM pItem; @@ -5594,7 +5666,7 @@ static double hb_vmPopNumber( void ) default: hb_errInternal( HB_EI_VMPOPINVITEM, NULL, "hb_vmPopNumber()", NULL ); - return 0.0; /* To avoid GCC -O2 warning */ + dNumber = 0.0; /* To avoid GCC -O2 warning */ } hb_stackDec(); @@ -5602,41 +5674,6 @@ static double hb_vmPopNumber( void ) return dNumber; } -/* NOTE: Type checking should be done by the caller. */ - -static HB_LONG hb_vmPopHBLong( void ) -{ - PHB_ITEM pItem; - HB_LONG lNumber; - - HB_TRACE(HB_TR_DEBUG, ("hb_vmPopHBLong()")); - - pItem = hb_stackItemFromTop( -1 ); - - switch( pItem->type ) - { - case HB_IT_INTEGER: - lNumber = ( HB_LONG ) pItem->item.asInteger.value; - break; - - case HB_IT_LONG: - lNumber = ( HB_LONG ) pItem->item.asLong.value; - break; - - case HB_IT_DOUBLE: - lNumber = ( HB_LONG ) pItem->item.asDouble.value; - break; - - default: - hb_errInternal( HB_EI_VMPOPINVITEM, NULL, "hb_vmPopNumber()", NULL ); - return 0; /* To avoid GCC -O2 warning */ - } - - hb_stackDec(); - - return lNumber; -} - /* Pops the item from the eval stack and uses it to select the current * workarea */ @@ -7096,6 +7133,45 @@ HB_EXPORT BOOL hb_xvmLocalAddInt( int iLocal, LONG lAdd ) HB_XVM_RETURN } +HB_EXPORT BOOL hb_xvmLocalInc( int iLocal ) +{ + PHB_ITEM pLocal; + + HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalInc(%d)", iLocal)); + + pLocal = hb_stackLocalVariable( &iLocal ); + hb_vmInc( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal ); + + HB_XVM_RETURN +} + +HB_EXPORT BOOL hb_xvmLocalDec( int iLocal ) +{ + PHB_ITEM pLocal; + + HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalDec(%d)", iLocal)); + + pLocal = hb_stackLocalVariable( &iLocal ); + hb_vmDec( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal ); + + HB_XVM_RETURN +} + +HB_EXPORT BOOL hb_xvmLocalIncPush( int iLocal ) +{ + PHB_ITEM pLocal; + + HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalInc(%d)", iLocal)); + + pLocal = hb_stackLocalVariable( &iLocal ); + if( HB_IS_BYREF( pLocal ) ) + pLocal = hb_itemUnRef( pLocal ); + hb_vmInc( pLocal ); + hb_itemCopy( hb_stackAllocItem(), pLocal ); + + HB_XVM_RETURN +} + HB_EXPORT BOOL hb_xvmLocalAdd( int iLocal ) { PHB_ITEM pLocal; @@ -7277,8 +7353,8 @@ HB_EXPORT BOOL hb_xvmEqualInt( LONG lValue ) } else if( HB_IS_NUMINT( pItem ) ) { - HB_LONG lNumber = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber == ( HB_LONG ) lValue ); + pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) == ( HB_LONG ) lValue; + pItem->type = HB_IT_LOGICAL; } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7324,7 +7400,8 @@ HB_EXPORT BOOL hb_xvmEqualIntIs( LONG lValue, BOOL * pfValue ) } else if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() == ( HB_LONG ) lValue; + * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) == ( HB_LONG ) lValue; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7380,8 +7457,8 @@ HB_EXPORT BOOL hb_xvmNotEqualInt( LONG lValue ) } else if( HB_IS_NUMINT( pItem ) ) { - HB_LONG lNumber = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber != ( HB_LONG ) lValue ); + pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) != ( HB_LONG ) lValue; + pItem->type = HB_IT_LOGICAL; } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7427,7 +7504,8 @@ HB_EXPORT BOOL hb_xvmNotEqualIntIs( LONG lValue, BOOL * pfValue ) } else if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() != ( HB_LONG ) lValue; + * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) != ( HB_LONG ) lValue; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7478,7 +7556,8 @@ HB_EXPORT BOOL hb_xvmLessThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - hb_vmPushLogical( hb_vmPopHBLong() < ( HB_LONG ) lValue ); + pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) < ( HB_LONG ) lValue; + pItem->type = HB_IT_LOGICAL; } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7518,7 +7597,8 @@ HB_EXPORT BOOL hb_xvmLessThenIntIs( LONG lValue, BOOL * pfValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() < ( HB_LONG ) lValue; + * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) < ( HB_LONG ) lValue; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7569,7 +7649,8 @@ HB_EXPORT BOOL hb_xvmLessEqualThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - hb_vmPushLogical( hb_vmPopHBLong() <= ( HB_LONG ) lValue ); + pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) <= ( HB_LONG ) lValue; + pItem->type = HB_IT_LOGICAL; } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7609,7 +7690,8 @@ HB_EXPORT BOOL hb_xvmLessEqualThenIntIs( LONG lValue, BOOL * pfValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() <= ( HB_LONG ) lValue; + * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) <= ( HB_LONG ) lValue; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7660,7 +7742,8 @@ HB_EXPORT BOOL hb_xvmGreaterThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - hb_vmPushLogical( hb_vmPopHBLong() > ( HB_LONG ) lValue ); + pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) > ( HB_LONG ) lValue; + pItem->type = HB_IT_LOGICAL; } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7700,7 +7783,8 @@ HB_EXPORT BOOL hb_xvmGreaterThenIntIs( LONG lValue, BOOL * pfValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() > ( HB_LONG ) lValue; + * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) > ( HB_LONG ) lValue; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7751,7 +7835,8 @@ HB_EXPORT BOOL hb_xvmGreaterEqualThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - hb_vmPushLogical( hb_vmPopHBLong() >= ( HB_LONG ) lValue ); + pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) >= ( HB_LONG ) lValue; + pItem->type = HB_IT_LOGICAL; } else if( HB_IS_NUMERIC( pItem ) ) { @@ -7791,7 +7876,8 @@ HB_EXPORT BOOL hb_xvmGreaterEqualThenIntIs( LONG lValue, BOOL * pfValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() >= ( HB_LONG ) lValue; + * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) >= ( HB_LONG ) lValue; + hb_stackDec(); } else if( HB_IS_NUMERIC( pItem ) ) { @@ -8182,7 +8268,34 @@ HB_EXPORT BOOL hb_xvmInc( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmInc()")); - hb_vmInc(); + hb_vmInc( hb_stackItemFromTop( -1 ) ); + + HB_XVM_RETURN +} + +HB_EXPORT BOOL hb_xvmIncEq( void ) +{ + PHB_ITEM pResult, pValue, pTemp; + + HB_TRACE(HB_TR_DEBUG, ("hb_xvmIncEq()")); + + pResult = hb_stackItemFromTop( -1 ); + pValue = hb_itemUnRef( pResult ); + hb_vmInc( pValue ); + pTemp = hb_stackAllocItem(); + hb_itemCopy( pTemp, pValue ); + hb_itemMove( pResult, pTemp ); + hb_stackDec(); + + HB_XVM_RETURN +} + +HB_EXPORT BOOL hb_xvmIncEqPop( void ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_xvmIncEqPop()")); + + hb_vmInc( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) ); + hb_stackPop(); HB_XVM_RETURN } @@ -8191,7 +8304,34 @@ HB_EXPORT BOOL hb_xvmDec( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmDec()")); - hb_vmDec(); + hb_vmDec( hb_stackItemFromTop( -1 ) ); + + HB_XVM_RETURN +} + +HB_EXPORT BOOL hb_xvmDecEq( void ) +{ + PHB_ITEM pResult, pValue, pTemp; + + HB_TRACE(HB_TR_DEBUG, ("hb_xvmDecEq()")); + + pResult = hb_stackItemFromTop( -1 ); + pValue = hb_itemUnRef( pResult ); + hb_vmDec( pValue ); + pTemp = hb_stackAllocItem(); + hb_itemCopy( pTemp, pValue ); + hb_itemMove( pResult, pTemp ); + hb_stackDec(); + + HB_XVM_RETURN +} + +HB_EXPORT BOOL hb_xvmDecEqPop( void ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_xvmDecEqPop()")); + + hb_vmDec( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) ); + hb_stackPop(); HB_XVM_RETURN } diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 19cdb87d58..03a505760b 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -1366,7 +1366,7 @@ void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL hb_compGenPCodeN( pBuffer, 1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ), HB_COMP_PARAM ); } -void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ) +void hb_compGenPushFunSym( char * szFunName, HB_COMP_DECL ) { char * szFunction; @@ -1384,6 +1384,12 @@ void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ) } } +void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ) +{ + hb_compGenPushFunSym( szFunName, HB_COMP_PARAM ); + hb_compGenPCode1( HB_P_PUSHNIL, HB_COMP_PARAM ); +} + void hb_compGenPushFunRef( char * szFunName, HB_COMP_DECL ) { char * szFunction; @@ -1409,7 +1415,6 @@ void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_COMP_DECL ) hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM ); } - void hb_compGenPCode1( BYTE byte, HB_COMP_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; diff --git a/harbour/utils/hbtest/rt_math.prg b/harbour/utils/hbtest/rt_math.prg index 60ac9b12e1..38407441a7 100644 --- a/harbour/utils/hbtest/rt_math.prg +++ b/harbour/utils/hbtest/rt_math.prg @@ -360,7 +360,7 @@ FUNCTION Main_MATH() /* MOD() */ - TEST_LINE( MOD() , "E BASE 1085 Argument error % A:2:U:NIL;U:NIL F:S" ) + TEST_LINE( MOD() , "E BASE 1085 Argument error % F:S" ) TEST_LINE( MOD( "A", "B" ) , "E BASE 1085 Argument error % A:2:C:A;C:B F:S" ) TEST_LINE( MOD( "A", 100 ) , "E BASE 1085 Argument error % A:2:C:A;N:100 F:S" ) TEST_LINE( MOD( 100, "B" ) , "E BASE 1085 Argument error % A:2:N:100;C:B F:S" )