From 21a332f04cbb17d2597cda3e6ab4ec34798899d6 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Fri, 1 Dec 2000 09:53:40 +0000 Subject: [PATCH] 2000-12-01 01:50 UTC+0800 Ron Pinkas * source/compiler/harbour.sly ! Minor optimization. * source/rtl/tgetint.prg * Corrected typo --- harbour/ChangeLog | 6 ++ harbour/source/compiler/harbour.sly | 105 +++++----------------------- harbour/source/rtl/tgetint.prg | 6 +- 3 files changed, 27 insertions(+), 90 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a7d57f90ad..0336c99274 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +2000-12-01 01:50 UTC+0800 Ron Pinkas + * source/compiler/harbour.sly + ! Minor optimization. + * source/rtl/tgetint.prg + * Corrected typo + 2000-11-30 18:25 UTC+0800 Ron Pinkas * include/hbmacro.h * source/macro/macro.y diff --git a/harbour/source/compiler/harbour.sly b/harbour/source/compiler/harbour.sly index 93f14d9915..e54ec30ca7 100644 --- a/harbour/source/compiler/harbour.sly +++ b/harbour/source/compiler/harbour.sly @@ -119,7 +119,7 @@ static HB_RTVAR_PTR hb_comp_rtvars = NULL; static HB_EXPR_PTR pArrayIndexAsList = NULL, pGetArgList = NULL, pBaseArrayName = NULL; -static BOOL bTrancuateBaseArray = FALSE, s_bBlock = FALSE, s_bBlockMacro = FALSE, s_bBlockDeclared = FALSE; +static BOOL bTrancuateBaseArray = FALSE, s_bBlock = FALSE, s_bBlockMacro = FALSE, s_bBlockDeclared = FALSE, s_bSetGet; static HB_EXPR_PTR pBlockSimple; extern int hb_compLocalGetPos( char * szVarName ); /* returns the order + 1 of a local variable */ @@ -241,7 +241,7 @@ static void hb_compDebugStart( void ) { }; %type DimIndex DimList %type FieldAlias FieldVarAlias %type PostOp -%type Get GetA GetArgList +%type Get GetVar GetA GetArgList %% @@ -1002,12 +1002,9 @@ ElemList : Argument { $$ = hb_compExprNewList( $1 ); } | ElemList ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); } ; -Get : GET Variable ',' +Get : GET GetVar ',' { - if( hb_compLocalGetPos( $2->value.asSymbol ) || - hb_compStaticGetPos( $2->value.asSymbol, hb_comp_functions.pLast ) || - hb_compMemvarGetPos( $2->value.asSymbol, hb_comp_functions.pLast ) || - hb_compFieldGetPos( $2->value.asSymbol, hb_comp_functions.pLast ) ) + if( s_bSetGet ) { HB_EXPR_PTR pSetGetBlock, pGetVar = $2, pIsNil, pIfList, pIIF; @@ -1038,87 +1035,6 @@ Get : GET Variable ',' GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - | GET AliasVar ',' - { - HB_EXPR_PTR pSetGetBlock, pGetVar = $2, pIsNil, pIfList, pIIF; - - pIsNil = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "_1" ) ), hb_compExprNewNil() ); - - pIfList = hb_compExprNewList( pIsNil ); - pIfList = hb_compExprAddListExpr( pIfList, pGetVar ); - pIfList = hb_compExprAddListExpr( pIfList, hb_compExprAssign( pGetVar, hb_compExprNewVar( "_1" ) ) ); - - pIIF = hb_compExprNewIIF( pIfList ); - - pSetGetBlock = hb_compExprNewCodeBlock(); - pSetGetBlock = hb_compExprCBVarAdd( pSetGetBlock, "_1", ' ' ); - - hb_compExprAddListExpr( pSetGetBlock, pIIF ); - - pGetArgList = hb_compExprNewArgList( pSetGetBlock ); - } - - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $5 ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ } - GetAExt ')' - { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - - | GET ObjectData ',' - { - HB_EXPR_PTR pSetGetBlock, pGetVar = $2, pIsNil, pIfList, pIIF; - - pIsNil = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "_1" ) ), hb_compExprNewNil() ); - - pIfList = hb_compExprNewList( pIsNil ); - pIfList = hb_compExprAddListExpr( pIfList, pGetVar ); - pIfList = hb_compExprAddListExpr( pIfList, hb_compExprAssign( pGetVar, hb_compExprNewVar( "_1" ) ) ); - - pIIF = hb_compExprNewIIF( pIfList ); - - pSetGetBlock = hb_compExprNewCodeBlock(); - pSetGetBlock = hb_compExprCBVarAdd( pSetGetBlock, "_1", ' ' ); - - hb_compExprAddListExpr( pSetGetBlock, pIIF ); - - pGetArgList = hb_compExprNewArgList( pSetGetBlock ); - } - - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $5 ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ } - GetAExt ')' - { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - - | GET ObjectData ArrayIndex ',' - { - HB_EXPR_PTR pSetGetBlock, pGetVar = $3, pIsNil, pIfList, pIIF; - - pIsNil = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "_1" ) ), hb_compExprNewNil() ); - - pIfList = hb_compExprNewList( pIsNil ); - pIfList = hb_compExprAddListExpr( pIfList, pGetVar ); - pIfList = hb_compExprAddListExpr( pIfList, hb_compExprAssign( pGetVar, hb_compExprNewVar( "_1" ) ) ); - - pIIF = hb_compExprNewIIF( pIfList ); - - pSetGetBlock = hb_compExprNewCodeBlock(); - pSetGetBlock = hb_compExprCBVarAdd( pSetGetBlock, "_1", ' ' ); - - hb_compExprAddListExpr( pSetGetBlock, pIIF ); - - pGetArgList = hb_compExprNewArgList( pSetGetBlock ); - } - - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $6 ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $9 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $12 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $15 ); /* WhenBlock */ } - GetAExt ')' - { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - | GET MACROVAR ',' { pGetArgList = hb_compExprNewArgList( hb_compExprNewNil() ); } EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewVar( $2 ) ) ; /* Var Name */ } ',' EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' @@ -1149,6 +1065,19 @@ Get : GET Variable ',' } ; +GetVar : Variable + { + s_bSetGet = ( hb_compLocalGetPos( $1->value.asSymbol ) || + hb_compStaticGetPos( $1->value.asSymbol, hb_comp_functions.pLast ) || + hb_compMemvarGetPos( $1->value.asSymbol, hb_comp_functions.pLast ) || + hb_compFieldGetPos( $1->value.asSymbol, hb_comp_functions.pLast ) ); + $$ = $1; + } + | AliasVar { s_bSetGet = TRUE; $$ = $1; } + | ObjectData { s_bSetGet = TRUE; $$ = $1; } + | ObjectData ArrayIndex { s_bSetGet = TRUE; $$ = $2; } + ; + GetArgList : Argument { $$ = hb_compExprAddListExpr( pGetArgList, $1 ); } | GetArgList ',' Argument { $$ = hb_compExprAddListExpr( pGetArgList, $3 ); } ; diff --git a/harbour/source/rtl/tgetint.prg b/harbour/source/rtl/tgetint.prg index 98dfea51fc..fe6178e1da 100644 --- a/harbour/source/rtl/tgetint.prg +++ b/harbour/source/rtl/tgetint.prg @@ -50,11 +50,13 @@ FUNCTION __GET( bSetGet, cVarName, cPicture, bValid, bWhen ) LOCAL oGet IF( bSetGet == NIL ) + //Alert( "No Block: " + cVarName ) IF __ISMV( cVarName ) bSetGet := {|_1| IIF( _1 == NIL, __MVGET( cVarName ), __MVPUT( cVarName, _1 ) ) } ELSE - /* "{|_1| IIF( _1 == NIL, &cVarName, &cVarName := _1 )" */ - bSetGet := &( "{|_1| IIF( _1 == NIL, " + cVarName + ", " + cVarName + " := _1 ) ) }" ) + //Alert( "Not Mem Var: " + cVarName ) + // "{|_1| IIF( _1 == NIL, &cVarName, &cVarName := _1 )" + bSetGet := &( "{|_1| IIF( _1 == NIL, " + cVarName + ", " + cVarName + " := _1 ) }" ) ENDIF ENDIF