From 822c550662ec1b959bb85e8bd85d010642b81777 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 2 Oct 2007 08:52:28 +0000 Subject: [PATCH] 2007-09-28 15:25 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexpra.c + added support for HB_ENUM*([@]) functions - disabled by default can be enabled by HB_USE_ENUM_FUNCTIONS macro * harbour/source/rtl/gttone.c * use assembler code for tone emulation for POCC/XCC compiler only for X86 platforms * harbour/source/rtl/filesys.c * do not include for POCC/XCC * harbour/source/compiler/gencli.c * pacify warning * harbour/config/w32/owatcom.cf * harbour/config/w32/xcc.cf * updated description in header files + harbour/config/w32/pocc.cf + added support for Pelles ISO C Compiler --- harbour/config/w32/owatcom.cf | 2 +- harbour/config/w32/pocc.cf | 84 ++++++++++++++++++++++++++++++++ harbour/config/w32/xcc.cf | 5 +- harbour/include/hbexpra.c | 78 +++++++++++++++++++---------- harbour/source/compiler/gencli.c | 4 +- harbour/source/rtl/filesys.c | 4 +- harbour/source/rtl/gttone.c | 4 +- 7 files changed, 149 insertions(+), 32 deletions(-) create mode 100644 harbour/config/w32/pocc.cf diff --git a/harbour/config/w32/owatcom.cf b/harbour/config/w32/owatcom.cf index 396277bed5..b6ace86338 100644 --- a/harbour/config/w32/owatcom.cf +++ b/harbour/config/w32/owatcom.cf @@ -2,7 +2,7 @@ # $Id$ # # The Harbour project -# GNU MAKE file for Watcom C/C++ 10.x +# GNU MAKE file for Open Watcom C/C++ compiler include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf diff --git a/harbour/config/w32/pocc.cf b/harbour/config/w32/pocc.cf new file mode 100644 index 0000000000..38ab3eedc8 --- /dev/null +++ b/harbour/config/w32/pocc.cf @@ -0,0 +1,84 @@ +# +# $Id$ +# +# The Harbour Project +# GNU MAKE file for Pelles ISO C Compiler + +include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf + +OBJ_EXT = .obj +EXE_EXT = .exe +LIB_PREF = +LIB_EXT = .lib + +CC = pocc.exe +CC_IN = -c +CC_OUT = -Fo +CPPFLAGS = -I. -I$(TOP) -I$(TOP)$(ROOT) + +CPPFLAGS += -Ze -Zx -Go + +# optimizations +CPPFLAGS += -Ot -Ox + +# For Pocket PC and ARM processors (including XScale) +#CPPFLAGS += -Tarm-coff + +# For x86 based CPUs +#CPPFLAGS += -Tx86-coff + +ifneq ($(HB_INC_COMPILE),) +CPPFLAGS += -I$(HB_INC_COMPILE) +endif + +CFLAGS = + +LD = polink.exe +LD_OUT = -OUT: + +# Add all libraries specified in CONTRIBS and LIBS. +ifeq ($(HB_LIB_COMPILE),) +LINKPATHS += $(foreach lib, $(CONTRIBS), -LIBPATH:$(TOP)$(ROOT)contrib/$(lib)/$(HB_ARCH)) +LINKPATHS += $(foreach lib, $(LIBS), -LIBPATH:$(TOP)$(ROOT)source/$(lib)/$(HB_ARCH)) +else +LINKPATHS += -LIBPATH:$(HB_LIB_COMPILE) +endif +LINKLIBS += $(foreach lib, $(CONTRIBS), $(subst lib,,$(lib))$(LIB_EXT)) +LINKLIBS += $(foreach lib, $(LIBS), $(lib)$(LIB_EXT)) + +# If LIBS specifies the rdd library, add all DB drivers. +ifeq ($(findstring rdd,$(LIBS)),rdd) +ifeq ($(HB_LIB_COMPILE),) +LINKPATHS += $(foreach drv, $(HB_DB_DRIVERS), -LIBPATH:$(TOP)$(ROOT)source/rdd/$(drv)/$(HB_ARCH)) +endif +LINKLIBS += $(foreach drv, $(HB_DB_DRIVERS), $(drv)$(LIB_EXT)) +endif + +# Add the specified GT driver library +ifeq ($(findstring rtl,$(LIBS)),rtl) +ifeq ($(HB_LIB_COMPILE),) +LINKPATHS += $(foreach gt, $(HB_GT_LIBS), -LIBPATH:$(TOP)$(ROOT)source/rtl/$(gt)/$(HB_ARCH)) +endif +LINKLIBS += $(foreach gt, $(HB_GT_LIBS), $(gt)$(LIB_EXT)) +endif + +LDFLAGS = $(LINKPATHS) kernel32.lib user32.lib \ + winspool.lib ole32.lib oleaut32.lib uuid.lib \ + comctl32.lib mapi32.lib advapi32.lib \ + gdi32.lib mpr.lib wsock32.lib + +ifeq ($(HB_GT_DEFAULT),gtgui) +LDFLAGS += /SUBSYSTEM:WINDOWS +else +ifeq ($(HB_GT_LIB),gtgui) +LDFLAGS += /SUBSYSTEM:WINDOWS +endif +endif + +# mpr wsock32 ws2_32 mapi32 + +AR = polib.exe +ARFLAGS = $(A_USR) +AR_RULE = $(AR) $(ARFLAGS) /out:$@ $(^F) + +include $(TOP)$(ROOT)config/rules.cf diff --git a/harbour/config/w32/xcc.cf b/harbour/config/w32/xcc.cf index 83ea7906a0..1a119745ea 100644 --- a/harbour/config/w32/xcc.cf +++ b/harbour/config/w32/xcc.cf @@ -2,7 +2,7 @@ # $Id$ # # The Harbour Project -# GNU MAKE file for Borland C/C++ 32bit (4.x, 5.x) +# GNU MAKE file for xHarbour.com POCC compiler include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf @@ -18,6 +18,9 @@ CPPFLAGS = -I. -I$(TOP) -I$(TOP)$(ROOT) # disabled - it produces bad code #CPPFLAGS += -Ot +# For Pocket PC and ARM processors (including XScale) +#CPPFLAGS += /Tarm-coff + ifneq ($(HB_INC_COMPILE),) CPPFLAGS += -I$(HB_INC_COMPILE) endif diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index ba973341cf..991e42ad6f 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -128,42 +128,70 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM * at runtime - in this case pName is an expression of HB_ET_MACRO type * e.g. &MyVar() */ - int iCount; + int iLen; HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewFunCall(%s)", pName->value.asSymbol)); - iCount = ( int ) hb_compExprParamListLen( pParms ); + iLen = strlen( pName->value.asSymbol ); - /* TODO: EMPTY() (not done by Clipper) */ - if( iCount == 0 ) +#if !defined( HB_MACRO_SUPPORT ) && defined( HB_USE_ENUM_FUNCTIONS ) + if( iLen > 7 && memcmp( "HB_ENUM", pName->value.asSymbol, 7 ) == 0 ) { -#if !defined( HB_MACRO_SUPPORT ) && defined( HB_EMULATE_ENUMINDEX_FUNC ) - if( strcmp( "HB_ENUMINDEX", pName->value.asSymbol ) == 0 ) + char * szMessage = NULL; + + if( iLen == 12 && memcmp( "INDEX", pName->value.asSymbol + 7, 5 ) == 0 ) + szMessage = "__ENUMINDEX"; + else if( iLen == 12 && memcmp( "VALUE", pName->value.asSymbol + 7, 5 ) == 0 ) + szMessage = "__ENUMVALUE"; + else if( iLen == 11 && memcmp( "BASE", pName->value.asSymbol + 7, 4 ) == 0 ) + szMessage = "__ENUMBASE"; + else if( iLen == 10 && memcmp( "KEY", pName->value.asSymbol + 7, 3 ) == 0 ) + szMessage = "__ENUMKEY"; + + if( szMessage ) { - HB_ENUMERATOR_PTR pForVar, pEnumVar = NULL; - pForVar = HB_COMP_PARAM->functions.pLast->pEnum; - if( pForVar ) + int iCount = ( int ) hb_compExprParamListLen( pParms ); + char * szName = NULL; + + if( iCount == 0 ) { - while( pForVar ) + HB_ENUMERATOR_PTR pForVar, pEnumVar = NULL; + pForVar = HB_COMP_PARAM->functions.pLast->pEnum; + if( pForVar ) { - if( pForVar->bForEach ) - pEnumVar = pForVar; - pForVar = pForVar->pNext; - } - if( pEnumVar ) - { - HB_COMP_EXPR_DELETE( pParms ); - HB_COMP_EXPR_DELETE( pName ); - return hb_compExprNewMethodCall( hb_compExprNewSend( - hb_compExprNewVar( pEnumVar->szName, HB_COMP_PARAM ), - "__ENUMINDEX", NULL, HB_COMP_PARAM ), NULL ); + while( pForVar ) + { + if( pForVar->bForEach ) + pEnumVar = pForVar; + pForVar = pForVar->pNext; + } + if( pEnumVar ) + szName = pEnumVar->szName; } } + else if( iCount == 1 ) + { + if( pParms->value.asList.pExprList->ExprType == HB_ET_VARIABLE || + pParms->value.asList.pExprList->ExprType == HB_ET_VARREF ) + szName = pParms->value.asList.pExprList->value.asSymbol; + } + if( szName ) + { + HB_COMP_EXPR_DELETE( pParms ); + HB_COMP_EXPR_DELETE( pName ); + return hb_compExprNewMethodCall( hb_compExprNewSend( + hb_compExprNewVar( szName, HB_COMP_PARAM ), + szMessage, NULL, HB_COMP_PARAM ), NULL ); + } } -#endif } - /* TODO: EMPTY() (not done by Clipper) */ - else if( strcmp( "EVAL", pName->value.asSymbol ) == 0 ) + else +#endif + if( hb_compExprParamListLen( pParms ) == 0 ) + { + /* nothing to do, both EVAL and _GET_ below need parameters */ + } + else if( iLen == 4 && memcmp( "EVAL", pName->value.asSymbol, 4 ) == 0 ) { HB_EXPR_PTR pEval; /* Optimize Eval( bBlock, [ArgList] ) to: bBlock:Eval( [ArgList] ) */ @@ -181,7 +209,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_COMP_EXPR_DELETE( pName ); return pEval; } - else if( strcmp( "_GET_", pName->value.asSymbol ) == 0 ) + else if( iLen == 5 && memcmp( "_GET_", pName->value.asSymbol, 5 ) == 0 ) { /* Reserved Clipper function used to handle GET variables */ diff --git a/harbour/source/compiler/gencli.c b/harbour/source/compiler/gencli.c index 11871a2971..b9bacc4f53 100644 --- a/harbour/source/compiler/gencli.c +++ b/harbour/source/compiler/gencli.c @@ -60,7 +60,7 @@ void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the IL { char szFileName[ _POSIX_PATH_MAX + 1 ], * szVer; PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst; - PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst; + /* PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst; */ PINLINE pInline; FILE * yyc; /* file handle for IL output */ BOOL bIsPublicFunction ; @@ -70,7 +70,7 @@ void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the IL BOOL bIsFirstFunction = TRUE; HB_SYMBOL_UNUSED( pFunc ); - HB_SYMBOL_UNUSED( pSym ); + /*HB_SYMBOL_UNUSED( pSym );*/ if( ! pFileName->szExtension ) pFileName->szExtension = ".il"; diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 54366126b1..2f1de3ed2d 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -123,7 +123,9 @@ #if ( defined(__DMC__) || defined(__BORLANDC__) || defined(__IBMCPP__) || defined(_MSC_VER) || \ defined(__MINGW32__) || defined(__WATCOMC__) ) && !defined( HB_OS_UNIX ) #include - #include + #if !defined( __POCC__ ) && !defined( __XCC__ ) + #include + #endif #include #include #include diff --git a/harbour/source/rtl/gttone.c b/harbour/source/rtl/gttone.c index 543e6c838b..90515d5762 100644 --- a/harbour/source/rtl/gttone.c +++ b/harbour/source/rtl/gttone.c @@ -86,7 +86,7 @@ static int hb_Inp9x( USHORT usPort ) __emit__(0x32,0xE4); /* ASM XOR AH, AH */ usVal = _AX; - #elif defined( __XCC__ ) + #elif ( defined( __XCC__ ) || defined( __POCC__ ) ) && defined( _M_IX86 ) __asm { mov dx, usPort @@ -123,7 +123,7 @@ static int hb_Outp9x( USHORT usPort, USHORT usVal ) _AL = usVal; __emit__(0xEE); /* ASM OUT DX, AL */ - #elif defined( __XCC__ ) + #elif ( defined( __XCC__ ) || defined( __POCC__ ) ) && defined( _M_IX86 ) __asm { mov dx, usPort