2016-01-28 15:00 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* include/hbexprb.c
  * src/common/expropt1.c
    ! fixed typo in macro alias push/pop operation
    * disable multivalue macro expansion for macro expressions enclosed in
      parenthesis, i.e.:
            s := "1,2,3"
            QOut( &s )        // 1, 2, 3
            QOut( &(s) )      // 1, 2, 3
            QOut( (&s) )      // 3

  * include/hbexprop.h
  * src/common/expropt1.c
  * src/common/expropt2.c
  * src/vm/hvm.c
    * return last array item when hb_ArrayToParams() is used in
      parenthesis, i.e.:
         QOut( hb_ArrayToParams( { 1, 2, 3 } ) )      // 1, 2, 3
         QOut( ( hb_ArrayToParams( { 1, 2, 3 } ) ) )  // 3
This commit is contained in:
Przemysław Czerpak
2016-01-28 15:00:20 +01:00
parent 301e4553a9
commit 08c4bf45fc
6 changed files with 50 additions and 16 deletions

View File

@@ -1345,6 +1345,15 @@ HB_ULONG hb_compExprParamListLen( PHB_EXPR pExpr )
return nLen;
}
/* Check if expression is hb_ArrayToParams( aParams ) function call
*/
HB_BOOL hb_compExprIsArrayToParams( PHB_EXPR pExpr )
{
return pExpr->ExprType == HB_ET_FUNCALL &&
pExpr->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME &&
pExpr->value.asFunCall.pFunName->value.asSymbol.funcid == HB_F_ARRAYTOPARAMS;
}
HB_SIZE hb_compExprParamListCheck( HB_COMP_DECL, PHB_EXPR pExpr )
{
HB_SIZE nLen = 0, nItems = 0;
@@ -1359,13 +1368,11 @@ HB_SIZE hb_compExprParamListCheck( HB_COMP_DECL, PHB_EXPR pExpr )
if( ( pElem->ExprType == HB_ET_MACRO && HB_SUPPORT_XBASE &&
pElem->value.asMacro.SubType != HB_ET_MACRO_SYMBOL &&
pElem->value.asMacro.SubType != HB_ET_MACRO_REFER &&
pElem->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) ||
pElem->value.asMacro.SubType != HB_ET_MACRO_ALIASED &&
( pElem->value.asMacro.SubType & HB_ET_MACRO_PARE ) == 0 ) ||
( pElem->ExprType == HB_ET_ARGLIST &&
pElem->value.asList.reference ) ||
( pElem->ExprType == HB_ET_FUNCALL &&
pElem->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME &&
pElem->value.asFunCall.pFunName->value.asSymbol.funcid ==
HB_F_ARRAYTOPARAMS ) )
hb_compExprIsArrayToParams( pElem ) )
{
/* &macro was passed
or optional parameters list passed, f.e.: f(a,b,...)

View File

@@ -1960,7 +1960,8 @@ PHB_EXPR hb_compExprListStrip( PHB_EXPR pSelf, HB_COMP_DECL )
{
while( pSelf->ExprType == HB_ET_LIST &&
hb_compExprListLen( pSelf ) == 1 &&
pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE )
pSelf->value.asList.pExprList->ExprType <= HB_ET_VARIABLE &&
! hb_compExprIsArrayToParams( pSelf->value.asList.pExprList ) )
{
/* replace the list with a simple expression
* ( EXPR ) -> EXPR

View File

@@ -12443,7 +12443,10 @@ HB_FUNC( HB_ARRAYTOPARAMS )
{
HB_STACK_TLS_PRELOAD
hb_retni( 0 );
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
if( pArray )
hb_arrayLast( pArray, hb_stackReturnItem() );
}
HB_FUNC( ERRORLEVEL )