* harbour/common.mak
* harbour/source/compiler/Makefile
* harbour/source/compiler/hbfix.c
+ harbour/source/compiler/hbopt.c
* divided hbfix.c into two separated functions:
- hb_compFixFuncPCode() which only fix generated PCODE updating
local parameters numbers when PARAMETERS is used
- hb_compOptimizePCode() which makes PCODE optimization
It allows to not execute hb_compFixFuncPCode() when PARAMETERS
is not use and execute hb_compOptimizePCode() more then once in
optimization process.
* harbour/hbgtmk.sh
* updated CVS server name
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/source/compiler/complex.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/hbcomp.c
* harbour/source/compiler/hbgenerr.c
* harbour/source/compiler/hbident.c
* changed code for generating in PCODE line numbers and module names
there was serious problem with line numbers and module names in old
code - in many cases line numbers were not generated at all or
generated in wrong places. Also file module name was not updated
when inside of function some code was included with #include
For such situation now modified version of HB_P_MODULE is generated
with module name only but without function name, f.e.:
HB_P_MODULE "test.prg:"
exactly the same form of HB_P_MODULE is used in xHarbour.
Debugger code should be updated to recognize such HB_P_MODULE version
Ryszard any chance that you can look at it?
And what about syncing with xHarbour debugger?
I can add some missing functions to compiler and HVM but I do not
want to update next peace of code myself. Sorry but I do not have
enough time. I'd prefer to finish some other things I'm working.
If Ryszard is busy can someone else try to port xHarbour debugger
to Harbour?
111 lines
2.9 KiB
C
111 lines
2.9 KiB
C
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
* The cache for identifiers
|
|
*
|
|
* Copyright 1999 Ryszard Glab <rglab@imid.med.pl>
|
|
* 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, or (at your option)
|
|
* any later version.
|
|
*
|
|
* 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 software; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
|
*
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#include "hbhash.h"
|
|
#include "hbcomp.h"
|
|
|
|
#define HB_IDENT_TABLE_SIZE 509UL
|
|
|
|
/* create a new identifier or return the existing one
|
|
*/
|
|
char * hb_compIdentifierNew( HB_COMP_DECL, char * szName, int iType )
|
|
{
|
|
char * szIdent;
|
|
|
|
szIdent = ( char * ) hb_hashTableFind( HB_COMP_PARAM->pIdentifiers,
|
|
( void * ) szName );
|
|
if( !szIdent )
|
|
{
|
|
/*
|
|
* In the future we may add direct support for static identifiers
|
|
* so it will not be necessary to allocate separate buffer for them
|
|
*/
|
|
if( iType == HB_IDENT_COPY || iType == HB_IDENT_STATIC )
|
|
szIdent = hb_strdup( szName );
|
|
else
|
|
szIdent = szName;
|
|
|
|
hb_hashTableAdd( HB_COMP_PARAM->pIdentifiers,
|
|
( void * ) szIdent, ( void * ) szIdent );
|
|
}
|
|
else if( iType == HB_IDENT_FREE )
|
|
hb_xfree( szName );
|
|
|
|
return szIdent;
|
|
}
|
|
|
|
/* returns a hash key */
|
|
static HB_HASH_FUNC( hb_comp_IdentKey ) /* ULONG func (void *Value, void *Cargo) */
|
|
{
|
|
ULONG ulSum = 0;
|
|
char *szName = ( char * )Value;
|
|
|
|
while( *szName )
|
|
ulSum += *szName++;
|
|
|
|
HB_SYMBOL_UNUSED( HashPtr );
|
|
HB_SYMBOL_UNUSED( Cargo );
|
|
|
|
return ulSum % HB_IDENT_TABLE_SIZE;
|
|
}
|
|
|
|
/* deletes an identifier */
|
|
static HB_HASH_FUNC( hb_comp_IdentDel )
|
|
{
|
|
hb_xfree( Value );
|
|
HB_SYMBOL_UNUSED( HashPtr );
|
|
HB_SYMBOL_UNUSED( Cargo );
|
|
return 1;
|
|
}
|
|
|
|
/* compares two identifiers */
|
|
static HB_HASH_FUNC( hb_comp_IdentComp )
|
|
{
|
|
HB_SYMBOL_UNUSED( HashPtr );
|
|
return strcmp( (char *)Value, (char *)Cargo );
|
|
}
|
|
|
|
/* initialize the hash table for identifiers */
|
|
void hb_compIdentifierOpen( HB_COMP_DECL )
|
|
{
|
|
HB_COMP_PARAM->pIdentifiers = hb_hashTableCreate( HB_IDENT_TABLE_SIZE,
|
|
hb_comp_IdentKey, hb_comp_IdentDel, hb_comp_IdentComp );
|
|
}
|
|
|
|
/* release identifiers table */
|
|
void hb_compIdentifierClose( HB_COMP_DECL )
|
|
{
|
|
if( HB_COMP_PARAM->pIdentifiers )
|
|
{
|
|
hb_hashTableKill( HB_COMP_PARAM->pIdentifiers );
|
|
HB_COMP_PARAM->pIdentifiers = NULL;
|
|
}
|
|
}
|