From 0e182c922d0463d774f29de0bcba17de7f4095ac Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Tue, 14 Feb 2006 12:29:11 +0000 Subject: [PATCH] 2006-02-14 13:40 UTC+0100 Ryszard Glab * include/hbexprc.c * source/compiler/exproptc.c * source/macro/macroc.c * disabled optimalization of compound assignment for fields --- harbour/ChangeLog | 7 + harbour/include/hbexprc.c | 198 ++++++++++++++++------------- harbour/source/compiler/exproptc.c | 2 +- harbour/source/macro/macroc.c | 2 +- 4 files changed, 116 insertions(+), 93 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7ee5b92c2d..6f65bfc77b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ * fixed <-x-> match marker +2006-02-14 13:40 UTC+0100 Ryszard Glab + * include/hbexprc.c + * source/compiler/exproptc.c + * source/macro/macroc.c + * disabled optimalization of compound assignment for fields + + 2006-02-14 11:40 UTC+0100 Ryszard Glab * include/hbapiitm.h * include/hbcomp.h diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c index 79d315dcd1..c5f403f80d 100644 --- a/harbour/include/hbexprc.c +++ b/harbour/include/hbexprc.c @@ -153,61 +153,66 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) bOpEq == HB_P_MULT || bOpEq == HB_P_DIVIDE ) && ( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) ) { - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + int iScope = hb_compVariableScope( pSelf->value.asOperator.pLeft->value.asSymbol ); - if( pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC || - pSelf->value.asOperator.pRight->ExprType == HB_ET_STRING || - pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) + if( ! ( iScope == HB_VS_LOCAL_FIELD || iScope == HB_VS_GLOBAL_FIELD ) ) { - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) + if( pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC || + pSelf->value.asOperator.pRight->ExprType == HB_ET_STRING ) { /* NOTE: direct type change */ - pSelf->value.asOperator.pRight->ExprType = HB_ET_VARREF; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + switch( bOpEq ) + { + case HB_P_PLUS: + bOpEq = HB_P_PLUSEQ; + break; + case HB_P_MINUS: + bOpEq = HB_P_MINUSEQ; + break; + case HB_P_MULT: + bOpEq = HB_P_MULTEQ; + break; + case HB_P_DIVIDE: + bOpEq = HB_P_DIVEQ; + break; + } + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); + return; } - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - switch( bOpEq ) + else if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) { - case HB_P_PLUS: - bOpEq = HB_P_PLUSEQ; - break; - case HB_P_MINUS: - bOpEq = HB_P_MINUSEQ; - break; - case HB_P_MULT: - bOpEq = HB_P_MULTEQ; - break; - case HB_P_DIVIDE: - bOpEq = HB_P_DIVEQ; - break; + int iScope = hb_compVariableScope( pSelf->value.asOperator.pRight->value.asSymbol ); + + if( ! ( iScope == HB_VS_LOCAL_FIELD || iScope == HB_VS_GLOBAL_FIELD ) ) + { + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + pSelf->value.asOperator.pRight->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + switch( bOpEq ) + { + case HB_P_PLUS: + bOpEq = HB_P_PLUSEQ; + break; + case HB_P_MINUS: + bOpEq = HB_P_MINUSEQ; + break; + case HB_P_MULT: + bOpEq = HB_P_MULTEQ; + break; + case HB_P_DIVIDE: + bOpEq = HB_P_DIVEQ; + break; + } + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); + return; + } } - HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); - return; - } - else if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) - { - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* NOTE: direct type change */ - pSelf->value.asOperator.pRight->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - switch( bOpEq ) - { - case HB_P_PLUS: - bOpEq = HB_P_PLUSEQ; - break; - case HB_P_MINUS: - bOpEq = HB_P_MINUSEQ; - break; - case HB_P_MULT: - bOpEq = HB_P_MULTEQ; - break; - case HB_P_DIVIDE: - bOpEq = HB_P_DIVEQ; - break; - } - HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); - return; } } /* push old value */ @@ -267,55 +272,66 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq ) bOpEq == HB_P_MULT || bOpEq == HB_P_DIVIDE ) && ( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) ) { - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + int iScope = hb_compVariableScope( pSelf->value.asOperator.pLeft->value.asSymbol ); - if( pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC || - pSelf->value.asOperator.pRight->ExprType == HB_ET_STRING ) + if( ! ( iScope == HB_VS_LOCAL_FIELD || iScope == HB_VS_GLOBAL_FIELD ) ) { - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - switch( bOpEq ) + if( pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC || + pSelf->value.asOperator.pRight->ExprType == HB_ET_STRING ) { - case HB_P_PLUS: - bOpEq = HB_P_PLUSEQPOP; - break; - case HB_P_MINUS: - bOpEq = HB_P_MINUSEQPOP; - break; - case HB_P_MULT: - bOpEq = HB_P_MULTEQPOP; - break; - case HB_P_DIVIDE: - bOpEq = HB_P_DIVEQPOP; - break; + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + switch( bOpEq ) + { + case HB_P_PLUS: + bOpEq = HB_P_PLUSEQPOP; + break; + case HB_P_MINUS: + bOpEq = HB_P_MINUSEQPOP; + break; + case HB_P_MULT: + bOpEq = HB_P_MULTEQPOP; + break; + case HB_P_DIVIDE: + bOpEq = HB_P_DIVEQPOP; + break; + } + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); + return; } - HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); - return; - } - else if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) - { - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* NOTE: direct type change */ - pSelf->value.asOperator.pRight->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - switch( bOpEq ) + else if( pSelf->value.asOperator.pRight->ExprType == HB_ET_VARIABLE ) { - case HB_P_PLUS: - bOpEq = HB_P_PLUSEQPOP; - break; - case HB_P_MINUS: - bOpEq = HB_P_MINUSEQPOP; - break; - case HB_P_MULT: - bOpEq = HB_P_MULTEQPOP; - break; - case HB_P_DIVIDE: - bOpEq = HB_P_DIVEQPOP; - break; + int iScope = hb_compVariableScope( pSelf->value.asOperator.pRight->value.asSymbol ); + + if( ! ( iScope == HB_VS_LOCAL_FIELD || iScope == HB_VS_GLOBAL_FIELD ) ) + { + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + pSelf->value.asOperator.pRight->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + switch( bOpEq ) + { + case HB_P_PLUS: + bOpEq = HB_P_PLUSEQPOP; + break; + case HB_P_MINUS: + bOpEq = HB_P_MINUSEQPOP; + break; + case HB_P_MULT: + bOpEq = HB_P_MULTEQPOP; + break; + case HB_P_DIVIDE: + bOpEq = HB_P_DIVEQPOP; + break; + } + HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); + return; + } } - HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq ); - return; } } diff --git a/harbour/source/compiler/exproptc.c b/harbour/source/compiler/exproptc.c index eb0193b0dd..dbd601c48a 100644 --- a/harbour/source/compiler/exproptc.c +++ b/harbour/source/compiler/exproptc.c @@ -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.6 - ignore this magic number - this is used to force compilation + * 1.7 - ignore this magic number - this is used to force compilation */ #include "hbexprc.c" diff --git a/harbour/source/macro/macroc.c b/harbour/source/macro/macroc.c index 6bafba2b8e..35be06a2da 100644 --- a/harbour/source/macro/macroc.c +++ b/harbour/source/macro/macroc.c @@ -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.5 - ignore this magic number - this is used to force compilation + * 1.6 - ignore this magic number - this is used to force compilation */ #define HB_MACRO_SUPPORT