2008-06-02 15:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/contrib/hbsqlit3/hbsqlit3.c
    ! use char * instead of LPSTR to compile in non Windows environment
    ! fixed one printf() parames
    ! fixed casting and parameter type in sqlite3_blob_open()

  * harbour/include/hbexprop.h
  * harbour/include/hbexprb.c
  * harbour/source/common/expropt1.c
  * harbour/source/common/expropt2.c
    - removed unused hb_compExprAsLong()
    + added hb_compExprAsLongNum(), hb_compExprReduceBitFunc()
    + added compiletime optimizatiob for HB_BIT*() functions:
      HB_BITAND(), HB_BITOR(), HB_BITXOR(), HB_BITSET(), HB_BITRESET()
      HB_BITSHIFT(), HB_BITNOT(), HB_BITTEST()
This commit is contained in:
Przemyslaw Czerpak
2008-06-02 13:41:00 +00:00
parent d6c536a44c
commit ed3ab32b06
6 changed files with 151 additions and 15 deletions

View File

@@ -8,6 +8,22 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-06-02 15:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbsqlit3/hbsqlit3.c
! use char * instead of LPSTR to compile in non Windows environment
! fixed one printf() parames
! fixed casting and parameter type in sqlite3_blob_open()
* harbour/include/hbexprop.h
* harbour/include/hbexprb.c
* harbour/source/common/expropt1.c
* harbour/source/common/expropt2.c
- removed unused hb_compExprAsLong()
+ added hb_compExprAsLongNum(), hb_compExprReduceBitFunc()
+ added compiletime optimizatiob for HB_BIT*() functions:
HB_BITAND(), HB_BITOR(), HB_BITXOR(), HB_BITSET(), HB_BITRESET()
HB_BITSHIFT(), HB_BITNOT(), HB_BITTEST()
2008-06-02 13:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbcurl/common.mak
* harbour/contrib/hbcurl/hbcurl.c

View File

@@ -216,7 +216,7 @@ HB_FUNC( SQLITE3_TEMP_DIRECTORY )
BOOL bResult = FALSE;
#ifdef NODLL
LPSTR pszDirName;
char * pszDirName;
#ifdef __XHARBOUR__
pszDirName = hb_fileNameConv( hb_strdup( ( char * ) hb_parc(1) ) );
@@ -276,14 +276,14 @@ HB_FUNC( SQLITE3_TEMP_DIRECTORY )
HB_FUNC( SQLITE3_OPEN )
{
psqlite3 db;
LPSTR pszdbName;
char * pszdbName;
#ifdef __XHARBOUR__
pszdbName = hb_fileNameConv( hb_strdup( ( char * ) hb_parc(1) ) );
#else
BOOL fFree;
pszdbName = ( LPSTR ) hb_fsNameConv( ( BYTE * ) hb_parc(1), &fFree );
pszdbName = ( char * ) hb_fsNameConv( ( BYTE * ) hb_parc(1), &fFree );
#endif
if( (!hb_fsFile( ( BYTE * ) pszdbName)) && (!hb_parl(2)) )
{
@@ -317,14 +317,14 @@ HB_FUNC( SQLITE3_OPEN )
HB_FUNC( SQLITE3_OPEN_V2 )
{
psqlite3 db;
LPSTR pszdbName;
char * pszdbName;
#ifdef __XHARBOUR__
pszdbName = hb_fileNameConv( hb_strdup( ( char * ) hb_parc(1) ) );
#else
BOOL fFree;
pszdbName = ( LPSTR ) hb_fsNameConv( ( BYTE * ) hb_parc(1), &fFree );
pszdbName = ( char * ) hb_fsNameConv( ( BYTE * ) hb_parc(1), &fFree );
#endif
if( sqlite3_open_v2(pszdbName, &db, hb_parni(2), NULL) == SQLITE_OK )
{
@@ -356,7 +356,7 @@ HB_FUNC( SQLITE3_OPEN_V2 )
HB_FUNC( SQLITE3_EXEC )
{
psqlite3 db;
LPSTR pszErrMsg = 0;
char * pszErrMsg = 0;
db = ( psqlite3 ) hb_parsqlite3( 1 );
if( db != NULL )
@@ -397,7 +397,7 @@ HB_FUNC( SQLITE3_PREPARE )
if( SQL != NULL )
{
LPSTR pSQL = hb_itemGetCPtr( SQL );
char * pSQL = hb_itemGetCPtr( SQL );
ULONG ulLen = hb_itemGetCLen( SQL );
psqlite3_stmt pStmt;
const char *pszTail;
@@ -1069,7 +1069,7 @@ HB_FUNC( SQLITE3_GET_TABLE )
{
PHB_ITEM pResultList = hb_itemArrayNew( 0 );
int iRow, iCol;
LPSTR pszErrMsg = 0;
char * pszErrMsg = 0;
char **pResult;
if( sqlite3_get_table(db, hb_parc(2), &pResult, &iRow, &iCol, &pszErrMsg) == SQLITE_OK )
@@ -1298,7 +1298,7 @@ HB_FUNC( SQLITE3_BLOB_OPEN )
pDb = ( psqlite3 ) hb_parsqlite3( 1 );
if( pDb != NULL )
{
sqlite3_blob **ppBlob;
sqlite3_blob *ppBlob;
sqlite3_int64 iRow;
#ifndef HB_LONG_LONG_OFF
@@ -1316,7 +1316,7 @@ HB_FUNC( SQLITE3_BLOB_OPEN )
( const char * ) hb_parc(4),
iRow,
hb_parni(6),
(HANDLE) & ppBlob
&ppBlob
)
)
{
@@ -1481,7 +1481,7 @@ static void SQL3ProfileLog( void *sFile, const char *sProfileMsg, sqlite3_uint64
if( hFile )
{
fprintf( hFile, "%s - %lld\n", sProfileMsg, &int64 );
fprintf( hFile, "%s - %" PFLL "d\n", sProfileMsg, int64 );
fclose( hFile );
}
}

View File

@@ -1643,6 +1643,106 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall )
{
hb_compExprReduceUPPER( pSelf, HB_COMP_PARAM );
}
else if( strncmp( "HB_BIT", pName->value.asSymbol, 6 ) == 0 &&
usCount && pParms->value.asList.pExprList->ExprType == HB_ET_NUMERIC )
{
HB_EXPR_PTR pArg = pParms->value.asList.pExprList;
HB_LONG lResult = 0;
BOOL fOptimize = FALSE, fBool = FALSE;
if( usCount >= 2 )
{
if( pArg->pNext->ExprType == HB_ET_NUMERIC )
{
if( strcmp( "TEST", pName->value.asSymbol + 6 ) == 0 )
{
HB_LONG lBit = hb_compExprAsLongNum( pArg->pNext );
lResult = ( hb_compExprAsLongNum( pArg ) &
( ( HB_LONG ) 1 << lBit ) ) != 0;
fOptimize = fBool = TRUE;
}
else if( strcmp( "SET", pName->value.asSymbol + 6 ) == 0 )
{
HB_LONG lBit = hb_compExprAsLongNum( pArg->pNext );
lResult = hb_compExprAsLongNum( pArg ) |
( ( HB_LONG ) 1 << lBit );
fOptimize = TRUE;
}
else if( strcmp( "RESET", pName->value.asSymbol + 6 ) == 0 )
{
HB_LONG lBit = hb_compExprAsLongNum( pArg->pNext );
lResult = hb_compExprAsLongNum( pArg ) &
( ~ ( ( HB_LONG ) 1 << lBit ) );
fOptimize = TRUE;
}
else if( strcmp( "SHIFT", pName->value.asSymbol + 6 ) == 0 )
{
HB_LONG lBits = hb_compExprAsLongNum( pArg->pNext );
lResult = hb_compExprAsLongNum( pArg );
if( lBits < 0 )
lResult >>= -lBits;
else
lResult <<= lBits;
fOptimize = TRUE;
}
}
}
else if( strcmp( "NOT", pName->value.asSymbol + 6 ) == 0 )
{
lResult = ~hb_compExprAsLongNum( pArg );
fOptimize = TRUE;
}
if( !fOptimize )
{
if( strcmp( "AND", pName->value.asSymbol + 6 ) == 0 )
{
fOptimize = TRUE;
lResult = hb_compExprAsLongNum( pArg );
while( --usCount )
{
pArg = pArg->pNext;
if( pArg->ExprType != HB_ET_NUMERIC )
{
fOptimize = FALSE;
break;
}
lResult &= hb_compExprAsLongNum( pArg );
}
}
else if( strcmp( "OR", pName->value.asSymbol + 6 ) == 0 )
{
fOptimize = TRUE;
lResult = hb_compExprAsLongNum( pArg );
while( --usCount )
{
pArg = pArg->pNext;
if( pArg->ExprType != HB_ET_NUMERIC )
{
fOptimize = FALSE;
break;
}
lResult |= hb_compExprAsLongNum( pArg );
}
}
else if( strcmp( "XOR", pName->value.asSymbol + 6 ) == 0 )
{
fOptimize = TRUE;
lResult = hb_compExprAsLongNum( pArg );
while( --usCount )
{
pArg = pArg->pNext;
if( pArg->ExprType != HB_ET_NUMERIC )
{
fOptimize = FALSE;
break;
}
lResult ^= hb_compExprAsLongNum( pArg );
}
}
}
if( fOptimize )
hb_compExprReduceBitFunc( pSelf, lResult, fBool, HB_COMP_PARAM );
}
#ifndef HB_MACRO_SUPPORT
else if( strncmp( "HB_I18N_", pName->value.asSymbol, 8 ) == 0 )
{

View File

@@ -163,6 +163,7 @@ extern int hb_compExprAsInteger( HB_EXPR_PTR );
extern int hb_compExprAsNumSign( HB_EXPR_PTR );
extern int hb_compExprIsString( HB_EXPR_PTR );
extern int hb_compExprAsStringLen( HB_EXPR_PTR );
extern HB_LONG hb_compExprAsLongNum( HB_EXPR_PTR );
extern char * hb_compExprAsString( HB_EXPR_PTR );
extern char * hb_compExprAsSymbol( HB_EXPR_PTR );
@@ -196,9 +197,10 @@ extern BOOL hb_compExprReduceAT( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceCHR( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL );
extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR, USHORT usCount, HB_COMP_DECL );
extern BOOL hb_compExprReduceCTOD( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceUPPER( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceBitFunc( HB_EXPR_PTR, HB_LONG, BOOL, HB_COMP_DECL );
extern void hb_compI18nAdd( HB_COMP_DECL, const char* szText, const char* szContext, UINT uiLine );

View File

@@ -266,10 +266,15 @@ int hb_compExprAsInteger( HB_EXPR_PTR pExpr )
return 0;
}
HB_LONG hb_compExprAsLong( HB_EXPR_PTR pExpr )
HB_LONG hb_compExprAsLongNum( HB_EXPR_PTR pExpr )
{
if( pExpr->ExprType == HB_ET_NUMERIC && pExpr->value.asNum.NumType == HB_ET_LONG )
return pExpr->value.asNum.val.l;
if( pExpr->ExprType == HB_ET_NUMERIC )
{
if( pExpr->value.asNum.NumType == HB_ET_LONG )
return pExpr->value.asNum.val.l;
else
return ( HB_LONG ) pExpr->value.asNum.val.d;
}
else
return 0;
}

View File

@@ -1783,3 +1783,16 @@ BOOL hb_compExprReduceUPPER( HB_EXPR_PTR pSelf, HB_COMP_DECL )
return FALSE;
}
BOOL hb_compExprReduceBitFunc( HB_EXPR_PTR pSelf, HB_LONG lResult, BOOL fBool, HB_COMP_DECL )
{
HB_EXPR_PTR pParms = pSelf->value.asFunCall.pParms;
HB_EXPR_PTR pExpr = fBool ? hb_compExprNewLogical( lResult != 0, HB_COMP_PARAM ) :
hb_compExprNewLong( lResult, HB_COMP_PARAM );
HB_COMP_EXPR_FREE( pParms );
HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName );
memcpy( pSelf, pExpr, sizeof( HB_EXPR ) );
HB_COMP_EXPR_CLEAR( pExpr );
return TRUE;
}