2000-07-09 01:02 UTC+0800 Ron Pinkas <ron@profit-master.com>
* include/hbcomp.h
+ Added: external BOOL hb_comp_bSimpLex
* source/compiler/harbour.c
+ Added: BOOL hb_comp_bSimpLex
+ Added: if( hb_comp_bSimpLex ) tests before releasing name strings of vars, and symbols.
+ Added: call to hb_compReleaseStrings(), if hb_comp_SimpLes is TRUE, after code generation.
* source/compiler/harbour.slx
+ Added: logic to resuse same allocated strings when string for identifier was perviously allocated.
+ Added: INIT_ACTION macro to set hb_comp_bSimpLex to TRUE.
+ Added: Function hb_compReleaseStrings()
* source/compiler/harbour.l
+ Added: empty Function hb_compReleaseStrings() to avoid link error.
* source/compiler/hbslex.c
* source/compiler/simplex.c
* Moved standard #includes from simplex to hbslex.
This commit is contained in:
@@ -1,3 +1,24 @@
|
||||
2000-07-09 01:02 UTC+0800 Ron Pinkas <ron@profit-master.com>
|
||||
* include/hbcomp.h
|
||||
+ Added: external BOOL hb_comp_bSimpLex
|
||||
|
||||
* source/compiler/harbour.c
|
||||
+ Added: BOOL hb_comp_bSimpLex
|
||||
+ Added: if( hb_comp_bSimpLex ) tests before releasing name strings of vars, and symbols.
|
||||
+ Added: call to hb_compReleaseStrings(), if hb_comp_SimpLes is TRUE, after code generation.
|
||||
|
||||
* source/compiler/harbour.slx
|
||||
+ Added: logic to resuse same allocated strings when string for identifier was perviously allocated.
|
||||
+ Added: INIT_ACTION macro to set hb_comp_bSimpLex to TRUE.
|
||||
+ Added: Function hb_compReleaseStrings()
|
||||
|
||||
* source/compiler/harbour.l
|
||||
+ Added: empty Function hb_compReleaseStrings() to avoid link error.
|
||||
|
||||
* source/compiler/hbslex.c
|
||||
* source/compiler/simplex.c
|
||||
* Moved standard #includes from simplex to hbslex.
|
||||
|
||||
2000-07-08 19:50 UTC+0800 Ron Pinkas <ron@profit-master.com>
|
||||
* source\compiler\simplex.c
|
||||
* source\compiler\harbour.slx
|
||||
|
||||
@@ -476,6 +476,7 @@ extern char * hb_comp_szWarnings[];
|
||||
extern char * hb_pp_STD_CH;
|
||||
extern BOOL hb_comp_bAutoOpen;
|
||||
extern BOOL hb_comp_bError;
|
||||
extern BOOL hb_comp_bSimpLex;
|
||||
|
||||
/* /GC command line setting types */
|
||||
#define HB_COMPGENC_COMPACT 0
|
||||
|
||||
@@ -129,6 +129,7 @@ char * hb_comp_szDeclaredFun = NULL;
|
||||
|
||||
BOOL hb_comp_bAutoOpen = TRUE;
|
||||
BOOL hb_comp_bError = FALSE;
|
||||
BOOL hb_comp_bSimpLex = FALSE;
|
||||
|
||||
/* EXTERNAL statement can be placed into any place in a function - this flag is
|
||||
* used to suppress error report generation
|
||||
@@ -1126,7 +1127,9 @@ PFUNCTION hb_compFunctionKill( PFUNCTION pFunc )
|
||||
pVar = pFunc->pLocals;
|
||||
pFunc->pLocals = pVar->pNext;
|
||||
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
|
||||
hb_xfree( ( void * ) pVar );
|
||||
}
|
||||
|
||||
@@ -1135,7 +1138,9 @@ PFUNCTION hb_compFunctionKill( PFUNCTION pFunc )
|
||||
pVar = pFunc->pStatics;
|
||||
pFunc->pStatics = pVar->pNext;
|
||||
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
|
||||
hb_xfree( ( void * ) pVar );
|
||||
}
|
||||
|
||||
@@ -1144,11 +1149,15 @@ PFUNCTION hb_compFunctionKill( PFUNCTION pFunc )
|
||||
pVar = pFunc->pFields;
|
||||
pFunc->pFields = pVar->pNext;
|
||||
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
|
||||
if( pVar->szAlias )
|
||||
{
|
||||
hb_xfree( ( void * ) pVar->szAlias );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szAlias );
|
||||
}
|
||||
|
||||
hb_xfree( ( void * ) pVar );
|
||||
}
|
||||
|
||||
@@ -1157,11 +1166,15 @@ PFUNCTION hb_compFunctionKill( PFUNCTION pFunc )
|
||||
pVar = pFunc->pMemvars;
|
||||
pFunc->pMemvars = pVar->pNext;
|
||||
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
|
||||
if( pVar->szAlias )
|
||||
{
|
||||
hb_xfree( ( void * ) pVar->szAlias );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szAlias );
|
||||
}
|
||||
|
||||
hb_xfree( ( void * ) pVar );
|
||||
}
|
||||
|
||||
@@ -1170,11 +1183,15 @@ PFUNCTION hb_compFunctionKill( PFUNCTION pFunc )
|
||||
pVar = pFunc->pPrivates;
|
||||
pFunc->pPrivates = pVar->pNext;
|
||||
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szName );
|
||||
|
||||
if( pVar->szAlias )
|
||||
{
|
||||
hb_xfree( ( void * ) pVar->szAlias );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pVar->szAlias );
|
||||
}
|
||||
|
||||
hb_xfree( ( void * ) pVar );
|
||||
}
|
||||
|
||||
@@ -1197,7 +1214,9 @@ PCOMSYMBOL hb_compSymbolKill( PCOMSYMBOL pSym )
|
||||
{
|
||||
PCOMSYMBOL pNext = pSym->pNext;
|
||||
|
||||
hb_xfree( ( void * ) pSym->szName );
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pSym->szName );
|
||||
|
||||
hb_xfree( ( void * ) pSym );
|
||||
|
||||
return pNext;
|
||||
@@ -3247,7 +3266,10 @@ void hb_compCodeBlockEnd( void )
|
||||
hb_compGenPCode2( HB_LOBYTE( wPos ), HB_HIBYTE( wPos ), ( BOOL ) 0 );
|
||||
|
||||
pFree = pVar;
|
||||
hb_xfree( ( void * ) pFree->szName );
|
||||
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pFree->szName );
|
||||
|
||||
pVar = pVar->pNext;
|
||||
hb_xfree( ( void * ) pFree );
|
||||
}
|
||||
@@ -3265,7 +3287,10 @@ void hb_compCodeBlockEnd( void )
|
||||
|
||||
/* free used variables */
|
||||
pFree = pVar;
|
||||
hb_xfree( ( void * ) pFree->szName );
|
||||
|
||||
if( ! hb_comp_bSimpLex )
|
||||
hb_xfree( ( void * ) pFree->szName );
|
||||
|
||||
pVar = pVar->pNext;
|
||||
hb_xfree( ( void * ) pFree );
|
||||
}
|
||||
@@ -3610,6 +3635,9 @@ int hb_compCompile( char * szPrg, int argc, char * argv[] )
|
||||
printf( "\rLines %i, Functions/Procedures %i\n", hb_comp_iLine, hb_comp_iFunctionCnt );
|
||||
|
||||
hb_compGenOutput( hb_comp_iLanguage );
|
||||
|
||||
if( hb_comp_bSimpLex )
|
||||
hb_compReleaseStrings();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1915,6 +1915,10 @@ static int yy_ConvertNumber( char * szBuffer )
|
||||
}
|
||||
}
|
||||
|
||||
void hb_compReleaseStrings( void )
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HB_NESTED_COMPILE
|
||||
void * hb_compGet_YY_CURRENT_BUFFER()
|
||||
{
|
||||
|
||||
@@ -44,8 +44,10 @@
|
||||
int yy_lex_input( char *, int );
|
||||
#define YY_INPUT( buf, result, max_size ) result = yy_lex_input( buf, max_size );
|
||||
|
||||
static int iTexts = 0;
|
||||
char * aTexts[256];
|
||||
static int iTexts = 0, iStrings = 0, iString;
|
||||
static char * aTexts[256];
|
||||
static char * aStrings[16384];
|
||||
static char * pString;
|
||||
|
||||
/* ----------------------------------------------------- Language Definitions. ---------------------------------------------------- */
|
||||
|
||||
@@ -834,7 +836,7 @@ LANGUAGE_RULES_ARE {
|
||||
#define NEW_LINE_ACTION() \
|
||||
while( iTexts ) \
|
||||
{ \
|
||||
/* printf( "Releasing Text: %i = %s At: %i\n", iTexts, aTexts[iTexts - 1], aTexts[iTexts - 1] ); */ \
|
||||
DEBUG_INFO( printf( "Releasing short term Text: %i = %s At: %i\n", iTexts, aTexts[iTexts - 1], aTexts[iTexts - 1] ) ); \
|
||||
iTexts--; \
|
||||
hb_xfree( aTexts[iTexts] ); \
|
||||
}\
|
||||
@@ -953,15 +955,35 @@ LANGUAGE_RULES_ARE {
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
DEBUG_INFO( printf( "Element \"%s\" is IDENTIFIER\n", sToken ) );\
|
||||
DEBUG_INFO( printf( "Element \"%s\" is IDENTIFIER\n", yytext ) );\
|
||||
\
|
||||
/* Plain Var. */\
|
||||
yytext = hb_strdup( yytext );\
|
||||
/* aTexts[iTexts++] = yytext; */\
|
||||
/* printf( "Text %i At: %i for %s\n", iTexts, aTexts[iTexts - 1], aTexts[iTexts - 1] ); */\
|
||||
iString = 0; \
|
||||
while( iString < iStrings ) \
|
||||
{ \
|
||||
if( strcmp( yytext, aStrings[ iString ] ) == 0 ) \
|
||||
{ \
|
||||
pString = aStrings[ iString ]; \
|
||||
break; \
|
||||
} \
|
||||
iString++; \
|
||||
} \
|
||||
\
|
||||
yylval.string = yytext;\
|
||||
iRet = IDENTIFIER;\
|
||||
if( iString < iStrings ) \
|
||||
{ \
|
||||
yytext = pString; \
|
||||
DEBUG_INFO( printf( "Re-Using Allocation for String \"%s\"\n", yytext ) ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
yytext = hb_strdup( yytext ); \
|
||||
aStrings[iStrings++] = yytext; \
|
||||
\
|
||||
/* aTexts[iTexts++] = yytext; */ \
|
||||
DEBUG_INFO( printf( "Allocated long term String \"%s\"\n", yytext ) ); \
|
||||
} \
|
||||
\
|
||||
yylval.string = yytext; \
|
||||
iRet = IDENTIFIER; \
|
||||
}\
|
||||
}\
|
||||
else\
|
||||
@@ -1377,6 +1399,9 @@ LANGUAGE_RULES_ARE {
|
||||
x = 0;\
|
||||
}
|
||||
|
||||
#undef INIT_ACTION()
|
||||
#define INIT_ACTION() hb_comp_bSimpLex = TRUE;
|
||||
|
||||
int yy_lex_input( char *buffer, int iBufferSize )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( buffer );
|
||||
@@ -1384,3 +1409,15 @@ int yy_lex_input( char *buffer, int iBufferSize )
|
||||
|
||||
return hb_pp_Internal( hb_comp_bPPO ? hb_comp_yyppo : NULL, buffer );
|
||||
}
|
||||
|
||||
void hb_compReleaseStrings( void )
|
||||
{
|
||||
DEBUG_INFO( printf( "Releasing: %i Strings\n", iStrings ) );
|
||||
|
||||
iString = 0;
|
||||
while( iString < iStrings )
|
||||
{
|
||||
hb_xfree( aStrings[ iString ] );
|
||||
iString++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
#include "hbcomp.h"
|
||||
#include "harboury.h"
|
||||
#include "hbsetup.h"
|
||||
#include "hberrors.h"
|
||||
#include "hbdefs.h"
|
||||
|
||||
#define SLX_RULES "harbour.slx"
|
||||
|
||||
#include "simplex.c"
|
||||
|
||||
@@ -23,11 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include "hbcomp.h"
|
||||
#include "harboury.h"
|
||||
#include "hbsetup.h"
|
||||
#include "hberrors.h"
|
||||
#include "hbdefs.h"
|
||||
|
||||
/* These are NOT overidable (yet). */
|
||||
#define MAX_MATCH 4
|
||||
@@ -90,6 +85,9 @@ typedef struct _LEX_PAIR
|
||||
#define LEX_CUSTOM_ACTION -65
|
||||
#define ERR_TOO_COMPLEX_RULE -66
|
||||
#define YY_BUF_SIZE 16384
|
||||
|
||||
|
||||
#define INIT_ACTION()
|
||||
#define INTERCEPT_ACTION(x)
|
||||
#define CUSTOM_ACTION(x)
|
||||
#define NEW_LINE_ACTION()
|
||||
@@ -832,6 +830,12 @@ int yylex( void /*YYSTYPE * yylval*/ )
|
||||
}
|
||||
*/
|
||||
|
||||
if( bStart )
|
||||
{
|
||||
bStart = FALSE;
|
||||
INIT_ACTION();
|
||||
}
|
||||
|
||||
YY_INPUT( (char*) szLexBuffer, iSize, YY_BUF_SIZE );
|
||||
|
||||
if( iSize )
|
||||
|
||||
Reference in New Issue
Block a user