2007-02-18 12:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/common.mak
* harbour/source/compiler/Makefile
* harbour/source/compiler/hbfix.c
+ harbour/source/compiler/hbopt.c
* divided hbfix.c into two separated functions:
- hb_compFixFuncPCode() which only fix generated PCODE updating
local parameters numbers when PARAMETERS is used
- hb_compOptimizePCode() which makes PCODE optimization
It allows to not execute hb_compFixFuncPCode() when PARAMETERS
is not use and execute hb_compOptimizePCode() more then once in
optimization process.
* harbour/hbgtmk.sh
* updated CVS server name
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/source/compiler/complex.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/hbcomp.c
* harbour/source/compiler/hbgenerr.c
* harbour/source/compiler/hbident.c
* changed code for generating in PCODE line numbers and module names
there was serious problem with line numbers and module names in old
code - in many cases line numbers were not generated at all or
generated in wrong places. Also file module name was not updated
when inside of function some code was included with #include
For such situation now modified version of HB_P_MODULE is generated
with module name only but without function name, f.e.:
HB_P_MODULE "test.prg:"
exactly the same form of HB_P_MODULE is used in xHarbour.
Debugger code should be updated to recognize such HB_P_MODULE version
Ryszard any chance that you can look at it?
And what about syncing with xHarbour debugger?
I can add some missing functions to compiler and HVM but I do not
want to update next peace of code myself. Sorry but I do not have
enough time. I'd prefer to finish some other things I'm working.
If Ryszard is busy can someone else try to port xHarbour debugger
to Harbour?
This commit is contained in:
@@ -8,6 +8,49 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2007-02-18 12:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/common.mak
|
||||
* harbour/source/compiler/Makefile
|
||||
* harbour/source/compiler/hbfix.c
|
||||
+ harbour/source/compiler/hbopt.c
|
||||
* divided hbfix.c into two separated functions:
|
||||
- hb_compFixFuncPCode() which only fix generated PCODE updating
|
||||
local parameters numbers when PARAMETERS is used
|
||||
- hb_compOptimizePCode() which makes PCODE optimization
|
||||
It allows to not execute hb_compFixFuncPCode() when PARAMETERS
|
||||
is not use and execute hb_compOptimizePCode() more then once in
|
||||
optimization process.
|
||||
|
||||
* harbour/hbgtmk.sh
|
||||
* updated CVS server name
|
||||
|
||||
* harbour/include/hbcomp.h
|
||||
* harbour/include/hbcompdf.h
|
||||
* harbour/source/compiler/complex.c
|
||||
* harbour/source/compiler/harbour.c
|
||||
* harbour/source/compiler/harbour.y
|
||||
* harbour/source/compiler/harbour.yyc
|
||||
* harbour/source/compiler/hbcomp.c
|
||||
* harbour/source/compiler/hbgenerr.c
|
||||
* harbour/source/compiler/hbident.c
|
||||
* changed code for generating in PCODE line numbers and module names
|
||||
there was serious problem with line numbers and module names in old
|
||||
code - in many cases line numbers were not generated at all or
|
||||
generated in wrong places. Also file module name was not updated
|
||||
when inside of function some code was included with #include
|
||||
For such situation now modified version of HB_P_MODULE is generated
|
||||
with module name only but without function name, f.e.:
|
||||
HB_P_MODULE "test.prg:"
|
||||
exactly the same form of HB_P_MODULE is used in xHarbour.
|
||||
Debugger code should be updated to recognize such HB_P_MODULE version
|
||||
Ryszard any chance that you can look at it?
|
||||
And what about syncing with xHarbour debugger?
|
||||
I can add some missing functions to compiler and HVM but I do not
|
||||
want to update next peace of code myself. Sorry but I do not have
|
||||
enough time. I'd prefer to finish some other things I'm working.
|
||||
If Ryszard is busy can someone else try to port xHarbour debugger
|
||||
to Harbour?
|
||||
|
||||
2007-02-14 00:15 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/contrib/libct/ctwfunc.c
|
||||
* harbour/contrib/libct/ctwin.c
|
||||
|
||||
@@ -752,6 +752,7 @@ HARBOUR_EXE_OBJS = \
|
||||
$(OBJ_DIR)\hbpcode.obj \
|
||||
$(OBJ_DIR)\hbfunchk.obj \
|
||||
$(OBJ_DIR)\hbfix.obj \
|
||||
$(OBJ_DIR)\hbopt.obj \
|
||||
$(OBJ_DIR)\ppcomp.obj \
|
||||
$(OBJ_DIR)\genc.obj \
|
||||
$(OBJ_DIR)\gencc.obj \
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
# ssh is not necessary for anonymous access on SourceForge
|
||||
# export CVS_RSH=ssh
|
||||
export CVSROOT=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/harbour-project"
|
||||
export CVSROOT=":pserver:anonymous@harbour-project.cvs.sourceforge.net:/cvsroot/harbour-project"
|
||||
export PROJECT=harbour
|
||||
|
||||
test_reqrpm()
|
||||
|
||||
@@ -192,10 +192,11 @@ extern ULONG hb_compGenJumpTrue( LONG, HB_COMP_DECL ); /* generates t
|
||||
extern void hb_compGenJumpHere( ULONG, HB_COMP_DECL ); /* returns the pcode pos where to set a jump offset */
|
||||
extern void hb_compGenJumpThere( ULONG, ULONG, HB_COMP_DECL ); /* sets a jump offset */
|
||||
|
||||
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_compGenModuleName( HB_COMP_DECL, char * szFunName ); /* generates the pcode with the currently compiled module and function name */
|
||||
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 */
|
||||
@@ -303,11 +304,13 @@ extern void hb_compNOOPfill( PFUNCTION pFunc, ULONG ulFrom, int iCount, BOOL fPo
|
||||
extern BOOL hb_compIsJump( HB_COMP_DECL, PFUNCTION pFunc, ULONG ulPos );
|
||||
|
||||
/* Misc functions defined in hbfix.c */
|
||||
extern void hb_compFixFuncPCode( HB_COMP_DECL, PFUNCTION );
|
||||
/* Misc functions defined in hbstripl.c */
|
||||
extern void hb_compStripFuncLines( PFUNCTION pFunc );
|
||||
extern void hb_compFixFuncPCode( HB_COMP_DECL, PFUNCTION pFunc );
|
||||
/* Misc functions defined in hbdead.c */
|
||||
extern void hb_compCodeTraceMarkDead( HB_COMP_DECL, PFUNCTION pFunc );
|
||||
/* Misc functions defined in hbopt.c */
|
||||
extern void hb_compOptimizePCode( HB_COMP_DECL, PFUNCTION pFunc );
|
||||
/* Misc functions defined in hbstripl.c */
|
||||
extern void hb_compStripFuncLines( PFUNCTION pFunc );
|
||||
|
||||
/* output related functions defined in gen*.c */
|
||||
extern void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME ); /* generates the C language output */
|
||||
|
||||
@@ -522,6 +522,7 @@ typedef struct _HB_COMP_LEX
|
||||
{
|
||||
PHB_PP_STATE pPP;
|
||||
int iState;
|
||||
BOOL fEol;
|
||||
char * lasttok;
|
||||
}
|
||||
HB_COMP_LEX, * PHB_COMP_LEX;
|
||||
@@ -571,6 +572,10 @@ typedef struct _HB_COMP
|
||||
PHB_FNAME pPpoPath;
|
||||
|
||||
ULONG lastLinePos; /* position of last opcode with line number */
|
||||
int lastLine; /* last generated in PCODE line number */
|
||||
int currLine; /* currently compiled line number */
|
||||
char * lastModule; /* last generated in PCODE module name */
|
||||
char * currModule; /* currently compiled module name */
|
||||
|
||||
char * szAnnounce;
|
||||
char * szStdCh; /* standard definitions file name (-u) */
|
||||
@@ -606,7 +611,6 @@ typedef struct _HB_COMP
|
||||
BOOL fForceMemvars; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
|
||||
BOOL fDebugInfo; /* holds if generate debugger required info */
|
||||
BOOL fNoStartUp; /* C code generation embed HB_FS_FIRST or not */
|
||||
BOOL fDontGenLineNum; /* suppress line number generation */
|
||||
BOOL fCredits; /* print credits */
|
||||
BOOL fBuildInfo; /* print build info */
|
||||
BOOL fLogo; /* print logo */
|
||||
|
||||
@@ -38,6 +38,7 @@ C_SOURCES=\
|
||||
hbfix.c \
|
||||
hbdead.c \
|
||||
hblbl.c \
|
||||
hbopt.c \
|
||||
hbstripl.c \
|
||||
hbusage.c \
|
||||
hbident.c \
|
||||
|
||||
@@ -284,9 +284,15 @@ static char * hb_comp_tokenString( YYSTYPE *yylval_ptr, HB_COMP_DECL, PHB_PP_TOK
|
||||
|
||||
int hb_complex( YYSTYPE *yylval_ptr, HB_COMP_DECL )
|
||||
{
|
||||
PHB_COMP_LEX pLex = ( PHB_COMP_LEX ) HB_COMP_PARAM->pLex;
|
||||
PHB_COMP_LEX pLex = HB_COMP_PARAM->pLex;
|
||||
PHB_PP_TOKEN pToken = hb_pp_tokenGet( pLex->pPP );
|
||||
|
||||
if( pLex->fEol )
|
||||
{
|
||||
pLex->fEol = FALSE;
|
||||
HB_COMP_PARAM->currLine++;
|
||||
}
|
||||
|
||||
if( !pToken || HB_COMP_PARAM->fExit )
|
||||
{
|
||||
pLex->lasttok = NULL;
|
||||
@@ -520,6 +526,7 @@ int hb_complex( YYSTYPE *yylval_ptr, HB_COMP_DECL )
|
||||
return pToken->value[ 0 ];
|
||||
|
||||
case HB_PP_TOKEN_EOL:
|
||||
pLex->fEol = TRUE;
|
||||
case HB_PP_TOKEN_EOC:
|
||||
pLex->iState = LOOKUP;
|
||||
return pToken->value[ 0 ];
|
||||
|
||||
@@ -813,7 +813,7 @@ void hb_compVariableAdd( HB_COMP_DECL, char * szVarName, BYTE cValueType )
|
||||
pVar->cType = cValueType;
|
||||
pVar->iUsed = VU_NOT_USED;
|
||||
pVar->pNext = NULL;
|
||||
pVar->iDeclLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP );
|
||||
pVar->iDeclLine = HB_COMP_PARAM->currLine;
|
||||
|
||||
if ( toupper( cValueType ) == 'S' )
|
||||
{
|
||||
@@ -1939,14 +1939,8 @@ void hb_compFunctionAdd( HB_COMP_DECL, char * szFunName, HB_SYMBOLSCOPE cScope,
|
||||
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP );
|
||||
|
||||
hb_compGenPCode1( HB_P_MODULENAME, HB_COMP_PARAM );
|
||||
hb_compGenPCodeN( ( BYTE * ) szFile, strlen( szFile ), HB_COMP_PARAM );
|
||||
hb_compGenPCode1( ':', HB_COMP_PARAM );
|
||||
hb_compGenPCodeN( ( BYTE * ) szFunName, strlen( szFunName ) + 1, HB_COMP_PARAM );
|
||||
hb_compGenModuleName( HB_COMP_PARAM, szFunName );
|
||||
}
|
||||
HB_COMP_PARAM->fDontGenLineNum = FALSE; /* reset the flag */
|
||||
}
|
||||
|
||||
PINLINE hb_compInlineAdd( HB_COMP_DECL, char * szFunName, int iLine )
|
||||
@@ -2342,7 +2336,7 @@ int hb_compLocalGetPos( HB_COMP_DECL, char * szVarName ) /* returns the order +
|
||||
pVar->cType = ' ';
|
||||
pVar->iUsed = VU_NOT_USED;
|
||||
pVar->pNext = NULL;
|
||||
pVar->iDeclLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP );
|
||||
pVar->iDeclLine = HB_COMP_PARAM->currLine;
|
||||
|
||||
/* Use negative order to signal that we are accessing a local
|
||||
* variable from a codeblock
|
||||
@@ -2641,21 +2635,48 @@ void hb_compGenJumpHere( ULONG ulOffset, HB_COMP_DECL )
|
||||
hb_compGenJumpThere( ulOffset, HB_COMP_PARAM->functions.pLast->lPCodePos, HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
/* generates the pcode with the currently compiled module and function name */
|
||||
void hb_compGenModuleName( HB_COMP_DECL, char * szFunName )
|
||||
{
|
||||
hb_compGenPCode1( HB_P_MODULENAME, HB_COMP_PARAM );
|
||||
hb_compGenPCodeN( ( BYTE * ) HB_COMP_PARAM->currModule,
|
||||
strlen( HB_COMP_PARAM->currModule ), HB_COMP_PARAM );
|
||||
hb_compGenPCode1( ':', HB_COMP_PARAM );
|
||||
if( szFunName && *szFunName )
|
||||
hb_compGenPCodeN( ( BYTE * ) szFunName, strlen( szFunName ) + 1, HB_COMP_PARAM );
|
||||
else /* special version for included files */
|
||||
hb_compGenPCode1( '\0', HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->lastModule = HB_COMP_PARAM->currModule;
|
||||
HB_COMP_PARAM->lastLine = -1;
|
||||
}
|
||||
|
||||
void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently compiled source code line */
|
||||
{
|
||||
if( HB_COMP_PARAM->fLineNumbers && ! HB_COMP_PARAM->fDontGenLineNum )
|
||||
if( HB_COMP_PARAM->fLineNumbers )
|
||||
{
|
||||
int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP );
|
||||
if( HB_COMP_PARAM->functions.pLast->lPCodePos - HB_COMP_PARAM->lastLinePos > 3 ||
|
||||
HB_COMP_PARAM->fDebugInfo )
|
||||
if( HB_COMP_PARAM->fDebugInfo && HB_COMP_PARAM->lastModule != HB_COMP_PARAM->currModule )
|
||||
{
|
||||
HB_COMP_PARAM->lastLinePos = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( iLine ), HB_HIBYTE( iLine ), HB_COMP_PARAM );
|
||||
if( HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos ] == HB_P_LINE &&
|
||||
HB_COMP_PARAM->functions.pLast->lPCodePos - HB_COMP_PARAM->lastLinePos == 3 )
|
||||
HB_COMP_PARAM->functions.pLast->lPCodePos -= 3;
|
||||
hb_compGenModuleName( HB_COMP_PARAM, NULL );
|
||||
}
|
||||
else
|
||||
|
||||
if( HB_COMP_PARAM->currLine != HB_COMP_PARAM->lastLine )
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos + 1 ] = HB_LOBYTE( iLine );
|
||||
HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos + 2 ] = HB_HIBYTE( iLine );
|
||||
if( HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos ] == HB_P_LINE &&
|
||||
HB_COMP_PARAM->functions.pLast->lPCodePos - HB_COMP_PARAM->lastLinePos == 3 )
|
||||
{
|
||||
HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos + 1 ] = HB_LOBYTE( HB_COMP_PARAM->currLine );
|
||||
HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos + 2 ] = HB_HIBYTE( HB_COMP_PARAM->currLine );
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_COMP_PARAM->lastLinePos = HB_COMP_PARAM->functions.pLast->lPCodePos;
|
||||
hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( HB_COMP_PARAM->currLine ),
|
||||
HB_HIBYTE( HB_COMP_PARAM->currLine ), HB_COMP_PARAM );
|
||||
}
|
||||
HB_COMP_PARAM->lastLine = HB_COMP_PARAM->currLine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2663,10 +2684,9 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c
|
||||
{
|
||||
/* 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->fDontGenLineNum = FALSE;
|
||||
/* clear RETURN/BREAK flag */
|
||||
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( /*FUN_WITH_RETURN |*/ FUN_BREAK_CODE );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2687,6 +2707,12 @@ void hb_compStatmentStart( HB_COMP_DECL )
|
||||
}
|
||||
}
|
||||
|
||||
void hb_compLinePushIfInside( HB_COMP_DECL ) /* generates the pcode with the currently compiled source code line */
|
||||
{
|
||||
hb_compStatmentStart( HB_COMP_PARAM );
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
/* Generates the pcode with the currently compiled source code line
|
||||
* if debug code was requested only
|
||||
*/
|
||||
@@ -2707,12 +2733,6 @@ void hb_compLinePushIfDebugger( HB_COMP_DECL )
|
||||
}
|
||||
}
|
||||
|
||||
void hb_compLinePushIfInside( HB_COMP_DECL ) /* generates the pcode with the currently compiled source code line */
|
||||
{
|
||||
hb_compStatmentStart( HB_COMP_PARAM );
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
/*
|
||||
* Function generates pcode for undeclared variable
|
||||
*/
|
||||
@@ -3449,7 +3469,7 @@ void hb_compFinalizeFunction( HB_COMP_DECL ) /* fixes all last defined function
|
||||
|
||||
if( pFunc )
|
||||
{
|
||||
if( (pFunc->bFlags & FUN_WITH_RETURN) == 0 )
|
||||
if( ( pFunc->bFlags & FUN_WITH_RETURN ) == 0 )
|
||||
{
|
||||
/* The last statement in a function/procedure was not a RETURN
|
||||
* Generate end-of-procedure pcode
|
||||
@@ -3459,12 +3479,8 @@ void hb_compFinalizeFunction( HB_COMP_DECL ) /* fixes all last defined function
|
||||
|
||||
if( !pFunc->bError )
|
||||
{
|
||||
if( pFunc->bFlags & FUN_USES_LOCAL_PARAMS )
|
||||
if( pFunc->wParamCount && !( pFunc->bFlags & FUN_USES_LOCAL_PARAMS ) )
|
||||
{
|
||||
int PCount = pFunc->wParamCount;
|
||||
|
||||
/* do not adjust if local parameters are used -remove NOOPs only */
|
||||
pFunc->wParamCount = 0;
|
||||
/* There was a PARAMETERS statement used.
|
||||
* NOTE: This fixes local variables references in a case when
|
||||
* there is PARAMETERS statement after a LOCAL variable declarations.
|
||||
@@ -3476,12 +3492,8 @@ void hb_compFinalizeFunction( HB_COMP_DECL ) /* fixes all last defined function
|
||||
* because the PARAMETERS statement can be used even at the end
|
||||
* of function body when all local variables are already created.
|
||||
*/
|
||||
|
||||
hb_compFixFuncPCode( HB_COMP_PARAM, pFunc );
|
||||
pFunc->wParamCount = PCount;
|
||||
}
|
||||
else
|
||||
hb_compFixFuncPCode( HB_COMP_PARAM, pFunc );
|
||||
|
||||
hb_compOptimizeJumps( HB_COMP_PARAM );
|
||||
}
|
||||
@@ -3807,6 +3819,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
if( ! HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
return;
|
||||
|
||||
hb_compOptimizePCode( HB_COMP_PARAM, HB_COMP_PARAM->functions.pLast );
|
||||
hb_compCodeTraceMarkDead( HB_COMP_PARAM, HB_COMP_PARAM->functions.pLast );
|
||||
|
||||
for( iPass = 0; iPass < 3 && !HB_COMP_PARAM->fExit; ++iPass )
|
||||
@@ -3891,15 +3904,18 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
lOffset = HB_PCODE_MKINT24( &pCode[ ulJumpAddr + 1 ] );
|
||||
if( lOffset == 4 )
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr, 4, FALSE, FALSE );
|
||||
else if( HB_LIM_INT8( lOffset ) )
|
||||
else if( iPass > 0 && HB_LIM_INT16( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPNEAR;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 2, 2, FALSE, FALSE );
|
||||
}
|
||||
else if( HB_LIM_INT16( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMP;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 3, 1, FALSE, FALSE );
|
||||
if( HB_LIM_INT8( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPNEAR;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 2, 2, FALSE, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMP;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 3, 1, FALSE, FALSE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3907,15 +3923,18 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
lOffset = HB_PCODE_MKINT24( &pCode[ ulJumpAddr + 1 ] );
|
||||
if( lOffset == 4 )
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr, 4, TRUE, FALSE );
|
||||
else if( HB_LIM_INT8( lOffset ) )
|
||||
else if( iPass > 0 && HB_LIM_INT16( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPFALSENEAR;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 2, 2, FALSE, FALSE );
|
||||
}
|
||||
else if( HB_LIM_INT16( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPFALSE;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 3, 1, FALSE, FALSE );
|
||||
if( HB_LIM_INT8( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPFALSENEAR;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 2, 2, FALSE, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPFALSE;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 3, 1, FALSE, FALSE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3923,15 +3942,18 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
lOffset = HB_PCODE_MKINT24( &pCode[ ulJumpAddr + 1 ] );
|
||||
if( lOffset == 4 )
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr, 4, TRUE, FALSE );
|
||||
else if( HB_LIM_INT8( lOffset ) )
|
||||
else if( iPass > 0 && HB_LIM_INT16( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPTRUENEAR;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 2, 2, FALSE, FALSE );
|
||||
}
|
||||
else if( HB_LIM_INT16( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPTRUE;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 3, 1, FALSE, FALSE );
|
||||
if( HB_LIM_INT8( lOffset ) )
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPTRUENEAR;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 2, 2, FALSE, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCode[ ulJumpAddr ] = HB_P_JUMPTRUE;
|
||||
hb_compNOOPfill( HB_COMP_PARAM->functions.pLast, ulJumpAddr + 3, 1, FALSE, FALSE );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3958,6 +3980,8 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
|
||||
if( HB_COMP_PARAM->functions.pLast->iNOOPs == 0 )
|
||||
{
|
||||
if( iPass == 0 )
|
||||
continue;
|
||||
if( fLineStrip )
|
||||
hb_compStripFuncLines( HB_COMP_PARAM->functions.pLast );
|
||||
if( HB_COMP_PARAM->functions.pLast->iNOOPs == 0 )
|
||||
@@ -4100,6 +4124,11 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
hb_xfree( HB_COMP_PARAM->functions.pLast->pNOOPs );
|
||||
HB_COMP_PARAM->functions.pLast->pNOOPs = NULL;
|
||||
HB_COMP_PARAM->functions.pLast->iNOOPs = 0;
|
||||
|
||||
if( iPass == 0 )
|
||||
{
|
||||
hb_compOptimizePCode( HB_COMP_PARAM, HB_COMP_PARAM->functions.pLast );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4251,10 +4280,10 @@ void hb_compStaticDefStart( HB_COMP_DECL )
|
||||
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP );
|
||||
|
||||
hb_compGenPCode1( HB_P_MODULENAME, HB_COMP_PARAM );
|
||||
hb_compGenPCodeN( ( BYTE * ) szFile, strlen( szFile ) + 1, HB_COMP_PARAM );
|
||||
/* uncomment this if you want to always set main module name
|
||||
not the one where first static variable was declared */
|
||||
/* HB_COMP_PARAM->currModule = HB_COMP_PARAM->szFile; */
|
||||
hb_compGenModuleName( HB_COMP_PARAM, "" );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -4381,12 +4410,7 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP );
|
||||
|
||||
hb_compGenPCode1( HB_P_MODULENAME, HB_COMP_PARAM );
|
||||
hb_compGenPCodeN( ( BYTE * ) szFile, strlen( szFile ), HB_COMP_PARAM );
|
||||
hb_compGenPCode1( ':', HB_COMP_PARAM );
|
||||
hb_compGenPCodeN( ( BYTE * ) pFunc->szName, strlen( pFunc->szName ) + 1, HB_COMP_PARAM );
|
||||
hb_compGenModuleName( HB_COMP_PARAM, pFunc->szName );
|
||||
|
||||
/* generate the name of referenced local variables */
|
||||
pVar = pCodeblock->pStatics;
|
||||
@@ -4653,7 +4677,9 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile )
|
||||
{
|
||||
BOOL bSkipGen = FALSE ;
|
||||
|
||||
HB_COMP_PARAM->szFile = szFileName;
|
||||
HB_COMP_PARAM->szFile = HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
if( bSingleFile )
|
||||
{
|
||||
@@ -4679,8 +4705,11 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile )
|
||||
hb_compFunctionAdd( HB_COMP_PARAM, "", HB_FS_PUBLIC, FUN_PROCEDURE );
|
||||
}
|
||||
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
hb_compCheckUnclosedStru( HB_COMP_PARAM );
|
||||
if( !HB_COMP_PARAM->fExit )
|
||||
{
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
hb_compCheckUnclosedStru( HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->pFilePpo )
|
||||
{
|
||||
@@ -5012,6 +5041,10 @@ static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * pbSkipGen, BOOL b
|
||||
/* Minimal Init. */
|
||||
if( hb_pp_inFile( HB_COMP_PARAM->pLex->pPP, szFileName, FALSE, NULL, FALSE ) )
|
||||
{
|
||||
HB_COMP_PARAM->currModule =
|
||||
hb_compIdentifierNew( HB_COMP_PARAM, szFileName, HB_IDENT_COPY );
|
||||
HB_COMP_PARAM->currLine = 1;
|
||||
|
||||
if( ! HB_COMP_PARAM->fQuiet )
|
||||
{
|
||||
if( HB_COMP_PARAM->fPPO )
|
||||
@@ -5033,16 +5066,16 @@ static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * pbSkipGen, BOOL b
|
||||
|
||||
hb_compparse( HB_COMP_PARAM );
|
||||
|
||||
if( HB_COMP_PARAM->pFilePpo )
|
||||
{
|
||||
hb_xfree( HB_COMP_PARAM->pFilePpo );
|
||||
HB_COMP_PARAM->pFilePpo = NULL;
|
||||
}
|
||||
|
||||
HB_COMP_PARAM->iExitLevel = ( i > HB_COMP_PARAM->iExitLevel ? i : HB_COMP_PARAM->iExitLevel );
|
||||
HB_COMP_PARAM->fAnyWarning = ( b ? b : HB_COMP_PARAM->fAnyWarning );
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->pFilePpo )
|
||||
{
|
||||
hb_xfree( HB_COMP_PARAM->pFilePpo );
|
||||
HB_COMP_PARAM->pFilePpo = NULL;
|
||||
}
|
||||
|
||||
if( HB_COMP_PARAM->fAnyWarning )
|
||||
{
|
||||
if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_SETEXIT )
|
||||
|
||||
@@ -219,6 +219,7 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
|
||||
%type <asExpr> LiteralValue LiteralAlias
|
||||
%type <asExpr> CodeBlock CodeBlockAlias
|
||||
%type <asExpr> Logical LogicalAlias
|
||||
%type <asExpr> DateValue
|
||||
%type <asExpr> SelfValue SelfAlias
|
||||
%type <asExpr> Array ArrayAlias
|
||||
%type <asExpr> ArrayAt ArrayAtAlias
|
||||
@@ -243,7 +244,6 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
|
||||
%type <asExpr> PostOp
|
||||
%type <asExpr> ForVar ForList ForExpr ForArgs
|
||||
%type <asCodeblock> CBSTART
|
||||
%type <asExpr> DateValue
|
||||
%type <asMessage> SendId
|
||||
|
||||
/*
|
||||
@@ -262,7 +262,7 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
|
||||
|
||||
%%
|
||||
|
||||
Main : { hb_compLinePush( HB_COMP_PARAM ); } Source { }
|
||||
Main : Source
|
||||
| /* empty file */
|
||||
;
|
||||
|
||||
@@ -281,16 +281,22 @@ Source : Crlf
|
||||
;
|
||||
|
||||
Line : LINE NUM_LONG LITERAL Crlf
|
||||
{ if( $3.dealloc ) { hb_xfree( $3.string ); $3.dealloc = FALSE; } }
|
||||
{ HB_COMP_PARAM->currModule = hb_compIdentifierNew( HB_COMP_PARAM, $3.string, $3.dealloc ? HB_IDENT_FREE : HB_IDENT_STATIC );
|
||||
HB_COMP_PARAM->currLine = $2.lNumber;
|
||||
HB_COMP_PARAM->pLex->fEol = FALSE;
|
||||
if( $3.dealloc ) { hb_xfree( $3.string ); $3.dealloc = FALSE; } }
|
||||
| LINE NUM_LONG LITERAL '@' LITERAL Crlf /* Xbase++ style */
|
||||
{ if( $3.dealloc ) { hb_xfree( $3.string ); $3.dealloc = FALSE; }
|
||||
{ HB_COMP_PARAM->currModule = hb_compIdentifierNew( HB_COMP_PARAM, $5.string, $5.dealloc ? HB_IDENT_FREE : HB_IDENT_STATIC );
|
||||
HB_COMP_PARAM->currLine = $2.lNumber;
|
||||
HB_COMP_PARAM->pLex->fEol = FALSE;
|
||||
if( $3.dealloc ) { hb_xfree( $3.string ); $3.dealloc = FALSE; }
|
||||
if( $5.dealloc ) { hb_xfree( $5.string ); $5.dealloc = FALSE; } }
|
||||
;
|
||||
|
||||
Function : FunScope FUNCTION IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, 0 ); } Crlf {}
|
||||
| FunScope PROCEDURE IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); } Crlf {}
|
||||
| FunScope FUNCTION IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, 0 ); HB_COMP_PARAM->iVarScope = VS_PARAMETER; } '(' Params ')' Crlf {}
|
||||
| FunScope PROCEDURE IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); HB_COMP_PARAM->iVarScope = VS_PARAMETER;} '(' Params ')' Crlf {}
|
||||
Function : FunScope FUNCTION IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, 0 ); } Crlf
|
||||
| FunScope PROCEDURE IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); } Crlf
|
||||
| FunScope FUNCTION IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, 0 ); HB_COMP_PARAM->iVarScope = VS_PARAMETER; } '(' Params ')' Crlf
|
||||
| FunScope PROCEDURE IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); HB_COMP_PARAM->iVarScope = VS_PARAMETER;} '(' Params ')' Crlf
|
||||
;
|
||||
|
||||
FunScope : { $$ = HB_FS_PUBLIC; }
|
||||
@@ -340,8 +346,8 @@ ParamList : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM
|
||||
* hb_compExprGenStatement(). With this solution we don't have to
|
||||
* stop compilation if invalid syntax will be used.
|
||||
*/
|
||||
Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
| WithObject CrlfStmnt { }
|
||||
Statement : ExecFlow CrlfStmnt
|
||||
| WithObject CrlfStmnt
|
||||
| IfInline CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| FunCall CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
| AliasExpr CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; }
|
||||
@@ -367,14 +373,16 @@ Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
| DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ 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; }
|
||||
| BREAK { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf { hb_compGenBreak( HB_COMP_PARAM ); hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
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; }
|
||||
| BREAK { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf
|
||||
{
|
||||
hb_compGenBreak( HB_COMP_PARAM ); hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
hb_compGenPCode2( HB_P_DOSHORT, 1, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= 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; }
|
||||
| RETURN CrlfStmnt {
|
||||
if( HB_COMP_PARAM->wSeqCounter )
|
||||
if( HB_COMP_PARAM->wSeqCounter )
|
||||
{
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL );
|
||||
}
|
||||
@@ -383,9 +391,7 @@ Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
{ /* 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;
|
||||
HB_COMP_PARAM->fDontGenLineNum = TRUE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_WITH_RETURN | FUN_BREAK_CODE;
|
||||
}
|
||||
| RETURN { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->cVarType = ' '; }
|
||||
Expression Crlf
|
||||
@@ -403,9 +409,7 @@ Statement : ExecFlow { HB_COMP_PARAM->fDontGenLineNum = TRUE; } CrlfStmnt { }
|
||||
{ /* 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;
|
||||
HB_COMP_PARAM->fDontGenLineNum = TRUE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE;
|
||||
HB_COMP_PARAM->functions.pLast->bFlags |= FUN_WITH_RETURN | FUN_BREAK_CODE;
|
||||
}
|
||||
| PUBLIC { hb_compLinePushIfInside( HB_COMP_PARAM ); HB_COMP_PARAM->iVarScope = VS_PUBLIC; }
|
||||
ExtVarList
|
||||
@@ -464,28 +468,27 @@ CompTimeStr : LITERAL {
|
||||
CrlfStmnt : { hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf
|
||||
;
|
||||
|
||||
LineStat : Crlf { $<lNumber>$ = 0; HB_COMP_PARAM->fDontGenLineNum = TRUE; }
|
||||
LineStat : Crlf { $<lNumber>$ = 0; }
|
||||
| Statement { $<lNumber>$ = 1; }
|
||||
| Declaration { $<lNumber>$ = 1; }
|
||||
| Line { $<lNumber>$ = 1; }
|
||||
| ControlError { $<lNumber>$ = 0; hb_compCheckUnclosedStru( HB_COMP_PARAM ); }
|
||||
| error { int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP );
|
||||
if( HB_COMP_PARAM->ilastLineErr && HB_COMP_PARAM->ilastLineErr == iLine )
|
||||
| error { if( HB_COMP_PARAM->ilastLineErr && HB_COMP_PARAM->ilastLineErr == HB_COMP_PARAM->currLine )
|
||||
{
|
||||
yyclearin;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyerrok;
|
||||
HB_COMP_PARAM->ilastLineErr = iLine;
|
||||
HB_COMP_PARAM->ilastLineErr = HB_COMP_PARAM->currLine;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
ControlError : FunScopeId FUNCTION IdentName Crlf {}
|
||||
| FunScopeId FUNCTION IdentName '(' Params ')' Crlf {}
|
||||
| FunScopeId PROCEDURE IdentName Crlf {}
|
||||
| FunScopeId PROCEDURE IdentName '(' Params ')' Crlf {}
|
||||
ControlError : FunScopeId FUNCTION IdentName Crlf
|
||||
| FunScopeId FUNCTION IdentName '(' Params ')' Crlf
|
||||
| FunScopeId PROCEDURE IdentName Crlf
|
||||
| FunScopeId PROCEDURE IdentName '(' Params ')' Crlf
|
||||
;
|
||||
|
||||
FunScopeId :
|
||||
@@ -1289,14 +1292,14 @@ DecData : IdentName { HB_COMP_PARAM->pLastMethod = hb_compMethodAdd( HB_COMP_
|
||||
}
|
||||
;
|
||||
|
||||
DecList : /* Nothing */ {}
|
||||
DecList : /* Nothing */
|
||||
| FormalList
|
||||
| OptList
|
||||
| FormalList ',' OptList
|
||||
;
|
||||
|
||||
DummyArgList : DummyArgument {}
|
||||
| DummyArgList ',' DummyArgument {}
|
||||
DummyArgList : DummyArgument
|
||||
| DummyArgList ',' DummyArgument
|
||||
;
|
||||
|
||||
DummyArgument : EmptyExpression { hb_compExprDelete( $1, HB_COMP_PARAM ); }
|
||||
@@ -1360,7 +1363,7 @@ IfElse : ELSE Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_C
|
||||
EmptyStats
|
||||
;
|
||||
|
||||
IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
Expression Crlf
|
||||
{ hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
|
||||
@@ -1370,7 +1373,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->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
|
||||
Expression Crlf
|
||||
{ hb_compExprDelete( hb_compExprGenPush( $4, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
|
||||
@@ -1421,7 +1424,7 @@ EndCase : ENDCASE
|
||||
DoCaseStart : DOCASE { ++HB_COMP_PARAM->wCaseCounter; hb_compLinePushIfDebugger( HB_COMP_PARAM );} Crlf
|
||||
;
|
||||
|
||||
DoCaseBegin : DoCaseStart { }
|
||||
DoCaseBegin : DoCaseStart
|
||||
| DoCaseStart Statements {
|
||||
if( $<lNumber>2 > 0 )
|
||||
{
|
||||
@@ -1491,6 +1494,7 @@ EndWhile : END { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE;
|
||||
ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */
|
||||
{
|
||||
hb_compLinePushIfInside( HB_COMP_PARAM );
|
||||
$<lNumber>1 = HB_COMP_PARAM->currLine;
|
||||
hb_compDebugStart();
|
||||
++HB_COMP_PARAM->wForCounter; /* 5 */
|
||||
$<asExpr>$ = hb_compExprGenStatement( hb_compExprAssign( $2, $4, HB_COMP_PARAM ), HB_COMP_PARAM );
|
||||
@@ -1512,6 +1516,8 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */
|
||||
{
|
||||
short iStep, iLocal;
|
||||
|
||||
HB_COMP_PARAM->currLine = $<lNumber>1;
|
||||
hb_compLinePush( HB_COMP_PARAM );
|
||||
hb_compLoopHere( HB_COMP_PARAM );
|
||||
|
||||
if( $<asExpr>8 )
|
||||
@@ -1579,7 +1585,7 @@ StepExpr : /* default step expression */ { $<asExpr>$ = NULL; }
|
||||
| STEP Expression { $<asExpr>$ = hb_compExprReduce( $2, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
ForStatements : EmptyStats NEXT { hb_compLinePush( HB_COMP_PARAM );
|
||||
ForStatements : EmptyStats NEXT { hb_compLinePush( HB_COMP_PARAM );
|
||||
if( HB_COMP_PARAM->wForCounter )
|
||||
--HB_COMP_PARAM->wForCounter; }
|
||||
| EmptyStats NEXT IdentName { hb_compLinePush( HB_COMP_PARAM );
|
||||
@@ -1687,7 +1693,7 @@ SwitchStart : DOSWITCH
|
||||
}
|
||||
;
|
||||
|
||||
SwitchBegin : SwitchStart { }
|
||||
SwitchBegin : SwitchStart
|
||||
| SwitchStart Statements {
|
||||
if( $<lNumber>2 > 0 )
|
||||
{
|
||||
@@ -1699,7 +1705,7 @@ SwitchBegin : SwitchStart { }
|
||||
SwitchCases : CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $2 ); hb_compLinePush( HB_COMP_PARAM ); } Crlf
|
||||
EmptyStats
|
||||
|
||||
| SwitchCases CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $3 ); hb_compLinePush( HB_COMP_PARAM ); }Crlf
|
||||
| SwitchCases CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $3 ); hb_compLinePush( HB_COMP_PARAM ); } Crlf
|
||||
EmptyStats
|
||||
|
||||
| SwitchDefault
|
||||
@@ -1856,15 +1862,15 @@ WithObject : WITHOBJECT Expression Crlf
|
||||
}
|
||||
EmptyStatements
|
||||
END
|
||||
{ if( HB_COMP_PARAM->wWithObjectCnt )
|
||||
{ if( HB_COMP_PARAM->wWithObjectCnt )
|
||||
--HB_COMP_PARAM->wWithObjectCnt;
|
||||
hb_compGenPCode1( HB_P_WITHOBJECTEND, HB_COMP_PARAM );
|
||||
}
|
||||
| WITHOBJECT Expression Crlf END { hb_compExprDelete( $2, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
Crlf : '\n' { HB_COMP_PARAM->fError = FALSE; }
|
||||
| ';' { HB_COMP_PARAM->fDontGenLineNum = TRUE; }
|
||||
Crlf : '\n' { HB_COMP_PARAM->fError = FALSE; }
|
||||
| ';'
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -92,7 +92,6 @@ HB_COMP_PTR hb_comp_new( void )
|
||||
pComp->fForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
|
||||
pComp->fDebugInfo = FALSE; /* holds if generate debugger required info */
|
||||
pComp->fNoStartUp = FALSE; /* C code generation embed HB_FS_FIRST or not */
|
||||
pComp->fDontGenLineNum = FALSE; /* suppress line number generation */
|
||||
pComp->fCredits = FALSE; /* print credits */
|
||||
pComp->fBuildInfo = FALSE; /* print build info */
|
||||
pComp->fLogo = TRUE; /* print logo */
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
typedef struct HB_stru_fix_info
|
||||
{
|
||||
HB_COMP_DECL;
|
||||
USHORT iNestedCodeblock;
|
||||
} HB_FIX_INFO, * HB_FIX_INFO_PTR;
|
||||
|
||||
#define HB_FIX_FUNC( func ) HB_PCODE_FUNC( func, HB_FIX_INFO_PTR )
|
||||
@@ -66,607 +65,151 @@ typedef HB_FIX_FUNC( HB_FIX_FUNC_ );
|
||||
typedef HB_FIX_FUNC_ * HB_FIX_FUNC_PTR;
|
||||
|
||||
|
||||
static HB_FIX_FUNC( hb_p_endblock )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( pFunc );
|
||||
HB_SYMBOL_UNUSED( lPCodePos );
|
||||
|
||||
--cargo->iNestedCodeblock;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_pushblockshort )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( pFunc );
|
||||
HB_SYMBOL_UNUSED( lPCodePos );
|
||||
|
||||
++cargo->iNestedCodeblock;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_pushblock )
|
||||
{
|
||||
BYTE * pLocal = &pFunc->pCode[ lPCodePos + 7 ];
|
||||
USHORT wVar;
|
||||
ULONG ulStart = lPCodePos;
|
||||
|
||||
++cargo->iNestedCodeblock;
|
||||
|
||||
wVar = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 5 ] );
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
/* opcode + codeblock size + number of parameters + number of local variables */
|
||||
lPCodePos += 7;
|
||||
if( pFunc->wParamCount == 0 )
|
||||
{
|
||||
lPCodePos += wVar << 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fix local variable's reference */
|
||||
while( wVar-- )
|
||||
{
|
||||
BYTE * pLocal = &( pFunc->pCode[ lPCodePos ] );
|
||||
USHORT wLocal = HB_PCODE_MKUSHORT( pLocal );
|
||||
wVar = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 5 ] );
|
||||
|
||||
wLocal += pFunc->wParamCount;
|
||||
pLocal[ 0 ] = HB_LOBYTE( wLocal );
|
||||
pLocal[ 1 ] = HB_HIBYTE( wLocal );
|
||||
lPCodePos += 2;
|
||||
}
|
||||
/* fix local variable's reference */
|
||||
while( wVar-- )
|
||||
{
|
||||
USHORT wLocal = HB_PCODE_MKUSHORT( pLocal ) + pFunc->wParamCount;
|
||||
pLocal[ 0 ] = HB_LOBYTE( wLocal );
|
||||
pLocal[ 1 ] = HB_HIBYTE( wLocal );
|
||||
pLocal += 2;
|
||||
}
|
||||
return (lPCodePos - ulStart);
|
||||
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
* skip the codeblock body
|
||||
*/
|
||||
return HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] );
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_pushblocklarge )
|
||||
{
|
||||
BYTE * pLocal = &pFunc->pCode[ lPCodePos + 8 ];
|
||||
USHORT wVar;
|
||||
ULONG ulStart = lPCodePos;
|
||||
|
||||
++cargo->iNestedCodeblock;
|
||||
|
||||
wVar = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 6 ] );
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
/* opcode + codeblock size + number of parameters + number of local variables */
|
||||
lPCodePos += 8;
|
||||
if( pFunc->wParamCount == 0 )
|
||||
{
|
||||
lPCodePos += wVar << 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fix local variable's reference */
|
||||
while( wVar-- )
|
||||
{
|
||||
BYTE * pLocal = &( pFunc->pCode[ lPCodePos ] );
|
||||
USHORT wLocal = HB_PCODE_MKUSHORT( pLocal );
|
||||
wVar = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 6 ] );
|
||||
|
||||
wLocal += pFunc->wParamCount;
|
||||
pLocal[ 0 ] = HB_LOBYTE( wLocal );
|
||||
pLocal[ 1 ] = HB_HIBYTE( wLocal );
|
||||
lPCodePos += 2;
|
||||
}
|
||||
/* fix local variable's reference */
|
||||
while( wVar-- )
|
||||
{
|
||||
USHORT wLocal = HB_PCODE_MKUSHORT( pLocal ) + pFunc->wParamCount;
|
||||
pLocal[ 0 ] = HB_LOBYTE( wLocal );
|
||||
pLocal[ 1 ] = HB_HIBYTE( wLocal );
|
||||
pLocal += 2;
|
||||
}
|
||||
return (lPCodePos - ulStart);
|
||||
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
* skip the codeblock body
|
||||
*/
|
||||
return HB_PCODE_MKUINT24( &pFunc->pCode[ lPCodePos + 1 ] );
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_poplocal )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
if( HB_LIM_INT8( iVar ) && HB_COMP_ISSUPPORTED( HB_COMPFLAG_OPTJUMP ) )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_POPLOCALNEAR;
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 2, 1, FALSE, FALSE );
|
||||
}
|
||||
}
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_pushlocal )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
if( HB_LIM_INT8( iVar ) && HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_PUSHLOCALNEAR;
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 2, 1, FALSE, FALSE );
|
||||
}
|
||||
}
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_pushlocalref )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 && pFunc->wParamCount != 0 )
|
||||
{
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
}
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_localaddint )
|
||||
{
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_poplocalnear )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
HB_SYMBOL_UNUSED( pFunc );
|
||||
HB_SYMBOL_UNUSED( lPCodePos );
|
||||
/*
|
||||
* this code should never be executed because compiler should
|
||||
* generate only non size optimized HB_P_POPLOCAL pcodes
|
||||
* for function body
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 && pFunc->wParamCount != 0 )
|
||||
{
|
||||
/*
|
||||
* this code should never be executed because compiler should
|
||||
* generate only non size optimized HB_P_POPLOCAL pcodes
|
||||
* for function body
|
||||
*/
|
||||
SHORT iVar = ( signed char ) pFunc->pCode[ lPCodePos + 1 ];
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pFunc->pCode[ lPCodePos + 1 ] = ( BYTE ) iVar;
|
||||
if( !HB_LIM_INT8( iVar ) )
|
||||
{
|
||||
char sTemp[16];
|
||||
char sTemp2[16];
|
||||
|
||||
snprintf( sTemp, sizeof( sTemp ), "%i", pFunc->wParamCount );
|
||||
snprintf( sTemp2, sizeof( sTemp2 ), "%i", iVar );
|
||||
hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, sTemp2, sTemp );
|
||||
}
|
||||
}
|
||||
hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, "", "" );
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_pushlocalnear )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
HB_SYMBOL_UNUSED( pFunc );
|
||||
HB_SYMBOL_UNUSED( lPCodePos );
|
||||
/*
|
||||
* this code should never be executed because compiler should
|
||||
* generate only non size optimized HB_P_POPLOCAL pcodes
|
||||
* for function body
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 && pFunc->wParamCount != 0 )
|
||||
{
|
||||
/*
|
||||
* this code should never be executed because compiler should
|
||||
* generate only non size optimized HB_P_POPLOCAL pcodes
|
||||
* for function body
|
||||
*/
|
||||
SHORT iVar = ( signed char ) pFunc->pCode[ lPCodePos + 1 ];
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
pFunc->pCode[ lPCodePos + 1 ] = ( BYTE ) iVar;
|
||||
if( !HB_LIM_INT8( iVar ) )
|
||||
{
|
||||
char sTemp[16];
|
||||
char sTemp2[16];
|
||||
|
||||
snprintf( sTemp, sizeof( sTemp ), "%i", pFunc->wParamCount );
|
||||
snprintf( sTemp2, sizeof( sTemp2 ), "%i", iVar );
|
||||
hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, sTemp2, sTemp );
|
||||
}
|
||||
}
|
||||
hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, "", "" );
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_localaddint )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
iVar += pFunc->wParamCount;
|
||||
if( HB_LIM_INT8( iVar ) && HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
{
|
||||
pVar[ 0 ] = HB_P_LOCALNEARADDINT;
|
||||
pVar[ 1 ] = HB_LOBYTE( iVar );
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
pVar[ 0 ] = HB_LOBYTE( iVar );
|
||||
pVar[ 1 ] = HB_HIBYTE( iVar );
|
||||
}
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_localnearaddint )
|
||||
{
|
||||
/* only local variables used outside of a codeblock need fixing
|
||||
HB_SYMBOL_UNUSED( pFunc );
|
||||
HB_SYMBOL_UNUSED( lPCodePos );
|
||||
/*
|
||||
* this code should never be executed because compiler should
|
||||
* generate only non size optimized HB_P_POPLOCAL pcodes
|
||||
* for function body
|
||||
*/
|
||||
if( cargo->iNestedCodeblock == 0 && pFunc->wParamCount )
|
||||
{
|
||||
USHORT uiVar = pFunc->pCode[ lPCodePos + 1 ];
|
||||
hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, "", "" );
|
||||
|
||||
uiVar += pFunc->wParamCount;
|
||||
if( uiVar < 256 )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos + 1 ] = ( BYTE ) uiVar;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* After fixing this variable cannot be accessed using near code */
|
||||
char sTemp[16];
|
||||
char sTemp2[16];
|
||||
|
||||
snprintf( sTemp, sizeof( sTemp ), "%i", pFunc->wParamCount );
|
||||
snprintf( sTemp2, sizeof( sTemp2 ), "%i", uiVar );
|
||||
hb_compGenError( cargo->HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE, sTemp2, sTemp );
|
||||
}
|
||||
}
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_false )
|
||||
{
|
||||
if( cargo->iNestedCodeblock == 0 )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_POP:
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
case HB_P_JUMPFALSE:
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
case HB_P_JUMPTRUE:
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
if( ! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
int iCount = 1;
|
||||
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPNEAR;
|
||||
break;
|
||||
case HB_P_JUMPFALSE:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMP;
|
||||
break;
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPFAR;
|
||||
break;
|
||||
case HB_P_POP:
|
||||
iCount = 2;
|
||||
break;
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
iCount = 3;
|
||||
break;
|
||||
case HB_P_JUMPTRUE:
|
||||
iCount = 4;
|
||||
break;
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
iCount = 5;
|
||||
break;
|
||||
}
|
||||
hb_compNOOPfill( pFunc, lPCodePos, iCount, FALSE, FALSE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_true )
|
||||
{
|
||||
if( cargo->iNestedCodeblock == 0 )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_POP:
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
case HB_P_JUMPTRUE:
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
case HB_P_JUMPFALSE:
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
if( ! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
int iCount = 1;
|
||||
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPNEAR;
|
||||
break;
|
||||
case HB_P_JUMPTRUE:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMP;
|
||||
break;
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPFAR;
|
||||
break;
|
||||
case HB_P_POP:
|
||||
iCount = 2;
|
||||
break;
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
iCount = 3;
|
||||
break;
|
||||
case HB_P_JUMPFALSE:
|
||||
iCount = 4;
|
||||
break;
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
iCount = 5;
|
||||
break;
|
||||
}
|
||||
hb_compNOOPfill( pFunc, lPCodePos, iCount, FALSE, FALSE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_duplicate )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
|
||||
if( cargo->iNestedCodeblock == 0 && HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
if( pFunc->pCode[ lPCodePos + 5 ] == HB_P_POP )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 2 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr ), lLastOffset = 0;
|
||||
ULONG ulNewPos = lPCodePos + 1 + lOffset;
|
||||
BOOL fNot = FALSE, fRepeat = TRUE;
|
||||
|
||||
do
|
||||
{
|
||||
if( pFunc->pCode[ ulNewPos ] == HB_P_DUPLICATE )
|
||||
{
|
||||
if( lOffset > 0 )
|
||||
hb_p_duplicate( pFunc, ulNewPos, cargo );
|
||||
}
|
||||
|
||||
if( pFunc->pCode[ ulNewPos ] == HB_P_NOOP )
|
||||
{
|
||||
ulNewPos++;
|
||||
lOffset++;
|
||||
}
|
||||
else if( pFunc->pCode[ ulNewPos ] == HB_P_NOT )
|
||||
{
|
||||
ulNewPos++;
|
||||
lOffset++;
|
||||
fNot = !fNot;
|
||||
}
|
||||
else if( pFunc->pCode[ ulNewPos ] == HB_P_DUPLICATE &&
|
||||
( pFunc->pCode[ ulNewPos + 1 ] == HB_P_JUMPTRUEFAR ||
|
||||
pFunc->pCode[ ulNewPos + 1 ] == HB_P_JUMPFALSEFAR ) )
|
||||
{
|
||||
LONG lJump;
|
||||
if( pFunc->pCode[ ulNewPos + 1 ] != pFunc->pCode[ lPCodePos + 1 ] )
|
||||
fNot = !fNot;
|
||||
lJump = fNot ? 4 : HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 2 ] );
|
||||
lOffset += lJump + 1;
|
||||
ulNewPos = lPCodePos + 1 + lOffset;
|
||||
fRepeat = lJump > 0;
|
||||
}
|
||||
else
|
||||
fRepeat = FALSE;
|
||||
|
||||
if( !fNot )
|
||||
lLastOffset = lOffset;
|
||||
}
|
||||
while( fRepeat );
|
||||
|
||||
if( ( pFunc->pCode[ ulNewPos ] == HB_P_JUMPTRUEFAR ||
|
||||
pFunc->pCode[ ulNewPos ] == HB_P_JUMPFALSEFAR ) &&
|
||||
!hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) &&
|
||||
!hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 5 ) )
|
||||
{
|
||||
if( pFunc->pCode[ ulNewPos ] != pFunc->pCode[ lPCodePos + 1 ] )
|
||||
fNot = !fNot;
|
||||
if( fNot )
|
||||
lOffset += 4;
|
||||
else
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 5, 1, FALSE, FALSE );
|
||||
}
|
||||
else if( lLastOffset )
|
||||
{
|
||||
HB_PUT_LE_UINT24( pAddr, lLastOffset );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_not )
|
||||
{
|
||||
if( cargo->iNestedCodeblock == 0 )
|
||||
{
|
||||
BYTE opcode;
|
||||
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_NOT:
|
||||
opcode = HB_P_NOOP;
|
||||
break;
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
opcode = HB_P_JUMPFALSENEAR;
|
||||
break;
|
||||
case HB_P_JUMPTRUE:
|
||||
opcode = HB_P_JUMPFALSE;
|
||||
break;
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
opcode = HB_P_JUMPFALSEFAR;
|
||||
break;
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
opcode = HB_P_JUMPTRUENEAR;
|
||||
break;
|
||||
case HB_P_JUMPFALSE:
|
||||
opcode = HB_P_JUMPTRUE;
|
||||
break;
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
opcode = HB_P_JUMPTRUEFAR;
|
||||
break;
|
||||
/* This optimization will be enabled in the future in a little bit differ form */
|
||||
#if 0
|
||||
case HB_P_DUPLICATE:
|
||||
if( ( pFunc->pCode[ lPCodePos + 2 ] == HB_P_JUMPTRUEFAR ||
|
||||
pFunc->pCode[ lPCodePos + 2 ] == HB_P_JUMPFALSEFAR ) &&
|
||||
pFunc->pCode[ lPCodePos + 6 ] == HB_P_POP )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 3 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
|
||||
if( lOffset > 0 )
|
||||
{
|
||||
hb_p_duplicate( pFunc, lPCodePos + 1, cargo );
|
||||
lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
}
|
||||
|
||||
if( ( pFunc->pCode[ lPCodePos + 1 ] == HB_P_NOT ||
|
||||
( pFunc->pCode[ lPCodePos + 1 ] == HB_P_DUPLICATE &&
|
||||
pFunc->pCode[ lPCodePos + lOffset + 2 ] == HB_P_NOT ) ) &&
|
||||
! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
if( pFunc->pCode[ lPCodePos + 2 ] == HB_P_JUMPTRUEFAR )
|
||||
pFunc->pCode[ lPCodePos + 2 ] = HB_P_JUMPFALSEFAR;
|
||||
else
|
||||
pFunc->pCode[ lPCodePos + 2 ] = HB_P_JUMPTRUEFAR;
|
||||
if( pFunc->pCode[ lPCodePos + 1 ] == HB_P_DUPLICATE )
|
||||
{
|
||||
++lOffset;
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
/* no break; */
|
||||
#endif
|
||||
default:
|
||||
opcode = HB_P_LAST_PCODE;
|
||||
break;
|
||||
}
|
||||
|
||||
if( opcode < HB_P_LAST_PCODE &&
|
||||
! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
if( opcode == HB_P_NOOP )
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 1, 1, FALSE, FALSE );
|
||||
else
|
||||
pFunc->pCode[ lPCodePos + 1 ] = opcode;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_jumpfar )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
|
||||
if( cargo->iNestedCodeblock == 0 && HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
ULONG ulNewPos = lPCodePos + lOffset;
|
||||
|
||||
switch( pFunc->pCode[ ulNewPos ] )
|
||||
{
|
||||
case HB_P_JUMPFAR:
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
break;
|
||||
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
ulNewPos += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
if( ulNewPos == lPCodePos + 4 )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_JUMPTRUEFAR;
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset + 4 );
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
ulNewPos += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
if( ulNewPos == lPCodePos + 4 )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_JUMPFALSEFAR;
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset + 4 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_jumpfalsefar )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
|
||||
if( cargo->iNestedCodeblock == 0 && HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
ULONG ulNewPos = lPCodePos + lOffset;
|
||||
|
||||
switch( pFunc->pCode[ ulNewPos ] )
|
||||
{
|
||||
case HB_P_JUMPFAR:
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
static HB_FIX_FUNC( hb_p_jumptruefar )
|
||||
{
|
||||
HB_COMP_DECL = cargo->HB_COMP_PARAM;
|
||||
|
||||
if( cargo->iNestedCodeblock == 0 && HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
ULONG ulNewPos = lPCodePos + lOffset;
|
||||
|
||||
switch( pFunc->pCode[ ulNewPos ] )
|
||||
{
|
||||
case HB_P_JUMPFAR:
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -681,10 +224,10 @@ static HB_FIX_FUNC_PTR s_fixlocals_table[] =
|
||||
NULL, /* HB_P_ARRAYDIM, */
|
||||
NULL, /* HB_P_ARRAYGEN, */
|
||||
NULL, /* HB_P_EQUAL, */
|
||||
hb_p_endblock, /* HB_P_ENDBLOCK, */
|
||||
NULL, /* HB_P_ENDBLOCK, */
|
||||
NULL, /* HB_P_ENDPROC, */
|
||||
NULL, /* HB_P_EXACTLYEQUAL, */
|
||||
hb_p_false, /* HB_P_FALSE, */
|
||||
NULL, /* HB_P_FALSE, */
|
||||
NULL, /* HB_P_FORTEST, */
|
||||
NULL, /* HB_P_FUNCTION, */
|
||||
NULL, /* HB_P_FUNCTIONSHORT, */
|
||||
@@ -696,19 +239,19 @@ static HB_FIX_FUNC_PTR s_fixlocals_table[] =
|
||||
NULL, /* HB_P_DIVIDE, */
|
||||
NULL, /* HB_P_DO, */
|
||||
NULL, /* HB_P_DOSHORT, */
|
||||
hb_p_duplicate, /* HB_P_DUPLICATE, */
|
||||
NULL, /* HB_P_DUPLICATE, */
|
||||
NULL, /* HB_P_DUPLTWO, */
|
||||
NULL, /* HB_P_INC, */
|
||||
NULL, /* HB_P_INSTRING, */
|
||||
NULL, /* HB_P_JUMPNEAR, */
|
||||
NULL, /* HB_P_JUMP, */
|
||||
hb_p_jumpfar, /* HB_P_JUMPFAR, */
|
||||
NULL, /* HB_P_JUMPFAR, */
|
||||
NULL, /* HB_P_JUMPFALSENEAR, */
|
||||
NULL, /* HB_P_JUMPFALSE, */
|
||||
hb_p_jumpfalsefar, /* HB_P_JUMPFALSEFAR, */
|
||||
NULL, /* HB_P_JUMPFALSEFAR, */
|
||||
NULL, /* HB_P_JUMPTRUENEAR, */
|
||||
NULL, /* HB_P_JUMPTRUE, */
|
||||
hb_p_jumptruefar, /* HB_P_JUMPTRUEFAR, */
|
||||
NULL, /* HB_P_JUMPTRUEFAR, */
|
||||
NULL, /* HB_P_LESSEQUAL, */
|
||||
NULL, /* HB_P_LESS, */
|
||||
NULL, /* HB_P_LINE, */
|
||||
@@ -745,7 +288,7 @@ static HB_FIX_FUNC_PTR s_fixlocals_table[] =
|
||||
NULL, /* HB_P_MULT, */
|
||||
NULL, /* HB_P_NEGATE, */
|
||||
NULL, /* HB_P_NOOP, */
|
||||
hb_p_not, /* HB_P_NOT, */
|
||||
NULL, /* HB_P_NOT, */
|
||||
NULL, /* HB_P_NOTEQUAL, */
|
||||
NULL, /* HB_P_OR, */
|
||||
NULL, /* HB_P_PARAMETER, */
|
||||
@@ -767,7 +310,7 @@ static HB_FIX_FUNC_PTR s_fixlocals_table[] =
|
||||
NULL, /* HB_P_PUSHALIASEDFIELDNEAR, */
|
||||
NULL, /* HB_P_PUSHALIASEDVAR, */
|
||||
hb_p_pushblock, /* HB_P_PUSHBLOCK, */
|
||||
hb_p_pushblockshort, /* HB_P_PUSHBLOCKSHORT, */
|
||||
NULL, /* HB_P_PUSHBLOCKSHORT, */
|
||||
NULL, /* HB_P_PUSHFIELD, */
|
||||
NULL, /* HB_P_PUSHBYTE, */
|
||||
NULL, /* HB_P_PUSHINT, */
|
||||
@@ -797,7 +340,7 @@ static HB_FIX_FUNC_PTR s_fixlocals_table[] =
|
||||
NULL, /* HB_P_STATICS, */
|
||||
NULL, /* HB_P_STATICNAME, */
|
||||
NULL, /* HB_P_SWAPALIAS, */
|
||||
hb_p_true, /* HB_P_TRUE, */
|
||||
NULL, /* HB_P_TRUE, */
|
||||
NULL, /* HB_P_ZERO, */
|
||||
NULL, /* HB_P_ONE, */
|
||||
NULL, /* HB_P_MACROFUNC, */
|
||||
@@ -852,7 +395,6 @@ void hb_compFixFuncPCode( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
{
|
||||
HB_FIX_INFO fix_info;
|
||||
|
||||
fix_info.iNestedCodeblock = 0;
|
||||
fix_info.HB_COMP_PARAM = HB_COMP_PARAM;
|
||||
|
||||
assert( HB_P_LAST_PCODE == sizeof( s_fixlocals_table ) / sizeof( HB_FIX_FUNC_PTR ) );
|
||||
|
||||
@@ -143,11 +143,9 @@ void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError,
|
||||
if( !HB_COMP_PARAM->fExit && ( cPrefix == 'F' || !HB_COMP_PARAM->fError ) )
|
||||
{
|
||||
PFUNCTION pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP );
|
||||
int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP );
|
||||
|
||||
if( szFile )
|
||||
fprintf( hb_comp_errFile, "\r%s(%i) ", szFile, iLine );
|
||||
if( HB_COMP_PARAM->currModule )
|
||||
fprintf( hb_comp_errFile, "\r%s(%i) ", HB_COMP_PARAM->currModule, HB_COMP_PARAM->currLine );
|
||||
|
||||
fprintf( hb_comp_errFile, "Error %c%04i ", cPrefix, iError );
|
||||
fprintf( hb_comp_errFile, szErrors[ iError - 1 ], szError1, szError2 );
|
||||
@@ -172,11 +170,8 @@ void hb_compGenWarning( HB_COMP_DECL, char * szWarnings[], char cPrefix, int iWa
|
||||
|
||||
if( !HB_COMP_PARAM->fExit && ( szText[ 0 ] - '0' <= HB_COMP_PARAM->iWarnings ) )
|
||||
{
|
||||
char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP );
|
||||
int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP );
|
||||
|
||||
if( szFile )
|
||||
fprintf( hb_comp_errFile, "\r%s(%i) ", szFile, iLine );
|
||||
if( HB_COMP_PARAM->currModule )
|
||||
fprintf( hb_comp_errFile, "\r%s(%i) ", HB_COMP_PARAM->currModule, HB_COMP_PARAM->currLine );
|
||||
|
||||
fprintf( hb_comp_errFile, "Warning %c%04i ", cPrefix, iWarning );
|
||||
fprintf( hb_comp_errFile, szText + 1, szWarning1, szWarning2 );
|
||||
|
||||
@@ -44,7 +44,7 @@ char * hb_compIdentifierNew( HB_COMP_DECL, char * szName, int iType )
|
||||
if( !szIdent )
|
||||
{
|
||||
/*
|
||||
* In the future we may want direct support for static identifiers
|
||||
* In the future we may add direct support for static identifiers
|
||||
* so it will not be necessary to allocate separate buffer for them
|
||||
*/
|
||||
if( iType == HB_IDENT_COPY || iType == HB_IDENT_STATIC )
|
||||
|
||||
640
harbour/source/compiler/hbopt.c
Normal file
640
harbour/source/compiler/hbopt.c
Normal file
@@ -0,0 +1,640 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Compiler PCODE optimizer
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "hbcomp.h"
|
||||
|
||||
typedef struct HB_stru_opt_info
|
||||
{
|
||||
HB_COMP_DECL;
|
||||
} HB_OPT_INFO, * HB_OPT_INFO_PTR;
|
||||
|
||||
#define HB_OPT_FUNC( func ) HB_PCODE_FUNC( func, HB_OPT_INFO_PTR )
|
||||
typedef HB_OPT_FUNC( HB_OPT_FUNC_ );
|
||||
typedef HB_OPT_FUNC_ * HB_OPT_FUNC_PTR;
|
||||
|
||||
|
||||
static HB_OPT_FUNC( hb_p_poplocal )
|
||||
{
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
if( HB_LIM_INT8( iVar ) )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_POPLOCALNEAR;
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 2, 1, FALSE, FALSE );
|
||||
}
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_pushlocal )
|
||||
{
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
if( HB_LIM_INT8( iVar ) )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_PUSHLOCALNEAR;
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 2, 1, FALSE, FALSE );
|
||||
}
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_localaddint )
|
||||
{
|
||||
BYTE * pVar = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
SHORT iVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
if( HB_LIM_INT8( iVar ) )
|
||||
{
|
||||
pVar[ 0 ] = HB_P_LOCALNEARADDINT;
|
||||
pVar[ 1 ] = HB_LOBYTE( iVar );
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_false )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_POP:
|
||||
case HB_P_NOT:
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
case HB_P_JUMPFALSE:
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
case HB_P_JUMPTRUE:
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
if( ! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
int iCount = 1;
|
||||
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPNEAR;
|
||||
break;
|
||||
case HB_P_JUMPFALSE:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMP;
|
||||
break;
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPFAR;
|
||||
break;
|
||||
case HB_P_NOT:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_TRUE;
|
||||
break;
|
||||
case HB_P_POP:
|
||||
iCount = 2;
|
||||
break;
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
iCount = 3;
|
||||
break;
|
||||
case HB_P_JUMPTRUE:
|
||||
iCount = 4;
|
||||
break;
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
iCount = 5;
|
||||
break;
|
||||
}
|
||||
hb_compNOOPfill( pFunc, lPCodePos, iCount, FALSE, FALSE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_true )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_POP:
|
||||
case HB_P_NOT:
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
case HB_P_JUMPTRUE:
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
case HB_P_JUMPFALSE:
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
if( ! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
int iCount = 1;
|
||||
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPNEAR;
|
||||
break;
|
||||
case HB_P_JUMPTRUE:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMP;
|
||||
break;
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_JUMPFAR;
|
||||
break;
|
||||
case HB_P_NOT:
|
||||
pFunc->pCode[ lPCodePos + 1 ] = HB_P_FALSE;
|
||||
break;
|
||||
case HB_P_POP:
|
||||
iCount = 2;
|
||||
break;
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
iCount = 3;
|
||||
break;
|
||||
case HB_P_JUMPFALSE:
|
||||
iCount = 4;
|
||||
break;
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
iCount = 5;
|
||||
break;
|
||||
}
|
||||
hb_compNOOPfill( pFunc, lPCodePos, iCount, FALSE, FALSE );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_duplicate )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
if( pFunc->pCode[ lPCodePos + 5 ] == HB_P_POP )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 2 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr ), lLastOffset = 0;
|
||||
ULONG ulNewPos = lPCodePos + 1 + lOffset;
|
||||
BOOL fNot = FALSE, fRepeat = TRUE;
|
||||
|
||||
do
|
||||
{
|
||||
if( pFunc->pCode[ ulNewPos ] == HB_P_DUPLICATE )
|
||||
{
|
||||
if( lOffset > 0 )
|
||||
hb_p_duplicate( pFunc, ulNewPos, cargo );
|
||||
}
|
||||
|
||||
if( pFunc->pCode[ ulNewPos ] == HB_P_NOOP )
|
||||
{
|
||||
ulNewPos++;
|
||||
lOffset++;
|
||||
}
|
||||
else if( pFunc->pCode[ ulNewPos ] == HB_P_NOT )
|
||||
{
|
||||
ulNewPos++;
|
||||
lOffset++;
|
||||
fNot = !fNot;
|
||||
}
|
||||
else if( pFunc->pCode[ ulNewPos ] == HB_P_DUPLICATE &&
|
||||
( pFunc->pCode[ ulNewPos + 1 ] == HB_P_JUMPTRUEFAR ||
|
||||
pFunc->pCode[ ulNewPos + 1 ] == HB_P_JUMPFALSEFAR ) )
|
||||
{
|
||||
LONG lJump;
|
||||
if( pFunc->pCode[ ulNewPos + 1 ] != pFunc->pCode[ lPCodePos + 1 ] )
|
||||
fNot = !fNot;
|
||||
lJump = fNot ? 4 : HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 2 ] );
|
||||
lOffset += lJump + 1;
|
||||
ulNewPos = lPCodePos + 1 + lOffset;
|
||||
fRepeat = lJump > 0;
|
||||
}
|
||||
else
|
||||
fRepeat = FALSE;
|
||||
|
||||
if( !fNot )
|
||||
lLastOffset = lOffset;
|
||||
}
|
||||
while( fRepeat );
|
||||
|
||||
if( ( pFunc->pCode[ ulNewPos ] == HB_P_JUMPTRUEFAR ||
|
||||
pFunc->pCode[ ulNewPos ] == HB_P_JUMPFALSEFAR ) &&
|
||||
!hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) &&
|
||||
!hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 5 ) )
|
||||
{
|
||||
if( pFunc->pCode[ ulNewPos ] != pFunc->pCode[ lPCodePos + 1 ] )
|
||||
fNot = !fNot;
|
||||
if( fNot )
|
||||
lOffset += 4;
|
||||
else
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 5, 1, FALSE, FALSE );
|
||||
}
|
||||
else if( lLastOffset )
|
||||
{
|
||||
HB_PUT_LE_UINT24( pAddr, lLastOffset );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_not )
|
||||
{
|
||||
BYTE opcode;
|
||||
|
||||
switch( pFunc->pCode[ lPCodePos + 1 ] )
|
||||
{
|
||||
case HB_P_NOT:
|
||||
opcode = HB_P_NOOP;
|
||||
break;
|
||||
case HB_P_JUMPTRUENEAR:
|
||||
opcode = HB_P_JUMPFALSENEAR;
|
||||
break;
|
||||
case HB_P_JUMPTRUE:
|
||||
opcode = HB_P_JUMPFALSE;
|
||||
break;
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
opcode = HB_P_JUMPFALSEFAR;
|
||||
break;
|
||||
case HB_P_JUMPFALSENEAR:
|
||||
opcode = HB_P_JUMPTRUENEAR;
|
||||
break;
|
||||
case HB_P_JUMPFALSE:
|
||||
opcode = HB_P_JUMPTRUE;
|
||||
break;
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
opcode = HB_P_JUMPTRUEFAR;
|
||||
break;
|
||||
/* This optimization will be enabled in the future in a little bit differ form */
|
||||
#if 0
|
||||
case HB_P_DUPLICATE:
|
||||
if( ( pFunc->pCode[ lPCodePos + 2 ] == HB_P_JUMPTRUEFAR ||
|
||||
pFunc->pCode[ lPCodePos + 2 ] == HB_P_JUMPFALSEFAR ) &&
|
||||
pFunc->pCode[ lPCodePos + 6 ] == HB_P_POP )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 3 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
|
||||
if( lOffset > 0 )
|
||||
{
|
||||
hb_p_duplicate( pFunc, lPCodePos + 1, cargo );
|
||||
lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
}
|
||||
|
||||
if( ( pFunc->pCode[ lPCodePos + 1 ] == HB_P_NOT ||
|
||||
( pFunc->pCode[ lPCodePos + 1 ] == HB_P_DUPLICATE &&
|
||||
pFunc->pCode[ lPCodePos + lOffset + 2 ] == HB_P_NOT ) ) &&
|
||||
! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
if( pFunc->pCode[ lPCodePos + 2 ] == HB_P_JUMPTRUEFAR )
|
||||
pFunc->pCode[ lPCodePos + 2 ] = HB_P_JUMPFALSEFAR;
|
||||
else
|
||||
pFunc->pCode[ lPCodePos + 2 ] = HB_P_JUMPTRUEFAR;
|
||||
if( pFunc->pCode[ lPCodePos + 1 ] == HB_P_DUPLICATE )
|
||||
{
|
||||
++lOffset;
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
/* no break; */
|
||||
#endif
|
||||
default:
|
||||
opcode = HB_P_LAST_PCODE;
|
||||
break;
|
||||
}
|
||||
|
||||
if( opcode < HB_P_LAST_PCODE &&
|
||||
! hb_compIsJump( cargo->HB_COMP_PARAM, pFunc, lPCodePos + 1 ) )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 1, FALSE, FALSE );
|
||||
if( opcode == HB_P_NOOP )
|
||||
hb_compNOOPfill( pFunc, lPCodePos + 1, 1, FALSE, FALSE );
|
||||
else
|
||||
pFunc->pCode[ lPCodePos + 1 ] = opcode;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_jumpfar )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
ULONG ulNewPos = lPCodePos + lOffset;
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
if( lOffset == 4 )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 4, FALSE, FALSE );
|
||||
}
|
||||
else switch( pFunc->pCode[ ulNewPos ] )
|
||||
{
|
||||
case HB_P_JUMPFAR:
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
break;
|
||||
|
||||
case HB_P_JUMPFALSEFAR:
|
||||
ulNewPos += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
if( ulNewPos == lPCodePos + 4 )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_JUMPTRUEFAR;
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset + 4 );
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_JUMPTRUEFAR:
|
||||
ulNewPos += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
if( ulNewPos == lPCodePos + 4 )
|
||||
{
|
||||
pFunc->pCode[ lPCodePos ] = HB_P_JUMPFALSEFAR;
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset + 4 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_jumpfalsefar )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
ULONG ulNewPos = lPCodePos + lOffset;
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
if( lOffset == 8 && pFunc->pCode[ lPCodePos + 4 ] == HB_P_JUMPFAR )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 4, FALSE, FALSE );
|
||||
pFunc->pCode[ lPCodePos + 4 ] = HB_P_JUMPTRUEFAR;
|
||||
}
|
||||
else if( pFunc->pCode[ ulNewPos ] == HB_P_JUMPFAR )
|
||||
{
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
static HB_OPT_FUNC( hb_p_jumptruefar )
|
||||
{
|
||||
BYTE * pAddr = &pFunc->pCode[ lPCodePos + 1 ];
|
||||
LONG lOffset = HB_PCODE_MKINT24( pAddr );
|
||||
ULONG ulNewPos = lPCodePos + lOffset;
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
if( lOffset == 8 && pFunc->pCode[ lPCodePos + 4 ] == HB_P_JUMPFAR )
|
||||
{
|
||||
hb_compNOOPfill( pFunc, lPCodePos, 4, FALSE, FALSE );
|
||||
pFunc->pCode[ lPCodePos + 4 ] = HB_P_JUMPFALSEFAR;
|
||||
}
|
||||
else if( pFunc->pCode[ ulNewPos ] == HB_P_JUMPFAR )
|
||||
{
|
||||
lOffset += HB_PCODE_MKINT24( &pFunc->pCode[ ulNewPos + 1 ] );
|
||||
HB_PUT_LE_UINT24( pAddr, lOffset );
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* NOTE: The order of functions have to match the order of opcodes mnemonics
|
||||
*/
|
||||
static HB_OPT_FUNC_PTR s_opt_table[] =
|
||||
{
|
||||
NULL, /* HB_P_AND, */
|
||||
NULL, /* HB_P_ARRAYPUSH, */
|
||||
NULL, /* HB_P_ARRAYPOP, */
|
||||
NULL, /* HB_P_ARRAYDIM, */
|
||||
NULL, /* HB_P_ARRAYGEN, */
|
||||
NULL, /* HB_P_EQUAL, */
|
||||
NULL, /* HB_P_ENDBLOCK, */
|
||||
NULL, /* HB_P_ENDPROC, */
|
||||
NULL, /* HB_P_EXACTLYEQUAL, */
|
||||
hb_p_false, /* HB_P_FALSE, */
|
||||
NULL, /* HB_P_FORTEST, */
|
||||
NULL, /* HB_P_FUNCTION, */
|
||||
NULL, /* HB_P_FUNCTIONSHORT, */
|
||||
NULL, /* HB_P_FRAME, */
|
||||
NULL, /* HB_P_FUNCPTR, */
|
||||
NULL, /* HB_P_GREATER, */
|
||||
NULL, /* HB_P_GREATEREQUAL, */
|
||||
NULL, /* HB_P_DEC, */
|
||||
NULL, /* HB_P_DIVIDE, */
|
||||
NULL, /* HB_P_DO, */
|
||||
NULL, /* HB_P_DOSHORT, */
|
||||
hb_p_duplicate, /* HB_P_DUPLICATE, */
|
||||
NULL, /* HB_P_DUPLTWO, */
|
||||
NULL, /* HB_P_INC, */
|
||||
NULL, /* HB_P_INSTRING, */
|
||||
NULL, /* HB_P_JUMPNEAR, */
|
||||
NULL, /* HB_P_JUMP, */
|
||||
hb_p_jumpfar, /* HB_P_JUMPFAR, */
|
||||
NULL, /* HB_P_JUMPFALSENEAR, */
|
||||
NULL, /* HB_P_JUMPFALSE, */
|
||||
hb_p_jumpfalsefar, /* HB_P_JUMPFALSEFAR, */
|
||||
NULL, /* HB_P_JUMPTRUENEAR, */
|
||||
NULL, /* HB_P_JUMPTRUE, */
|
||||
hb_p_jumptruefar, /* HB_P_JUMPTRUEFAR, */
|
||||
NULL, /* HB_P_LESSEQUAL, */
|
||||
NULL, /* HB_P_LESS, */
|
||||
NULL, /* HB_P_LINE, */
|
||||
NULL, /* HB_P_LOCALNAME, */
|
||||
NULL, /* HB_P_MACROPOP, */
|
||||
NULL, /* HB_P_MACROPOPALIASED, */
|
||||
NULL, /* HB_P_MACROPUSH, */
|
||||
NULL, /* HB_P_MACROARRAYGEN, */
|
||||
NULL, /* HB_P_MACROPUSHLIST, */
|
||||
NULL, /* HB_P_MACROPUSHINDEX, */
|
||||
NULL, /* HB_P_MACROPUSHPARE, */
|
||||
NULL, /* HB_P_MACROPUSHALIASED, */
|
||||
NULL, /* HB_P_MACROSYMBOL, */
|
||||
NULL, /* HB_P_MACROTEXT, */
|
||||
NULL, /* HB_P_MESSAGE, */
|
||||
NULL, /* HB_P_MINUS, */
|
||||
NULL, /* HB_P_MODULUS, */
|
||||
NULL, /* HB_P_MODULENAME, */
|
||||
/* start: pcodes generated by macro compiler */
|
||||
NULL, /* HB_P_MMESSAGE, */
|
||||
NULL, /* HB_P_MPOPALIASEDFIELD, */
|
||||
NULL, /* HB_P_MPOPALIASEDVAR, */
|
||||
NULL, /* HB_P_MPOPFIELD, */
|
||||
NULL, /* HB_P_MPOPMEMVAR, */
|
||||
NULL, /* HB_P_MPUSHALIASEDFIELD, */
|
||||
NULL, /* HB_P_MPUSHALIASEDVAR, */
|
||||
NULL, /* HB_P_MPUSHBLOCK, */
|
||||
NULL, /* HB_P_MPUSHFIELD, */
|
||||
NULL, /* HB_P_MPUSHMEMVAR, */
|
||||
NULL, /* HB_P_MPUSHMEMVARREF, */
|
||||
NULL, /* HB_P_MPUSHSYM, */
|
||||
NULL, /* HB_P_MPUSHVARIABLE, */
|
||||
/* end: */
|
||||
NULL, /* HB_P_MULT, */
|
||||
NULL, /* HB_P_NEGATE, */
|
||||
NULL, /* HB_P_NOOP, */
|
||||
hb_p_not, /* HB_P_NOT, */
|
||||
NULL, /* HB_P_NOTEQUAL, */
|
||||
NULL, /* HB_P_OR, */
|
||||
NULL, /* HB_P_PARAMETER, */
|
||||
NULL, /* HB_P_PLUS, */
|
||||
NULL, /* HB_P_POP, */
|
||||
NULL, /* HB_P_POPALIAS, */
|
||||
NULL, /* HB_P_POPALIASEDFIELD, */
|
||||
NULL, /* HB_P_POPALIASEDFIELDNEAR, */
|
||||
NULL, /* HB_P_POPALIASEDVAR, */
|
||||
NULL, /* HB_P_POPFIELD, */
|
||||
hb_p_poplocal, /* HB_P_POPLOCAL, */
|
||||
NULL, /* HB_P_POPLOCALNEAR, */
|
||||
NULL, /* HB_P_POPMEMVAR, */
|
||||
NULL, /* HB_P_POPSTATIC, */
|
||||
NULL, /* HB_P_POPVARIABLE, */
|
||||
NULL, /* HB_P_POWER, */
|
||||
NULL, /* HB_P_PUSHALIAS, */
|
||||
NULL, /* HB_P_PUSHALIASEDFIELD, */
|
||||
NULL, /* HB_P_PUSHALIASEDFIELDNEAR, */
|
||||
NULL, /* HB_P_PUSHALIASEDVAR, */
|
||||
NULL, /* HB_P_PUSHBLOCK, */
|
||||
NULL, /* HB_P_PUSHBLOCKSHORT, */
|
||||
NULL, /* HB_P_PUSHFIELD, */
|
||||
NULL, /* HB_P_PUSHBYTE, */
|
||||
NULL, /* HB_P_PUSHINT, */
|
||||
hb_p_pushlocal, /* HB_P_PUSHLOCAL, */
|
||||
NULL, /* HB_P_PUSHLOCALNEAR, */
|
||||
NULL, /* HB_P_PUSHLOCALREF, */
|
||||
NULL, /* HB_P_PUSHLONG, */
|
||||
NULL, /* HB_P_PUSHMEMVAR, */
|
||||
NULL, /* HB_P_PUSHMEMVARREF, */
|
||||
NULL, /* HB_P_PUSHNIL, */
|
||||
NULL, /* HB_P_PUSHDOUBLE, */
|
||||
NULL, /* HB_P_PUSHSELF, */
|
||||
NULL, /* HB_P_PUSHSTATIC, */
|
||||
NULL, /* HB_P_PUSHSTATICREF, */
|
||||
NULL, /* HB_P_PUSHSTR, */
|
||||
NULL, /* HB_P_PUSHSTRSHORT, */
|
||||
NULL, /* HB_P_PUSHSYM, */
|
||||
NULL, /* HB_P_PUSHSYMNEAR, */
|
||||
NULL, /* HB_P_PUSHVARIABLE, */
|
||||
NULL, /* HB_P_RETVALUE, */
|
||||
NULL, /* HB_P_SEND, */
|
||||
NULL, /* HB_P_SENDSHORT, */
|
||||
NULL, /* HB_P_SEQBEGIN, */
|
||||
NULL, /* HB_P_SEQEND, */
|
||||
NULL, /* HB_P_SEQRECOVER, */
|
||||
NULL, /* HB_P_SFRAME, */
|
||||
NULL, /* HB_P_STATICS, */
|
||||
NULL, /* HB_P_STATICNAME, */
|
||||
NULL, /* HB_P_SWAPALIAS, */
|
||||
hb_p_true, /* HB_P_TRUE, */
|
||||
NULL, /* HB_P_ZERO, */
|
||||
NULL, /* HB_P_ONE, */
|
||||
NULL, /* HB_P_MACROFUNC, */
|
||||
NULL, /* HB_P_MACRODO, */
|
||||
NULL, /* HB_P_MPUSHSTR, */
|
||||
NULL, /* HB_P_LOCALNEARADDINT, */
|
||||
NULL, /* HB_P_MACROPUSHREF */
|
||||
NULL, /* HB_P_PUSHLONGLONG */
|
||||
NULL, /* HB_P_ENUMSTART */
|
||||
NULL, /* HB_P_ENUMNEXT */
|
||||
NULL, /* HB_P_ENUMPREV */
|
||||
NULL, /* HB_P_ENUMEND */
|
||||
NULL, /* HB_P_SWITCH */
|
||||
NULL, /* HB_P_PUSHDATE */
|
||||
NULL, /* HB_P_PLUSEQPOP */
|
||||
NULL, /* HB_P_MINUSEQPOP */
|
||||
NULL, /* HB_P_MULTEQPOP */
|
||||
NULL, /* HB_P_DIVEQPOP */
|
||||
NULL, /* HB_P_PLUSEQ */
|
||||
NULL, /* HB_P_MINUSEQ */
|
||||
NULL, /* HB_P_MULTEQ */
|
||||
NULL, /* HB_P_DIVEQ */
|
||||
NULL, /* HB_P_WITHOBJECTSTART */
|
||||
NULL, /* HB_P_WITHOBJECTMESSAGE */
|
||||
NULL, /* HB_P_WITHOBJECTEND */
|
||||
NULL, /* HB_P_MACROSEND */
|
||||
NULL, /* HB_P_PUSHOVARREF */
|
||||
NULL, /* HB_P_ARRAYPUSHREF */
|
||||
NULL, /* HB_P_VFRAME */
|
||||
NULL, /* HB_P_LARGEFRAME */
|
||||
NULL, /* HB_P_LARGEVFRAME */
|
||||
NULL, /* HB_P_PUSHSTRHIDDEN */
|
||||
hb_p_localaddint, /* HB_P_LOCALADDINT */
|
||||
NULL, /* HB_P_MODEQPOP */
|
||||
NULL, /* HB_P_EXPEQPOP */
|
||||
NULL, /* HB_P_MODEQ */
|
||||
NULL, /* HB_P_EXPEQ */
|
||||
NULL, /* HB_P_DUPLUNREF */
|
||||
NULL, /* HB_P_MPUSHBLOCKLARGE */
|
||||
NULL, /* HB_P_MPUSHSTRLARGE */
|
||||
NULL, /* HB_P_PUSHBLOCKLARGE */
|
||||
NULL, /* HB_P_PUSHSTRLARGE */
|
||||
NULL, /* HB_P_SWAP */
|
||||
NULL, /* HB_P_PUSHVPARAMS */
|
||||
NULL, /* HB_P_PUSHUNREF */
|
||||
NULL, /* HB_P_SEQALWAYS */
|
||||
NULL, /* HB_P_ALWAYSBEGIN */
|
||||
NULL /* HB_P_ALWAYSEND */
|
||||
};
|
||||
|
||||
void hb_compOptimizePCode( HB_COMP_DECL, PFUNCTION pFunc )
|
||||
{
|
||||
HB_OPT_INFO opt_info;
|
||||
|
||||
opt_info.HB_COMP_PARAM = HB_COMP_PARAM;
|
||||
|
||||
assert( HB_P_LAST_PCODE == sizeof( s_opt_table ) / sizeof( HB_OPT_FUNC_PTR ) );
|
||||
|
||||
hb_compPCodeEval( pFunc, ( HB_PCODE_FUNC_PTR * ) s_opt_table, ( void * ) &opt_info );
|
||||
}
|
||||
Reference in New Issue
Block a user