2006-02-14 16:10 UTC+0100 Ryszard Glab <rglab@imid.med.pl>

* include/hbapiitm.h
   * include/hbexpra.c
   * include/hbexprc.c
   * include/hbexprop.h
   * source/compiler/expropta.c
   * source/compiler/exproptb.c
   * source/compiler/exproptc.c
   * source/macro/macroa.c
   * source/macro/macrob.c
   * source/macro/macroc.c
   * source/vm/hvm.c
   * source/vm/itemapi.c
      * fixed code for adding date and numeric values (introduced
        in my last commits)
      * removed hb_itemPutBHLong (use hb_itemPutNInt instead)
      * added more optimization for localvar+=integer
        using HB_P_LOCALNEARADDINT pcode
        (borrowed from xHarbour)
This commit is contained in:
Ryszard Glab
2006-02-14 15:12:07 +00:00
parent adba72912b
commit e92af8dbd2
13 changed files with 79 additions and 44 deletions

View File

@@ -8,6 +8,26 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
* fixed <-x-> match marker
2006-02-14 16:10 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* include/hbapiitm.h
* include/hbexpra.c
* include/hbexprc.c
* include/hbexprop.h
* source/compiler/expropta.c
* source/compiler/exproptb.c
* source/compiler/exproptc.c
* source/macro/macroa.c
* source/macro/macrob.c
* source/macro/macroc.c
* source/vm/hvm.c
* source/vm/itemapi.c
* fixed code for adding date and numeric values (introduced
in my last commits)
* removed hb_itemPutBHLong (use hb_itemPutNInt instead)
* added more optimization for localvar+=integer
using HB_P_LOCALNEARADDINT pcode
(borrowed from xHarbour)
2006-02-14 14:40 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
* include/hbexprc.c
* source/compiler/exproptc.c

View File

@@ -104,7 +104,6 @@ extern HB_EXPORT void hb_itemSetCMemo ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM hb_itemPutD ( PHB_ITEM pItem, int iYear, int iMonth, int iDay );
extern HB_EXPORT PHB_ITEM hb_itemPutDS ( PHB_ITEM pItem, const char * szDate );
extern HB_EXPORT PHB_ITEM hb_itemPutDL ( PHB_ITEM pItem, long lJulian );
extern HB_EXPORT PHB_ITEM hb_itemPutHBLong( PHB_ITEM pItem, HB_LONG lNumber );
extern HB_EXPORT PHB_ITEM hb_itemPutL ( PHB_ITEM pItem, BOOL bValue );
extern HB_EXPORT PHB_ITEM hb_itemPutND ( PHB_ITEM pItem, double dNumber );
extern HB_EXPORT PHB_ITEM hb_itemPutNI ( PHB_ITEM pItem, int iNumber );

View File

@@ -134,7 +134,7 @@ static HB_CBVAR_PTR hb_compExprCBVarNew( char *, BYTE );
/* ************************************************************************ */
HB_EXPR_PTR hb_compExprNew( int iType )
HB_EXPR_PTR hb_compExprNew( HB_EXPRTYPE iType )
{
HB_EXPR_PTR pExpr;

View File

@@ -158,9 +158,31 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq )
if( ! ( iScope == HB_VS_LOCAL_FIELD || iScope == HB_VS_GLOBAL_FIELD ) )
{
if( pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC ||
pSelf->value.asOperator.pRight->ExprType == HB_ET_STRING )
HB_EXPRTYPE iType = pSelf->value.asOperator.pRight->ExprType;
if( iType == HB_ET_NUMERIC || iType == HB_ET_STRING )
{
if( iScope == HB_VS_LOCAL_VAR && iType == HB_ET_NUMERIC &&
( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ) )
{
int iLocal = hb_compLocalGetPos( pSelf->value.asOperator.pLeft->value.asSymbol );
if( iLocal < 256 && hb_compExprIsInteger( pSelf->value.asOperator.pRight ) )
{
int iIncrement = ( short ) pSelf->value.asOperator.pRight->value.asNum.lVal;
if( bOpEq == HB_P_MINUS )
{
iIncrement = -iIncrement;
}
hb_compGenPCode4( HB_P_LOCALNEARADDINT, ( BYTE ) iLocal, HB_LOBYTE( iIncrement ), HB_HIBYTE( iIncrement ), ( BOOL ) 0 );
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
return;
}
}
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF;
@@ -279,9 +301,29 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq )
if( ! ( iScope == HB_VS_LOCAL_FIELD || iScope == HB_VS_GLOBAL_FIELD ) )
{
if( pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC ||
pSelf->value.asOperator.pRight->ExprType == HB_ET_STRING )
HB_EXPRTYPE iType = pSelf->value.asOperator.pRight->ExprType;
if( iType == HB_ET_NUMERIC || iType == HB_ET_STRING )
{
if( iScope == HB_VS_LOCAL_VAR && iType == HB_ET_NUMERIC &&
( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ) )
{
int iLocal = hb_compLocalGetPos( pSelf->value.asOperator.pLeft->value.asSymbol );
if( iLocal < 256 && hb_compExprIsInteger( pSelf->value.asOperator.pRight ) )
{
short iIncrement = ( short ) pSelf->value.asOperator.pRight->value.asNum.lVal;
if( bOpEq == HB_P_MINUS )
{
iIncrement = -iIncrement;
}
hb_compGenPCode4( HB_P_LOCALNEARADDINT, ( BYTE ) iLocal, HB_LOBYTE( iIncrement ), HB_HIBYTE( iIncrement ), ( BOOL ) 0 );
return;
}
}
/* NOTE: direct type change */
pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF;

View File

@@ -168,6 +168,7 @@ typedef enum
HB_EO_PREDEC /* pre-operators -> the highest precedence */
} HB_EXPR_OPERATOR;
typedef USHORT HB_EXPRTYPE;
typedef struct HB_EXPR_
{
@@ -240,7 +241,7 @@ typedef struct HB_EXPR_
} value;
ULONG ulLength;
ULONG Counter;
unsigned char ExprType; /* internal expression type */
HB_EXPRTYPE ExprType; /* internal expression type */
USHORT ValType; /* language level value type */
struct HB_EXPR_ *pNext; /* next expression in the list of expressions */
} HB_EXPR, *HB_EXPR_PTR;
@@ -305,7 +306,7 @@ typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage );
#endif
HB_EXPR_PTR hb_compExprNew( int );
HB_EXPR_PTR hb_compExprNew( HB_EXPRTYPE );
HB_EXPR_PTR hb_compExprNewEmpty( void );
HB_EXPR_PTR hb_compExprNewNil( void );
HB_EXPR_PTR hb_compExprNewDouble( double, BYTE, BYTE );

View File

@@ -5,6 +5,6 @@
/* hbexpra.c is also included from ../macro/macro.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.18 - ignore this magic number - this is used to force compilation
* 1.19 - ignore this magic number - this is used to force compilation
*/
#include "hbexpra.c"

View File

@@ -5,6 +5,6 @@
/* hbexprb.c is also included from ../macro/macro.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.16 - ignore this magic number - this is used to force compilation
* 1.17 - ignore this magic number - this is used to force compilation
*/
#include "hbexprb.c"

View File

@@ -5,6 +5,6 @@
/* hbexprc.c is also included from ../macro/macro.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.8 - ignore this magic number - this is used to force compilation
* 1.9 - ignore this magic number - this is used to force compilation
*/
#include "hbexprc.c"

View File

@@ -5,7 +5,7 @@
/* hbexpra.c is also included from ../compiler/expropta.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.18 - ignore this magic number - this is used to force compilation
* 1.19 - ignore this magic number - this is used to force compilation
*/
#define HB_MACRO_SUPPORT

View File

@@ -5,7 +5,7 @@
/* hbexprb.c is also included from ../compiler/exproptb.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.15 - ignore this magic number - this is used to force compilation
* 1.16 - ignore this magic number - this is used to force compilation
*/
#define HB_MACRO_SUPPORT

View File

@@ -5,7 +5,7 @@
/* hbexprc.c is also included from ../compiler/exproptc.c
* However it produces a slighty different code if used in
* macro compiler (there is an additional parameter passed to some functions)
* 1.7 - ignore this magic number - this is used to force compilation
* 1.8 - ignore this magic number - this is used to force compilation
*/
#define HB_MACRO_SUPPORT

View File

@@ -2159,7 +2159,7 @@ static void hb_vmPlus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pIte
}
else if( HB_IS_DATE( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
{
hb_itemPutND( pResult, ( long ) hb_itemGetND( pItem1 ) + ( long ) hb_itemGetND( pItem1 ) );
hb_itemPutDL( pResult, ( long ) hb_itemGetND( pItem1 ) + ( long ) hb_itemGetND( pItem1 ) );
while( iPopCnt-- > 0 )
{
hb_stackDec();
@@ -2235,7 +2235,7 @@ static void hb_vmMinus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pIt
}
else if( HB_IS_DATE( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
{
hb_itemPutND( pResult, ( long ) hb_itemGetND( pItem1 ) - ( long ) hb_itemGetND( pItem1 ) );
hb_itemPutNL( pResult, ( long ) hb_itemGetND( pItem1 ) - ( long ) hb_itemGetND( pItem1 ) );
while( iPopCnt-- > 0 )
{
hb_stackDec();

View File

@@ -1049,29 +1049,6 @@ HB_EXPORT PHB_ITEM hb_itemPutNLLLen( PHB_ITEM pItem, LONGLONG llNumber, int iWid
}
#endif
HB_EXPORT PHB_ITEM hb_itemPutHBLong( PHB_ITEM pItem, HB_LONG lNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_itemPutHBLong( %p, %" PFHL "d)", pItem, lNumber));
if( pItem )
{
if( HB_IS_COMPLEX( pItem ) )
{
hb_itemClear( pItem );
}
}
else
{
pItem = hb_itemNew( NULL );
}
pItem->type = HB_IT_LONG;
pItem->item.asLong.value = lNumber;
pItem->item.asLong.length = HB_LONG_LENGTH( lNumber );
return pItem;
}
HB_EXPORT PHB_ITEM hb_itemPutNumType( PHB_ITEM pItem, double dNumber, int iDec, int iType1, int iType2 )
{
HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNumType( %p, %lf, %d, %i, %i)", pItem, dNumber, iDec, iType1, iType2));
@@ -1082,11 +1059,7 @@ HB_EXPORT PHB_ITEM hb_itemPutNumType( PHB_ITEM pItem, double dNumber, int iDec,
}
else if ( HB_DBL_LIM_INT( dNumber ) )
{
return hb_itemPutNI( pItem, ( int ) dNumber );
}
else if ( HB_DBL_LIM_LONG( dNumber ) )
{
return hb_itemPutHBLong( pItem, ( HB_LONG ) dNumber );
return hb_itemPutNInt( pItem, ( HB_LONG ) dNumber );
}
else
{