2001-01-10 18:20 UTC-0800 Ron Pinkas <ron@profit-master.com>
* include/hbcomp.h
* source/compiler/harbour.c
+ Added members szFileName and iLine to structure INLINE, set to originating PRG name and line number.
* source/compiler/genc.c
+ Added #line directive to INLINE generations, so C compile warnings/errors will report source file and line number in PRG.
* source/compiler/harbour.l
* source/compiler/harbour.slx
+ Added Error message if inline C is used with non C output.
+ Added support for {} on same line
* Minor optimization
* include/hberrors.h
* source/compiler/hbgenerr.c
+ Added: "Inline C requires C output generartion, use -gc[n]"
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
2001-01-10 18:20 UTC-0800 Ron Pinkas <ron@profit-master.com>
|
||||
* include/hbcomp.h
|
||||
* source/compiler/harbour.c
|
||||
+ Added members szFileName and iLine to structure INLINE, set to originating PRG name and line number.
|
||||
|
||||
* source/compiler/genc.c
|
||||
+ Added #line directive to INLINE generations, so C compile warnings/errors will report source file and line number in PRG.
|
||||
|
||||
* source/compiler/harbour.l
|
||||
* source/compiler/harbour.slx
|
||||
+ Added Error message if inline C is used with non C output.
|
||||
+ Added support for {} on same line
|
||||
* Minor optimization
|
||||
|
||||
* include/hberrors.h
|
||||
* source/compiler/hbgenerr.c
|
||||
+ Added: "Inline C requires C output generartion, use -gc[n]"
|
||||
|
||||
2001-01-10 22:30 GMT -3 Luiz Rafael Culik <culik@sl.conex.net>
|
||||
*utils/hbmake/hbmake.prg
|
||||
*Fixed an typo on an fwh lib name
|
||||
|
||||
@@ -162,6 +162,8 @@ typedef struct __INLINE
|
||||
char * szName; /* name of a inline function */
|
||||
BYTE * pCode; /* pointer to a memory block where pcode is stored */
|
||||
ULONG lPCodeSize; /* total memory size for pcode */
|
||||
char * szFileName; /* Source file name */
|
||||
int iLine; /* Source line number */
|
||||
struct __INLINE * pNext; /* pointer to the next defined inline */
|
||||
} _INLINE, * PINLINE;
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ extern "C" {
|
||||
#define HB_COMP_ERR_GET_COMPLEX_MACRO 48
|
||||
#define HB_COMP_ERR_INVALID_INLINE 49
|
||||
#define HB_COMP_ERR_TOOMANY_INLINE 50
|
||||
#define HB_COMP_ERR_REQUIRES_C 51
|
||||
|
||||
#define HB_COMP_WARN_AMBIGUOUS_VAR 1
|
||||
#define HB_COMP_WARN_MEMVAR_ASSUMED 2
|
||||
|
||||
@@ -237,6 +237,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
pInline = hb_comp_inlines.pFirst;
|
||||
while( pInline )
|
||||
{
|
||||
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;
|
||||
@@ -265,6 +266,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
{
|
||||
hb_comp_inlines.pFirst = pInline->pNext;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -990,6 +990,8 @@ static PINLINE hb_compInlineNew( char * szName )
|
||||
pInline->pCode = NULL;
|
||||
pInline->lPCodeSize = 0;
|
||||
pInline->pNext = NULL;
|
||||
pInline->szFileName = hb_strdup( hb_comp_files.pLast->szFileName );
|
||||
pInline->iLine = hb_comp_iLine - 1;
|
||||
|
||||
return pInline;
|
||||
}
|
||||
|
||||
@@ -794,57 +794,53 @@ Separator {SpaceTab}
|
||||
}
|
||||
pBuffer = (char*) sBuffer;
|
||||
|
||||
while( *pBuffer && ( *pBuffer == ' ' || *pBuffer == '\t' ) )
|
||||
{
|
||||
while( *pBuffer /* && ( *pBuffer == ' ' || *pBuffer == '\t' ) */ )
|
||||
{
|
||||
if( *pBuffer == '{' )
|
||||
{
|
||||
iBraces++;
|
||||
}
|
||||
else if( *pBuffer == '}' && iBraces > 1 )
|
||||
{
|
||||
iBraces--;
|
||||
}
|
||||
else if( *pBuffer == '}' )
|
||||
{
|
||||
hb_pp_bInline = FALSE;
|
||||
}
|
||||
|
||||
pBuffer++;
|
||||
}
|
||||
}
|
||||
|
||||
if( *pBuffer == '\0' )
|
||||
{
|
||||
goto DigestInline;
|
||||
}
|
||||
else if( *pBuffer == '{' )
|
||||
{
|
||||
iBraces++;
|
||||
}
|
||||
else if( *pBuffer == '}' && iBraces > 1 )
|
||||
{
|
||||
iBraces--;
|
||||
}
|
||||
else if( *pBuffer == '}' )
|
||||
{
|
||||
if( pInline->pCode == NULL )
|
||||
{
|
||||
pInline->pCode = (unsigned char *) hb_xgrab( ( iSize = strlen( (char*) sBuffer ) ) + 1 );
|
||||
strcpy( (char *) pInline->pCode, (char *) sBuffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
pInline->pCode = (unsigned char *) hb_xrealloc( pInline->pCode, pInline->lPCodeSize + ( iSize = strlen( (char*) sBuffer ) ) + 1 );
|
||||
strcpy( (char *) (pInline->pCode + pInline->lPCodeSize), (char *) sBuffer );
|
||||
}
|
||||
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;
|
||||
|
||||
pInline->lPCodeSize += iSize;
|
||||
if( hb_pp_bInline )
|
||||
{
|
||||
goto DigestInline;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( hb_comp_iLanguage != LANG_C )
|
||||
{
|
||||
hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_REQUIRES_C, NULL, NULL );
|
||||
hb_xfree( ( void * ) pInline->pCode );
|
||||
hb_xfree( ( void * ) pInline->szFileName );
|
||||
hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */
|
||||
}
|
||||
|
||||
hb_pp_bInline = FALSE;
|
||||
yylval.string = hb_compIdentifierNew( sInlineSym, TRUE );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
if( pInline->pCode == NULL )
|
||||
{
|
||||
pInline->pCode = (unsigned char *) hb_xgrab( ( iSize = strlen( (char*) sBuffer ) ) + 1 );
|
||||
strcpy( (char *) pInline->pCode, (char *) sBuffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
pInline->pCode = (unsigned char *) hb_xrealloc( pInline->pCode, pInline->lPCodeSize + ( iSize = strlen( (char*) sBuffer ) ) + 1 );
|
||||
strcpy( (char *) (pInline->pCode + pInline->lPCodeSize), (char *) sBuffer );
|
||||
}
|
||||
|
||||
pInline->lPCodeSize += iSize;
|
||||
|
||||
goto DigestInline;
|
||||
}
|
||||
}
|
||||
|
||||
%{
|
||||
|
||||
@@ -1035,45 +1035,24 @@ int hb_comp_SLX_CustomAction( int x, int aiHold[], int *ptr_iHold, BOOL *ptr_bIg
|
||||
}
|
||||
pBuffer = (char*) sBuffer;
|
||||
|
||||
while( *pBuffer && ( *pBuffer == ' ' || *pBuffer == '\t' ) )
|
||||
while( *pBuffer /* && ( *pBuffer == ' ' || *pBuffer == '\t' ) */ )
|
||||
{
|
||||
if( *pBuffer == '{' )
|
||||
{
|
||||
iBraces++;
|
||||
}
|
||||
else if( *pBuffer == '}' && iBraces > 1 )
|
||||
{
|
||||
iBraces--;
|
||||
}
|
||||
else if( *pBuffer == '}' )
|
||||
{
|
||||
hb_pp_bInline = FALSE;
|
||||
}
|
||||
|
||||
pBuffer++;
|
||||
}
|
||||
|
||||
if( *pBuffer == '\0' )
|
||||
{
|
||||
goto DigestInline;
|
||||
}
|
||||
else if( *pBuffer == '{' )
|
||||
{
|
||||
iBraces++;
|
||||
}
|
||||
else if( *pBuffer == '}' && iBraces > 1 )
|
||||
{
|
||||
iBraces--;
|
||||
}
|
||||
else if( *pBuffer == '}' )
|
||||
{
|
||||
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;
|
||||
|
||||
hb_pp_bInline = FALSE;
|
||||
yylval.string = hb_compIdentifierNew( sInlineSym, TRUE );
|
||||
iIdentifier++;
|
||||
DEBUG_INFO( printf( "INLINE, Primary Identifier %s Increased to: %i\n", "INLINE", iIdentifier ) );
|
||||
return IDENTIFIER + DONT_REDUCE;
|
||||
}
|
||||
|
||||
if( pInline->pCode == NULL )
|
||||
{
|
||||
pInline->pCode = hb_xgrab( ( iSize = strlen( (char*) sBuffer ) ) + 1 );
|
||||
@@ -1084,10 +1063,27 @@ int hb_comp_SLX_CustomAction( int x, int aiHold[], int *ptr_iHold, BOOL *ptr_bIg
|
||||
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;
|
||||
if( hb_pp_bInline )
|
||||
{
|
||||
goto DigestInline;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( hb_comp_iLanguage != LANG_C )
|
||||
{
|
||||
hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_REQUIRES_C, NULL, NULL );
|
||||
hb_xfree( ( void * ) pInline->pCode );
|
||||
hb_xfree( ( void * ) pInline->szFileName );
|
||||
hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */
|
||||
}
|
||||
|
||||
yylval.string = hb_compIdentifierNew( sInlineSym, TRUE );
|
||||
iIdentifier++;
|
||||
DEBUG_INFO( printf( "INLINE, Primary Identifier %s Increased to: %i\n", "INLINE", iIdentifier ) );
|
||||
return IDENTIFIER + DONT_REDUCE;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -89,7 +89,8 @@ char * hb_comp_szErrors[] =
|
||||
"Code block contains both macro and declared symbol references",
|
||||
"GET contains complex macro",
|
||||
"Unterminated inline block in function: \'%s\'",
|
||||
"Too many inline blocks"
|
||||
"Too many inline blocks",
|
||||
"Inline C requires C output generartion, use -gc[n]"
|
||||
};
|
||||
|
||||
/* Table with parse warnings */
|
||||
|
||||
Reference in New Issue
Block a user