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

@@ -10,6 +10,26 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
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
2016-01-28 13:20 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/rtl/hbsocket.c
* enabled new socket functions in MSC 18.0 (before was MSC 19.0)

View File

@@ -1039,9 +1039,6 @@ static HB_EXPR_FUNC( hb_compExprUseList )
case HB_EA_REDUCE:
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 )
@@ -1056,6 +1053,9 @@ static HB_EXPR_FUNC( hb_compExprUseList )
}
}
}
if( HB_SUPPORT_HARBOUR )
pSelf = hb_compExprListStrip( pSelf, HB_COMP_PARAM );
break;
case HB_EA_ARRAY_AT:
@@ -1406,9 +1406,10 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt )
{
if( HB_SUPPORT_XBASE )
{
if( pSelf->value.asMacro.SubType != HB_ET_MACRO_SYMBOL &&
pSelf->value.asMacro.SubType != HB_ET_MACRO_REFER &&
pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED )
if( pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_SYMBOL &&
pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_REFER &&
pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_ALIASED &&
( pSelf->value.asList.pIndex->value.asMacro.SubType & HB_ET_MACRO_PARE ) == 0 )
{
pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_LIST;
fMacroIndex = HB_TRUE;
@@ -1486,9 +1487,10 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt )
{
if( HB_SUPPORT_XBASE )
{
if( pSelf->value.asMacro.SubType != HB_ET_MACRO_SYMBOL &&
pSelf->value.asMacro.SubType != HB_ET_MACRO_REFER &&
pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED )
if( pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_SYMBOL &&
pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_REFER &&
pSelf->value.asList.pIndex->value.asMacro.SubType != HB_ET_MACRO_ALIASED &&
( pSelf->value.asList.pIndex->value.asMacro.SubType & HB_ET_MACRO_PARE ) == 0 )
{
pSelf->value.asList.pIndex->value.asMacro.SubType |= HB_ET_MACRO_LIST;
fMacroIndex = HB_TRUE;

View File

@@ -154,6 +154,7 @@ extern HB_EXPORT_INT HB_SIZE hb_compExprAsStringLen( PHB_EXPR );
extern HB_EXPORT_INT HB_MAXINT hb_compExprAsLongNum( PHB_EXPR );
extern HB_EXPORT_INT const char * hb_compExprAsString( PHB_EXPR );
extern HB_EXPORT_INT const char * hb_compExprAsSymbol( PHB_EXPR );
extern HB_EXPORT_INT HB_BOOL hb_compExprIsArrayToParams( PHB_EXPR );
extern HB_EXPORT_INT PHB_EXPR hb_compExprListStrip( PHB_EXPR, HB_COMP_DECL );

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 )