diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fc2d143cd2..d033f11c8a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,24 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + +2006-06-26 14:27 UTC+0300 Chen Kedem + * doc/en/var.txt + + +2006-06-26 12:55 UTC+0100 Ryszard Glab + * TODO + * assigned SQLRDD to me + + * source/compiler/harbour.c + * source/compiler/harbour.y + * fixed one more warning (function with no RETURN) in cases: + + RETURN 1 + ELSE + * fixed to call hb_gcUnregisterSweep before the memory + ENDIF + * include/hbapi.h * source/vm/garbage.c * fixed to call hb_gcUnregisterSweep before the memory diff --git a/harbour/TODO b/harbour/TODO index 384ab1054b..47fc62f074 100644 --- a/harbour/TODO +++ b/harbour/TODO @@ -193,7 +193,7 @@ Status...: Open. Assign to: Ryszard Detail...: Clean vertical spacing in .ppo files. It's necessary to strep leading blank lines from included files. -Status...: Open. +Status...: Worjing on it. *** @@ -205,9 +205,9 @@ Status...: Open. *** -Assign to: +Assign to: Ryszard Detail...: SQLRDD. -Status...: Open. +Status...: Working on it. *** @@ -217,7 +217,7 @@ Status...: Working on it. *** -Assign to: +Assign to: Ryszard Detail...: Real strong typing in the compiler. Status...: Open. diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index dc57281809..2d3ff81af3 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -547,7 +547,7 @@ typedef HB_GARBAGE_SWEEPER( HB_GARBAGE_SWEEPER_ ); typedef HB_GARBAGE_SWEEPER_ * HB_GARBAGE_SWEEPER_PTR; extern void hb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ); -extern void hb_gcUnregisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ); +extern void hb_gcUnregisterSweep( void * Cargo ); extern PHB_ITEM hb_gcGripGet( HB_ITEM_PTR pItem ); extern void hb_gcGripDrop( HB_ITEM_PTR pItem ); diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 42fe0032d4..69674bf30c 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -2926,7 +2926,7 @@ void hb_compLinePush( void ) /* generates the pcode with the currently compiled } hb_comp_bDontGenLineNum = FALSE; /* clear RETURN/BREAK flag */ - hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); + hb_comp_functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE ); /* Resting Compile Time Stack */ hb_comp_functions.pLast->iStackIndex = 0; @@ -2948,7 +2948,7 @@ void hb_compLinePushIfDebugger( void ) /* previous line contained RETURN/BREAK/LOOP/EXIT statement */ hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_UNREACHABLE, NULL, NULL ); } - hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); /* clear RETURN flag */ + hb_comp_functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE ); /* clear RETURN flag */ } } diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 3b8aa6b2ac..eebbf35864 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -330,7 +330,7 @@ Line : LINE NUM_INTEGER LITERAL Crlf | LINE NUM_INTEGER LITERAL '@' LITERAL Crlf /* Xbase++ style */ ; -ProcReq : PROCREQ CompTimeStr ')' Crlf {} +ProcReq : PROCREQ CompTimeStr ')' Crlf { hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } ; CompTimeStr: LITERAL { hb_compAutoOpenAdd( $1 ); } @@ -388,27 +388,29 @@ ParamList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_c * stop compilation if invalid syntax will be used. */ Statement : ExecFlow { hb_comp_bDontGenLineNum = TRUE; } CrlfStmnt { } - | IfInline CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | FunCall CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | AliasExpr CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ObjectMethod CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } + | IfInline CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | FunCall CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | AliasExpr CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ObjectMethod CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } | MacroVar CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) hb_compExprDelete( hb_compExprGenStatement( $1 ) ); else hb_compExprDelete( hb_compErrorSyntax( $1 ) ); + hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } | MacroExpr CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) hb_compExprDelete( hb_compExprGenStatement( $1 ) ); else hb_compExprDelete( hb_compErrorSyntax( $1 ) ); + hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | PareExpList CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprPreOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprPostOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprOperEq CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprEqual CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } + | PareExpList CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprPreOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprPostOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprOperEq CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprEqual CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } | BREAK CrlfStmnt { hb_compGenBreak(); hb_compGenPCode2( HB_P_DOSHORT, 0, ( BOOL ) 1 ); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | BREAK { hb_compLinePushIfInside(); } Expression Crlf { hb_compGenBreak(); hb_compExprDelete( hb_compExprGenPush( $3 ) ); @@ -450,10 +452,16 @@ Statement : ExecFlow { hb_comp_bDontGenLineNum = TRUE; } CrlfStmnt { } } | PUBLIC { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PUBLIC; } ExtVarList - { hb_compRTVariableGen( hb_compIdentifierNew("__MVPUBLIC",TRUE) ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } Crlf + { hb_compRTVariableGen( hb_compIdentifierNew("__MVPUBLIC",TRUE) ); + hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; + hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; + } Crlf | PRIVATE { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PRIVATE; } ExtVarList - { hb_compRTVariableGen( hb_compIdentifierNew("__MVPRIVATE",TRUE) ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } Crlf + { hb_compRTVariableGen( hb_compIdentifierNew("__MVPRIVATE",TRUE) ); + hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; + hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; + } Crlf | EXIT { hb_comp_bDontGenLineNum = !hb_comp_bDebugInfo; } CrlfStmnt { hb_compLoopExit(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } | LOOP { hb_comp_bDontGenLineNum = !hb_comp_bDebugInfo; } CrlfStmnt { hb_compLoopLoop(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } @@ -1481,8 +1489,8 @@ IfElseIf : ELSEIF { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_co } ; -EndIf : ENDIF { --hb_comp_wIfCounter; hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); } - | END { --hb_comp_wIfCounter; hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); } +EndIf : ENDIF { --hb_comp_wIfCounter; hb_comp_functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE ); } + | END { --hb_comp_wIfCounter; hb_comp_functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE ); } ; DoCase : DoCaseBegin @@ -2657,3 +2665,4 @@ void hb_compSwitchKill( ) hb_xfree( (void *) pSwitch ); } } + diff --git a/harbour/source/vm/garbage.c b/harbour/source/vm/garbage.c index 1702a7cd70..6ec395bfd1 100644 --- a/harbour/source/vm/garbage.c +++ b/harbour/source/vm/garbage.c @@ -96,6 +96,7 @@ typedef struct HB_GARBAGE_ #define HB_GC_LOCKED 1 /* do not collect a memory block */ #define HB_GC_USED_FLAG 2 /* the bit for used/unused flag */ #define HB_GC_DELETE 4 /* item will be deleted during finalization */ +#define HB_GC_USERSWEEP 8 /* memory block with user defined sweep function */ /* pointer to memory block that will be checked in next step */ static HB_GARBAGE_PTR s_pCurrBlock = NULL; @@ -415,12 +416,17 @@ void hb_gcItemRef( HB_ITEM_PTR pItem ) void hb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ) { HB_GARBAGE_EXTERN_PTR pExt; + HB_GARBAGE_PTR pAlloc; pExt = ( HB_GARBAGE_EXTERN_PTR ) hb_xgrab( sizeof( HB_GARBAGE_EXTERN ) ); pExt->pFunc = pSweep; pExt->pBlock = Cargo; pExt->pNext = NULL; + /* set user sweep flag */ + pAlloc = ( HB_GARBAGE_PTR ) ( ( BYTE * ) Cargo - HB_GARBAGE_SIZE ); + pAlloc->used ^= HB_GC_USERSWEEP; + if( s_pSweepExtern == NULL ) { s_pSweepExtern = pExt; @@ -433,7 +439,7 @@ void hb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ) } -void hb_gcUnregisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ) +void hb_gcUnregisterSweep( void * Cargo ) { HB_GARBAGE_EXTERN_PTR pExt; HB_GARBAGE_EXTERN_PTR pPrev; @@ -441,8 +447,14 @@ void hb_gcUnregisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo ) pPrev = pExt = s_pSweepExtern; while( pExt ) { - if( pExt->pFunc == pSweep && pExt->pBlock == Cargo ) + if( pExt->pBlock == Cargo ) { + HB_GARBAGE_PTR pAlloc; + + /* clear user sweep flag */ + pAlloc = ( HB_GARBAGE_PTR ) ( ( BYTE * ) Cargo - HB_GARBAGE_SIZE ); + pAlloc->used &= ~ HB_GC_USERSWEEP; + if( pExt == s_pSweepExtern ) { s_pSweepExtern = pExt->pNext; @@ -568,6 +580,9 @@ void hb_gcCollectAll( void ) pAlloc = s_pDeletedBlock; do { + if( s_pDeletedBlock->used & HB_GC_USERSWEEP ) + hb_gcUnregisterSweep( HB_MEM_PTR( s_pDeletedBlock ) ); + if( s_pDeletedBlock->pFunc ) ( s_pDeletedBlock->pFunc )( HB_MEM_PTR( s_pDeletedBlock ) );