diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index d0b83288de..fbb180a706 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -116,7 +116,11 @@ typedef struct __FUNC ULONG * pNOOPs; /* pointer to the NOOP array */ ULONG * pJumps; /* pointer to the Jumps array */ int iNOOPs; /* NOOPs Counter */ - int iJumps; /* Jumps Counter */ + BYTE iJumps; /* Jumps Counter */ + BYTE pStack[256]; /* Compile Time Stack */ + SHORT iStackIndex; /* Compile Time Stack Index */ + BYTE pFunctionCalls[256]; /* Array of Function Calls Compile Time Stack Postion */ + SHORT iFunctionIndex; /* Index into Array of Function Calls Compile Time Stack Postion */ struct __FUNC * pOwner; /* pointer to the function/procedure that owns the codeblock */ struct __FUNC * pNext; /* pointer to the next defined function */ } _FUNC, * PFUNCTION; @@ -222,10 +226,10 @@ extern void hb_compGenPushAliasedVar( char *, BOOL, char *, long, HB_MACRO_DECL extern void hb_compGenPopAliasedVar( char *, BOOL, char *, long, HB_MACRO_DECL ); extern void hb_compGenPushFunRef( char *, HB_MACRO_DECL ); extern void hb_compGenPCode1( BYTE, HB_MACRO_DECL ); /* generates 1 byte of pcode */ -extern void hb_compGenPCode2( BYTE, BYTE, HB_MACRO_DECL ); /* generates 2 bytes of pcode */ -extern void hb_compGenPCode3( BYTE, BYTE, BYTE, HB_MACRO_DECL ); /* generates 3 bytes of pcode */ -extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE, HB_MACRO_DECL ); /* generates 4 bytes of pcode */ -extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_MACRO_DECL ); /* copy bytes to a pcode buffer */ +extern void hb_compGenPCode2( BYTE, BYTE, BOOL, HB_MACRO_DECL ); /* generates 2 bytes of pcode */ +extern void hb_compGenPCode3( BYTE, BYTE, BYTE, BOOL, HB_MACRO_DECL ); /* generates 3 bytes of pcode */ +extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE, BOOL, HB_MACRO_DECL ); /* generates 4 bytes of pcode */ +extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, BOOL, HB_MACRO_DECL ); /* copy bytes to a pcode buffer */ /* Codeblocks */ extern void hb_compCodeBlockStart( HB_MACRO_DECL ); /* starts a codeblock creation */ @@ -272,10 +276,10 @@ extern void hb_compGenPushAliasedVar( char *, BOOL, char *, long ); extern void hb_compGenPopAliasedVar( char *, BOOL, char *, long ); extern void hb_compGenPushFunRef( char * ); extern void hb_compGenPCode1( BYTE ); /* generates 1 byte of pcode */ -extern void hb_compGenPCode2( BYTE, BYTE ); /* generates 2 bytes of pcode */ -extern void hb_compGenPCode3( BYTE, BYTE, BYTE ); /* generates 3 bytes of pcode */ -extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE ); /* generates 4 bytes of pcode */ -extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize ); /* copy bytes to a pcode buffer */ +extern void hb_compGenPCode2( BYTE, BYTE, BOOL ); /* generates 2 bytes of pcode + flag for optional StrongType(). */ +extern void hb_compGenPCode3( BYTE, BYTE, BYTE, BOOL ); /* generates 3 bytes of pcode + flag for optional StrongType() */ +extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE, BOOL ); /* generates 4 bytes of pcode + flag for optional StrongType() */ +extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, BOOL ); /* copy bytes to a pcode buffer + flag for optional StrongType() */ extern ULONG hb_compSequenceBegin( void ); extern ULONG hb_compSequenceEnd( void ); diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index cdffb18fe4..77bba52565 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -99,16 +99,13 @@ extern "C" { #define HB_COMP_WARN_PROC_RETURN_VALUE 6 #define HB_COMP_WARN_FUN_WITH_NO_RETURN 7 #define HB_COMP_WARN_ASSIGN_TYPE 8 -#define HB_COMP_WARN_LOGICAL_TYPE 9 -#define HB_COMP_WARN_NUMERIC_TYPE 10 -#define HB_COMP_WARN_OPERANDS_INCOMPATBLE 11 -#define HB_COMP_WARN_ASSIGN_SUSPECT 12 -#define HB_COMP_WARN_OPERAND_SUSPECT 13 -#define HB_COMP_WARN_LOGICAL_SUSPECT 14 -#define HB_COMP_WARN_NUMERIC_SUSPECT 15 -#define HB_COMP_WARN_MEANINGLESS 16 -#define HB_COMP_WARN_UNREACHABLE 17 -#define HB_COMP_WARN_DUPL_ANNOUNCE 18 +#define HB_COMP_WARN_OPERAND_TYPE 9 +#define HB_COMP_WARN_OPERANDS_INCOMPATBLE 10 +#define HB_COMP_WARN_ASSIGN_SUSPECT 11 +#define HB_COMP_WARN_OPERAND_SUSPECT 12 +#define HB_COMP_WARN_MEANINGLESS 13 +#define HB_COMP_WARN_UNREACHABLE 14 +#define HB_COMP_WARN_DUPL_ANNOUNCE 15 /* * Errors generated by Harbour preprocessor diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 1fe1f4a49f..6baa822ac3 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -217,7 +217,7 @@ static HB_EXPR_FUNC( hb_compExprUseDummy ) hb_compErrorLValue( pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); break; case HB_EA_POP_PCODE: case HB_EA_PUSH_POP: @@ -246,7 +246,7 @@ static HB_EXPR_FUNC( hb_compExprUseNil ) hb_compErrorLValue( pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); break; case HB_EA_POP_PCODE: break; @@ -318,7 +318,7 @@ static HB_EXPR_FUNC( hb_compExprUseString ) * need to check for locals or static variables */ if( hb_compExprCheckMacroVar( pSelf->value.asString ) ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROTEXT ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROTEXT ); #endif } break; @@ -467,7 +467,7 @@ static HB_EXPR_FUNC( hb_compExprUseSelf ) hb_compErrorLValue( pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHSELF ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHSELF ); break; case HB_EA_POP_PCODE: break; @@ -507,7 +507,7 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) /* Push all elements of the array */ if( ( pElem == NULL ) || ( pElem->ExprType == HB_ET_NONE && pElem->pNext == NULL ) ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_ARRAYGEN, 0, 0 ); + HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_ARRAYGEN, 0, 0, ( BOOL ) 1 ); else { while( pElem ) @@ -515,7 +515,7 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) HB_EXPR_USE( pElem, HB_EA_PUSH_PCODE ); pElem = pElem->pNext; } - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_ARRAYGEN, HB_LOBYTE( pSelf->ulLength ), HB_HIBYTE( pSelf->ulLength ) ); + HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_ARRAYGEN, HB_LOBYTE( pSelf->ulLength ), HB_HIBYTE( pSelf->ulLength ), ( BOOL ) 1 ); } } break; @@ -608,7 +608,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunRef ) break; case HB_EA_PUSH_PCODE: HB_EXPR_PCODE1( hb_compGenPushFunCall, pSelf->value.asSymbol ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_FUNCPTR ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_FUNCPTR ); break; case HB_EA_POP_PCODE: break; @@ -668,7 +668,7 @@ static HB_EXPR_FUNC( hb_compExprUseIIF ) case HB_EA_STATEMENT: { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); /* remove a value if used in statement */ + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); /* remove a value if used in statement */ } break; @@ -909,7 +909,7 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPUSH ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_ARRAYPUSH ); } break; @@ -917,7 +917,7 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPOP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_ARRAYPOP ); } break; @@ -981,9 +981,9 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) /* compile & run - leave a result on the eval stack */ if( pSelf->value.asMacro.SubType == HB_ET_MACRO_SYMBOL ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROSYMBOL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROSYMBOL ); else if( pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSH ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPUSH ); /* NOTE: pcode for alias context is generated in * hb_compExprUseAliasVar() */ @@ -1021,14 +1021,14 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) * from the eval stack */ if( pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPOP ); } break; case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); break; case HB_EA_DELETE: @@ -1070,7 +1070,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) USHORT usCount; HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); if( pSelf->value.asFunCall.pParms ) { @@ -1087,9 +1087,9 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) usCount = 0; if( usCount > 255 ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_FUNCTION, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_FUNCTION, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ), ( BOOL ) 1 ); else - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, ( BYTE ) usCount ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, ( BYTE ) usCount, ( BOOL ) 1 ); } break; @@ -1102,7 +1102,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) USHORT usCount; HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); if( pSelf->value.asFunCall.pParms ) { @@ -1116,9 +1116,9 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) usCount = 0; if( usCount > 255 ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ), ( BOOL ) 1 ); else - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_DOSHORT, ( BYTE ) usCount ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_DOSHORT, ( BYTE ) usCount, ( BOOL ) 1 ); } break; @@ -1269,7 +1269,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); break; case HB_EA_DELETE: @@ -1301,13 +1301,13 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) { /* save currently selected workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHALIAS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHALIAS ); /* push the expression that will return a new workarea */ HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_PUSH_PCODE ); /* pop the value from the stack and select it as current workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POPALIAS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POPALIAS ); /* evaluate any expression */ HB_EXPR_USE( pSelf->value.asAlias.pExpList, HB_EA_PUSH_PCODE ); @@ -1316,7 +1316,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) * is previously selected workarea. After swaping select again * the restored workarea. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_SWAPALIAS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_SWAPALIAS ); } break; @@ -1329,20 +1329,20 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) { /* save currently selected workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHALIAS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHALIAS ); /* push the expression that will return a new workarea */ HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_PUSH_PCODE ); /* pop the value from the stack and select it as current workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POPALIAS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POPALIAS ); /* evaluate any expression - it will not leave any return * value on the eval stack */ HB_EXPR_USE( pSelf->value.asAlias.pExpList, HB_EA_PUSH_POP ); /* Pop and select again the restored workarea. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POPALIAS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POPALIAS ); } break; case HB_EA_DELETE: @@ -1479,7 +1479,7 @@ static HB_EXPR_FUNC( hb_compExprUseVariable ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_PCODE1( hb_compGenPushVar, pSelf->value.asSymbol ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); break; case HB_EA_DELETE: @@ -1526,16 +1526,16 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_PUSH_PCODE ); if( iParms > 255 ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_FUNCTION, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ) ); + HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_FUNCTION, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ), ( BOOL ) 1 ); else - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, ( BYTE ) iParms ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, ( BYTE ) iParms, ( BOOL ) 1 ); } else { /* acces to instance variable */ HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_PUSH_PCODE ); HB_EXPR_PCODE1( hb_compGenMessage, pSelf->value.asMessage.szMessage ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0, ( BOOL ) 1 ); } } break; @@ -1548,14 +1548,14 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_PUSH_PCODE ); HB_EXPR_PCODE1( hb_compGenMessageData, pSelf->value.asMessage.szMessage ); HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1, ( BOOL ) 1 ); } break; case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); if( ! pSelf->value.asMessage.pParms ) /* Is it a method call ? */ { /* instance variable */ @@ -1685,7 +1685,7 @@ static HB_EXPR_FUNC( hb_compExprUseAssign ) HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); /* QUESTION: Can we replace DUPLICATE+POP with a single PUT opcode */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } } @@ -1706,7 +1706,7 @@ static HB_EXPR_FUNC( hb_compExprUseAssign ) HB_EXPR_USE( pObj, HB_EA_POP_PCODE ); pObj->value.asMessage.pParms = NULL; /* to suppress duplicated releasing */ /* Remove the return value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); } else { @@ -2004,17 +2004,17 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); lEndPos = HB_EXPR_PCODE1( hb_compGenJumpTrue, 0 ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_OR ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_OR ); HB_EXPR_PCODE1( hb_compGenJumpHere, lEndPos ); } else { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_OR ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_OR ); } break; @@ -2025,7 +2025,7 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2074,17 +2074,17 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); lEndPos = HB_EXPR_PCODE1( hb_compGenJumpFalse, 0 ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_AND ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_AND ); HB_EXPR_PCODE1( hb_compGenJumpHere, lEndPos ); } else { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_AND ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_AND ); } break; @@ -2094,7 +2094,7 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2150,7 +2150,7 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_NOT ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_NOT ); break; case HB_EA_POP_PCODE: @@ -2159,7 +2159,7 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2228,7 +2228,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) { HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_EQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_EQUAL ); } break; @@ -2261,7 +2261,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) { HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_EQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_EQUAL ); } } else @@ -2270,7 +2270,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) */ HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_EQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_EQUAL ); } } break; @@ -2281,7 +2281,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2305,7 +2305,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) HB_EXPR_USE( pObj, HB_EA_POP_PCODE ); pObj->value.asMessage.pParms = NULL; /* to suppress duplicated releasing */ /* Remove the return value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); } else { @@ -2348,7 +2348,7 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_EXACTLYEQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_EXACTLYEQUAL ); } break; @@ -2358,7 +2358,7 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2403,7 +2403,7 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_LESS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_LESS ); } break; @@ -2413,7 +2413,7 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2458,7 +2458,7 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_GREATER ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_GREATER ); } break; @@ -2468,7 +2468,7 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2514,7 +2514,7 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_LESSEQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_LESSEQUAL ); } break; @@ -2524,7 +2524,7 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2570,7 +2570,7 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_GREATEREQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_GREATEREQUAL ); } break; @@ -2580,7 +2580,7 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2626,7 +2626,7 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_NOTEQUAL ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_NOTEQUAL ); } break; @@ -2636,7 +2636,7 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2683,7 +2683,7 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INSTRING ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_INSTRING ); } break; @@ -2693,7 +2693,7 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2738,7 +2738,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PLUS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PLUS ); } break; @@ -2748,7 +2748,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2793,7 +2793,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MINUS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MINUS ); } break; @@ -2803,7 +2803,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2848,7 +2848,7 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MULT ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MULT ); } break; @@ -2858,7 +2858,7 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2903,7 +2903,7 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DIVIDE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DIVIDE ); } break; @@ -2913,7 +2913,7 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -2958,7 +2958,7 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MODULUS ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MODULUS ); } break; @@ -2968,7 +2968,7 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -3010,7 +3010,7 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POWER ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POWER ); } break; @@ -3020,7 +3020,7 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used @@ -3077,7 +3077,7 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) case HB_EA_PUSH_PCODE: { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_NEGATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_NEGATE ); } break; @@ -3087,7 +3087,7 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) case HB_EA_PUSH_POP: #ifdef HB_C52_STRICT HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); #else /* NOTE: This will not generate a runtime error if incompatible * data type is used diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index f14b1bc1de..3659403526 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -91,11 +91,11 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) * reverts items on the stack ! * duplicate object on the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); #endif /* now send the message */ HB_EXPR_PCODE1( hb_compGenMessage, pObj->value.asMessage.szMessage ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0, ( BOOL ) 1 ); /* NOTE: COMPATIBILITY ISSUE: * The above HB_C52_STRICT setting determines @@ -125,10 +125,10 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) /* push increment value */ HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); /* increase operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); /* call pop message with one argument */ - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1, ( BOOL ) 1 ); } /* TODO: add a special code for arrays to correctly handle a[ i++ ]++ */ @@ -139,8 +139,8 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) /* push increment value */ HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); /* perform operation and duplicate the new value */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); /* pop the new value into variable and leave the copy on the stack */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } @@ -172,21 +172,21 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) HB_EXPR_USE( pObj->value.asMessage.pObject, HB_EA_PUSH_PCODE ); #else /* duplicate object on the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); #endif /* now send the message */ HB_EXPR_PCODE1( hb_compGenMessage, pObj->value.asMessage.szMessage ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0, ( BOOL ) 1 ); /* push increment value */ HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); /* increase operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); /* call pop message with one argument */ - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1, ( BOOL ) 1 ); /* pop the value from the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); } else { @@ -195,7 +195,7 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) /* push increment value */ HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); /* add */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); /* pop the new value into variable and remove it from the stack */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } @@ -226,26 +226,26 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper ) HB_EXPR_USE( pObj->value.asMessage.pObject, HB_EA_PUSH_PCODE ); #else /* duplicate object on the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); #endif /* now send the message */ HB_EXPR_PCODE1( hb_compGenMessage, pObj->value.asMessage.szMessage ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 0, ( BOOL ) 1 ); /* increase/decrease operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOper ); /* call pop message with one argument - it leaves the value on the stack */ - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1 ); + HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, 1, ( BOOL ) 1 ); } else { /* Push current value */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); /* Increment */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOper ); /* duplicate a value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); /* pop new value and leave the duplicated copy of it on the stack */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } @@ -268,16 +268,16 @@ void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper ) /* now increment the value */ HB_EXPR_PCODE2( hb_compExprPushPreOp, pSelf, bOper ); /* pop the value from the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); } else { /* Push current value */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); /* Duplicate value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); /* Increment */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOper ); /* pop new value from the stack */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } @@ -298,14 +298,14 @@ void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper ) { HB_EXPR_PCODE2( hb_compExprPushPreOp, pSelf, bOper ); /* pop the value from the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP ); } else { /* Push current value */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); /* Increment */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOper ); /* pop new value from the stack */ HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } @@ -339,9 +339,9 @@ void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction ) HB_EXPR_PCODE2( hb_compGenPushString, pAlias->value.asSymbol, strlen(pAlias->value.asSymbol) ); HB_EXPR_USE( pVar, HB_EA_PUSH_PCODE ); if( bAction == HB_EA_PUSH_PCODE ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); } else if( pVar->ExprType == HB_ET_VARIABLE ) { @@ -351,18 +351,18 @@ void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction ) HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); HB_EXPR_PCODE2( hb_compGenPushString, pVar->value.asSymbol, strlen(pVar->value.asSymbol) ); if( bAction == HB_EA_PUSH_PCODE ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); } else { HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pVar, HB_EA_PUSH_PCODE ); if( bAction == HB_EA_PUSH_PCODE ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); + HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); } } diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index ab011d23f2..2d640a372d 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -228,6 +228,10 @@ typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage, void * pMa #define HB_EXPR_PCODE2( action, p1, p2 ) action( (p1), (p2), pMacro ) #define HB_EXPR_PCODE3( action, p1, p2, p3 ) action( (p1), (p2), (p3), pMacro ) #define HB_EXPR_PCODE4( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4), pMacro ) +#define HB_EXPR_GENPCODE1( action, p1 ) action( (p1), pMacro ) +#define HB_EXPR_GENPCODE2( action, p1, p2, p3 ) action( (p1), (p2), (p3), pMacro ) +#define HB_EXPR_GENPCODE3( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4), pMacro ) +#define HB_EXPR_GENPCODE4( action, p1, p2, p3, p4, p5 ) action( (p1), (p2), (p3), (p4), (p5), pMacro ) #define HB_MACRO_VARNAME pMacro @@ -249,6 +253,10 @@ typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage ); #define HB_EXPR_PCODE2( action, p1, p2 ) action( (p1), (p2) ) #define HB_EXPR_PCODE3( action, p1, p2, p3 ) action( (p1), (p2), (p3) ) #define HB_EXPR_PCODE4( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4) ) +#define HB_EXPR_GENPCODE1( action, p1 ) action( (p1) ) +#define HB_EXPR_GENPCODE2( action, p1, p2, p3 ) action( (p1), (p2), (p3) ) +#define HB_EXPR_GENPCODE3( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4) ) +#define HB_EXPR_GENPCODE4( action, p1, p2, p3, p4, p5 ) action( (p1), (p2), (p3), (p4), (p5) ) /* pass NULL instead of macro structure pointer */ #define HB_MACRO_DECL void *pMacro diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index 0631c982a5..621dd16ad3 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -87,9 +87,10 @@ extern void hb_macroError( int, HB_MACRO_DECL ); extern int hb_compParse( HB_MACRO_PTR ); extern void hb_compGenPCode1( BYTE, HB_MACRO_DECL ); -extern void hb_compGenPCode2( BYTE, BYTE, HB_MACRO_DECL ); -extern void hb_compGenPCode3( BYTE, BYTE, BYTE, HB_MACRO_DECL ); -extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_MACRO_DECL ); +extern void hb_compGenPCode2( BYTE, BYTE, BOOL, HB_MACRO_DECL ); +extern void hb_compGenPCode3( BYTE, BYTE, BYTE, BOOL, HB_MACRO_DECL ); +extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE, BOOL, HB_MACRO_DECL ); +extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, BOOL, HB_MACRO_DECL ); extern void hb_compGenJumpHere( ULONG, HB_MACRO_DECL ); @@ -131,9 +132,10 @@ extern void hb_compGenPushDouble( double dNumber, BYTE bDec, HB_MACRO_DECL ); extern void hb_compGenPushFunCall( char * szFunName, HB_MACRO_DECL ); extern void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_MACRO_DECL ); extern void hb_compGenPCode1( BYTE byte, HB_MACRO_DECL ); -extern void hb_compGenPCode2( BYTE byte1, BYTE byte2, HB_MACRO_DECL ); -extern void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_MACRO_DECL ); -extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_MACRO_DECL ); +extern void hb_compGenPCode2( BYTE byte1, BYTE byte2, BOOL bStackAffected, HB_MACRO_DECL ); +extern void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, BOOL bStackAffected, HB_MACRO_DECL ); +extern void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, BOOL bStackAffected, HB_MACRO_DECL ); +extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, BOOL, HB_MACRO_DECL ); extern void hb_compCodeBlockStart( HB_MACRO_DECL ); extern void hb_compCodeBlockEnd( HB_MACRO_DECL ); diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 2e1d5db0ef..58766f172d 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -339,9 +339,12 @@ int isatty( int handle ) void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ { void * pMem = malloc( ulSize ); + char * szSize [10]; + + sprintf( szSize, "%li", ulSize ); if( ! pMem ) - hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_MEMALLOC, NULL, NULL ); + hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_MEMALLOC, szSize, NULL ); return pMem; } @@ -349,9 +352,12 @@ void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on fail void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ { void * pResult = realloc( pMem, ulSize ); + char * szSize [10]; + + sprintf( szSize, "%li", ulSize ); if( ! pResult ) - hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_MEMREALLOC, NULL, NULL ); + hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_MEMREALLOC, szSize, NULL ); return pResult; } @@ -500,7 +506,7 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) if( ! pSym ) pSym = hb_compSymbolAdd( hb_strdup( szVarName ), &wPos ); pSym->cScope |= VS_MEMVAR; - hb_compGenPCode4( HB_P_PARAMETER, HB_LOBYTE( wPos ), HB_HIBYTE( wPos ), HB_LOBYTE( hb_comp_functions.pLast->wParamNum ) ); + hb_compGenPCode4( HB_P_PARAMETER, HB_LOBYTE( wPos ), HB_HIBYTE( wPos ), HB_LOBYTE( hb_comp_functions.pLast->wParamNum ), ( BOOL ) 0 ); } break; case VS_PRIVATE: @@ -559,7 +565,7 @@ void hb_compVariableAdd( char * szVarName, char cValueType ) memcpy( ( BYTE * ) ( & ( pBuffer[3] ) ), szVarName, strlen( szVarName ) + 1 ); - hb_compGenPCodeN( pBuffer, strlen( szVarName ) + 4 ); + hb_compGenPCodeN( pBuffer, strlen( szVarName ) + 4 , 0 ); hb_xfree( pBuffer ); } @@ -676,25 +682,27 @@ static PFUNCTION hb_compFunctionNew( char * szName, HB_SYMBOLSCOPE cScope ) PFUNCTION pFunc; pFunc = ( PFUNCTION ) hb_xgrab( sizeof( _FUNC ) ); - pFunc->szName = szName; - pFunc->cScope = cScope; - pFunc->pLocals = NULL; - pFunc->pStatics = NULL; - pFunc->pFields = NULL; - pFunc->pMemvars = NULL; - pFunc->pCode = NULL; - pFunc->lPCodeSize = 0; - pFunc->lPCodePos = 0; - pFunc->pNext = NULL; - pFunc->wParamCount = 0; - pFunc->wParamNum = 0; - pFunc->iStaticsBase = hb_comp_iStaticCnt; - pFunc->pOwner = NULL; - pFunc->bFlags = 0; - pFunc->iNOOPs = 0; - pFunc->iJumps = 0; - pFunc->pNOOPs = NULL; - pFunc->pJumps = NULL; + pFunc->szName = szName; + pFunc->cScope = cScope; + pFunc->pLocals = NULL; + pFunc->pStatics = NULL; + pFunc->pFields = NULL; + pFunc->pMemvars = NULL; + pFunc->pCode = NULL; + pFunc->lPCodeSize = 0; + pFunc->lPCodePos = 0; + pFunc->pNext = NULL; + pFunc->wParamCount = 0; + pFunc->wParamNum = 0; + pFunc->iStaticsBase = hb_comp_iStaticCnt; + pFunc->pOwner = NULL; + pFunc->bFlags = 0; + pFunc->iNOOPs = 0; + pFunc->iJumps = 0; + pFunc->pNOOPs = NULL; + pFunc->pJumps = NULL; + pFunc->iStackIndex = 0; + pFunc->iFunctionIndex = 0; return pFunc; } @@ -758,8 +766,8 @@ void hb_compFunctionAdd( char * szFunName, HB_SYMBOLSCOPE cScope, int iType ) hb_comp_ulLastLinePos = 0; /* optimization of line numbers opcode generation */ - hb_compGenPCode3( HB_P_FRAME, 0, 0 ); /* frame for locals and parameters */ - hb_compGenPCode3( HB_P_SFRAME, 0, 0 ); /* frame for statics variables */ + hb_compGenPCode3( HB_P_FRAME, 0, 0, ( BOOL ) 0 ); /* frame for locals and parameters */ + hb_compGenPCode3( HB_P_SFRAME, 0, 0, ( BOOL ) 0 ); /* frame for statics variables */ if( hb_comp_bDebugInfo ) { @@ -775,7 +783,7 @@ void hb_compFunctionAdd( char * szFunName, HB_SYMBOLSCOPE cScope, int iType ) memcpy( ( BYTE * ) ( &( pBuffer[ strlen( hb_comp_files.pLast->szFileName ) + 2 ] ) ), ( BYTE * ) szFunName, strlen( szFunName ) + 1 ); - hb_compGenPCodeN( pBuffer, 3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( szFunName ) ); + hb_compGenPCodeN( pBuffer, 3 + strlen( hb_comp_files.pLast->szFileName ) + strlen( szFunName ), 0 ); hb_xfree( pBuffer ); } @@ -1354,19 +1362,19 @@ ULONG hb_compGenJump( LONG lOffset ) /* Just a place holder, it might be a far jump...*/ if( lOffset == 0 ) { - hb_compGenPCode4( HB_P_JUMPFAR, 0, 0, 0 ); + hb_compGenPCode4( HB_P_JUMPFAR, 0, 0, 0, ( BOOL ) 0 ); } else if( lOffset >= -128 && lOffset <= 127 ) { - hb_compGenPCode4( HB_P_JUMPNEAR, HB_LOBYTE( lOffset ), HB_P_NOOP, HB_P_NOOP ); + hb_compGenPCode4( HB_P_JUMPNEAR, HB_LOBYTE( lOffset ), HB_P_NOOP, HB_P_NOOP, ( BOOL ) 0 ); } else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX ) { - hb_compGenPCode4( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_P_NOOP ); + hb_compGenPCode4( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_P_NOOP, ( BOOL ) 0 ); } else if( lOffset >= (-8388608L) && lOffset <= 8388607L ) { - hb_compGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ) ); + hb_compGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ), ( BOOL ) 0 ); } else { @@ -1383,19 +1391,19 @@ ULONG hb_compGenJumpFalse( LONG lOffset ) /* Just a place holder, it might be a far jump...*/ if( lOffset == 0 ) { - hb_compGenPCode4( HB_P_JUMPFALSEFAR, 0, 0, 0 ); + hb_compGenPCode4( HB_P_JUMPFALSEFAR, 0, 0, 0, ( BOOL ) 1 ); } else if( lOffset >= -128 && lOffset <= 127 ) { - hb_compGenPCode4( HB_P_JUMPFALSENEAR, HB_LOBYTE( lOffset ), HB_P_NOOP, HB_P_NOOP ); + hb_compGenPCode4( HB_P_JUMPFALSENEAR, HB_LOBYTE( lOffset ), HB_P_NOOP, HB_P_NOOP, ( BOOL ) 1 ); } else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX ) { - hb_compGenPCode4( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_P_NOOP ); + hb_compGenPCode4( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_P_NOOP, ( BOOL ) 1 ); } else if( lOffset >= (-8388608L) && lOffset <= 8388607L ) { - hb_compGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ) ); + hb_compGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ), ( BOOL ) 1 ); } else { @@ -1412,19 +1420,19 @@ ULONG hb_compGenJumpTrue( LONG lOffset ) /* Just a place holder, it might be a far jump...*/ if( lOffset == 0 ) { - hb_compGenPCode4( HB_P_JUMPTRUEFAR, 0, 0, 0 ); + hb_compGenPCode4( HB_P_JUMPTRUEFAR, 0, 0, 0, ( BOOL ) 1 ); } else if( lOffset >= -128 && lOffset <= 127 ) { - hb_compGenPCode4( HB_P_JUMPTRUENEAR, HB_LOBYTE( lOffset ), HB_P_NOOP, HB_P_NOOP ); + hb_compGenPCode4( HB_P_JUMPTRUENEAR, HB_LOBYTE( lOffset ), HB_P_NOOP, HB_P_NOOP, ( BOOL ) 1 ); } else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX ) { - hb_compGenPCode4( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_P_NOOP ); + hb_compGenPCode4( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_P_NOOP, ( BOOL ) 1 ); } else if( lOffset >= (-8388608L) && lOffset <= 8388607L ) { - hb_compGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ) ); + hb_compGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ), ( BOOL ) 1 ); } else { @@ -1617,7 +1625,7 @@ void hb_compLinePush( void ) /* generates the pcode with the currently compiled if( ( ( hb_comp_functions.pLast->lPCodePos - hb_comp_ulLastLinePos ) > 3 ) || hb_comp_bDebugInfo ) { hb_comp_ulLastLinePos = hb_comp_functions.pLast->lPCodePos; - hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( hb_comp_iLine ), HB_HIBYTE( hb_comp_iLine ) ); + hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( hb_comp_iLine ), HB_HIBYTE( hb_comp_iLine ), ( BOOL ) 0 ); } else { @@ -1750,7 +1758,7 @@ void hb_compGenVarPCode( BYTE bPCode, char * szVarName ) if( ! pSym ) pSym = hb_compSymbolAdd( szVarName, &wVar ); pSym->cScope |= VS_MEMVAR; - hb_compGenPCode3( bPCode, HB_LOBYTE( wVar ), HB_HIBYTE( wVar ) ); + hb_compGenPCode3( bPCode, HB_LOBYTE( wVar ), HB_HIBYTE( wVar ), ( BOOL ) 1 ); } void hb_compGenMessage( char * szMsgName ) /* sends a message to an object */ @@ -1761,7 +1769,7 @@ void hb_compGenMessage( char * szMsgName ) /* sends a message to an object if( ! pSym ) /* the symbol was not found on the symbol table */ pSym = hb_compSymbolAdd( szMsgName, &wSym ); pSym->cScope |= HB_FS_MESSAGE; - hb_compGenPCode3( HB_P_MESSAGE, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ) ); + hb_compGenPCode3( HB_P_MESSAGE, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ), ( BOOL ) 1 ); } void hb_compGenMessageData( char * szMsg ) /* generates an underscore-symbol name for a data assignment */ @@ -1800,12 +1808,12 @@ void hb_compGenPopVar( char * szVarName ) /* generates the pcode to pop a value * use 2 bytes for LOCALNEAR */ if( hb_comp_functions.pLast->szName ) - hb_compGenPCode3( HB_P_POPLOCALNEAR, ( BYTE ) iVar, 0 ); + hb_compGenPCode3( HB_P_POPLOCALNEAR, ( BYTE ) iVar, 0, ( BOOL ) 1 ); else - hb_compGenPCode2( HB_P_POPLOCALNEAR, ( BYTE ) iVar ); + hb_compGenPCode2( HB_P_POPLOCALNEAR, ( BYTE ) iVar, ( BOOL ) 1 ); } else - hb_compGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); } else { @@ -1824,7 +1832,7 @@ void hb_compGenPopVar( char * szVarName ) /* generates the pcode to pop a value { /* Static variable declared in current function */ - hb_compGenPCode3( HB_P_POPSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_POPSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); pFunc->bFlags |= FUN_USES_STATICS; } else @@ -1853,7 +1861,7 @@ void hb_compGenPopVar( char * szVarName ) /* generates the pcode to pop a value { /* Global static variable */ - hb_compGenPCode3( HB_P_POPSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_POPSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_USES_STATICS; } else @@ -1965,12 +1973,12 @@ void hb_compGenPushVar( char * szVarName ) * use 2 bytes for LOCALNEAR */ if( hb_comp_functions.pLast->szName ) - hb_compGenPCode3( HB_P_PUSHLOCALNEAR, ( BYTE ) iVar, 0 ); + hb_compGenPCode3( HB_P_PUSHLOCALNEAR, ( BYTE ) iVar, 0, ( BOOL ) 1 ); else - hb_compGenPCode2( HB_P_PUSHLOCALNEAR, ( BYTE ) iVar ); + hb_compGenPCode2( HB_P_PUSHLOCALNEAR, ( BYTE ) iVar, ( BOOL ) 1 ); } else - hb_compGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); } else { @@ -1979,7 +1987,7 @@ void hb_compGenPushVar( char * szVarName ) { /* Static variable declared in current function */ - hb_compGenPCode3( HB_P_PUSHSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_PUSHSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_USES_STATICS; } else @@ -2008,7 +2016,7 @@ void hb_compGenPushVar( char * szVarName ) { /* Global static variable */ - hb_compGenPCode3( HB_P_PUSHSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_PUSHSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_USES_STATICS; } else @@ -2054,7 +2062,7 @@ void hb_compGenPushVarRef( char * szVarName ) /* generates the pcode to push a v { /* local variable */ - hb_compGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); } else { @@ -2063,7 +2071,7 @@ void hb_compGenPushVarRef( char * szVarName ) /* generates the pcode to push a v { /* Static variable declared in current function */ - hb_compGenPCode3( HB_P_PUSHSTATICREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_PUSHSTATICREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_USES_STATICS; } else @@ -2091,7 +2099,7 @@ void hb_compGenPushVarRef( char * szVarName ) /* generates the pcode to push a v { /* Global static variable */ - hb_compGenPCode3( HB_P_PUSHSTATICREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ) ); + hb_compGenPCode3( HB_P_PUSHSTATICREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_USES_STATICS; } else @@ -2209,7 +2217,7 @@ void hb_compGenPushDouble( double dNumber, BYTE bDec ) pBuffer[ sizeof( double ) + 1 ] = bDec; - hb_compGenPCodeN( pBuffer, sizeof( double ) + 2 ); + hb_compGenPCodeN( pBuffer, sizeof( double ) + 2, 1 ); } void hb_compGenPushFunCall( char * szFunName ) @@ -2237,9 +2245,9 @@ void hb_compGenPushLong( long lNumber ) else if( ( ( char * ) &lNumber )[ 2 ] == 0 && ( ( char * ) &lNumber )[ 3 ] == 0 ) { if( ( ( char * ) &lNumber )[ 1 ] == 0 ) - hb_compGenPCode2( HB_P_PUSHBYTE, ( ( char * ) &lNumber )[ 0 ] ); + hb_compGenPCode2( HB_P_PUSHBYTE, ( ( char * ) &lNumber )[ 0 ], ( BOOL ) 1 ); else - hb_compGenPCode3( HB_P_PUSHINT, ( ( char * ) &lNumber )[ 0 ], ( ( char * ) &lNumber )[ 1 ] ); + hb_compGenPCode3( HB_P_PUSHINT, ( ( char * ) &lNumber )[ 0 ], ( ( char * ) &lNumber )[ 1 ], ( BOOL ) 1 ); } else { @@ -2251,7 +2259,7 @@ void hb_compGenPushLong( long lNumber ) pBuffer[3] = ( ( BYTE * ) &lNumber )[2]; pBuffer[4] = ( ( BYTE * ) &lNumber )[3]; - hb_compGenPCodeN( pBuffer, 5 ); + hb_compGenPCodeN( pBuffer, 5, 1 ); } } @@ -2270,7 +2278,7 @@ void hb_compGenPushString( char * szText, ULONG ulStrLen ) memcpy( ( BYTE *)( &( pBuffer[3] ) ), ( BYTE * ) szText, ulStrLen ); - hb_compGenPCodeN( pBuffer, ulStrLen + 3 ); + hb_compGenPCodeN( pBuffer, ulStrLen + 3, 1 ); } else { @@ -2281,7 +2289,7 @@ void hb_compGenPushString( char * szText, ULONG ulStrLen ) memcpy( ( BYTE *)( &( pBuffer[2] ) ), ( BYTE * ) szText, ulStrLen ); - hb_compGenPCodeN( pBuffer, ulStrLen + 2 ); + hb_compGenPCodeN( pBuffer, ulStrLen + 2, 1 ); } hb_xfree( pBuffer ); @@ -2305,9 +2313,9 @@ void hb_compGenPushSymbol( char * szSymbolName, int iIsFunction ) } if( wSym > 255 ) - hb_compGenPCode3( HB_P_PUSHSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ) ); + hb_compGenPCode3( HB_P_PUSHSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ), ( BOOL ) 1 ); else - hb_compGenPCode2( HB_P_PUSHSYMNEAR, ( BYTE ) wSym ); + hb_compGenPCode2( HB_P_PUSHSYMNEAR, ( BYTE ) wSym, ( BOOL ) 1 ); } @@ -2362,7 +2370,7 @@ void hb_compFinalizeFunction( void ) /* fixes all last defined function returns } else hb_compFixFuncPCode( pFunc ); - + if( hb_comp_iJumpOptimize && pFunc->iNOOPs ) hb_compOptimizeJumps(); @@ -2517,9 +2525,9 @@ static void hb_compOptimizeJumps( void ) BYTE * pCode = hb_comp_functions.pLast->pCode; ULONG * pNOOPs = hb_comp_functions.pLast->pNOOPs; ULONG * pJumps = hb_comp_functions.pLast->pJumps; - int * piShifts = ( int * ) hb_xgrab( sizeof( int ) * hb_comp_functions.pLast->iJumps ); ULONG ulOptimized = 0; ULONG ulNextByte = 0; + int * piShifts; int iNOOP; ULONG ulOffset; ULONG ulBytes2Copy; @@ -2529,6 +2537,8 @@ static void hb_compOptimizeJumps( void ) /* Needed so the pasting of PCODE pieces below will work correctly */ qsort( ( void * ) pNOOPs, hb_comp_functions.pLast->iNOOPs, sizeof( ULONG ), hb_compSort_ULONG ); + if ( hb_comp_functions.pLast->iJumps ) + piShifts = ( int * ) hb_xgrab( sizeof( int ) * hb_comp_functions.pLast->iJumps ); for( iJump = 0; iJump < hb_comp_functions.pLast->iJumps; iJump++ ) piShifts[ iJump ] = 0; @@ -2653,7 +2663,7 @@ static void hb_compOptimizeJumps( void ) */ ULONG hb_compSequenceBegin( void ) { - hb_compGenPCode4( HB_P_SEQBEGIN, 0, 0, 0 ); + hb_compGenPCode4( HB_P_SEQBEGIN, 0, 0, 0, ( BOOL ) 0 ); hb_compPrepareOptimize(); @@ -2669,7 +2679,7 @@ ULONG hb_compSequenceBegin( void ) */ ULONG hb_compSequenceEnd( void ) { - hb_compGenPCode4( HB_P_SEQEND, 0, 0, 0 ); + hb_compGenPCode4( HB_P_SEQEND, 0, 0, 0, ( BOOL ) 0 ); hb_compPrepareOptimize(); @@ -2756,9 +2766,9 @@ void hb_compStaticDefStart( void ) pBuffer[ 3 ] = 1; /* the number of static variables is unknown now */ pBuffer[ 4 ] = 0; - hb_compGenPCodeN( pBuffer, 5 ); + hb_compGenPCodeN( pBuffer, 5, 0 ); - hb_compGenPCode3( HB_P_SFRAME, 0, 0 ); /* frame for statics variables */ + hb_compGenPCode3( HB_P_SFRAME, 0, 0, ( BOOL ) 0 ); /* frame for statics variables */ } else { @@ -2838,24 +2848,24 @@ void hb_compCodeBlockEnd( void ) /* NOTE: 8 = HB_P_PUSHBLOCK + USHORT( size ) + USHORT( wParams ) + USHORT( wLocals ) + _ENDBLOCK */ wSize = ( USHORT ) pCodeblock->lPCodePos + 8 + wLocals * 2; - hb_compGenPCode3( HB_P_PUSHBLOCK, HB_LOBYTE( wSize ), HB_HIBYTE( wSize ) ); - hb_compGenPCode2( HB_LOBYTE( pCodeblock->wParamCount ), HB_HIBYTE( pCodeblock->wParamCount ) ); - hb_compGenPCode2( HB_LOBYTE( wLocals ), HB_HIBYTE( wLocals ) ); + hb_compGenPCode3( HB_P_PUSHBLOCK, HB_LOBYTE( wSize ), HB_HIBYTE( wSize ), ( BOOL ) 1 ); + hb_compGenPCode2( HB_LOBYTE( pCodeblock->wParamCount ), HB_HIBYTE( pCodeblock->wParamCount ), ( BOOL ) 0 ); + hb_compGenPCode2( HB_LOBYTE( wLocals ), HB_HIBYTE( wLocals ), ( BOOL ) 0 ); /* generate the table of referenced local variables */ pVar = pCodeblock->pStatics; while( wLocals-- ) { wPos = hb_compVariableGetPos( pFunc->pLocals, pVar->szName ); - hb_compGenPCode2( HB_LOBYTE( wPos ), HB_HIBYTE( wPos ) ); + hb_compGenPCode2( HB_LOBYTE( wPos ), HB_HIBYTE( wPos ), ( BOOL ) 0 ); pFree = pVar; hb_xfree( ( void * ) pFree->szName ); pVar = pVar->pNext; hb_xfree( ( void * ) pFree ); } - - hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos ); + + hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, ( BOOL ) 1 ); hb_compGenPCode1( HB_P_ENDBLOCK ); /* finish the codeblock */ /* this fake-function is no longer needed */ diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 6bfb155b70..ab4eef42b7 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -237,7 +237,7 @@ Main : { hb_compLinePush(); } Source { } | /* empty file */ ; -Source : Crlf { hb_comp_EOL = FALSE; } +Source : Crlf { hb_comp_EOL = FALSE; } | VarDefs { hb_comp_EOL = FALSE; } | FieldsDef { hb_comp_EOL = FALSE; } | MemvarDef { hb_comp_EOL = FALSE; } @@ -303,12 +303,12 @@ Statement : ExecFlow CrlfStmnt { } | ExprPostOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | ExprOperEq CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | ExprEqual CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } + | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } | DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | BREAK CrlfStmnt { hb_compGenBreak(); hb_compGenPCode2( HB_P_DOSHORT, 0 ); + | BREAK CrlfStmnt { hb_compGenBreak(); hb_compGenPCode2( HB_P_DOSHORT, 0, ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | BREAK { hb_compLinePushIfInside(); } Expression Crlf { hb_compGenBreak(); hb_compExprDelete( hb_compExprGenPush( $3 ) ); - hb_compGenPCode2( HB_P_DOSHORT, 1 ); + hb_compGenPCode2( HB_P_DOSHORT, 1, ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | RETURN CrlfStmnt { @@ -331,7 +331,7 @@ Statement : ExecFlow CrlfStmnt { } hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); } hb_compExprGenPush( $3 ); /* TODO: check if return value agree with declared value */ - hb_compGenPCode2( HB_P_RETVALUE, HB_P_ENDPROC ); + hb_compGenPCode2( HB_P_RETVALUE, HB_P_ENDPROC, ( BOOL ) 1 ); if( hb_comp_functions.pLast->bFlags & FUN_PROCEDURE ) { /* procedure returns a value */ hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PROC_RETURN_VALUE, NULL, NULL ); @@ -1035,14 +1035,14 @@ ExtVarDef : VarDef { USHORT uCount = hb_compExprListLen( $2 ); hb_compExprDelete( hb_compExprGenPush( $2 ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); + hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); hb_compRTVariableAdd( hb_compExprNewRTVar( NULL, $1 ), TRUE ); } | MacroVar DimList AS_ARRAY { USHORT uCount = hb_compExprListLen( $2 ); hb_compExprDelete( hb_compExprGenPush( $2 ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); + hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); hb_compRTVariableAdd( hb_compExprNewRTVar( NULL, $1 ), TRUE ); } ; @@ -1366,7 +1366,7 @@ RecoverEmpty : RECOVER hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; $$ = hb_comp_functions.pLast->lPCodePos; --hb_comp_wSeqCounter; - hb_compGenPCode2( HB_P_SEQRECOVER, HB_P_POP ); + hb_compGenPCode2( HB_P_SEQRECOVER, HB_P_POP, ( BOOL ) 1 ); } ; @@ -1829,9 +1829,9 @@ static void hb_compRTVariableGen( char * szCreateFun ) /* call function that will create either PUBLIC or PRIVATE variables */ if( usCount > 255 ) - hb_compGenPCode3( HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + hb_compGenPCode3( HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ), ( BOOL ) 1 ); else - hb_compGenPCode2( HB_P_DOSHORT, ( BYTE ) usCount ); + hb_compGenPCode2( HB_P_DOSHORT, ( BYTE ) usCount, ( BOOL ) 1 ); /* pop initial values */ while( pVar ) @@ -1854,7 +1854,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) USHORT uCount = hb_compExprListLen( pInitValue ); hb_compVariableAdd( szName, 'A' ); hb_compExprDelete( hb_compExprGenPush( pInitValue ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); + hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); hb_compRTVariableAdd( hb_compExprNewRTVar( szName, NULL ), TRUE ); } else if( hb_comp_iVarScope == VS_STATIC ) @@ -1868,7 +1868,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) hb_compStaticDefStart(); /* switch to statics pcode buffer */ /* create an array */ hb_compExprGenPush( pInitValue ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); + hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); /* check if valid initializers were used but don't generate any code */ pAssign = hb_compExprAssignStatic( pVar, pInitValue ); /* now pop an array */ @@ -1883,7 +1883,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) hb_compVariableAdd( szName, 'A' ); hb_compExprDelete( hb_compExprGenPush( pInitValue ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) ); + hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName ) ) ); } } diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index b59176c756..06c384b5a9 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -64,8 +64,8 @@ char * hb_comp_szErrors[] = "Formal parameters already declared", "Invalid %s from within of SEQUENCE code", "Unterminated array index", - "Memory allocation error", - "Memory reallocation error", + "Could not allocate [%s] bytes", + "Could not re-allocate [%s] bytes", "Freeing a NULL memory pointer", "Syntax error: \"%s at \'%s\'\"", "Jump offset too long", @@ -99,13 +99,10 @@ char * hb_comp_szWarnings[] = "1Procedure returns value", "1Function \'%s\' does not end with RETURN statement", "3Incompatible type in assignment to: \'%s\' expected: \'%s\'", - "3Incompatible operand type: \'%s\' expected: \'Logical\'", - "3Incompatible operand type: \'%s\' expected: \'Numeric\'", + "3Incompatible operand type: \'%s\' expected: \'%s\'", "3Incompatible operand types: \'%s\' and: \'%s\'", "3Suspicious type in assignment to: \'%s\' expected: \'%s\'", "3Suspicious operand type: \'UnKnown\' expected: \'%s\'", - "3Suspicious operand type: \'UnKnown\' expected: \'Logical\'", - "3Suspicious operand type: \'UnKnown\' expected: \'Numeric\'", "0Meaningless use of expression: \'%s\'", "2Unreachable code", "1Redundant \'ANNOUNCE %s\' statement ignored" @@ -114,7 +111,7 @@ char * hb_comp_szWarnings[] = void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ) { int iLine = hb_comp_iLine; - + if( hb_comp_EOL ) --iLine; if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) @@ -134,14 +131,14 @@ void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, char * { char * szText = szWarnings[ iWarning - 1 ]; int iLine = hb_comp_iLine; - + if( hb_comp_EOL ) --iLine; if( ( szText[ 0 ] - '0' ) <= hb_comp_iWarnings ) { if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, iLine + hb_pp_nEmptyStrings ); + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, iLine + hb_pp_nEmptyStrings ); printf( "Warning %c%04i ", cPrefix, iWarning ); printf( szText + 1, szWarning1, szWarning2 ); printf( "\n" ); diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index 2fd540bad8..ff7bfbcbf5 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -33,6 +33,17 @@ * */ +/* + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * Copyright 2000 RonPinkas + * hb_compStrongType() + * + * See doc/license.txt for licensing terms. + * + */ + #include #include "hbcomp.h" @@ -190,6 +201,553 @@ void hb_compPCodeEval( PFUNCTION pFunc, HB_PCODE_FUNC_PTR * pFunctions, void * c } +void hb_compStrongType( int iSize ) +{ + PFUNCTION pFunc = hb_comp_functions.pLast, pTmp; + PVAR pVar; + PCOMSYMBOL pSym; + ULONG ulPos = pFunc->lPCodePos - iSize; + SHORT wVar; + int iVar; + char szType1[2], szType2[2]; + BYTE bLast1, bLast2; + + /* TODO Split under conitions for the different matching possible iSize. */ + + switch ( pFunc->pCode[ ulPos ] ) + { + /*-----------------4/26/00 0:16AM------------------- + * Push values on stack. + * --------------------------------------------------*/ + + case HB_P_SWAPALIAS : + case HB_P_RETVALUE : + /* TODO Check effect on stack. */ + break; + + case HB_P_DO : + case HB_P_DOSHORT : + case HB_P_FUNCTION : + case HB_P_FUNCTIONSHORT : + + /* TODO: Add support for Function Parameters Declaration. */ + + /* Removing all the optional parameters. */ + pFunc->iStackIndex = pFunc->pFunctionCalls[ pFunc->iFunctionIndex--] ; + /* Function Type already on stack at this position. */ + break; + + /* Subject to Operator Overloading - Don't expect Numeric! */ + case HB_P_DEC : + case HB_P_INC : + break; + + case HB_P_JUMPFALSENEAR : + case HB_P_JUMPFALSE : + case HB_P_JUMPFALSEFAR : + case HB_P_JUMPTRUENEAR : + case HB_P_JUMPTRUE : + case HB_P_JUMPTRUEFAR : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + sprintf( szType1, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); + + if ( pFunc->pStack[ pFunc->iStackIndex ] == 'L' ) + ; + else if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); + else + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, szType1, "L" ); + + break; + + case HB_P_INSTRING : + + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 1 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + sprintf( szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); + sprintf( szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); + + if ( ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) || + ( pFunc->pStack[ pFunc->iStackIndex ] == 'C' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == 'C' ) ) + ; + else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "C", NULL ); + else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'C' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, szType1, "C" ); + else if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "C", NULL ); + else if ( pFunc->pStack[ pFunc->iStackIndex ] != 'C' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, szType2, "C" ); + + /* Override the last item with the new result type */ + pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'L'; + break; + + /* May be subject to Operator Overloading - don't restrict to Numeric! */ + case HB_P_DIVIDE : + case HB_P_PLUS : + case HB_P_NEGATE : + case HB_P_MULT : + case HB_P_POWER : + case HB_P_EQUAL : + case HB_P_EXACTLYEQUAL : + case HB_P_NOTEQUAL : + case HB_P_GREATER : + case HB_P_GREATEREQUAL : + case HB_P_LESSEQUAL : + case HB_P_LESS : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 1 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + sprintf( szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); + sprintf( szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); + + if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) + /* Override the last item with the new result type wich is already there */ + ; + else if ( pFunc->pStack[ pFunc->iStackIndex ] == pFunc->pStack[ pFunc->iStackIndex - 1 ] ) + /* Override the last item with the new result type wich is already there */ + ; + else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) + { + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, szType2, NULL ); + + /* Override the last item with the new result type */ + pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; + } + else if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + { + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, szType1, NULL ); + + /* Override the last item with the new result type wich is already there */ + } + else + { + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERANDS_INCOMPATBLE, szType1, szType2 ); + + /* Override the last item with the new result type */ + pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; + } + + break; + + /* Should we allow Operator Overloading here too? */ + case HB_P_AND : + case HB_P_NOT : + case HB_P_OR : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + sprintf( szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); + sprintf( szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); + + if ( ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) || + ( pFunc->pStack[ pFunc->iStackIndex ] == 'L' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == 'L' ) ) + ; + else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); + else if ( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'L' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, szType1, "L" ); + else if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); + else if ( pFunc->pStack[ pFunc->iStackIndex ] != 'L' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, szType2, "L" ); + + /* Override the last item with the new result type */ + pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'L'; + break; + + case HB_P_DUPLICATE : + bLast1 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; + pFunc->pStack[ pFunc->iStackIndex++ ] = bLast1; + break; + + case HB_P_DUPLTWO : + bLast1 = pFunc->pStack[ pFunc->iStackIndex - 2 ]; + bLast2 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; + pFunc->pStack[ pFunc->iStackIndex++ ] = bLast1; + pFunc->pStack[ pFunc->iStackIndex++ ] = bLast2; + break; + /* Explicit Types. */ + + /* Objects */ + case HB_P_PUSHSELF : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'O'; + break; + + /* Blcks */ + case HB_P_MPUSHBLOCK : + case HB_P_PUSHBLOCK : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'B'; + break; + + /* Undefined */ + case HB_P_PUSHNIL : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'U'; + break; + + /* Logicals */ + case HB_P_TRUE : + case HB_P_FALSE : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'L'; + break; + + /* Numerics */ + case HB_P_PUSHDOUBLE : + case HB_P_PUSHLONG : + case HB_P_PUSHINT : + case HB_P_PUSHBYTE : + case HB_P_ZERO : + case HB_P_ONE : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'N'; + break; + + /* Charcters */ + case HB_P_PUSHSTRSHORT : + case HB_P_PUSHSTR : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'C'; + break; + + case HB_P_PUSHSYM : + case HB_P_MPUSHSYM : + pFunc->pFunctionCalls[ pFunc->iFunctionIndex++ ] = pFunc->iStackIndex; + + pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256 ); + + if ( pVar ) + pFunc->pStack[ pFunc->iStackIndex++ ] = pSym->cType; + else + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + + break; + + case HB_P_PUSHSYMNEAR : + pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] ); + + if ( pSym ) + { + /* TODO: Check this!!! */ + if ( pSym->cScope & HB_FS_PUBLIC == HB_FS_PUBLIC || + pSym->cScope & HB_FS_STATIC == HB_FS_STATIC || + pSym->cScope & HB_FS_INIT == HB_FS_INIT || + pSym->cScope & HB_FS_EXIT == HB_FS_EXIT ) + /* Storing a Book Mark of the last pushed symbol so we know how many bytes to pop when encountering function call. */ + pFunc->pFunctionCalls[ pFunc->iFunctionIndex++ ] = pFunc->iStackIndex; + + pFunc->pStack[ pFunc->iStackIndex++ ] = pSym->cType; + } + else + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + + break; + + /* Local Variables */ + + case HB_P_PUSHLOCAL : + wVar = * ( ( SHORT * ) &( pFunc->pCode )[ ulPos + 1 ] ); + + /* we are accesing variables within a codeblock */ + if( wVar < 0 ) + /* TODO: Deal with Codeblock Refernced locals. */ + ; + else + pVar = hb_compVariableFind( pFunc->pLocals, wVar ); + + if ( pVar ) + { + /* Review with Ryszard. */ + if ( pVar->cType == 'U' ) + pVar->cType = ' '; + + pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType; + } + else + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + + break; + + case HB_P_PUSHLOCALREF : + /* QUESTION: Fall from above, or use a "REFERENCED" type. */ + pFunc->pStack[ pFunc->iStackIndex++ ] = 'R'; + break; + + case HB_P_PUSHLOCALNEAR : + iVar = pFunc->pCode[ ulPos + 1 ]; + + /* we are accesing variables within a codeblock */ + if( iVar < 0 ) + /* TODO: Deal with Codeblock Refernced locals. */ + ; + else + pVar = hb_compVariableFind( pFunc->pLocals, iVar ); + + if ( pVar ) + { + /* Review with Ryszard. */ + if ( pVar->cType == 'U' ) + pVar->cType = ' '; + + pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType; + } + else + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + + break; + + /* Static Variables */ + + case HB_P_PUSHSTATIC : + pTmp = hb_comp_functions.pFirst; + wVar = pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256; + + while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar ) + pTmp = pTmp->pNext; + + pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase ); + + if ( pVar ) + { + /* Review with Ryszard. */ + if ( pVar->cType == 'U' ) + pVar->cType = ' '; + + pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType; + } + else + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + + break; + + case HB_P_PUSHSTATICREF : + /* Question use type "REFERENCE" or the base type of the var */ + pFunc->pStack[ pFunc->iStackIndex++ ] = 'R'; + + /* MemVars */ + + case HB_P_PUSHVARIABLE : + case HB_P_PUSHMEMVAR : + pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256 ); + if ( pSym ) + { + /* Review with Ryszard. */ + if ( pVar->cType == 'U' ) + pVar->cType = ' '; + + pFunc->pStack[ pFunc->iStackIndex++ ] = pSym->cType; + } + else + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + + case HB_P_PUSHMEMVARREF : + pFunc->pStack[ pFunc->iStackIndex++ ] = 'R'; + + /* Arrays. */ + + case HB_P_ARRAYPUSH : + /* TODO: Deal with Array Elements. */ + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + break; + + /* Macros type unknown */ + case HB_P_MPUSHALIASEDFIELD : + case HB_P_MPUSHALIASEDVAR : + case HB_P_MPUSHFIELD : + case HB_P_MPUSHMEMVAR : + case HB_P_MPUSHMEMVARREF : + case HB_P_MPUSHVARIABLE : + case HB_P_MACROPUSHALIASED : + case HB_P_MACROPUSH : + pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; + break; + + case HB_P_MACROSYMBOL : + /* TODO: check affect on stack. */ + case HB_P_MACROTEXT : + /* TODO: check affect on stack. */ + break; + + /*-----------------4/26/00 0:15AM------------------- + * Begin POP Check and Remove from Stack. + * --------------------------------------------------*/ + + case HB_P_POP : + case HB_P_POPALIAS : + case HB_P_POPFIELD : + /* TODO: Add support for FIELD declarations. */ + case HB_P_POPALIASEDFIELD : + /* TODO: Add support for FIELD declarations. */ + pFunc->iStackIndex--; + break; + + case HB_P_POPMEMVAR : + case HB_P_POPVARIABLE : + case HB_P_POPALIASEDVAR : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256 ); + + if ( pSym->cType != ' ' ) + { + char szType[2]; + sprintf( szType, "%c", pSym->cType ); + + if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pSym->szName, szType ); + else if ( pSym->cType != pFunc->pStack[ pFunc->iStackIndex ] ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pSym->szName, szType ); + } + + break; + + case HB_P_POPLOCAL : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + wVar = * ( ( SHORT * ) &( pFunc->pCode )[ ulPos + 1 ] ); + + /* we are accesing variables within a codeblock */ + if( wVar < 0 ) + /* TODO: Deal with Codeblock Refernced locals. */ + ; + else + pVar = hb_compVariableFind( pFunc->pLocals, wVar ); + + if ( pVar->cType != ' ' ) + { + char szType[2]; + sprintf( szType, "%c", pVar->cType ); + + if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, szType ); + else if ( pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, szType ); + } + + break; + + case HB_P_POPLOCALNEAR : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + iVar = pFunc->pCode[ ulPos + 1 ]; + + /* we are accesing variables within a codeblock */ + if( iVar < 0 ) + /* TODO: Deal with Codeblock Refernced locals. */ + ; + else + pVar = hb_compVariableFind( pFunc->pLocals, iVar ); + + if ( pVar->cType != ' ' ) + { + char szType[2]; + sprintf( szType, "%c", pVar->cType ); + + if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, szType ); + else if ( pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, szType ); + } + + break; + + case HB_P_POPSTATIC : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + pTmp = hb_comp_functions.pFirst; + wVar = pFunc->pCode[ ulPos + 1 ] + pFunc->pCode[ ulPos + 2 ] * 256; + + while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar ) + pTmp = pTmp->pNext; + + pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase ); + + if ( pVar->cType != ' ' ) + { + char szType[2]; + sprintf( szType, "%c", pVar->cType ); + + if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, szType ); + else if ( pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, szType ); + } + + break; + + /* Macros Undefined Types */ + + case HB_P_MPOPALIASEDFIELD : + case HB_P_MPOPALIASEDVAR : + case HB_P_MPOPFIELD : + case HB_P_MPOPMEMVAR : + case HB_P_MACROPOP : + case HB_P_MACROPOPALIASED : + pFunc->iStackIndex--; + break; + + case HB_P_ARRAYPOP : + pFunc->iStackIndex--; + + if ( pFunc->iStackIndex < 0 ) + /* TODO Error Message after finalizing all possible pcodes. */ + break; + + /* TODO: Deal with Array Elements. */ + if ( pFunc->pStack[ pFunc->iStackIndex ] != ' ' ) + { + } + + break; + + case HB_P_ARRAYDIM : + pFunc->iStackIndex -= 2; + /* TODO: Deal with Array Elements. */ + /* Pop the values used to generate the array. */ + break; + + case HB_P_ARRAYGEN : + pFunc->iStackIndex -= 2; + /* TODO: Deal with Array Elements. */ + /* Pop the values used to generate the array. */ + break; + } + + /* TODO Error or trace messages when completed. */ + if ( pFunc->iStackIndex < 0 ) + pFunc->iStackIndex = 0; + else if ( pFunc->iStackIndex > 255 ) + pFunc->iStackIndex = 255; +} void hb_compGenPCode1( BYTE byte ) { @@ -205,9 +763,12 @@ void hb_compGenPCode1( BYTE byte ) pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK ); pFunc->pCode[ pFunc->lPCodePos++ ] = byte; + + if ( hb_comp_iWarnings >= 3 ) + hb_compStrongType( 1 ); } -void hb_compGenPCode2( BYTE byte1, BYTE byte2 ) +void hb_compGenPCode2( BYTE byte1, BYTE byte2, BOOL bStackAffected ) { PFUNCTION pFunc = hb_comp_functions.pLast; /* get the currently defined Clipper function */ @@ -222,9 +783,12 @@ void hb_compGenPCode2( BYTE byte1, BYTE byte2 ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte1; pFunc->pCode[ pFunc->lPCodePos++ ] = byte2; + + if ( hb_comp_iWarnings >= 3 && bStackAffected ) + hb_compStrongType( 2 ); } -void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3 ) +void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, BOOL bStackAffected ) { PFUNCTION pFunc = hb_comp_functions.pLast; /* get the currently defined Clipper function */ @@ -240,9 +804,12 @@ void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3 ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte1; pFunc->pCode[ pFunc->lPCodePos++ ] = byte2; pFunc->pCode[ pFunc->lPCodePos++ ] = byte3; + + if ( hb_comp_iWarnings >= 3 && bStackAffected ) + hb_compStrongType( 3 ); } -void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4 ) +void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, BOOL bStackAffected ) { PFUNCTION pFunc = hb_comp_functions.pLast; /* get the currently defined Clipper function */ @@ -259,9 +826,12 @@ void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4 ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte2; pFunc->pCode[ pFunc->lPCodePos++ ] = byte3; pFunc->pCode[ pFunc->lPCodePos++ ] = byte4; + + if ( hb_comp_iWarnings >= 3 && bStackAffected ) + hb_compStrongType( 4 ); } -void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize ) +void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, BOOL bStackAffected ) { PFUNCTION pFunc = hb_comp_functions.pLast; /* get the currently defined Clipper function */ @@ -280,5 +850,7 @@ void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize ) memcpy( pFunc->pCode + pFunc->lPCodePos, pBuffer, ulSize ); pFunc->lPCodePos += ulSize; -} + if ( hb_comp_iWarnings >= 3 && bStackAffected ) + hb_compStrongType( ulSize ); +} diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 1f04c32c94..622cf2cceb 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -755,7 +755,7 @@ ULONG hb_compGenJump( LONG lOffset, HB_MACRO_DECL ) if( lOffset < ( LONG ) SHRT_MIN || lOffset > ( LONG ) SHRT_MAX ) hb_macroError( HB_MACRO_TOO_COMPLEX, HB_MACRO_PARAM ); - hb_compGenPCode3( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BOOL ) 0, HB_MACRO_PARAM ); return HB_PCODE_DATA->lPCodePos - 2; } @@ -767,7 +767,7 @@ ULONG hb_compGenJumpFalse( LONG lOffset, HB_MACRO_DECL ) if( lOffset < ( LONG ) SHRT_MIN || lOffset > ( LONG ) SHRT_MAX ) hb_macroError( HB_MACRO_TOO_COMPLEX, HB_MACRO_PARAM ); - hb_compGenPCode3( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BOOL ) 1, HB_MACRO_PARAM ); return HB_PCODE_DATA->lPCodePos - 2; } @@ -798,7 +798,7 @@ ULONG hb_compGenJumpTrue( LONG lOffset, HB_MACRO_DECL ) if( lOffset < ( LONG ) SHRT_MIN || lOffset > ( LONG ) SHRT_MAX ) hb_macroError( HB_MACRO_TOO_COMPLEX, HB_MACRO_PARAM ); - hb_compGenPCode3( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BOOL ) 1, HB_MACRO_PARAM ); return HB_PCODE_DATA->lPCodePos - 2; } @@ -833,7 +833,7 @@ void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_MACRO_DECL ) pSym = hb_dynsymGet( szVarName ); } hb_compGenPCode1( bPCode, HB_MACRO_PARAM ); - hb_compGenPCodeN( ( BYTE * )( &pSym ), sizeof( pSym ), HB_MACRO_PARAM ); + hb_compGenPCodeN( ( BYTE * )( &pSym ), sizeof( pSym ), ( BOOL ) 0, HB_MACRO_PARAM ); } /* generates the pcode to push a symbol on the virtual machine stack */ @@ -861,7 +861,7 @@ void hb_compGenPushSymbol( char * szSymbolName, int isFunction, HB_MACRO_DECL ) pSym = hb_dynsymGet( szSymbolName ); hb_compGenPCode1( HB_P_MPUSHSYM, HB_MACRO_PARAM ); - hb_compGenPCodeN( ( BYTE * ) &pSym, sizeof( pSym ), HB_MACRO_PARAM ); + hb_compGenPCodeN( ( BYTE * ) &pSym, sizeof( pSym ), ( BOOL ) 0, HB_MACRO_PARAM ); } /* generates the pcode to push a long number on the virtual machine stack */ @@ -888,7 +888,7 @@ void hb_compGenMessage( char * szMsgName, HB_MACRO_DECL ) HB_DYNS_PTR pSym = hb_dynsymGet( szMsgName ); hb_compGenPCode1( HB_P_MMESSAGE, HB_MACRO_PARAM ); - hb_compGenPCodeN( ( BYTE * ) &pSym, sizeof( pSym ), HB_MACRO_PARAM ); + hb_compGenPCodeN( ( BYTE * ) &pSym, sizeof( pSym ), ( BOOL ) 0, HB_MACRO_PARAM ); } /* generates an underscore-symbol name for a data assignment */ @@ -915,7 +915,7 @@ void hb_compGenPopVar( char * szVarName, HB_MACRO_DECL ) if( iVar ) { /* this is a codeblock parameter */ - hb_compGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1, HB_MACRO_PARAM ); } else { @@ -996,7 +996,7 @@ void hb_compGenPushVar( char * szVarName, HB_MACRO_DECL ) if( iVar ) { /* this is a codeblock parameter */ - hb_compGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1, HB_MACRO_PARAM ); } else { @@ -1015,7 +1015,7 @@ void hb_compGenPushVarRef( char * szVarName, HB_MACRO_DECL ) iVar = hb_compLocalVarGetPos( szVarName, HB_MACRO_PARAM ); if( iVar ) - hb_compGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), ( BOOL ) 1, HB_MACRO_PARAM ); else { hb_compMemvarGenPCode( HB_P_MPUSHMEMVARREF, szVarName, HB_MACRO_PARAM ); @@ -1097,7 +1097,7 @@ void hb_compGenPushLogical( int iTrueFalse, HB_MACRO_DECL ) void hb_compGenPushDouble( double dNumber, BYTE bDec, HB_MACRO_DECL ) { hb_compGenPCode1( HB_P_PUSHDOUBLE, HB_MACRO_PARAM ); - hb_compGenPCodeN( ( BYTE * ) &dNumber, sizeof( double ), HB_MACRO_PARAM ); + hb_compGenPCodeN( ( BYTE * ) &dNumber, sizeof( double ), ( BOOL ) 0, HB_MACRO_PARAM ); hb_compGenPCode1( bDec, HB_MACRO_PARAM ); } @@ -1122,8 +1122,8 @@ void hb_compGenPushFunCall( char * szFunName, HB_MACRO_DECL ) /* generates the pcode to push a string on the virtual machine stack */ void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_MACRO_DECL ) { - hb_compGenPCode3( HB_P_PUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_MACRO_PARAM ); - hb_compGenPCodeN( ( BYTE * ) szText, ulStrLen, HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_PUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), ( BOOL ) 1, HB_MACRO_PARAM ); + hb_compGenPCodeN( ( BYTE * ) szText, ulStrLen, ( BOOL ) 0, HB_MACRO_PARAM ); } @@ -1137,7 +1137,7 @@ void hb_compGenPCode1( BYTE byte, HB_MACRO_DECL ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte; } -void hb_compGenPCode2( BYTE byte1, BYTE byte2, HB_MACRO_DECL ) +void hb_compGenPCode2( BYTE byte1, BYTE byte2, BOOL bStackAffected, HB_MACRO_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1148,7 +1148,7 @@ void hb_compGenPCode2( BYTE byte1, BYTE byte2, HB_MACRO_DECL ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte2; } -void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_MACRO_DECL ) +void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, BOOL bStackAffected, HB_MACRO_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1160,7 +1160,7 @@ void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_MACRO_DECL ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte3; } -void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_MACRO_DECL ) +void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, BOOL bStackAffected, HB_MACRO_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1173,7 +1173,7 @@ void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_MACRO_ pFunc->pCode[ pFunc->lPCodePos++ ] = byte4; } -void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_MACRO_DECL ) +void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, BOOL bStackAffected, HB_MACRO_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1260,12 +1260,12 @@ void hb_compCodeBlockEnd( HB_MACRO_DECL ) /*NOTE: HB_P_MPUSHBLOCK differs from HB_P_PUSHBLOCK - the pcode * is stored in dynamic memory pool instead of static memory */ - hb_compGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( wSize ), HB_HIBYTE( wSize ), HB_MACRO_PARAM ); + hb_compGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( wSize ), HB_HIBYTE( wSize ), ( BOOL ) 1, HB_MACRO_PARAM ); hb_compGenPCode1( HB_LOBYTE( wParms ), HB_MACRO_PARAM ); hb_compGenPCode1( HB_HIBYTE( wParms ), HB_MACRO_PARAM ); /* copy a codeblock pcode buffer */ - hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, HB_MACRO_PARAM ); + hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, ( BOOL ) 1, HB_MACRO_PARAM ); hb_compGenPCode1( HB_P_ENDBLOCK, HB_MACRO_PARAM ); /* finish the codeblock */ /* free memory allocated for a codeblock */ diff --git a/harbour/tests/testwarn.prg b/harbour/tests/testwarn.prg index 99045880c1..d261866827 100644 --- a/harbour/tests/testwarn.prg +++ b/harbour/tests/testwarn.prg @@ -18,8 +18,9 @@ FUNCTION Main() FUNCTION Hex2Dec( lVar AS LOGICAL ) LOCAL nVar AS NUMERIC, cVar AS CHARACTER, lVar2 AS LOGICAL, nNoType := 3 + PRIVATE cMemVar1 AS CHARACTER - nVar := .T. + nVar := .T. nVar := 1 @@ -37,9 +38,11 @@ FUNCTION Hex2Dec( lVar AS LOGICAL ) cVar := nVar - NondDeclared := 2 + M->cMemVar1 := 2 - cVar := {|x,y,z| nMyFunc( 3 ) } + NondDeclared := 2 + + cVar := {|n AS NUMERIC , c AS CHARACTER, d AS DATE| n := nMyFunc( n,c,d ), c := 2 } nVar := 8 + cVar