2001-01-13 02:25 UTC-0800 Ron Pinkas <ron@profit-master.com>

* source/compiler/genc.c
   * source/compiler/harbour.c
   * source/pp/pragma.c
     + Added support for #pragma BEGINDUMP ... [#pragma STOPDUMP] or EOF.
       /* BEGINDUMP & STOPDUMP are just a suggestion. */

   * utils/hbpp/hbpp.c
   * source/pp/pplib.c
     + Added empty stub hb_compInlineAdd() (needed by pragma.c)

   * tests/inline_c.prg
     + Added code to demonstrate #pragam BEGINDUMP
This commit is contained in:
Ron Pinkas
2001-01-13 10:28:32 +00:00
parent 5a7c00ebfb
commit 71b35897c3
7 changed files with 139 additions and 18 deletions

View File

@@ -1,3 +1,17 @@
2001-01-13 02:25 UTC-0800 Ron Pinkas <ron@profit-master.com>
* source/compiler/genc.c
* source/compiler/harbour.c
* source/pp/pragma.c
+ Added support for #pragma BEGINDUMP ... [#pragma STOPDUMP] or EOF.
/* BEGINDUMP & STOPDUMP are just a suggestion. */
* utils/hbpp/hbpp.c
* source/pp/pplib.c
+ Added empty stub hb_compInlineAdd() (needed by pragma.c)
* tests/inline_c.prg
+ Added code to demonstrate #pragam BEGINDUMP
2001-01-11 20:10 UTC-0800 Ron Pinkas <ron@profit-master.com>
* source/compiler/harbour.l
* source/compiler/harbour.slx

View File

@@ -103,7 +103,8 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
/* write functions prototypes for inline blocks */
while( pInline )
{
fprintf( yyc, "static HB_FUNC( %s );\n", pInline->szName );
if( pInline->szName )
fprintf( yyc, "static HB_FUNC( %s );\n", pInline->szName );
pInline = pInline->pNext;
}
@@ -231,21 +232,28 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
/* Generate codeblocks data
*/
if( hb_comp_inlines.iCount )
if( hb_comp_cInlineID )
{
fprintf( yyc, "#include \"hbapi.h\"\n" );
pInline = hb_comp_inlines.pFirst;
while( pInline )
}
pInline = hb_comp_inlines.pFirst;
while( pInline )
{
fprintf( yyc, "#line %i \"%s\"\n", pInline->iLine, pInline->szFileName );
if( pInline->szName )
{
fprintf( yyc, "#line %i \"%s\"\n", pInline->iLine, pInline->szFileName );
fprintf( yyc, "static HB_FUNC( %s )\n", pInline->szName );
fprintf( yyc, "%s", pInline->pCode );
pInline = pInline->pNext;
}
fprintf( yyc, "%s", pInline->pCode );
pInline = pInline->pNext;
}
}
else
{
fprintf( yyc, "/* Empty source file */\n\n" );
}
fclose( yyc );
@@ -265,7 +273,10 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
while( pInline )
{
hb_comp_inlines.pFirst = pInline->pNext;
hb_xfree( ( void * ) pInline->pCode );
if( pInline->pCode )
{
hb_xfree( ( void * ) pInline->pCode );
}
hb_xfree( ( void * ) pInline->szFileName );
hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */
pInline = hb_comp_inlines.pFirst;

View File

@@ -1084,16 +1084,18 @@ PINLINE hb_compInlineAdd( char * szFunName )
PINLINE pInline;
PCOMSYMBOL pSym;
pSym = hb_compSymbolFind( szFunName, NULL );
if( ! pSym )
if( szFunName )
{
pSym = hb_compSymbolAdd( szFunName, NULL );
pSym = hb_compSymbolFind( szFunName, NULL );
if( ! pSym )
{
pSym = hb_compSymbolAdd( szFunName, NULL );
}
if( pSym )
{
pSym->cScope |= HB_FS_STATIC;
}
}
if( pSym )
{
pSym->cScope |= HB_FS_STATIC;
}
pInline = hb_compInlineNew( szFunName );
if( hb_comp_inlines.iCount == 0 )
@@ -1304,7 +1306,7 @@ PINLINE hb_compInlineFind( char * szFunctionName )
while( pInline )
{
if( ! strcmp( pInline->szName, szFunctionName ) )
if( pInline->szName && strcmp( pInline->szName, szFunctionName ) == 0 )
return pInline;
else
{

View File

@@ -61,14 +61,17 @@ int hb_comp_iLine; /* currently parsed file line number */
BOOL hb_comp_bPPO = FALSE; /* flag indicating, is ppo output needed */
BOOL hb_comp_bStartProc = TRUE; /* holds if we need to create the starting procedure */
BOOL hb_comp_bLineNumbers = TRUE; /* holds if we need pcodes with line numbers */
#if 0
BOOL hb_comp_bShortCuts = TRUE; /* .and. & .or. expressions shortcuts */
#endif
int hb_comp_iWarnings = 0; /* enable parse warnings */
BOOL hb_comp_bAutoMemvarAssume = FALSE; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
BOOL hb_comp_bForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
BOOL hb_comp_bDebugInfo = FALSE; /* holds if generate debugger required info */
int hb_comp_iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */
FILE *hb_comp_yyppo = NULL;
static jmp_buf s_env;
@@ -154,5 +157,11 @@ void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, const c
HB_SYMBOL_UNUSED( szWarning2 );
}
PINLINE hb_compInlineAdd( char * szFunName )
{
HB_SYMBOL_UNUSED( szFunName );
return NULL;
}
#endif

View File

@@ -169,6 +169,70 @@ void hb_pp_ParsePragma( char * szLine )
hb_comp_bAutoMemvarAssume = StringToBool( szLine, hb_comp_bAutoMemvarAssume );
DebugPragma( szLine, -1, hb_comp_bAutoMemvarAssume );
}
else if( memcmp( szLine, "BEGINDUMP", PRAGMAS_LEN ) == 0 )
{
char sBuffer[ HB_PP_STR_SIZE ], *pBuffer, sDirective[9] ;
int iSize;
extern BOOL hb_pp_bInline;
PINLINE pInline;
hb_pp_bInline = TRUE;
pInline = hb_compInlineAdd( NULL );
DigestInline :
iSize = hb_pp_Internal( hb_comp_bPPO ? hb_comp_yyppo : NULL, sBuffer );
if( iSize == 0 )
{
hb_pp_bInline = FALSE;
return;
}
pBuffer = (char*) sBuffer;
while( *pBuffer == ' ' || *pBuffer == '\t' )
{
pBuffer++;
}
if( *pBuffer == '#' )
{
pBuffer++;
while( *pBuffer == ' ' || *pBuffer == '\t' )
{
pBuffer++;
}
hb_strupr( strncpy( sDirective, pBuffer, 6 ) );
if( memcmp( sDirective, "PRAGMA", 6 ) == 0 )
{
pBuffer += 6;
}
while( *pBuffer == ' ' || *pBuffer == '\t' )
{
pBuffer++;
}
hb_strupr( strncpy( sDirective, pBuffer, 8 ) );
if( memcmp( sDirective, "STOPDUMP", 8 ) == 0 )
{
hb_pp_bInline = FALSE;
return;
}
}
if( pInline->pCode == NULL )
{
pInline->pCode = hb_xgrab( ( iSize = strlen( (char*) sBuffer ) ) + 1 );
strcpy( pInline->pCode, (char*) sBuffer );
}
else
{
pInline->pCode = hb_xrealloc( pInline->pCode, pInline->lPCodeSize + ( iSize = strlen( (char*) sBuffer ) ) + 1 );
strcpy( pInline->pCode + pInline->lPCodeSize, (char*) sBuffer );
}
pInline->lPCodeSize += iSize;
goto DigestInline;
}
else if( memcmp( szLine, "DEBUGINFO", PRAGMAS_LEN ) == 0 )
{
hb_comp_bDebugInfo = StringToBool( szLine, hb_comp_bDebugInfo );

View File

@@ -15,7 +15,11 @@ PROCEDURE MAIN( cLine, cDelim )
NEXT i
QOut( HB_INLINE() )
{ hb_retc( "\na C String, including { and \" \n" ); }
{ hb_retc( "\na C String, including { and \" { \n" ); }
QOut( C_Func() )
QOut( PostDumpTest() )
RETURN
@@ -75,3 +79,13 @@ FUNCTION aTokens( cLine, cDelimiter )
#endif
RETURN aTokens
#pragma BEGINDUMP
HB_FUNC( C_FUNC )
{
hb_retc( "returned from C_FUN\n" );
}
#pragma STOPDUMP
Function PostDumpTest()
RETURN "Post Dump Test"

View File

@@ -78,6 +78,7 @@ BOOL hb_comp_bAutoMemvarAssume = FALSE; /* holds if undeclared variables
BOOL hb_comp_bForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
BOOL hb_comp_bDebugInfo = FALSE; /* holds if generate debugger required info */
int hb_comp_iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */
FILE *hb_comp_yyppo = NULL;
int main( int argc, char * argv[] )
{
@@ -514,3 +515,9 @@ BOOL hb_pp_fopen( char * szFileName )
return TRUE;
}
PINLINE hb_compInlineAdd( char * szFunName )
{
HB_SYMBOL_UNUSED( szFunName );
return NULL;
}