From ec66e96b744643dcb7f46a76cd9895c22676cac1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 31 Dec 2001 12:23:05 +0000 Subject: [PATCH] 2001-12-31 13:22 UTC+0100 Viktor Szakats --- harbour/ChangeLog | 13 +++++ harbour/include/hbdefs.h | 2 - harbour/include/hbtypes.h | 11 ++--- harbour/source/compiler/genc.c | 87 ++++++++++------------------------ 4 files changed, 44 insertions(+), 69 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 37aa47c2bb..3270e202e0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,19 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + to conform with the new startup generation routines + * source/compiler/harbour.c + + BOOL hb_comp_bNoStartUp = FALSE, initialization for option to create + C-source with startup. + * source/compiler/hbusage.c + + description of /n switch + - remove description of /gc3 + % Optimized a bit of code related to the generation of +2002-01-01 12:30 UTC+0700 Andi Jahja + * source/compiler/hbusage.c + * bump Copyright year to 2002 + +2002-01-01 11:15 UTC+0700 Andi Jahja * source/vm/fm.c Memory allocation error was transparently noticed when running hbtest.exe with -DHB_FM_STATISTICS_OFF, fixed. diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index b197aacbab..4531711540 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -230,8 +230,6 @@ typedef PHB_FUNC HB_FUNC_PTR; #define HB_FUNCNAME( funcname ) HB_FUN_##funcname #define HB_FUNC( funcname ) HARBOUR HB_EXPORT HB_FUN_##funcname ( void ) #define HB_FUNC_STATIC( funcname ) static HARBOUR HB_FUN_##funcname ( void ) -#define HB_FUNC_INIT( funcname ) static HARBOUR HB_FUN_##funcname ( void ) -#define HB_FUNC_EXIT( funcname ) static HARBOUR HB_FUN_##funcname ( void ) /* */ diff --git a/harbour/include/hbtypes.h b/harbour/include/hbtypes.h index f3584bc67e..0356b338d1 100644 --- a/harbour/include/hbtypes.h +++ b/harbour/include/hbtypes.h @@ -1,11 +1,10 @@ - /* - * $Id: + * $Id$ */ /* * Harbour Project source code: - * Header file for typedef for maindllp.c + * Header file for typedef for maindllp.c * * Copyright 2001-2002 Luiz Rafael Culik * www - http://www.harbour-project.org @@ -51,8 +50,8 @@ * */ -#ifndef HB_APITYS_H_ -#define HB_APITYS_H_ +#ifndef HB_TYPES_H_ +#define HB_TYPES_H_ #include "hbvm.h" #include "hbapiitm.h" @@ -135,4 +134,4 @@ typedef void ( * HB_XFREE)( void * pMem ); /* frees memory typedef void * ( * HB_XREALLOC)( void * pMem, ULONG ulSize ); /* reallocates memory */ typedef ULONG ( * HB_XSIZE)( void * pMem ); /* returns the size of an allocated memory block */ -#endif +#endif /* HB_TYPES_H_ */ diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 6d3731b901..d5abd56933 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -48,16 +48,12 @@ typedef HB_GENC_FUNC_ * HB_GENC_FUNC_PTR; void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language output */ { char szFileName[ _POSIX_PATH_MAX ]; - PFUNCTION pFunc = hb_comp_functions.pFirst, pFTemp; + PFUNCTION pFunc = hb_comp_functions.pFirst; PCOMSYMBOL pSym = hb_comp_symbols.pFirst; PCOMDECLARED pDeclared; PCOMCLASS pClass; FILE * yyc; /* file handle for C output */ PINLINE pInline = hb_comp_inlines.pFirst; - BOOL bIsPublicFunction ; - BOOL bIsInitFunction ; - BOOL bIsExitFunction ; - BOOL bIsStaticVariable ; if( ! pFileName->szExtension ) pFileName->szExtension = ".c"; @@ -93,29 +89,12 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou /* write functions prototypes for PRG defined functions */ while( pFunc ) { - bIsInitFunction = ( pFunc->cScope & HB_FS_INIT ) ; - bIsExitFunction = ( pFunc->cScope & HB_FS_EXIT ) ; - bIsStaticVariable = ( pFunc == hb_comp_pInitFunc ) ; - bIsPublicFunction = ( pFunc->cScope == HB_FS_PUBLIC ) ; - - /* Is it a PUBLIC FUNCTION/PROCEDURE */ - if ( bIsPublicFunction ) - fprintf( yyc, "HB_FUNC( %s );\n", pFunc->szName ); + if( pFunc == hb_comp_pInitFunc ) + fprintf( yyc, "static HARBOUR hb_INITSTATICS( void );\n" ); /* NOTE: hb_ intentionally in lower case */ + else if( pFunc->cScope & HB_FS_STATIC || pFunc->cScope & HB_FS_INIT || pFunc->cScope & HB_FS_EXIT ) + fprintf( yyc, "HB_FUNC_STATIC( %s );\n", pFunc->szName ); else - /* Is it a STATIC$ */ - if ( bIsStaticVariable ) - fprintf( yyc, "static HARBOUR hb_INITSTATICS( void );\n" ); /* NOTE: hb_ intentionally in lower case */ - else - /* Is it an INIT FUNCTION/PROCEDURE */ - if ( bIsInitFunction ) - fprintf( yyc, "HB_FUNC_INIT( %s );\n", pFunc->szName ); - else - /* Is it an EXIT FUNCTION/PROCEDURE */ - if ( bIsExitFunction ) - fprintf( yyc, "HB_FUNC_EXIT( %s );\n", pFunc->szName ); - else - /* Then it must be a STATIC FUNCTION/PROCEDURE */ - fprintf( yyc, "HB_FUNC_STATIC( %s );\n", pFunc->szName ); + fprintf( yyc, "HB_FUNC( %s );\n", pFunc->szName ); pFunc = pFunc->pNext; } @@ -124,7 +103,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou while( pInline ) { if( pInline->szName ) - fprintf( yyc, "static HB_FUNC( %s );\n", pInline->szName ); + fprintf( yyc, "HB_FUNC_STATIC( %s );\n", pInline->szName ); pInline = pInline->pNext; } @@ -132,14 +111,9 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou pFunc = hb_comp_funcalls.pFirst; while( pFunc ) { - pFTemp = hb_compFunctionFind( pFunc->szName ); - if( ! pFTemp || pFTemp == hb_comp_functions.pFirst ) - { - if( pFTemp == NULL && hb_compInlineFind( pFunc->szName ) == NULL ) - { - fprintf( yyc, "extern HB_FUNC( %s );\n", pFunc->szName ); - } - } + if( hb_compFunctionFind( pFunc->szName ) == NULL && + hb_compInlineFind( pFunc->szName ) == NULL ) + fprintf( yyc, "extern HB_FUNC( %s );\n", pFunc->szName ); pFunc = pFunc->pNext; } @@ -182,7 +156,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou if( ( pSym->cScope != HB_FS_MESSAGE ) && ( pSym->cScope & HB_FS_MESSAGE ) ) /* only for non public symbols */ fprintf( yyc, " | HB_FS_MESSAGE" ); - if ( ( pSym->cScope & HB_FS_FIRST ) && ( hb_comp_iGenCOutput != HB_COMPGENC_NO_STARTUP ) ) + if( pSym->cScope & HB_FS_FIRST ) fprintf( yyc, " | HB_FS_FIRST" ); /* specify the function address if it is a defined function or an @@ -230,30 +204,22 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou while( pFunc ) { + if( pFunc == hb_comp_pInitFunc ) /* Is it STATICS$ */ + fprintf( yyc, "static HARBOUR hb_INITSTATICS( void )" ); /* NOTE: hb_ intentionally in lower case */ + else if( pFunc->cScope & HB_FS_STATIC || pFunc->cScope & HB_FS_INIT || pFunc->cScope & HB_FS_EXIT ) + { + fprintf( yyc, "HB_FUNC_STATIC( %s )", pFunc->szName ); - bIsInitFunction = ( pFunc->cScope & HB_FS_INIT ) ; - bIsExitFunction = ( pFunc->cScope & HB_FS_EXIT ) ; - bIsStaticVariable = ( pFunc == hb_comp_pInitFunc ) ; - bIsPublicFunction = ( pFunc->cScope == HB_FS_PUBLIC ) ; - - if ( bIsPublicFunction ) - /* Is it a PUBLIC FUNCTION/PROCEDURE */ - fprintf( yyc, "HB_FUNC( %s )", pFunc->szName ); + if( hb_comp_iGenCOutput != HB_COMPGENC_COMPACT ) + { + if( pFunc->cScope & HB_FS_INIT ) + fprintf( yyc, " /* INIT */" ); + if( pFunc->cScope & HB_FS_EXIT ) + fprintf( yyc, " /* EXIT */" ); + } + } else - /* Is it STATICS$ */ - if( bIsStaticVariable ) - fprintf( yyc, "static HARBOUR hb_INITSTATICS( void )" ); /* NOTE: hb_ intentionally in lower case */ - else - if ( bIsInitFunction ) - /* Is it an INIT FUNCTION/PROCEDURE */ - fprintf( yyc, "HB_FUNC_INIT( %s )", pFunc->szName ); - else - /* Is it an EXIT FUNCTION/PROCEDURE */ - if ( bIsExitFunction ) - fprintf( yyc, "HB_FUNC_EXIT( %s )", pFunc->szName ); - else - /* Then it must be a STATIC FUNCTION/PROCEDURE */ - fprintf( yyc, "HB_FUNC_STATIC( %s )", pFunc->szName ); + fprintf( yyc, "HB_FUNC( %s )", pFunc->szName ); fprintf( yyc, "\n{\n static const BYTE pcode[] =\n {\n" ); @@ -287,7 +253,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou if( pInline->szName ) { - fprintf( yyc, "static HB_FUNC( %s )\n", pInline->szName ); + fprintf( yyc, "HB_FUNC_STATIC( %s )\n", pInline->szName ); } fprintf( yyc, "%s", pInline->pCode ); pInline = pInline->pNext; @@ -1970,7 +1936,6 @@ static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc ) fprintf( yyc, "/* %05li */\n", pFunc->lPCodePos ); } - static void hb_compGenCCompact( PFUNCTION pFunc, FILE * yyc ) { ULONG lPCodePos = 0;