From cb4e5e74e06540c891bcfe2957a57953686104f2 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Sun, 5 Aug 2001 19:24:12 +0000 Subject: [PATCH] 2001-08-05 12:15 UTC-0800 Ron Pinkas + include/hbmsetup.h * include/hbmacro.h * Moved #defines of HB_SM_* to new file hbmsetup.h * source/compiler/harbour.c * source/vm/macro.c * source/compiler/genc.c + Added logic to automatically synchronize HB_SETMACRO() level with the -k option supplied to compiler. /* HB_SETMACRO() may still be called explictly, but now specifying any -k option to harbour will automatically provide same level of functionalty in macro compiler. Example: harbour test -kc will restrict the compiler to the Clipper level mode, and will automatically disable extended macro support in that module without requiring: HB_SETMACRO( HB_SM_HARBOUR, .F. ) HB_SETMACRO( HB_SM_XBASE, .F. ) By default all harbour extensions are enabled - you can use -kc, -kx -ki, etc., to disable any unwanted feature. We should still review the need to have -ki which I find absolutley redundant and unproductive. */ --- harbour/ChangeLog | 30 ++++++++++++++++++++++++++++-- harbour/include/hbmacro.h | 10 +--------- harbour/include/hbmsetup.h | 6 ++++++ harbour/source/compiler/genc.c | 21 +++++++++++++++++++++ harbour/source/compiler/harbour.c | 10 ++++++++-- harbour/source/vm/macro.c | 2 +- 6 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 harbour/include/hbmsetup.h diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3784e4d51a..eba7782146 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,29 @@ +2001-08-05 12:15 UTC-0800 Ron Pinkas + + include/hbmsetup.h + * include/hbmacro.h + * Moved #defines of HB_SM_* to new file hbmsetup.h + + * source/compiler/harbour.c + * source/vm/macro.c + * source/compiler/genc.c + + Added logic to automatically synchronize HB_SETMACRO() level with the -k option supplied to compiler. + + /* HB_SETMACRO() may still be called explictly, but now specifying any -k option to harbour will automatically provide same + level of functionalty in macro compiler. Example: + + harbour test -kc + + will restrict the compiler to the Clipper level mode, and will automatically disable extended macro support in that module + without requiring: + + HB_SETMACRO( HB_SM_HARBOUR, .F. ) + HB_SETMACRO( HB_SM_XBASE, .F. ) + + By default all harbour extensions are enabled - you can use -kc, -kx -ki, etc., to disable any unwanted feature. + + We should still review the need to have -ki which I find absolutley redundant and unproductive. + */ + 2001-08-05 22:58 GMT+3 Alexander Kresin * source/vm/memvars.c + Two functions added: hb_memvarGetVarHandle() and hb_memvarGetValueByHandle() @@ -14,10 +40,10 @@ * all options used with -k switch are letter case sensitive * -kc (Clipper compatibility) clears all other switches (minimal set of features) - + *source/compiler/harbour.l * added support for -ki command line switch - + *source/compiler/harbour.sly *source/compiler/harbour.y * fixed line numer issues in generated pcode diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index bbf90afb52..ad8fbf4d73 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -72,6 +72,7 @@ #include "hbvm.h" #include "hbexprop.h" #include "hbpcode.h" +#include "hbmsetup.h" #if defined(HB_EXTERN_C) extern "C" { @@ -100,15 +101,6 @@ extern "C" { #define HB_MACRO_UNKN_SYM 8 /* requested symbol was not found in runtime symbol table */ #define HB_MACRO_UNKN_VAR 16 /* requested variable doesn't exist */ -/* runtime settings for macro compiler */ -#define HB_SM_HARBOUR 1 /* extended Harbour features */ -#define HB_SM_XBASE 2 /* extended xbase compatibility */ -#define HB_SM_PREPROC 4 /* enable/disable commands preprocessing */ -#define HB_SM_SHORTCUTS 8 /* enable/disable sortcuts for logical operators */ -#define HB_SM_PARSER 128 /* address of macro parser (TODO) */ - - - /* Global functions */ extern void hb_macroError( int iError, HB_BISON_PTR pMacro ); diff --git a/harbour/include/hbmsetup.h b/harbour/include/hbmsetup.h new file mode 100644 index 0000000000..f1bb97c514 --- /dev/null +++ b/harbour/include/hbmsetup.h @@ -0,0 +1,6 @@ +/* runtime settings for macro compiler */ +#define HB_SM_HARBOUR 1 /* extended Harbour features */ +#define HB_SM_XBASE 2 /* extended xbase compatibility */ +#define HB_SM_PREPROC 4 /* enable/disable commands preprocessing */ +#define HB_SM_SHORTCUTS 8 /* enable/disable sortcuts for logical operators */ +#define HB_SM_PARSER 128 /* address of macro parser (TODO) */ diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index c44ed2b698..759ba9a093 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -29,6 +29,7 @@ #include #include "hbcomp.h" +#include "hbmsetup.h" static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc ); static void hb_compGenCCompact( PFUNCTION pFunc, FILE * yyc ); @@ -202,6 +203,10 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou hb_comp_szPrefix, pFileName->szName, hb_comp_szPrefix, pFileName->szName ); + + if( hb_comp_Supported ) + fprintf( yyc, "\nextern ULONG hb_macroSetMacro( BOOL bSet, ULONG flag );\n" ); + /* Generate functions data */ pFunc = hb_comp_functions.pFirst; @@ -227,6 +232,22 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou hb_compGenCReadable( pFunc, yyc ); fprintf( yyc, " };\n\n" ); + + if( hb_comp_Supported ) + { + if( hb_comp_Supported & HB_COMPFLAG_HARBOUR ) + { + fprintf( yyc, " hb_macroSetMacro( TRUE, %i );\n\n", HB_SM_HARBOUR ); + } + + if( hb_comp_Supported & HB_COMPFLAG_XBASE ) + { + fprintf( yyc, " hb_macroSetMacro( TRUE, %i );\n\n", HB_SM_XBASE ); + } + + hb_comp_Supported = 0; + } + fprintf( yyc, " hb_vmExecute( pcode, symbols );\n}\n\n" ); pFunc = pFunc->pNext; } diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index b145978b41..e33915bdbd 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -142,7 +142,8 @@ int hb_comp_iLinePRG; INLINES hb_comp_inlines; /* various compatibility flags (-k switch) */ -ULONG hb_comp_Supported = HB_COMPFLAG_HARBOUR; +ULONG hb_comp_Supported; + /* EXTERNAL statement can be placed into any place in a function - this flag is * used to suppress error report generation @@ -185,6 +186,11 @@ int main( int argc, char * argv[] ) hb_comp_pOutPath = NULL; + /* Activate Harbour extensions by default. */ + hb_comp_Supported = HB_COMPFLAG_HARBOUR; + hb_comp_Supported |= HB_COMPFLAG_XBASE; + hb_comp_Supported |= HB_COMPFLAG_HB_INLINE; + /* First check the environment variables */ hb_compChkCompilerSwitch( 0, NULL ); @@ -2235,7 +2241,7 @@ static void hb_compGenVariablePCode( BYTE bPCode, char * szVarName ) bGenCode = hb_comp_bForceMemvars; /* harbour compatibility */ else bGenCode = ( hb_comp_bForceMemvars || bPCode == HB_P_POPVARIABLE ); - + if( bGenCode ) { /* -v switch was used -> assume it is a memvar variable diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 7b2c39e3f0..f74d27b140 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -69,7 +69,7 @@ BOOL hb_comp_bShortCuts = TRUE; /* various flags for macro compiler */ -static ULONG s_macroFlags = (HB_SM_SHORTCUTS | HB_SM_HARBOUR); +static ULONG s_macroFlags = HB_SM_SHORTCUTS; static void hb_macroUseAliased( HB_ITEM_PTR, HB_ITEM_PTR, int ); static void hb_compMemvarCheck( char * szVarName, HB_MACRO_DECL );