diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 13892284ec..104acebd60 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,18 @@ +2001-07-18 16:10 UTC-0800 Ron Pinkas + * source/vm/macro.c + * source/vm/hvm.c + % Simplified logic for suppoting macro lists. Removed global variables: + int hb_vm_iFunCalls = 0, *hb_vm_aiMacroListParameters = NULL, hb_vm_iMacroListAllocated + which are no longer needed. No longer using any logic in any PCODE case, other than HB_P_PUSHMACROARG. + No longer using any arrays, or memory allocations. + + * include/hbexpra.c + * include/hbexprb.c + * HB_P_PUSHMACROARG will now be followed with a push symbol sequence, indicating its parrent function call. + + * include/hbpcode.h + * Added decimal values into the description comments for readability. + 2001-07-18 12:17 GMT+1 Antonio Linares * source/rtl/seconds.c + Added Clocks2Secs() function diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index d2512e64c2..0d9d65152c 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -130,6 +130,7 @@ static BYTE s_PrecedTable[] = { }; BOOL hb_exp_bArgList = FALSE; +HB_EXPR_PTR hb_exp_pSelf; static HB_CBVAR_PTR hb_compExprCBVarNew( char *, BYTE ); diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index f2930d6f4b..8f995ca5d6 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -219,6 +219,7 @@ HB_EXPR_FUNC_PTR hb_comp_ExprTable[] = { }; extern BOOL hb_exp_bArgList; +extern HB_EXPR_PTR hb_exp_pSelf; /* ************************************************************************* */ @@ -1007,6 +1008,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) if( hb_exp_bArgList ) { HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_MACROPUSHARG ); + HB_EXPR_USE( hb_exp_pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); } else { @@ -1112,6 +1114,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( usCount ) { hb_exp_bArgList = TRUE; + hb_exp_pSelf = pSelf; HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_PUSH_PCODE ); hb_exp_bArgList = FALSE; } @@ -1145,6 +1148,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( usCount ) { hb_exp_bArgList = TRUE; + hb_exp_pSelf = pSelf; HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_PUSH_PCODE ); hb_exp_bArgList = FALSE; } diff --git a/harbour/include/hbpcode.h b/harbour/include/hbpcode.h index 813051a5e3..e144d764eb 100644 --- a/harbour/include/hbpcode.h +++ b/harbour/include/hbpcode.h @@ -61,130 +61,130 @@ */ typedef enum { - HB_P_AND, /* peforms the logical AND of two latest stack values, removes them and places result */ - HB_P_ARRAYPUSH, /* places on the virtual machine stack an array element */ - HB_P_ARRAYPOP, /* pops a value from the eval stack into an array element */ - HB_P_ARRAYDIM, /* instructs the virtual machine to build an array with some specific dimensions */ - HB_P_ARRAYGEN, /* instructs the virtual machine to build an array and load elemnst from the stack */ - HB_P_EQUAL, /* check if the latest two values on the stack are equal, removing them and leaving there the result */ - HB_P_ENDBLOCK, /* end of a codeblock definition */ - HB_P_ENDPROC, /* instructs the virtual machine to end execution */ - HB_P_EXACTLYEQUAL, /* check if the latest two values on the stack are exactly equal, removing them and leaving there the result */ - HB_P_FALSE, /* pushes false on the virtual machine stack */ - HB_P_FORTEST, /* For STEP. If step > 1 less. If step < 1 greater. */ - HB_P_FUNCTION, /* instructs the virtual machine to execute a function saving its result */ - HB_P_FUNCTIONSHORT, /* instructs the virtual machine to execute a function saving its result */ - HB_P_FRAME, /* instructs the virtual machine about how many parameters and locals a function uses */ - HB_P_FUNCPTR, /* returns a function address pointer */ - HB_P_GREATER, /* checks if the second latest value on the stack is greater that the lastest one */ - HB_P_GREATEREQUAL, /* checks if the second latest value on the stack is greater equal that the latest one, leaves the result only */ - HB_P_DEC, /* decrements the latest value on the virtual machine stack */ - HB_P_DIVIDE, /* divides the latest two values on the stack, removing them and leaving there the result */ - HB_P_DO, /* instructs the virtual machine to execute a function discarding its result */ - HB_P_DOSHORT, /* instructs the virtual machine to execute a function discarding its result */ - HB_P_DUPLICATE, /* places a copy of the latest virtual machine stack value on to the stack */ - HB_P_DUPLTWO, /* places a copy of the latest two virtual machine stack value on to the stack */ - HB_P_INC, /* increments the latest value on the virtual machine stack */ - HB_P_INSTRING, /* checks if the second latest value on the stack is a substring of the latest one */ - HB_P_JUMPNEAR, /* jumps to a relative offset 1 Byte */ - HB_P_JUMP, /* jumps to a relative offset 2 Bytes */ - HB_P_JUMPFAR, /* jumps to a relative offset 3 Bytes */ - HB_P_JUMPFALSENEAR, /* checks a logic expression of the stack and jumps to a relative offset */ - HB_P_JUMPFALSE, /* checks a logic expression of the stack and jumps to a relative offset */ - HB_P_JUMPFALSEFAR, /* checks a logic expression of the stack and jumps to a relative offset */ - HB_P_JUMPTRUENEAR, /* checks a logic expression of the stack and jumps to a relative offset */ - HB_P_JUMPTRUE, /* checks a logic expression of the stack and jumps to a relative offset */ - HB_P_JUMPTRUEFAR, /* checks a logic expression of the stack and jumps to a relative offset */ - HB_P_LESSEQUAL, /* checks if the second latest value on the stack is less equal that the latest one, leaves the result only */ - HB_P_LESS, /* checks if the second latest value on the stack is less that the lastest one */ - HB_P_LINE, /* currently compiled source code line number */ - HB_P_LOCALNAME, /* sets the name of local variable */ - HB_P_MACROPOP, /* compile and run - pop a value from the stack */ - HB_P_MACROPOPALIASED, /* compile and run - pop a field value from the stack */ - HB_P_MACROPUSH, /* compile and run - leave the result on the stack */ - HB_P_MACROPUSHARG, /* compile and run - leave the result on the stack */ - HB_P_MACROPUSHALIASED, /* compile and run - leave the field value on the stack */ - HB_P_MACROSYMBOL, /* compile into a symbol name (used in function calls) */ - HB_P_MACROTEXT, /* macro text substitution */ - HB_P_MESSAGE, /* sends a message to an object */ - HB_P_MINUS, /* subs the latest two values on the stack, removing them and leaving there the result */ - HB_P_MODULUS, /* calculates the modulus of the two values on the stack, removing them and leaving there the result */ - HB_P_MODULENAME, /* sets the name of debugged module */ + HB_P_AND, /* 0 peforms the logical AND of two latest stack values, removes them and places result */ + HB_P_ARRAYPUSH, /* 1 places on the virtual machine stack an array element */ + HB_P_ARRAYPOP, /* 2 pops a value from the eval stack into an array element */ + HB_P_ARRAYDIM, /* 3 instructs the virtual machine to build an array with some specific dimensions */ + HB_P_ARRAYGEN, /* 4 instructs the virtual machine to build an array and load elemnst from the stack */ + HB_P_EQUAL, /* 5 check if the latest two values on the stack are equal, removing them and leaving there the result */ + HB_P_ENDBLOCK, /* 6 end of a codeblock definition */ + HB_P_ENDPROC, /* 7 instructs the virtual machine to end execution */ + HB_P_EXACTLYEQUAL, /* 8 check if the latest two values on the stack are exactly equal, removing them and leaving there the result */ + HB_P_FALSE, /* 9 pushes false on the virtual machine stack */ + HB_P_FORTEST, /* 10 For STEP. If step > 1 less. If step < 1 greater. */ + HB_P_FUNCTION, /* 11 instructs the virtual machine to execute a function saving its result */ + HB_P_FUNCTIONSHORT, /* 12 instructs the virtual machine to execute a function saving its result */ + HB_P_FRAME, /* 13 instructs the virtual machine about how many parameters and locals a function uses */ + HB_P_FUNCPTR, /* 14 returns a function address pointer */ + HB_P_GREATER, /* 15 checks if the second latest value on the stack is greater that the lastest one */ + HB_P_GREATEREQUAL, /* 16 checks if the second latest value on the stack is greater equal that the latest one, leaves the result only */ + HB_P_DEC, /* 17 decrements the latest value on the virtual machine stack */ + HB_P_DIVIDE, /* 18 divides the latest two values on the stack, removing them and leaving there the result */ + HB_P_DO, /* 19 instructs the virtual machine to execute a function discarding its result */ + HB_P_DOSHORT, /* 20 instructs the virtual machine to execute a function discarding its result */ + HB_P_DUPLICATE, /* 21 places a copy of the latest virtual machine stack value on to the stack */ + HB_P_DUPLTWO, /* 22 places a copy of the latest two virtual machine stack value on to the stack */ + HB_P_INC, /* 23 increments the latest value on the virtual machine stack */ + HB_P_INSTRING, /* 24 checks if the second latest value on the stack is a substring of the latest one */ + HB_P_JUMPNEAR, /* 25 jumps to a relative offset 1 Byte */ + HB_P_JUMP, /* 26 jumps to a relative offset 2 Bytes */ + HB_P_JUMPFAR, /* 27 jumps to a relative offset 3 Bytes */ + HB_P_JUMPFALSENEAR, /* 28 checks a logic expression of the stack and jumps to a relative offset */ + HB_P_JUMPFALSE, /* 29 checks a logic expression of the stack and jumps to a relative offset */ + HB_P_JUMPFALSEFAR, /* 30 checks a logic expression of the stack and jumps to a relative offset */ + HB_P_JUMPTRUENEAR, /* 31 checks a logic expression of the stack and jumps to a relative offset */ + HB_P_JUMPTRUE, /* 32 checks a logic expression of the stack and jumps to a relative offset */ + HB_P_JUMPTRUEFAR, /* 33 checks a logic expression of the stack and jumps to a relative offset */ + HB_P_LESSEQUAL, /* 34 checks if the second latest value on the stack is less equal that the latest one, leaves the result only */ + HB_P_LESS, /* 35 checks if the second latest value on the stack is less that the lastest one */ + HB_P_LINE, /* 36 currently compiled source code line number */ + HB_P_LOCALNAME, /* 37 sets the name of local variable */ + HB_P_MACROPOP, /* 38 compile and run - pop a value from the stack */ + HB_P_MACROPOPALIASED, /* 39 compile and run - pop a field value from the stack */ + HB_P_MACROPUSH, /* 40 compile and run - leave the result on the stack */ + HB_P_MACROPUSHARG, /* 41 compile and run - leave the result on the stack */ + HB_P_MACROPUSHALIASED, /* 42 compile and run - leave the field value on the stack */ + HB_P_MACROSYMBOL, /* 43 compile into a symbol name (used in function calls) */ + HB_P_MACROTEXT, /* 44 macro text substitution */ + HB_P_MESSAGE, /* 45 sends a message to an object */ + HB_P_MINUS, /* 46 subs the latest two values on the stack, removing them and leaving there the result */ + HB_P_MODULUS, /* 47 calculates the modulus of the two values on the stack, removing them and leaving there the result */ + HB_P_MODULENAME, /* 48 sets the name of debugged module */ /* start: pcodes generated by the macro compiler - the symbol address is used */ - HB_P_MMESSAGE, - HB_P_MPOPALIASEDFIELD, - HB_P_MPOPALIASEDVAR, - HB_P_MPOPFIELD, - HB_P_MPOPMEMVAR, - HB_P_MPUSHALIASEDFIELD, - HB_P_MPUSHALIASEDVAR, - HB_P_MPUSHBLOCK, - HB_P_MPUSHFIELD, - HB_P_MPUSHMEMVAR, - HB_P_MPUSHMEMVARREF, - HB_P_MPUSHSYM, - HB_P_MPUSHVARIABLE, + HB_P_MMESSAGE, /* 49 */ + HB_P_MPOPALIASEDFIELD, /* 50 */ + HB_P_MPOPALIASEDVAR, /* 51 */ + HB_P_MPOPFIELD, /* 52 */ + HB_P_MPOPMEMVAR, /* 53 */ + HB_P_MPUSHALIASEDFIELD, /* 54 */ + HB_P_MPUSHALIASEDVAR, /* 55 */ + HB_P_MPUSHBLOCK, /* 56 */ + HB_P_MPUSHFIELD, /* 57 */ + HB_P_MPUSHMEMVAR, /* 58 */ + HB_P_MPUSHMEMVARREF, /* 59 */ + HB_P_MPUSHSYM, /* 60 */ + HB_P_MPUSHVARIABLE, /* 61 */ /* end: */ - HB_P_MULT, /* multiplies the latest two values on the stack, removing them and leaving there the result */ - HB_P_NEGATE, /* numerically negates the latest value on the stack */ - HB_P_NOOP, /* no operation */ - HB_P_NOT, /* logically negates the latest value on the stack */ - HB_P_NOTEQUAL, /* checks if the latest two stack values are equal, leaves just the result */ - HB_P_OR, /* peforms the logical OR of two latest stack values, removes them and places result */ - HB_P_PARAMETER, /* creates PRIVATE variables and assigns values to functions paramaters */ - HB_P_PLUS, /* adds the latest two values on the stack, removing them and leaving there the result */ - HB_P_POP, /* removes the latest value from the stack */ - HB_P_POPALIAS, /* pops the item from the eval stack and selects the current workarea */ - HB_P_POPALIASEDFIELD, /* pops aliased field */ - HB_P_POPALIASEDFIELDNEAR, /* pops aliased field */ - HB_P_POPALIASEDVAR, /* pops aliased variable (either a field or a memvar) */ - HB_P_POPFIELD, /* pops unaliased field */ - HB_P_POPLOCAL, /* pops the contains of the virtual machine stack onto a local variable */ - HB_P_POPLOCALNEAR, /* pops the contains of the virtual machine stack onto a local variable */ - HB_P_POPMEMVAR, /* pops the contains of a memvar variable to the virtual machine stack */ - HB_P_POPSTATIC, /* pops the contains of the virtual machine stack onto a static variable */ - HB_P_POPVARIABLE, /* pops the contains of an undeclared variable from the virtual machine stack */ - HB_P_POWER, /* calculates the power of the two values on the stack, removing them and leaving there the result */ - HB_P_PUSHALIAS, /* saves the current workarea number on the eval stack */ - HB_P_PUSHALIASEDFIELD, /* pushes aliased field */ - HB_P_PUSHALIASEDFIELDNEAR, /* pushes aliased field */ - HB_P_PUSHALIASEDVAR, /* pushes aliased variable (either a field or a memvar) */ - HB_P_PUSHBLOCK, /* start of a codeblock definition */ - HB_P_PUSHBLOCKSHORT, /* start of a codeblock definition */ - HB_P_PUSHFIELD, /* pushes unaliased field */ - HB_P_PUSHBYTE, /* places a 1 byte integer number on the virtual machine stack */ - HB_P_PUSHINT, /* places an integer number on the virtual machine stack */ - HB_P_PUSHLOCAL, /* pushes the contains of a local variable to the virtual machine stack */ - HB_P_PUSHLOCALNEAR, /* pushes the contains of a local variable to the virtual machine stack */ - HB_P_PUSHLOCALREF, /* pushes a local variable by reference to the virtual machine stack */ - HB_P_PUSHLONG, /* places an integer number on the virtual machine stack */ - HB_P_PUSHMEMVAR, /* pushes the contains of a memvar variable to the virtual machine stack */ - HB_P_PUSHMEMVARREF, /* pushes the a memvar variable by reference to the virtual machine stack */ - HB_P_PUSHNIL, /* places a nil on the virtual machine stack */ - HB_P_PUSHDOUBLE, /* places a double number on the virtual machine stack */ - HB_P_PUSHSELF, /* pushes Self for the current processed method */ - HB_P_PUSHSTATIC, /* pushes the contains of a static variable to the virtual machine stack */ - HB_P_PUSHSTATICREF, /* pushes the a static variable by reference to the virtual machine stack */ - HB_P_PUSHSTR, /* places a string on the virtual machine stack */ - HB_P_PUSHSTRSHORT, /* places a string on the virtual machine stack */ - HB_P_PUSHSYM, /* places a symbol on the virtual machine stack */ - HB_P_PUSHSYMNEAR, /* places a symbol on the virtual machine stack */ - HB_P_PUSHVARIABLE, /* pushes the contains of an undeclared variable to the virtual machine stack */ - HB_P_RETVALUE, /* instructs the virtual machine to return the latest stack value */ - HB_P_SEND, /* send operator */ - HB_P_SENDSHORT, /* send operator */ - HB_P_SEQBEGIN, /* BEGIN SEQUENCE */ - HB_P_SEQEND, /* END SEQUENCE */ - HB_P_SEQRECOVER, /* RECOVER statement */ - HB_P_SFRAME, /* sets the statics frame for a function */ - HB_P_STATICS, /* defines the number of statics variables for a PRG */ - HB_P_STATICNAME, /* sets the name of static variable */ - HB_P_SWAPALIAS, /* restores the current workarea number from the eval stack */ - HB_P_TRUE, /* pushes true on the virtual machine stack */ - HB_P_ZERO, /* places a ZERO on the virtual machine stack */ - HB_P_ONE, /* places a ONE on the virtual machine stack */ + HB_P_MULT, /* 62 multiplies the latest two values on the stack, removing them and leaving there the result */ + HB_P_NEGATE, /* 63 numerically negates the latest value on the stack */ + HB_P_NOOP, /* 64 no operation */ + HB_P_NOT, /* 65 logically negates the latest value on the stack */ + HB_P_NOTEQUAL, /* 66 checks if the latest two stack values are equal, leaves just the result */ + HB_P_OR, /* 67 peforms the logical OR of two latest stack values, removes them and places result */ + HB_P_PARAMETER, /* 68 creates PRIVATE variables and assigns values to functions paramaters */ + HB_P_PLUS, /* 69 adds the latest two values on the stack, removing them and leaving there the result */ + HB_P_POP, /* 70 removes the latest value from the stack */ + HB_P_POPALIAS, /* 71 pops the item from the eval stack and selects the current workarea */ + HB_P_POPALIASEDFIELD, /* 72 pops aliased field */ + HB_P_POPALIASEDFIELDNEAR, /* 73 pops aliased field */ + HB_P_POPALIASEDVAR, /* 74 pops aliased variable (either a field or a memvar) */ + HB_P_POPFIELD, /* 75 pops unaliased field */ + HB_P_POPLOCAL, /* 76 pops the contains of the virtual machine stack onto a local variable */ + HB_P_POPLOCALNEAR, /* 77 pops the contains of the virtual machine stack onto a local variable */ + HB_P_POPMEMVAR, /* 78 pops the contains of a memvar variable to the virtual machine stack */ + HB_P_POPSTATIC, /* 79 pops the contains of the virtual machine stack onto a static variable */ + HB_P_POPVARIABLE, /* 80 pops the contains of an undeclared variable from the virtual machine stack */ + HB_P_POWER, /* 81 calculates the power of the two values on the stack, removing them and leaving there the result */ + HB_P_PUSHALIAS, /* 82 saves the current workarea number on the eval stack */ + HB_P_PUSHALIASEDFIELD, /* 83 pushes aliased field */ + HB_P_PUSHALIASEDFIELDNEAR, /* 84 pushes aliased field */ + HB_P_PUSHALIASEDVAR, /* 85 pushes aliased variable (either a field or a memvar) */ + HB_P_PUSHBLOCK, /* 86 start of a codeblock definition */ + HB_P_PUSHBLOCKSHORT, /* 87 start of a codeblock definition */ + HB_P_PUSHFIELD, /* 88 pushes unaliased field */ + HB_P_PUSHBYTE, /* 89 places a 1 byte integer number on the virtual machine stack */ + HB_P_PUSHINT, /* 90 places an integer number on the virtual machine stack */ + HB_P_PUSHLOCAL, /* 91 pushes the contains of a local variable to the virtual machine stack */ + HB_P_PUSHLOCALNEAR, /* 92 pushes the contains of a local variable to the virtual machine stack */ + HB_P_PUSHLOCALREF, /* 93 pushes a local variable by reference to the virtual machine stack */ + HB_P_PUSHLONG, /* 94 places an integer number on the virtual machine stack */ + HB_P_PUSHMEMVAR, /* 95 pushes the contains of a memvar variable to the virtual machine stack */ + HB_P_PUSHMEMVARREF, /* 96 pushes the a memvar variable by reference to the virtual machine stack */ + HB_P_PUSHNIL, /* 97 places a nil on the virtual machine stack */ + HB_P_PUSHDOUBLE, /* 98 places a double number on the virtual machine stack */ + HB_P_PUSHSELF, /* 99 pushes Self for the current processed method */ + HB_P_PUSHSTATIC, /* 100 pushes the contains of a static variable to the virtual machine stack */ + HB_P_PUSHSTATICREF, /* 101 pushes the a static variable by reference to the virtual machine stack */ + HB_P_PUSHSTR, /* 102 places a string on the virtual machine stack */ + HB_P_PUSHSTRSHORT, /* 103 places a string on the virtual machine stack */ + HB_P_PUSHSYM, /* 104 places a symbol on the virtual machine stack */ + HB_P_PUSHSYMNEAR, /* 105 places a symbol on the virtual machine stack */ + HB_P_PUSHVARIABLE, /* 106 pushes the contains of an undeclared variable to the virtual machine stack */ + HB_P_RETVALUE, /* 107 instructs the virtual machine to return the latest stack value */ + HB_P_SEND, /* 108 send operator */ + HB_P_SENDSHORT, /* 109 send operator */ + HB_P_SEQBEGIN, /* 110 BEGIN SEQUENCE */ + HB_P_SEQEND, /* 111 END SEQUENCE */ + HB_P_SEQRECOVER, /* 112 RECOVER statement */ + HB_P_SFRAME, /* 113 sets the statics frame for a function */ + HB_P_STATICS, /* 114 defines the number of statics variables for a PRG */ + HB_P_STATICNAME, /* 115 sets the name of static variable */ + HB_P_SWAPALIAS, /* 116 restores the current workarea number from the eval stack */ + HB_P_TRUE, /* 117 pushes true on the virtual machine stack */ + HB_P_ZERO, /* 118 places a ZERO on the virtual machine stack */ + HB_P_ONE, /* 119 places a ONE on the virtual machine stack */ /* NOTE: This have to be the last definition */ - HB_P_LAST_PCODE /* this defines the number of defined pcodes */ + HB_P_LAST_PCODE /* 120 this defines the number of defined pcodes */ } HB_PCODE; #endif /* HB_PCODE_H_ */ diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 05b95ca05b..84128552be 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -253,7 +253,8 @@ static LONG s_lRecoverBase; #define HB_RECOVER_ADDRESS -3 #define HB_RECOVER_VALUE -4 -int hb_vm_iFunCalls = 0, *hb_vm_aiMacroListParameters = NULL, hb_vm_iMacroListAllocated = 0, hb_vm_iExtraParams; +int hb_vm_iExtraParams = 0; +PHB_SYMB hb_vm_pExtraParamsSymbol = NULL; /* Request for some action - stop processing of opcodes */ @@ -290,8 +291,6 @@ void hb_vmInit( BOOL bStartMainProc ) s_lRecoverBase = 0; s_uiActionRequest = 0; - hb_vm_aiMacroListParameters = (int *) hb_xgrab( sizeof( int ) * ( hb_vm_iMacroListAllocated = 16 ) ); - hb_stack.pItems = NULL; /* keep this here as it is used by fm.c */ hb_stack.Return.type = HB_IT_NIL; @@ -397,11 +396,6 @@ void hb_vmQuit( void ) hb_pp_Free(); #endif - if( hb_vm_aiMacroListParameters ) - { - hb_xfree( (void*) hb_vm_aiMacroListParameters ); - } - s_uiActionRequest = 0; /* EXIT procedures should be processed */ hb_vmDoExitFunctions(); /* process defined EXIT functions */ @@ -594,13 +588,6 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) /* Object */ case HB_P_MESSAGE: - if( hb_vm_iFunCalls >= hb_vm_iMacroListAllocated ) - { - //printf( "\nRealloc! FunCalls: %i Allocated: %i \n", hb_vm_iFunCalls, hb_vm_iMacroListAllocated ); - hb_vm_aiMacroListParameters = (int *) hb_xrealloc( (void*) hb_vm_aiMacroListParameters, sizeof( int ) * ( hb_vm_iMacroListAllocated += 16 ) ); - } - hb_vm_aiMacroListParameters[ hb_vm_iFunCalls++ ] = 0; - hb_vmMessage( pSymbols + ( USHORT ) ( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) ) ); w += 3; break; @@ -615,102 +602,42 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) /* Execution */ case HB_P_DO: - if( hb_vm_iFunCalls ) - { - hb_vm_iExtraParams = hb_vm_aiMacroListParameters[ --hb_vm_iFunCalls ]; - } - else - { - hb_vm_iExtraParams = 0; - //printf( "\nOops!\n" ); - } - - hb_vmDo( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) + hb_vm_iExtraParams ); + hb_vmDo( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) ); w += 3; break; case HB_P_DOSHORT: - if( hb_vm_iFunCalls ) - { - hb_vm_iExtraParams = hb_vm_aiMacroListParameters[ --hb_vm_iFunCalls ]; - } - else - { - hb_vm_iExtraParams = 0; - //printf( "\nOops!\n" ); - } - - hb_vmDo( pCode[ w + 1 ] + hb_vm_iExtraParams ); + hb_vmDo( pCode[ w + 1 ] ); w += 2; break; case HB_P_FUNCTION: - if( hb_vm_iFunCalls ) - { - hb_vm_iExtraParams = hb_vm_aiMacroListParameters[ --hb_vm_iFunCalls ]; - } - else - { - hb_vm_iExtraParams = 0; - //printf( "\nOops!\n" ); - } - hb_itemClear( &hb_stack.Return ); - hb_vmDo( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) + hb_vm_iExtraParams ); + hb_vmDo( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) ); hb_itemCopy( hb_stackTopItem(), &hb_stack.Return ); hb_stackPush(); w += 3; break; case HB_P_FUNCTIONSHORT: - if( hb_vm_iFunCalls ) - { - hb_vm_iExtraParams = hb_vm_aiMacroListParameters[ --hb_vm_iFunCalls ]; - } - else - { - hb_vm_iExtraParams = 0; - //printf( "\nOops!\n" ); - } - hb_itemClear( &hb_stack.Return ); - hb_vmDo( pCode[ w + 1 ] + hb_vm_iExtraParams ); + hb_vmDo( pCode[ w + 1 ] ); hb_itemCopy( hb_stackTopItem(), &hb_stack.Return ); hb_stackPush(); w += 2; break; case HB_P_SEND: - if( hb_vm_iFunCalls ) - { - hb_vm_iExtraParams = hb_vm_aiMacroListParameters[ --hb_vm_iFunCalls ]; - } - else - { - hb_vm_iExtraParams = 0; - //printf( "\nOops!\n" ); - } - hb_itemClear( &hb_stack.Return ); - hb_vmSend( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 + hb_vm_iExtraParams ) ); + hb_vmSend( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) ); hb_itemCopy( hb_stackTopItem(), &hb_stack.Return ); hb_stackPush(); w += 3; break; case HB_P_SENDSHORT: - if( hb_vm_iFunCalls ) - { - hb_vm_iExtraParams = hb_vm_aiMacroListParameters[ --hb_vm_iFunCalls ]; - } - else - { - hb_vm_iExtraParams = 0; - //printf( "\nOops!\n" ); - } - hb_itemClear( &hb_stack.Return ); - hb_vmSend( pCode[ w + 1 ] + hb_vm_iExtraParams ); + hb_vmSend( pCode[ w + 1 ] ); hb_itemCopy( hb_stackTopItem(), &hb_stack.Return ); hb_stackPush(); w += 2; @@ -1104,25 +1031,11 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) break; case HB_P_PUSHSYM: - if( hb_vm_iFunCalls >= hb_vm_iMacroListAllocated ) - { - //printf( "\nRealloc! FunCalls: %i Allocated: %i \n", hb_vm_iFunCalls, hb_vm_iMacroListAllocated ); - hb_vm_aiMacroListParameters = (int *) hb_xrealloc( (void*) hb_vm_aiMacroListParameters, sizeof( int ) * ( hb_vm_iMacroListAllocated += 16 ) ); - } - hb_vm_aiMacroListParameters[ hb_vm_iFunCalls++ ] = 0; - hb_vmPushSymbol( pSymbols + ( USHORT ) ( pCode[ w + 1 ] + ( pCode[ w + 2 ] * 256 ) ) ); w += 3; break; case HB_P_PUSHSYMNEAR: - if( hb_vm_iFunCalls >= hb_vm_iMacroListAllocated ) - { - //printf( "\nRealloc! FunCalls: %i Allocated: %i \n", hb_vm_iFunCalls, hb_vm_iMacroListAllocated ); - hb_vm_aiMacroListParameters = (int *) hb_xrealloc( (void*) hb_vm_aiMacroListParameters, sizeof( int ) * ( hb_vm_iMacroListAllocated += 16 ) ); - } - hb_vm_aiMacroListParameters[ hb_vm_iFunCalls++ ] = 0; - hb_vmPushSymbol( pSymbols + ( USHORT ) pCode[ w + 1 ] ); w += 2; break; @@ -1323,8 +1236,24 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) /* the topmost element on the stack contains a macro * string for compilation */ + if( pCode[ w + 1 ] == HB_P_PUSHSYMNEAR ) + { + hb_vm_pExtraParamsSymbol = pSymbols + ( USHORT ) ( pCode[ w + 2 ] ); + w += 3; + } + else if( pCode[ w + 1 ] == HB_P_MPUSHSYM ) + { + HB_DYNS_PTR *pDynSym = ( HB_DYNS_PTR * ) ( pCode + w + 2 ); + + hb_vm_pExtraParamsSymbol = ( *pDynSym )->pSymbol; + w += sizeof( HB_DYNS_PTR ) + 2; + } + else + { + hb_vm_pExtraParamsSymbol = pSymbols + ( USHORT ) ( pCode[ w + 2 ] + ( pCode[ w + 3 ] * 256 ) ); + w += 4; + } hb_macroGetValue( hb_stackItemFromTop( -1 ), TRUE ); - w++; break; case HB_P_MACROPUSHALIASED: @@ -1335,13 +1264,6 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_MACROSYMBOL: /* compile into a symbol name (used in function calls) */ - if( hb_vm_iFunCalls >= hb_vm_iMacroListAllocated ) - { - //printf( "\nRealloc! FunCalls: %i Allocated: %i \n", hb_vm_iFunCalls, hb_vm_iMacroListAllocated ); - hb_vm_aiMacroListParameters = (int *) hb_xrealloc( (void*) hb_vm_aiMacroListParameters, sizeof( int ) * ( hb_vm_iMacroListAllocated += 16 ) ); - } - hb_vm_aiMacroListParameters[ hb_vm_iFunCalls++ ] = 0; - hb_macroPushSymbol( hb_stackItemFromTop( -1 ) ); w++; break; @@ -1359,14 +1281,6 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ) case HB_P_MMESSAGE: { HB_DYNS_PTR * pDynSym = ( HB_DYNS_PTR * ) ( pCode + w + 1 ); - - if( hb_vm_iFunCalls >= hb_vm_iMacroListAllocated ) - { - //printf( "\nRealloc! FunCalls: %i Allocated: %i \n", hb_vm_iFunCalls, hb_vm_iMacroListAllocated ); - hb_vm_aiMacroListParameters = (int *) hb_xrealloc( (void*) hb_vm_aiMacroListParameters, sizeof( int ) * ( hb_vm_iMacroListAllocated += 16 ) ); - } - hb_vm_aiMacroListParameters[ hb_vm_iFunCalls++ ] = 0; - hb_vmMessage( ( *pDynSym )->pSymbol ); w += sizeof( HB_DYNS_PTR ) + 1; break; @@ -2960,6 +2874,16 @@ void hb_vmDo( USHORT uiParams ) HB_TRACE(HB_TR_DEBUG, ("hb_vmDo(%hu)", uiParams)); + /* + printf( "\nItems: %i Params: %i Extra %i\n", hb_stack.pPos - hb_stack.pBase, uiParams, hb_vm_iExtraParams ); + */ + if( hb_vm_iExtraParams && ( ( hb_stack.pPos - hb_stack.pBase ) >= ( uiParams + hb_vm_iExtraParams + 2 ) ) && HB_IS_SYMBOL( pItem = hb_stackItemFromTop( -( uiParams + hb_vm_iExtraParams + 2 ) ) ) && pItem->item.asSymbol.value == hb_vm_pExtraParamsSymbol ) + { + uiParams += hb_vm_iExtraParams; + hb_vm_iExtraParams = 0; + hb_vm_pExtraParamsSymbol = NULL; + } + if( bProfiler ) ulClock = ( ULONG ) clock(); @@ -3083,6 +3007,13 @@ void hb_vmSend( USHORT uiParams ) HB_TRACE(HB_TR_DEBUG, ("hb_vmSend(%hu)", uiParams)); + if( hb_vm_iExtraParams && ( hb_stack.pPos - hb_stack.pBase >= ( uiParams + hb_vm_iExtraParams + 2 ) ) && HB_IS_SYMBOL( pItem = hb_stackItemFromTop( -( uiParams + hb_vm_iExtraParams + 2 ) ) ) && pItem->item.asSymbol.value == hb_vm_pExtraParamsSymbol ) + { + uiParams += hb_vm_iExtraParams; + hb_vm_iExtraParams = 0; + hb_vm_pExtraParamsSymbol = NULL; + } + if( bProfiler ) ulClock = ( ULONG ) clock(); diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index b86dfe15f4..31d92f3911 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -427,7 +427,7 @@ char * hb_macroTextSubst( char * szString, ULONG *pulStringLen ) */ void hb_macroGetValue( HB_ITEM_PTR pItem, BOOL bArg ) { - extern int *hb_vm_aiMacroListParameters, hb_vm_iFunCalls; + extern int hb_vm_iExtraParams; HB_TRACE(HB_TR_DEBUG, ("hb_macroGetValue(%p)", pItem)); @@ -474,19 +474,15 @@ void hb_macroGetValue( HB_ITEM_PTR pItem, BOOL bArg ) hb_xfree( pOut ); #endif - if( hb_vm_iFunCalls ) - { - hb_vm_aiMacroListParameters[ hb_vm_iFunCalls - 1 ] = struMacro.iListElements; - } - else - { - //printf( "Oops\n" ); - } - hb_stackPop(); /* remove compiled string */ if( iStatus == HB_MACRO_OK && ( struMacro.status & HB_MACRO_CONT ) ) { hb_macroEvaluate( &struMacro ); + + if( bArg && struMacro.iListElements > 0 ) + { + hb_vm_iExtraParams += struMacro.iListElements; + } } else hb_macroSyntaxError( &struMacro );