* include/hbcomp.h
* include/hberrors.h
* include/hbexpra.c
* include/hbexprb.c
* include/hbexprop.h
* include/hbhash.h
* include/hbmacro.h
* include/hbpcode.h
* source/common/Makefile
* source/common/expropt1.c
* source/common/expropt2.c
* source/common/hbhash.c
* source/compiler/expropta.c
* source/compiler/exproptb.c
* source/compiler/genc.c
* source/compiler/harbour.c
* source/compiler/harbour.l
* source/compiler/harbour.y
* source/compiler/hbfix.c
* source/compiler/hbgenerr.c
* source/compiler/hbident.c
* source/compiler/hbpcode.c
* source/macro/macro.l
* source/macro/macro.y
* source/macro/macroa.c
* source/macro/macrob.c
* source/rtl/dates.c
* source/vm/hvm.c
* source/vm/macro.c
+ source/common/hbdate.c
+ tests/ddate.prg
+ tests/switch.prg
+added support for DATE type constants in the following format:
0dYYYYMMDD
for example (see tests/ddate.prg for more):
IF( dDate > 0d20051112 )
+added support for SWITCH command (see tests/switch.prg)
SWITCH <expr>
CASE <integer_expression>
...
[EXIT]
CASE <string_expression>
...
[EXIT]
[OTHERWISE]
...
END
Notice:
- Integer and string expressions can be mixed in a single
SWITCH command with no runtime errors;
- CASE expression have to be resolved at compile time and
the result has to be either an integer or string constant
- if there is no EXIT statement then next CASE is executed
(or OTHERWISE for the last CASE)
For example:
CASE 1+32+2*4
CASE CHR(64)
CASE ASC('A')
CASE "A"+CHR(13)
Notice:
The above changes apply only to FLEX version!
101 lines
2.5 KiB
C
101 lines
2.5 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
|
|
|
|
static HB_HASH_TABLE_PTR s_comp_Identifiers; /* table of identifiers for reuse */
|
|
|
|
/* create a new identifier or return the existing one
|
|
*/
|
|
char * hb_compIdentifierNew( char * szName, BOOL bCopy )
|
|
{
|
|
char * szIdent;
|
|
|
|
szIdent = ( char * )hb_hashTableFind( s_comp_Identifiers, (void *) szName );
|
|
if( !szIdent )
|
|
{
|
|
if( bCopy )
|
|
szIdent = hb_strdup( szName );
|
|
else
|
|
szIdent = szName;
|
|
|
|
hb_hashTableAdd( s_comp_Identifiers, (void *)szIdent, (void *)szIdent );
|
|
}
|
|
|
|
return szIdent;
|
|
}
|
|
|
|
/* returns a hash key */
|
|
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 */
|
|
HB_HASH_FUNC( hb_comp_IdentDel )
|
|
{
|
|
hb_xfree( Value );
|
|
HB_SYMBOL_UNUSED( HashPtr );
|
|
HB_SYMBOL_UNUSED( Cargo );
|
|
return 1;
|
|
}
|
|
|
|
/* compares two identifiers */
|
|
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( )
|
|
{
|
|
s_comp_Identifiers = hb_hashTableCreate( HB_IDENT_TABLE_SIZE, hb_comp_IdentKey,
|
|
hb_comp_IdentDel, hb_comp_IdentComp );
|
|
}
|
|
|
|
/* release identifiers table */
|
|
void hb_compIdentifierClose( )
|
|
{
|
|
hb_hashTableKill( s_comp_Identifiers );
|
|
}
|