2015-12-29 20:16 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/hbcomp.h
* include/hbcompdf.h
* src/compiler/gencc.c
! generate platform and C compiler independent C code for -gc3 output
This commit is contained in:
@@ -10,6 +10,12 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2015-12-29 20:16 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* include/hbcomp.h
|
||||
* include/hbcompdf.h
|
||||
* src/compiler/gencc.c
|
||||
! generate platform and C compiler independent C code for -gc3 output
|
||||
|
||||
2015-12-29 17:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* src/3rd/hbdossrl/Makefile
|
||||
! typo in library name
|
||||
|
||||
@@ -60,11 +60,6 @@
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
/* definitions for hb_compPCodeEval() support */
|
||||
typedef void * PHB_VOID;
|
||||
#define HB_PCODE_FUNC( func, type ) HB_SIZE func( PHB_HFUNC pFunc, HB_SIZE nPCodePos, type cargo )
|
||||
typedef HB_PCODE_FUNC( ( * PHB_PCODE_FUNC ), PHB_VOID );
|
||||
|
||||
extern HB_ISIZ hb_compPCodeSize( PHB_HFUNC, HB_SIZE );
|
||||
extern void hb_compPCodeEval( PHB_HFUNC, const PHB_PCODE_FUNC *, void * );
|
||||
extern void hb_compPCodeTrace( PHB_HFUNC, const PHB_PCODE_FUNC *, void * );
|
||||
|
||||
@@ -610,6 +610,11 @@ typedef struct _HB_MODULE
|
||||
struct _HB_MODULE * pNext;
|
||||
} HB_MODULE, * PHB_MODULE;
|
||||
|
||||
/* definitions for hb_compPCodeEval() support */
|
||||
typedef void * PHB_VOID;
|
||||
#define HB_PCODE_FUNC( func, type ) HB_SIZE func( PHB_HFUNC pFunc, HB_SIZE nPCodePos, type cargo )
|
||||
typedef HB_PCODE_FUNC( ( * PHB_PCODE_FUNC ), PHB_VOID );
|
||||
|
||||
typedef struct _HB_DEBUGINFO
|
||||
{
|
||||
char * pszModuleName;
|
||||
@@ -629,6 +634,7 @@ typedef struct _HB_LABEL_INFO
|
||||
HB_BOOL fEndRequest;
|
||||
int iNestedBlock;
|
||||
HB_SIZE * pnLabels;
|
||||
const PHB_PCODE_FUNC * pFuncTable;
|
||||
} HB_LABEL_INFO, * PHB_LABEL_INFO;
|
||||
|
||||
#define HB_MODE_COMPILER 1
|
||||
|
||||
@@ -194,14 +194,14 @@ static int hb_gencc_checkJumpCondAhead( HB_LONG lValue, PHB_HFUNC pFunc, HB_SIZE
|
||||
|
||||
if( iSize )
|
||||
{
|
||||
fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ld, &fValue ) ) break;\n",
|
||||
fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ldL, &fValue ) ) break;\n",
|
||||
szFunc, lValue );
|
||||
fprintf( cargo->yyc, "\tif( %sfValue )\n\t\tgoto lab%05" HB_PFS "u;\n",
|
||||
fNot ? "!" : "", HB_GENC_GETLABEL( nPCodePos + 1 + nOffset ) );
|
||||
return iSize;
|
||||
}
|
||||
}
|
||||
fprintf( cargo->yyc, "\tif( hb_xvm%sInt( %ld ) ) break;\n",
|
||||
fprintf( cargo->yyc, "\tif( hb_xvm%sInt( %ldL ) ) break;\n",
|
||||
szFunc, lValue );
|
||||
return 1;
|
||||
}
|
||||
@@ -213,13 +213,13 @@ static int hb_gencc_checkNumAhead( HB_LONG lValue, PHB_HFUNC pFunc, HB_SIZE nPCo
|
||||
switch( pFunc->pCode[ nPCodePos ] )
|
||||
{
|
||||
case HB_P_POPLOCAL:
|
||||
fprintf( cargo->yyc, "\thb_xvmLocalSetInt( %d, %ld );\n",
|
||||
fprintf( cargo->yyc, "\thb_xvmLocalSetInt( %d, %ldL );\n",
|
||||
HB_PCODE_MKSHORT( &pFunc->pCode[ nPCodePos + 1 ] ),
|
||||
lValue );
|
||||
return 3;
|
||||
|
||||
case HB_P_POPLOCALNEAR:
|
||||
fprintf( cargo->yyc, "\thb_xvmLocalSetInt( %d, %ld );\n",
|
||||
fprintf( cargo->yyc, "\thb_xvmLocalSetInt( %d, %ldL );\n",
|
||||
( signed char ) pFunc->pCode[ nPCodePos + 1 ], lValue );
|
||||
return 2;
|
||||
|
||||
@@ -245,7 +245,7 @@ static int hb_gencc_checkNumAhead( HB_LONG lValue, PHB_HFUNC pFunc, HB_SIZE nPCo
|
||||
case HB_P_ARRAYPUSH:
|
||||
if( lValue > 0 )
|
||||
{
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmArrayItemPush( %ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmArrayItemPush( %ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@@ -253,27 +253,27 @@ static int hb_gencc_checkNumAhead( HB_LONG lValue, PHB_HFUNC pFunc, HB_SIZE nPCo
|
||||
case HB_P_ARRAYPOP:
|
||||
if( lValue > 0 )
|
||||
{
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmArrayItemPop( %ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmArrayItemPop( %ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_P_MULT:
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmMultByInt( %ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmMultByInt( %ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
|
||||
case HB_P_DIVIDE:
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmDivideByInt( %ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmDivideByInt( %ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
|
||||
case HB_P_MODULUS:
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmModulusByInt( %ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmModulusByInt( %ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
|
||||
case HB_P_MINUS:
|
||||
if( lValue > 0 )
|
||||
{
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmAddInt( -%ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmAddInt( -%ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
}
|
||||
#if -LONG_MAX > LONG_MIN
|
||||
@@ -284,11 +284,11 @@ static int hb_gencc_checkNumAhead( HB_LONG lValue, PHB_HFUNC pFunc, HB_SIZE nPCo
|
||||
/* no break */
|
||||
|
||||
case HB_P_PLUS:
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmAddInt( %ld ) ) break;\n", lValue );
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmAddInt( %ldL ) ) break;\n", lValue );
|
||||
return 1;
|
||||
|
||||
case HB_P_RETVALUE:
|
||||
fprintf( cargo->yyc, "\thb_xvmRetInt( %ld );\n", lValue );
|
||||
fprintf( cargo->yyc, "\thb_xvmRetInt( %ldL );\n", lValue );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1286,7 +1286,7 @@ static HB_GENC_FUNC( hb_p_pushlong )
|
||||
if( iSkip == 0 )
|
||||
{
|
||||
fprintf( cargo->yyc, "#if INT_MAX >= INT32_MAX\n" );
|
||||
fprintf( cargo->yyc, "\thb_xvmPushInteger( %d );\n", ( int ) lVal );
|
||||
fprintf( cargo->yyc, "\thb_xvmPushInteger( %ld );\n", lVal );
|
||||
fprintf( cargo->yyc, "#else\n" );
|
||||
fprintf( cargo->yyc, "\thb_xvmPushLong( %ldL );\n", lVal );
|
||||
fprintf( cargo->yyc, "#endif\n" );
|
||||
@@ -1300,25 +1300,37 @@ static HB_GENC_FUNC( hb_p_pushlonglong )
|
||||
HB_GENC_LABEL();
|
||||
fprintf( cargo->yyc, "\thb_xvmPushLongLong( %.1f );\n", HB_PCODE_MKLONGLONG( &pFunc->pCode[ nPCodePos + 1 ] ) );
|
||||
return 9;
|
||||
#elif LONG_MAX == LONGLONG_MAX
|
||||
HB_LONGLONG llVal = HB_PCODE_MKLONGLONG( &pFunc->pCode[ nPCodePos + 1 ] ), iSkip;
|
||||
#else
|
||||
HB_LONGLONG llVal, iSkip;
|
||||
char szBuf[ 24 ];
|
||||
|
||||
HB_GENC_LABEL();
|
||||
|
||||
fprintf( cargo->yyc, "#if LONG_MAX >= LONGLONG_MAX\n" );
|
||||
llVal = HB_PCODE_MKLONGLONG( &pFunc->pCode[ nPCodePos + 1 ] );
|
||||
iSkip = hb_gencc_checkNumAhead( llVal, pFunc, nPCodePos + 9, cargo );
|
||||
|
||||
if( iSkip == 0 )
|
||||
{
|
||||
fprintf( cargo->yyc, "\thb_xvmPushLong( %ldL );\n", ( long ) llVal );
|
||||
}
|
||||
return 9 + iSkip;
|
||||
#else
|
||||
char szBuf[ 24 ];
|
||||
HB_GENC_LABEL();
|
||||
fprintf( cargo->yyc, "#else\n" );
|
||||
fprintf( cargo->yyc, "\thb_xvmPushLongLong( HB_LL( %s ) );\n",
|
||||
hb_numToStr( szBuf, sizeof( szBuf ),
|
||||
HB_PCODE_MKLONGLONG( &pFunc->pCode[ nPCodePos + 1 ] ) ) );
|
||||
return 9;
|
||||
if( iSkip > 0 )
|
||||
{
|
||||
int iDone = 0;
|
||||
while( iDone < iSkip )
|
||||
{
|
||||
HB_BYTE opcode = pFunc->pCode[ nPCodePos + 9 + iDone ];
|
||||
if( opcode >= HB_P_LAST_PCODE )
|
||||
break;
|
||||
iDone += ( int ) cargo->pFuncTable[ opcode ]( pFunc, nPCodePos + 9 + iDone, cargo );
|
||||
}
|
||||
if( iDone != iSkip )
|
||||
HB_GENC_ERROR( "PCODE mismatch" );
|
||||
}
|
||||
fprintf( cargo->yyc, "#endif\n" );
|
||||
return 9 + iSkip;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2387,6 +2399,7 @@ void hb_compGenCRealCode( HB_COMP_DECL, PHB_HFUNC pFunc, FILE * yyc )
|
||||
label_info.fCondJump = HB_FALSE;
|
||||
label_info.fEndRequest = HB_FALSE;
|
||||
label_info.iNestedBlock = 0;
|
||||
label_info.pFuncTable = ( const PHB_PCODE_FUNC * ) pFuncTable;
|
||||
if( pFunc->nPCodePos == 0 )
|
||||
label_info.pnLabels = NULL;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user