2006-12-24 16:54 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcompdf.h
* harbour/include/hbexprb.c
* harbour/source/common/expropt1.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/hbcomp.c
- removed not longer used fExternal from compiler structure
* allow to pass array items by reference ( func(@a[1]) ) and some
cleanups in reference rules. Probably we should also block using:
@func(param1 [,param2,[,...paramN]])
and accept only @func()
! fixed using statements in codeblocks used to initialize static
variables and some other cleanups (f.e. allow to use as static
initializers any functions which are later eliminated by expression
optimizer.
This commit is contained in:
@@ -8,6 +8,24 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2006-12-24 16:54 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbcompdf.h
|
||||
* harbour/include/hbexprb.c
|
||||
* harbour/source/common/expropt1.c
|
||||
* harbour/source/compiler/harbour.c
|
||||
* harbour/source/compiler/harbour.y
|
||||
* harbour/source/compiler/harbour.yyc
|
||||
* harbour/source/compiler/hbcomp.c
|
||||
- removed not longer used fExternal from compiler structure
|
||||
* allow to pass array items by reference ( func(@a[1]) ) and some
|
||||
cleanups in reference rules. Probably we should also block using:
|
||||
@func(param1 [,param2,[,...paramN]])
|
||||
and accept only @func()
|
||||
! fixed using statements in codeblocks used to initialize static
|
||||
variables and some other cleanups (f.e. allow to use as static
|
||||
initializers any functions which are later eliminated by expression
|
||||
optimizer.
|
||||
|
||||
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
|
||||
|
||||
@@ -614,7 +614,6 @@ typedef struct _HB_COMP
|
||||
BOOL fLongOptimize; /* optimize PCODEs generated for integers */
|
||||
BOOL fAutoOpen; /* automatically compile DO...[WITH...] external modules (-m) */
|
||||
BOOL fError; /* error appeared during compilation */
|
||||
BOOL fExternal; /* suppress error report generation for EXTERNAL statement */
|
||||
|
||||
USHORT wSeqCounter;
|
||||
USHORT wForCounter;
|
||||
|
||||
@@ -3330,29 +3330,49 @@ static HB_EXPR_FUNC( hb_compExprUsePlus )
|
||||
break;
|
||||
|
||||
case HB_EA_PUSH_PCODE:
|
||||
#if HB_ADD_SUB_ONE_OPT
|
||||
#if defined( 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 ) )
|
||||
if( pLeft->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC );
|
||||
break;
|
||||
if( 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( 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_DEC );
|
||||
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 ) )
|
||||
else if( pRight->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC );
|
||||
break;
|
||||
if( 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;
|
||||
}
|
||||
else if( 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_DEC );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -3413,18 +3433,28 @@ static HB_EXPR_FUNC( hb_compExprUseMinus )
|
||||
break;
|
||||
|
||||
case HB_EA_PUSH_PCODE:
|
||||
#if HB_ADD_SUB_ONE_OPT
|
||||
#if defined( 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 ) )
|
||||
if( pRight->ExprType == HB_ET_NUMERIC )
|
||||
{
|
||||
HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE );
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DEC );
|
||||
break;
|
||||
if( 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;
|
||||
}
|
||||
else if( 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_INC );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -199,8 +199,8 @@ char *hb_compExprAsSymbol( HB_EXPR_PTR pExpr )
|
||||
case HB_ET_VARIABLE:
|
||||
case HB_ET_VARREF:
|
||||
case HB_ET_FUNNAME:
|
||||
return pExpr->value.asSymbol ;
|
||||
|
||||
return pExpr->value.asSymbol;
|
||||
|
||||
case HB_ET_FUNCALL:
|
||||
return pExpr->value.asFunCall.pFunName->value.asSymbol;
|
||||
}
|
||||
|
||||
@@ -659,7 +659,6 @@ void hb_compExternAdd( HB_COMP_DECL, char * szExternName ) /* defines a new exte
|
||||
pLast = pLast->pNext;
|
||||
pLast->pNext = pExtern;
|
||||
}
|
||||
HB_COMP_PARAM->fExternal = TRUE;
|
||||
}
|
||||
|
||||
void hb_compDeclaredParameterAdd( HB_COMP_DECL, char * szVarName, BYTE cValueType )
|
||||
@@ -2630,10 +2629,11 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c
|
||||
*/
|
||||
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 )
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 &&
|
||||
HB_COMP_PARAM->functions.pLast != HB_COMP_PARAM->pInitFunc &&
|
||||
HB_COMP_PARAM->functions.pLast->szName )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL );
|
||||
return;
|
||||
@@ -4725,8 +4725,6 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile )
|
||||
/* printf( "No code generated\n" ); */
|
||||
iStatus = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
HB_COMP_PARAM->fExternal = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -434,36 +434,36 @@ Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
HB_COMP_PARAM->fDontGenLineNum = TRUE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE;
|
||||
}
|
||||
| PUBLIC { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->iVarScope = VS_PUBLIC; }
|
||||
| PUBLIC { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->iVarScope = VS_PUBLIC; }
|
||||
ExtVarList
|
||||
{ hb_compRTVariableGen( HB_COMP_PARAM, "__MVPUBLIC" );
|
||||
HB_COMP_PARAM->cVarType = ' '; HB_COMP_PARAM->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
} Crlf
|
||||
| PRIVATE { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->iVarScope = VS_PRIVATE; }
|
||||
ExtVarList
|
||||
{ hb_compRTVariableGen( HB_COMP_PARAM, "__MVPRIVATE" );
|
||||
HB_COMP_PARAM->cVarType = ' '; HB_COMP_PARAM->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
} Crlf
|
||||
{ hb_compRTVariableGen( HB_COMP_PARAM, "__MVPUBLIC" );
|
||||
HB_COMP_PARAM->cVarType = ' '; HB_COMP_PARAM->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
} Crlf
|
||||
| PRIVATE { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->iVarScope = VS_PRIVATE; }
|
||||
ExtVarList
|
||||
{ hb_compRTVariableGen( HB_COMP_PARAM, "__MVPRIVATE" );
|
||||
HB_COMP_PARAM->cVarType = ' '; HB_COMP_PARAM->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
} Crlf
|
||||
| VarDefs
|
||||
| FieldsDef
|
||||
| MemvarDef
|
||||
| EXTERN ExtList Crlf
|
||||
| ANNOUNCE IdentName {
|
||||
if( HB_COMP_PARAM->szAnnounce == NULL )
|
||||
{
|
||||
/* check for reserved name
|
||||
* NOTE: Clipper doesn't check for it
|
||||
*/
|
||||
char * szFunction = hb_compReservedName( $2 );
|
||||
if( szFunction )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FUNC_RESERVED, szFunction, $2 );
|
||||
HB_COMP_PARAM->szAnnounce = $2;
|
||||
}
|
||||
else
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_DUPL_ANNOUNCE, $2, NULL );
|
||||
} Crlf
|
||||
if( HB_COMP_PARAM->szAnnounce == NULL )
|
||||
{
|
||||
/* check for reserved name
|
||||
* NOTE: Clipper doesn't check for it
|
||||
*/
|
||||
char * szFunction = hb_compReservedName( $2 );
|
||||
if( szFunction )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FUNC_RESERVED, szFunction, $2 );
|
||||
HB_COMP_PARAM->szAnnounce = $2;
|
||||
}
|
||||
else
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_DUPL_ANNOUNCE, $2, NULL );
|
||||
} Crlf
|
||||
| PROCREQ CompTimeStr ')' Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
;
|
||||
|
||||
@@ -739,7 +739,7 @@ VariableAtAlias : VariableAt ALIASOP { $$ = $1; }
|
||||
*/
|
||||
FunIdentCall: IdentName '(' {$<bTrue>$=HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL;} ArgList ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( $1, HB_COMP_PARAM ), $4, HB_COMP_PARAM ); HB_COMP_PARAM->iPassByRef=$<bTrue>3; }
|
||||
;
|
||||
|
||||
|
||||
FunCall : FunIdentCall { $$ = $1; }
|
||||
| MacroVar '(' {$<bTrue>$=HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL;} ArgList ')' { $$ = hb_compExprNewFunCall( $1, $4, HB_COMP_PARAM ); HB_COMP_PARAM->iPassByRef=$<bTrue>3; }
|
||||
| MacroExpr '(' {$<bTrue>$=HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL;} ArgList ')' { $$ = hb_compExprNewFunCall( $1, $4, HB_COMP_PARAM ); HB_COMP_PARAM->iPassByRef=$<bTrue>3; }
|
||||
@@ -840,11 +840,15 @@ Expression : Variable { $$ = $1; }
|
||||
| PareExpList { $$ = $1; }
|
||||
| Variable { HB_COMP_PARAM->cVarType = ' ';} StrongType { $$ = $1; }
|
||||
| PareExpList { HB_COMP_PARAM->cVarType = ' ';} StrongType { $$ = $1; }
|
||||
| '@' FunIdentCall {
|
||||
$$ = hb_compExprNewFunRef( hb_compExprAsSymbol( $2 ), HB_COMP_PARAM );
|
||||
hb_compExprDelete( $2, HB_COMP_PARAM );
|
||||
}
|
||||
| '@' IdentName { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewVarRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' FunIdentCall { int bPassByRef=HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL;$<string>$ = hb_compExprAsSymbol( $2 ); hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewFunRef( $<string>$, HB_COMP_PARAM ) ); HB_COMP_PARAM->iPassByRef=bPassByRef; }
|
||||
| '@' MacroVar { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' AliasVar { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' ObjectData { $$ = hb_compExprNewRef( $2, HB_COMP_PARAM ); }
|
||||
| '@' ObjectData { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' VariableAt { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, $2 ); $$->value.asList.reference = TRUE; }
|
||||
;
|
||||
|
||||
EmptyExpression : /* nothing => nil */ { $$ = hb_compExprNewEmpty( HB_COMP_PARAM ); }
|
||||
@@ -2455,7 +2459,7 @@ static HB_CARGO2_FUNC( hb_compEnumEvalStart )
|
||||
char * szName = hb_compExprAsSymbol( (HB_EXPR_PTR)cargo );
|
||||
if( szName )
|
||||
hb_compForStart( HB_COMP_PARAM, szName, TRUE );
|
||||
|
||||
|
||||
hb_compExprGenPush( (HB_EXPR_PTR)dummy, HB_COMP_PARAM ); /* expression */
|
||||
hb_compExprGenPush( (HB_EXPR_PTR)cargo, HB_COMP_PARAM ); /* variable */
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -95,9 +95,6 @@ HB_COMP_PTR hb_comp_new( void )
|
||||
pComp->fSyntaxCheckOnly = FALSE; /* syntax check only */
|
||||
pComp->fAutoOpen = TRUE;
|
||||
pComp->fError = FALSE;
|
||||
/* EXTERNAL statement can be placed into any place in a function - this flag is
|
||||
used to suppress error report generation */
|
||||
pComp->fExternal = FALSE;
|
||||
|
||||
pComp->iWarnings = 0; /* enable parse warnings */
|
||||
pComp->iGenCOutput= HB_COMPGENC_VERBOSE; /* C code generation should be verbose (use comments) or not */
|
||||
|
||||
Reference in New Issue
Block a user