20000421-00:34 GMT+1 Victor Szakats <info@szelvesz.hu>
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
20000421-00:34 GMT+1 Victor Szakats <info@szelvesz.hu>
|
||||
|
||||
* source/compiler/genc.c
|
||||
% Variable scopes adjusted.
|
||||
! Some GCC warnings removed.
|
||||
|
||||
* source/compiler/harbour.c
|
||||
! Some GCC warnings removed
|
||||
! One int changed to BOOL
|
||||
! Indentation fixed
|
||||
|
||||
20000420-23:58 GMT+1 Victor Szakats <info@szelvesz.hu>
|
||||
* source/compiler/genc.c
|
||||
! STATICS and SFRAME fixed with -gc0 mode.
|
||||
|
||||
@@ -227,14 +227,10 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
|
||||
static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
{
|
||||
USHORT w, wLen, wSym, wVar;
|
||||
USHORT iNestedCodeblock = 0;
|
||||
ULONG lPCodePos;
|
||||
char chr;
|
||||
LONG lOffset;
|
||||
ULONG lPCodePos = 0;
|
||||
BOOL bVerbose = ( hb_comp_iGenCOutput == HB_COMPGENC_VERBOSE );
|
||||
|
||||
lPCodePos = 0;
|
||||
while( lPCodePos < pFunc->lPCodePos )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos ] )
|
||||
@@ -260,13 +256,15 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_ARRAYDIM:
|
||||
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_ARRAYDIM, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 3;
|
||||
{
|
||||
USHORT w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_ARRAYDIM, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_DIVIDE:
|
||||
@@ -362,13 +360,15 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_ARRAYGEN:
|
||||
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_ARRAYGEN, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 3;
|
||||
{
|
||||
USHORT w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_ARRAYGEN, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_GREATER:
|
||||
@@ -394,7 +394,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
case HB_P_JUMPSHORT:
|
||||
/* if( 1 ) ( lPCodePos + 3 ) < pFunc->lPCodePos ) */
|
||||
{
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
|
||||
if ( lOffset > 127 )
|
||||
lOffset -= 256;
|
||||
@@ -410,7 +410,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
case HB_P_JUMP:
|
||||
/* if( 1 ) ( lPCodePos + 3 ) < pFunc->lPCodePos ) */
|
||||
{
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
|
||||
if ( lOffset > SHRT_MAX )
|
||||
lOffset -= 65536;
|
||||
@@ -427,7 +427,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
case HB_P_JUMPFAR:
|
||||
/* if( 1 ) ( lPCodePos + 3 ) < pFunc->lPCodePos ) */
|
||||
{
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
if ( lOffset > 8388607L )
|
||||
lOffset -= 16777216;
|
||||
|
||||
@@ -442,35 +442,39 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_JUMPSHORTFALSE:
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
{
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
|
||||
if ( lOffset > 127 )
|
||||
lOffset -= 256;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPSHORTFALSE, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
if ( lOffset > 127 )
|
||||
lOffset -= 256;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPSHORTFALSE, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
}
|
||||
lPCodePos += 2;
|
||||
break;
|
||||
|
||||
case HB_P_JUMPFALSE:
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
|
||||
if ( lOffset > SHRT_MAX )
|
||||
lOffset -= 65536;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPFALSE, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
{
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
|
||||
if ( lOffset > SHRT_MAX )
|
||||
lOffset -= 65536;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPFALSE, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
}
|
||||
lPCodePos += 3;
|
||||
break;
|
||||
|
||||
case HB_P_JUMPFARFALSE:
|
||||
{
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
if ( lOffset > 8388607L )
|
||||
lOffset -= 16777216;
|
||||
|
||||
@@ -485,33 +489,37 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_JUMPSHORTTRUE:
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
if ( lOffset > 127 )
|
||||
lOffset -= 256;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPSHORTTRUE, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
{
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
if ( lOffset > 127 )
|
||||
lOffset -= 256;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPSHORTTRUE, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
}
|
||||
lPCodePos += 2;
|
||||
break;
|
||||
|
||||
case HB_P_JUMPTRUE:
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
if ( lOffset > SHRT_MAX )
|
||||
lOffset -= 65536;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPTRUE, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
{
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
if ( lOffset > SHRT_MAX )
|
||||
lOffset -= 65536;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_JUMPTRUE, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, ( LONG ) ( lPCodePos + lOffset ) );
|
||||
fprintf( s_yyc, "\n" );
|
||||
}
|
||||
lPCodePos += 3;
|
||||
break;
|
||||
|
||||
case HB_P_JUMPFARTRUE:
|
||||
{
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
if ( lOffset > 8388607L )
|
||||
lOffset -= 16777216;
|
||||
|
||||
@@ -536,15 +544,18 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_LINE:
|
||||
if( bVerbose ) fprintf( s_yyc, "/* %05li */ ", lPCodePos );
|
||||
else fprintf( s_yyc, "\t" );
|
||||
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "HB_P_LINE, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 3;
|
||||
{
|
||||
USHORT w;
|
||||
if( bVerbose ) fprintf( s_yyc, "/* %05li */ ", lPCodePos );
|
||||
else fprintf( s_yyc, "\t" );
|
||||
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "HB_P_LINE, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_LOCALNAME:
|
||||
@@ -556,7 +567,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
lPCodePos += 3;
|
||||
while( pFunc->pCode[ lPCodePos ] )
|
||||
{
|
||||
chr = pFunc->pCode[ lPCodePos++ ];
|
||||
char chr = pFunc->pCode[ lPCodePos++ ];
|
||||
if( chr == '\'' || chr == '\\')
|
||||
fprintf( s_yyc, " \'\\%c\',", chr );
|
||||
else
|
||||
@@ -598,7 +609,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_MESSAGE:
|
||||
{
|
||||
wSym = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wSym = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_MESSAGE, %i, %i,",
|
||||
HB_LOBYTE( wSym ),
|
||||
HB_HIBYTE( wSym ) );
|
||||
@@ -621,7 +632,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
lPCodePos++;
|
||||
while( pFunc->pCode[ lPCodePos ] )
|
||||
{
|
||||
chr = pFunc->pCode[ lPCodePos++ ];
|
||||
char chr = pFunc->pCode[ lPCodePos++ ];
|
||||
if( chr == '\'' || chr == '\\')
|
||||
fprintf( s_yyc, " \'\\%c\',", chr );
|
||||
else
|
||||
@@ -663,7 +674,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PARAMETER:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PARAMETER, %i, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ),
|
||||
@@ -691,7 +702,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_POPALIASEDFIELD:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_POPALIASEDFIELD, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -703,7 +714,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_POPALIASEDVAR:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_POPALIASEDVAR, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -715,7 +726,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_POPFIELD:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_POPFIELD, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -766,7 +777,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_POPMEMVAR:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_POPMEMVAR, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -781,7 +792,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
PVAR pVar;
|
||||
PFUNCTION pTmp = hb_comp_functions.pFirst;
|
||||
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar )
|
||||
pTmp = pTmp->pNext;
|
||||
pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase );
|
||||
@@ -796,7 +807,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_POPVARIABLE:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_POPVARIABLE, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -818,8 +829,8 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PUSHALIASEDFIELD:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHALIASEDFIELD, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -831,8 +842,8 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PUSHALIASEDVAR:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHALIASEDVAR, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -843,48 +854,52 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_PUSHBLOCK:
|
||||
++iNestedCodeblock;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_PUSHBLOCK, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */",
|
||||
pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
fprintf( s_yyc, "\n" );
|
||||
|
||||
w = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 3 ] ) );
|
||||
fprintf( s_yyc, "\t%i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 3 ],
|
||||
pFunc->pCode[ lPCodePos + 4 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* number of local parameters (%i) */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
|
||||
wVar = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 5 ] ) );
|
||||
fprintf( s_yyc, "\t%i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 5 ],
|
||||
pFunc->pCode[ lPCodePos + 6 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* number of local variables (%i) */", wVar );
|
||||
fprintf( s_yyc, "\n" );
|
||||
|
||||
lPCodePos += 7; /* codeblock size + number of parameters + number of local variables */
|
||||
/* create the table of referenced local variables */
|
||||
while( wVar-- )
|
||||
{
|
||||
w = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos ] ) );
|
||||
fprintf( s_yyc, "\t%i, %i,",
|
||||
pFunc->pCode[ lPCodePos ],
|
||||
pFunc->pCode[ lPCodePos + 1 ] );
|
||||
/* NOTE:
|
||||
* When a codeblock is used to initialize a static variable
|
||||
* the the names of local variables cannot be determined
|
||||
* because at the time of C code generation we don't know
|
||||
* in which function was defined this local variable
|
||||
*/
|
||||
if( ( pFunc->cScope & ( HB_FS_INIT | HB_FS_EXIT ) ) != ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %s */", hb_compVariableFind( pFunc->pLocals, w )->szName );
|
||||
USHORT wVar, w;
|
||||
|
||||
++iNestedCodeblock;
|
||||
|
||||
fprintf( s_yyc, "\tHB_P_PUSHBLOCK, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */",
|
||||
pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256 );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos +=2;
|
||||
|
||||
w = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 3 ] ) );
|
||||
fprintf( s_yyc, "\t%i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 3 ],
|
||||
pFunc->pCode[ lPCodePos + 4 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* number of local parameters (%i) */", w );
|
||||
fprintf( s_yyc, "\n" );
|
||||
|
||||
wVar = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 5 ] ) );
|
||||
fprintf( s_yyc, "\t%i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 5 ],
|
||||
pFunc->pCode[ lPCodePos + 6 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* number of local variables (%i) */", wVar );
|
||||
fprintf( s_yyc, "\n" );
|
||||
|
||||
lPCodePos += 7; /* codeblock size + number of parameters + number of local variables */
|
||||
/* create the table of referenced local variables */
|
||||
while( wVar-- )
|
||||
{
|
||||
w = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos ] ) );
|
||||
fprintf( s_yyc, "\t%i, %i,",
|
||||
pFunc->pCode[ lPCodePos ],
|
||||
pFunc->pCode[ lPCodePos + 1 ] );
|
||||
/* NOTE:
|
||||
* When a codeblock is used to initialize a static variable
|
||||
* the the names of local variables cannot be determined
|
||||
* because at the time of C code generation we don't know
|
||||
* in which function was defined this local variable
|
||||
*/
|
||||
if( ( pFunc->cScope & ( HB_FS_INIT | HB_FS_EXIT ) ) != ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %s */", hb_compVariableFind( pFunc->pLocals, w )->szName );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos +=2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -906,8 +921,8 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PUSHFIELD:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHFIELD, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -1019,8 +1034,8 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PUSHMEMVAR:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHMEMVAR, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -1032,8 +1047,8 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PUSHMEMVARREF:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHMEMVARREF, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -1058,7 +1073,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
PVAR pVar;
|
||||
PFUNCTION pTmp = hb_comp_functions.pFirst;
|
||||
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar )
|
||||
pTmp = pTmp->pNext;
|
||||
pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase );
|
||||
@@ -1076,7 +1091,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
PVAR pVar;
|
||||
PFUNCTION pTmp = hb_comp_functions.pFirst;
|
||||
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar )
|
||||
pTmp = pTmp->pNext;
|
||||
pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase );
|
||||
@@ -1090,42 +1105,44 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_PUSHSTR:
|
||||
wLen = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHSTR, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", wLen );
|
||||
lPCodePos +=3;
|
||||
if( wLen > 0 )
|
||||
{
|
||||
unsigned char uchr;
|
||||
|
||||
fprintf( s_yyc, "\n\t" );
|
||||
while( wLen-- )
|
||||
USHORT wLen = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHSTR, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %i */", wLen );
|
||||
lPCodePos +=3;
|
||||
if( wLen > 0 )
|
||||
{
|
||||
uchr = ( unsigned char ) ( pFunc->pCode[ lPCodePos++ ] );
|
||||
/*
|
||||
* NOTE: After optimization some CHR(n) can be converted
|
||||
* into a string containing nonprintable characters.
|
||||
*
|
||||
* TODO: add switch to use hexadecimal format "%#04x"
|
||||
*/
|
||||
if( ( uchr < (unsigned char) ' ' ) || ( uchr >= 127 ) )
|
||||
fprintf( s_yyc, "%i, ", uchr );
|
||||
else if( strchr( "\'\\\"", uchr ) )
|
||||
fprintf( s_yyc, "%i, ", uchr );
|
||||
else
|
||||
fprintf( s_yyc, "\'%c\', ", uchr );
|
||||
unsigned char uchr;
|
||||
|
||||
fprintf( s_yyc, "\n\t" );
|
||||
while( wLen-- )
|
||||
{
|
||||
uchr = ( unsigned char ) ( pFunc->pCode[ lPCodePos++ ] );
|
||||
/*
|
||||
* NOTE: After optimization some CHR(n) can be converted
|
||||
* into a string containing nonprintable characters.
|
||||
*
|
||||
* TODO: add switch to use hexadecimal format "%#04x"
|
||||
*/
|
||||
if( ( uchr < (unsigned char) ' ' ) || ( uchr >= 127 ) )
|
||||
fprintf( s_yyc, "%i, ", uchr );
|
||||
else if( strchr( "\'\\\"", uchr ) )
|
||||
fprintf( s_yyc, "%i, ", uchr );
|
||||
else
|
||||
fprintf( s_yyc, "\'%c\', ", uchr );
|
||||
}
|
||||
}
|
||||
fprintf( s_yyc, "\n" );
|
||||
}
|
||||
fprintf( s_yyc, "\n" );
|
||||
break;
|
||||
|
||||
case HB_P_PUSHSYM:
|
||||
{
|
||||
wSym = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wSym = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHSYM, %i, %i,",
|
||||
HB_LOBYTE( wSym ),
|
||||
HB_HIBYTE( wSym ) );
|
||||
@@ -1137,8 +1154,8 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
case HB_P_PUSHVARIABLE:
|
||||
{
|
||||
wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
USHORT wVar = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
fprintf( s_yyc, "\tHB_P_PUSHVARIABLE, %i, %i,",
|
||||
HB_LOBYTE( wVar ),
|
||||
HB_HIBYTE( wVar ) );
|
||||
@@ -1154,27 +1171,32 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_SEQBEGIN:
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
fprintf( s_yyc, "\tHB_P_SEQBEGIN, %i, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ],
|
||||
pFunc->pCode[ lPCodePos + 3 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, lPCodePos + lOffset );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 4;
|
||||
{
|
||||
LONG lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
fprintf( s_yyc, "\tHB_P_SEQBEGIN, %i, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ],
|
||||
pFunc->pCode[ lPCodePos + 3 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, lPCodePos + lOffset );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 4;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_SEQEND:
|
||||
if( bVerbose ) fprintf( s_yyc, "/* %05li */ ", lPCodePos );
|
||||
else fprintf( s_yyc, "\t" );
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
fprintf( s_yyc, "HB_P_SEQEND, %i, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ],
|
||||
pFunc->pCode[ lPCodePos + 3 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, lPCodePos + lOffset );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 4;
|
||||
{
|
||||
LONG lOffset;
|
||||
if( bVerbose ) fprintf( s_yyc, "/* %05li */ ", lPCodePos );
|
||||
else fprintf( s_yyc, "\t" );
|
||||
lOffset = ( LONG ) ( pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256 + pFunc->pCode[ lPCodePos + 3 ] * 65536 );
|
||||
fprintf( s_yyc, "HB_P_SEQEND, %i, %i, %i,",
|
||||
pFunc->pCode[ lPCodePos + 1 ],
|
||||
pFunc->pCode[ lPCodePos + 2 ],
|
||||
pFunc->pCode[ lPCodePos + 3 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* %li (abs: %05li) */", lOffset, lPCodePos + lOffset );
|
||||
fprintf( s_yyc, "\n" );
|
||||
lPCodePos += 4;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_SEQRECOVER:
|
||||
@@ -1186,6 +1208,7 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
/* we only generate it if there are statics used in this function */
|
||||
if( pFunc->bFlags & FUN_USES_STATICS )
|
||||
{
|
||||
USHORT w;
|
||||
hb_compSymbolFind( hb_comp_pInitFunc->szName, &w );
|
||||
fprintf( s_yyc, "\tHB_P_SFRAME, %i, %i,",
|
||||
HB_LOBYTE( w ), HB_HIBYTE( w ) );
|
||||
@@ -1196,14 +1219,17 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_STATICS:
|
||||
hb_compSymbolFind( hb_comp_pInitFunc->szName, &w );
|
||||
fprintf( s_yyc, "\tHB_P_STATICS, %i, %i, %i, %i,",
|
||||
HB_LOBYTE( w ),
|
||||
HB_HIBYTE( w ),
|
||||
pFunc->pCode[ lPCodePos + 3 ],
|
||||
pFunc->pCode[ lPCodePos + 4 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* symbol (_INITSTATICS), %i statics */", pFunc->pCode[ lPCodePos + 3 ] + pFunc->pCode[ lPCodePos + 4 ] * 256 );
|
||||
fprintf( s_yyc, "\n" );
|
||||
{
|
||||
USHORT w;
|
||||
hb_compSymbolFind( hb_comp_pInitFunc->szName, &w );
|
||||
fprintf( s_yyc, "\tHB_P_STATICS, %i, %i, %i, %i,",
|
||||
HB_LOBYTE( w ),
|
||||
HB_HIBYTE( w ),
|
||||
pFunc->pCode[ lPCodePos + 3 ],
|
||||
pFunc->pCode[ lPCodePos + 4 ] );
|
||||
if( bVerbose ) fprintf( s_yyc, "\t/* symbol (_INITSTATICS), %i statics */", pFunc->pCode[ lPCodePos + 3 ] + pFunc->pCode[ lPCodePos + 4 ] * 256 );
|
||||
fprintf( s_yyc, "\n" );
|
||||
}
|
||||
lPCodePos += 5;
|
||||
break;
|
||||
|
||||
@@ -1241,15 +1267,12 @@ static void hb_compGenCReadable( PFUNCTION pFunc )
|
||||
|
||||
static void hb_compGenCCompact( PFUNCTION pFunc )
|
||||
{
|
||||
USHORT w, wLen, wSym, wVar;
|
||||
ULONG lPCodePos;
|
||||
LONG lOffset;
|
||||
ULONG lPCodePos = 0;
|
||||
|
||||
fprintf( s_yyc, "\t" );
|
||||
|
||||
s_nChar = 0;
|
||||
|
||||
lPCodePos = 0;
|
||||
while( lPCodePos < pFunc->lPCodePos )
|
||||
{
|
||||
switch( pFunc->pCode[ lPCodePos ] )
|
||||
@@ -1379,19 +1402,21 @@ static void hb_compGenCCompact( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_PUSHBLOCK:
|
||||
wVar = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 5 ] ) );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
/* create the table of referenced local variables */
|
||||
while( wVar-- )
|
||||
{
|
||||
USHORT wVar = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 5 ] ) );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
/* create the table of referenced local variables */
|
||||
while( wVar-- )
|
||||
{
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1415,20 +1440,23 @@ static void hb_compGenCCompact( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_PUSHSTR:
|
||||
wLen = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
hb_fputc( pFunc->pCode[ lPCodePos ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 2 ] );
|
||||
lPCodePos += 3;
|
||||
while( wLen-- )
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
{
|
||||
USHORT wLen = pFunc->pCode[ lPCodePos + 1 ] +
|
||||
pFunc->pCode[ lPCodePos + 2 ] * 256;
|
||||
hb_fputc( pFunc->pCode[ lPCodePos ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 1 ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 2 ] );
|
||||
lPCodePos += 3;
|
||||
while( wLen-- )
|
||||
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_SFRAME:
|
||||
/* we only generate it if there are statics used in this function */
|
||||
if( pFunc->bFlags & FUN_USES_STATICS )
|
||||
{
|
||||
USHORT w;
|
||||
hb_compSymbolFind( hb_comp_pInitFunc->szName, &w );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos ] );
|
||||
hb_fputc( HB_LOBYTE( w ) );
|
||||
@@ -1438,13 +1466,16 @@ static void hb_compGenCCompact( PFUNCTION pFunc )
|
||||
break;
|
||||
|
||||
case HB_P_STATICS:
|
||||
hb_compSymbolFind( hb_comp_pInitFunc->szName, &w );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos ] );
|
||||
hb_fputc( HB_LOBYTE( w ) );
|
||||
hb_fputc( HB_HIBYTE( w ) );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 3 ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 4 ] );
|
||||
lPCodePos += 5;
|
||||
{
|
||||
USHORT w;
|
||||
hb_compSymbolFind( hb_comp_pInitFunc->szName, &w );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos ] );
|
||||
hb_fputc( HB_LOBYTE( w ) );
|
||||
hb_fputc( HB_HIBYTE( w ) );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 3 ] );
|
||||
hb_fputc( pFunc->pCode[ lPCodePos + 4 ] );
|
||||
lPCodePos += 5;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -861,11 +861,11 @@ PFUNCTION hb_compFunctionKill( PFUNCTION pFunc )
|
||||
}
|
||||
|
||||
/* Release the NOOP array. */
|
||||
if ( pFunc->pNOOPs )
|
||||
if( pFunc->pNOOPs )
|
||||
hb_xfree( ( void * ) pFunc->pNOOPs );
|
||||
|
||||
/* Release the Jumps array. */
|
||||
if ( pFunc->pJumps )
|
||||
if( pFunc->pJumps )
|
||||
hb_xfree( ( void * ) pFunc->pJumps );
|
||||
|
||||
hb_xfree( ( void * ) pFunc->pCode );
|
||||
@@ -1268,7 +1268,7 @@ USHORT hb_compFunctionGetPos( char * szFunctionName ) /* return 0 if not found o
|
||||
|
||||
void hb_compPrepareOptimize()
|
||||
{
|
||||
if ( ! hb_comp_iJumpOptimize )
|
||||
if( ! hb_comp_iJumpOptimize )
|
||||
return;
|
||||
|
||||
hb_comp_functions.pLast->iJumps++;
|
||||
@@ -1276,7 +1276,7 @@ void hb_compPrepareOptimize()
|
||||
//printf( "Preparing for Jump #%i in: %li 3rd Byte=%i", hb_comp_functions.pLast->iJumps, ( ULONG ) ( hb_comp_functions.pLast->lPCodePos - 4 ), hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos ] );
|
||||
//getchar();
|
||||
|
||||
if ( hb_comp_functions.pLast->pJumps )
|
||||
if( hb_comp_functions.pLast->pJumps )
|
||||
{
|
||||
|
||||
hb_comp_functions.pLast->pJumps = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pJumps, sizeof( ULONG ) * hb_comp_functions.pLast->iJumps );
|
||||
@@ -1289,9 +1289,9 @@ void hb_compPrepareOptimize()
|
||||
}
|
||||
|
||||
/* Only Reserve Request - Don't know if NOOPs will remain yet. */
|
||||
if ( hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos - 3 ] == 0 &&
|
||||
hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos - 2 ] == 0 &&
|
||||
hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos - 1 ] == 0 )
|
||||
if( hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos - 3 ] == 0 &&
|
||||
hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos - 2 ] == 0 &&
|
||||
hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos - 1 ] == 0 )
|
||||
return;
|
||||
|
||||
/* 3rd. Byte might be not used */
|
||||
@@ -1299,7 +1299,7 @@ void hb_compPrepareOptimize()
|
||||
{
|
||||
hb_comp_functions.pLast->iNOOPs++;
|
||||
|
||||
if ( hb_comp_functions.pLast->pNOOPs )
|
||||
if( hb_comp_functions.pLast->pNOOPs )
|
||||
{
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pNOOPs, sizeof( ULONG ) * hb_comp_functions.pLast->iNOOPs );
|
||||
hb_comp_functions.pLast->pNOOPs[ hb_comp_functions.pLast->iNOOPs - 1 ] = hb_comp_functions.pLast->lPCodePos - 1;
|
||||
@@ -1315,7 +1315,7 @@ void hb_compPrepareOptimize()
|
||||
{
|
||||
hb_comp_functions.pLast->iNOOPs++;
|
||||
|
||||
if ( hb_comp_functions.pLast->pNOOPs )
|
||||
if( hb_comp_functions.pLast->pNOOPs )
|
||||
{
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pNOOPs, sizeof( ULONG ) * hb_comp_functions.pLast->iNOOPs );
|
||||
hb_comp_functions.pLast->pNOOPs[ hb_comp_functions.pLast->iNOOPs - 1 ] = hb_comp_functions.pLast->lPCodePos - 2;
|
||||
@@ -1332,22 +1332,22 @@ void hb_compPrepareOptimize()
|
||||
ULONG hb_compGenJump( LONG lOffset )
|
||||
{
|
||||
/* Just a place holder, it might be a far jump...*/
|
||||
if ( lOffset == 0 )
|
||||
if( lOffset == 0 )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFAR, 0, 0 );
|
||||
hb_compGenPCode1( 0 );
|
||||
}
|
||||
else if ( lOffset >= -128 && lOffset <= 127 )
|
||||
else if( lOffset >= -128 && lOffset <= 127 )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPSHORT, HB_LOBYTE( lOffset ), HB_P_NOOP );
|
||||
hb_compGenPCode1( HB_P_NOOP );
|
||||
}
|
||||
else if ( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ) );
|
||||
hb_compGenPCode1( HB_P_NOOP );
|
||||
}
|
||||
else if ( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
else if( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ) );
|
||||
hb_compGenPCode1( ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ) );
|
||||
@@ -1365,22 +1365,22 @@ ULONG hb_compGenJump( LONG lOffset )
|
||||
ULONG hb_compGenJumpFalse( LONG lOffset )
|
||||
{
|
||||
/* Just a place holder, it might be a far jump...*/
|
||||
if ( lOffset == 0 )
|
||||
if( lOffset == 0 )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFARFALSE, 0, 0 );
|
||||
hb_compGenPCode1( 0 );
|
||||
}
|
||||
else if ( lOffset >= -128 && lOffset <= 127 )
|
||||
else if( lOffset >= -128 && lOffset <= 127 )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPSHORTFALSE, HB_LOBYTE( lOffset ), HB_P_NOOP );
|
||||
hb_compGenPCode1( HB_P_NOOP );
|
||||
}
|
||||
else if ( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ) );
|
||||
hb_compGenPCode1( HB_P_NOOP );
|
||||
}
|
||||
else if ( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
else if( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFARFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ) );
|
||||
hb_compGenPCode1( ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ) );
|
||||
@@ -1398,22 +1398,22 @@ ULONG hb_compGenJumpFalse( LONG lOffset )
|
||||
ULONG hb_compGenJumpTrue( LONG lOffset )
|
||||
{
|
||||
/* Just a place holder, it might be a far jump...*/
|
||||
if ( lOffset == 0 )
|
||||
if( lOffset == 0 )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFARTRUE, 0, 0 );
|
||||
hb_compGenPCode1( 0 );
|
||||
}
|
||||
else if ( lOffset >= -128 && lOffset <= 127 )
|
||||
else if( lOffset >= -128 && lOffset <= 127 )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPSHORTTRUE, HB_LOBYTE( lOffset ), HB_P_NOOP );
|
||||
hb_compGenPCode1( HB_P_NOOP );
|
||||
}
|
||||
else if ( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ) );
|
||||
hb_compGenPCode1( HB_P_NOOP );
|
||||
}
|
||||
else if ( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
else if( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
{
|
||||
hb_compGenPCode3( HB_P_JUMPFARTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ) );
|
||||
hb_compGenPCode1( ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF ) );
|
||||
@@ -1432,11 +1432,11 @@ void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo )
|
||||
{
|
||||
BYTE * pCode = hb_comp_functions.pLast->pCode;
|
||||
LONG lOffset = ulTo - ulFrom + 1;
|
||||
int iOptimize = 1 && hb_comp_iJumpOptimize ;
|
||||
int iOptimize = hb_comp_iJumpOptimize;
|
||||
|
||||
if ( lOffset >= -128 && lOffset <= 127 )
|
||||
if( lOffset >= -128 && lOffset <= 127 )
|
||||
{
|
||||
switch ( pCode[ ( ULONG ) ( ulFrom - 1 ) ] )
|
||||
switch( pCode[ ( ULONG ) ( ulFrom - 1 ) ] )
|
||||
{
|
||||
/*
|
||||
case HB_P_JUMPSHORT :
|
||||
@@ -1501,31 +1501,31 @@ void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo )
|
||||
|
||||
pCode[ ( ULONG ) ulFrom ] = HB_LOBYTE( lOffset );
|
||||
|
||||
if ( ! iOptimize )
|
||||
if( ! iOptimize )
|
||||
return;
|
||||
|
||||
/* Check if 3rd. Byte not used. */
|
||||
if ( pCode[ ( ULONG ) ( ulFrom + 2 ) ] == HB_P_NOOP )
|
||||
if( pCode[ ( ULONG ) ( ulFrom + 2 ) ] == HB_P_NOOP )
|
||||
{
|
||||
hb_comp_functions.pLast->iNOOPs++;
|
||||
|
||||
if ( hb_comp_functions.pLast->pNOOPs )
|
||||
if( hb_comp_functions.pLast->pNOOPs )
|
||||
{
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pNOOPs, sizeof( ULONG ) * hb_comp_functions.pLast->iNOOPs );
|
||||
hb_comp_functions.pLast->pNOOPs[ hb_comp_functions.pLast->iNOOPs - 1 ] = ( ULONG ) ulFrom + 2;
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pNOOPs, sizeof( ULONG ) * hb_comp_functions.pLast->iNOOPs );
|
||||
hb_comp_functions.pLast->pNOOPs[ hb_comp_functions.pLast->iNOOPs - 1 ] = ( ULONG ) ulFrom + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xgrab( sizeof( ULONG ) );
|
||||
hb_comp_functions.pLast->pNOOPs[ 0 ] = ( ULONG ) ulFrom + 2;
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xgrab( sizeof( ULONG ) );
|
||||
hb_comp_functions.pLast->pNOOPs[ 0 ] = ( ULONG ) ulFrom + 2;
|
||||
}
|
||||
|
||||
/* Check if 2nd. Byte not used. */
|
||||
if ( pCode[ ( ULONG ) ulFrom + 1 ] == HB_P_NOOP )
|
||||
if( pCode[ ( ULONG ) ulFrom + 1 ] == HB_P_NOOP )
|
||||
{
|
||||
hb_comp_functions.pLast->iNOOPs++;
|
||||
|
||||
if ( hb_comp_functions.pLast->pNOOPs )
|
||||
if( hb_comp_functions.pLast->pNOOPs )
|
||||
{
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pNOOPs, sizeof( ULONG ) * hb_comp_functions.pLast->iNOOPs );
|
||||
hb_comp_functions.pLast->pNOOPs[ hb_comp_functions.pLast->iNOOPs - 1 ] = ( ULONG ) ulFrom + 1;
|
||||
@@ -1538,9 +1538,9 @@ void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
else if( lOffset >= SHRT_MIN && lOffset <= SHRT_MAX )
|
||||
{
|
||||
switch ( pCode[ ( ULONG ) ( ulFrom - 1 ) ] )
|
||||
switch( pCode[ ( ULONG ) ( ulFrom - 1 ) ] )
|
||||
{
|
||||
/*
|
||||
case HB_P_JUMPSHORT :
|
||||
@@ -1600,15 +1600,15 @@ void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo )
|
||||
pCode[ ulFrom ] = HB_LOBYTE( lOffset );
|
||||
pCode[ ( ULONG ) ( ulFrom + 1 ) ] = HB_HIBYTE( lOffset );
|
||||
|
||||
if ( ! iOptimize )
|
||||
if( ! iOptimize )
|
||||
return;
|
||||
|
||||
/* Check if 3rd. Byte not used. */
|
||||
if ( pCode[ ( ULONG ) ulFrom + 2 ] == HB_P_NOOP )
|
||||
if( pCode[ ( ULONG ) ulFrom + 2 ] == HB_P_NOOP )
|
||||
{
|
||||
hb_comp_functions.pLast->iNOOPs++;
|
||||
|
||||
if ( hb_comp_functions.pLast->pNOOPs )
|
||||
if( hb_comp_functions.pLast->pNOOPs )
|
||||
{
|
||||
hb_comp_functions.pLast->pNOOPs = ( ULONG * ) hb_xrealloc( hb_comp_functions.pLast->pNOOPs, sizeof( ULONG ) * hb_comp_functions.pLast->iNOOPs );
|
||||
hb_comp_functions.pLast->pNOOPs[ hb_comp_functions.pLast->iNOOPs - 1 ] = ( ULONG ) ulFrom + 2;
|
||||
@@ -1620,16 +1620,14 @@ void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( lOffset >= (-8388608L) && lOffset <= 8388607L )
|
||||
else if( lOffset >= ( -8388608L ) && lOffset <= 8388607L )
|
||||
{
|
||||
pCode[ ulFrom ] = HB_LOBYTE( lOffset );
|
||||
pCode[ ( ULONG ) ( ulFrom + 1 ) ] = HB_HIBYTE( lOffset );
|
||||
pCode[ ( ULONG ) ( ulFrom + 2 ) ] = ( BYTE ) ( ( ( USHORT ) ( lOffset ) >> 16 ) & 0xFF );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_JUMP_TOO_LONG, NULL, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
void hb_compGenJumpHere( ULONG ulOffset )
|
||||
@@ -2301,9 +2299,10 @@ void hb_compFixReturns( void ) /* fixes all last defined function returns jumps
|
||||
hb_compGenPCode1( HB_P_ENDPROC );
|
||||
}
|
||||
|
||||
if ( hb_comp_iJumpOptimize )
|
||||
if ( hb_comp_functions.pLast && hb_comp_functions.pLast->iNOOPs )
|
||||
hb_compOptimizeJumps();
|
||||
if( hb_comp_iJumpOptimize &&
|
||||
hb_comp_functions.pLast &&
|
||||
hb_comp_functions.pLast->iNOOPs )
|
||||
hb_compOptimizeJumps();
|
||||
|
||||
if( hb_comp_iWarnings && hb_comp_functions.pLast )
|
||||
{
|
||||
@@ -2341,9 +2340,9 @@ int hb_compSort_ULONG( const void * pLeft, const void * pRight )
|
||||
ULONG ulLeft = *( (ULONG *) (pLeft) );
|
||||
ULONG ulRight = *( (ULONG *) (pRight) );
|
||||
|
||||
if ( ulLeft == ulRight )
|
||||
if( ulLeft == ulRight )
|
||||
return 0 ;
|
||||
else if ( ulLeft < ulRight )
|
||||
else if( ulLeft < ulRight )
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
@@ -2352,18 +2351,18 @@ int hb_compSort_ULONG( const void * pLeft, const void * pRight )
|
||||
void hb_compOptimizeJumps( void )
|
||||
{
|
||||
/* Jump Optimizer */
|
||||
BYTE * pCode = hb_comp_functions.pLast->pCode;
|
||||
BYTE * pOptimized = ( BYTE * ) hb_xgrab( hb_comp_functions.pLast->lPCodePos - hb_comp_functions.pLast->iNOOPs );
|
||||
ULONG * pNOOPs = hb_comp_functions.pLast->pNOOPs;
|
||||
ULONG * pJumps = hb_comp_functions.pLast->pJumps;
|
||||
int * piShifts = ( int * ) hb_xgrab( sizeof( int ) * hb_comp_functions.pLast->iJumps );
|
||||
ULONG ulOptimized = 0;
|
||||
ULONG ulNextByte = 0;
|
||||
BYTE * pCode = hb_comp_functions.pLast->pCode;
|
||||
BYTE * pOptimized = ( BYTE * ) hb_xgrab( hb_comp_functions.pLast->lPCodePos - hb_comp_functions.pLast->iNOOPs );
|
||||
ULONG * pNOOPs = hb_comp_functions.pLast->pNOOPs;
|
||||
ULONG * pJumps = hb_comp_functions.pLast->pJumps;
|
||||
int * piShifts = ( int * ) hb_xgrab( sizeof( int ) * hb_comp_functions.pLast->iJumps );
|
||||
ULONG ulOptimized = 0;
|
||||
ULONG ulNextByte = 0;
|
||||
int iNOOP;
|
||||
ULONG ulOffset;
|
||||
ULONG ulBytes2Copy;
|
||||
int iJump;
|
||||
int iForward;
|
||||
BOOL bForward = FALSE;
|
||||
|
||||
//printf( "\rOptimize ON" );
|
||||
//getchar();
|
||||
@@ -2371,16 +2370,16 @@ void hb_compOptimizeJumps( void )
|
||||
/* Needed so the pasting of PCODE pieces below will work correctly */
|
||||
qsort( (void *) pNOOPs, hb_comp_functions.pLast->iNOOPs, sizeof( ULONG ), hb_compSort_ULONG );
|
||||
|
||||
/*
|
||||
/*
|
||||
for( iNOOP = 0; iNOOP < hb_comp_functions.pLast->iNOOPs; iNOOP++ )
|
||||
{
|
||||
printf( "\rNOOP #%i at:%li", iNOOP, pNOOPs[ iNOOP ] );
|
||||
getchar();
|
||||
|
||||
if ( pNOOPs[ iNOOP ] == 0 )
|
||||
if( pNOOPs[ iNOOP ] == 0 )
|
||||
{
|
||||
printf( "\r*** 0 *** NOOP # %i at:%li", iNOOP, pNOOPs[ iNOOP ] );
|
||||
getchar();
|
||||
printf( "\r*** 0 *** NOOP # %i at:%li", iNOOP, pNOOPs[ iNOOP ] );
|
||||
getchar();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2392,15 +2391,15 @@ void hb_compOptimizeJumps( void )
|
||||
case HB_P_JUMPSHORTFALSE :
|
||||
case HB_P_JUMPSHORTTRUE :
|
||||
{
|
||||
ulOffset = pCode[ pJumps[ iJump ] + 1 ];
|
||||
ulOffset = pCode[ pJumps[ iJump ] + 1 ];
|
||||
|
||||
if ( ulOffset > 127 )
|
||||
{
|
||||
ulOffset -= 256;
|
||||
iForward = 0;
|
||||
}
|
||||
else
|
||||
iForward = 1;
|
||||
if( ulOffset > 127 )
|
||||
{
|
||||
ulOffset -= 256;
|
||||
bForward = FALSE;
|
||||
}
|
||||
else
|
||||
bForward = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2408,25 +2407,25 @@ void hb_compOptimizeJumps( void )
|
||||
case HB_P_JUMPFALSE :
|
||||
case HB_P_JUMPTRUE :
|
||||
{
|
||||
ulOffset = ( ULONG ) ( pCode[ pJumps[ iJump ] + 1 ] + ( pCode[ pJumps[ iJump ] + 2 ] * 256 ) );
|
||||
if ( ulOffset > SHRT_MAX )
|
||||
{
|
||||
ulOffset -= 65536;
|
||||
iForward = 0;
|
||||
}
|
||||
else
|
||||
iForward = 1;
|
||||
ulOffset = ( ULONG ) ( pCode[ pJumps[ iJump ] + 1 ] + ( pCode[ pJumps[ iJump ] + 2 ] * 256 ) );
|
||||
if( ulOffset > SHRT_MAX )
|
||||
{
|
||||
ulOffset -= 65536;
|
||||
bForward = FALSE;
|
||||
}
|
||||
else
|
||||
bForward = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
ulOffset = ( ULONG )( pCode[ pJumps[ iJump ] + 1 ] + ( pCode[ pJumps[ iJump ] + 2 ] * 256 ) + ( pCode[ pJumps[ iJump ] + 3 ] * 65536 ) );
|
||||
if ( ulOffset > 8388607L )
|
||||
{
|
||||
ulOffset -= 16777216L;
|
||||
iForward = 0;
|
||||
}
|
||||
ulOffset = ( ULONG )( pCode[ pJumps[ iJump ] + 1 ] + ( pCode[ pJumps[ iJump ] + 2 ] * 256 ) + ( pCode[ pJumps[ iJump ] + 3 ] * 65536 ) );
|
||||
if( ulOffset > 8388607L )
|
||||
{
|
||||
ulOffset -= 16777216L;
|
||||
bForward = FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2434,13 +2433,13 @@ void hb_compOptimizeJumps( void )
|
||||
printf( "\rJump=%li, Base=%li, Offset=%li, Target=%li", iJump, pJumps[ iJump ], ulOffset, pJumps[ iJump ] + ulOffset );
|
||||
getchar();
|
||||
|
||||
if ( pJumps[ iJump ] == 0 || ulOffset == 0 )
|
||||
if( pJumps[ iJump ] == 0 || ulOffset == 0 )
|
||||
{
|
||||
printf( "\r*** 0 *** Jump=%li, Base=%li, Offset=%li, Target=%li", iJump, pJumps[ iJump ], ulOffset, pJumps[ iJump ] + ulOffset );
|
||||
getchar();
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
for( iJump = 0; iJump < hb_comp_functions.pLast->iJumps; iJump++ )
|
||||
piShifts[ iJump ] = 0;
|
||||
@@ -2457,15 +2456,15 @@ void hb_compOptimizeJumps( void )
|
||||
case HB_P_JUMPSHORTFALSE :
|
||||
case HB_P_JUMPSHORTTRUE :
|
||||
{
|
||||
ulOffset = pCode[ pJumps[ iJump ] + 1 ];
|
||||
ulOffset = pCode[ pJumps[ iJump ] + 1 ];
|
||||
|
||||
if ( ulOffset > 127 )
|
||||
{
|
||||
ulOffset -= 256;
|
||||
iForward = 0;
|
||||
}
|
||||
else
|
||||
iForward = 1;
|
||||
if( ulOffset > 127 )
|
||||
{
|
||||
ulOffset -= 256;
|
||||
bForward = FALSE;
|
||||
}
|
||||
else
|
||||
bForward = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2474,41 +2473,41 @@ void hb_compOptimizeJumps( void )
|
||||
case HB_P_JUMPTRUE :
|
||||
{
|
||||
ulOffset = ( ULONG ) ( pCode[ pJumps[ iJump ] + 1 ] + ( pCode[ pJumps[ iJump ] + 2 ] * 256 ) );
|
||||
if ( ulOffset > SHRT_MAX )
|
||||
if( ulOffset > SHRT_MAX )
|
||||
{
|
||||
ulOffset -= 65536;
|
||||
iForward = 0;
|
||||
ulOffset -= 65536;
|
||||
bForward = FALSE;
|
||||
}
|
||||
else
|
||||
iForward = 1;
|
||||
bForward = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
ulOffset = ( ULONG )( pCode[ pJumps[ iJump ] + 1 ] + ( pCode[ pJumps[ iJump ] + 2 ] * 256 ) + ( pCode[ pJumps[ iJump ] + 3 ] * 65536 ) );
|
||||
if ( ulOffset > 8388607L )
|
||||
if( ulOffset > 8388607L )
|
||||
{
|
||||
ulOffset -= 16777216L;
|
||||
iForward = 0;
|
||||
ulOffset -= 16777216L;
|
||||
bForward = FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Only intrested in forward (positive) jumps. */
|
||||
if ( iForward )
|
||||
if( bForward )
|
||||
{
|
||||
//printf( "\rCurrent NOOP=%li, Address=%li, Jump=%i, Base=%li, Offset=%li, Target=%li", iNOOP, pNOOPs[ iNOOP ], iJump, pJumps[ iJump ], ulOffset, pJumps[ iJump ] + ulOffset );
|
||||
//getchar();
|
||||
|
||||
/* Only if points to code beyond the current fix. */
|
||||
if ( pJumps[ iJump ] < pNOOPs[ iNOOP ] && pJumps[ iJump ] + piShifts[ iJump ] + ulOffset > pNOOPs[ iNOOP ] )
|
||||
if( pJumps[ iJump ] < pNOOPs[ iNOOP ] && pJumps[ iJump ] + piShifts[ iJump ] + ulOffset > pNOOPs[ iNOOP ] )
|
||||
{
|
||||
/* Increasing Shift Counter for this Jump. */
|
||||
piShifts[ iJump ]++;
|
||||
|
||||
if ( pCode[ pJumps[ iJump ] + 1 ] )
|
||||
if( pCode[ pJumps[ iJump ] + 1 ] )
|
||||
pCode[ pJumps[ iJump ] + 1 ]--;
|
||||
else
|
||||
{
|
||||
@@ -2528,12 +2527,12 @@ void hb_compOptimizeJumps( void )
|
||||
//getchar();
|
||||
|
||||
// Only if points to code beyond the current fix.
|
||||
if ( pJumps[ iJump ] > pNOOPs[ iNOOP ] && pJumps[ iJump ] + piShifts[ iJump ] + ulOffset < pNOOPs[ iNOOP ] )
|
||||
if( pJumps[ iJump ] > pNOOPs[ iNOOP ] && pJumps[ iJump ] + piShifts[ iJump ] + ulOffset < pNOOPs[ iNOOP ] )
|
||||
{
|
||||
/* Decreasing Shift Counter for this Jump. */
|
||||
piShifts[ iJump ]--;
|
||||
|
||||
if ( pCode[ pJumps[ iJump ] + 1 ] < 255 )
|
||||
if( pCode[ pJumps[ iJump ] + 1 ] < 255 )
|
||||
pCode[ pJumps[ iJump ] + 1 ]++;
|
||||
else
|
||||
{
|
||||
@@ -2735,9 +2734,10 @@ void hb_compCodeBlockEnd( void )
|
||||
USHORT wPos;
|
||||
PVAR pVar, pFree;
|
||||
|
||||
if ( hb_comp_iJumpOptimize )
|
||||
if ( hb_comp_functions.pLast && hb_comp_functions.pLast->iNOOPs )
|
||||
hb_compOptimizeJumps();
|
||||
if( hb_comp_iJumpOptimize &&
|
||||
hb_comp_functions.pLast &&
|
||||
hb_comp_functions.pLast->iNOOPs )
|
||||
hb_compOptimizeJumps();
|
||||
|
||||
pCodeblock = hb_comp_functions.pLast;
|
||||
|
||||
@@ -2808,11 +2808,11 @@ void hb_compCodeBlockEnd( void )
|
||||
hb_xfree( ( void * ) pFree );
|
||||
}
|
||||
/* Release the NOOP array. */
|
||||
if ( pCodeblock->pNOOPs )
|
||||
if( pCodeblock->pNOOPs )
|
||||
hb_xfree( ( void * ) pCodeblock->pNOOPs );
|
||||
|
||||
/* Release the Jumps array. */
|
||||
if ( pCodeblock->pJumps )
|
||||
if( pCodeblock->pJumps )
|
||||
hb_xfree( ( void * ) pCodeblock->pJumps );
|
||||
|
||||
hb_xfree( ( void * ) pCodeblock );
|
||||
|
||||
Reference in New Issue
Block a user