Files
harbour-core/harbour/source/compiler/hbident.c
Przemyslaw Czerpak 86333ba271 2008-09-18 07:21 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
    * use assembler version of atomic inc/dec operation in all x86 based
      GCC builds - it should noticeable improve OS2 MT build speed,
      please test.

  * harbour/include/hbcomp.h
  * harbour/include/hbapicdp.h
  * harbour/include/hbcompdf.h
  * harbour/include/hbgtcore.h
  * harbour/include/hbapifs.h
  * harbour/include/hbwince.h
  * harbour/include/hbexpra.c
  * harbour/include/hbexprop.h
  * harbour/include/hbmacro.h
  * harbour/include/hbapigt.h
  * harbour/include/hbapi.h
  * harbour/include/hbapiitm.h
  * harbour/include/hbexprb.c
  * harbour/source/pp/ppcore.c
  * harbour/source/pp/hbpp.c
  * harbour/source/vm/macro.c
  * harbour/source/vm/cmdarg.c
  * harbour/source/vm/arrays.c
  * harbour/source/vm/extrap.c
  * harbour/source/vm/memvars.c
  * harbour/source/vm/eval.c
  * harbour/source/vm/extend.c
  * harbour/source/vm/set.c
  * harbour/source/main/harbour.c
  * harbour/source/common/hbfsapi.c
  * harbour/source/common/reserved.c
  * harbour/source/common/expropt1.c
  * harbour/source/macro/macro.yyc
  * harbour/source/macro/macro.y
  * harbour/source/macro/macro.yyh
  * harbour/source/macro/macrolex.c
  * harbour/source/rtl/gtdos/gtdos.c
  * harbour/source/rtl/gtwin/gtwin.c
  * harbour/source/rtl/gtxwc/gtxwc.c
  * harbour/source/rtl/gtos2/gtos2.c
  * harbour/source/rtl/hbgtcore.c
  * harbour/source/rtl/cdpapi.c
  * harbour/source/rtl/gtcrs/gtcrs.c
  * harbour/source/rtl/hbtoken.c
  * harbour/source/rtl/gtchrmap.c
  * harbour/source/rtl/gtstd/gtstd.c
  * harbour/source/rtl/gtsln/mousesln.c
  * harbour/source/rtl/gtsln/gtsln.c
  * harbour/source/rtl/gtsln/kbsln.c
  * harbour/source/rtl/gttrm/gttrm.c
  * harbour/source/rtl/gtpca/gtpca.c
  * harbour/source/rtl/hbhex.c
  * harbour/source/rtl/gtgui/gtgui.c
  * harbour/source/rtl/gt_tpl/gt_tpl.c
  * harbour/source/rtl/gtcgi/gtcgi.c
  * harbour/source/rtl/gtwvt/gtwvt.c
  * harbour/source/rtl/strtran.c
  * harbour/source/rtl/hbinet.c
  * harbour/source/rtl/gtapi.c
  * harbour/source/rtl/filesys.c
  * harbour/source/rdd/dbfntx/dbfntx1.c
  * harbour/source/rdd/dbsql.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
  * harbour/source/rdd/hbsix/sxfname.c
  * harbour/source/compiler/ppcomp.c
  * harbour/source/compiler/hbmain.c
  * harbour/source/compiler/cmdcheck.c
  * harbour/source/compiler/hbdbginf.c
  * harbour/source/compiler/genc.c
  * harbour/source/compiler/hbident.c
  * harbour/source/compiler/hbusage.c
  * harbour/source/compiler/gencc.c
  * harbour/source/compiler/harbour.yyc
  * harbour/source/compiler/harbour.y
  * harbour/contrib/gtalleg/gtalleg.c
  * harbour/contrib/hbct/charlist.c
  * harbour/contrib/hbct/charmix.c
  * harbour/contrib/hbct/screen1.c
  * harbour/contrib/hbct/atrepl.c
  * harbour/contrib/xhb/hboutdbg.c
  * harbour/contrib/xhb/hbxml.c
  * harbour/contrib/xhb/hbxml.h
  * harbour/contrib/hbgt/strexpan.c
  * harbour/contrib/hbsqlit3/sqlite3/sqlite3.c
  * harbour/contrib/gtwvg/gtwvg.c
  * harbour/contrib/hbclipsm/status.c
  * harbour/contrib/hbclipsm/gauge.c
  * harbour/contrib/hbmisc/stringsx.c
  * harbour/contrib/hbtip/utils.c
  * harbour/contrib/hbgf/hbgfgtk/msginfo.c
  * harbour/contrib/hbgf/hbgfgtk/harbgtk.h
  * harbour/contrib/hbbmcdx/bmdbfcdx.c
  * harbour/utils/hbmake/hbmgauge.c
    * use const char * instead of char * in places which should be marked
      as const
2008-09-18 05:23:49 +00:00

111 lines
3.0 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
*/
const char * hb_compIdentifierNew( HB_COMP_DECL, const char * szName, int iType )
{
const 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( ( void * ) szName );
return szIdent;
}
/* returns a hash key */
static HB_HASH_FUNC( hb_comp_IdentKey ) /* ULONG func (void *Value, void *Cargo) */
{
ULONG ulSum = 0;
const 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;
}
}