From 0e1f0f34e963e5faadc0f349e5053fd1232f927f Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 19 Oct 2009 09:54:05 +0000 Subject: [PATCH] 2009-10-19 11:53 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexprb.c ! always optimized ASC() and LEN() functions (was disabled by -kc switch). These optimizations are not Harbour extensions - Clipper also optimize above functions * harbour/doc/cmpopt.txt * updated optimization description * harbour/doc/pp.txt + added information about new lexer --- harbour/ChangeLog | 12 ++++++++++ harbour/doc/cmpopt.txt | 11 +++++---- harbour/doc/pp.txt | 5 ++++ harbour/include/hbexprb.c | 50 +++++++++++++++++++-------------------- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2a714d256c..15e2185843 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,18 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-10-19 11:53 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbexprb.c + ! always optimized ASC() and LEN() functions (was disabled by -kc switch). + These optimizations are not Harbour extensions - Clipper also optimize + above functions + + * harbour/doc/cmpopt.txt + * updated optimization description + + * harbour/doc/pp.txt + + added information about new lexer + 2009-10-19 10:55 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/cdpapi.c * harbour/include/hbapicdp.h diff --git a/harbour/doc/cmpopt.txt b/harbour/doc/cmpopt.txt index d5e86432b0..6bebe44e0d 100644 --- a/harbour/doc/cmpopt.txt +++ b/harbour/doc/cmpopt.txt @@ -15,23 +15,24 @@ optimized at compile time: AT( , ) // Clipper wrongly calculates // AT( "", ) as 1 + ASC( [ , ... ] ) CHR( ) + LEN( | | ) // is Harbour extension UPPER( ) // cannot contain characters different then [0-9A-Za-z ] - Harbour extension: INT( ) - ASC( [ , ... ] ) MIN( , ) // is N, D or L value MAX( , ) // is N, D or L value EMPTY( | | | | | | | NIL ) - LEN( | | ) - CTOD( [ , ... } ) + CTOD( "" [ , ... ] ) DTOS( ] ) STOD( [ ] ) HB_STOD( [ ] ) + HB_STOT( [ ] ) HB_BITNOT( [, ... ] ) HB_BITAND( , [, ] ) HB_BITOR( , [, ] ) @@ -45,6 +46,8 @@ optimized at compile time: HB_I18N_GETTEXT_NOOP( [ , ] ) HB_I18N_NGETTEXT_NOOP( | [ , ] ) + HB_I18N_GETTEXT_NOOP_*( [ , ] ) + HB_I18N_NGETTEXT_NOOP_*( | [ , ] ) HB_MUTEXCREATE() @@ -171,7 +174,7 @@ does not optimize in expressions like: Unlike Clipper Harbour tries to optimize all expressions. If some code needs strict Clipper behavior then it can be forced by using --kc Harbour compiler switch. It disabled Harbour extensions and enables +-kc Harbour compiler switch. It disables Harbour extensions and enables replicating some Clipper bugs like optimizing "" $ to .T. at compile time (at runtime and in macrocompiler it's always .F. in Clipper and Harbour). diff --git a/harbour/doc/pp.txt b/harbour/doc/pp.txt index a04d425746..85506381a4 100644 --- a/harbour/doc/pp.txt +++ b/harbour/doc/pp.txt @@ -673,6 +673,11 @@ I had to break Clipper compatibility to keep FLEX working. Just simply I cannot generate preprocessed line in exactly the same form as Clipper does because FLEX or SIMPLEX will not be able to decode it. +Update: +New Harbour lexer is simple translator between PP tokens and Harbour +grammar terminal symbols so it's not necessary to convert preprocessed +code to strings to pass them to FLEX or SIMPLEX. It works faster and it's +fully compatible Clipper behavior what fixes above problem. best regards, Przemek diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 716ff65e5a..e1761a47d3 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1726,6 +1726,11 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( usCount == 2 ) hb_compExprReduceAT( pSelf, HB_COMP_PARAM ); } + else if( strcmp( "ASC", pName->value.asSymbol ) == 0 ) + { + if( usCount ) + hb_compExprReduceASC( pSelf, HB_COMP_PARAM ); + } else if( strcmp( "CHR", pName->value.asSymbol ) == 0 ) { if( usCount ) @@ -1733,24 +1738,34 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) } else if( strcmp( "LEN", pName->value.asSymbol ) == 0 ) { - if( usCount && HB_SUPPORT_HARBOUR ) + if( usCount ) hb_compExprReduceLEN( pSelf, HB_COMP_PARAM ); } + else if( strcmp( "UPPER", pName->value.asSymbol ) == 0 ) + { + if( usCount ) + hb_compExprReduceUPPER( pSelf, HB_COMP_PARAM ); + } else if( strcmp( "EMPTY", pName->value.asSymbol ) == 0 ) { if( usCount && HB_SUPPORT_HARBOUR ) hb_compExprReduceEMPTY( pSelf, HB_COMP_PARAM ); } - else if( strcmp( "ASC", pName->value.asSymbol ) == 0 ) - { - if( usCount && HB_SUPPORT_HARBOUR ) - hb_compExprReduceASC( pSelf, HB_COMP_PARAM ); - } else if( strcmp( "INT", pName->value.asSymbol ) == 0 ) { if( usCount == 1 && HB_SUPPORT_HARBOUR ) hb_compExprReduceINT( pSelf, HB_COMP_PARAM ); } + else if( strcmp( "MIN", pName->value.asSymbol ) == 0 ) + { + if( usCount == 2 && HB_SUPPORT_HARBOUR ) + hb_compExprReduceMIN( pSelf, HB_COMP_PARAM ); + } + else if( strcmp( "MAX", pName->value.asSymbol ) == 0 ) + { + if( usCount == 2 && HB_SUPPORT_HARBOUR ) + hb_compExprReduceMAX( pSelf, HB_COMP_PARAM ); + } else if( strcmp( "STOD", pName->value.asSymbol ) == 0 || strcmp( "HB_STOD", pName->value.asSymbol ) == 0 ) { @@ -1771,21 +1786,6 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( usCount && HB_SUPPORT_HARBOUR ) hb_compExprReduceCTOD( pSelf, HB_COMP_PARAM ); } - else if( strcmp( "MIN", pName->value.asSymbol ) == 0 ) - { - if( usCount == 2 && HB_SUPPORT_HARBOUR ) - hb_compExprReduceMIN( pSelf, HB_COMP_PARAM ); - } - else if( strcmp( "MAX", pName->value.asSymbol ) == 0 ) - { - if( usCount == 2 && HB_SUPPORT_HARBOUR ) - hb_compExprReduceMAX( pSelf, HB_COMP_PARAM ); - } - else if( strcmp( "UPPER", pName->value.asSymbol ) == 0 ) - { - if( usCount ) - 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 ) { @@ -1902,16 +1902,14 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( strncmp( "_STRICT", &pName->value.asSymbol[ ulPos ], 7 ) == 0 ) { ulPos += 7; - if( !pName->value.asSymbol[ ulPos ] || pName->value.asSymbol[ ulPos ] == '_' ) - fI18nFunc = fStrict = TRUE; + fStrict = TRUE; } else if( strncmp( "_NOOP", &pName->value.asSymbol[ ulPos ], 5 ) == 0 ) { ulPos += 5; - if( !pName->value.asSymbol[ ulPos ] || pName->value.asSymbol[ ulPos ] == '_' ) - fI18nFunc = fNoop = TRUE; + fNoop = TRUE; } - else if( !pName->value.asSymbol[ ulPos ] || pName->value.asSymbol[ ulPos ] == '_' ) + if( !pName->value.asSymbol[ ulPos ] || pName->value.asSymbol[ ulPos ] == '_' ) fI18nFunc = TRUE; } if( fI18nFunc )