From 3b543d303902c7939bf2347ea435139db4d2a4b4 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 10 Jun 2008 23:17:39 +0000 Subject: [PATCH] 2008-06-11 01:17 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/hbwince.c ! fixed typo in GetDriveTypeA() * temporary disabled GetDriveTypeW() call because not all CRTLs for WinCE support it * harbour/include/hbexpra.c * harbour/include/hbexprb.c * harbour/source/common/expropt2.c * harbour/source/compiler/harbour.y * harbour/source/compiler/harbour.yyc * added full expression list stripping - it enables optimizations in few additional places ! fixed code to always refresh expression address after direct or indirect reduction - seems that we have some memory leaks and possible GPFs not located so far Please make tests with your code. --- harbour/ChangeLog | 18 +++ harbour/include/hbexpra.c | 53 ++++--- harbour/include/hbexprb.c | 203 +++++++++++------------- harbour/source/common/expropt2.c | 7 - harbour/source/common/hbwince.c | 11 +- harbour/source/compiler/harbour.y | 81 +++++----- harbour/source/compiler/harbour.yyc | 233 ++++++++++++++-------------- 7 files changed, 312 insertions(+), 294 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index afa679c8b7..13d0b61962 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,24 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-11 01:17 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/common/hbwince.c + ! fixed typo in GetDriveTypeA() + * temporary disabled GetDriveTypeW() call because not all CRTLs for + WinCE support it + + * harbour/include/hbexpra.c + * harbour/include/hbexprb.c + * harbour/source/common/expropt2.c + * harbour/source/compiler/harbour.y + * harbour/source/compiler/harbour.yyc + * added full expression list stripping - it enables optimizations + in few additional places + ! fixed code to always refresh expression address after direct or + indirect reduction - seems that we have some memory leaks and + possible GPFs not located so far + Please make tests with your code. + 2008-06-10 15:35 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com * harbour/source/rtl/gtwvt/gtwvt.c ! Fixed maximized state. Borders were missing. diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index 991e42ad6f..1d49644d5a 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -216,10 +216,13 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_EXPR_PTR pArg, pNext; USHORT uiCount; - HB_EXPR_USE( pParms, HB_EA_REDUCE ); + pParms->value.asList.pExprList = HB_EXPR_USE( pParms->value.asList.pExprList, HB_EA_REDUCE ); pArg = pParms->value.asList.pExprList; - if( pArg->ExprType == HB_ET_LIST ) + /* When -kc switch is used expression list is not stripped + * in reduce operation + */ + if( !HB_SUPPORT_HARBOUR && pArg->ExprType == HB_ET_LIST ) { pNext = pArg->pNext; pArg->pNext = NULL; @@ -549,17 +552,23 @@ static void hb_compExprCheckStaticInitializers( HB_EXPR_PTR pLeftExpr, HB_EXPR_P pPrev = &pRightExpr->value.asList.pExprList; while( pElem ) { - /* NOTE: During reduction the expression can be replaced by the - * new one - this will break the linked list of expressions. - * (classical case of replacing an item in a linked list) - */ - pNext = pElem->pNext; /* store next expression in case the current will be reduced */ - pElem = hb_compExprListStrip( HB_EXPR_USE( pElem, HB_EA_REDUCE ), HB_COMP_PARAM ); + pNext = pElem->pNext; /* store next expression in case the current will be reduced */ + if( !HB_SUPPORT_HARBOUR ) + { + /* When -kc switch is used expression list is not stripped + * in reduce operation + */ + /* NOTE: During reduction the expression can be replaced by the + * new one - this will break the linked list of expressions. + * (classical case of replacing an item in a linked list) + */ + pElem = hb_compExprListStrip( pElem, HB_COMP_PARAM ); + *pPrev = pElem; /* store a new expression into the previous one */ + pElem->pNext = pNext; /* restore the link to next expression */ + pPrev = &pElem->pNext; + } if( pElem->ExprType > HB_ET_FUNREF ) hb_compErrorStatic( HB_COMP_PARAM, pLeftExpr->value.asSymbol, pElem ); - *pPrev = pElem; /* store a new expression into the previous one */ - pElem->pNext = pNext; /* restore the link to next expression */ - pPrev = &pElem->pNext; pElem = pNext; } } @@ -581,7 +590,13 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx pExpr->value.asOperator.pLeft = pLeftExpr; /* Try to reduce the assigned value */ - pRightExpr = hb_compExprListStrip( HB_EXPR_USE( pRightExpr, HB_EA_REDUCE ), HB_COMP_PARAM ); + pRightExpr = HB_EXPR_USE( pRightExpr, HB_EA_REDUCE ); + /* When -kc switch is used expression list is not stripped + * in reduce operation + */ + if( !HB_SUPPORT_HARBOUR ) + pRightExpr = hb_compExprListStrip( pRightExpr, HB_COMP_PARAM ); + pExpr->value.asOperator.pRight = pRightExpr; if( pRightExpr->ExprType == HB_ET_ARGLIST ) @@ -592,12 +607,6 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx */ hb_compExprCheckStaticInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM ); } - else if( pRightExpr->ExprType > HB_ET_FUNREF ) - { - /* Illegal initializer for static variable (not a constant value) - */ - hb_compErrorStatic( HB_COMP_PARAM, pLeftExpr->value.asSymbol, pRightExpr ); - } else if( pRightExpr->ExprType == HB_ET_ARRAY ) { /* { elem1, elem2, elemN } was used as initializer @@ -606,6 +615,12 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx */ hb_compExprCheckStaticInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM ); } + else if( pRightExpr->ExprType > HB_ET_FUNREF ) + { + /* Illegal initializer for static variable (not a constant value) + */ + hb_compErrorStatic( HB_COMP_PARAM, pLeftExpr->value.asSymbol, pRightExpr ); + } return pExpr; } @@ -693,7 +708,7 @@ HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR pExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR pExpr, HB_COMP_DECL ) { - return hb_compExprListStrip( HB_EXPR_USE( pExpr, HB_EA_REDUCE ), HB_COMP_PARAM ); + return HB_EXPR_USE( pExpr, HB_EA_REDUCE ); } #endif diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 9cc2c36a30..cfb8292a81 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -144,7 +144,7 @@ static void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); static void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); static void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); static void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_COMP_DECL ); -static ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, BOOL fStrip, HB_COMP_DECL ); +static HB_EXPR_PTR hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL ); const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ] = { @@ -523,7 +523,7 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) switch( iMessage ) { case HB_EA_REDUCE: - hb_compExprReduceList( pSelf, FALSE, HB_COMP_PARAM ); + pSelf = hb_compExprReduceList( pSelf, HB_COMP_PARAM ); break; case HB_EA_ARRAY_AT: @@ -619,7 +619,7 @@ static HB_EXPR_FUNC( hb_compExprUseHash ) switch( iMessage ) { case HB_EA_REDUCE: - hb_compExprReduceList( pSelf, FALSE, HB_COMP_PARAM ); + pSelf = hb_compExprReduceList( pSelf, HB_COMP_PARAM ); break; case HB_EA_ARRAY_AT: @@ -762,6 +762,7 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) switch( iMessage ) { case HB_EA_REDUCE: + pSelf->value.asReference = HB_EXPR_USE( pSelf->value.asReference, HB_EA_REDUCE ); break; case HB_EA_ARRAY_AT: HB_COMP_ERROR_TYPE( pSelf ); @@ -833,8 +834,7 @@ static HB_EXPR_FUNC( hb_compExprUseIIF ) switch( iMessage ) { case HB_EA_REDUCE: - hb_compExprReduceList( pSelf, FALSE, HB_COMP_PARAM ); - pSelf = hb_compExprReduceIIF( pSelf, HB_COMP_PARAM ); + pSelf = hb_compExprReduceIIF( hb_compExprReduceList( pSelf, HB_COMP_PARAM ), HB_COMP_PARAM ); break; case HB_EA_ARRAY_AT: @@ -936,7 +936,12 @@ static HB_EXPR_FUNC( hb_compExprUseList ) switch( iMessage ) { case HB_EA_REDUCE: - if( HB_SUPPORT_XBASE ) + pSelf = hb_compExprReduceList( pSelf, HB_COMP_PARAM ); + + if( HB_SUPPORT_HARBOUR ) + pSelf = hb_compExprListStrip( pSelf, HB_COMP_PARAM ); + + if( HB_SUPPORT_XBASE && pSelf->ExprType == HB_ET_LIST ) { if( hb_compExprListLen( pSelf ) == 1 ) { @@ -950,12 +955,6 @@ static HB_EXPR_FUNC( hb_compExprUseList ) } } } - - hb_compExprReduceList( pSelf, FALSE, HB_COMP_PARAM ); - /* NOTE: if the list contains a single expression then the list - * is not reduced to this expression - if you need that reduction - * then call hb_compExprListStrip() additionaly - */ break; case HB_EA_ARRAY_AT: @@ -1060,7 +1059,7 @@ static HB_EXPR_FUNC( hb_compExprUseArgList ) switch( iMessage ) { case HB_EA_REDUCE: - hb_compExprReduceList( pSelf, FALSE, HB_COMP_PARAM ); + pSelf = hb_compExprReduceList( pSelf, HB_COMP_PARAM ); break; case HB_EA_ARRAY_AT: @@ -1124,7 +1123,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList ) switch( iMessage ) { case HB_EA_REDUCE: - hb_compExprReduceList( pSelf, FALSE, HB_COMP_PARAM ); + pSelf = hb_compExprReduceList( pSelf, HB_COMP_PARAM ); break; case HB_EA_ARRAY_AT: @@ -1597,12 +1596,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) /* Reduce the expressions on the list of arguments */ if( pSelf->value.asFunCall.pParms ) - { - if( HB_SUPPORT_HARBOUR ) - hb_compExprReduceList( pSelf->value.asFunCall.pParms, TRUE, HB_COMP_PARAM ); - else - pSelf->value.asFunCall.pParms = HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_REDUCE ); - } + pSelf->value.asFunCall.pParms = HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_REDUCE ); if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME ) { @@ -1968,6 +1962,15 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) switch( iMessage ) { case HB_EA_REDUCE: + /* NOTE: direct reduction not used for HB_ET_LIST to avoid + * list stripping before PUSH/POP operations + */ + if( pSelf->value.asAlias.pAlias->ExprType == HB_ET_LIST ) + pSelf->value.asAlias.pAlias = hb_compExprReduceList( pSelf->value.asAlias.pAlias, HB_COMP_PARAM ); + else + pSelf->value.asAlias.pAlias = HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_REDUCE ); + break; + case HB_EA_ARRAY_AT: case HB_EA_ARRAY_INDEX: case HB_EA_LVALUE: @@ -1976,15 +1979,6 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) case HB_EA_PUSH_PCODE: { HB_EXPR_PTR pAlias = pSelf->value.asAlias.pAlias; - BOOL bReduced = FALSE; - - if( pAlias->ExprType == HB_ET_LIST ) - { - /* ( expr1, expr2, ... )->variable - */ - pSelf->value.asAlias.pAlias = HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_REDUCE ); - bReduced = TRUE; - } if( pAlias->ExprType == HB_ET_MACRO || pSelf->value.asAlias.pVar->ExprType == HB_ET_MACRO ) { @@ -2016,7 +2010,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) else hb_compErrorAlias( HB_COMP_PARAM, pAlias ); } - else if( bReduced ) + else if( pAlias->ExprType == HB_ET_LIST ) { /* * ( expression )->var @@ -2033,13 +2027,6 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) case HB_EA_POP_PCODE: { HB_EXPR_PTR pAlias = pSelf->value.asAlias.pAlias; - BOOL bReduced = FALSE; - - if( pAlias->ExprType == HB_ET_LIST ) - { - pSelf->value.asAlias.pAlias = HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_REDUCE ); - bReduced = TRUE; - } if( pAlias->ExprType == HB_ET_MACRO || pSelf->value.asAlias.pVar->ExprType == HB_ET_MACRO ) { @@ -2070,7 +2057,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) else hb_compErrorAlias( HB_COMP_PARAM, pAlias ); } - else if( bReduced ) + else if( pAlias->ExprType == HB_ET_LIST ) { /* * ( expression )->var @@ -2115,6 +2102,10 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) switch( iMessage ) { case HB_EA_REDUCE: + pSelf->value.asAlias.pAlias = HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_REDUCE ); + pSelf->value.asAlias.pExpList = HB_EXPR_USE( pSelf->value.asAlias.pExpList, HB_EA_REDUCE ); + break; + case HB_EA_ARRAY_AT: case HB_EA_ARRAY_INDEX: break; @@ -2320,13 +2311,11 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) switch( iMessage ) { case HB_EA_REDUCE: - { - /* Clipper does not reduce object expressions */ - if( HB_SUPPORT_HARBOUR && pSelf->value.asMessage.pObject ) - pSelf->value.asMessage.pObject = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_REDUCE ), HB_COMP_PARAM ); - if( pSelf->value.asMessage.pParms ) /* Is it a method call ? */ - pSelf->value.asMessage.pParms = HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_REDUCE ); - } + /* Clipper does not reduce object expressions */ + if( HB_SUPPORT_HARBOUR && pSelf->value.asMessage.pObject ) + pSelf->value.asMessage.pObject = HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_REDUCE ); + if( pSelf->value.asMessage.pParms ) /* Is it a method call ? */ + pSelf->value.asMessage.pParms = HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_REDUCE ); break; case HB_EA_ARRAY_AT: @@ -2411,7 +2400,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostInc ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; case HB_EA_ARRAY_AT: @@ -2449,7 +2438,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostDec ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; case HB_EA_ARRAY_AT: @@ -2485,8 +2474,8 @@ static HB_EXPR_FUNC( hb_compExprUseAssign ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2561,8 +2550,8 @@ static HB_EXPR_FUNC( hb_compExprUsePlusEq ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2601,8 +2590,8 @@ static HB_EXPR_FUNC( hb_compExprUseMinusEq ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2641,8 +2630,8 @@ static HB_EXPR_FUNC( hb_compExprUseMultEq ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2681,8 +2670,8 @@ static HB_EXPR_FUNC( hb_compExprUseDivEq ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2721,8 +2710,8 @@ static HB_EXPR_FUNC( hb_compExprUseModEq ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2761,8 +2750,8 @@ static HB_EXPR_FUNC( hb_compExprUseExpEq ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -2801,8 +2790,8 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceOr( pSelf, HB_COMP_PARAM ); break; @@ -2886,8 +2875,8 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceAnd( pSelf, HB_COMP_PARAM ); break; @@ -2974,7 +2963,7 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) { HB_EXPR_PTR pExpr; - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); pExpr = pSelf->value.asOperator.pLeft; if( pExpr->ExprType == HB_ET_LOGICAL ) @@ -3047,8 +3036,8 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceEQ( pSelf, HB_COMP_PARAM ); break; @@ -3105,8 +3094,8 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceEQ( pSelf, HB_COMP_PARAM ); break; @@ -3161,8 +3150,8 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceLT( pSelf, HB_COMP_PARAM ); break; @@ -3217,8 +3206,8 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceGT( pSelf, HB_COMP_PARAM ); break; @@ -3273,8 +3262,8 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceLE( pSelf, HB_COMP_PARAM ); break; @@ -3330,8 +3319,8 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceGE( pSelf, HB_COMP_PARAM ); break; @@ -3387,8 +3376,8 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceNE( pSelf, HB_COMP_PARAM ); break; @@ -3444,11 +3433,9 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) switch( iMessage ) { case HB_EA_REDUCE: - { - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf = hb_compExprReduceIN( pSelf, HB_COMP_PARAM ); - } + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); + pSelf = hb_compExprReduceIN( pSelf, HB_COMP_PARAM ); break; case HB_EA_ARRAY_AT: @@ -3503,8 +3490,8 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReducePlus( pSelf, HB_COMP_PARAM ); break; @@ -3606,8 +3593,8 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceMinus( pSelf, HB_COMP_PARAM ); break; @@ -3688,8 +3675,8 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceMult( pSelf, HB_COMP_PARAM ); break; @@ -3745,8 +3732,8 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf = hb_compExprReduceDiv( pSelf, HB_COMP_PARAM ); break; @@ -3802,8 +3789,8 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); pSelf =hb_compExprReduceMod( pSelf, HB_COMP_PARAM ); break; @@ -3859,12 +3846,10 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) switch( iMessage ) { case HB_EA_REDUCE: + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); + pSelf->value.asOperator.pRight = HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ); if( HB_SUPPORT_HARBOUR ) /* Clipper doesn't optimize it */ - { - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); - pSelf->value.asOperator.pRight = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_REDUCE ), HB_COMP_PARAM ); pSelf =hb_compExprReducePower( pSelf, HB_COMP_PARAM ); - } break; case HB_EA_ARRAY_AT: @@ -3919,7 +3904,7 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); pSelf = hb_compExprReduceNegate( pSelf, HB_COMP_PARAM ); break; @@ -3974,7 +3959,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreInc ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -4014,7 +3999,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreDec ) switch( iMessage ) { case HB_EA_REDUCE: - pSelf->value.asOperator.pLeft = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ), HB_COMP_PARAM ); + pSelf->value.asOperator.pLeft = HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_REDUCE ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_LVALUE ); break; @@ -5038,29 +5023,27 @@ static void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_ * * pExpr is the first expression on the list */ -static ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, BOOL fStrip, HB_COMP_DECL ) +static HB_EXPR_PTR hb_compExprReduceList( HB_EXPR_PTR pList, HB_COMP_DECL ) { - HB_EXPR_PTR pNext; + HB_EXPR_PTR pNext, pExpr; HB_EXPR_PTR * pPrev; - ULONG ulCnt = 0; /* NOTE: During optimalization an expression on the list can be * replaced by the new one */ - pPrev = &pExpr->value.asList.pExprList; - pExpr = pExpr->value.asList.pExprList; + pPrev = &pList->value.asList.pExprList; + pExpr = pList->value.asList.pExprList; while( pExpr ) { pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - if( fStrip ) + if( HB_SUPPORT_HARBOUR ) pExpr = hb_compExprListStrip( pExpr, HB_COMP_PARAM ); *pPrev = pExpr; /* store a new expression into the previous one */ pExpr->pNext = pNext; /* restore the link to next expression */ pPrev = &pExpr->pNext; pExpr = pNext; - ++ulCnt; } - return ulCnt; + return pList; } diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index 31bdf40c4a..2df1b525ad 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -1421,13 +1421,6 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL ) /* get conditional expression */ pExpr = pSelf->value.asList.pExprList; - if( pExpr->ExprType == HB_ET_LIST ) - { - HB_EXPR_PTR pNext = pExpr->pNext; - pExpr = hb_compExprListStrip( pExpr, HB_COMP_PARAM ); - pExpr->pNext = pNext; - pSelf->value.asList.pExprList = pExpr; - } if( pExpr->ExprType == HB_ET_LOGICAL ) { diff --git a/harbour/source/common/hbwince.c b/harbour/source/common/hbwince.c index c09e6b3f43..ffc32b3e72 100644 --- a/harbour/source/common/hbwince.c +++ b/harbour/source/common/hbwince.c @@ -502,16 +502,23 @@ DWORD WINAPI GetFileAttributesA( LPCSTR path ) return dw; } -UINT WINAPI GetDriveTypeA( LPCSTR filename ) +UINT WINAPI GetDriveTypeA( LPCSTR path ) { + /* temporary disabled - not all WinCE compilers support GetDriveTypeW() */ +#if 0 LPWSTR wpath; - UINT ui + UINT ui; wpath = hb_mbtowc( path ); ui = GetDriveTypeW( wpath ); hb_xfree( wpath ); return ui; +#else + HB_SYMBOL_UNUSED( path ); + + return DRIVE_UNKNOWN; +#endif } BOOL WINAPI GetVersionExA( OSVERSIONINFOA * v ) diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 78f32fd79f..6b4970c558 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -882,7 +882,7 @@ LValue : IdentName { $$ = hb_compExprNewVar( $1, HB_COMP_ | MacroExpr | ObjectData | VariableAt - | PareExpList { $$ = hb_compExprListStrip( $1, NULL ); } + | PareExpList { $$ = hb_compExprListStrip( $1, HB_COMP_PARAM ); } ; /* NOTE: The rule: Expression Operator Expression @@ -1548,10 +1548,11 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */ $1 = HB_COMP_PARAM->currLine; hb_compDebugStart(); ++HB_COMP_PARAM->functions.pLast->wForCounter; + $2 = hb_compExprReduce( $2, HB_COMP_PARAM ); $$ = hb_compExprGenPush( hb_compExprAssign( $2, $4, HB_COMP_PARAM ), HB_COMP_PARAM ); - if( hb_compExprAsSymbol( $2 ) ) + if( hb_compExprAsSymbol( $2 ) ) { - hb_compForStart( HB_COMP_PARAM, hb_compExprAsSymbol( $2 ), FALSE ); + hb_compForStart( HB_COMP_PARAM, hb_compExprAsSymbol( $2 ), FALSE ); } } TO ExpList StepExpr /* 6 7 8 */ @@ -1574,18 +1575,28 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */ hb_compLinePush( HB_COMP_PARAM ); HB_COMP_PARAM->currLine = iLine; - iSign = $8 ? hb_compExprAsNumSign( $8 ) : 1; if( $8 ) + { + $8 = hb_compExprReduce( $8, HB_COMP_PARAM ); + iSign = hb_compExprAsNumSign( $8 ); HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprSetOperand( hb_compExprNewPlusEq( $2, HB_COMP_PARAM ), $8, HB_COMP_PARAM ), HB_COMP_PARAM ) ); - else - HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprNewPreInc( $2, HB_COMP_PARAM ), HB_COMP_PARAM ) ); - hb_compGenJumpHere( ( ULONG ) $9, HB_COMP_PARAM ); - hb_compExprGenPush( $7, HB_COMP_PARAM ); /* end */ - if( iSign ) - hb_compGenPCode1( iSign > 0 ? HB_P_GREATER : HB_P_LESS, HB_COMP_PARAM ); + } else { - hb_compExprGenPush( $8, HB_COMP_PARAM ); /* step */ + iSign = 1; + HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprNewPreInc( $2, HB_COMP_PARAM ), HB_COMP_PARAM ) ); + } + hb_compGenJumpHere( ( ULONG ) $9, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $7, HB_COMP_PARAM ) ); /* end */ + if( iSign ) + { + hb_compGenPCode1( iSign > 0 ? HB_P_GREATER : HB_P_LESS, HB_COMP_PARAM ); + if( $8 ) + HB_COMP_EXPR_DELETE( $8 ); + } + else + { + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $8, HB_COMP_PARAM ) ); /* step */ hb_compGenPCode1( HB_P_FORTEST, HB_COMP_PARAM ); } @@ -1593,10 +1604,7 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */ hb_compLoopEnd( HB_COMP_PARAM ); if( hb_compExprAsSymbol( $2 ) ) hb_compForEnd( HB_COMP_PARAM, hb_compExprAsSymbol( $2 ) ); - HB_COMP_EXPR_DELETE( $7 ); HB_COMP_EXPR_DELETE( $5 ); /* deletes $5, $2, $4 */ - if( $8 ) - HB_COMP_EXPR_DELETE( $8 ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); } ; @@ -1650,6 +1658,8 @@ ForEach : FOREACH ForList IN ForArgs /* 1 2 3 4 */ { /* 7 */ + $2 = hb_compExprReduce( $2, HB_COMP_PARAM ); + $4 = hb_compExprReduce( $4, HB_COMP_PARAM ); hb_compEnumStart( HB_COMP_PARAM, $2, $4, $6 ); hb_compLoopStart( HB_COMP_PARAM, TRUE ); @@ -2320,11 +2330,11 @@ static void hb_compRTVariableGen( HB_COMP_DECL, char * szCreateFun ) /* push variable names to create */ while( pVar->pNext ) { - hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); + pVar->pVar = hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); pVar = pVar->pNext; ++usCount; } - hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); + pVar->pVar = hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); ++usCount; /* call function that will create either PUBLIC or PRIVATE variables */ @@ -2364,7 +2374,7 @@ void hb_compRTVariableKill( HB_COMP_DECL, PFUNCTION pFunc ) static HB_EXPR_PTR hb_compArrayDimPush( HB_EXPR_PTR pInitValue, HB_COMP_DECL ) { - USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); + USHORT uCount = ( USHORT ) hb_compExprListLen( pInitValue ); if( uCount == 1 && hb_compExprIsInteger( pInitValue->value.asList.pExprList ) && hb_compExprAsInteger( pInitValue->value.asList.pExprList ) == 0 ) @@ -2397,10 +2407,10 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D hb_compStaticDefStart( HB_COMP_PARAM ); /* switch to statics pcode buffer */ /* create an array */ pInitValue = hb_compArrayDimPush( pInitValue, HB_COMP_PARAM ); + /* now pop an array */ + pVar = hb_compExprGenPop( pVar, HB_COMP_PARAM ); /* check if valid initializers were used but don't generate any code */ pAssign = hb_compExprAssignStatic( pVar, pInitValue, HB_COMP_PARAM ); - /* now pop an array */ - hb_compExprGenPop( pVar, HB_COMP_PARAM ); /* delete all used expressions */ HB_COMP_EXPR_DELETE( pAssign ); hb_compStaticDefEnd( HB_COMP_PARAM, szName ); @@ -2483,38 +2493,29 @@ BOOL hb_compForEachVarError( HB_COMP_DECL, char *szVarName ) static void hb_compForEnd( HB_COMP_DECL, char *szVar ) { - HB_ENUMERATOR_PTR pEnumVar; + HB_ENUMERATOR_PTR * pEnumVar; HB_SYMBOL_UNUSED( szVar ); - pEnumVar = HB_COMP_PARAM->functions.pLast->pEnum; - if( pEnumVar->pNext ) + pEnumVar = &HB_COMP_PARAM->functions.pLast->pEnum; + if( *pEnumVar ) { - HB_ENUMERATOR_PTR pLast = pEnumVar; - - while( pEnumVar->pNext ) - { - pLast = pEnumVar; - pEnumVar = pEnumVar->pNext; - } - hb_xfree( pEnumVar ); - pLast->pNext = NULL; - } - else - { - hb_xfree( pEnumVar ); - HB_COMP_PARAM->functions.pLast->pEnum = NULL; + while( ( *pEnumVar )->pNext ) + pEnumVar = &( *pEnumVar )->pNext; + + hb_xfree( *pEnumVar ); + *pEnumVar = NULL; } } static HB_CARGO2_FUNC( hb_compEnumEvalStart ) { - char * szName = hb_compExprAsSymbol( (HB_EXPR_PTR)cargo ); + char * szName = hb_compExprAsSymbol( ( HB_EXPR_PTR ) cargo ); if( szName ) hb_compForStart( HB_COMP_PARAM, szName, TRUE ); - hb_compExprGenPush( (HB_EXPR_PTR)dummy, HB_COMP_PARAM ); /* expression */ - hb_compExprGenPush( (HB_EXPR_PTR)cargo, HB_COMP_PARAM ); /* variable */ + hb_compExprGenPush( ( HB_EXPR_PTR ) dummy, HB_COMP_PARAM ); /* expression */ + hb_compExprGenPush( ( HB_EXPR_PTR ) cargo, HB_COMP_PARAM ); /* variable */ } static void hb_compEnumStart( HB_COMP_DECL, HB_EXPR_PTR pVars, HB_EXPR_PTR pExprs, int descend ) @@ -2555,7 +2556,7 @@ static void hb_compEnumNext( HB_COMP_DECL, HB_EXPR_PTR pExpr, int descend ) static HB_CARGO_FUNC( hb_compEnumEvalEnd ) { - char * szName = hb_compExprAsSymbol( (HB_EXPR_PTR)cargo ); + char * szName = hb_compExprAsSymbol( ( HB_EXPR_PTR ) cargo ); if( szName ) hb_compForEnd( HB_COMP_PARAM, szName ); diff --git a/harbour/source/compiler/harbour.yyc b/harbour/source/compiler/harbour.yyc index 520a1fd644..8f3b38dbb6 100644 --- a/harbour/source/compiler/harbour.yyc +++ b/harbour/source/compiler/harbour.yyc @@ -1078,15 +1078,15 @@ static const yytype_uint16 yyrline[] = 1434, 1437, 1441, 1445, 1448, 1454, 1461, 1462, 1465, 1465, 1468, 1469, 1477, 1478, 1477, 1489, 1490, 1489, 1502, 1502, 1502, 1504, 1504, 1509, 1514, 1508, 1528, 1537, 1541, 1542, - 1546, 1558, 1563, 1545, 1604, 1605, 1608, 1609, 1612, 1620, - 1621, 1622, 1623, 1626, 1627, 1630, 1631, 1634, 1635, 1638, - 1639, 1644, 1650, 1659, 1643, 1679, 1680, 1684, 1683, 1696, - 1703, 1711, 1712, 1716, 1715, 1725, 1726, 1735, 1735, 1738, - 1738, 1741, 1743, 1746, 1746, 1746, 1751, 1759, 1770, 1780, - 1750, 1811, 1812, 1815, 1816, 1824, 1825, 1828, 1837, 1838, - 1839, 1842, 1853, 1871, 1872, 1876, 1875, 1883, 1882, 1893, - 1894, 1897, 1898, 1899, 1900, 1901, 1904, 1905, 1906, 1907, - 1908, 1912, 1911, 1934, 1935, 1938, 1939 + 1546, 1559, 1564, 1545, 1612, 1613, 1616, 1617, 1620, 1628, + 1629, 1630, 1631, 1634, 1635, 1638, 1639, 1642, 1643, 1646, + 1647, 1652, 1658, 1669, 1651, 1689, 1690, 1694, 1693, 1706, + 1713, 1721, 1722, 1726, 1725, 1735, 1736, 1745, 1745, 1748, + 1748, 1751, 1753, 1756, 1756, 1756, 1761, 1769, 1780, 1790, + 1760, 1821, 1822, 1825, 1826, 1834, 1835, 1838, 1847, 1848, + 1849, 1852, 1863, 1881, 1882, 1886, 1885, 1893, 1892, 1903, + 1904, 1907, 1908, 1909, 1910, 1911, 1914, 1915, 1916, 1917, + 1918, 1922, 1921, 1944, 1945, 1948, 1949 }; #endif @@ -5510,7 +5510,7 @@ yyreduce: case 317: #line 885 "harbour.y" - { (yyval.asExpr) = hb_compExprListStrip( (yyvsp[(1) - (1)].asExpr), NULL ); ;} + { (yyval.asExpr) = hb_compExprListStrip( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} break; case 339: @@ -6579,6 +6579,7 @@ yyreduce: (yyvsp[(1) - (4)].lNumber) = HB_COMP_PARAM->currLine; hb_compDebugStart(); ++HB_COMP_PARAM->functions.pLast->wForCounter; + (yyvsp[(2) - (4)].asExpr) = hb_compExprReduce( (yyvsp[(2) - (4)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compExprGenPush( hb_compExprAssign( (yyvsp[(2) - (4)].asExpr), (yyvsp[(4) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); if( hb_compExprAsSymbol( (yyvsp[(2) - (4)].asExpr) ) ) { @@ -6588,7 +6589,7 @@ yyreduce: break; case 551: -#line 1558 "harbour.y" +#line 1559 "harbour.y" { /* 9 */ hb_compLoopStart( HB_COMP_PARAM, TRUE ); (yyval.lNumber) = hb_compGenJump( 0, HB_COMP_PARAM ); @@ -6596,14 +6597,14 @@ yyreduce: break; case 552: -#line 1563 "harbour.y" +#line 1564 "harbour.y" { /* 11 */ (yyval.lNumber) = HB_COMP_PARAM->functions.pLast->lPCodePos; ;} break; case 553: -#line 1567 "harbour.y" +#line 1568 "harbour.y" { int iSign, iLine; @@ -6614,18 +6615,28 @@ yyreduce: hb_compLinePush( HB_COMP_PARAM ); HB_COMP_PARAM->currLine = iLine; - iSign = (yyvsp[(8) - (12)].asExpr) ? hb_compExprAsNumSign( (yyvsp[(8) - (12)].asExpr) ) : 1; if( (yyvsp[(8) - (12)].asExpr) ) + { + (yyvsp[(8) - (12)].asExpr) = hb_compExprReduce( (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ); + iSign = hb_compExprAsNumSign( (yyvsp[(8) - (12)].asExpr) ); HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprSetOperand( hb_compExprNewPlusEq( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); - else - HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprNewPreInc( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); - hb_compGenJumpHere( ( ULONG ) (yyvsp[(9) - (12)].lNumber), HB_COMP_PARAM ); - hb_compExprGenPush( (yyvsp[(7) - (12)].asExpr), HB_COMP_PARAM ); /* end */ - if( iSign ) - hb_compGenPCode1( iSign > 0 ? HB_P_GREATER : HB_P_LESS, HB_COMP_PARAM ); + } else { - hb_compExprGenPush( (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ); /* step */ + iSign = 1; + HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprNewPreInc( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); + } + hb_compGenJumpHere( ( ULONG ) (yyvsp[(9) - (12)].lNumber), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(7) - (12)].asExpr), HB_COMP_PARAM ) ); /* end */ + if( iSign ) + { + hb_compGenPCode1( iSign > 0 ? HB_P_GREATER : HB_P_LESS, HB_COMP_PARAM ); + if( (yyvsp[(8) - (12)].asExpr) ) + HB_COMP_EXPR_DELETE( (yyvsp[(8) - (12)].asExpr) ); + } + else + { + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ) ); /* step */ hb_compGenPCode1( HB_P_FORTEST, HB_COMP_PARAM ); } @@ -6633,26 +6644,23 @@ yyreduce: hb_compLoopEnd( HB_COMP_PARAM ); if( hb_compExprAsSymbol( (yyvsp[(2) - (12)].asExpr) ) ) hb_compForEnd( HB_COMP_PARAM, hb_compExprAsSymbol( (yyvsp[(2) - (12)].asExpr) ) ); - HB_COMP_EXPR_DELETE( (yyvsp[(7) - (12)].asExpr) ); HB_COMP_EXPR_DELETE( (yyvsp[(5) - (12)].asExpr) ); /* deletes $5, $2, $4 */ - if( (yyvsp[(8) - (12)].asExpr) ) - HB_COMP_EXPR_DELETE( (yyvsp[(8) - (12)].asExpr) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); ;} break; case 556: -#line 1608 "harbour.y" +#line 1616 "harbour.y" { (yyval.asExpr) = NULL; ;} break; case 557: -#line 1609 "harbour.y" +#line 1617 "harbour.y" { (yyval.asExpr) = hb_compExprReduce( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); ;} break; case 558: -#line 1613 "harbour.y" +#line 1621 "harbour.y" { hb_compLinePush( HB_COMP_PARAM ); if( HB_COMP_PARAM->functions.pLast->wForCounter ) @@ -6661,42 +6669,42 @@ yyreduce: break; case 563: -#line 1626 "harbour.y" +#line 1634 "harbour.y" { (yyval.asExpr) = hb_compExprNewVarRef( (yyvsp[(1) - (1)].string), HB_COMP_PARAM ); ;} break; case 564: -#line 1627 "harbour.y" +#line 1635 "harbour.y" { (yyval.asExpr) = hb_compExprNewRef( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} break; case 565: -#line 1630 "harbour.y" - { (yyval.asExpr) = hb_compExprNewArgList( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} - break; - - case 566: -#line 1631 "harbour.y" - { (yyval.asExpr) = hb_compExprAddListExpr( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].asExpr) ); ;} - break; - - case 567: -#line 1634 "harbour.y" - { (yyval.asExpr) = hb_compExprNewVarRef( (yyvsp[(2) - (2)].string), HB_COMP_PARAM ); ;} - break; - - case 569: #line 1638 "harbour.y" { (yyval.asExpr) = hb_compExprNewArgList( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} break; - case 570: + case 566: #line 1639 "harbour.y" { (yyval.asExpr) = hb_compExprAddListExpr( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].asExpr) ); ;} break; + case 567: +#line 1642 "harbour.y" + { (yyval.asExpr) = hb_compExprNewVarRef( (yyvsp[(2) - (2)].string), HB_COMP_PARAM ); ;} + break; + + case 569: +#line 1646 "harbour.y" + { (yyval.asExpr) = hb_compExprNewArgList( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} + break; + + case 570: +#line 1647 "harbour.y" + { (yyval.asExpr) = hb_compExprAddListExpr( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].asExpr) ); ;} + break; + case 571: -#line 1644 "harbour.y" +#line 1652 "harbour.y" { ++HB_COMP_PARAM->functions.pLast->wForCounter; /* 5 */ hb_compLinePushIfInside( HB_COMP_PARAM ); @@ -6705,10 +6713,12 @@ yyreduce: break; case 572: -#line 1650 "harbour.y" +#line 1658 "harbour.y" { /* 7 */ + (yyvsp[(2) - (6)].asExpr) = hb_compExprReduce( (yyvsp[(2) - (6)].asExpr), HB_COMP_PARAM ); + (yyvsp[(4) - (6)].asExpr) = hb_compExprReduce( (yyvsp[(4) - (6)].asExpr), HB_COMP_PARAM ); hb_compEnumStart( HB_COMP_PARAM, (yyvsp[(2) - (6)].asExpr), (yyvsp[(4) - (6)].asExpr), (yyvsp[(6) - (6)].iNumber) ); hb_compLoopStart( HB_COMP_PARAM, TRUE ); @@ -6717,7 +6727,7 @@ yyreduce: break; case 573: -#line 1659 "harbour.y" +#line 1669 "harbour.y" { /* 9 */ @@ -6726,7 +6736,7 @@ yyreduce: break; case 574: -#line 1665 "harbour.y" +#line 1675 "harbour.y" { hb_compLoopHere( HB_COMP_PARAM ); hb_compEnumNext( HB_COMP_PARAM, (yyvsp[(2) - (10)].asExpr), (yyvsp[(6) - (10)].iNumber) ); @@ -6742,17 +6752,17 @@ yyreduce: break; case 575: -#line 1679 "harbour.y" +#line 1689 "harbour.y" { (yyval.iNumber) = 1; ;} break; case 576: -#line 1680 "harbour.y" +#line 1690 "harbour.y" { (yyval.iNumber) = -1; ;} break; case 577: -#line 1684 "harbour.y" +#line 1694 "harbour.y" { hb_compLoopStart( HB_COMP_PARAM, FALSE ); hb_compSwitchStart( HB_COMP_PARAM ); @@ -6761,7 +6771,7 @@ yyreduce: break; case 578: -#line 1691 "harbour.y" +#line 1701 "harbour.y" { hb_compSwitchEnd( HB_COMP_PARAM ); hb_compLoopEnd( HB_COMP_PARAM ); @@ -6769,14 +6779,14 @@ yyreduce: break; case 579: -#line 1698 "harbour.y" +#line 1708 "harbour.y" { hb_compGenPCode1( HB_P_POP, HB_COMP_PARAM ); ;} break; case 580: -#line 1704 "harbour.y" +#line 1714 "harbour.y" { if( HB_COMP_PARAM->functions.pLast->wSwitchCounter ) --HB_COMP_PARAM->functions.pLast->wSwitchCounter; @@ -6785,21 +6795,21 @@ yyreduce: break; case 583: -#line 1716 "harbour.y" +#line 1726 "harbour.y" { ++HB_COMP_PARAM->functions.pLast->wSwitchCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); ;} break; case 584: -#line 1720 "harbour.y" +#line 1730 "harbour.y" { HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ) ); ;} break; case 586: -#line 1727 "harbour.y" +#line 1737 "harbour.y" { if( (yyvsp[(2) - (2)].lNumber) > 0 ) { @@ -6809,27 +6819,27 @@ yyreduce: break; case 587: -#line 1735 "harbour.y" +#line 1745 "harbour.y" { hb_compSwitchAdd( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); hb_compLinePush( HB_COMP_PARAM ); ;} break; case 589: -#line 1738 "harbour.y" +#line 1748 "harbour.y" { hb_compSwitchAdd( HB_COMP_PARAM, (yyvsp[(3) - (3)].asExpr) ); hb_compLinePush( HB_COMP_PARAM ); ;} break; case 593: -#line 1746 "harbour.y" +#line 1756 "harbour.y" { hb_compSwitchAdd( HB_COMP_PARAM, NULL ); hb_compLinePush( HB_COMP_PARAM ); ;} break; case 594: -#line 1746 "harbour.y" +#line 1756 "harbour.y" { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; ;} break; case 596: -#line 1751 "harbour.y" +#line 1761 "harbour.y" { /* 2 */ hb_compLinePushIfInside( HB_COMP_PARAM ); ++HB_COMP_PARAM->functions.pLast->wSeqCounter; @@ -6838,7 +6848,7 @@ yyreduce: break; case 597: -#line 1759 "harbour.y" +#line 1769 "harbour.y" { /* 6 */ /* Set jump address for HB_P_SEQBEGIN opcode - this address * will be used in BREAK code if there is no RECOVER clause @@ -6852,7 +6862,7 @@ yyreduce: break; case 598: -#line 1770 "harbour.y" +#line 1780 "harbour.y" { /* 8 */ /* Replace END address with RECOVER address in * HB_P_SEQBEGIN opcode if there is RECOVER clause @@ -6865,7 +6875,7 @@ yyreduce: break; case 599: -#line 1780 "harbour.y" +#line 1790 "harbour.y" { /* 10 */ long lLoopCount = hb_compLoopCount( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); @@ -6897,12 +6907,12 @@ yyreduce: break; case 603: -#line 1815 "harbour.y" +#line 1825 "harbour.y" { (yyval.lNumber) = 0; ;} break; case 604: -#line 1817 "harbour.y" +#line 1827 "harbour.y" { HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ) ); hb_compGenPCode1( HB_P_SEQBLOCK, HB_COMP_PARAM ); @@ -6911,12 +6921,12 @@ yyreduce: break; case 605: -#line 1824 "harbour.y" +#line 1834 "harbour.y" { (yyval.lNumber) = 0; ;} break; case 607: -#line 1829 "harbour.y" +#line 1839 "harbour.y" { HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); (yyval.lNumber) = HB_COMP_PARAM->functions.pLast->lPCodePos; @@ -6926,12 +6936,12 @@ yyreduce: break; case 608: -#line 1837 "harbour.y" +#line 1847 "harbour.y" { (yyval.lNumber) = 0; HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; ;} break; case 611: -#line 1843 "harbour.y" +#line 1853 "harbour.y" { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; (yyval.lNumber) = HB_COMP_PARAM->functions.pLast->lPCodePos; @@ -6943,7 +6953,7 @@ yyreduce: break; case 612: -#line 1854 "harbour.y" +#line 1864 "harbour.y" { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; (yyval.lNumber) = HB_COMP_PARAM->functions.pLast->lPCodePos; @@ -6956,12 +6966,12 @@ yyreduce: break; case 615: -#line 1876 "harbour.y" +#line 1886 "harbour.y" { (yyval.bTrue) = HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL; ;} break; case 616: -#line 1878 "harbour.y" +#line 1888 "harbour.y" { (yyval.asExpr) = hb_compExprNewFunCall( (yyvsp[(2) - (4)].asExpr), (yyvsp[(4) - (4)].asExpr), HB_COMP_PARAM ); HB_COMP_PARAM->iPassByRef = (yyvsp[(3) - (4)].bTrue); @@ -6969,12 +6979,12 @@ yyreduce: break; case 617: -#line 1883 "harbour.y" +#line 1893 "harbour.y" { (yyval.bTrue) = HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL; ;} break; case 618: -#line 1885 "harbour.y" +#line 1895 "harbour.y" { hb_compAutoOpenAdd( HB_COMP_PARAM, (yyvsp[(1) - (3)].string) ); /* DOIDENT is the only one identifier which can be returned in lower letters */ @@ -6984,47 +6994,47 @@ yyreduce: break; case 619: -#line 1893 "harbour.y" +#line 1903 "harbour.y" { (yyval.asExpr) = NULL; ;} break; case 620: -#line 1894 "harbour.y" +#line 1904 "harbour.y" { (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} break; case 621: -#line 1897 "harbour.y" +#line 1907 "harbour.y" { (yyval.asExpr) = hb_compExprAddListExpr( hb_compExprNewArgList( hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ), hb_compExprNewNil( HB_COMP_PARAM ) ); ;} break; case 622: -#line 1898 "harbour.y" +#line 1908 "harbour.y" { (yyval.asExpr) = hb_compExprAddListExpr( hb_compExprNewArgList( hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ), (yyvsp[(2) - (2)].asExpr) ); ;} break; case 623: -#line 1899 "harbour.y" +#line 1909 "harbour.y" { (yyval.asExpr) = hb_compExprNewArgList( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} break; case 624: -#line 1900 "harbour.y" +#line 1910 "harbour.y" { (yyval.asExpr) = hb_compExprAddListExpr( (yyvsp[(1) - (2)].asExpr), hb_compExprNewNil( HB_COMP_PARAM ) ); ;} break; case 625: -#line 1901 "harbour.y" +#line 1911 "harbour.y" { (yyval.asExpr) = hb_compExprAddListExpr( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].asExpr) ); ;} break; case 626: -#line 1904 "harbour.y" +#line 1914 "harbour.y" { (yyval.asExpr) = hb_compExprNewVarRef( (yyvsp[(1) - (1)].string), HB_COMP_PARAM ); ;} break; case 631: -#line 1912 "harbour.y" +#line 1922 "harbour.y" { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ) ); @@ -7035,7 +7045,7 @@ yyreduce: break; case 632: -#line 1921 "harbour.y" +#line 1931 "harbour.y" { if( HB_COMP_PARAM->functions.pLast->wWithObjectCnt ) --HB_COMP_PARAM->functions.pLast->wWithObjectCnt; if( (yyvsp[(5) - (6)].lNumber) ) @@ -7050,13 +7060,13 @@ yyreduce: break; case 635: -#line 1938 "harbour.y" +#line 1948 "harbour.y" { HB_COMP_PARAM->fError = FALSE; ;} break; /* Line 1268 of yacc.c. */ -#line 7060 "harboury.c" +#line 7070 "harboury.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -7275,7 +7285,7 @@ yyreturn: } -#line 1942 "harbour.y" +#line 1952 "harbour.y" /* @@ -7657,11 +7667,11 @@ static void hb_compRTVariableGen( HB_COMP_DECL, char * szCreateFun ) /* push variable names to create */ while( pVar->pNext ) { - hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); + pVar->pVar = hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); pVar = pVar->pNext; ++usCount; } - hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); + pVar->pVar = hb_compExprGenPush( pVar->pVar, HB_COMP_PARAM ); ++usCount; /* call function that will create either PUBLIC or PRIVATE variables */ @@ -7701,7 +7711,7 @@ void hb_compRTVariableKill( HB_COMP_DECL, PFUNCTION pFunc ) static HB_EXPR_PTR hb_compArrayDimPush( HB_EXPR_PTR pInitValue, HB_COMP_DECL ) { - USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); + USHORT uCount = ( USHORT ) hb_compExprListLen( pInitValue ); if( uCount == 1 && hb_compExprIsInteger( pInitValue->value.asList.pExprList ) && hb_compExprAsInteger( pInitValue->value.asList.pExprList ) == 0 ) @@ -7734,10 +7744,10 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D hb_compStaticDefStart( HB_COMP_PARAM ); /* switch to statics pcode buffer */ /* create an array */ pInitValue = hb_compArrayDimPush( pInitValue, HB_COMP_PARAM ); + /* now pop an array */ + pVar = hb_compExprGenPop( pVar, HB_COMP_PARAM ); /* check if valid initializers were used but don't generate any code */ pAssign = hb_compExprAssignStatic( pVar, pInitValue, HB_COMP_PARAM ); - /* now pop an array */ - hb_compExprGenPop( pVar, HB_COMP_PARAM ); /* delete all used expressions */ HB_COMP_EXPR_DELETE( pAssign ); hb_compStaticDefEnd( HB_COMP_PARAM, szName ); @@ -7820,38 +7830,29 @@ BOOL hb_compForEachVarError( HB_COMP_DECL, char *szVarName ) static void hb_compForEnd( HB_COMP_DECL, char *szVar ) { - HB_ENUMERATOR_PTR pEnumVar; + HB_ENUMERATOR_PTR * pEnumVar; HB_SYMBOL_UNUSED( szVar ); - pEnumVar = HB_COMP_PARAM->functions.pLast->pEnum; - if( pEnumVar->pNext ) + pEnumVar = &HB_COMP_PARAM->functions.pLast->pEnum; + if( *pEnumVar ) { - HB_ENUMERATOR_PTR pLast = pEnumVar; - - while( pEnumVar->pNext ) - { - pLast = pEnumVar; - pEnumVar = pEnumVar->pNext; - } - hb_xfree( pEnumVar ); - pLast->pNext = NULL; - } - else - { - hb_xfree( pEnumVar ); - HB_COMP_PARAM->functions.pLast->pEnum = NULL; + while( ( *pEnumVar )->pNext ) + pEnumVar = &( *pEnumVar )->pNext; + + hb_xfree( *pEnumVar ); + *pEnumVar = NULL; } } static HB_CARGO2_FUNC( hb_compEnumEvalStart ) { - char * szName = hb_compExprAsSymbol( (HB_EXPR_PTR)cargo ); + char * szName = hb_compExprAsSymbol( ( HB_EXPR_PTR ) cargo ); if( szName ) hb_compForStart( HB_COMP_PARAM, szName, TRUE ); - hb_compExprGenPush( (HB_EXPR_PTR)dummy, HB_COMP_PARAM ); /* expression */ - hb_compExprGenPush( (HB_EXPR_PTR)cargo, HB_COMP_PARAM ); /* variable */ + hb_compExprGenPush( ( HB_EXPR_PTR ) dummy, HB_COMP_PARAM ); /* expression */ + hb_compExprGenPush( ( HB_EXPR_PTR ) cargo, HB_COMP_PARAM ); /* variable */ } static void hb_compEnumStart( HB_COMP_DECL, HB_EXPR_PTR pVars, HB_EXPR_PTR pExprs, int descend ) @@ -7892,7 +7893,7 @@ static void hb_compEnumNext( HB_COMP_DECL, HB_EXPR_PTR pExpr, int descend ) static HB_CARGO_FUNC( hb_compEnumEvalEnd ) { - char * szName = hb_compExprAsSymbol( (HB_EXPR_PTR)cargo ); + char * szName = hb_compExprAsSymbol( ( HB_EXPR_PTR ) cargo ); if( szName ) hb_compForEnd( HB_COMP_PARAM, szName );