20000422-16:16 GMT+1 Victor Szakats <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
2000-04-22 14:13:56 +00:00
parent 2a333af85c
commit 09bb6f21b2
16 changed files with 495 additions and 726 deletions

View File

@@ -1,3 +1,36 @@
20000422-16:16 GMT+1 Victor Szakats <info@szelvesz.hu>
* source/compiler/genc.c
* source/compiler/genhrb.c
* source/compiler/genjava.c
! Optimized all output types. Variables removed, made faster, cleaner.
% #include "hbpcode.h" is not included in the generated C code for -gc0
! Warnings fixed in GENOBJ32
* source/compiler/cmdcheck.c
* source/compiler/hbusage.c
* -gf switch changed to -go
* include/hbcomp.h
* source/compiler/harbour.c
* source/compiler/cmdcheck.c
* source/compiler/hbusage.c
- source/compiler/genrc.c
- source/compiler/genpas.c
* source/compiler/Makefile
* makefile.bc
* makefile.vc
- Removed GENPAS and GENRC because they not used.
* source/compiler/harbour.c
! Returning errorlevel after the help screen. (Thanks to Dave)
* include/hbvm.h
* source/vm/hvm.c
! PushOne/PushZero/PushByte() made static in hvm.c
! Fixed trace call in PushByte()
! Fixed casts in PushOne/PushZero/PushByte()
20000422-06:20 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/include/hbvm.h
* Corrected comments of hb_vmPushOne(), hb_vmPushZero(), and hb_vmPushByte()

View File

@@ -61,8 +61,6 @@ typedef enum
LANG_C, /* C language (by default) <file.c> */
LANG_OBJ32, /* DOS/Windows 32 bits <file.obj> */
LANG_JAVA, /* Java <file.java> */
LANG_PASCAL, /* Pascal <file.pas> */
LANG_RESOURCES, /* Resources <file.rc> */
LANG_PORT_OBJ /* Portable objects <file.hrb> */
} LANGUAGES; /* supported Harbour output languages */
@@ -317,8 +315,6 @@ extern char * hb_comp_buffer; /* yacc input buffer */
/* output related functions defined in gen*.c */
extern void hb_compGenCCode( PHB_FNAME ); /* generates the C language output */
extern void hb_compGenJava( PHB_FNAME ); /* generates the Java language output */
extern void hb_compGenPascal( PHB_FNAME ); /* generates the Pascal language output */
extern void hb_compGenRC( PHB_FNAME ); /* generates the RC language output */
extern void hb_compGenPortObj( PHB_FNAME ); /* generates the portable objects */
extern void hb_compGenObj32( PHB_FNAME ); /* generates OBJ 32 bits */

View File

@@ -77,9 +77,6 @@ extern void hb_vmFunction( USHORT uiParams ); /* executes a function saving i
extern void hb_vmPush( PHB_ITEM pItem ); /* pushes a generic item onto the stack */
extern void hb_vmPushNil( void ); /* in this case it places nil at self */
extern void hb_vmPushNumber( double dNumber, int iDec ); /* pushes a number on to the stack and decides if it is integer, long or double */
extern void hb_vmPushOne( void ); /* pushes a 1 onto the stack */
extern void hb_vmPushZero( void ); /* pushes a 0 onto the stack */
extern void hb_vmPushByte( BYTE bNumber ); /* pushes a 1 byte integer number onto the stack */
extern void hb_vmPushInteger( int iNumber ); /* pushes a integer number onto the stack */
extern void hb_vmPushLong( long lNumber ); /* pushes a long number onto the stack */
extern void hb_vmPushDouble( double lNumber, int iDec ); /* pushes a double number onto the stack */

View File

@@ -515,8 +515,6 @@ HARBOUR_EXE_OBJS = \
$(OBJ_DIR)\genc.obj \
$(OBJ_DIR)\genobj32.obj \
$(OBJ_DIR)\genjava.obj \
$(OBJ_DIR)\genpas.obj \
$(OBJ_DIR)\genrc.obj \
$(OBJ_DIR)\genhrb.obj \
$(OBJ_DIR)\expropta.obj \
$(OBJ_DIR)\exproptb.obj \
@@ -685,8 +683,6 @@ $(HARBOUR_EXE) : $(HARBOUR_EXE_OBJS)
echo. $(OBJ_DIR)\genc.obj >> make.tmp
echo. $(OBJ_DIR)\genobj32.obj >> make.tmp
echo. $(OBJ_DIR)\genjava.obj >> make.tmp
echo. $(OBJ_DIR)\genpas.obj >> make.tmp
echo. $(OBJ_DIR)\genrc.obj >> make.tmp
echo. $(OBJ_DIR)\genhrb.obj >> make.tmp
echo. $(OBJ_DIR)\expropta.obj >> make.tmp
echo. $(OBJ_DIR)\exproptb.obj >> make.tmp
@@ -734,12 +730,6 @@ $(OBJ_DIR)\genobj32.obj : $(COMPILER_DIR)\genobj32.c
$(OBJ_DIR)\genjava.obj : $(COMPILER_DIR)\genjava.c
$(CC) $(CLIBFLAGS) -o$@ $**
$(OBJ_DIR)\genpas.obj : $(COMPILER_DIR)\genpas.c
$(CC) $(CLIBFLAGS) -o$@ $**
$(OBJ_DIR)\genrc.obj : $(COMPILER_DIR)\genrc.c
$(CC) $(CLIBFLAGS) -o$@ $**
$(OBJ_DIR)\genhrb.obj : $(COMPILER_DIR)\genhrb.c
$(CC) $(CLIBFLAGS) -o$@ $**

View File

@@ -750,9 +750,7 @@ $(HARBOUR_EXE) : \
$(COMPILER_DIR)\genobj32.c \
$(COMPILER_DIR)\genc.c \
$(COMPILER_DIR)\genhrb.c \
$(COMPILER_DIR)\genrc.c \
$(COMPILER_DIR)\genjava.c \
$(COMPILER_DIR)\genpas.c \
$(COMPILER_DIR)\expropta.c \
$(COMPILER_DIR)\exproptb.c \
$(COMPILER_DIR)\exproptc.c

View File

@@ -27,8 +27,6 @@ C_SOURCES=\
genhrb.c \
genjava.c \
genobj32.c \
genpas.c \
genrc.c \
hbfunchk.c \
hbgenerr.c \
hbpcode.c \

View File

@@ -282,8 +282,8 @@ void hb_compChkEnvironVar( char * szSwitch )
}
break;
case 'f':
case 'F':
case 'o':
case 'O':
hb_comp_iLanguage = LANG_OBJ32;
break;
@@ -292,16 +292,6 @@ void hb_compChkEnvironVar( char * szSwitch )
hb_comp_iLanguage = LANG_JAVA;
break;
case 'p':
case 'P':
hb_comp_iLanguage = LANG_PASCAL;
break;
case 'r':
case 'R':
hb_comp_iLanguage = LANG_RESOURCES;
break;
case 'h':
case 'H':
hb_comp_iLanguage = LANG_PORT_OBJ;

File diff suppressed because it is too large Load Diff

View File

@@ -92,19 +92,13 @@ void hb_compGenPortObj( PHB_FNAME pFileName )
/* specify the function address if it is a defined function or a
external called function */
if( hb_compFunctionFind( pSym->szName ) ) /* is it a defined function ? */
{
fputc( SYM_FUNC, yyc );
}
else
{
if( hb_compFunCallFind( pSym->szName ) )
{
fputc( SYM_EXTERN, yyc );
}
else
{
fputc( SYM_NOLINK, yyc );
}
}
pSym = pSym->pNext;
}
@@ -140,8 +134,6 @@ void hb_compGenPortObj( PHB_FNAME pFileName )
fputc( ( BYTE ) ( ( ulCodeLength >> 16 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( ulCodeLength >> 24 ) & 255 ), yyc );
/* printf( "Creating output for %s\n", pFunc->szName ); */
lPCodePos = 0;
while( lPCodePos < pFunc->lPCodePos )
fputc( pFunc->pCode[ lPCodePos++ ], yyc );

View File

@@ -54,7 +54,6 @@ void hb_compGenJava( PHB_FNAME pFileName )
ULONG lPCodePos;
LONG lSymbols;
ULONG ulCodeLength;
FILE * s_yyc; /* file handle for C output */
if( ! pFileName->szExtension )
pFileName->szExtension = ".java";
@@ -111,19 +110,13 @@ void hb_compGenJava( PHB_FNAME pFileName )
/* specify the function address if it is a defined function or a
external called function */
if( hb_compFunctionFind( pSym->szName ) ) /* is it a defined function ? */
{
hb_fputc( SYM_FUNC );
}
else
{
if( hb_compFunCallFind( pSym->szName ) )
{
hb_fputc( SYM_EXTERN );
}
else
{
hb_fputc( SYM_NOLINK );
}
}
pSym = pSym->pNext;
}
@@ -159,11 +152,9 @@ void hb_compGenJava( PHB_FNAME pFileName )
hb_fputc( ( BYTE ) ( ( ulCodeLength >> 16 ) & 255 ) );
hb_fputc( ( BYTE ) ( ( ulCodeLength >> 24 ) & 255 ) );
/* printf( "Creating output for %s\n", pFunc->szName ); */
lPCodePos = 0;
while( lPCodePos < pFunc->lPCodePos )
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
hb_fputc( pFunc->pCode[ lPCodePos++ ] );
pFunc = pFunc->pNext;
}
@@ -198,6 +189,7 @@ static void hb_fputc( BYTE b )
static void hb_fputs( char * szName )
{
unsigned int nPos = 0;
while( nPos < strlen( szName ) )
hb_fputc( szName[ nPos++ ] );
}

View File

@@ -342,7 +342,7 @@ static void CompiledFileName( FILE * hObjFile, char * szFileName )
putbyte( wLen, hObjFile, &bChk ); /* szFileName length */
while( (bChar = * szFileName++) )
while( ( bChar = * szFileName++ ) != 0 )
putbyte( bChar, hObjFile, &bChk ); /* each of the szFileName characters */
putbyte( 256 - bChk, hObjFile, &bChk ); /* a checksum that will be recalculated by the linker */
@@ -358,7 +358,7 @@ static void CompilerVersion( FILE * hObjFile, char * szVersion )
putword( 3 + wLen, hObjFile, &bChk ); /* now it comes the total length of this OBJ record */
putword( 0, hObjFile, &bChk );
while( ( bChar = * szVersion++ ) )
while( ( bChar = * szVersion++ ) != 0 )
putbyte( bChar, hObjFile, &bChk ); /* each of the szFileName characters */
putbyte( 256 - bChk, hObjFile, &bChk ); /* a checksum that will be recalculated by the linker */
@@ -561,10 +561,10 @@ static void PubDef( FILE * hObjFile, char * szName, USHORT wSegment, USHORT wOff
putbyte( strlen( szPrefix ) + strlen( szName ), hObjFile, &bChk );
szTemp = szPrefix;
while( ( bChar = * szTemp++ ) )
while( ( bChar = * szTemp++ ) != 0 )
putbyte( bChar, hObjFile, &bChk );
while( ( bChar = * szName++ ) )
while( ( bChar = * szName++ ) != 0 )
putbyte( bChar, hObjFile, &bChk );
putword( wOffset, hObjFile, &bChk );

View File

@@ -1,50 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Compiler Pascal source generation
*
* Copyright 1999 {list of individual authors and e-mail addresses}
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "hbcomp.h"
void hb_compGenPascal( PHB_FNAME pFileName )
{
char szFileName[ _POSIX_PATH_MAX ];
if( ! pFileName->szExtension )
pFileName->szExtension = ".pas";
hb_fsFNameMerge( szFileName, pFileName );
printf( "Generating Pascal source output to \'%s\'... ", szFileName );
fflush( stdout );
printf( "\nNot implemented yet!\n" );
}

View File

@@ -1,50 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Compiler Windows resource (.RC) generation
*
* Copyright 1999 {list of individual authors and e-mail addresses}
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "hbcomp.h"
void hb_compGenRC( PHB_FNAME pFileName )
{
char szFileName[ _POSIX_PATH_MAX ];
if( ! pFileName->szExtension )
pFileName->szExtension = ".rc";
hb_fsFNameMerge( szFileName, pFileName );
printf( "Generating Windows resource output to \'%s\'... ", szFileName );
fflush( stdout );
printf( "\nNot implemented yet!\n" );
}

View File

@@ -293,7 +293,10 @@ int main( int argc, char * argv[] )
}
if( !bAnyFiles )
{
hb_compPrintUsage( argv[ 0 ] );
iStatus = EXIT_FAILURE;
}
if( hb_comp_pOutPath )
hb_xfree( hb_comp_pOutPath );
@@ -2370,9 +2373,11 @@ void hb_compOptimizeFrames()
ULONG ulOptimized = 0;
ULONG ulNextByte;
USHORT w;
BYTE * pOptimized;
BYTE * pOptimized;
if ( pFunc == NULL || pFunc->pCode[0] != HB_P_FRAME || pFunc->pCode[3] != HB_P_SFRAME )
if( pFunc == NULL ||
pFunc->pCode[ 0 ] != HB_P_FRAME ||
pFunc->pCode[ 3 ] != HB_P_SFRAME )
return;
pLocal = pFunc->pLocals;
@@ -2399,9 +2404,9 @@ void hb_compOptimizeFrames()
else
bSkipSFRAME = 1;
if ( bSkipFRAME || bSkipSFRAME )
if( bSkipFRAME || bSkipSFRAME )
{
if ( bSkipFRAME && bSkipSFRAME )
if( bSkipFRAME && bSkipSFRAME )
{
pOptimized = ( BYTE * ) hb_xgrab( pFunc->lPCodePos - 6 );
@@ -2425,28 +2430,28 @@ void hb_compOptimizeFrames()
{
pOptimized = ( BYTE * ) hb_xgrab( hb_comp_functions.pLast->lPCodePos - 3 );
pOptimized[0] = pFunc->pCode[0];
pOptimized[1] = pFunc->pCode[1];
pOptimized[2] = pFunc->pCode[2];
pOptimized[ 0 ] = pFunc->pCode[ 0 ];
pOptimized[ 1 ] = pFunc->pCode[ 1 ];
pOptimized[ 2 ] = pFunc->pCode[ 2 ];
ulNextByte = 6;
ulOptimized = 3;
while ( ulNextByte < pFunc->lPCodePos )
while( ulNextByte < pFunc->lPCodePos )
pOptimized[ ulOptimized++ ] = pFunc->pCode[ ulNextByte++ ];
pFunc->lPCodePos -= 3;
}
hb_xfree( (void *) pFunc->pCode );
hb_xfree( ( void * ) pFunc->pCode );
pFunc->pCode = pOptimized;
}
}
int hb_compSort_ULONG( const void * pLeft, const void * pRight )
{
ULONG ulLeft = *( (ULONG *) (pLeft) );
ULONG ulRight = *( (ULONG *) (pRight) );
ULONG ulLeft = *( ( ULONG * ) ( pLeft ) );
ULONG ulRight = *( ( ULONG * ) ( pRight ) );
if( ulLeft == ulRight )
return 0 ;
@@ -2476,7 +2481,7 @@ void hb_compOptimizeJumps( void )
//getchar();
/* Needed so the pasting of PCODE pieces below will work correctly */
qsort( (void *) pNOOPs, hb_comp_functions.pLast->iNOOPs, sizeof( ULONG ), hb_compSort_ULONG );
qsort( ( void * ) pNOOPs, hb_comp_functions.pLast->iNOOPs, sizeof( ULONG ), hb_compSort_ULONG );
/*
for( iNOOP = 0; iNOOP < hb_comp_functions.pLast->iNOOPs; iNOOP++ )
@@ -2972,14 +2977,6 @@ static void hb_compGenOutput( int iLanguage )
hb_compGenJava( hb_comp_pFileName );
break;
case LANG_PASCAL:
hb_compGenPascal( hb_comp_pFileName );
break;
case LANG_RESOURCES:
hb_compGenRC( hb_comp_pFileName );
break;
case LANG_PORT_OBJ:
hb_compGenPortObj( hb_comp_pFileName );
break;

View File

@@ -50,12 +50,10 @@ void hb_compPrintUsage( char * szSelf )
"\n %cgc[<type>] output type: C source (.c) (default)",
"\n <type>: 0=compact, 1=normal, 2=verbose (default)",
#ifdef HARBOUR_OBJ_GENERATION
"\n %cgf output type: Windows/DOS OBJ32 (.obj)",
"\n %cgo output type: Windows/DOS OBJ32 (.obj)",
#endif
"\n %cgh output type: Harbour Portable Object (.hrb)",
"\n %cgj output type: Java source (.java)",
"\n %cgp output type: Pascal source (.pas)",
"\n %cgr output type: Windows resource (.rc)",
"\n %ci<path> add #include file search path",
"\n %cj[0|1] Jump Optimizer 0=disabled 1=enabled (default)",
"\n %cl suppress line number information",

View File

@@ -140,6 +140,9 @@ static void hb_vmPushAlias( void ); /* pushes the current workarea
static void hb_vmPushAliasedField( PHB_SYMB ); /* pushes an aliased field on the eval stack */
static void hb_vmPushAliasedVar( PHB_SYMB ); /* pushes an aliased variable on the eval stack */
static void hb_vmPushBlock( BYTE * pCode, PHB_SYMB pSymbols ); /* creates a codeblock */
static void hb_vmPushOne( void ); /* pushes a 1 onto the stack */
static void hb_vmPushZero( void ); /* pushes a 0 onto the stack */
static void hb_vmPushByte( BYTE bNumber ); /* pushes a 1 byte integer number onto the stack */
static void hb_vmPushDoubleConst( double dNumber, int iWidth, int iDec ); /* Pushes a double constant (pcode) */
static void hb_vmPushMacroBlock( BYTE * pCode, PHB_SYMB pSymbols ); /* creates a macro-compiled codeblock */
static void hb_vmPushLocal( SHORT iLocal ); /* pushes the containts of a local onto the stack */
@@ -2955,32 +2958,32 @@ void hb_vmPushNumber( double dNumber, int iDec )
hb_vmPushDouble( dNumber, hb_set.HB_SET_DECIMALS );
}
void hb_vmPushOne( void )
static void hb_vmPushOne( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushOne()"));
hb_stack.pPos->type = HB_IT_INTEGER;
hb_stack.pPos->item.asInteger.value = ( BYTE ) 1;
hb_stack.pPos->item.asInteger.value = ( int ) 1;
hb_stack.pPos->item.asInteger.length = 10;
hb_stackPush();
}
void hb_vmPushZero( void )
static void hb_vmPushZero( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushZero()"));
hb_stack.pPos->type = HB_IT_INTEGER;
hb_stack.pPos->item.asInteger.value = ( BYTE ) 0;
hb_stack.pPos->item.asInteger.value = ( int ) 0;
hb_stack.pPos->item.asInteger.length = 10;
hb_stackPush();
}
void hb_vmPushByte( BYTE bNumber )
static void hb_vmPushByte( BYTE bNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushInteger(%i)", bNumber));
HB_TRACE(HB_TR_DEBUG, ("hb_vmPushByte(%i)", bNumber));
hb_stack.pPos->type = HB_IT_INTEGER;
hb_stack.pPos->item.asInteger.value = bNumber;
hb_stack.pPos->item.asInteger.value = ( int ) bNumber;
hb_stack.pPos->item.asInteger.length = 10;
hb_stackPush();
}