2006-12-28 16:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbcomp.h
  * harbour/include/hbcompdf.h
  * harbour/include/hbexprb.c
  * harbour/include/hbexprc.c
  * harbour/include/hbpcode.h
  * harbour/include/hbpp.h
  * harbour/include/hbxvm.h
  * harbour/source/compiler/genc.c
  * harbour/source/compiler/gencc.c
  * harbour/source/compiler/gencli.c
  * harbour/source/compiler/harbour.c
  * harbour/source/compiler/harbour.y
  * harbour/source/compiler/harbour.yyc
  * harbour/source/compiler/hbgenerr.c
  * harbour/source/compiler/hbpcode.c
  * harbour/source/vm/hvm.c
  * harbour/source/vm/macro.c
    * changed HB_P_MACROPUSHINDEX PCODE behavior - now it does not evaluated
      macro expression
    * eliminated HB_ET_MACRO_INDEX - HB_ET_MACRO_LIST can be used instead
    * accept ... in codeblocks only when codeblocks parameters are defined
      as variables, f.e: {|a,b,...|qout(a+b,...)}
    ! fixed error in a[&s]:=100
    + added support for a[...] - now ... can be used in the same context as
      xbase++ like multivalue macro (a[&s])
    * disabled ++, --, <op>= optimizations when -kc (strict Clipper
      compatibility mode) compiler switch is used
This commit is contained in:
Przemyslaw Czerpak
2006-12-28 15:44:41 +00:00
parent 88716ffc11
commit 40999edb49
18 changed files with 3138 additions and 3030 deletions

View File

@@ -8,6 +8,35 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2006-12-28 16:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/include/hbexprb.c
* harbour/include/hbexprc.c
* harbour/include/hbpcode.h
* harbour/include/hbpp.h
* harbour/include/hbxvm.h
* harbour/source/compiler/genc.c
* harbour/source/compiler/gencc.c
* harbour/source/compiler/gencli.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/hbgenerr.c
* harbour/source/compiler/hbpcode.c
* harbour/source/vm/hvm.c
* harbour/source/vm/macro.c
* changed HB_P_MACROPUSHINDEX PCODE behavior - now it does not evaluated
macro expression
* eliminated HB_ET_MACRO_INDEX - HB_ET_MACRO_LIST can be used instead
* accept ... in codeblocks only when codeblocks parameters are defined
as variables, f.e: {|a,b,...|qout(a+b,...)}
! fixed error in a[&s]:=100
+ added support for a[...] - now ... can be used in the same context as
xbase++ like multivalue macro (a[&s])
* disabled ++, --, <op>= optimizations when -kc (strict Clipper
compatibility mode) compiler switch is used
2006-12-27 21:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcompdf.h
* removed not longer used pFunCall from asMacro expression.

View File

@@ -265,7 +265,7 @@ extern void hb_compErrorDuplVar( HB_COMP_DECL, const char * );
extern HB_EXPR_PTR hb_compErrorRefer( HB_COMP_DECL, HB_EXPR_PTR, const char * );
extern HB_EXPR_PTR hb_compWarnMeaningless( HB_COMP_DECL, HB_EXPR_PTR );
extern void hb_compErrorMacro( HB_COMP_DECL, const char * );
extern void hb_compErrorVParams( HB_COMP_DECL, HB_EXPR_PTR );
extern void hb_compErrorVParams( HB_COMP_DECL, const char * );
extern HB_EXPR_PTR hb_compErrorStatic( HB_COMP_DECL, const char *, HB_EXPR_PTR );
extern void hb_compErrorCodeblock( HB_COMP_DECL, const char * );

View File

@@ -146,6 +146,7 @@ typedef struct __FUNC
ULONG iNOOPs; /* NOOPs Counter */
ULONG iJumps; /* Jumps Counter */
BOOL bLateEval; /* TRUE if accessing of declared (compile time) variables is allowed */
BOOL fVParams; /* TRUE if variable number of parameters is used */
BOOL bError; /* error during function compilation */
struct __FUNC * pOwner; /* pointer to the function/procedure that owns the codeblock */
struct __FUNC * pNext; /* pointer to the next defined function */
@@ -253,10 +254,9 @@ typedef enum
#define HB_ET_MACRO_ALIASED 2 /* &alias->&variable */
#define HB_ET_MACRO_EXPR 4 /* &( expr ) */
#define HB_ET_MACRO_LIST 16 /* &variable used as in literal arrays or function call argument. */
#define HB_ET_MACRO_INDEX 32 /* &variable used as arrays index. */
#define HB_ET_MACRO_PARE 64 /* &variable used as parentesised expressions. */
#define HB_ET_MACRO_REFER 128 /* &macro used in @ (pass by reference) */
#define HB_ET_MACRO_ASSIGN 256 /* o:&msgname := value */
#define HB_ET_MACRO_PARE 32 /* &variable used as parentesised expressions. */
#define HB_ET_MACRO_REFER 64 /* &macro used in @ (pass by reference) */
#define HB_ET_MACRO_ASSIGN 128 /* o:&msgname := value */
/* types of expressions
* NOTE: the order of these definition is important - change it carefully
@@ -370,7 +370,7 @@ typedef struct HB_EXPR_
{
char *string; /* source code of a codeblock */
USHORT length;
USHORT flags; /* HB_BLOCK_MACRO, HB_BLOCK_LATEEVAL */
USHORT flags; /* HB_BLOCK_MACRO, HB_BLOCK_LATEEVAL, HB_BLOCK_VPARAMS */
struct HB_EXPR_ *pExprList; /* list elements */
HB_CBVAR_PTR pLocals; /* list of local variables */
} asCodeblock;

View File

@@ -402,7 +402,8 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock )
HB_EXPR_PCODE1( hb_compExprCodeblockPush, pSelf );
#else
if( ( pSelf->value.asCodeblock.flags & HB_BLOCK_MACRO ) &&
!( pSelf->value.asCodeblock.flags & HB_BLOCK_LATEEVAL ) )
!( pSelf->value.asCodeblock.flags &
( HB_BLOCK_LATEEVAL | HB_BLOCK_VPARAMS ) ) )
/* early evaluation of a macro */
hb_compExprCodeblockEarly( pSelf, HB_COMP_PARAM );
else
@@ -459,6 +460,8 @@ static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, BOOL bLateEval, HB_COMP
HB_PCODE_DATA->pLocals = pSelf->value.asCodeblock.pLocals;
#else
HB_EXPR_PCODE1( hb_compCodeBlockStart, bLateEval );
HB_COMP_PARAM->functions.pLast->fVParams =
( pSelf->value.asCodeblock.flags & HB_BLOCK_VPARAMS ) != 0;
{
HB_CBVAR_PTR pVar;
@@ -1077,10 +1080,11 @@ static HB_EXPR_FUNC( hb_compExprUseArgList )
if( pSelf->value.asList.reference )
{
#if !defined( HB_MACRO_SUPPORT )
if( HB_COMP_PARAM->functions.pLast->szName &&
HB_COMP_PARAM->functions.pLast->pCode[0] != HB_P_VFRAME )
if( !HB_COMP_PARAM->functions.pLast->fVParams )
{
hb_compErrorVParams( HB_COMP_PARAM, pSelf );
hb_compErrorVParams( HB_COMP_PARAM,
HB_COMP_PARAM->functions.pLast->szName ?
"Function" : "Codeblock" );
}
#endif
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHVPARAMS );
@@ -1252,45 +1256,63 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt )
break;
case HB_EA_PUSH_PCODE:
HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE );
if( HB_SUPPORT_XBASE )
{
BOOL fMacroIndex = FALSE;
if( pSelf->value.asList.pIndex->ExprType == HB_ET_MACRO )
{
if( pSelf->value.asList.pIndex->ExprType == HB_ET_MACRO )
pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_INDEX;
if( HB_SUPPORT_XBASE )
{
pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_LIST;
fMacroIndex = TRUE;
}
}
else if( pSelf->value.asList.pIndex->ExprType == HB_ET_ARGLIST )
{
fMacroIndex = pSelf->value.asList.pIndex->value.asList.reference;
}
HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE );
HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_PUSH_PCODE );
if( fMacroIndex )
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHINDEX );
if( pSelf->value.asList.reference )
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPUSHREF );
else
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPUSH );
break;
}
case HB_EA_POP_PCODE:
{
BOOL bRemoveRef = FALSE;
/* #ifndef HB_C52_STRICT */
if( HB_SUPPORT_ARRSTR )
BOOL fMacroIndex = FALSE, bRemoveRef = FALSE;
/* to manage strings as bytes arrays, they must be pushed by reference */
/* arrays also are passed by reference */
if( pSelf->value.asList.pExprList->ExprType == HB_ET_VARIABLE )
{
/* to manage strings as bytes arrays, they must be pushed by reference */
/* arrays also are passed by reference */
if( pSelf->value.asList.pExprList->ExprType == HB_ET_VARIABLE )
if( HB_SUPPORT_ARRSTR )
{
pSelf->value.asList.pExprList->ExprType = HB_ET_VARREF;
bRemoveRef = TRUE;
}
}
/* #endif */
if( pSelf->value.asList.pIndex->ExprType == HB_ET_MACRO )
{
if( HB_SUPPORT_XBASE )
{
pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_LIST;
fMacroIndex = TRUE;
}
}
else if( pSelf->value.asList.pIndex->ExprType == HB_ET_ARGLIST )
{
fMacroIndex = pSelf->value.asList.pIndex->value.asList.reference;
}
HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE );
HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_PUSH_PCODE );
if( fMacroIndex )
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHINDEX );
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPOP );
/* #ifndef HB_C52_STRICT */
if( HB_SUPPORT_ARRSTR && bRemoveRef )
{
if( bRemoveRef )
pSelf->value.asList.pExprList->ExprType = HB_ET_VARIABLE;
}
/* #endif */
break;
}
@@ -1387,14 +1409,9 @@ static HB_EXPR_FUNC( hb_compExprUseMacro )
{
if( pSelf->value.asMacro.SubType & HB_ET_MACRO_LIST )
{
/* { &macro } or funCall( &macro ) */
/* { &macro }, funCall( &macro ) or var[ &macro ] */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHLIST );
}
else if( pSelf->value.asMacro.SubType & HB_ET_MACRO_INDEX )
{
/* var[ &macro ] */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHINDEX );
}
else if( pSelf->value.asMacro.SubType & HB_ET_MACRO_PARE )
{
/* var := (somevalue, &macro) - in xbase compatibility mode

View File

@@ -212,40 +212,6 @@ void hb_compExprDelOperator( HB_EXPR_PTR pExpr, HB_COMP_DECL )
*
* pExpr is an expression created by hb_compExprNew<operator>Eq functions
*/
void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
{
BYTE bNewOp;
switch( bOpEq )
{
case HB_P_PLUS:
bNewOp = HB_P_PLUSEQ;
break;
case HB_P_MINUS:
bNewOp = HB_P_MINUSEQ;
break;
case HB_P_MULT:
bNewOp = HB_P_MULTEQ;
break;
case HB_P_DIVIDE:
bNewOp = HB_P_DIVEQ;
break;
case HB_P_MODULUS:
bNewOp = HB_P_MODEQ;
break;
case HB_P_POWER:
bNewOp = HB_P_EXPEQ;
break;
default:
bNewOp = bOpEq;
break;
}
/* NOTE: an object instance variable needs special handling
*/
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
{
/* NOTE: COMPATIBILITY ISSUE:
* The HB_SUPPORT_HARBOUR in code below determines
* the way the chained send messages are handled.
@@ -272,12 +238,51 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
* be changed
*/
void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
{
BYTE bNewOp;
if( HB_SUPPORT_HARBOUR )
{
switch( bOpEq )
{
case HB_P_PLUS:
bNewOp = HB_P_PLUSEQ;
break;
case HB_P_MINUS:
bNewOp = HB_P_MINUSEQ;
break;
case HB_P_MULT:
bNewOp = HB_P_MULTEQ;
break;
case HB_P_DIVIDE:
bNewOp = HB_P_DIVEQ;
break;
case HB_P_MODULUS:
bNewOp = HB_P_MODEQ;
break;
case HB_P_POWER:
bNewOp = HB_P_EXPEQ;
break;
default:
bNewOp = bOpEq;
break;
}
}
else
bNewOp = bOpEq;
/* NOTE: an object instance variable needs special handling
*/
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
{
if( pSelf->value.asOperator.pLeft->value.asMessage.pParms )
{
hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft );
}
#ifdef HB_USE_OBJMSG_REF
else if( HB_SUPPORT_HARBOUR && bOpEq != bNewOp )
else if( bOpEq != bNewOp )
{
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
@@ -296,24 +301,6 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
}
else if( bOpEq != bNewOp )
{
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
if( HB_SUPPORT_HARBOUR )
{
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp );
return;
}
}
else
#endif
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
@@ -328,6 +315,20 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
return;
}
}
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp );
return;
}
#endif
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE )
{
#if defined( HB_MACRO_SUPPORT )
@@ -395,30 +396,35 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
{
BYTE bNewOp;
switch( bOpEq )
if( HB_SUPPORT_HARBOUR )
{
case HB_P_PLUS:
bNewOp = HB_P_PLUSEQPOP;
break;
case HB_P_MINUS:
bNewOp = HB_P_MINUSEQPOP;
break;
case HB_P_MULT:
bNewOp = HB_P_MULTEQPOP;
break;
case HB_P_DIVIDE:
bNewOp = HB_P_DIVEQPOP;
break;
case HB_P_MODULUS:
bNewOp = HB_P_MODEQPOP;
break;
case HB_P_POWER:
bNewOp = HB_P_EXPEQPOP;
break;
default:
bNewOp = bOpEq;
break;
switch( bOpEq )
{
case HB_P_PLUS:
bNewOp = HB_P_PLUSEQPOP;
break;
case HB_P_MINUS:
bNewOp = HB_P_MINUSEQPOP;
break;
case HB_P_MULT:
bNewOp = HB_P_MULTEQPOP;
break;
case HB_P_DIVIDE:
bNewOp = HB_P_DIVEQPOP;
break;
case HB_P_MODULUS:
bNewOp = HB_P_MODEQPOP;
break;
case HB_P_POWER:
bNewOp = HB_P_EXPEQPOP;
break;
default:
bNewOp = bOpEq;
break;
}
}
else
bNewOp = bOpEq;
/* NOTE: an object instance variable needs special handling
*/
@@ -429,7 +435,7 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft );
}
#ifdef HB_USE_OBJMSG_REF
else if( HB_SUPPORT_HARBOUR && bOpEq != bNewOp )
else if( bOpEq != bNewOp )
{
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
@@ -450,24 +456,6 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
}
else if( bOpEq != bNewOp )
{
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
if( HB_SUPPORT_HARBOUR )
{
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp );
return;
}
}
else
#endif
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
@@ -482,6 +470,20 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
return;
}
}
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp );
return;
}
#endif
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE )
{
HB_EXPRTYPE iOldType;
@@ -575,49 +577,52 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL )
hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL,
FALSE, bOper, HB_COMP_PARAM );
}
return;
}
else if( HB_SUPPORT_HARBOUR )
{
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO &&
pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType;
/* increase/decrease operation, leave unreferenced value on stack */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
return;
}
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( HB_SUPPORT_HARBOUR &&
pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* push reference to current value */
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* push reference to current value */
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
/* increase/decrease operation, leave unreferenced value on stack */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
}
/* increase/decrease operation, leave unreferenced value on stack */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
return;
}
#endif
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO &&
pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType;
}
/* increase/decrease operation, leave unreferenced value on stack */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
}
else
{
/* Push current value */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
/* Increment */
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
/* duplicate a value */
HB_EXPR_PCODE1( 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 );
}
/* Push current value */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
/* Increment */
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
/* duplicate a value */
HB_EXPR_PCODE1( 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 );
}
/* Generates the pcodes for post- increment/decrement expressions
@@ -653,57 +658,60 @@ void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL )
hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL,
TRUE, bOper, HB_COMP_PARAM );
}
return;
}
else if( HB_SUPPORT_HARBOUR )
{
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO &&
pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType;
/* Duplicate the reference and unref the original one -
* it will be the result of whole expression
*/
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF );
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
return;
}
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( HB_SUPPORT_HARBOUR &&
pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* push reference to current value */
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* push reference to current value */
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
/* Duplicate the reference and unref the original one -
* it will be the result of whole expression
*/
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF );
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
}
/* Duplicate the reference and unref the original one -
* it will be the result of whole expression
*/
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF );
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
return;
}
#endif
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO &&
pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType;
}
/* Duplicate the reference and unref the original one -
* it will be the result of whole expression
*/
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF );
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
}
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 );
/* Increment */
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
/* pop new value from the stack */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE );
}
/* Push current value */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
/* Duplicate value */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE );
/* Increment */
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
/* pop new value from the stack */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE );
}
/* Generates the pcodes for increment/decrement operations
@@ -738,46 +746,49 @@ void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL )
/* pop the value from the stack */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP );
}
return;
}
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( HB_SUPPORT_HARBOUR &&
pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
else if( HB_SUPPORT_HARBOUR )
{
/* push reference to current value */
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
}
#endif
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO &&
pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType;
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO &&
pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR )
{
USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType;
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType;
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
}
else
{
/* Push current value */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
/* Increment */
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
/* pop new value from the stack */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE );
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
return;
}
#ifdef HB_USE_ARRAYAT_REF
/* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */
else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT )
{
/* push reference to current value */
/* Note: change type to array reference */
pSelf->value.asOperator.pLeft->value.asList.reference = TRUE;
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
pSelf->value.asOperator.pLeft->value.asList.reference = FALSE;
/* increase/decrease operation */
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ONE );
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQPOP : HB_P_MINUSEQPOP;
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
return;
}
#endif
}
/* Push current value */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
/* Increment */
HB_EXPR_PCODE1( hb_compGenPCode1, bOper );
/* pop new value from the stack */
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE );
}
/* Generate pcode for aliased expression which contains macro operator on

View File

@@ -111,7 +111,7 @@ typedef enum
HB_P_MACROPUSH, /* 40 compile and run - leave the result on the stack */
HB_P_MACROARRAYGEN, /* 41 generate array from arguments set(s) on HVM stack { &var } */
HB_P_MACROPUSHLIST, /* 42 compile and run - leave the result on the stack */
HB_P_MACROPUSHINDEX, /* 43 compile and run - leave the result on the stack */
HB_P_MACROPUSHINDEX, /* 43 push array items using macro array index */
HB_P_MACROPUSHPARE, /* 44 compile and run - leave the result on the stack */
HB_P_MACROPUSHALIASED, /* 45 compile and run - leave the field value on the stack */
HB_P_MACROSYMBOL, /* 46 compile into a symbol name (used in function calls) */

View File

@@ -61,6 +61,7 @@ HB_EXTERN_BEGIN
#define HB_BLOCK_MACRO 1
#define HB_BLOCK_LATEEVAL 2
#define HB_BLOCK_VPARAMS 4
/* #pragma {__text,__stream,__cstream}|functionOut|functionEnd|functionStart */
#define HB_PP_STREAM_OFF 0 /* standard preprocessing */

View File

@@ -182,7 +182,7 @@ extern HB_EXPORT BOOL hb_xvmMacroSend( USHORT uiArgSets );
extern HB_EXPORT BOOL hb_xvmMacroArrayGen( USHORT uiArgSets );
extern HB_EXPORT BOOL hb_xvmMacroPush( BYTE bFlags );
extern HB_EXPORT BOOL hb_xvmMacroPushRef( void );
extern HB_EXPORT BOOL hb_xvmMacroPushIndex( BYTE bFlags );
extern HB_EXPORT BOOL hb_xvmMacroPushIndex( void );
extern HB_EXPORT BOOL hb_xvmMacroPushArg( PHB_SYMB pSymbol, BYTE bFlags );
extern HB_EXPORT BOOL hb_xvmMacroPushList( BYTE bFlags );
extern HB_EXPORT BOOL hb_xvmMacroPushAliased( BYTE bFlags );

View File

@@ -922,8 +922,8 @@ static HB_GENC_FUNC( hb_p_macropushindex )
HB_SYMBOL_UNUSED( pFunc );
HB_SYMBOL_UNUSED( lPCodePos );
fprintf( cargo->yyc, "\tHB_P_MACROPUSHINDEX, %i,\n", pFunc->pCode[ lPCodePos + 1 ] );
return 2;
fprintf( cargo->yyc, "\tHB_P_MACROPUSHINDEX,\n" );
return 1;
}
static HB_GENC_FUNC( hb_p_macropushpare )

View File

@@ -667,9 +667,8 @@ static HB_GENC_FUNC( hb_p_macropushindex )
{
HB_GENC_LABEL();
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushIndex( %d ) ) break;\n",
pFunc->pCode[ lPCodePos + 1 ] );
return 2;
fprintf( cargo->yyc, "\tif( hb_xvmMacroPushIndex() ) break;\n" );
return 1;
}
static HB_GENC_FUNC( hb_p_macropushpare )

View File

@@ -799,8 +799,8 @@ static HB_GENC_FUNC( hb_p_macropushindex )
HB_SYMBOL_UNUSED( pFunc );
HB_SYMBOL_UNUSED( lPCodePos );
fprintf( cargo->yyc, "\tHB_P_MACROPUSHINDEX, %i,\n", pFunc->pCode[ lPCodePos + 1 ] );
return 2;
fprintf( cargo->yyc, "\tHB_P_MACROPUSHINDEX,\n" );
return 1;
}
static HB_GENC_FUNC( hb_p_macropushpare )

View File

@@ -1790,6 +1790,7 @@ static PFUNCTION hb_compFunctionNew( HB_COMP_DECL, char * szName, HB_SYMBOLSCOPE
pFunc->pNOOPs = NULL;
pFunc->pJumps = NULL;
pFunc->bLateEval = TRUE;
pFunc->fVParams = FALSE;
pFunc->bError = FALSE;
pFunc->pEnum = NULL;
@@ -3546,8 +3547,7 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
}
}
}
else if( (pFunc->pCode[ 0 ] == HB_P_FRAME || pFunc->pCode[ 0 ] == HB_P_VFRAME) &&
pFunc->pCode[ 3 ] == HB_P_SFRAME )
else if( pFunc->pCode[ 0 ] == HB_P_FRAME && pFunc->pCode[ 3 ] == HB_P_SFRAME )
{
PVAR pLocal;
int iLocals = 0, iOffset = 0;
@@ -3587,8 +3587,7 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
*/
hb_compGenPCode1( 0, HB_COMP_PARAM );
memmove( pFunc->pCode + 4, pFunc->pCode + 3, pFunc->lPCodePos - 4 );
pFunc->pCode[ 0 ] = pFunc->pCode[ 0 ] == HB_P_FRAME ?
HB_P_LARGEFRAME : HB_P_LARGEVFRAME;
pFunc->pCode[ 0 ] = HB_P_LARGEFRAME;
pFunc->pCode[ 1 ] = HB_LOBYTE( iLocals );
pFunc->pCode[ 2 ] = HB_HIBYTE( iLocals );
pFunc->pCode[ 3 ] = ( BYTE )( pFunc->wParamCount );
@@ -3603,12 +3602,11 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
}
else
/* Skip LOCALs frame only when function is not declared with
* variable number of parameters (HB_P_VFRAME)
* variable number of parameters (HB_P_[LARGE]VFRAME)
*/
bSkipFRAME = pFunc->pCode[ 0 ] == HB_P_FRAME;
bSkipFRAME = !pFunc->fVParams;
/* Remove the frame pcodes if they are not needed */
if( bSkipFRAME )
{
if( bSkipSFRAME )
@@ -3622,11 +3620,17 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
memmove( pFunc->pCode, pFunc->pCode + 3, pFunc->lPCodePos );
}
}
else if( bSkipSFRAME )
else
{
pFunc->lPCodePos -= 3;
memmove( pFunc->pCode + 3 + iOffset, pFunc->pCode + 6 + iOffset,
pFunc->lPCodePos - 3 - iOffset );
if( pFunc->fVParams )
pFunc->pCode[ 0 ] = iOffset ? HB_P_LARGEVFRAME : HB_P_VFRAME;
if( bSkipSFRAME )
{
pFunc->lPCodePos -= 3;
memmove( pFunc->pCode + 3 + iOffset, pFunc->pCode + 6 + iOffset,
pFunc->lPCodePos - 3 - iOffset );
}
}
}
}

View File

@@ -207,7 +207,7 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
%type <iNumber> Descend
%type <lNumber> WhileBegin
%type <pVoid> IfElseIf Cases
%type <asExpr> ArgList ElemList BlockExpList BlockVarList BlockNoVar
%type <asExpr> ArgList ElemList BlockExpList BlockVars BlockVarList BlockNoVar
%type <asExpr> DoName DoProc DoArgument DoArgList
%type <asExpr> PareExpList1 PareExpList2 PareExpList3 PareExpListN
%type <asExpr> ExpList ExpList1 ExpList2 ExpList3
@@ -327,9 +327,9 @@ FunScope : { $$ = HB_FS_PUBLIC; }
;
Params : /*no parameters */ { $$ = 0; }
| EPSILON { HB_COMP_PARAM->functions.pLast->pCode[0] = HB_P_VFRAME; $$ = 0; }
| EPSILON { HB_COMP_PARAM->functions.pLast->fVParams = TRUE; $$ = 0; }
| ParamList { $$ = $1; }
| ParamList ',' EPSILON { HB_COMP_PARAM->functions.pLast->pCode[0] = HB_P_VFRAME; $$ = $1; }
| ParamList ',' EPSILON { HB_COMP_PARAM->functions.pLast->fVParams = TRUE; $$ = $1; }
;
AsType : /* not specified */ { HB_COMP_PARAM->cVarType = ' '; }
@@ -1120,9 +1120,9 @@ ArrayIndex : IndexList ']' { $$ = $1; }
/* NOTE: $0 represents the expression before ArrayIndex
* Don't use ArrayIndex in other context than as an array index!
*/
IndexList : '[' Expression { $$ = hb_compExprNewArrayAt( $<asExpr>0, $2, HB_COMP_PARAM ); }
| IndexList ',' Expression { $$ = hb_compExprNewArrayAt( $1, $3, HB_COMP_PARAM ); }
| IndexList ']' '[' Expression { $$ = hb_compExprNewArrayAt( $1, $4, HB_COMP_PARAM ); }
IndexList : '[' ExtExpression { $$ = hb_compExprNewArrayAt( $<asExpr>0, $2, HB_COMP_PARAM ); }
| IndexList ',' ExtExpression { $$ = hb_compExprNewArrayAt( $1, $3, HB_COMP_PARAM ); }
| IndexList ']' '[' ExtExpression { $$ = hb_compExprNewArrayAt( $1, $4, HB_COMP_PARAM ); }
;
ElemList : EmptyExtExpression { $$ = hb_compExprNewList( $1, HB_COMP_PARAM ); }
@@ -1131,7 +1131,7 @@ ElemList : EmptyExtExpression { $$ = hb_compExprNewList( $1, HB_C
CodeBlock : CBSTART { $<asExpr>$ = hb_compExprNewCodeBlock( $1.string, $1.length, $1.flags, HB_COMP_PARAM ); $1.string = NULL; } BlockNoVar
'|' BlockExpList '}' { $$ = $<asExpr>2; }
| CBSTART { $<asExpr>$ = hb_compExprNewCodeBlock( $1.string, $1.length, $1.flags, HB_COMP_PARAM ); $1.string = NULL; } BlockVarList
| CBSTART { $<asExpr>$ = hb_compExprNewCodeBlock( $1.string, $1.length, $1.flags, HB_COMP_PARAM ); $1.string = NULL; } BlockVars
'|' BlockExpList '}' { $$ = $<asExpr>2; }
;
@@ -1147,6 +1147,11 @@ BlockExpList : Expression { $$ = hb_compExprAddCodeblockExpr(
BlockNoVar : /* empty list */ { $$ = NULL; }
;
BlockVars : EPSILON { $<asExpr>0->value.asCodeblock.flags |= HB_BLOCK_VPARAMS; $$ = NULL; }
| BlockVarList { $$ = $1; }
| BlockVarList ',' EPSILON { $<asExpr>0->value.asCodeblock.flags |= HB_BLOCK_VPARAMS; $$ = $1; }
;
BlockVarList : IdentName AsType { HB_COMP_PARAM->iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $<asExpr>0, $1, HB_COMP_PARAM->cVarType, HB_COMP_PARAM ); HB_COMP_PARAM->cVarType = ' '; }
| BlockVarList ',' IdentName AsType { HB_COMP_PARAM->iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $<asExpr>0, $3, HB_COMP_PARAM->cVarType, HB_COMP_PARAM ); HB_COMP_PARAM->cVarType = ' '; }
;

File diff suppressed because it is too large Load Diff

View File

@@ -95,7 +95,7 @@ char * hb_comp_szErrors[] =
"Unsupported output language option",
"String too long",
"Code block size too big",
"Not a function with variable parameters",
"%s not declared with variable number of parameters",
"Can't find %s file"
};
@@ -249,8 +249,9 @@ HB_EXPR_PTR hb_compWarnMeaningless( HB_COMP_DECL, HB_EXPR_PTR pExpr )
void hb_compErrorCodeblock( HB_COMP_DECL, const char * szBlock )
{
BOOL fError = HB_COMP_PARAM->fError;
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BLOCK, szBlock, NULL );
HB_COMP_PARAM->fError = FALSE; /* clear error flag for this line */
HB_COMP_PARAM->fError = fError; /* restore error flag for this line */
}
void hb_compErrorMacro( HB_COMP_DECL, const char *szText )
@@ -265,8 +266,7 @@ HB_EXPR_PTR hb_compErrorRefer( HB_COMP_DECL, HB_EXPR_PTR pExpr, const char *szAl
return pExpr;
}
void hb_compErrorVParams( HB_COMP_DECL, HB_EXPR_PTR pExpr )
void hb_compErrorVParams( HB_COMP_DECL, const char * szFuncOrBlock )
{
HB_SYMBOL_UNUSED( pExpr );
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NOT_VPARAMS, NULL, NULL );
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NOT_VPARAMS, szFuncOrBlock, NULL );
}

View File

@@ -165,7 +165,7 @@ const BYTE hb_comp_pcode_len[] = {
2, /* HB_P_MACROPUSH, */
3, /* HB_P_MACROARRAYGEN, */
2, /* HB_P_MACROPUSHLIST, */
2, /* HB_P_MACROPUSHINDEX, */
1, /* HB_P_MACROPUSHINDEX, */
2, /* HB_P_MACROPUSHPARE, */
2, /* HB_P_MACROPUSHALIASED, */
1, /* HB_P_MACROSYMBOL, */

View File

@@ -146,7 +146,7 @@ static void hb_vmMacroDo( USHORT uiArgSets ); /* execute function passin
static void hb_vmMacroFunc( USHORT uiArgSets ); /* execute procedure passing arguments set(s) on HVM stack func( &var ) */
static void hb_vmMacroSend( USHORT uiArgSets ); /* execute procedure passing arguments set(s) on HVM stack func( &var ) */
static void hb_vmMacroArrayGen( USHORT uiArgSets ); /* generate array from arguments set(s) on HVM stack { &var } */
static void hb_vmMacroPushIndex( BYTE bFlags ); /* push macro array index {...}[ &var ] */
static void hb_vmMacroPushIndex( void ); /* push macro array index {...}[ &var ] */
/* Database */
static ERRCODE hb_vmSelectWorkarea( PHB_ITEM, PHB_SYMB ); /* select the workarea using a given item or a substituted value */
@@ -1703,8 +1703,8 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
break;
case HB_P_MACROPUSHINDEX:
hb_vmMacroPushIndex( pCode[ ++w ] );
++w;
hb_vmMacroPushIndex();
w++;
break;
case HB_P_MACROARRAYGEN:
@@ -3919,49 +3919,43 @@ static void hb_vmArrayDim( USHORT uiDimensions ) /* generates an uiDimensions Ar
/* Macros */
/* ------------------------------- */
static void hb_vmMacroPushIndex( BYTE bFlags )
static void hb_vmMacroPushIndex( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroPushIndex(%d)", ( int ) bFlags));
ULONG ulIndexes;
/* compile and run - leave the result on the stack
* the topmost element on the stack contains a macro
* string for compilation
HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroPushIndex()"));
/*
* Now the top most element on the stack points to number of
* additional indexes to generated array
*/
hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHINDEX, bFlags );
ulIndexes = hb_itemGetNL( hb_stackItemFromTop( -1 ) );
hb_stackDec();
/* If no RT errors during compilation */
if( s_uiActionRequest == 0 )
if( ulIndexes > 1 )
{
/*
* Now the top most element on the stack points to number of
* additional indexes to generated array
*/
ULONG ulIndexes = hb_itemGetNL( hb_stackItemFromTop( -1 ) );
hb_stackDec();
PHB_ITEM pIndexArray;
ULONG ul = 1;
if( ulIndexes )
hb_vmArrayGen( ulIndexes - 1 );
pIndexArray = hb_itemNew( hb_stackItemFromTop( -1 ) );
hb_stackPop();
/* First index is still on stack.*/
do
{
PHB_ITEM pIndexArray;
ULONG ul = 1;
hb_vmArrayGen( ulIndexes );
pIndexArray = hb_itemNew( hb_stackItemFromTop( -1 ) );
hb_stackPop();
/* First index is still on stack.*/
do
{
hb_vmArrayPush();
/* RT error? */
if( s_uiActionRequest != 0 )
break;
hb_vmPush( hb_arrayGetItemPtr( pIndexArray, ul ) );
}
while( ++ul <= ulIndexes );
hb_itemRelease( pIndexArray );
hb_vmArrayPush();
/* RT error? */
if( s_uiActionRequest != 0 )
break;
hb_vmPush( hb_arrayGetItemPtr( pIndexArray, ul ) );
}
while( ++ul < ulIndexes );
hb_itemRelease( pIndexArray );
}
else if( ulIndexes == 0 )
hb_vmPushNil(); /* It will force RT error later in array push or pop */
}
/*
@@ -8276,11 +8270,11 @@ HB_EXPORT BOOL hb_xvmMacroPushRef( void )
HB_XVM_RETURN
}
HB_EXPORT BOOL hb_xvmMacroPushIndex( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPushIndex( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushIndex(%d)", bFlags));
HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushIndex()"));
hb_vmMacroPushIndex( bFlags );
hb_vmMacroPushIndex();
HB_XVM_RETURN
}

View File

@@ -399,7 +399,6 @@ char * hb_macroTextSubst( char * szString, ULONG *pulStringLen )
* iContext contains additional info when HB_SM_XBASE is enabled
* = 0 - in Clipper strict compatibility mode
* = HB_P_MACROPUSHLIST
* = HB_P_MACROPUSHINDEX
* = HB_P_MACROPUSHPARE
*
* iContext contains HB_P_MACROPUSHPARE if a macro is used inside a codeblock
@@ -488,13 +487,8 @@ void hb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags )
{
hb_macroRun( &struMacro );
if( iContext )
{
if( iContext == HB_P_MACROPUSHLIST )
hb_vmPushLong( struMacro.uiListElements + 1 );
else if( iContext == HB_P_MACROPUSHINDEX )
hb_vmPushLong( struMacro.uiListElements );
}
if( iContext == HB_P_MACROPUSHLIST )
hb_vmPushLong( struMacro.uiListElements + 1 );
}
else
hb_macroSyntaxError( &struMacro );