2009-03-02 21:28 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/include/hbexpra.c
* harbour/source/compiler/hbmain.c
* harbour/source/compiler/cmdcheck.c
* harbour/source/compiler/hbcomp.c
* harbour/source/compiler/genc.c
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyh
* harbour/source/compiler/ppcomp.c
* harbour/source/compiler/hbdbginf.c
* harbour/source/compiler/genhrb.c
* harbour/source/compiler/hbusage.c
! fixed static variables indexes in the generated PCODE when static
variables are declared inside extended codeblocks - in some cases
wrong PCODE was generated
! fixed initialization PCODE for thread static variables declared
inside extended codeblocks
! fixed modulename generated for debugger to always contain function name
part for extended codeblock declared as file wide static variables.
In such case "(_INITSTATICS)" is used as function name.
Without it debugger does not register entering such codeblocks and
GPFs.
+ added support for automatic adding 1-st function with the same name
as compiled .prg file if some code statements are used before 1-st
function/procedure declared explicitly in .prg file. Such mode can
be enabled by -n2 new harbour compiler switch.
This commit is contained in:
@@ -8,6 +8,36 @@
|
||||
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2009-03-02 21:28 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbcomp.h
|
||||
* harbour/include/hbcompdf.h
|
||||
* harbour/include/hbexpra.c
|
||||
* harbour/source/compiler/hbmain.c
|
||||
* harbour/source/compiler/cmdcheck.c
|
||||
* harbour/source/compiler/hbcomp.c
|
||||
* harbour/source/compiler/genc.c
|
||||
* harbour/source/compiler/harbour.yyc
|
||||
* harbour/source/compiler/harbour.y
|
||||
* harbour/source/compiler/harbour.yyh
|
||||
* harbour/source/compiler/ppcomp.c
|
||||
* harbour/source/compiler/hbdbginf.c
|
||||
* harbour/source/compiler/genhrb.c
|
||||
* harbour/source/compiler/hbusage.c
|
||||
! fixed static variables indexes in the generated PCODE when static
|
||||
variables are declared inside extended codeblocks - in some cases
|
||||
wrong PCODE was generated
|
||||
! fixed initialization PCODE for thread static variables declared
|
||||
inside extended codeblocks
|
||||
! fixed modulename generated for debugger to always contain function name
|
||||
part for extended codeblock declared as file wide static variables.
|
||||
In such case "(_INITSTATICS)" is used as function name.
|
||||
Without it debugger does not register entering such codeblocks and
|
||||
GPFs.
|
||||
+ added support for automatic adding 1-st function with the same name
|
||||
as compiled .prg file if some code statements are used before 1-st
|
||||
function/procedure declared explicitly in .prg file. Such mode can
|
||||
be enabled by -n2 new harbour compiler switch.
|
||||
|
||||
2009-03-02 18:48 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
|
||||
* utils/hbmk2/hbmk2.prg
|
||||
+ Compiler value unknown message now shows the actual value.
|
||||
|
||||
@@ -126,7 +126,7 @@ extern int hb_compVariableScope( HB_COMP_DECL, const char * );
|
||||
#define VT_OFFSET_OPTIONAL 90
|
||||
|
||||
/*
|
||||
* flags for bFlags member
|
||||
* flags for funFlags member
|
||||
*/
|
||||
#define FUN_STATEMENTS 0x01 /* Function have at least one executable statement */
|
||||
#define FUN_USES_STATICS 0x02 /* Function uses static variables */
|
||||
@@ -135,6 +135,7 @@ extern int hb_compVariableScope( HB_COMP_DECL, const char * );
|
||||
#define FUN_USES_LOCAL_PARAMS 0x10 /* parameters are declared using () */
|
||||
#define FUN_WITH_RETURN 0x20 /* there was RETURN statement in previous line */
|
||||
#define FUN_EXTBLOCK 0x40 /* it's extended codeblock */
|
||||
#define FUN_FILE_DECL 0x80 /* pseudo function with file wide declarations */
|
||||
|
||||
extern void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */
|
||||
extern PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunName ); /* locates a previously defined function */
|
||||
|
||||
@@ -379,7 +379,7 @@ typedef struct __FUNC
|
||||
{
|
||||
const char * szName; /* name of a defined Clipper function */
|
||||
HB_SYMBOLSCOPE cScope; /* scope of a defined Clipper function */
|
||||
BYTE bFlags; /* some flags we may need */
|
||||
USHORT funFlags; /* some flags we may need */
|
||||
USHORT wParamCount; /* number of declared parameters */
|
||||
USHORT wParamNum; /* current parameter number */
|
||||
PVAR pLocals; /* pointer to local variables list */
|
||||
@@ -674,10 +674,8 @@ typedef struct _HB_COMP
|
||||
char cDataListType; /* current declared variable list type */
|
||||
char cCastType; /* current casting type */
|
||||
|
||||
int iPassByRef; /* check if it's possible to pass variable be reference, can be removed */
|
||||
|
||||
int iErrorCount;
|
||||
int iFunctionCnt;
|
||||
BOOL iStartProc; /* holds if we need to create the starting procedure */
|
||||
int iMaxTransCycles; /* maximum translate cycles in PP (-r=<n>) */
|
||||
int iHidden; /* hide strings */
|
||||
int iWarnings; /* enable parse warnings */
|
||||
@@ -693,7 +691,6 @@ typedef struct _HB_COMP
|
||||
BOOL fExit; /* force breaking compilation process */
|
||||
BOOL fPPO; /* flag indicating, is ppo output needed */
|
||||
BOOL fPPT; /* flag indicating, is ppt output needed */
|
||||
BOOL fStartProc; /* holds if we need to create the starting procedure */
|
||||
BOOL fLineNumbers; /* holds if we need pcodes with line numbers */
|
||||
BOOL fAnyWarning; /* holds if there was any warning during the compilation process */
|
||||
BOOL fAutoMemvarAssume; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC_PTR pEval )
|
||||
{
|
||||
ULONG ulLen = 0;
|
||||
|
||||
|
||||
if( pEval && ((pExpr->ExprType == HB_ET_LIST) || (pExpr->ExprType == HB_ET_ARGLIST)) )
|
||||
{
|
||||
pExpr = pExpr->value.asList.pExprList;
|
||||
@@ -79,8 +79,8 @@ ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2
|
||||
ULONG ulLen = 0;
|
||||
|
||||
if( !pEval )
|
||||
return ulLen;
|
||||
|
||||
return ulLen;
|
||||
|
||||
if( (pExpr1->ExprType == HB_ET_LIST || pExpr1->ExprType == HB_ET_ARGLIST)
|
||||
&&
|
||||
(pExpr2->ExprType == HB_ET_LIST || pExpr2->ExprType == HB_ET_ARGLIST) )
|
||||
|
||||
@@ -492,26 +492,23 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch )
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
/*
|
||||
-n1 no start up procedure and no implicit start up procedure
|
||||
*/
|
||||
if( *( s + 1 ) == '1' )
|
||||
HB_COMP_PARAM->fNoStartUp = s[ 1 ] == '1';
|
||||
switch( s[ 1 ] )
|
||||
{
|
||||
HB_COMP_PARAM->fStartProc = FALSE;
|
||||
HB_COMP_PARAM->fNoStartUp = TRUE;
|
||||
case '-':
|
||||
HB_COMP_PARAM->iStartProc = 0;
|
||||
break;
|
||||
case '\0':
|
||||
case '0':
|
||||
case '1':
|
||||
HB_COMP_PARAM->iStartProc = 1;
|
||||
break;
|
||||
case '2':
|
||||
HB_COMP_PARAM->iStartProc = 2;
|
||||
break;
|
||||
default:
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
|
||||
}
|
||||
/*
|
||||
-n or -n0 no implicit start up procedure
|
||||
*/
|
||||
else if( ( *( s + 1 ) == '0' ) || ( *( s + 1 ) == '\0' ) )
|
||||
HB_COMP_PARAM->fStartProc = FALSE;
|
||||
/*
|
||||
-n- creates implicit start up procedure
|
||||
*/
|
||||
else if( *( s + 1 ) == '-' )
|
||||
HB_COMP_PARAM->fStartProc = TRUE;
|
||||
else
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
|
||||
@@ -96,7 +96,14 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the
|
||||
hb_xfree( szHrb );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->iFunctionCnt )
|
||||
pFunc = HB_COMP_PARAM->functions.pFirst;
|
||||
while( pFunc &&
|
||||
( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 ||
|
||||
pFunc == HB_COMP_PARAM->pInitFunc ||
|
||||
pFunc == HB_COMP_PARAM->pLineFunc ) )
|
||||
pFunc = pFunc->pNext;
|
||||
|
||||
if( pFunc )
|
||||
{
|
||||
fprintf( yyc, "#include \"hbvmpub.h\"\n" );
|
||||
if( HB_COMP_PARAM->iGenCOutput != HB_COMPGENC_COMPACT )
|
||||
@@ -110,8 +117,8 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the
|
||||
|
||||
/* write functions prototypes for PRG defined functions */
|
||||
pFunc = HB_COMP_PARAM->functions.pFirst;
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
pFunc = pFunc->pNext; /* No implicit starting procedure */
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
pFunc = pFunc->pNext;
|
||||
|
||||
while( pFunc )
|
||||
{
|
||||
@@ -258,8 +265,8 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the
|
||||
/* Generate functions data
|
||||
*/
|
||||
pFunc = HB_COMP_PARAM->functions.pFirst;
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
pFunc = pFunc->pNext; /* No implicit starting procedure */
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
pFunc = pFunc->pNext;
|
||||
|
||||
while( pFunc )
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
static PFUNCTION hb_compFirstFunc( HB_COMP_DECL )
|
||||
{
|
||||
PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst;
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
pFunc = pFunc->pNext;
|
||||
return pFunc;
|
||||
}
|
||||
|
||||
@@ -360,50 +360,50 @@ ParamList : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM
|
||||
* stop compilation if invalid syntax will be used.
|
||||
*/
|
||||
Statement : ExecFlow CrlfStmnt
|
||||
| IfInline CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| FunCall CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| AliasExpr CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ObjectMethod CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| IfInline CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| FunCall CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| AliasExpr CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ObjectMethod CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| MacroVar CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) )
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) );
|
||||
else
|
||||
HB_COMP_EXPR_DELETE( HB_COMP_ERROR_SYNTAX( $1 ) );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN;
|
||||
}
|
||||
| MacroExpr CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) )
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) );
|
||||
else
|
||||
HB_COMP_EXPR_DELETE( HB_COMP_ERROR_SYNTAX( $1 ) );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN;
|
||||
}
|
||||
| PareExpList CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprPreOp CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprPostOp CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprOperEq CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprEqual CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprAssign CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| DoProc CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| PareExpList CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprPreOp CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprPostOp CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprOperEq CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprEqual CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| ExprAssign CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| DoProc CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
| BREAK CrlfStmnt { hb_compGenBreak( HB_COMP_PARAM ); hb_compGenPCode2( HB_P_DOSHORT, 0, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_BREAK_CODE; }
|
||||
| BREAK { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf
|
||||
{
|
||||
hb_compGenBreak( HB_COMP_PARAM ); HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) );
|
||||
hb_compGenPCode2( HB_P_DOSHORT, 1, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_BREAK_CODE;
|
||||
}
|
||||
| EXIT CrlfStmnt { hb_compLoopExit( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| LOOP CrlfStmnt { hb_compLoopLoop( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| EXIT CrlfStmnt { hb_compLoopExit( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->funFlags |= FUN_BREAK_CODE; }
|
||||
| LOOP CrlfStmnt { hb_compLoopLoop( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->funFlags |= FUN_BREAK_CODE; }
|
||||
| RETURN CrlfStmnt {
|
||||
if( HB_COMP_PARAM->functions.pLast->wSeqCounter )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL );
|
||||
}
|
||||
hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM );
|
||||
if( (HB_COMP_PARAM->functions.pLast->bFlags & FUN_PROCEDURE) == 0 )
|
||||
if( (HB_COMP_PARAM->functions.pLast->funFlags & FUN_PROCEDURE) == 0 )
|
||||
{ /* return from a function without a return value */
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_NO_RETURN_VALUE, NULL, NULL );
|
||||
}
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_WITH_RETURN | FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_WITH_RETURN | FUN_BREAK_CODE;
|
||||
}
|
||||
| RETURN { hb_compLinePushIfInside( HB_COMP_PARAM ); }
|
||||
Expression Crlf
|
||||
@@ -414,28 +414,28 @@ Statement : ExecFlow CrlfStmnt
|
||||
}
|
||||
/* TODO: check if return value agree with declared value */
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) );
|
||||
if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_EXTBLOCK )
|
||||
if( HB_COMP_PARAM->functions.pLast->funFlags & FUN_EXTBLOCK )
|
||||
/* extended clodeblock, use HB_P_ENDBLOCK to return value and stop execution */
|
||||
hb_compGenPCode1( HB_P_ENDBLOCK, HB_COMP_PARAM );
|
||||
else
|
||||
hb_compGenPCode2( HB_P_RETVALUE, HB_P_ENDPROC, HB_COMP_PARAM );
|
||||
if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_PROCEDURE )
|
||||
if( HB_COMP_PARAM->functions.pLast->funFlags & FUN_PROCEDURE )
|
||||
{ /* procedure returns a value */
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_PROC_RETURN_VALUE, NULL, NULL );
|
||||
}
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_WITH_RETURN | FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_WITH_RETURN | FUN_BREAK_CODE;
|
||||
}
|
||||
| PUBLIC { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->iVarScope = VS_PUBLIC; }
|
||||
ExtVarList
|
||||
{ hb_compRTVariableGen( HB_COMP_PARAM, "__MVPUBLIC" );
|
||||
HB_COMP_PARAM->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ 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->iVarScope = VS_NONE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN;
|
||||
} Crlf
|
||||
| VarDefs
|
||||
| FieldsDef
|
||||
@@ -456,7 +456,7 @@ Statement : ExecFlow CrlfStmnt
|
||||
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; }
|
||||
| PROCREQ CompTimeStr ')' Crlf { HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN; }
|
||||
;
|
||||
|
||||
CompTimeStr : LITERAL {
|
||||
@@ -759,13 +759,14 @@ VariableAt : NumValue ArrayIndex { $$ = $2; }
|
||||
|
||||
VariableAtAlias : VariableAt ALIASOP
|
||||
;
|
||||
|
||||
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; }
|
||||
/* function call
|
||||
*/
|
||||
FunIdentCall: IdentName '(' ArgList ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( $1, HB_COMP_PARAM ), $3, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
FunCall : FunIdentCall
|
||||
| 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; }
|
||||
| MacroVar '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3, HB_COMP_PARAM ); }
|
||||
| MacroExpr '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
/* FunRef : '@' FunCall { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, $2 ); } */
|
||||
@@ -817,7 +818,7 @@ ObjectDataAlias : ObjectData ALIASOP
|
||||
|
||||
/* Object's method
|
||||
*/
|
||||
ObjectMethod : ObjectData '(' {$<bTrue>$=HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL;} ArgList ')' { $$ = hb_compExprNewMethodCall( $1, $4 ); HB_COMP_PARAM->iPassByRef=$<bTrue>3; }
|
||||
ObjectMethod : ObjectData '(' ArgList ')' { $$ = hb_compExprNewMethodCall( $1, $3 ); }
|
||||
;
|
||||
|
||||
ObjectMethodAlias : ObjectMethod ALIASOP
|
||||
@@ -1054,7 +1055,7 @@ CodeBlock : BlockHead
|
||||
HB_CBVAR_PTR pVar;
|
||||
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
hb_compCodeBlockStart( HB_COMP_PARAM, TRUE );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_EXTBLOCK;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_EXTBLOCK;
|
||||
HB_COMP_PARAM->functions.pLast->fVParams =
|
||||
( $1->value.asCodeblock.flags & HB_BLOCK_VPARAMS ) != 0;
|
||||
|
||||
@@ -1113,7 +1114,7 @@ VarDefs : LOCAL { HB_COMP_PARAM->iVarScope = VS_LOCAL; hb_compLinePush( HB_COMP
|
||||
VarList Crlf
|
||||
| THREAD STATIC { HB_COMP_PARAM->iVarScope = VS_TH_STATIC; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
VarList Crlf
|
||||
| PARAMETERS { if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_USES_LOCAL_PARAMS )
|
||||
| PARAMETERS { if( HB_COMP_PARAM->functions.pLast->funFlags & FUN_USES_LOCAL_PARAMS )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_PARAMETERS_NOT_ALLOWED, NULL, NULL );
|
||||
else
|
||||
{
|
||||
@@ -1150,8 +1151,9 @@ ExtVarDef : VarDef
|
||||
}
|
||||
;
|
||||
|
||||
VarDef : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM, $1, $2 ); }
|
||||
VarDef : IdentName AsType
|
||||
{
|
||||
hb_compVariableAdd( HB_COMP_PARAM, $1, $2 );
|
||||
if( HB_COMP_PARAM->iVarScope & VS_STATIC )
|
||||
{
|
||||
hb_compStaticDefStart( HB_COMP_PARAM ); /* switch to statics pcode buffer */
|
||||
@@ -1162,7 +1164,7 @@ VarDef : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM, $1, $2 ); }
|
||||
hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( $1, NULL, HB_COMP_PARAM ), FALSE );
|
||||
}
|
||||
else if( HB_COMP_PARAM->iVarScope == VS_LOCAL &&
|
||||
( HB_COMP_PARAM->functions.pLast->bFlags & FUN_EXTBLOCK ) )
|
||||
( HB_COMP_PARAM->functions.pLast->funFlags & FUN_EXTBLOCK ) )
|
||||
{
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPush( hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ) );
|
||||
}
|
||||
@@ -1170,28 +1172,28 @@ VarDef : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM, $1, $2 ); }
|
||||
| IdentName AsType { $<iNumber>$ = HB_COMP_PARAM->iVarScope;
|
||||
hb_compVariableAdd( HB_COMP_PARAM, $1, $2 );
|
||||
}
|
||||
INASSIGN { ; } Expression
|
||||
INASSIGN Expression
|
||||
{
|
||||
HB_COMP_PARAM->iVarScope = $<iNumber>3;
|
||||
if( HB_COMP_PARAM->iVarScope & VS_STATIC )
|
||||
{
|
||||
hb_compStaticDefStart( HB_COMP_PARAM ); /* switch to statics pcode buffer */
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( $1, HB_COMP_PARAM ), $6, HB_COMP_PARAM ), HB_COMP_PARAM ) );
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( $1, HB_COMP_PARAM ), $5, HB_COMP_PARAM ), HB_COMP_PARAM ) );
|
||||
hb_compStaticDefEnd( HB_COMP_PARAM, $1 );
|
||||
}
|
||||
else if( HB_COMP_PARAM->iVarScope == VS_PUBLIC || HB_COMP_PARAM->iVarScope == VS_PRIVATE )
|
||||
{
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPush( $6, HB_COMP_PARAM ) );
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPush( $5, HB_COMP_PARAM ) );
|
||||
hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( $1, NULL, HB_COMP_PARAM ), TRUE );
|
||||
}
|
||||
else if( HB_COMP_PARAM->iVarScope == VS_LOCAL &&
|
||||
( HB_COMP_PARAM->functions.pLast->bFlags & FUN_EXTBLOCK ) )
|
||||
( HB_COMP_PARAM->functions.pLast->funFlags & FUN_EXTBLOCK ) )
|
||||
{
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPush( $6, HB_COMP_PARAM ) );
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPush( $5, HB_COMP_PARAM ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( $1, HB_COMP_PARAM ), $6, HB_COMP_PARAM ), HB_COMP_PARAM ) );
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( $1, HB_COMP_PARAM ), $5, HB_COMP_PARAM ), HB_COMP_PARAM ) );
|
||||
}
|
||||
HB_COMP_PARAM->iVarScope = $<iNumber>3;
|
||||
}
|
||||
@@ -1395,11 +1397,11 @@ IfBegin : IF ExpList
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
IfElse : ELSE Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
IfElse : ELSE Crlf { HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; }
|
||||
EmptyStats
|
||||
;
|
||||
|
||||
IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
ExpList Crlf
|
||||
{ HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) );
|
||||
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
|
||||
@@ -1409,7 +1411,7 @@ IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE
|
||||
hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
| IfElseIf ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
| IfElseIf ELSEIF { HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
ExpList Crlf
|
||||
{ HB_COMP_EXPR_DELETE( hb_compExprGenPush( $4, HB_COMP_PARAM ) );
|
||||
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
|
||||
@@ -1424,7 +1426,7 @@ EndIf : EndIfID
|
||||
{
|
||||
if( HB_COMP_PARAM->functions.pLast->wIfCounter )
|
||||
--HB_COMP_PARAM->functions.pLast->wIfCounter;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1452,7 +1454,7 @@ DoCase : DoCaseBegin
|
||||
EndCase : EndCaseID
|
||||
{ if( HB_COMP_PARAM->functions.pLast->wCaseCounter )
|
||||
--HB_COMP_PARAM->functions.pLast->wCaseCounter;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1479,7 +1481,7 @@ Cases : CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } ExpList Crlf
|
||||
}
|
||||
EmptyStats
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE;
|
||||
$$ = hb_compElseIfGen( HB_COMP_PARAM, NULL, hb_compGenJump( 0, HB_COMP_PARAM ) );
|
||||
hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM );
|
||||
}
|
||||
@@ -1491,13 +1493,13 @@ Cases : CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } ExpList Crlf
|
||||
}
|
||||
EmptyStats
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE;
|
||||
$$ = hb_compElseIfGen( HB_COMP_PARAM, $1, hb_compGenJump( 0, HB_COMP_PARAM ) );
|
||||
hb_compGenJumpHere( $<iNumber>6, HB_COMP_PARAM );
|
||||
}
|
||||
;
|
||||
|
||||
Otherwise : OTHERWISE {hb_compLinePushIfDebugger( HB_COMP_PARAM ); } Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
Otherwise : OTHERWISE {hb_compLinePushIfDebugger( HB_COMP_PARAM ); } Crlf { HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; }
|
||||
EmptyStats
|
||||
| Otherwise OTHERWISE { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_MAYHEM_IN_CASE, NULL, NULL ); } Crlf
|
||||
EmptyStats
|
||||
@@ -1519,7 +1521,7 @@ DoWhile : WhileBegin ExpList Crlf
|
||||
if( HB_COMP_PARAM->functions.pLast->wWhileCounter )
|
||||
--HB_COMP_PARAM->functions.pLast->wWhileCounter;
|
||||
hb_compLoopEnd( HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_WITH_RETURN;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1533,7 +1535,7 @@ WhileBegin : WHILE
|
||||
;
|
||||
|
||||
EndWhile : EndWhileID
|
||||
{ HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
{ HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; }
|
||||
;
|
||||
|
||||
EndWhileID : ENDDO
|
||||
@@ -1603,7 +1605,7 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */
|
||||
if( hb_compExprAsSymbol( $<asExpr>2 ) )
|
||||
hb_compForEnd( HB_COMP_PARAM, hb_compExprAsSymbol( $<asExpr>2 ) );
|
||||
HB_COMP_EXPR_DELETE( $<asExpr>5 ); /* deletes $5, $2, $4 */
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1677,7 +1679,7 @@ ForEach : FOREACH ForList IN ForArgs /* 1 2 3 4 */
|
||||
|
||||
hb_compGenJumpHere( ( ULONG ) $<lNumber>9, HB_COMP_PARAM );
|
||||
hb_compLoopEnd( HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
hb_compEnumEnd( HB_COMP_PARAM, $2 );
|
||||
HB_COMP_EXPR_DELETE( $2 );
|
||||
HB_COMP_EXPR_DELETE( $4 );
|
||||
@@ -1712,7 +1714,7 @@ EndSwitch : EndSwitchID
|
||||
{
|
||||
if( HB_COMP_PARAM->functions.pLast->wSwitchCounter )
|
||||
--HB_COMP_PARAM->functions.pLast->wSwitchCounter;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1751,7 +1753,7 @@ SwitchCases : CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $2 ); hb_compLi
|
||||
| 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; }
|
||||
SwitchDefault : OTHERWISE { hb_compSwitchAdd( HB_COMP_PARAM, NULL ); hb_compLinePush( HB_COMP_PARAM ); } Crlf { HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; }
|
||||
EmptyStats
|
||||
;
|
||||
|
||||
@@ -1787,7 +1789,7 @@ BeginSeq : BEGINSEQ /* 1 */
|
||||
AlwaysSeq /* 9 */
|
||||
{ /* 10 */
|
||||
long lLoopCount = hb_compLoopCount( HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
if( $<lNumber>9 )
|
||||
{
|
||||
if( $<lNumber>4 != lLoopCount )
|
||||
@@ -1835,21 +1837,21 @@ AlwaysSeq : /* no always */ { $<lNumber>$ = 0; }
|
||||
|
||||
Always : ALWAYS
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
++HB_COMP_PARAM->functions.pLast->wAlwaysCounter;
|
||||
hb_compSequenceAlways( HB_COMP_PARAM );
|
||||
}
|
||||
;
|
||||
|
||||
RecoverSeq : /* no recover */ { $<lNumber>$ = 0; HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
RecoverSeq : /* no recover */ { $<lNumber>$ = 0; HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE; }
|
||||
| RecoverEmpty Crlf EmptyStats
|
||||
| RecoverUsing Crlf EmptyStats
|
||||
;
|
||||
|
||||
RecoverEmpty : RECOVER
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE;
|
||||
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
if( HB_COMP_PARAM->functions.pLast->wSeqCounter )
|
||||
--HB_COMP_PARAM->functions.pLast->wSeqCounter;
|
||||
@@ -1860,7 +1862,7 @@ RecoverEmpty : RECOVER
|
||||
|
||||
RecoverUsing : RECOVERUSING IdentName
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ FUN_BREAK_CODE;
|
||||
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
if( HB_COMP_PARAM->functions.pLast->wSeqCounter )
|
||||
--HB_COMP_PARAM->functions.pLast->wSeqCounter;
|
||||
@@ -1880,21 +1882,15 @@ DoName : MacroVar
|
||||
| MacroExpr
|
||||
;
|
||||
|
||||
DoProc : DO DoName
|
||||
{ $<bTrue>$ = HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL; }
|
||||
DoArgs
|
||||
DoProc : DO DoName DoArgs
|
||||
{
|
||||
$$ = hb_compExprNewFunCall( $2, $4, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->iPassByRef = $<bTrue>3;
|
||||
$$ = hb_compExprNewFunCall( $2, $3, HB_COMP_PARAM );
|
||||
}
|
||||
| DOIDENT
|
||||
{ $<bTrue>$ = HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL; }
|
||||
DoArgs
|
||||
| DOIDENT DoArgs
|
||||
{
|
||||
hb_compAutoOpenAdd( HB_COMP_PARAM, $1 );
|
||||
/* DOIDENT is the only one identifier which can be returned in lower letters */
|
||||
$$ = hb_compExprNewFunCall( hb_compExprNewFunName( hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( $1 ) ), HB_IDENT_FREE ), HB_COMP_PARAM ), $3, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->iPassByRef = $<bTrue>2;
|
||||
$$ = hb_compExprNewFunCall( hb_compExprNewFunName( hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( $1 ) ), HB_IDENT_FREE ), HB_COMP_PARAM ), $2, HB_COMP_PARAM );
|
||||
}
|
||||
;
|
||||
|
||||
@@ -2419,7 +2415,7 @@ static void hb_compVariableDim( const char * szName, HB_EXPR_PTR pInitValue, HB_
|
||||
hb_compVariableAdd( HB_COMP_PARAM, szName, hb_compVarTypeNew( HB_COMP_PARAM, 'A', NULL ) );
|
||||
HB_COMP_EXPR_DELETE( hb_compArrayDimPush( pInitValue, HB_COMP_PARAM ) );
|
||||
if( HB_COMP_PARAM->iVarScope != VS_LOCAL ||
|
||||
!( HB_COMP_PARAM->functions.pLast->bFlags & FUN_EXTBLOCK ) )
|
||||
!( HB_COMP_PARAM->functions.pLast->funFlags & FUN_EXTBLOCK ) )
|
||||
{
|
||||
HB_COMP_EXPR_DELETE( hb_compExprGenPop( hb_compExprNewVar( szName, HB_COMP_PARAM ), HB_COMP_PARAM ) );
|
||||
}
|
||||
@@ -2583,7 +2579,7 @@ static void hb_compSwitchAdd( HB_COMP_DECL, HB_EXPR_PTR pExpr )
|
||||
HB_SWITCHCASE_PTR pCase;
|
||||
PFUNCTION pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
|
||||
pFunc->bFlags &= ~FUN_BREAK_CODE;
|
||||
pFunc->funFlags &= ~FUN_BREAK_CODE;
|
||||
|
||||
if( pExpr )
|
||||
{
|
||||
@@ -2742,24 +2738,7 @@ static HB_EXPR_PTR hb_compCheckPassByRef( HB_COMP_DECL, HB_EXPR_PTR pExpr )
|
||||
return hb_compErrorRefer( HB_COMP_PARAM, pExpr, szDesc );
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if( !( HB_COMP_PARAM->iPassByRef & ( HB_PASSBYREF_FUNCALL | HB_PASSBYREF_ARRAY ) ) )
|
||||
{
|
||||
const char * szDesc;
|
||||
if( pExpr->ExprType == HB_ET_REFERENCE )
|
||||
{
|
||||
HB_EXPR_PTR pDelExpr = pExpr;
|
||||
pExpr = pExpr->value.asReference;
|
||||
HB_COMP_EXPR_CLEAR( pDelExpr );
|
||||
}
|
||||
|
||||
szDesc = hb_compExprAsSymbol( pExpr );
|
||||
if( ! szDesc )
|
||||
szDesc = hb_compExprDescription( pExpr );
|
||||
|
||||
return hb_compErrorRefer( HB_COMP_PARAM, pExpr, szDesc );
|
||||
}
|
||||
#endif
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
@@ -2804,10 +2783,10 @@ BOOL hb_compCheckUnclosedStru( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_UNCLOSED_STRU, "BEGIN SEQUENCE", NULL );
|
||||
pFunc->wSeqCounter = 0;
|
||||
}
|
||||
else if( pFunc->bFlags & FUN_EXTBLOCK )
|
||||
else if( pFunc->funFlags & FUN_EXTBLOCK )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_UNCLOSED_STRU, "{||...}", NULL );
|
||||
pFunc->bFlags &= ~FUN_EXTBLOCK;
|
||||
pFunc->funFlags &= ~FUN_EXTBLOCK;
|
||||
}
|
||||
else
|
||||
fUnclosed = FALSE;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -299,7 +299,7 @@ typedef union YYSTYPE
|
||||
struct
|
||||
{
|
||||
BOOL bMacro;
|
||||
union
|
||||
union
|
||||
{
|
||||
char * string;
|
||||
HB_EXPR_PTR macro;
|
||||
|
||||
@@ -220,7 +220,6 @@ HB_COMP_PTR hb_comp_new( void )
|
||||
|
||||
pComp->fLongOptimize = TRUE;
|
||||
pComp->fPPO = FALSE; /* flag indicating, is ppo output needed */
|
||||
pComp->fStartProc = TRUE; /* holds if we need to create the starting procedure */
|
||||
pComp->fLineNumbers = TRUE; /* holds if we need pcodes with line numbers */
|
||||
pComp->fAnyWarning = FALSE; /* holds if there was any warning during the compilation process */
|
||||
pComp->fAutoMemvarAssume= FALSE; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
|
||||
@@ -234,7 +233,9 @@ HB_COMP_PTR hb_comp_new( void )
|
||||
pComp->fAutoOpen = TRUE;
|
||||
pComp->fError = FALSE;
|
||||
|
||||
pComp->iWarnings = 0; /* enable parse warnings */
|
||||
pComp->iStartProc = 0; /* no implicit starting procedure */
|
||||
pComp->iWarnings = 0; /* enable parse warnings */
|
||||
|
||||
pComp->iGenCOutput= HB_COMPGENC_COMPACT; /* C code generation default mode */
|
||||
pComp->iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */
|
||||
pComp->iLanguage = HB_LANG_C; /* default Harbour generated output language */
|
||||
|
||||
@@ -60,7 +60,7 @@ PHB_DEBUGINFO hb_compGetDebugInfo( HB_COMP_DECL )
|
||||
PFUNCTION pFunc;
|
||||
|
||||
pFunc = HB_COMP_PARAM->functions.pFirst;
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
pFunc = pFunc->pNext;
|
||||
|
||||
while( pFunc )
|
||||
|
||||
@@ -382,12 +382,12 @@ void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarT
|
||||
PVAR pVar;
|
||||
BOOL bFreeVar = TRUE;
|
||||
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 &&
|
||||
if( ( HB_COMP_PARAM->functions.pLast->funFlags & FUN_FILE_DECL ) != 0 &&
|
||||
( 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. */
|
||||
In this case only STATICs, MEMVARs and FIELDs declarations are allowed. */
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL );
|
||||
return;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarT
|
||||
/* check if we are declaring local/static variable after some
|
||||
* executable statements
|
||||
*/
|
||||
if( pFunc->bFlags & FUN_STATEMENTS )
|
||||
if( pFunc->funFlags & FUN_STATEMENTS )
|
||||
{
|
||||
const char * szVarScope;
|
||||
switch( HB_COMP_PARAM->iVarScope )
|
||||
@@ -436,7 +436,7 @@ void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarT
|
||||
HB_COMP_PARAM->iVarScope == VS_PUBLIC ) )
|
||||
hb_compCheckDuplVars( HB_COMP_PARAM, pFunc->pMemvars, szVarName );
|
||||
}
|
||||
else if( pFunc->bFlags & FUN_EXTBLOCK )
|
||||
else if( pFunc->funFlags & FUN_EXTBLOCK )
|
||||
{
|
||||
/* variable defined in an extended codeblock */
|
||||
hb_compCheckDuplVars( HB_COMP_PARAM, pFunc->pFields, szVarName );
|
||||
@@ -573,7 +573,7 @@ void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarT
|
||||
if( HB_COMP_PARAM->iVarScope == VS_PARAMETER )
|
||||
{
|
||||
++pFunc->wParamCount;
|
||||
pFunc->bFlags |= FUN_USES_LOCAL_PARAMS;
|
||||
pFunc->funFlags |= FUN_USES_LOCAL_PARAMS;
|
||||
}
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
@@ -585,6 +585,7 @@ void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarT
|
||||
case VS_TH_STATIC:
|
||||
pVar->uiFlags = VS_THREAD;
|
||||
case VS_STATIC:
|
||||
++HB_COMP_PARAM->iStaticCnt;
|
||||
hb_compVarListAdd( &pFunc->pStatics, pVar );
|
||||
break;
|
||||
|
||||
@@ -694,8 +695,8 @@ PVAR hb_compVariableFind( HB_COMP_DECL, const char * szVarName, int * piPos, int
|
||||
|
||||
/* check current function/codeblock variables */
|
||||
pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
pGlobal = ( HB_COMP_PARAM->fStartProc ||
|
||||
HB_COMP_PARAM->functions.pFirst == pFunc )
|
||||
pGlobal = ( HB_COMP_PARAM->functions.pFirst == pFunc ||
|
||||
!( HB_COMP_PARAM->functions.pFirst->funFlags & FUN_FILE_DECL ) )
|
||||
? NULL : HB_COMP_PARAM->functions.pFirst;
|
||||
|
||||
while( pFunc )
|
||||
@@ -805,7 +806,7 @@ PVAR hb_compVariableFind( HB_COMP_DECL, const char * szVarName, int * piPos, int
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTER_VAR, szVarName, NULL );
|
||||
}
|
||||
}
|
||||
else if( pFunc->bFlags & FUN_EXTBLOCK )
|
||||
else if( pFunc->funFlags & FUN_EXTBLOCK )
|
||||
{ /* extended codeblock */
|
||||
/* check static variables */
|
||||
pVar = hb_compVariableGet( pFunc->pStatics, szVarName, piPos );
|
||||
@@ -860,7 +861,7 @@ const char * hb_compLocalVariableName( PFUNCTION pFunc, USHORT wVar )
|
||||
{
|
||||
PVAR pVar;
|
||||
|
||||
if( pFunc->wParamCount && !( pFunc->bFlags & FUN_USES_LOCAL_PARAMS ) )
|
||||
if( pFunc->wParamCount && !( pFunc->funFlags & FUN_USES_LOCAL_PARAMS ) )
|
||||
wVar -= pFunc->wParamCount;
|
||||
pVar = hb_compVariableGetVar( pFunc->pLocals, wVar );
|
||||
|
||||
@@ -1555,7 +1556,7 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
if( pFunc->pCode[ 0 ] == HB_P_STATICS &&
|
||||
pFunc->pCode[ 5 ] == HB_P_SFRAME )
|
||||
{
|
||||
hb_compSymbolFind( HB_COMP_PARAM, HB_COMP_PARAM->pInitFunc->szName, &w, HB_SYM_FUNCNAME );
|
||||
hb_compSymbolFind( HB_COMP_PARAM, pFunc->szName, &w, HB_SYM_FUNCNAME );
|
||||
pFunc->pCode[ 1 ] = HB_LOBYTE( w );
|
||||
pFunc->pCode[ 2 ] = HB_HIBYTE( w );
|
||||
pFunc->pCode[ 6 ] = HB_LOBYTE( w );
|
||||
@@ -1566,7 +1567,7 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
|
||||
/* NOTE: For some reason this will not work for the static init
|
||||
function, so I'm using an ugly hack instead. [vszakats] */
|
||||
/* if( !( pFunc->bFlags & FUN_USES_STATICS ) ) */
|
||||
/* if( !( pFunc->funFlags & FUN_USES_STATICS ) ) */
|
||||
if( pFunc->pCode[ 8 ] == HB_P_ENDPROC )
|
||||
{
|
||||
pFunc->lPCodePos -= 3;
|
||||
@@ -1608,7 +1609,7 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
iLocals++;
|
||||
}
|
||||
|
||||
if( pFunc->bFlags & FUN_USES_STATICS )
|
||||
if( pFunc->funFlags & FUN_USES_STATICS )
|
||||
{
|
||||
hb_compSymbolFind( HB_COMP_PARAM, HB_COMP_PARAM->pInitFunc->szName, &w, HB_SYM_FUNCNAME );
|
||||
pFunc->pCode[ 4 ] = HB_LOBYTE( w );
|
||||
@@ -1623,7 +1624,7 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
/* Parameters declared with PARAMETERS statement are not
|
||||
* placed in the local variable list.
|
||||
*/
|
||||
if( pFunc->bFlags & FUN_USES_LOCAL_PARAMS )
|
||||
if( pFunc->funFlags & FUN_USES_LOCAL_PARAMS )
|
||||
iLocals -= pFunc->wParamCount;
|
||||
|
||||
if( iLocals > 255 )
|
||||
@@ -1681,13 +1682,22 @@ static void hb_compOptimizeFrames( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_compWarnUnusedVar( HB_COMP_DECL, const char * szFuncName,
|
||||
const char * szVarName, int iDeclLine )
|
||||
{
|
||||
char szFun[ HB_SYMBOL_NAME_LEN + 17 ];
|
||||
hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", szFuncName, iDeclLine );
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W',
|
||||
HB_COMP_WARN_VAR_NOT_USED, szVarName, szFun );
|
||||
}
|
||||
|
||||
static void hb_compFinalizeFunction( HB_COMP_DECL ) /* fixes all last defined function returns jumps offsets */
|
||||
{
|
||||
PFUNCTION pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
|
||||
if( pFunc )
|
||||
{
|
||||
if( ( pFunc->bFlags & FUN_WITH_RETURN ) == 0 )
|
||||
if( ( pFunc->funFlags & FUN_WITH_RETURN ) == 0 )
|
||||
{
|
||||
/* The last statement in a function/procedure was not a RETURN
|
||||
* Generate end-of-procedure pcode
|
||||
@@ -1704,45 +1714,38 @@ static void hb_compFinalizeFunction( HB_COMP_DECL ) /* fixes all last defined fu
|
||||
|
||||
if( HB_COMP_PARAM->iWarnings )
|
||||
{
|
||||
PVAR pVar;
|
||||
|
||||
pVar = pFunc->pLocals;
|
||||
while( pVar )
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) == 0 )
|
||||
{
|
||||
if( pVar->szName && pFunc->szName && pFunc->szName[0] && (! ( pVar->iUsed & VU_USED )) )
|
||||
PVAR pVar;
|
||||
|
||||
pVar = pFunc->pLocals;
|
||||
while( pVar )
|
||||
{
|
||||
char szFun[ 256 ];
|
||||
hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, pVar->iDeclLine );
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_VAR_NOT_USED, pVar->szName, szFun );
|
||||
if( pVar->szName && ( pVar->iUsed & VU_USED ) == 0 )
|
||||
hb_compWarnUnusedVar( HB_COMP_PARAM, pFunc->szName, pVar->szName, pVar->iDeclLine );
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
|
||||
pVar = pFunc->pStatics;
|
||||
while( pVar )
|
||||
{
|
||||
if( pVar->szName && pFunc->szName && pFunc->szName[0] && ! ( pVar->iUsed & VU_USED ) )
|
||||
pVar = pFunc->pStatics;
|
||||
while( pVar )
|
||||
{
|
||||
char szFun[ 256 ];
|
||||
hb_snprintf( szFun, sizeof( szFun ), "%s(%i)", pFunc->szName, pVar->iDeclLine );
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_VAR_NOT_USED, pVar->szName, szFun );
|
||||
if( pVar->szName && ( pVar->iUsed & VU_USED ) == 0 )
|
||||
hb_compWarnUnusedVar( HB_COMP_PARAM, pFunc->szName, pVar->szName, pVar->iDeclLine );
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
|
||||
/* Check if the function returned some value
|
||||
*/
|
||||
if( (pFunc->bFlags & FUN_WITH_RETURN) == 0 &&
|
||||
(pFunc->bFlags & FUN_PROCEDURE) == 0 )
|
||||
if( (pFunc->funFlags & FUN_WITH_RETURN) == 0 &&
|
||||
(pFunc->funFlags & FUN_PROCEDURE) == 0 )
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_FUN_WITH_NO_RETURN,
|
||||
pFunc->szName, NULL );
|
||||
}
|
||||
|
||||
if( !pFunc->bError )
|
||||
{
|
||||
if( pFunc->wParamCount && !( pFunc->bFlags & FUN_USES_LOCAL_PARAMS ) )
|
||||
if( pFunc->wParamCount && ( pFunc->funFlags & FUN_USES_LOCAL_PARAMS ) == 0 )
|
||||
{
|
||||
/* There was a PARAMETERS statement used.
|
||||
* NOTE: This fixes local variables references in a case when
|
||||
@@ -1956,6 +1959,43 @@ static void hb_compAddFunc( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
HB_COMP_PARAM->functions.iCount++;
|
||||
}
|
||||
|
||||
static BOOL hb_compRegisterFunc( HB_COMP_DECL, const char * szFunName,
|
||||
HB_SYMBOLSCOPE cScope, BOOL fError )
|
||||
{
|
||||
PFUNCTION pFunc = hb_compFunctionFind( HB_COMP_PARAM, szFunName );
|
||||
|
||||
if( pFunc )
|
||||
{
|
||||
/* The name of a function/procedure is already defined */
|
||||
if( fError )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_FUNC_DUPL, szFunName, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char * szFunction = hb_compReservedName( szFunName );
|
||||
if( szFunction )
|
||||
{
|
||||
if( fError )
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FUNC_RESERVED, szFunction, szFunName );
|
||||
}
|
||||
else
|
||||
{
|
||||
PCOMSYMBOL pSym = hb_compSymbolFind( HB_COMP_PARAM, szFunName, NULL, HB_SYM_FUNCNAME );
|
||||
if( ! pSym )
|
||||
{
|
||||
/* there is not a symbol on the symbol table for this function name */
|
||||
pSym = hb_compSymbolAdd( HB_COMP_PARAM, szFunName, NULL, HB_SYM_FUNCNAME );
|
||||
}
|
||||
if( pSym )
|
||||
{
|
||||
pSym->cScope |= cScope | HB_FS_LOCAL;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stores a Clipper defined function/procedure
|
||||
* szFunName - name of a function
|
||||
@@ -1964,9 +2004,7 @@ static void hb_compAddFunc( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
*/
|
||||
void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, int iType )
|
||||
{
|
||||
PCOMSYMBOL pSym;
|
||||
PFUNCTION pFunc;
|
||||
const char * szFunction;
|
||||
|
||||
hb_compFinalizeFunction( HB_COMP_PARAM ); /* fix all previous function returns offsets */
|
||||
|
||||
@@ -1983,37 +2021,12 @@ void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cS
|
||||
szNewName[ iLen + 1 ] = '\0';
|
||||
szFunName = hb_compIdentifierNew( HB_COMP_PARAM, szNewName, HB_IDENT_COPY );
|
||||
}
|
||||
pFunc = hb_compFunctionFind( HB_COMP_PARAM, szFunName );
|
||||
if( pFunc )
|
||||
{
|
||||
/* The name of a function/procedure is already defined */
|
||||
if( pFunc != HB_COMP_PARAM->functions.pFirst || HB_COMP_PARAM->fStartProc )
|
||||
/* it is not a starting procedure that was automatically created */
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_FUNC_DUPL, szFunName, NULL );
|
||||
}
|
||||
|
||||
szFunction = hb_compReservedName( szFunName );
|
||||
if( szFunction && !( HB_COMP_PARAM->functions.iCount == 0 && !HB_COMP_PARAM->fStartProc ) )
|
||||
{
|
||||
/* We are ignoring it when it is the name of PRG file and we are
|
||||
* not creating implicit starting procedure
|
||||
*/
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_FUNC_RESERVED, szFunction, szFunName );
|
||||
}
|
||||
|
||||
HB_COMP_PARAM->iFunctionCnt++;
|
||||
|
||||
pSym = hb_compSymbolFind( HB_COMP_PARAM, szFunName, NULL, HB_SYM_FUNCNAME );
|
||||
if( ! pSym )
|
||||
{
|
||||
/* there is not a symbol on the symbol table for this function name */
|
||||
pSym = hb_compSymbolAdd( HB_COMP_PARAM, szFunName, NULL, HB_SYM_FUNCNAME );
|
||||
}
|
||||
if( pSym )
|
||||
pSym->cScope |= cScope | HB_FS_LOCAL;
|
||||
if( ( iType & FUN_FILE_DECL ) == 0 )
|
||||
hb_compRegisterFunc( HB_COMP_PARAM, szFunName, cScope, TRUE );
|
||||
|
||||
pFunc = hb_compFunctionNew( HB_COMP_PARAM, szFunName, cScope );
|
||||
pFunc->bFlags |= iType;
|
||||
pFunc->funFlags |= iType;
|
||||
|
||||
hb_compAddFunc( HB_COMP_PARAM, pFunc );
|
||||
|
||||
@@ -2032,7 +2045,7 @@ void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cS
|
||||
PINLINE hb_compInlineAdd( HB_COMP_DECL, const char * szFunName, int iLine )
|
||||
{
|
||||
PINLINE pInline;
|
||||
PCOMSYMBOL pSym;
|
||||
PCOMSYMBOL pSym;
|
||||
|
||||
if( szFunName )
|
||||
{
|
||||
@@ -2089,10 +2102,9 @@ void hb_compAnnounce( HB_COMP_DECL, const char * szFunName )
|
||||
pSym->cScope = HB_FS_PUBLIC | HB_FS_LOCAL;
|
||||
|
||||
pFunc = hb_compFunctionNew( HB_COMP_PARAM, szFunName, pSym->cScope );
|
||||
pFunc->bFlags |= FUN_PROCEDURE;
|
||||
pFunc->funFlags |= FUN_PROCEDURE;
|
||||
|
||||
hb_compAddFunc( HB_COMP_PARAM, pFunc );
|
||||
HB_COMP_PARAM->iFunctionCnt++;
|
||||
|
||||
/* this function have a very limited functionality
|
||||
*/
|
||||
@@ -2160,7 +2172,8 @@ PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunctionName ) /* re
|
||||
|
||||
while( pFunc )
|
||||
{
|
||||
if( ! strcmp( pFunc->szName, szFunctionName ) )
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) == 0 &&
|
||||
! strcmp( pFunc->szName, szFunctionName ) )
|
||||
break;
|
||||
pFunc = pFunc->pNext;
|
||||
}
|
||||
@@ -2297,12 +2310,12 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c
|
||||
}
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_BREAK_CODE )
|
||||
if( HB_COMP_PARAM->functions.pLast->funFlags & FUN_BREAK_CODE )
|
||||
{
|
||||
/* previous line contained RETURN/BREAK/LOOP/EXIT statement */
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_UNREACHABLE, NULL, NULL );
|
||||
/* clear RETURN/BREAK flag */
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE );
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2311,16 +2324,20 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c
|
||||
*/
|
||||
void hb_compStatmentStart( HB_COMP_DECL )
|
||||
{
|
||||
if( ( HB_COMP_PARAM->functions.pLast->bFlags & FUN_STATEMENTS ) == 0 )
|
||||
if( ( HB_COMP_PARAM->functions.pLast->funFlags & FUN_STATEMENTS ) == 0 )
|
||||
{
|
||||
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 )
|
||||
PFUNCTION pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
|
||||
if( ( pFunc->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL );
|
||||
return;
|
||||
if( HB_COMP_PARAM->iStartProc == 2 &&
|
||||
HB_COMP_PARAM->functions.iCount == 1 && pFunc->szName[0] &&
|
||||
hb_compRegisterFunc( HB_COMP_PARAM, pFunc->szName, pFunc->cScope, FALSE ) )
|
||||
pFunc->funFlags &= ~FUN_FILE_DECL;
|
||||
else
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OUTSIDE, NULL, NULL );
|
||||
}
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_STATEMENTS;
|
||||
pFunc->funFlags |= FUN_STATEMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2341,12 +2358,12 @@ void hb_compLinePushIfDebugger( HB_COMP_DECL )
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
else
|
||||
{
|
||||
if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_BREAK_CODE )
|
||||
if( HB_COMP_PARAM->functions.pLast->funFlags & FUN_BREAK_CODE )
|
||||
{
|
||||
/* previous line contained RETURN/BREAK/LOOP/EXIT statement */
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_UNREACHABLE, NULL, NULL );
|
||||
}
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE ); /* clear RETURN flag */
|
||||
HB_COMP_PARAM->functions.pLast->funFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE ); /* clear RETURN flag */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2374,7 +2391,7 @@ void hb_compGenStaticName( const char *szVarName, HB_COMP_DECL )
|
||||
PFUNCTION pFunc;
|
||||
int iVar;
|
||||
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 )
|
||||
if( ( HB_COMP_PARAM->functions.pLast->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
{
|
||||
/* Variable declaration is outside of function/procedure body.
|
||||
File-wide static variable
|
||||
@@ -2565,7 +2582,7 @@ void hb_compGenPopVar( const char * szVarName, HB_COMP_DECL ) /* generates the p
|
||||
* use 2 bytes for LOCALNEAR
|
||||
*/
|
||||
if( HB_LIM_INT8( iVar ) && !HB_COMP_PARAM->functions.pLast->szName &&
|
||||
!( HB_COMP_PARAM->functions.pLast->bFlags & FUN_EXTBLOCK ) )
|
||||
!( HB_COMP_PARAM->functions.pLast->funFlags & FUN_EXTBLOCK ) )
|
||||
hb_compGenPCode2( HB_P_POPLOCALNEAR, ( BYTE ) iVar, HB_COMP_PARAM );
|
||||
else
|
||||
hb_compGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
|
||||
@@ -2584,7 +2601,7 @@ void hb_compGenPopVar( const char * szVarName, HB_COMP_DECL ) /* generates the p
|
||||
pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
if( ( HB_COMP_PARAM->functions.pLast->cScope & HB_FS_INITEXIT ) == HB_FS_INITEXIT )
|
||||
pFunc = pFunc->pOwner;
|
||||
pFunc->bFlags |= FUN_USES_STATICS;
|
||||
pFunc->funFlags |= FUN_USES_STATICS;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2649,7 +2666,7 @@ void hb_compGenPushVar( const char * szVarName, BOOL bMacroVar, HB_COMP_DECL )
|
||||
* use 2 bytes for LOCALNEAR
|
||||
*/
|
||||
if( HB_LIM_INT8( iVar ) && !HB_COMP_PARAM->functions.pLast->szName &&
|
||||
!( HB_COMP_PARAM->functions.pLast->bFlags & FUN_EXTBLOCK ) )
|
||||
!( HB_COMP_PARAM->functions.pLast->funFlags & FUN_EXTBLOCK ) )
|
||||
hb_compGenPCode2( HB_P_PUSHLOCALNEAR, ( BYTE ) iVar, HB_COMP_PARAM );
|
||||
else
|
||||
hb_compGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
|
||||
@@ -2659,7 +2676,7 @@ void hb_compGenPushVar( const char * szVarName, BOOL bMacroVar, HB_COMP_DECL )
|
||||
case HB_VS_GLOBAL_STATIC:
|
||||
/* Static variable */
|
||||
hb_compGenPCode3( HB_P_PUSHSTATIC, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_USES_STATICS;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_USES_STATICS;
|
||||
break;
|
||||
|
||||
case HB_VS_LOCAL_FIELD:
|
||||
@@ -2713,7 +2730,7 @@ void hb_compGenPushVarRef( const char * szVarName, HB_COMP_DECL ) /* generates t
|
||||
case HB_VS_GLOBAL_STATIC:
|
||||
/* Static variable */
|
||||
hb_compGenPCode3( HB_P_PUSHSTATICREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_USES_STATICS;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_USES_STATICS;
|
||||
break;
|
||||
|
||||
case HB_VS_LOCAL_FIELD:
|
||||
@@ -3239,14 +3256,14 @@ void hb_compSequenceFinish( HB_COMP_DECL, ULONG ulStartPos, ULONG ulEndPos,
|
||||
*/
|
||||
void hb_compStaticDefStart( HB_COMP_DECL )
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_USES_STATICS;
|
||||
HB_COMP_PARAM->functions.pLast->funFlags |= FUN_USES_STATICS;
|
||||
if( ! HB_COMP_PARAM->pInitFunc )
|
||||
{
|
||||
BYTE pBuffer[ 5 ];
|
||||
|
||||
HB_COMP_PARAM->pInitFunc = hb_compFunctionNew( HB_COMP_PARAM, "(_INITSTATICS)", HB_FS_INITEXIT );
|
||||
HB_COMP_PARAM->pInitFunc->pOwner = HB_COMP_PARAM->functions.pLast;
|
||||
HB_COMP_PARAM->pInitFunc->bFlags = FUN_USES_STATICS | FUN_PROCEDURE;
|
||||
HB_COMP_PARAM->pInitFunc->funFlags = FUN_USES_STATICS | FUN_PROCEDURE;
|
||||
HB_COMP_PARAM->pInitFunc->cScope = HB_FS_INITEXIT | HB_FS_LOCAL;
|
||||
HB_COMP_PARAM->functions.pLast = HB_COMP_PARAM->pInitFunc;
|
||||
|
||||
@@ -3283,13 +3300,12 @@ void hb_compStaticDefEnd( HB_COMP_DECL, const char * szVarName )
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast = HB_COMP_PARAM->pInitFunc->pOwner;
|
||||
HB_COMP_PARAM->pInitFunc->pOwner = NULL;
|
||||
++HB_COMP_PARAM->iStaticCnt;
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
BYTE bGlobal = 0;
|
||||
int iVar;
|
||||
|
||||
if( ! HB_COMP_PARAM->fStartProc && HB_COMP_PARAM->functions.iCount <= 1 )
|
||||
if( ( HB_COMP_PARAM->functions.pLast->funFlags & FUN_FILE_DECL ) != 0 )
|
||||
{
|
||||
/* Variable declaration is outside of function/procedure body.
|
||||
* File-wide static variable
|
||||
@@ -3381,7 +3397,7 @@ static void hb_compLineNumberDefStart( HB_COMP_DECL )
|
||||
{
|
||||
HB_COMP_PARAM->pLineFunc = hb_compFunctionNew( HB_COMP_PARAM, "(_INITLINES)", HB_FS_INITEXIT );
|
||||
HB_COMP_PARAM->pLineFunc->pOwner = HB_COMP_PARAM->functions.pLast;
|
||||
HB_COMP_PARAM->pLineFunc->bFlags = 0;
|
||||
HB_COMP_PARAM->pLineFunc->funFlags = 0;
|
||||
HB_COMP_PARAM->pLineFunc->cScope = HB_FS_INITEXIT | HB_FS_LOCAL;
|
||||
HB_COMP_PARAM->functions.pLast = HB_COMP_PARAM->pLineFunc;
|
||||
|
||||
@@ -3439,8 +3455,8 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
pCodeblock = HB_COMP_PARAM->functions.pLast;
|
||||
|
||||
/* Check if the extended codeblock has return statement */
|
||||
if( ( pCodeblock->bFlags & FUN_EXTBLOCK ) &&
|
||||
!( pCodeblock->bFlags & FUN_WITH_RETURN ) )
|
||||
if( ( pCodeblock->funFlags & FUN_EXTBLOCK ) &&
|
||||
!( pCodeblock->funFlags & FUN_WITH_RETURN ) )
|
||||
{
|
||||
if( HB_COMP_PARAM->iWarnings >= 1 )
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_FUN_WITH_NO_RETURN,
|
||||
@@ -3453,7 +3469,7 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
|
||||
if( !pCodeblock->bError )
|
||||
{
|
||||
if( pCodeblock->wParamCount && !( pCodeblock->bFlags & FUN_USES_LOCAL_PARAMS ) )
|
||||
if( pCodeblock->wParamCount && !( pCodeblock->funFlags & FUN_USES_LOCAL_PARAMS ) )
|
||||
/* PARAMETERs were used after LOCALs in extended codeblock
|
||||
* fix generated local indexes
|
||||
*/
|
||||
@@ -3475,7 +3491,9 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
if( pFunc->szName && *pFunc->szName )
|
||||
pFuncName = pFunc->szName;
|
||||
}
|
||||
pFunc->bFlags |= ( pCodeblock->bFlags & FUN_USES_STATICS );
|
||||
if( *pFuncName == 0 )
|
||||
pFuncName = "(_INITSTATICS)";
|
||||
pFunc->funFlags |= ( pCodeblock->funFlags & FUN_USES_STATICS );
|
||||
|
||||
/* generate a proper codeblock frame with a codeblock size and with
|
||||
* a number of expected parameters
|
||||
@@ -3558,19 +3576,40 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
pVar = pCodeblock->pLocals;
|
||||
while( pVar )
|
||||
{
|
||||
if( HB_COMP_PARAM->iWarnings && pFunc->szName && pVar->szName && ! ( pVar->iUsed & VU_USED ) )
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_BLOCKVAR_NOT_USED, pVar->szName, pFunc->szName );
|
||||
if( HB_COMP_PARAM->iWarnings && pVar->szName && ! ( pVar->iUsed & VU_USED ) )
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_BLOCKVAR_NOT_USED, pVar->szName, pFuncName );
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
pVar = pCodeblock->pStatics;
|
||||
while( pVar )
|
||||
{
|
||||
if( HB_COMP_PARAM->iWarnings && pFunc->szName && pVar->szName && ! ( pVar->iUsed & VU_USED ) )
|
||||
hb_compGenWarning( HB_COMP_PARAM, hb_comp_szWarnings, 'W', HB_COMP_WARN_VAR_NOT_USED, pVar->szName, "{||...}" );
|
||||
if( HB_COMP_PARAM->iWarnings && pVar->szName && ! ( pVar->iUsed & VU_USED ) )
|
||||
hb_compWarnUnusedVar( HB_COMP_PARAM, "{||...}", pVar->szName, pVar->iDeclLine );
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
/* move static variables to owner */
|
||||
pVar = pFunc->pStatics;
|
||||
if( pVar )
|
||||
{
|
||||
while( pVar->pNext )
|
||||
pVar = pVar->pNext;
|
||||
pVar->pNext = pCodeblock->pStatics;
|
||||
}
|
||||
else
|
||||
pFunc->pStatics = pCodeblock->pStatics;
|
||||
pVar = pCodeblock->pStatics;
|
||||
pCodeblock->pStatics = NULL;
|
||||
/* change stati variables names to avoid conflicts */
|
||||
while( pVar )
|
||||
{
|
||||
char szName[ HB_SYMBOL_NAME_LEN + 4 ];
|
||||
hb_snprintf( szName, sizeof( szName ), "%s(b)", pVar->szName );
|
||||
pVar->szName = hb_compIdentifierNew( HB_COMP_PARAM, szName, HB_IDENT_COPY );
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
|
||||
hb_compFunctionKill( HB_COMP_PARAM, pCodeblock );
|
||||
}
|
||||
|
||||
@@ -3651,7 +3690,6 @@ static void hb_compInitVars( HB_COMP_DECL )
|
||||
HB_COMP_PARAM->pLineFunc = NULL;
|
||||
HB_COMP_PARAM->fAnyWarning = FALSE;
|
||||
|
||||
HB_COMP_PARAM->iFunctionCnt = 0;
|
||||
HB_COMP_PARAM->iErrorCount = 0;
|
||||
HB_COMP_PARAM->lastLinePos = 0;
|
||||
HB_COMP_PARAM->iStaticCnt = 0;
|
||||
@@ -3927,7 +3965,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
|
||||
if( iFileType == HB_COMP_MEMBUFFER )
|
||||
{
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", 0, FUN_PROCEDURE );
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", 0, FUN_PROCEDURE | FUN_FILE_DECL );
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
}
|
||||
else if( iFileType == HB_COMP_SINGLEFILE )
|
||||
@@ -3944,18 +3982,9 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
}
|
||||
|
||||
/* Generate the starting procedure frame */
|
||||
if( HB_COMP_PARAM->fStartProc )
|
||||
{
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ), HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Don't pass the name of module if the code for starting procedure
|
||||
* will be not generated. The name cannot be placed as first symbol
|
||||
* because this symbol can be used as function call or memvar's name.
|
||||
*/
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", 0, FUN_PROCEDURE );
|
||||
}
|
||||
hb_compFunctionAdd( HB_COMP_PARAM,
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ),
|
||||
HB_FS_PUBLIC, FUN_PROCEDURE | ( HB_COMP_PARAM->iStartProc == 0 ? 0 : FUN_FILE_DECL ) );
|
||||
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
@@ -4072,6 +4101,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
HB_COMP_PARAM->iErrorCount == 0 )
|
||||
{
|
||||
const char * szFirstFunction = NULL;
|
||||
int iFunctionCount = 0;
|
||||
PFUNCTION *pFunPtr;
|
||||
|
||||
/* we create the output file name */
|
||||
@@ -4079,21 +4109,20 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
|
||||
pFunPtr = &HB_COMP_PARAM->functions.pFirst;
|
||||
/* skip first non-startup procedure */
|
||||
if( ! HB_COMP_PARAM->fStartProc )
|
||||
if( (*pFunPtr)->funFlags & FUN_FILE_DECL )
|
||||
{
|
||||
hb_compOptimizeFrames( HB_COMP_PARAM, *pFunPtr );
|
||||
pFunPtr = &(*pFunPtr)->pNext;
|
||||
HB_COMP_PARAM->iFunctionCnt--;
|
||||
}
|
||||
|
||||
while( *pFunPtr && !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
/* remove function frames with no names */
|
||||
if( ! HB_COMP_PARAM->fStartProc && ! (*pFunPtr)->szName[0] )
|
||||
/* remove pseudo function frames used in automatically included
|
||||
files */
|
||||
if( (*pFunPtr)->funFlags & FUN_FILE_DECL )
|
||||
{
|
||||
*pFunPtr = hb_compFunctionKill( HB_COMP_PARAM, *pFunPtr );
|
||||
HB_COMP_PARAM->functions.iCount--;
|
||||
HB_COMP_PARAM->iFunctionCnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4104,6 +4133,9 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
{
|
||||
szFirstFunction = ( *pFunPtr )->szName;
|
||||
}
|
||||
if( *pFunPtr != HB_COMP_PARAM->pInitFunc &&
|
||||
*pFunPtr != HB_COMP_PARAM->pLineFunc )
|
||||
++iFunctionCount;
|
||||
pFunPtr = &(*pFunPtr)->pNext;
|
||||
}
|
||||
}
|
||||
@@ -4119,9 +4151,9 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType )
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
{
|
||||
hb_snprintf( buffer, sizeof( buffer ),
|
||||
"\rLines %i, Functions/Procedures %i\n",
|
||||
hb_pp_lineTot( HB_COMP_PARAM->pLex->pPP ),
|
||||
HB_COMP_PARAM->iFunctionCnt );
|
||||
"\rLines %i, Functions/Procedures %i\n",
|
||||
hb_pp_lineTot( HB_COMP_PARAM->pLex->pPP ),
|
||||
iFunctionCount );
|
||||
hb_compOutStd( HB_COMP_PARAM, buffer );
|
||||
}
|
||||
|
||||
@@ -4250,10 +4282,10 @@ static int hb_compAutoOpen( HB_COMP_DECL, const char * szPrg, BOOL * pbSkipGen,
|
||||
}
|
||||
|
||||
/* Generate the starting procedure frame */
|
||||
if( HB_COMP_PARAM->fStartProc )
|
||||
if( HB_COMP_PARAM->iStartProc == 0 )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( HB_COMP_PARAM->pFileName->szName ) ), HB_IDENT_FREE ), HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
else if( iFileType != HB_COMP_SINGLEFILE )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", 0, FUN_PROCEDURE );
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", 0, FUN_PROCEDURE | FUN_FILE_DECL );
|
||||
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
|
||||
@@ -86,6 +86,7 @@ void hb_compPrintUsage( HB_COMP_DECL, const char * szSelf )
|
||||
"\n %cn[<type>] no implicit starting procedure",
|
||||
"\n <type>: 0=no implicit starting procedure",
|
||||
"\n 1=no starting procedure at all",
|
||||
"\n 2=add starting procedure if necessary",
|
||||
"\n %co<path> object file drive and/or path",
|
||||
"\n %cp[<path>] generate pre-processed output (.ppo) file",
|
||||
"\n %cp+ generate pre-processor trace (.ppt) file",
|
||||
|
||||
@@ -151,7 +151,10 @@ static BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch,
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
HB_COMP_PARAM->fStartProc = iValue != 0;
|
||||
if( iValue >= 0 && iValue <= 2 )
|
||||
HB_COMP_PARAM->iStartProc = iValue;
|
||||
else
|
||||
fError = TRUE;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
|
||||
Reference in New Issue
Block a user