2006-12-23 06:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbexprb.c
* do not generate HB_P_FUNCPTR - it's not longer necessary
+ added optimization for <exp> + 1, <exp> - 1 - disabled by default
because it changes error messages in hbtest, code like NIL + 1
generates 'argument error ++' instead of 'argument error +'. I'd like
you will decide what you prefer - faster code or strict Clipper error
messaged.
* harbour/source/common/expropt2.c
+ added optimizations for <num> + <date>
+ added ooptimizations for <exp> + 0, 0 + <exp>, <exp> - 0
This is also sth what may interact with operators overloading in object
system. When we will have strong typing then we should think about an
option which will optionally disable some optimizations - someone may
want to define arithmetic where <obj> + 0 gives differ then <obj>
results.
* harbour/include/hbcomp.h
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/harbour.yyh
+ added hb_compStatmentStart()
! restrict MEMVAR and FIELD usage - now they have to be located before
executable statements like in Clipper.
! generate error when PARAMETERS is used as file wide declaration.
! generate errors when different executable statements are used before
first procedure - now such code was simply ignored without any errors.
! generate valid error messages when some declarations are used in
wrong places
! fixed setting begin of executable statement flag in different .prg
constructions.
This commit is contained in:
@@ -8,6 +8,40 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2006-12-23 06:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbexprb.c
|
||||
* do not generate HB_P_FUNCPTR - it's not longer necessary
|
||||
+ added optimization for <exp> + 1, <exp> - 1 - disabled by default
|
||||
because it changes error messages in hbtest, code like NIL + 1
|
||||
generates 'argument error ++' instead of 'argument error +'. I'd like
|
||||
you will decide what you prefer - faster code or strict Clipper error
|
||||
messaged.
|
||||
|
||||
* harbour/source/common/expropt2.c
|
||||
+ added optimizations for <num> + <date>
|
||||
+ added ooptimizations for <exp> + 0, 0 + <exp>, <exp> - 0
|
||||
This is also sth what may interact with operators overloading in object
|
||||
system. When we will have strong typing then we should think about an
|
||||
option which will optionally disable some optimizations - someone may
|
||||
want to define arithmetic where <obj> + 0 gives differ then <obj>
|
||||
results.
|
||||
|
||||
* harbour/include/hbcomp.h
|
||||
* harbour/source/compiler/harbour.c
|
||||
* harbour/source/compiler/harbour.y
|
||||
* harbour/source/compiler/harbour.yyc
|
||||
* harbour/source/compiler/harbour.yyh
|
||||
+ added hb_compStatmentStart()
|
||||
! restrict MEMVAR and FIELD usage - now they have to be located before
|
||||
executable statements like in Clipper.
|
||||
! generate error when PARAMETERS is used as file wide declaration.
|
||||
! generate errors when different executable statements are used before
|
||||
first procedure - now such code was simply ignored without any errors.
|
||||
! generate valid error messages when some declarations are used in
|
||||
wrong places
|
||||
! fixed setting begin of executable statement flag in different .prg
|
||||
constructions.
|
||||
|
||||
2006-12-22 11:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/contrib/rdd_ads/adsfunc.c
|
||||
* do not use hb_param( pItem, HB_IT_BYREF ) but ISBYREF() macro
|
||||
|
||||
@@ -195,6 +195,7 @@ extern void hb_compGenJumpThere( ULONG, ULONG, HB_COMP_DECL ); /* sets a jump o
|
||||
extern void hb_compLinePush( HB_COMP_DECL ); /* generates the pcode with the currently compiled source code line */
|
||||
extern void hb_compLinePushIfDebugger( HB_COMP_DECL ); /* generates the pcode with the currently compiled source code line */
|
||||
extern void hb_compLinePushIfInside( HB_COMP_DECL ); /* generates the pcode with the currently compiled source code line */
|
||||
extern void hb_compStatmentStart( HB_COMP_DECL ); /* Check if we can start statement (without line pushing) */
|
||||
|
||||
extern void hb_compGenMessage( char * szMsgName, BOOL bIsObject, HB_COMP_DECL ); /* sends a message to an object */
|
||||
extern void hb_compGenMessageData( char * szMsg, BOOL bIsObject, HB_COMP_DECL ); /* generates an underscore-symbol name for a data assignment */
|
||||
|
||||
@@ -817,7 +817,8 @@ static HB_EXPR_FUNC( hb_compExprUseFunRef )
|
||||
|
||||
case HB_EA_PUSH_PCODE:
|
||||
HB_EXPR_PCODE1( hb_compGenPushFunCall, pSelf->value.asSymbol );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_FUNCPTR );
|
||||
/* NOTE: it's not longer necessary in current HVM */
|
||||
/* HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_FUNCPTR ); */
|
||||
break;
|
||||
|
||||
case HB_EA_POP_PCODE:
|
||||
@@ -3329,6 +3330,32 @@ static HB_EXPR_FUNC( hb_compExprUsePlus )
|
||||
break;
|
||||
|
||||
case HB_EA_PUSH_PCODE:
|
||||
#if HB_ADD_SUB_ONE_OPT
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
{
|
||||
HB_EXPR_PTR pLeft, pRight;
|
||||
pLeft = pSelf->value.asOperator.pLeft;
|
||||
pRight = pSelf->value.asOperator.pRight;
|
||||
if( pLeft->ExprType == HB_ET_NUMERIC &&
|
||||
( pLeft->value.asNum.NumType == HB_ET_LONG ?
|
||||
pLeft->value.asNum.val.l == 1 :
|
||||
pLeft->value.asNum.val.d == 1 ) )
|
||||
{
|
||||
HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC );
|
||||
break;
|
||||
}
|
||||
else if( pRight->ExprType == HB_ET_NUMERIC &&
|
||||
( pRight->value.asNum.NumType == HB_ET_LONG ?
|
||||
pRight->value.asNum.val.l == 1 :
|
||||
pRight->value.asNum.val.d == 1 ) )
|
||||
{
|
||||
HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC );
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PLUS );
|
||||
@@ -3386,6 +3413,21 @@ static HB_EXPR_FUNC( hb_compExprUseMinus )
|
||||
break;
|
||||
|
||||
case HB_EA_PUSH_PCODE:
|
||||
#if HB_ADD_SUB_ONE_OPT
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
{
|
||||
HB_EXPR_PTR pRight = pSelf->value.asOperator.pRight;
|
||||
if( pRight->ExprType == HB_ET_NUMERIC &&
|
||||
( pRight->value.asNum.NumType == HB_ET_LONG ?
|
||||
pRight->value.asNum.val.l == 1 :
|
||||
pRight->value.asNum.val.d == 1 ) )
|
||||
{
|
||||
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DEC );
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MINUS );
|
||||
|
||||
@@ -371,67 +371,125 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
pLeft = pSelf->value.asOperator.pLeft;
|
||||
pRight = pSelf->value.asOperator.pRight;
|
||||
|
||||
if( pLeft->ExprType == HB_ET_NUMERIC && pRight->ExprType == HB_ET_NUMERIC )
|
||||
if( pLeft->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );
|
||||
|
||||
switch( bType )
|
||||
if( pRight->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
case HB_ET_LONG:
|
||||
{
|
||||
HB_MAXDBL dVal = ( HB_MAXDBL ) pLeft->value.asNum.val.l + ( HB_MAXDBL ) pRight->value.asNum.val.l;
|
||||
BYTE bType = ( pLeft->value.asNum.NumType & pRight->value.asNum.NumType );
|
||||
|
||||
if ( HB_DBL_LIM_LONG( dVal ) )
|
||||
switch( bType )
|
||||
{
|
||||
case HB_ET_LONG:
|
||||
{
|
||||
pSelf->value.asNum.val.l = ( HB_LONG ) dVal;
|
||||
pSelf->value.asNum.bDec = 0;
|
||||
pSelf->value.asNum.NumType = HB_ET_LONG;
|
||||
HB_MAXDBL dVal = ( HB_MAXDBL ) pLeft->value.asNum.val.l + ( HB_MAXDBL ) pRight->value.asNum.val.l;
|
||||
|
||||
if ( HB_DBL_LIM_LONG( dVal ) )
|
||||
{
|
||||
pSelf->value.asNum.val.l = ( HB_LONG ) dVal;
|
||||
pSelf->value.asNum.bDec = 0;
|
||||
pSelf->value.asNum.NumType = HB_ET_LONG;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->value.asNum.val.d = ( double ) dVal;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
pSelf->value.asNum.bDec = 0;
|
||||
pSelf->value.asNum.NumType = HB_ET_DOUBLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->value.asNum.val.d = ( double ) dVal;
|
||||
|
||||
case HB_ET_DOUBLE:
|
||||
pSelf->value.asNum.val.d = pLeft->value.asNum.val.d + pRight->value.asNum.val.d;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
pSelf->value.asNum.bDec = 0;
|
||||
if( pLeft->value.asNum.bDec < pRight->value.asNum.bDec )
|
||||
pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
|
||||
else
|
||||
pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
|
||||
pSelf->value.asNum.NumType = HB_ET_DOUBLE;
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case HB_ET_DOUBLE:
|
||||
{
|
||||
pSelf->value.asNum.val.d = pLeft->value.asNum.val.d + pRight->value.asNum.val.d;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
if( pLeft->value.asNum.bDec < pRight->value.asNum.bDec )
|
||||
pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
|
||||
else
|
||||
pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
|
||||
pSelf->value.asNum.NumType = HB_ET_DOUBLE;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
|
||||
{
|
||||
pSelf->value.asNum.val.d = pLeft->value.asNum.val.d + ( double ) pRight->value.asNum.val.l;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l + pRight->value.asNum.val.d;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
|
||||
}
|
||||
pSelf->value.asNum.NumType = HB_ET_DOUBLE;
|
||||
default:
|
||||
if( pLeft->value.asNum.NumType == HB_ET_DOUBLE )
|
||||
{
|
||||
pSelf->value.asNum.val.d = pLeft->value.asNum.val.d + ( double ) pRight->value.asNum.val.l;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
pSelf->value.asNum.bDec = pLeft->value.asNum.bDec;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->value.asNum.val.d = ( double ) pLeft->value.asNum.val.l + pRight->value.asNum.val.d;
|
||||
pSelf->value.asNum.bWidth = HB_DEFAULT_WIDTH;
|
||||
pSelf->value.asNum.bDec = pRight->value.asNum.bDec;
|
||||
}
|
||||
pSelf->value.asNum.NumType = HB_ET_DOUBLE;
|
||||
}
|
||||
pSelf->ExprType = HB_ET_NUMERIC;
|
||||
pSelf->ValType = HB_EV_NUMERIC;
|
||||
hb_compExprFree( pLeft, HB_COMP_PARAM );
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
}
|
||||
else if( pRight->ExprType == HB_ET_DATE )
|
||||
{
|
||||
if( pLeft->value.asNum.NumType == HB_ET_LONG )
|
||||
pSelf->value.asNum.val.l = pRight->value.asNum.val.l + pLeft->value.asNum.val.l;
|
||||
else
|
||||
pSelf->value.asNum.val.l = pRight->value.asNum.val.l + ( HB_LONG ) pLeft->value.asNum.val.d;
|
||||
pSelf->ExprType = HB_ET_DATE;
|
||||
pSelf->ValType = HB_EV_DATE;
|
||||
hb_compExprFree( pLeft, HB_COMP_PARAM );
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
}
|
||||
else if( HB_SUPPORT_HARBOUR &&
|
||||
( pLeft->value.asNum.NumType == HB_ET_LONG ?
|
||||
pLeft->value.asNum.val.l == 0 :
|
||||
pLeft->value.asNum.val.d == 0 ) )
|
||||
{
|
||||
/* NOTE: This will not generate a runtime error if incompatible
|
||||
* data type is used
|
||||
*/
|
||||
pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
|
||||
hb_compExprFree( pSelf, HB_COMP_PARAM );
|
||||
pSelf = pRight;
|
||||
hb_compExprFree( pLeft, HB_COMP_PARAM );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: Check for incompatible types e.g. "txt" + 3
|
||||
*/
|
||||
}
|
||||
}
|
||||
else if( pRight->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
if( pLeft->ExprType == HB_ET_DATE )
|
||||
{
|
||||
if( pRight->value.asNum.NumType == HB_ET_LONG )
|
||||
pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + pRight->value.asNum.val.l;
|
||||
else
|
||||
pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + ( HB_LONG ) pRight->value.asNum.val.d;
|
||||
pSelf->ExprType = HB_ET_DATE;
|
||||
pSelf->ValType = HB_EV_DATE;
|
||||
hb_compExprFree( pLeft, HB_COMP_PARAM );
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
}
|
||||
else if( HB_SUPPORT_HARBOUR &&
|
||||
( pRight->value.asNum.NumType == HB_ET_LONG ?
|
||||
pRight->value.asNum.val.l == 0 :
|
||||
pRight->value.asNum.val.d == 0 ) )
|
||||
{
|
||||
/* NOTE: This will not generate a runtime error if incompatible
|
||||
* data type is used
|
||||
*/
|
||||
pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
|
||||
hb_compExprFree( pSelf, HB_COMP_PARAM );
|
||||
pSelf = pLeft;
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: Check for incompatible types e.g. "txt" + 3
|
||||
*/
|
||||
}
|
||||
pSelf->ExprType = HB_ET_NUMERIC;
|
||||
pSelf->ValType = HB_EV_NUMERIC;
|
||||
hb_compExprFree( pLeft, HB_COMP_PARAM );
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
}
|
||||
else if( pLeft->ExprType == HB_ET_STRING && pRight->ExprType == HB_ET_STRING )
|
||||
{
|
||||
@@ -464,21 +522,6 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( pLeft->ExprType == HB_ET_DATE && pRight->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
if( pRight->value.asNum.NumType == HB_ET_LONG )
|
||||
{
|
||||
pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + pRight->value.asNum.val.l;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + ( HB_LONG ) pRight->value.asNum.val.d;
|
||||
}
|
||||
pSelf->ExprType = HB_ET_DATE;
|
||||
pSelf->ValType = HB_EV_DATE;
|
||||
hb_compExprFree( pLeft, HB_COMP_PARAM );
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: Check for incompatible types e.g. "txt" + 3
|
||||
|
||||
@@ -749,7 +749,9 @@ void hb_compVariableAdd( HB_COMP_DECL, char * szVarName, BYTE cValueType )
|
||||
|
||||
HB_SYMBOL_UNUSED( cValueType );
|
||||
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 && HB_COMP_PARAM->iVarScope == VS_LOCAL )
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 &&
|
||||
( HB_COMP_PARAM->iVarScope == VS_LOCAL ||
|
||||
HB_COMP_PARAM->iVarScope == ( VS_PRIVATE | VS_PARAMETER ) ) )
|
||||
{
|
||||
/* Variable declaration is outside of function/procedure body.
|
||||
In this case only STATIC and PARAMETERS variables are allowed. */
|
||||
@@ -759,11 +761,32 @@ void hb_compVariableAdd( HB_COMP_DECL, char * szVarName, BYTE cValueType )
|
||||
|
||||
/* check if we are declaring local/static variable after some
|
||||
* executable statements
|
||||
* Note: FIELD and MEMVAR are executable statements
|
||||
*/
|
||||
if( ( HB_COMP_PARAM->functions.pLast->bFlags & FUN_STATEMENTS ) && !( HB_COMP_PARAM->iVarScope == VS_FIELD || ( HB_COMP_PARAM->iVarScope & VS_MEMVAR ) ) )
|
||||
if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_STATEMENTS )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FOLLOWS_EXEC, ( HB_COMP_PARAM->iVarScope == VS_LOCAL ? "LOCAL" : "STATIC" ), NULL );
|
||||
char * szVarScope;
|
||||
switch( HB_COMP_PARAM->iVarScope )
|
||||
{
|
||||
case VS_LOCAL:
|
||||
szVarScope = "LOCAL";
|
||||
break;
|
||||
case VS_STATIC:
|
||||
szVarScope = "STATIC";
|
||||
break;
|
||||
case VS_FIELD:
|
||||
szVarScope = "FIELD";
|
||||
break;
|
||||
case VS_MEMVAR:
|
||||
szVarScope = "MEMVAR";
|
||||
break;
|
||||
default:
|
||||
szVarScope = NULL;
|
||||
}
|
||||
if( szVarScope )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FOLLOWS_EXEC, szVarScope, NULL );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if a declaration of duplicated variable name is requested */
|
||||
@@ -772,9 +795,9 @@ void hb_compVariableAdd( HB_COMP_DECL, char * szVarName, BYTE cValueType )
|
||||
/* variable defined in a function/procedure */
|
||||
hb_compCheckDuplVars( HB_COMP_PARAM, pFunc->pFields, szVarName );
|
||||
hb_compCheckDuplVars( HB_COMP_PARAM, pFunc->pStatics, szVarName );
|
||||
/*NOTE: Clipper warns if PARAMETER variable duplicates the MEMVAR
|
||||
/* NOTE: Clipper warns if PARAMETER variable duplicates the MEMVAR
|
||||
* declaration
|
||||
*/
|
||||
*/
|
||||
if( !( HB_COMP_PARAM->iVarScope == VS_PRIVATE || HB_COMP_PARAM->iVarScope == VS_PUBLIC ) )
|
||||
hb_compCheckDuplVars( HB_COMP_PARAM, pFunc->pMemvars, szVarName );
|
||||
}
|
||||
@@ -809,7 +832,7 @@ void hb_compVariableAdd( HB_COMP_DECL, char * szVarName, BYTE cValueType )
|
||||
HB_COMP_PARAM->szFromClass = NULL;
|
||||
}
|
||||
|
||||
if ( HB_COMP_PARAM->iVarScope & VS_PARAMETER )
|
||||
if( HB_COMP_PARAM->iVarScope & VS_PARAMETER )
|
||||
pVar->iUsed = VU_INITIALIZED;
|
||||
|
||||
if( HB_COMP_PARAM->iVarScope & VS_MEMVAR )
|
||||
@@ -2602,11 +2625,30 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE );
|
||||
}
|
||||
|
||||
/*
|
||||
* Test if we can generate statement (without line pushing)
|
||||
*/
|
||||
void hb_compStatmentStart( HB_COMP_DECL )
|
||||
{
|
||||
// if( ! HB_COMP_PARAM->fExternal )
|
||||
if( ( HB_COMP_PARAM->functions.pLast->bFlags & FUN_STATEMENTS ) == 0 )
|
||||
{
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL );
|
||||
return;
|
||||
}
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_STATEMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generates the pcode with the currently compiled source code line
|
||||
* if debug code was requested only
|
||||
*/
|
||||
void hb_compLinePushIfDebugger( HB_COMP_DECL )
|
||||
{
|
||||
hb_compStatmentStart( HB_COMP_PARAM );
|
||||
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
else
|
||||
@@ -2622,18 +2664,7 @@ void hb_compLinePushIfDebugger( HB_COMP_DECL )
|
||||
|
||||
void hb_compLinePushIfInside( HB_COMP_DECL ) /* generates the pcode with the currently compiled source code line */
|
||||
{
|
||||
/* This line can be placed inside a procedure or function only
|
||||
* except EXTERNAL
|
||||
*/
|
||||
if( ! HB_COMP_PARAM->fExternal )
|
||||
{
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_STATEMENTS;
|
||||
hb_compStatmentStart( HB_COMP_PARAM );
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
@@ -3687,6 +3718,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
BYTE * pCode = HB_COMP_PARAM->functions.pLast->pCode;
|
||||
ULONG * pNOOPs, * pJumps;
|
||||
ULONG ulOptimized, ulNextByte, ulBytes2Copy, ulJumpAddr, iNOOP, iJump;
|
||||
BOOL fLineStrip = !HB_COMP_PARAM->fDebugInfo && HB_COMP_PARAM->fLineNumbers;
|
||||
int iPass;
|
||||
|
||||
if( ! HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
@@ -3698,8 +3730,11 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
{
|
||||
LONG lOffset;
|
||||
|
||||
if( iPass == 2 && ! HB_COMP_PARAM->fDebugInfo && HB_COMP_PARAM->fLineNumbers )
|
||||
if( iPass == 2 && fLineStrip )
|
||||
{
|
||||
hb_compStripFuncLines( HB_COMP_PARAM->functions.pLast );
|
||||
fLineStrip = FALSE;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->functions.pLast->iJumps > 0 )
|
||||
{
|
||||
@@ -3839,7 +3874,12 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->functions.pLast->iNOOPs == 0 )
|
||||
return;
|
||||
{
|
||||
if( fLineStrip )
|
||||
hb_compStripFuncLines( HB_COMP_PARAM->functions.pLast );
|
||||
if( HB_COMP_PARAM->functions.pLast->iNOOPs == 0 )
|
||||
return;
|
||||
}
|
||||
|
||||
pNOOPs = HB_COMP_PARAM->functions.pLast->pNOOPs;
|
||||
|
||||
|
||||
@@ -297,18 +297,12 @@ Main : { hb_compLinePush( HB_COMP_PARAM ); } Source { }
|
||||
;
|
||||
|
||||
Source : Crlf
|
||||
| VarDefs
|
||||
| FieldsDef
|
||||
| MemvarDef
|
||||
| Declaration
|
||||
| Function
|
||||
| Statement
|
||||
| Line
|
||||
| error Crlf { yyclearin; yyerrok; }
|
||||
| Source Crlf
|
||||
| Source VarDefs
|
||||
| Source FieldsDef
|
||||
| Source MemvarDef
|
||||
| Source Declaration
|
||||
| Source Function
|
||||
| Source Statement
|
||||
@@ -404,6 +398,8 @@ Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
hb_compGenPCode2( HB_P_DOSHORT, 1, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE;
|
||||
}
|
||||
| EXIT { HB_COMP_PARAM->fDontGenLineNum = !HB_COMP_PARAM->fDebugInfo; } CrlfStmnt { hb_compLoopExit( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| LOOP { HB_COMP_PARAM->fDontGenLineNum = !HB_COMP_PARAM->fDebugInfo; } CrlfStmnt { hb_compLoopLoop( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| RETURN CrlfStmnt {
|
||||
if( HB_COMP_PARAM->wSeqCounter )
|
||||
{
|
||||
@@ -450,9 +446,9 @@ Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
HB_COMP_PARAM->cVarType = ' '; HB_COMP_PARAM->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
} Crlf
|
||||
|
||||
| EXIT { HB_COMP_PARAM->fDontGenLineNum = !HB_COMP_PARAM->fDebugInfo; } CrlfStmnt { hb_compLoopExit( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| LOOP { HB_COMP_PARAM->fDontGenLineNum = !HB_COMP_PARAM->fDebugInfo; } CrlfStmnt { hb_compLoopLoop( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| VarDefs
|
||||
| FieldsDef
|
||||
| MemvarDef
|
||||
| EXTERN ExtList Crlf
|
||||
| ANNOUNCE IdentName {
|
||||
if( HB_COMP_PARAM->szAnnounce == NULL )
|
||||
@@ -510,7 +506,7 @@ LineStat : Crlf { $<lNumber>$ = 0; HB_COMP_PARAM->fDontGenLineNum = T
|
||||
yyerrok;
|
||||
HB_COMP_PARAM->ilastLineErr = iLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ControlError : FunScopeId FUNCTION IdentName Crlf {}
|
||||
@@ -1197,13 +1193,15 @@ IfInline : IIF PareExpList3 { $$ = hb_compExprNewIIF( $2, HB_COMP_
|
||||
IfInlineAlias : IfInline ALIASOP { $$ = $1; }
|
||||
;
|
||||
|
||||
VarDefs : LOCAL { HB_COMP_PARAM->iVarScope = VS_LOCAL; hb_compLinePush( HB_COMP_PARAM ); } VarList Crlf { HB_COMP_PARAM->cVarType = ' '; }
|
||||
| STATIC { HB_COMP_PARAM->iVarScope = VS_STATIC; hb_compLinePush( HB_COMP_PARAM ); } VarList Crlf { HB_COMP_PARAM->cVarType = ' '; }
|
||||
VarDefs : LOCAL { HB_COMP_PARAM->iVarScope = VS_LOCAL; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
VarList Crlf { HB_COMP_PARAM->cVarType = ' '; }
|
||||
| STATIC { HB_COMP_PARAM->iVarScope = VS_STATIC; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
VarList Crlf { HB_COMP_PARAM->cVarType = ' '; }
|
||||
| PARAMETERS { if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_USES_LOCAL_PARAMS )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_PARAMETERS_NOT_ALLOWED, NULL, NULL );
|
||||
else
|
||||
HB_COMP_PARAM->functions.pLast->wParamNum=0; HB_COMP_PARAM->iVarScope = ( VS_PRIVATE | VS_PARAMETER ); }
|
||||
MemvarList Crlf { HB_COMP_PARAM->iVarScope = VS_NONE; }
|
||||
MemvarList Crlf { HB_COMP_PARAM->iVarScope = VS_NONE; }
|
||||
;
|
||||
|
||||
VarList : VarDef { $$ = 1; }
|
||||
@@ -1487,23 +1485,23 @@ EmptyStats : /* empty */ { $<lNumber>$ = 0; }
|
||||
| EmptyStatements { $<lNumber>$ = $<lNumber>1; }
|
||||
;
|
||||
|
||||
IfBegin : IF SimpleExpression { ++HB_COMP_PARAM->wIfCounter; hb_compLinePush( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
IfBegin : IF SimpleExpression { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF Variable { ++HB_COMP_PARAM->wIfCounter; hb_compLinePush( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
| IF Variable { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF PareExpList1 { ++HB_COMP_PARAM->wIfCounter; hb_compLinePush( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
| IF PareExpList1 { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF PareExpList2 { ++HB_COMP_PARAM->wIfCounter; hb_compLinePush( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
| IF PareExpList2 { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF PareExpListN { ++HB_COMP_PARAM->wIfCounter; hb_compLinePush( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
| IF PareExpListN { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
;
|
||||
@@ -1582,7 +1580,7 @@ DoCaseBegin : DoCaseStart { }
|
||||
}
|
||||
;
|
||||
|
||||
Cases : CASE { hb_compLinePush( HB_COMP_PARAM ); } Expression Crlf
|
||||
Cases : CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf
|
||||
{
|
||||
hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
|
||||
@@ -1594,7 +1592,7 @@ Cases : CASE { hb_compLinePush( HB_COMP_PARAM ); } Expression Crlf
|
||||
hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
| Cases CASE { hb_compLinePush( HB_COMP_PARAM ); } Expression Crlf
|
||||
| Cases CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf
|
||||
{
|
||||
hb_compExprDelete( hb_compExprGenPush( $4, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
|
||||
@@ -1642,7 +1640,7 @@ EndWhile : END { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE;
|
||||
|
||||
ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */
|
||||
{
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
hb_compDebugStart();
|
||||
++HB_COMP_PARAM->wForCounter; /* 5 */
|
||||
$<asExpr>$ = hb_compExprGenStatement( hb_compExprAssign( $2, $4, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
@@ -1760,7 +1758,7 @@ ForExpr : Expression { $$ = hb_compExprNewArgList( $1, HB_COMP_P
|
||||
ForEach : FOREACH ForList IN ForExpr /* 1 2 3 4 */
|
||||
{
|
||||
++HB_COMP_PARAM->wForCounter; /* 5 */
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
hb_compDebugStart();
|
||||
}
|
||||
Descend /* 6 */
|
||||
@@ -1826,7 +1824,7 @@ EndSwitch : END
|
||||
|
||||
SwitchStart : DOSWITCH
|
||||
{ ++HB_COMP_PARAM->wSwitchCounter;
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
}
|
||||
Expression Crlf
|
||||
{
|
||||
@@ -1844,21 +1842,21 @@ SwitchBegin : SwitchStart { }
|
||||
;
|
||||
|
||||
SwitchCases : CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $2 ); hb_compLinePush( HB_COMP_PARAM ); } Crlf
|
||||
EmptyStats
|
||||
EmptyStats
|
||||
|
||||
| SwitchCases CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $3 ); hb_compLinePush( HB_COMP_PARAM ); }Crlf
|
||||
EmptyStats
|
||||
| SwitchCases CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $3 ); hb_compLinePush( HB_COMP_PARAM ); }Crlf
|
||||
EmptyStats
|
||||
|
||||
| SwitchDefault
|
||||
| SwitchDefault
|
||||
|
||||
| SwitchCases SwitchDefault
|
||||
;
|
||||
| SwitchCases SwitchDefault
|
||||
;
|
||||
|
||||
SwitchDefault : OTHERWISE { hb_compSwitchAdd( HB_COMP_PARAM, NULL ); hb_compLinePush( HB_COMP_PARAM ); } Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
EmptyStats
|
||||
;
|
||||
|
||||
BeginSeq : BEGINSEQ { ++HB_COMP_PARAM->wSeqCounter; $<lNumber>$ = hb_compSequenceBegin( HB_COMP_PARAM ); } Crlf
|
||||
BeginSeq : BEGINSEQ { ++HB_COMP_PARAM->wSeqCounter; hb_compStatmentStart( HB_COMP_PARAM ); $<lNumber>$ = hb_compSequenceBegin( HB_COMP_PARAM ); } Crlf
|
||||
EmptyStats
|
||||
{
|
||||
/* Set jump address for HB_P_SEQBEGIN opcode - this address
|
||||
@@ -1900,7 +1898,7 @@ RecoverEmpty : RECOVER
|
||||
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
if( HB_COMP_PARAM->wSeqCounter )
|
||||
--HB_COMP_PARAM->wSeqCounter;
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
hb_compGenPCode2( HB_P_SEQRECOVER, HB_P_POP, HB_COMP_PARAM );
|
||||
}
|
||||
;
|
||||
@@ -1911,7 +1909,7 @@ RecoverUsing : RECOVERUSING IdentName
|
||||
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
if( HB_COMP_PARAM->wSeqCounter )
|
||||
--HB_COMP_PARAM->wSeqCounter;
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
hb_compGenPCode1( HB_P_SEQRECOVER, HB_COMP_PARAM );
|
||||
hb_compGenPopVar( $2, HB_COMP_PARAM );
|
||||
}
|
||||
@@ -1962,6 +1960,7 @@ DoArgument : IdentName { $$ = hb_compExprNewVarRef( $1, HB_C
|
||||
|
||||
WithObject : WITHOBJECT Expression Crlf
|
||||
{
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
hb_compGenPCode1( HB_P_WITHOBJECTSTART, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->wWithObjectCnt++;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -250,7 +250,7 @@
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 103 "../../harbour.y"
|
||||
#line 103 "harbour.y"
|
||||
{
|
||||
char * string; /* to hold a string returned by lex */
|
||||
int iNumber; /* to hold a temporary integer number */
|
||||
|
||||
Reference in New Issue
Block a user