2014-12-05 01:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/common/hbffind.c
  * src/common/hbfsapi.c
  * src/rtl/filebuf.c
  * src/rtl/fssize.c
  * contrib/hbmzip/mzip.c
  * contrib/xhb/filestat.c
    ! typo in comment - thanks to Viktor

  * include/hbexprb.c
    * small code reorganization

  * include/hbvmpub.h
  * src/vm/hvm.c
    % use HB_VM_PUSHNIL() macro
    ! generate RTE for code like:
         LOCAL aVar[ 10, -1 ]
      (Cl*pper compatible)
This commit is contained in:
Przemysław Czerpak
2014-12-05 01:33:30 +01:00
parent 86e8c25df5
commit 513f8824df
10 changed files with 78 additions and 65 deletions

View File

@@ -10,6 +10,25 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2014-12-05 01:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/common/hbffind.c
* src/common/hbfsapi.c
* src/rtl/filebuf.c
* src/rtl/fssize.c
* contrib/hbmzip/mzip.c
* contrib/xhb/filestat.c
! typo in comment - thanks to Viktor
* include/hbexprb.c
* small code reorganization
* include/hbvmpub.h
* src/vm/hvm.c
% use HB_VM_PUSHNIL() macro
! generate RTE for code like:
LOCAL aVar[ 10, -1 ]
(Cl*pper compatible)
2014-12-05 00:13 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
* src/common/hbver.c
* synced copyright with fork to be in sync with merged sources

View File

@@ -97,7 +97,7 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and effectively enables lseek64/flock64/ftruncate64 functions
* defined and effectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64

View File

@@ -74,7 +74,7 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and effectively enables lseek64/flock64/ftruncate64 functions
* defined and effectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64

View File

@@ -2109,14 +2109,22 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall )
HB_BOOL fArgsList = HB_FALSE;
HB_USHORT usCount = 0;
/* NOTE: pParms will be NULL in 'DO procname' (if there is
* no WITH keyword)
*/
if( pSelf->value.asFunCall.pParms )
{
usCount = ( HB_USHORT ) hb_compExprParamListCheck( HB_COMP_PARAM, pSelf->value.asFunCall.pParms );
fArgsList = pSelf->value.asFunCall.pParms->ExprType == HB_ET_MACROARGLIST;
}
if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME )
{
if( pSelf->value.asFunCall.pFunName->value.asSymbol.funcid == HB_F_ARRAYTOPARAMS )
if( ! fArgsList )
{
usCount = ( HB_USHORT ) hb_compExprParamListCheck( HB_COMP_PARAM, pSelf->value.asFunCall.pParms );
if( usCount == 1 &&
( pSelf->value.asFunCall.pFunName->value.asSymbol.flags & HB_FN_MULTIARG ) != 0 &&
pSelf->value.asFunCall.pParms->ExprType != HB_ET_MACROARGLIST )
if( pSelf->value.asFunCall.pFunName->value.asSymbol.funcid == HB_F_ARRAYTOPARAMS &&
usCount == 1 &&
( pSelf->value.asFunCall.pFunName->value.asSymbol.flags & HB_FN_MULTIARG ) != 0 )
{
HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_PUSH_PCODE );
HB_GEN_FUNC1( PCode1, HB_P_PUSHAPARAMS );
@@ -2132,16 +2140,8 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall )
HB_GEN_FUNC1( PCode1, HB_P_PUSHNIL );
}
/* NOTE: pParms will be NULL in 'DO procname' (if there is
* no WITH keyword)
*/
if( pSelf->value.asFunCall.pParms )
{
usCount = ( HB_USHORT ) hb_compExprParamListCheck( HB_COMP_PARAM, pSelf->value.asFunCall.pParms );
fArgsList = pSelf->value.asFunCall.pParms->ExprType == HB_ET_MACROARGLIST;
if( usCount )
HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_PUSH_PCODE );
}
if( usCount )
HB_EXPR_USE( pSelf->value.asFunCall.pParms, HB_EA_PUSH_PCODE );
if( fArgsList )
{

View File

@@ -66,6 +66,7 @@ struct _HB_SYMB;
# define HB_ITEM_TYPE( p ) ( HB_ITEM_TYPERAW( p ) & ~ HB_IT_DEFAULT )
# define HB_OBJ_CLASS( p ) ( ( p )->item.asArray.value->uiClass )
# define HB_ARRAY_OBJ( p ) ( ( p )->item.asArray.value->uiClass != 0 )
# define HB_VM_PUSHNIL() do { hb_stackAllocItem()->type = HB_IT_NIL; } while( 0 )
# define HB_ITEM_GET_NUMINTRAW( p ) ( HB_IS_INTEGER( p ) ? \
( HB_MAXINT ) (p)->item.asInteger.value : \

View File

@@ -178,7 +178,7 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and effectively enables lseek64/flock64/ftruncate64 functions
* defined and effectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64

View File

@@ -81,7 +81,7 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and effectively enables lseek64/flock64/ftruncate64 functions
* defined and effectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64

View File

@@ -70,7 +70,7 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and effectively enables lseek64/flock64/ftruncate64 functions
* defined and effectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64

View File

@@ -64,7 +64,7 @@
#if defined( __USE_LARGEFILE64 )
/*
* The macro: __USE_LARGEFILE64 is set when _LARGEFILE64_SOURCE is
* define and effectively enables lseek64/flock64/ftruncate64 functions
* defined and effectively enables lseek64/flock64/ftruncate64 functions
* on 32bit machines.
*/
#define HB_USE_LARGEFILE64

View File

@@ -4578,7 +4578,7 @@ void hb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue )
hb_objHasOperator( pBase, HB_OO_OP_ENUMSTOP ) )
{
hb_stackPushReturn();
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_objOperatorCall( HB_OO_OP_ENUMSTOP, hb_stackItemFromTop( -1 ),
pBase, NULL, NULL );
hb_stackPop();
@@ -4714,7 +4714,7 @@ static void hb_vmEnumStart( int nVars, int nDescend )
{
pEnum->item.asEnum.offset = 0;
pEnum->item.asEnum.valuePtr = hb_itemNew( NULL );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushLogical( nDescend == 0 );
hb_objOperatorCall( HB_OO_OP_ENUMSTART, hb_stackItemFromTop( -2 ),
pBase, pEnumRef, hb_stackItemFromTop( -1 ) );
@@ -4796,7 +4796,7 @@ static void hb_vmEnumNext( void )
hb_objHasOperator( pBase, HB_OO_OP_ENUMSKIP ) )
{
++pEnum->item.asEnum.offset;
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushLogical( HB_FALSE );
hb_objOperatorCall( HB_OO_OP_ENUMSKIP, hb_stackItemFromTop( -2 ),
pBase, pEnumRef, hb_stackItemFromTop( -1 ) );
@@ -4876,7 +4876,7 @@ static void hb_vmEnumPrev( void )
hb_objHasOperator( pBase, HB_OO_OP_ENUMSKIP ) )
{
--pEnum->item.asEnum.offset;
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushLogical( HB_TRUE );
hb_objOperatorCall( HB_OO_OP_ENUMSKIP, hb_stackItemFromTop( -2 ),
pBase, pEnumRef, hb_stackItemFromTop( -1 ) );
@@ -5451,10 +5451,10 @@ static void hb_vmArrayGen( HB_SIZE nElements ) /* generates an nElements Array a
/* This function creates an array item using 'uiDimension' as an index
* to retrieve the number of elements from the stack
*/
static void hb_vmArrayNew( PHB_ITEM pArray, HB_USHORT uiDimension )
static HB_BOOL hb_vmArrayNew( PHB_ITEM pArray, HB_USHORT uiDimension )
{
HB_STACK_TLS_PRELOAD
HB_SIZE nElements;
HB_ISIZ nElements;
PHB_ITEM pDim;
HB_TRACE( HB_TR_DEBUG, ( "hb_vmArrayNew(%p, %hu)", pArray, uiDimension ) );
@@ -5463,11 +5463,11 @@ static void hb_vmArrayNew( PHB_ITEM pArray, HB_USHORT uiDimension )
/* use the proper type of number of elements */
if( HB_IS_INTEGER( pDim ) )
nElements = ( HB_SIZE ) pDim->item.asInteger.value;
nElements = ( HB_ISIZ ) pDim->item.asInteger.value;
else if( HB_IS_LONG( pDim ) )
nElements = ( HB_SIZE ) pDim->item.asLong.value;
nElements = ( HB_ISIZ ) pDim->item.asLong.value;
else if( HB_IS_DOUBLE( pDim ) )
nElements = ( HB_SIZE ) pDim->item.asDouble.value;
nElements = ( HB_ISIZ ) pDim->item.asDouble.value;
else
/* NOTE: Clipper creates empty array if non-numeric value is
* specified as dimension and stops further processing.
@@ -5475,16 +5475,23 @@ static void hb_vmArrayNew( PHB_ITEM pArray, HB_USHORT uiDimension )
*/
nElements = 0;
/* create an array */
hb_arrayNew( pArray, nElements );
if( --uiDimension )
if( nElements >= 0 )
{
/* call self recursively to create next dimensions
*/
while( nElements-- )
hb_vmArrayNew( pArray->item.asArray.value->pItems + nElements, uiDimension );
/* create an array */
hb_arrayNew( pArray, nElements );
if( --uiDimension )
{
/* call self recursively to create next dimensions */
while( nElements-- )
if( ! hb_vmArrayNew( pArray->item.asArray.value->pItems + nElements, uiDimension ) )
return HB_FALSE;
}
return HB_TRUE;
}
hb_errRT_BASE( EG_BOUND, 1131, NULL, hb_langDGetErrorDesc( EG_ARRDIMENSION ), 0 );
return HB_FALSE;
}
static void hb_vmArrayDim( HB_USHORT uiDimensions ) /* generates an uiDimensions Array and initialize those dimensions from the stack values */
@@ -5498,9 +5505,7 @@ static void hb_vmArrayDim( HB_USHORT uiDimensions ) /* generates an uiDimensions
hb_itemMove( hb_stackItemFromTop( ( int ) ( -1 - uiDimensions ) ),
hb_stackItemFromTop( -1 ) );
do
{
hb_stackPop();
}
while( --uiDimensions );
}
@@ -5580,7 +5585,7 @@ static void hb_vmMacroPushIndex( void )
hb_itemRelease( pIndexArray );
}
else if( nIndexes == 0 )
hb_vmPushNil(); /* It will force RT error later in array push or pop */
HB_VM_PUSHNIL(); /* It will force RT error later in array push or pop */
}
/*
@@ -6266,7 +6271,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, const char * szName, int nInd
{
case HB_DBG_MODULENAME:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_MODULENAME );
hb_vmPushString( szName, strlen( szName ) );
hb_vmProc( 2 );
@@ -6274,7 +6279,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, const char * szName, int nInd
case HB_DBG_LOCALNAME:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_LOCALNAME );
hb_vmPushInteger( nIndex );
hb_vmPushString( szName, strlen( szName ) );
@@ -6283,7 +6288,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, const char * szName, int nInd
case HB_DBG_STATICNAME:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_STATICNAME );
hb_vmPush( pFrame ); /* current static frame */
hb_vmPushInteger( nIndex ); /* variable index */
@@ -6293,7 +6298,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, const char * szName, int nInd
case HB_DBG_SHOWLINE:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_SHOWLINE );
hb_vmPushInteger( nLine );
hb_vmProc( 2 );
@@ -6302,7 +6307,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, const char * szName, int nInd
case HB_DBG_ENDPROC:
hb_stackPushReturn(); /* saves the previous returned value */
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_ENDPROC );
hb_vmProc( 1 );
hb_stackPopReturn(); /* restores the previous returned value */
@@ -6311,14 +6316,14 @@ static void hb_vmDebugEntry( int nMode, int nLine, const char * szName, int nInd
case HB_DBG_GETENTRY:
/* Try to get C dbgEntry() function pointer */
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_GETENTRY );
hb_vmProc( 1 );
break;
case HB_DBG_VMQUIT:
hb_vmPushDynSym( s_pDynsDbgEntry );
hb_vmPushNil();
HB_VM_PUSHNIL();
hb_vmPushInteger( HB_DBG_VMQUIT );
hb_vmPushInteger( nIndex );
hb_vmProc( 2 );
@@ -6432,7 +6437,7 @@ static void hb_vmFrame( HB_USHORT usLocals, unsigned char ucParams )
{
iTotal -= pBase->item.asSymbol.paramcnt;
while( --iTotal >= 0 )
hb_vmPushNil();
HB_VM_PUSHNIL();
}
#else
pBase->item.asSymbol.paramdeclcnt = ucParams;
@@ -6442,14 +6447,8 @@ static void hb_vmFrame( HB_USHORT usLocals, unsigned char ucParams )
iTotal = 0;
iTotal += usLocals;
if( iTotal )
{
do
{
hb_vmPushNil();
}
while( --iTotal > 0 );
}
while( --iTotal >= 0 )
HB_VM_PUSHNIL();
#endif
}
@@ -6470,14 +6469,8 @@ static void hb_vmVFrame( HB_USHORT usLocals, unsigned char ucParams )
iTotal = 0;
iTotal += usLocals;
if( iTotal )
{
do
{
hb_vmPushNil();
}
while( --iTotal > 0 );
}
while( --iTotal >= 0 )
HB_VM_PUSHNIL();
}
static void hb_vmSFrame( PHB_SYMB pSym ) /* sets the statics frame for a function */