From 8ce0d03aa081f5c8c23ad367dd0ace79095de921 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 9 Mar 2007 03:44:42 +0000 Subject: [PATCH] 2007-03-09 04:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/common.mak * harbour/makefile.bc * harbour/makefile.vc * harbour/bin/hb-func.sh * harbour/config/global.cf * harbour/include/error.ch * harbour/include/hbcomp.h * harbour/include/hbcompdf.h * harbour/include/hbexpra.c * harbour/include/hbexprb.c - harbour/include/hbexprc.c * harbour/include/hbexprop.h * harbour/include/hbmacro.h * harbour/source/Makefile * harbour/source/common/expropt1.c * harbour/source/common/expropt2.c * harbour/source/compiler/Makefile - harbour/source/compiler/exproptc.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/hbmain.c * harbour/source/compiler/hbpcode.c * harbour/source/macro/Makefile * harbour/source/macro/macro.y * harbour/source/macro/macro.yyc - harbour/source/macro/macroc.c + harbour/source/main/Makefile + harbour/source/main/harbour.c * harbour/source/vm/macro.c * resolved name conflicts between compiler and macro compiler. Now new compiler library is created. There are some things which can be improved and cleaned yet but it's enough to create single binaries with compiler+HVM+RTLs. I updated non GNU make files but I cannot tested the modifications - please check and fix me if necessary --- harbour/ChangeLog | 40 + harbour/bin/hb-func.sh | 2 +- harbour/common.mak | 61 +- harbour/config/global.cf | 2 +- harbour/include/error.ch | 3 + harbour/include/hbcomp.h | 51 +- harbour/include/hbcompdf.h | 18 + harbour/include/hbexpra.c | 485 +---- harbour/include/hbexprb.c | 1649 +++++++++++++---- harbour/include/hbexprc.c | 942 ---------- harbour/include/hbexprop.h | 40 +- harbour/include/hbmacro.h | 70 +- harbour/makefile.bc | 10 +- harbour/makefile.vc | 18 +- harbour/source/Makefile | 1 + harbour/source/common/expropt1.c | 387 +++- harbour/source/common/expropt2.c | 218 +-- harbour/source/compiler/Makefile | 12 +- harbour/source/compiler/exproptc.c | 10 - harbour/source/compiler/harbour.y | 158 +- harbour/source/compiler/harbour.yyc | 156 +- harbour/source/compiler/hbcomp.c | 139 ++ harbour/source/compiler/hbgenerr.c | 19 - .../source/compiler/{harbour.c => hbmain.c} | 360 +--- harbour/source/compiler/hbpcode.c | 17 +- harbour/source/macro/Makefile | 1 - harbour/source/macro/macro.y | 119 +- harbour/source/macro/macro.yyc | 119 +- harbour/source/macro/macroc.c | 16 - harbour/source/main/Makefile | 16 + harbour/source/main/harbour.c | 367 ++++ harbour/source/vm/macro.c | 208 ++- 32 files changed, 3005 insertions(+), 2709 deletions(-) delete mode 100644 harbour/include/hbexprc.c delete mode 100644 harbour/source/compiler/exproptc.c rename harbour/source/compiler/{harbour.c => hbmain.c} (95%) delete mode 100644 harbour/source/macro/macroc.c create mode 100644 harbour/source/main/Makefile create mode 100644 harbour/source/main/harbour.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 83ced04fba..f44b902117 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,46 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-03-09 04:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/common.mak + * harbour/makefile.bc + * harbour/makefile.vc + * harbour/bin/hb-func.sh + * harbour/config/global.cf + * harbour/include/error.ch + * harbour/include/hbcomp.h + * harbour/include/hbcompdf.h + * harbour/include/hbexpra.c + * harbour/include/hbexprb.c + - harbour/include/hbexprc.c + * harbour/include/hbexprop.h + * harbour/include/hbmacro.h + * harbour/source/Makefile + * harbour/source/common/expropt1.c + * harbour/source/common/expropt2.c + * harbour/source/compiler/Makefile + - harbour/source/compiler/exproptc.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/hbmain.c + * harbour/source/compiler/hbpcode.c + * harbour/source/macro/Makefile + * harbour/source/macro/macro.y + * harbour/source/macro/macro.yyc + - harbour/source/macro/macroc.c + + harbour/source/main/Makefile + + harbour/source/main/harbour.c + * harbour/source/vm/macro.c + * resolved name conflicts between compiler and macro compiler. + Now new compiler library is created. + There are some things which can be improved and cleaned yet + but it's enough to create single binaries with compiler+HVM+RTLs. + I updated non GNU make files but I cannot tested the modifications + - please check and fix me if necessary + 2007-03-05 23:30 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbcompdf.h * harbour/include/hbexprb.c diff --git a/harbour/bin/hb-func.sh b/harbour/bin/hb-func.sh index d255d799ae..f722aaa16f 100644 --- a/harbour/bin/hb-func.sh +++ b/harbour/bin/hb-func.sh @@ -64,7 +64,7 @@ mk_hbgetlibs() { if [ -z "$@" ] then - echo -n "vm pp rtl rdd dbffpt dbfcdx dbfntx hsx hbsix usrrdd ${HB_DB_DRVEXT} macro common lang codepage gtcrs gtsln gtxvt gtxwc gtalleg gtcgi gtstd gtpca gtwin gtwvt gtdos gtos2 debug profiler" + echo -n "vm pp rtl rdd dbffpt dbfcdx dbfntx hsx hbsix usrrdd ${HB_DB_DRVEXT} macro common lang codepage gtcrs gtsln gtxvt gtxwc gtalleg gtcgi gtstd gtpca gtwin gtwvt gtdos gtos2 debug profiler compiler" else echo -n "$@" fi diff --git a/harbour/common.mak b/harbour/common.mak index 185474539d..0e9b2bd9d9 100644 --- a/harbour/common.mak +++ b/harbour/common.mak @@ -37,7 +37,9 @@ HB_DEST_DIRS = \ $(DLL_ROOTDIR) \ $(DLL_OBJ_DIR) +MAIN_DIR = source\main COMMON_DIR = source\common +COMPILER_DIR = source\compiler PP_DIR = source\pp VM_DIR = source\vm RTL_DIR = source\rtl @@ -80,7 +82,9 @@ HBPDF_DIR = contrib\pdflib # Where Bcc-Make should look for C and PRG sources ALL_LIB_SRC_DIRS_TMP=\ $(OBJ_DIR);\ +$(MAIN_DIR);\ $(COMMON_DIR);\ +$(COMPILER_DIR);\ $(PP_DIR);\ $(VM_DIR);\ $(RTL_DIR);\ @@ -130,6 +134,7 @@ ALL_SRC_DIRS = $(ALL_SRC_DIRS_TMP: =) # COMMON_LIB = $(LIB_DIR)\common.lib +COMPILER_LIB = $(LIB_DIR)\compiler.lib PP_LIB = $(LIB_DIR)\pp.lib VM_LIB = $(LIB_DIR)\vm.lib RTL_LIB = $(LIB_DIR)\rtl.lib @@ -245,6 +250,35 @@ PP_LIB_OBJS = \ #********************************************************** +COMPILER_LIB_OBJS = \ + $(OBJ_DIR)\hbmain.obj \ + $(OBJ_DIR)\harboury.obj \ + $(OBJ_DIR)\complex.obj \ + $(OBJ_DIR)\cmdcheck.obj \ + $(OBJ_DIR)\hbcomp.obj \ + $(OBJ_DIR)\hbdead.obj \ + $(OBJ_DIR)\hbstripl.obj \ + $(OBJ_DIR)\hbusage.obj \ + $(OBJ_DIR)\hbident.obj \ + $(OBJ_DIR)\hbgenerr.obj \ + $(OBJ_DIR)\hblbl.obj \ + $(OBJ_DIR)\hbpcode.obj \ + $(OBJ_DIR)\hbfunchk.obj \ + $(OBJ_DIR)\hbfix.obj \ + $(OBJ_DIR)\hbopt.obj \ + $(OBJ_DIR)\ppcomp.obj \ + $(OBJ_DIR)\genc.obj \ + $(OBJ_DIR)\gencc.obj \ + $(OBJ_DIR)\gencli.obj \ + $(OBJ_DIR)\gencobj.obj \ + $(OBJ_DIR)\genobj32.obj \ + $(OBJ_DIR)\genjava.obj \ + $(OBJ_DIR)\genhrb.obj \ + $(OBJ_DIR)\expropta.obj \ + $(OBJ_DIR)\exproptb.obj \ + +#********************************************************** + # VM Objects common for STATIC and SHARED library VM_COMMON_LIB_OBJS = \ $(OBJ_DIR)\arrays.obj \ @@ -488,7 +522,6 @@ MACRO_LIB_OBJS = \ $(OBJ_DIR)\macroy.obj \ $(OBJ_DIR)\macroa.obj \ $(OBJ_DIR)\macrob.obj \ - $(OBJ_DIR)\macroc.obj \ $(OBJ_DIR)\macrolex.obj \ #********************************************************** @@ -739,31 +772,6 @@ GTGUI_DLL_OBJS = $(GTGUI_LIB_COMMON_OBJS) $(GTGUI_LIB_SHARED_OBJS) HARBOUR_EXE_OBJS = \ $(OBJ_DIR)\harbour.obj \ - $(OBJ_DIR)\harboury.obj \ - $(OBJ_DIR)\complex.obj \ - $(OBJ_DIR)\cmdcheck.obj \ - $(OBJ_DIR)\hbcomp.obj \ - $(OBJ_DIR)\hbdead.obj \ - $(OBJ_DIR)\hbstripl.obj \ - $(OBJ_DIR)\hbusage.obj \ - $(OBJ_DIR)\hbident.obj \ - $(OBJ_DIR)\hbgenerr.obj \ - $(OBJ_DIR)\hblbl.obj \ - $(OBJ_DIR)\hbpcode.obj \ - $(OBJ_DIR)\hbfunchk.obj \ - $(OBJ_DIR)\hbfix.obj \ - $(OBJ_DIR)\hbopt.obj \ - $(OBJ_DIR)\ppcomp.obj \ - $(OBJ_DIR)\genc.obj \ - $(OBJ_DIR)\gencc.obj \ - $(OBJ_DIR)\gencli.obj \ - $(OBJ_DIR)\gencobj.obj \ - $(OBJ_DIR)\genobj32.obj \ - $(OBJ_DIR)\genjava.obj \ - $(OBJ_DIR)\genhrb.obj \ - $(OBJ_DIR)\expropta.obj \ - $(OBJ_DIR)\exproptb.obj \ - $(OBJ_DIR)\exproptc.obj \ #********************************************************** @@ -907,6 +915,7 @@ HB_BUILD_TARGETS = \ $(HBPPGEN_EXE) \ $(PP_LIB) \ \ + $(COMPILER_LIB) \ $(HARBOUR_EXE) \ $(HBPP_EXE) \ \ diff --git a/harbour/config/global.cf b/harbour/config/global.cf index de0ca0faf7..9d926f4d5e 100644 --- a/harbour/config/global.cf +++ b/harbour/config/global.cf @@ -20,7 +20,7 @@ HB_DB_DRIVERS += $(HB_DB_DRVEXT) endif ifeq ($(HB_BIN_COMPILE),) -HB_BIN_COMPILE := $(TOP)$(ROOT)source/compiler/$(HB_ARCH) +HB_BIN_COMPILE := $(TOP)$(ROOT)source/main/$(HB_ARCH) endif ifeq ($(HB_INC_COMPILE),) diff --git a/harbour/include/error.ch b/harbour/include/error.ch index 3a8aa30ab9..fd1ee0abe0 100644 --- a/harbour/include/error.ch +++ b/harbour/include/error.ch @@ -136,4 +136,7 @@ #define HB_EI_XREALLOCNULLSIZE 9024 /* "hb_xrealloc requested to resize to zero byte" */ #define HB_EI_XALLOCNULLSIZE 9025 /* "hb_xalloc requested to allocate zero byte" */ +#define HB_EI_COMPBADOPCODE 9100 /* "Unsupported VM opcode" */ +#define HB_EI_COMPBADOPSIZE 9101 /* "Invalid opcode size" */ + #endif /* _ERROR_CH */ diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index dcd61160b3..0d9736b753 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -183,7 +183,6 @@ extern void hb_compElseIfKill( HB_COMP_DECL ); extern void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ); /* generic parsing error management function */ extern void hb_compGenWarning( HB_COMP_DECL, char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2); /* generic parsing warning management function */ -extern BOOL hb_compIsValidMacroText( HB_COMP_DECL, char *, ULONG ); extern BOOL hb_compForEachVarError( HB_COMP_DECL, char * ); /* checks if it is FOR EACH enumerator variable and generates a warning */ extern ULONG hb_compGenJump( LONG, HB_COMP_DECL ); /* generates the pcode to jump to a specific offset */ @@ -207,6 +206,7 @@ extern void hb_compGenPushFunSym( char *, HB_COMP_DECL ); /* genera extern void hb_compGenPushFunRef( char *, HB_COMP_DECL ); /* generates the pcode to push function's reference symbol */ extern void hb_compGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ); /* generates the pcode to push a variable value to the virtual machine stack */ extern void hb_compGenPushVarRef( char * szVarName, HB_COMP_DECL ); /* generates the pcode to push a variable by reference to the virtual machine stack */ +extern void hb_compGenPushMemvarRef( char * szVarName, HB_COMP_DECL ); /* generates the pcode to push memvar variable by reference to the virtual machine stack */ extern void hb_compGenPushInteger( int iNumber, HB_COMP_DECL ); /* Pushes a integer number on the virtual machine stack */ extern void hb_compGenPushLogical( int iTrueFalse, HB_COMP_DECL ); /* pushes a logical value on the virtual machine stack */ extern void hb_compGenPushLong( HB_LONG lNumber, HB_COMP_DECL ); /* Pushes a long number on the virtual machine stack */ @@ -217,7 +217,6 @@ extern void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAli extern void hb_compGenPushAliasedVar( char *, BOOL, char *, long, HB_COMP_DECL ); extern void hb_compGenPopAliasedVar( char *, BOOL, char *, long, HB_COMP_DECL ); extern void hb_compGenPushFunRef( char *, HB_COMP_DECL ); -extern void hb_compGenVarPCode( BYTE, char *, HB_COMP_DECL ); extern void hb_compGenPCode1( BYTE, HB_COMP_DECL ); /* generates 1 byte of pcode */ extern void hb_compGenPCode2( BYTE, BYTE, HB_COMP_DECL ); /* generates 2 bytes of pcode + flag for optional StrongType(). */ extern void hb_compGenPCode3( BYTE, BYTE, BYTE, HB_COMP_DECL ); /* generates 3 bytes of pcode + flag for optional StrongType() */ @@ -240,32 +239,50 @@ extern void hb_compGenStaticName( char *, HB_COMP_DECL ); extern BOOL hb_compCheckUnclosedStru( HB_COMP_DECL ); -#ifdef HB_MACRO_SUPPORT +#define HB_COMP_ERROR_TYPE( x ) HB_COMP_PARAM->funcs->ErrorType( HB_COMP_PARAM, x ) +#define HB_COMP_ERROR_SYNTAX( x ) HB_COMP_PARAM->funcs->ErrorSyntax( HB_COMP_PARAM, x ) +#define HB_COMP_ERROR_DUPLVAR( s ) HB_COMP_PARAM->funcs->ErrorDuplVar( HB_COMP_PARAM, s ) + +#define HB_COMP_EXPR_NEW( i ) HB_COMP_PARAM->funcs->ExprNew( HB_COMP_PARAM, i ) +#define HB_COMP_EXPR_FREE( x ) HB_COMP_PARAM->funcs->ExprFree( HB_COMP_PARAM, x ) +#define HB_COMP_EXPR_CLEAR( x ) HB_COMP_PARAM->funcs->ExprClear( HB_COMP_PARAM, x ) +#define HB_COMP_EXPR_DELETE( x ) HB_COMP_PARAM->funcs->ExprDelete( HB_COMP_PARAM, x ) + +#if defined( HB_MACRO_SUPPORT ) + +#define HB_GEN_FUNC1( func, p1 ) hb_macroGen##func( p1, HB_COMP_PARAM ) +#define HB_GEN_FUNC2( func, p1,p2 ) hb_macroGen##func( p1, p2, HB_COMP_PARAM ) +#define HB_GEN_FUNC3( func, p1,p2,p3 ) hb_macroGen##func( p1, p2, p3, HB_COMP_PARAM ) +#define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_macroGen##func( p1, p2, p3, p4, HB_COMP_PARAM ) -#define hb_compErrorType( p, x ) hb_macroError( EG_ARG, ( p ) ) #define hb_compErrorIndex( p, x ) hb_macroError( EG_BOUND, ( p ) ) -#define hb_compErrorSyntax( p, x ) hb_macroError( EG_SYNTAX, ( p ) ) #define hb_compErrorLValue( p, x ) hb_macroError( EG_SYNTAX, ( p ) ) #define hb_compErrorBound( p, x ) hb_macroError( EG_BOUND, ( p ) ) #define hb_compErrorAlias( p, x ) hb_macroError( EG_NOALIAS, ( p ) ) -#define hb_compErrorDuplVar( p, c ) hb_macroError( EG_SYNTAX, ( p ) ) #define hb_compErrorRefer( p, x, c ) hb_macroError( EG_SYNTAX, ( p ) ) #define hb_compErrorVParams( p, x ) hb_macroError( EG_SYNTAX, ( p ) ) #define hb_compWarnMeaningless( p, x ) #define hb_compErrorMacro( p, x ) -/* Codeblocks */ -extern void hb_compCodeBlockStart( HB_COMP_DECL ); /* starts a codeblock creation */ +#elif !defined( HB_COMMON_SUPPORT ) -#else /* HB_MACRO_SUPPORT */ +#define HB_GEN_FUNC1( func, p1 ) hb_compGen##func( p1, HB_COMP_PARAM ) +#define HB_GEN_FUNC2( func, p1,p2 ) hb_compGen##func( p1, p2, HB_COMP_PARAM ) +#define HB_GEN_FUNC3( func, p1,p2,p3 ) hb_compGen##func( p1, p2, p3, HB_COMP_PARAM ) +#define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_compGen##func( p1, p2, p3, p4, HB_COMP_PARAM ) + +extern int compMain( int argc, char * argv[] ); +extern void hb_compExprLstDealloc( HB_COMP_DECL ); + +extern HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR, HB_COMP_DECL ); +extern HB_EXPR_PTR hb_compExprGenPush( HB_EXPR_PTR, HB_COMP_DECL ); +extern HB_EXPR_PTR hb_compExprGenPop( HB_EXPR_PTR, HB_COMP_DECL ); +extern HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR, HB_COMP_DECL ); -extern HB_EXPR_PTR hb_compErrorType( HB_COMP_DECL, HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compErrorIndex( HB_COMP_DECL, HB_EXPR_PTR ); -extern HB_EXPR_PTR hb_compErrorSyntax( HB_COMP_DECL, HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compErrorLValue( HB_COMP_DECL, HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compErrorBound( HB_COMP_DECL, HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compErrorAlias( HB_COMP_DECL, HB_EXPR_PTR ); -extern void hb_compErrorDuplVar( HB_COMP_DECL, const char * ); extern HB_EXPR_PTR hb_compErrorRefer( HB_COMP_DECL, HB_EXPR_PTR, const char * ); extern HB_EXPR_PTR hb_compWarnMeaningless( HB_COMP_DECL, HB_EXPR_PTR ); extern void hb_compErrorMacro( HB_COMP_DECL, const char * ); @@ -274,16 +291,16 @@ extern void hb_compErrorVParams( HB_COMP_DECL, const char * ); extern HB_EXPR_PTR hb_compErrorStatic( HB_COMP_DECL, const char *, HB_EXPR_PTR ); extern void hb_compErrorCodeblock( HB_COMP_DECL, const char * ); -/* Codeblocks */ -extern void hb_compCodeBlockStart( BOOL, HB_COMP_DECL ); /* starts a codeblock creation */ - -#endif /* HB_MACRO_SUPPORT */ +extern BOOL hb_compIsValidMacroText( HB_COMP_DECL, char *, ULONG ); /* Codeblocks */ +extern void hb_compCodeBlockStart( HB_COMP_DECL, BOOL ); /* starts a codeblock creation */ extern void hb_compCodeBlockEnd( HB_COMP_DECL ); /* end of codeblock creation */ extern void hb_compCodeBlockStop( HB_COMP_DECL ); /* end of fake codeblock */ extern void hb_compCodeBlockRewind( HB_COMP_DECL ); /* restart of fake codeblock */ +#endif /* HB_MACRO_SUPPORT */ + extern ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC_PTR pEval ); extern ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2, HB_CARGO2_FUNC_PTR pEval ); @@ -377,7 +394,7 @@ extern FILE *hb_comp_errFile; #if defined( HB_MACRO_SUPPORT ) # define HB_MACRO_GENFLAGS HB_COMPFLAG_RT_MACRO -#else +#elif ! defined( HB_COMMON_SUPPORT ) # define HB_MACRO_GENFLAGS ( HB_COMP_PARAM->supported & \ ( HB_COMPFLAG_HARBOUR | \ HB_COMPFLAG_XBASE | \ diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index 1d8768b222..9cc7b99c92 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -464,6 +464,8 @@ typedef struct _HB_LABEL_INFO #define HB_MODE_COMPILER 1 #define HB_MODE_MACRO 2 +struct _HB_COMP_FUNCS; + #if defined( HB_COMMON_SUPPORT ) typedef struct _HB_COMMON @@ -471,6 +473,7 @@ typedef struct _HB_COMMON /* common to macro compiler members */ int mode; /* HB_MODE_* */ ULONG supported; /* various flags for supported capabilities */ + const struct _HB_COMP_FUNCS * funcs; } HB_COMMON, * HB_COMMON_PTR; @@ -497,6 +500,7 @@ typedef struct HB_MACRO_ /* a macro compiled pcode container */ /* common to compiler members */ int mode; ULONG supported; /* various flags for supported capabilities */ + const struct _HB_COMP_FUNCS * funcs; /* macro compiler only members */ char * string; /* compiled string */ @@ -540,6 +544,7 @@ typedef struct _HB_COMP /* common to macro compiler members */ int mode; ULONG supported; /* various flags for supported capabilities */ + const struct _HB_COMP_FUNCS * funcs; /* compiler only members */ PHB_COMP_LEX pLex; @@ -637,6 +642,19 @@ extern void hb_comp_free( HB_COMP_PTR ); #endif /* !HB_MACRO_SUPPORT */ +typedef struct _HB_COMP_FUNCS +{ + HB_EXPR_PTR ( * ExprNew ) ( HB_COMP_DECL, HB_EXPRTYPE iType ); + void ( * ExprClear ) ( HB_COMP_DECL, HB_EXPR_PTR pExpr ); + void ( * ExprFree ) ( HB_COMP_DECL, HB_EXPR_PTR pExpr ); + void ( * ExprDelete ) ( HB_COMP_DECL, HB_EXPR_PTR pExpr ); + + HB_EXPR_PTR ( * ErrorType ) ( HB_COMP_DECL, HB_EXPR_PTR ); + HB_EXPR_PTR ( * ErrorSyntax ) ( HB_COMP_DECL, HB_EXPR_PTR ); + void ( * ErrorDuplVar ) ( HB_COMP_DECL, const char* ); +} HB_COMP_FUNCS, * PHB_COMP_FUNCS; + + #define HB_MACRO_DATA HB_COMP_PARAM #define HB_PCODE_DATA ( HB_MACRO_DATA->pCodeInfo ) diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index b0e3cf67c1..8bd0f2d578 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -54,211 +54,8 @@ #include #include "hbcomp.h" -/* memory allocation - */ - -/* Table with operators precedence - * NOTE: - * HB_ET_NIL is used for an ordinary values and post- operators - * HB_ET_NONE is used for invalid syntax, e.g. var := var1 += 2 - */ -static BYTE s_PrecedTable[ HB_EXPR_COUNT ] = { - HB_ET_NIL, /* HB_ET_NONE = 0, */ - HB_ET_NIL, /* HB_ET_NIL, */ - HB_ET_NIL, /* HB_ET_NUMERIC, */ - HB_ET_NIL, /* HB_ET_DATE, */ - HB_ET_NIL, /* HB_ET_STRING, */ - HB_ET_NIL, /* HB_ET_CODEBLOCK, */ - HB_ET_NIL, /* HB_ET_LOGICAL, */ - HB_ET_NIL, /* HB_ET_SELF, */ - HB_ET_NIL, /* HB_ET_ARRAY, */ - HB_ET_NIL, /* HB_ET_VARREF, */ - HB_ET_NIL, /* HB_ET_REFERENCE, */ - HB_ET_NIL, /* HB_ET_FUNREF, */ - HB_ET_NIL, /* HB_ET_IIF, */ - HB_ET_NIL, /* HB_ET_LIST, */ - HB_ET_NIL, /* HB_ET_ARGLIST, */ - HB_ET_NIL, /* HB_ET_MACROARGLIST,*/ - HB_ET_NIL, /* HB_ET_ARRAYAT, */ - HB_ET_NIL, /* HB_ET_MACRO, */ - HB_ET_NIL, /* HB_ET_FUNCALL, */ - HB_ET_NIL, /* HB_ET_ALIASVAR, */ - HB_ET_NIL, /* HB_ET_ALIASEXPR, */ - HB_ET_NIL, /* HB_ET_SEND, */ - HB_ET_NIL, /* HB_ET_FUNNAME, */ - HB_ET_NIL, /* HB_ET_ALIAS, */ - HB_ET_NIL, /* HB_ET_RTVARIABLE, */ - HB_ET_NIL, /* HB_ET_VARIABLE, */ - HB_ET_NIL, /* HB_EO_POSTINC, post-operators */ - HB_ET_NIL, /* HB_EO_POSTDEC, */ - HB_ET_NONE, /* HB_EO_ASSIGN, assigments */ - HB_ET_NONE, /* HB_EO_PLUSEQ, Invalid syntax */ - HB_ET_NONE, /* HB_EO_MINUSEQ, */ - HB_ET_NONE, /* HB_EO_MULTEQ, */ - HB_ET_NONE, /* HB_EO_DIVEQ, */ - HB_ET_NONE, /* HB_EO_MODEQ, */ - HB_ET_NONE, /* HB_EO_EXPEQ, */ - HB_EO_OR, /* HB_EO_OR, logical operators */ - HB_EO_AND, /* HB_EO_AND, */ - HB_ET_NIL, /* HB_EO_NOT, */ - HB_EO_EQUAL, /* HB_EO_EQUAL, relational operators */ - HB_EO_EQUAL, /* HB_EO_EQ, */ - HB_EO_EQUAL, /* HB_EO_LT, */ - HB_EO_EQUAL, /* HB_EO_GT, */ - HB_EO_EQUAL, /* HB_EO_LE, */ - HB_EO_EQUAL, /* HB_EO_GE, */ - HB_EO_EQUAL, /* HB_EO_NE, */ - HB_EO_EQUAL, /* HB_EO_IN, */ - HB_EO_PLUS, /* HB_EO_PLUS, addition */ - HB_EO_PLUS, /* HB_EO_MINUS, */ - HB_EO_MULT, /* HB_EO_MULT, multiple */ - HB_EO_MULT, /* HB_EO_DIV, */ - HB_EO_MULT, /* HB_EO_MOD, */ - HB_EO_POWER, /* HB_EO_POWER, */ - HB_ET_NIL, /* HB_EO_NEGATE, sign operator */ - HB_ET_NIL, /* HB_EO_PREINC, */ - HB_ET_NIL /* HB_EO_PREDEC, pre-operators */ -}; - -static HB_CBVAR_PTR hb_compExprCBVarNew( char *, BYTE ); - /* ************************************************************************ */ -#if !defined( HB_MACRO_SUPPORT ) -static HB_EXPR_PTR hb_compExprAlloc( HB_COMP_DECL ) -{ - PHB_EXPRLST pExpItm = ( PHB_EXPRLST ) hb_xgrab( sizeof( HB_EXPRLST ) ); - - pExpItm->pNext = HB_COMP_PARAM->pExprLst; - HB_COMP_PARAM->pExprLst = pExpItm; - if( pExpItm->pNext ) - { - pExpItm->pPrev = pExpItm->pNext->pPrev; - pExpItm->pNext->pPrev = pExpItm; - pExpItm->pPrev->pNext = pExpItm; - } - else - pExpItm->pPrev = pExpItm->pNext = pExpItm; - - return &pExpItm->Expression; -} - -static void hb_compExprDealloc( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - if( HB_COMP_PARAM->pExprLst ) - { - PHB_EXPRLST pExpItm = ( PHB_EXPRLST ) pExpr; - - pExpItm->pNext->pPrev = pExpItm->pPrev; - pExpItm->pPrev->pNext = pExpItm->pNext; - if( pExpItm == HB_COMP_PARAM->pExprLst ) - { - if( pExpItm->pNext == pExpItm ) - HB_COMP_PARAM->pExprLst = NULL; - else - HB_COMP_PARAM->pExprLst = pExpItm->pNext; - } - hb_xfree( pExpItm ); - } -} - -void hb_compExprLstDealloc( HB_COMP_DECL ) -{ - if( HB_COMP_PARAM->pExprLst ) - { - PHB_EXPRLST pExpItm, pExp; - pExpItm = pExp = HB_COMP_PARAM->pExprLst; - HB_COMP_PARAM->pExprLst = NULL; - do - { - hb_compExprDelete( &pExp->Expression, HB_COMP_PARAM ); - pExp = pExp->pNext; - } - while( pExp != pExpItm ); - do - { - PHB_EXPRLST pFree = pExp; - pExp = pExp->pNext; - hb_xfree( pFree ); - } - while( pExp != pExpItm ); - } -} - -#endif - -HB_EXPR_PTR hb_compExprNew( HB_EXPRTYPE iType, HB_COMP_DECL ) -{ - HB_EXPR_PTR pExpr; - - HB_TRACE(HB_TR_DEBUG, ("hb_compExprNew(%i,%p)", iType, HB_COMP_PARAM)); - -#if defined( HB_MACRO_SUPPORT ) - pExpr = hb_macroExprNew( HB_COMP_PARAM ); -#else - pExpr = hb_compExprAlloc( HB_COMP_PARAM ); -#endif - pExpr->ExprType = iType; - pExpr->pNext = NULL; - pExpr->ValType = HB_EV_UNKNOWN; - pExpr->Counter = 1; - - return pExpr; -} - -/* Delete self - all components will be deleted somewhere else - */ -void hb_compExprClear( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - if( --pExpr->Counter == 0 ) -#if defined( HB_MACRO_SUPPORT ) - pExpr->ExprType = HB_ET_NONE; - HB_SYMBOL_UNUSED( HB_COMP_PARAM ); -#else - hb_compExprDealloc( pExpr, HB_COMP_PARAM ); -#endif -} - -/* Delete all components and delete self - */ -void hb_compExprDelete( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_compExprDelete(%p,%p)", pExpr, HB_COMP_PARAM)); - if( pExpr && --pExpr->Counter == 0 ) - { - HB_EXPR_USE( pExpr, HB_EA_DELETE ); -#if defined( HB_MACRO_SUPPORT ) - pExpr->ExprType = HB_ET_NONE; -#else - hb_compExprDealloc( pExpr, HB_COMP_PARAM ); -#endif - } -} - -/* Delete all components and delete self - */ -void hb_compExprFree( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_compExprFree()")); - if( --pExpr->Counter == 0 ) - { - HB_EXPR_USE( pExpr, HB_EA_DELETE ); -#if defined( HB_MACRO_SUPPORT ) - pExpr->ExprType = HB_ET_NONE; -#else - hb_compExprDealloc( pExpr, HB_COMP_PARAM ); -#endif - } -} - -void hb_compExprErrorType( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_compExprErrorType()")); - hb_compErrorType( HB_COMP_PARAM, pExpr ); - HB_SYMBOL_UNUSED( pExpr ); - HB_SYMBOL_UNUSED( HB_COMP_PARAM ); -} - #ifndef HB_MACRO_SUPPORT ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC_PTR pEval ) { @@ -312,43 +109,13 @@ ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2 } #endif -/* Add a new local variable declaration - */ -HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR pCB, char * szVarName, BYTE bType, - HB_COMP_DECL ) -{ - HB_CBVAR_PTR pVar; - - HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarAdd(%s)", szVarName)); - - if( pCB->value.asCodeblock.pLocals ) - { - /* add it to the end of the list - */ - pVar = pCB->value.asCodeblock.pLocals; - while( pVar ) - { - if( strcmp( szVarName, pVar->szName ) == 0 ) - hb_compErrorDuplVar( HB_COMP_PARAM, szVarName ); - - if( pVar->pNext ) - pVar = pVar->pNext; - else - { - pVar->pNext = hb_compExprCBVarNew( szVarName, bType ); - break; - } - } - } - else - pCB->value.asCodeblock.pLocals = hb_compExprCBVarNew( szVarName, bType ); - - return pCB; -} - /* Create function call */ +#ifdef HB_MACRO_SUPPORT +HB_EXPR_PTR hb_macroExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COMP_DECL ) +#else HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COMP_DECL ) +#endif { HB_EXPR_PTR pExpr = NULL; @@ -372,12 +139,18 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM { HB_EXPR_PTR pEval; /* Optimize Eval( bBlock, [ArgList] ) to: bBlock:Eval( [ArgList] ) */ - pEval = hb_compExprNewMethodCall( +#ifdef HB_MACRO_SUPPORT + pEval = hb_compExprNewMethodCall( + hb_macroExprNewSend( pParms->value.asList.pExprList, "EVAL", NULL, HB_COMP_PARAM ), + hb_compExprNewArgList( pParms->value.asList.pExprList->pNext, HB_COMP_PARAM ) ); +#else + pEval = hb_compExprNewMethodCall( hb_compExprNewSend( pParms->value.asList.pExprList, "EVAL", NULL, HB_COMP_PARAM ), hb_compExprNewArgList( pParms->value.asList.pExprList->pNext, HB_COMP_PARAM ) ); +#endif pParms->value.asList.pExprList = NULL; - HB_EXPR_PCODE1( hb_compExprDelete, pParms ); - HB_EXPR_PCODE1( hb_compExprDelete, pName ); + HB_COMP_EXPR_DELETE( pParms ); + HB_COMP_EXPR_DELETE( pName ); return pEval; } else if( iCount && strcmp( "_GET_", pName->value.asSymbol ) == 0 ) @@ -387,7 +160,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_EXPR_PTR pArg, pNext; USHORT uiCount; - hb_compExprReduceList( pParms, HB_COMP_PARAM ); + HB_EXPR_USE( pParms, HB_EA_REDUCE ); pArg = pParms->value.asList.pExprList; if( pArg->ExprType == HB_ET_LIST ) @@ -430,7 +203,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM if( pVar->ExprType == HB_ET_MACRO ) { /* &var[1] */ - hb_compExprFree( pVar, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pVar ); pVar = hb_compExprNewNil( HB_COMP_PARAM ); } else @@ -448,7 +221,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM */ pArg->value.asList.pIndex = NULL; pArg->value.asList.pExprList = NULL; - hb_compExprClear( pArg, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pArg ); /* Create an array with index elements */ pIndex = HB_EXPR_PCODE1( hb_compExprNewArray, hb_compExprNewList( pIndex, HB_COMP_PARAM ) ); @@ -465,7 +238,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM if( pVar->pNext ) /* Delete 6-th argument if present */ { pIndex->pNext = pVar->pNext->pNext; - HB_EXPR_PCODE1( hb_compExprDelete, pVar->pNext ); + HB_COMP_EXPR_DELETE( pVar->pNext ); } pVar->pNext = pIndex; /* Set a new 6-th argument */ @@ -496,7 +269,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM { pVar = pBase->value.asList.pExprList; pBase->value.asList.pExprList = NULL; - hb_compExprClear( pBase, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pBase ); pBase = pVar; } } @@ -528,10 +301,10 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM */ char *szName = pFirst->value.asMacro.szMacro; if( pFirst->pNext ) - HB_EXPR_PCODE1( hb_compExprDelete, pFirst->pNext ); /* delete a second argument */ + HB_COMP_EXPR_DELETE( pFirst->pNext ); /* delete a second argument */ pArg->pNext = hb_compExprNewVar( szName, HB_COMP_PARAM ); pArg->pNext->pNext = pNext; /* restore third argument */ - HB_EXPR_PCODE1( hb_compExprDelete, pFirst ); + HB_COMP_EXPR_DELETE( pFirst ); } else { @@ -545,7 +318,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM pArg->pNext = hb_compExprNewString( szText, strlen( szText ), FALSE, HB_COMP_PARAM ); pArg->pNext->pNext = pNext; } - HB_EXPR_PCODE1( hb_compExprDelete, pFirst ); /* delete first argument */ + HB_COMP_EXPR_DELETE( pFirst ); /* delete first argument */ } } else @@ -563,9 +336,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM pNext = pArg->pNext; pArg->pNext = NULL; /* replace first argument with a set/get codeblock */ -#ifdef HB_MACRO_SUPPORT - pArg = hb_compExprSetGetBlock( pArg, HB_COMP_PARAM ); -#else +#if !defined( HB_MACRO_SUPPORT ) if( pArg->ExprType == HB_ET_VARIABLE ) { if( hb_compVariableScope( HB_COMP_PARAM, pArg->value.asSymbol ) > 0 ) @@ -575,15 +346,15 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM /* Undeclared variable name - create a set/get codeblock * at runtime */ - hb_compExprFree( pArg, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pArg ); pArg = hb_compExprNewNil( HB_COMP_PARAM ); } } else +#endif { pArg = hb_compExprSetGetBlock( pArg, HB_COMP_PARAM ); } -#endif /* restore next arguments */ pArg->pNext = pNext; /* set an updated list of arguments */ @@ -604,7 +375,7 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM if( pExpr == NULL ) { - pExpr = hb_compExprNew( HB_ET_FUNCALL, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNCALL ); pExpr->value.asFunCall.pParms = pParms; pExpr->value.asFunCall.pFunName = pName; } @@ -615,14 +386,19 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM /* Creates new send expression * pObject : szMessage */ +#ifdef HB_MACRO_SUPPORT +HB_EXPR_PTR hb_macroExprNewSend( HB_EXPR_PTR pObject, char * szMessage, + HB_EXPR_PTR pMessage, HB_COMP_DECL ) +#else HB_EXPR_PTR hb_compExprNewSend( HB_EXPR_PTR pObject, char * szMessage, HB_EXPR_PTR pMessage, HB_COMP_DECL ) +#endif { HB_EXPR_PTR pExpr; HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewSend(%p,%s,%p,%p)", pObject, szMessage, pMessage, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_SEND, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_SEND ); pExpr->value.asMessage.pObject = pObject; pExpr->value.asMessage.pParms = NULL; @@ -671,13 +447,17 @@ HB_EXPR_PTR hb_compExprNewSend( HB_EXPR_PTR pObject, char * szMessage, * NOTE: In case of multiple indexes it is called recursively * array[ idx1, idx2 ] => ( array[ idx1 ] )[ idx2 ] */ +#ifdef HB_MACRO_SUPPORT +HB_EXPR_PTR hb_macroExprNewArrayAt( HB_EXPR_PTR pArray, HB_EXPR_PTR pIndex, HB_COMP_DECL ) +#else HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR pArray, HB_EXPR_PTR pIndex, HB_COMP_DECL ) +#endif { HB_EXPR_PTR pExpr; HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewArrayAt()")); - pExpr = hb_compExprNew( HB_ET_ARRAYAT, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_ARRAYAT ); /* Check if this expression can be indexed */ HB_EXPR_USE( pArray, HB_EA_ARRAY_AT ); @@ -731,7 +511,7 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx HB_TRACE(HB_TR_DEBUG, ("hb_compExprAssignStatic()")); - pExpr = hb_compExprNew( HB_EO_ASSIGN, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_EO_ASSIGN ); pExpr->value.asOperator.pLeft = pLeftExpr; /* Try to reduce the assigned value */ @@ -765,105 +545,33 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx } #endif - -/* Sets the argument of an operation found previously - */ -HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR pExpr, HB_EXPR_PTR pItem, HB_COMP_DECL ) -{ - BYTE ucRight; - - ucRight = s_PrecedTable[ pItem->ExprType ]; - - if( ucRight == HB_ET_NIL ) - { - /* the right side of an operator is an ordinary value - * e.g. a := 1 - */ - pExpr->value.asOperator.pRight = pItem; - } - else if( ucRight == HB_ET_NONE ) - { - /* the right side of an operator is an invalid expression - * e.g. - * a := 1 + b:=2 - * a := 1 + b += 2 - */ - - if( pExpr->ExprType >= HB_EO_PLUSEQ && pExpr->ExprType <= HB_EO_EXPEQ ) - { - } - else - { - hb_compErrorSyntax( HB_COMP_PARAM, pItem ); - } - pExpr->value.asOperator.pRight = pItem; /* set it anyway */ - } - else - { - /* the right side of an operator is an expression with other operator - * e.g. a := 2 + b * 3 - * We have to set the proper order of evaluation using - * precedence rules - */ - BYTE ucLeft = s_PrecedTable[ pExpr->ExprType ]; - if( ucLeft < ucRight || - ( ucLeft == ucRight && HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) && - ( ucLeft == HB_EO_OR || ucLeft == HB_EO_AND ) ) ) - { - /* Left operator has a lower precedence then the right one - * e.g. a + b * c - * pItem -> b * c -> L=b R=c O=* - * pExpr -> a + -> l=a r= o=+ - * - * -> a + (b * c) -> Left=a Right=(b * c) Oper=+ - * Left := l - * Right := L (O) R := pItem - * Oper := o - */ - pExpr->value.asOperator.pRight = pItem; - } - else - { - /* Left operator has the same or higer precedence then the right one - * e.g. a * b + c - * pItem -> b + c -> L=b R=c O=+ - * pExpr -> a * -> l=a r= o=* - * - * -> (a * b) + c -> Lelf=(a * b) Right=c Oper=+ - * Left := l (o) L - * Right := R - * Oper := O - */ - pItem->value.asOperator.pLeft = hb_compExprSetOperand( pExpr, pItem->value.asOperator.pLeft, HB_COMP_PARAM ); - pExpr = pItem; - } - } - - return pExpr; -} - /* ************************************************************************* */ -/* Generates pcode for inline expression used as a statement - * NOTE: It doesn't not leave any value on the eval stack - */ -HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_compExprGenStatement(%p)", pExpr)); - if( pExpr ) - { - if( pExpr->ExprType == HB_EO_EQUAL ) - { - /* NOTE: direct type change */ - pExpr->ExprType = HB_EO_ASSIGN; - } +#if defined( HB_MACRO_SUPPORT ) - pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - HB_EXPR_USE( pExpr, HB_EA_STATEMENT ); - } +/* Generates pcode to push an expressions + * NOTE: It pushes a value on the stack and leaves this value on the stack + */ +HB_EXPR_PTR hb_macroExprGenPush( HB_EXPR_PTR pExpr, HB_COMP_DECL ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprGenPush(%i)", pExpr->ExprType)); + + pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); + HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); return pExpr; } +/* Generates pcode to pop an expressions + */ +HB_EXPR_PTR hb_macroExprGenPop( HB_EXPR_PTR pExpr, HB_COMP_DECL ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprGenPop(%i)", pExpr->ExprType)); + + return HB_EXPR_USE( pExpr, HB_EA_POP_PCODE ); +} + +#else + /* Generates pcode to push an expressions * NOTE: It pushes a value on the stack and leaves this value on the stack */ @@ -885,77 +593,30 @@ HB_EXPR_PTR hb_compExprGenPop( HB_EXPR_PTR pExpr, HB_COMP_DECL ) return HB_EXPR_USE( pExpr, HB_EA_POP_PCODE ); } -/* ************************************************************************* */ - -/* Create a new declaration for codeblock local variable +/* Generates pcode for inline expression used as a statement + * NOTE: It doesn't not leave any value on the eval stack */ -static HB_CBVAR_PTR hb_compExprCBVarNew( char * szVarName, BYTE bType ) +HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR pExpr, HB_COMP_DECL ) { - HB_CBVAR_PTR pVar; - - HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarNew(%s)", szVarName)); - - pVar = ( HB_CBVAR_PTR ) hb_xgrab( sizeof( HB_CBVAR ) ); - - pVar->szName = szVarName; - pVar->bType = bType; - pVar->pNext = NULL; - pVar->bUsed = FALSE; - - return pVar; -} - -/* NOTE: This deletes all linked variables - */ -void hb_compExprCBVarDel( HB_CBVAR_PTR pVars ) -{ - HB_CBVAR_PTR pDel; - - while( pVars ) + HB_TRACE(HB_TR_DEBUG, ("hb_compExprGenStatement(%p)", pExpr)); + if( pExpr ) { - pDel = pVars; - pVars = pVars->pNext; - hb_xfree( pDel ); + if( pExpr->ExprType == HB_EO_EQUAL ) + { + /* NOTE: direct type change */ + pExpr->ExprType = HB_EO_ASSIGN; + } + + pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); + HB_EXPR_USE( pExpr, HB_EA_STATEMENT ); } + return pExpr; } -#ifndef HB_MACRO_SUPPORT HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR pExpr, HB_COMP_DECL ) { return hb_compExprListStrip( HB_EXPR_USE( pExpr, HB_EA_REDUCE ), HB_COMP_PARAM ); } #endif -/* Creates a set/get codeblock for passed expression used in __GET - * - * {|var| IIF( var==NIL, , :=var )} - */ -HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - HB_EXPR_PTR pIIF; - HB_EXPR_PTR pSet; - - /* create {|var| expression - * NOTE: this is not a valid variable name so there will be no collisions - */ - /* create var==NIL */ - pIIF = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "~1", HB_COMP_PARAM ), HB_COMP_PARAM ), - hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ); - /* create ( var==NIL, */ - pIIF = hb_compExprNewList( pIIF, HB_COMP_PARAM ); - /* create ( var==NIL, , */ - pIIF = hb_compExprAddListExpr( pIIF, pExpr ); - /* create var */ - pSet =hb_compExprNewVar( "~1", HB_COMP_PARAM ); - /* create :=var */ - pSet = hb_compExprAssign( hb_compExprClone( pExpr ), pSet, HB_COMP_PARAM ); - /* create ( var==nil, , :=var ) */ - pIIF = hb_compExprAddListExpr( pIIF, pSet ); - /* create IIF() expression */ - pIIF = hb_compExprNewIIF( pIIF ); - /* create a codeblock - */ - return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd( - hb_compExprNewCodeBlock( NULL, 0, 0, HB_COMP_PARAM ), - "~1", ' ', HB_COMP_PARAM ), pIIF ); -} +/* ************************************************************************* */ diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index c2cf64814b..f6bf8eb3f1 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -54,8 +54,11 @@ #include "hbcomp.h" #include "hbmacro.ch" -/* memory allocation - */ +#define HB_USE_ARRAYAT_REF +/* Temporary disabled optimization with references to object variables + until we will not have extended reference items in our HVM [druzus] */ +/* #define HB_USE_OBJMSG_REF */ + /* Forward declarations */ @@ -121,12 +124,23 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ); /* other helper functions */ #if defined( HB_MACRO_SUPPORT ) - static void hb_compExprCodeblockPush( HB_EXPR_PTR, HB_COMP_DECL ); + static void hb_compExprCodeblockPush( HB_EXPR_PTR, HB_COMP_DECL ); #else - static void hb_compExprCodeblockPush( HB_EXPR_PTR, BOOL, HB_COMP_DECL ); - static void hb_compExprCodeblockEarly( HB_EXPR_PTR, HB_COMP_DECL ); + static void hb_compExprCodeblockPush( HB_EXPR_PTR, BOOL, HB_COMP_DECL ); + static void hb_compExprCodeblockEarly( HB_EXPR_PTR, HB_COMP_DECL ); #endif +static void hb_compExprPushSendPop( HB_EXPR_PTR pSelf, HB_COMP_DECL ); +static void hb_compExprPushSendPush( HB_EXPR_PTR pSelf, HB_COMP_DECL ); +static void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ); +static void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ); +static void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); +static void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); +static void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ); +static void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_COMP_DECL ); +static ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL ); + + const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ] = { hb_compExprUseDummy, hb_compExprUseNil, @@ -194,14 +208,14 @@ static HB_EXPR_FUNC( hb_compExprUseDummy ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); case HB_EA_ARRAY_INDEX: break; case HB_EA_LVALUE: hb_compErrorLValue( HB_COMP_PARAM, pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHNIL ); break; case HB_EA_POP_PCODE: case HB_EA_PUSH_POP: @@ -221,7 +235,7 @@ static HB_EXPR_FUNC( hb_compExprUseNil ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: hb_compErrorIndex( HB_COMP_PARAM, pSelf ); /* NIL cannot be used as index element */ @@ -230,7 +244,7 @@ static HB_EXPR_FUNC( hb_compExprUseNil ) hb_compErrorLValue( HB_COMP_PARAM, pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHNIL ); break; case HB_EA_POP_PCODE: break; @@ -253,7 +267,7 @@ static HB_EXPR_FUNC( hb_compExprUseNumeric ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: break; @@ -262,9 +276,9 @@ static HB_EXPR_FUNC( hb_compExprUseNumeric ) break; case HB_EA_PUSH_PCODE: if( pSelf->value.asNum.NumType == HB_ET_DOUBLE ) - HB_EXPR_PCODE3( hb_compGenPushDouble, pSelf->value.asNum.val.d, pSelf->value.asNum.bWidth, pSelf->value.asNum.bDec ); + HB_GEN_FUNC3( PushDouble, pSelf->value.asNum.val.d, pSelf->value.asNum.bWidth, pSelf->value.asNum.bDec ); else - HB_EXPR_PCODE1( hb_compGenPushLong, pSelf->value.asNum.val.l ); + HB_GEN_FUNC1( PushLong, pSelf->value.asNum.val.l ); break; case HB_EA_POP_PCODE: break; @@ -286,7 +300,7 @@ static HB_EXPR_FUNC( hb_compExprUseDate ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: hb_compErrorIndex( HB_COMP_PARAM, pSelf ); /* Date cannot be used as index element */ @@ -295,7 +309,7 @@ static HB_EXPR_FUNC( hb_compExprUseDate ) hb_compErrorLValue( HB_COMP_PARAM, pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPushDate, pSelf->value.asNum.val.l ); + HB_GEN_FUNC1( PushDate, pSelf->value.asNum.val.l ); break; case HB_EA_POP_PCODE: break; @@ -319,7 +333,7 @@ static HB_EXPR_FUNC( hb_compExprUseString ) break; case HB_EA_ARRAY_AT: if( ! HB_SUPPORT_ARRSTR ) - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: hb_compErrorIndex( HB_COMP_PARAM, pSelf ); /* string cannot be used as index element */ @@ -329,18 +343,19 @@ static HB_EXPR_FUNC( hb_compExprUseString ) break; case HB_EA_PUSH_PCODE: { - HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asString.string, + HB_GEN_FUNC2( PushString, pSelf->value.asString.string, pSelf->ulLength + 1 ); #if ! defined( HB_MACRO_SUPPORT ) - if( HB_COMP_PARAM->fTextSubst ) -#endif + if( HB_COMP_PARAM->fTextSubst && + hb_compIsValidMacroText( HB_COMP_PARAM, + pSelf->value.asString.string, + pSelf->ulLength ) ) +#else + if( hb_macroIsValidMacroText( pSelf->value.asString.string, + pSelf->ulLength ) ) +#endif { - if( hb_compIsValidMacroText( HB_COMP_PARAM, - pSelf->value.asString.string, - pSelf->ulLength ) ) - { - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROTEXT ); - } + HB_GEN_FUNC1( PCode1, HB_P_MACROTEXT ); } break; } @@ -369,7 +384,7 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: hb_compErrorIndex( HB_COMP_PARAM, pSelf ); /* codeblock cannot be used as index element */ @@ -412,7 +427,7 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) while( pExp ) { pNext = pExp->pNext; - HB_EXPR_PCODE1( hb_compExprDelete, pExp ); + HB_COMP_EXPR_DELETE( pExp ); pExp = pNext; } @@ -422,141 +437,6 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) return pSelf; } -/* This generates a push pcode for a codeblock (with no macro expression or - with late evaluation of a macro) -*/ -#if defined( HB_MACRO_SUPPORT ) -static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, HB_COMP_DECL ) -#else -static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, BOOL bLateEval, HB_COMP_DECL ) -#endif -{ - HB_EXPR_PTR pExpr, pNext; - HB_EXPR_PTR * pPrev; - - /* Define requested local variables - */ -#if defined( HB_MACRO_SUPPORT ) - HB_EXPR_PCODE0( hb_compCodeBlockStart ); - HB_PCODE_DATA->pLocals = pSelf->value.asCodeblock.pLocals; - HB_PCODE_DATA->fVParams = - ( pSelf->value.asCodeblock.flags & HB_BLOCK_VPARAMS ) != 0; -#else - HB_EXPR_PCODE1( hb_compCodeBlockStart, bLateEval ); - HB_COMP_PARAM->functions.pLast->fVParams = - ( pSelf->value.asCodeblock.flags & HB_BLOCK_VPARAMS ) != 0; - - { - HB_CBVAR_PTR pVar; - - pVar = pSelf->value.asCodeblock.pLocals; - while( pVar ) - { - hb_compVariableAdd( HB_COMP_PARAM, pVar->szName, pVar->bType ); - pVar =pVar->pNext; - } - } - - HB_EXPR_PCODE0( hb_compLinePushIfDebugger ); -#endif - pExpr = pSelf->value.asCodeblock.pExprList; - pPrev = &pSelf->value.asCodeblock.pExprList; - while( pExpr ) - { - if( pExpr->ExprType == HB_ET_MACRO && - pExpr->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && - pExpr->value.asMacro.SubType != HB_ET_MACRO_REFER && - pExpr->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) - { - /* Clipper allows for list expressions in a codeblock - * macro := "1,2" - * EVAL( {|| ¯o} ) - */ - pExpr->value.asMacro.SubType |= HB_ET_MACRO_PARE; - } - - /* store next expression in case the current will be reduced - * NOTE: During reduction the expression can be replaced by the - * new one - this will break the linked list of expressions. - */ - pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ - pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - /* Generate push/pop pcodes for all expresions except the last one - * The value of the last expression is used as a return value - * of a codeblock evaluation - */ - /* NOTE: This will genereate warnings if constant value is - * used as an expression - some operators will generate it too - * e.g. - * EVAL( {|| 3+5, func()} ) - */ - *pPrev = pExpr; /* store a new expression into the previous one */ - pExpr->pNext = pNext; /* restore the link to next expression */ -#if defined( HB_MACRO_SUPPORT ) - if( pNext ) - HB_EXPR_USE( pExpr, HB_EA_PUSH_POP ); - else - HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); -#else - if( pNext && bLateEval ) - HB_EXPR_USE( pExpr, HB_EA_PUSH_POP ); - else - HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); -#endif - pPrev = &pExpr->pNext; - pExpr = pNext; - } -#if defined( HB_MACRO_SUPPORT ) - HB_EXPR_PCODE0( hb_compCodeBlockEnd ); -#else - if( bLateEval ) - HB_EXPR_PCODE0( hb_compCodeBlockEnd ); - else - HB_EXPR_PCODE0( hb_compCodeBlockRewind ); -#endif -} - -/* This generates a push pcode for early evaluation of a macro -*/ -#if !defined(HB_MACRO_SUPPORT) -static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf, HB_COMP_DECL ) -{ - HB_EXPR_PTR pExpr; - - /* check first expression */ - pExpr = pSelf->value.asCodeblock.pExprList; - if( pExpr->ExprType == HB_ET_MACRO && pExpr->value.asMacro.cMacroOp ) - { - /* simple macro variable expansion: &variable - * 'szMacro' is a variable name - * {|| &variable} => &( '{||' + variable +'}' ) - */ - HB_EXPR_PTR pVar, pNew; - - pVar = hb_compExprNewVar( pExpr->value.asMacro.szMacro, HB_COMP_PARAM ); - pNew = hb_compExprNewString( "{||", 3, FALSE, HB_COMP_PARAM ); - pNew = hb_compExprSetOperand( hb_compExprNewPlus( pNew, HB_COMP_PARAM ), pVar, HB_COMP_PARAM ); - pNew = hb_compExprSetOperand( hb_compExprNewPlus( pNew, HB_COMP_PARAM ), hb_compExprNewString( "}", 1, FALSE, HB_COMP_PARAM ), HB_COMP_PARAM ); - pNew = hb_compExprNewMacro( pNew, 0, NULL, HB_COMP_PARAM ); - HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE ); - hb_compExprDelete( pNew, HB_COMP_PARAM ); - } - else - { - /* everything else is macro compiled at runtime - * {|| &variable+1} => &( '{|| &variable+1}' ) - */ - HB_EXPR_PTR pNew; - - hb_compExprCodeblockPush( pSelf, FALSE, HB_COMP_PARAM ); - pNew = hb_compExprNewMacro( hb_compExprNewString( pSelf->value.asCodeblock.string, pSelf->value.asCodeblock.length, FALSE, HB_COMP_PARAM ), 0, NULL, HB_COMP_PARAM ); - HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE ); - hb_compExprDelete( pNew, HB_COMP_PARAM ); - HB_EXPR_PCODE0( hb_compCodeBlockStop ); - } -} -#endif /*HB_MACRO_SUPPORT*/ - /* actions for HB_ET_LOGICAL expression */ static HB_EXPR_FUNC( hb_compExprUseLogical ) @@ -566,7 +446,7 @@ static HB_EXPR_FUNC( hb_compExprUseLogical ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: hb_compErrorIndex( HB_COMP_PARAM, pSelf ); /* logical cannot be used as array index element */ @@ -575,7 +455,7 @@ static HB_EXPR_FUNC( hb_compExprUseLogical ) hb_compErrorLValue( HB_COMP_PARAM, pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPushLogical, pSelf->value.asLogical ); + HB_GEN_FUNC1( PushLogical, pSelf->value.asLogical ); break; case HB_EA_POP_PCODE: break; @@ -597,7 +477,7 @@ static HB_EXPR_FUNC( hb_compExprUseSelf ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); /* QUESTION: Is this OK ? */ + HB_COMP_ERROR_TYPE( pSelf ); /* QUESTION: Is this OK ? */ break; case HB_EA_ARRAY_INDEX: hb_compErrorIndex( HB_COMP_PARAM, pSelf ); /* SELF cannot be used as array index element */ @@ -606,7 +486,7 @@ static HB_EXPR_FUNC( hb_compExprUseSelf ) hb_compErrorLValue( HB_COMP_PARAM, pSelf ); break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHSELF ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHSELF ); break; case HB_EA_POP_PCODE: break; @@ -646,7 +526,7 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) if( usItems == 0 ) { - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_ARRAYGEN, 0, 0 ); + HB_GEN_FUNC3( PCode3, HB_P_ARRAYGEN, 0, 0 ); } else { @@ -663,12 +543,12 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) if( fArgsList ) { - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_MACROARRAYGEN, + HB_GEN_FUNC3( PCode3, HB_P_MACROARRAYGEN, HB_LOBYTE( usItems ), HB_HIBYTE( usItems ) ); } else { - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_ARRAYGEN, + HB_GEN_FUNC3( PCode3, HB_P_ARRAYGEN, HB_LOBYTE( usItems ), HB_HIBYTE( usItems ) ); } } @@ -704,7 +584,7 @@ static HB_EXPR_FUNC( hb_compExprUseArray ) while( pElem ) { pNext = pElem->pNext; - HB_EXPR_PCODE1( hb_compExprDelete, pElem ); + HB_COMP_EXPR_DELETE( pElem ); pElem = pNext; } } @@ -724,7 +604,7 @@ static HB_EXPR_FUNC( hb_compExprUseVarRef ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -735,7 +615,7 @@ static HB_EXPR_FUNC( hb_compExprUseVarRef ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPushVarRef, pSelf->value.asSymbol ); + HB_GEN_FUNC1( PushVarRef, pSelf->value.asSymbol ); break; case HB_EA_POP_PCODE: @@ -760,7 +640,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunRef ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -771,7 +651,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunRef ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPushFunRef, pSelf->value.asSymbol ); + HB_GEN_FUNC1( PushFunRef, pSelf->value.asSymbol ); break; case HB_EA_POP_PCODE: @@ -795,7 +675,7 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) case HB_EA_REDUCE: break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: break; @@ -823,7 +703,7 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) if( !pSend || pSend->ExprType == HB_ET_VARIABLE ) */ { hb_compExprPushSendPop( pExp, HB_COMP_PARAM ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); break; } } @@ -835,11 +715,7 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) memcmp( szAlias, "MEMVAR", iLen ) == 0 && pExp->value.asAlias.pVar->ExprType == HB_ET_VARIABLE ) { /* @M-> @MEMVAR-> or @MEMVA-> or @MEMV-> */ -#if !defined(HB_MACRO_SUPPORT) - HB_EXPR_PCODE2( hb_compGenVarPCode, HB_P_PUSHMEMVARREF, pExp->value.asAlias.pVar->value.asSymbol ); -#else - HB_EXPR_PCODE2( hb_compMemvarGenPCode, HB_P_MPUSHMEMVARREF, pExp->value.asAlias.pVar->value.asSymbol ); -#endif + HB_GEN_FUNC1( PushMemvarRef, pExp->value.asAlias.pVar->value.asSymbol ); break; } } @@ -854,7 +730,7 @@ static HB_EXPR_FUNC( hb_compExprUseRef ) case HB_EA_STATEMENT: hb_compWarnMeaningless( HB_COMP_PARAM, pSelf ); case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asReference ); + HB_COMP_EXPR_DELETE( pSelf->value.asReference ); break; } return pSelf; @@ -888,16 +764,16 @@ static HB_EXPR_FUNC( hb_compExprUseIIF ) HB_EXPR_PTR pExpr = pSelf->value.asList.pExprList; HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); - lPosFalse = HB_EXPR_PCODE1( hb_compGenJumpFalse, 0 ); + lPosFalse = HB_GEN_FUNC1( JumpFalse, 0 ); pExpr =pExpr->pNext; HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); - lPosEnd = HB_EXPR_PCODE1( hb_compGenJump, 0 ); + lPosEnd = HB_GEN_FUNC1( Jump, 0 ); pExpr =pExpr->pNext; - HB_EXPR_PCODE1( hb_compGenJumpHere, lPosFalse ); + HB_GEN_FUNC1( JumpHere, lPosFalse ); HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenJumpHere, lPosEnd ); + HB_GEN_FUNC1( JumpHere, lPosEnd ); } break; @@ -908,7 +784,7 @@ static HB_EXPR_FUNC( hb_compExprUseIIF ) case HB_EA_STATEMENT: { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); /* remove a value if used in statement */ + HB_GEN_FUNC1( PCode1, HB_P_POP ); /* remove a value if used in statement */ } break; @@ -919,7 +795,7 @@ static HB_EXPR_FUNC( hb_compExprUseIIF ) while( pExpr ) { pTmp = pExpr->pNext; /* store next expression */ - HB_EXPR_PCODE1( hb_compExprDelete, pExpr ); + HB_COMP_EXPR_DELETE( pExpr ); pExpr =pTmp; } pSelf->value.asList.pExprList = NULL; @@ -984,7 +860,7 @@ static HB_EXPR_FUNC( hb_compExprUseList ) { /* Empty list was used () */ - hb_compErrorSyntax( HB_COMP_PARAM, pExpr ); + HB_COMP_ERROR_SYNTAX( pExpr ); } else { @@ -1045,7 +921,7 @@ static HB_EXPR_FUNC( hb_compExprUseList ) while( pExpr ) { pTmp = pExpr->pNext; /* store next expression */ - HB_EXPR_PCODE1( hb_compExprDelete, pExpr ); + HB_COMP_EXPR_DELETE( pExpr ); pExpr =pTmp; } pSelf->value.asList.pExprList = NULL; @@ -1083,7 +959,7 @@ static HB_EXPR_FUNC( hb_compExprUseArgList ) HB_COMP_PARAM->functions.pLast->szName ? "Function" : "Codeblock" ); } - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHVPARAMS ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHVPARAMS ); } else { @@ -1108,7 +984,7 @@ static HB_EXPR_FUNC( hb_compExprUseArgList ) while( pExpr ) { pTmp = pExpr->pNext; /* store next expression */ - HB_EXPR_PCODE1( hb_compExprDelete, pExpr ); + HB_COMP_EXPR_DELETE( pExpr ); pExpr =pTmp; } pSelf->value.asList.pExprList = NULL; @@ -1148,7 +1024,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList ) { if( usItems ) { - HB_EXPR_PCODE1( hb_compGenPushLong, usItems ); + HB_GEN_FUNC1( PushLong, usItems ); usItems = 0; } } @@ -1159,7 +1035,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList ) } if( usItems ) { - HB_EXPR_PCODE1( hb_compGenPushLong, usItems ); + HB_GEN_FUNC1( PushLong, usItems ); } } break; @@ -1176,7 +1052,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList ) while( pExpr ) { pTmp = pExpr->pNext; /* store next expression */ - HB_EXPR_PCODE1( hb_compExprDelete, pExpr ); + HB_COMP_EXPR_DELETE( pExpr ); pExpr =pTmp; } pSelf->value.asList.pExprList = NULL; @@ -1233,7 +1109,7 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) { /* extract a single expression from the array */ - HB_EXPR_PTR pNew = hb_compExprNew( HB_ET_NONE, HB_COMP_PARAM ); + HB_EXPR_PTR pNew = HB_COMP_EXPR_NEW( HB_ET_NONE ); memcpy( pNew, pExpr, sizeof( HB_EXPR ) ); /* This will suppres releasing of memory occupied by components of * the expression - we have just copied them into the new expression. @@ -1242,7 +1118,7 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) */ pExpr->ExprType = HB_ET_NONE; /* Here comes the magic */ - HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + HB_COMP_EXPR_DELETE( pSelf ); pSelf = pNew; } else @@ -1258,12 +1134,12 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) pszValue[ 0 ] = pExpr->value.asString.string[ lIndex - 1 ]; pszValue[ 1 ] = '\0'; - HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + HB_COMP_EXPR_DELETE( pSelf ); pSelf = hb_compExprNewString( pszValue, 1, TRUE, HB_COMP_PARAM ); #else UCHAR ucValue = ( UCHAR ) pExpr->value.asString.string[ lIndex - 1 ]; - HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + HB_COMP_EXPR_DELETE( pSelf ); pSelf = hb_compExprNewLong( ucValue, HB_COMP_PARAM ); #endif } @@ -1307,11 +1183,11 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_PUSH_PCODE ); if( fMacroIndex ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHINDEX ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHINDEX ); if( pSelf->value.asList.reference ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPUSHREF ); + HB_GEN_FUNC1( PCode1, HB_P_ARRAYPUSHREF ); else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPUSH ); + HB_GEN_FUNC1( PCode1, HB_P_ARRAYPUSH ); break; } @@ -1348,8 +1224,8 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) HB_EXPR_USE( pSelf->value.asList.pExprList, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asList.pIndex, HB_EA_PUSH_PCODE ); if( fMacroIndex ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHINDEX ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_ARRAYPOP ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHINDEX ); + HB_GEN_FUNC1( PCode1, HB_P_ARRAYPOP ); if( bRemoveRef ) pSelf->value.asList.pExprList->ExprType = HB_ET_VARIABLE; break; @@ -1368,8 +1244,8 @@ static HB_EXPR_FUNC( hb_compExprUseArrayAt ) break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asList.pExprList ); - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asList.pIndex ); + HB_COMP_EXPR_DELETE( pSelf->value.asList.pExprList ); + HB_COMP_EXPR_DELETE( pSelf->value.asList.pIndex ); break; } return pSelf; @@ -1391,7 +1267,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) case HB_EA_PUSH_PCODE: if( pSelf->value.asMacro.SubType & HB_ET_MACRO_ASSIGN ) - HB_EXPR_PCODE2( hb_compGenPushString, "_", 2 ); + HB_GEN_FUNC2( PushString, "_", 2 ); if( pSelf->value.asMacro.pExprList ) { @@ -1407,7 +1283,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) /* simple macro variable expansion: &variable * 'szMacro' is a variable name */ - HB_EXPR_PCODE2( hb_compGenPushVar, pSelf->value.asMacro.szMacro, TRUE ); + HB_GEN_FUNC2( PushVar, pSelf->value.asMacro.szMacro, TRUE ); } else { @@ -1424,23 +1300,23 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) ); #endif - HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) + 1 ); + HB_GEN_FUNC2( PushString, pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) + 1 ); } } if( pSelf->value.asMacro.SubType & HB_ET_MACRO_ASSIGN ) { - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PLUS ); + HB_GEN_FUNC1( PCode1, HB_P_PLUS ); pSelf->value.asMacro.SubType &= ~HB_ET_MACRO_ASSIGN; } /* compile & run - leave a result on the eval stack */ if( pSelf->value.asMacro.SubType == HB_ET_MACRO_SYMBOL ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROSYMBOL ); + HB_GEN_FUNC1( PCode1, HB_P_MACROSYMBOL ); else if( pSelf->value.asMacro.SubType == HB_ET_MACRO_REFER ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHREF ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHREF ); else if( pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) { @@ -1449,27 +1325,27 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) if( pSelf->value.asMacro.SubType & HB_ET_MACRO_LIST ) { /* { ¯o }, funCall( ¯o ) or var[ ¯o ] */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHLIST ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHLIST ); } else if( pSelf->value.asMacro.SubType & HB_ET_MACRO_PARE ) { /* var := (somevalue, ¯o) - in xbase compatibility mode * EVAL( {|| ¯o} ) - in all cases */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHPARE ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHPARE ); } else { /* usual ¯o */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSH ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSH ); } } else /* usual ¯o */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSH ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSH ); /* Always add byte to pcode indicating requested macro compiler flag. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_MACRO_GENFLAGS ); + HB_GEN_FUNC1( PCode1, HB_MACRO_GENFLAGS ); } /* NOTE: pcode for alias context is generated in @@ -1492,7 +1368,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) /* simple macro variable expansion: &variable * 'szMacro' is a variable name */ - HB_EXPR_PCODE2( hb_compGenPushVar, pSelf->value.asMacro.szMacro, TRUE ); + HB_GEN_FUNC2( PushVar, pSelf->value.asMacro.szMacro, TRUE ); } else { @@ -1509,7 +1385,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) ); #endif - HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) + 1 ); + HB_GEN_FUNC2( PushString, pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) + 1 ); } } /* compile & run - macro compiler will generate pcode to pop a value @@ -1517,22 +1393,22 @@ static HB_EXPR_FUNC( hb_compExprUseMacro ) */ if( pSelf->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) { - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOP ); + HB_GEN_FUNC1( PCode1, HB_P_MACROPOP ); /* Always add byte to pcode indicating requested macro compiler flag. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_MACRO_GENFLAGS ); + HB_GEN_FUNC1( PCode1, HB_MACRO_GENFLAGS ); } break; case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); break; case HB_EA_DELETE: if( pSelf->value.asMacro.pExprList ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMacro.pExprList ); + HB_COMP_EXPR_DELETE( pSelf->value.asMacro.pExprList ); break; } return pSelf; @@ -1601,12 +1477,12 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME ) { - hb_compGenPushFunCall( pSelf->value.asFunCall.pFunName->value.asSymbol, HB_COMP_PARAM ); + HB_GEN_FUNC1( PushFunCall, pSelf->value.asFunCall.pFunName->value.asSymbol ); } else { HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHNIL ); } /* NOTE: pParms will be NULL in 'DO procname' (if there is @@ -1622,14 +1498,14 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( fArgsList ) { - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_MACROFUNC, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + HB_GEN_FUNC3( PCode3, HB_P_MACROFUNC, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); /* restore original expression type */ pSelf->value.asFunCall.pParms->ExprType = HB_ET_ARGLIST; } else if( usCount > 255 ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_FUNCTION, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + HB_GEN_FUNC3( PCode3, HB_P_FUNCTION, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); else - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_FUNCTIONSHORT, ( BYTE ) usCount ); + HB_GEN_FUNC2( PCode2, HB_P_FUNCTIONSHORT, ( BYTE ) usCount ); break; } case HB_EA_POP_PCODE: @@ -1643,12 +1519,12 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( pSelf->value.asFunCall.pFunName->ExprType == HB_ET_FUNNAME ) { - hb_compGenPushFunCall( pSelf->value.asFunCall.pFunName->value.asSymbol, HB_COMP_PARAM ); + HB_GEN_FUNC1( PushFunCall, pSelf->value.asFunCall.pFunName->value.asSymbol ); } else { HB_EXPR_USE( pSelf->value.asFunCall.pFunName, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHNIL ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHNIL ); } if( pSelf->value.asFunCall.pParms ) @@ -1661,20 +1537,20 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( fArgsList ) { - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_MACRODO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + HB_GEN_FUNC3( PCode3, HB_P_MACRODO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); /* restore original expression type */ pSelf->value.asFunCall.pParms->ExprType = HB_ET_ARGLIST; } else if( usCount > 255 ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); + HB_GEN_FUNC3( PCode3, HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ) ); else - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_DOSHORT, ( BYTE ) usCount ); + HB_GEN_FUNC2( PCode2, HB_P_DOSHORT, ( BYTE ) usCount ); break; } case HB_EA_DELETE: if( pSelf->value.asFunCall.pParms ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asFunCall.pParms ); - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asFunCall.pFunName ); + HB_COMP_EXPR_DELETE( pSelf->value.asFunCall.pParms ); + HB_COMP_EXPR_DELETE( pSelf->value.asFunCall.pFunName ); break; } return pSelf; @@ -1723,7 +1599,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) * * NOTE: TRUE = push also alias */ - HB_EXPR_PCODE4( hb_compGenPushAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, pAlias->value.asSymbol, 0 ); + HB_GEN_FUNC4( PushAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, pAlias->value.asSymbol, 0 ); } else if( pAlias->ExprType == HB_ET_NUMERIC ) { @@ -1733,7 +1609,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) * NOTE: only integer (long) values are allowed */ if( pAlias->value.asNum.NumType == HB_ET_LONG ) - HB_EXPR_PCODE4( hb_compGenPushAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, NULL, pAlias->value.asNum.val.l ); + HB_GEN_FUNC4( PushAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, NULL, pAlias->value.asNum.val.l ); else hb_compErrorAlias( HB_COMP_PARAM, pAlias ); } @@ -1745,7 +1621,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) * NOTE: FALSE = don't push alias value */ HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE4( hb_compGenPushAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, FALSE, NULL, 0 ); + HB_GEN_FUNC4( PushAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, FALSE, NULL, 0 ); } else hb_compErrorAlias( HB_COMP_PARAM, pAlias ); @@ -1777,7 +1653,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) * FIELD->var * MEMVAR->var */ - HB_EXPR_PCODE4( hb_compGenPopAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, pAlias->value.asSymbol, 0 ); + HB_GEN_FUNC4( PopAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, pAlias->value.asSymbol, 0 ); } else if( pAlias->ExprType == HB_ET_NUMERIC ) { @@ -1787,7 +1663,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) * NOTE: only integer (long) values are allowed */ if( pAlias->value.asNum.NumType == HB_ET_LONG ) - HB_EXPR_PCODE4( hb_compGenPopAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, NULL, pAlias->value.asNum.val.l ); + HB_GEN_FUNC4( PopAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, TRUE, NULL, pAlias->value.asNum.val.l ); else hb_compErrorAlias( HB_COMP_PARAM, pAlias ); } @@ -1807,7 +1683,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) else { HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE4( hb_compGenPopAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, FALSE, NULL, 0 ); + HB_GEN_FUNC4( PopAliasedVar, pSelf->value.asAlias.pVar->value.asSymbol, FALSE, NULL, 0 ); } } else @@ -1817,13 +1693,13 @@ static HB_EXPR_FUNC( hb_compExprUseAliasVar ) case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asAlias.pAlias ); + HB_COMP_EXPR_DELETE( pSelf->value.asAlias.pAlias ); if( pSelf->value.asAlias.pVar ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asAlias.pVar ); + HB_COMP_EXPR_DELETE( pSelf->value.asAlias.pVar ); break; } return pSelf; @@ -1847,13 +1723,13 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) case HB_EA_PUSH_PCODE: /* save currently selected workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHALIAS ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHALIAS ); /* push the expression that will return a new workarea */ HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_PUSH_PCODE ); /* pop the value from the stack and select it as current workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POPALIAS ); + HB_GEN_FUNC1( PCode1, HB_P_POPALIAS ); /* evaluate any expression */ HB_EXPR_USE( pSelf->value.asAlias.pExpList, HB_EA_PUSH_PCODE ); @@ -1862,7 +1738,7 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) * is previously selected workarea. After swaping select again * the restored workarea. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_SWAPALIAS ); + HB_GEN_FUNC1( PCode1, HB_P_SWAPALIAS ); break; case HB_EA_POP_PCODE: @@ -1873,25 +1749,25 @@ static HB_EXPR_FUNC( hb_compExprUseAliasExpr ) case HB_EA_STATEMENT: /* save currently selected workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHALIAS ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHALIAS ); /* push the expression that will return a new workarea */ HB_EXPR_USE( pSelf->value.asAlias.pAlias, HB_EA_PUSH_PCODE ); /* pop the value from the stack and select it as current workarea */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POPALIAS ); + HB_GEN_FUNC1( PCode1, HB_P_POPALIAS ); /* evaluate any expression - it will not leave any return * value on the eval stack */ HB_EXPR_USE( pSelf->value.asAlias.pExpList, HB_EA_PUSH_POP ); /* Pop and select again the restored workarea. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POPALIAS ); + HB_GEN_FUNC1( PCode1, HB_P_POPALIAS ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asAlias.pAlias ); - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asAlias.pExpList ); + HB_COMP_EXPR_DELETE( pSelf->value.asAlias.pAlias ); + HB_COMP_EXPR_DELETE( pSelf->value.asAlias.pExpList ); break; } return pSelf; @@ -1908,7 +1784,7 @@ static HB_EXPR_FUNC( hb_compExprUseAlias ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE3( hb_compGenPushSymbol, pSelf->value.asSymbol, FALSE, TRUE ); + HB_GEN_FUNC3( PushSymbol, pSelf->value.asSymbol, FALSE, TRUE ); break; case HB_EA_POP_PCODE: @@ -1933,7 +1809,7 @@ static HB_EXPR_FUNC( hb_compExprUseFunName ) break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE1( hb_compGenPushFunSym, pSelf->value.asSymbol ); + HB_GEN_FUNC1( PushFunSym, pSelf->value.asSymbol ); break; case HB_EA_POP_PCODE: @@ -1956,13 +1832,13 @@ static HB_EXPR_FUNC( hb_compExprUseRTVariable ) break; case HB_EA_PUSH_PCODE: if( pSelf->value.asRTVar.szName ) - HB_EXPR_PCODE3( hb_compGenPushSymbol, pSelf->value.asRTVar.szName, FALSE, FALSE ); /* this is not a functio */ + HB_GEN_FUNC3( PushSymbol, pSelf->value.asRTVar.szName, FALSE, FALSE ); /* this is not a functio */ else HB_EXPR_USE( pSelf->value.asRTVar.pMacro, HB_EA_PUSH_PCODE ); break; case HB_EA_POP_PCODE: if( pSelf->value.asRTVar.szName ) - HB_EXPR_PCODE1( hb_compGenPopVar, pSelf->value.asRTVar.szName ); + HB_GEN_FUNC1( PopVar, pSelf->value.asRTVar.szName ); else HB_EXPR_USE( pSelf->value.asRTVar.pMacro, HB_EA_POP_PCODE ); break; @@ -1973,7 +1849,7 @@ static HB_EXPR_FUNC( hb_compExprUseRTVariable ) case HB_EA_DELETE: #if ! defined( HB_MACRO_SUPPORT ) if( ! pSelf->value.asRTVar.szName ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asRTVar.pMacro ); + HB_COMP_EXPR_DELETE( pSelf->value.asRTVar.pMacro ); #endif break; } @@ -2002,12 +1878,12 @@ static HB_EXPR_FUNC( hb_compExprUseVariable ) * genearate alias aware pcode even if we known a variable part only. */ if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_ALIASED ) - HB_EXPR_PCODE4( hb_compGenPushAliasedVar, pSelf->value.asSymbol, FALSE, NULL, 0 ); + HB_GEN_FUNC4( PushAliasedVar, pSelf->value.asSymbol, FALSE, NULL, 0 ); else - HB_EXPR_PCODE2( hb_compGenPushVar, pSelf->value.asSymbol, FALSE ); + HB_GEN_FUNC2( PushVar, pSelf->value.asSymbol, FALSE ); } #else - HB_EXPR_PCODE2( hb_compGenPushVar, pSelf->value.asSymbol, FALSE ); + HB_GEN_FUNC2( PushVar, pSelf->value.asSymbol, FALSE ); #endif break; @@ -2015,19 +1891,19 @@ static HB_EXPR_FUNC( hb_compExprUseVariable ) #if defined( HB_MACRO_SUPPORT ) { if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_ALIASED ) - HB_EXPR_PCODE4( hb_compGenPopAliasedVar, pSelf->value.asSymbol, FALSE, NULL, 0 ); + HB_GEN_FUNC4( PopAliasedVar, pSelf->value.asSymbol, FALSE, NULL, 0 ); else - HB_EXPR_PCODE1( hb_compGenPopVar, pSelf->value.asSymbol ); + HB_GEN_FUNC1( PopVar, pSelf->value.asSymbol ); } #else - HB_EXPR_PCODE1( hb_compGenPopVar, pSelf->value.asSymbol ); + HB_GEN_FUNC1( PopVar, pSelf->value.asSymbol ); #endif break; case HB_EA_PUSH_POP: case HB_EA_STATEMENT: - HB_EXPR_PCODE2( hb_compGenPushVar, pSelf->value.asSymbol, FALSE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC2( PushVar, pSelf->value.asSymbol, FALSE ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); break; case HB_EA_DELETE: @@ -2070,33 +1946,33 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) if( fArgsList ) { - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_MACROSEND, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ) ); + HB_GEN_FUNC3( PCode3, HB_P_MACROSEND, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ) ); /* restore original expression type */ pSelf->value.asMessage.pParms->ExprType = HB_ET_ARGLIST; } else if( iParms > 255 ) - HB_EXPR_PCODE3( hb_compGenPCode3, HB_P_SEND, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ) ); + HB_GEN_FUNC3( PCode3, HB_P_SEND, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ) ); else - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SENDSHORT, ( BYTE ) iParms ); + HB_GEN_FUNC2( PCode2, HB_P_SENDSHORT, ( BYTE ) iParms ); } else { /* acces to instance variable */ hb_compExprPushSendPush( pSelf, HB_COMP_PARAM ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 0 ); + HB_GEN_FUNC2( PCode2, HB_P_SENDSHORT, 0 ); } break; case HB_EA_POP_PCODE: hb_compExprPushSendPop( pSelf, HB_COMP_PARAM ); HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 1 ); + HB_GEN_FUNC2( PCode2, HB_P_SENDSHORT, 1 ); break; case HB_EA_PUSH_POP: case HB_EA_STATEMENT: HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); if( ! pSelf->value.asMessage.pParms ) /* Is it a method call ? */ { /* instance variable */ @@ -2111,15 +1987,15 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) { if( pSelf->value.asMessage.pObject ) { - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMessage.pObject ); + HB_COMP_EXPR_DELETE( pSelf->value.asMessage.pObject ); } if( pSelf->value.asMessage.pParms ) { - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMessage.pParms ); + HB_COMP_EXPR_DELETE( pSelf->value.asMessage.pParms ); } if( pSelf->value.asMessage.pMessage ) { - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asMessage.pMessage ); + HB_COMP_EXPR_DELETE( pSelf->value.asMessage.pMessage ); } } break; @@ -2159,7 +2035,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostInc ) case HB_EA_DELETE: if( pSelf->value.asOperator.pLeft ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_DELETE( pSelf->value.asOperator.pLeft ); break; } return pSelf; @@ -2195,7 +2071,7 @@ static HB_EXPR_FUNC( hb_compExprUsePostDec ) case HB_EA_DELETE: if( pSelf->value.asOperator.pLeft ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_DELETE( pSelf->value.asOperator.pLeft ); break; } return pSelf; @@ -2237,7 +2113,7 @@ static HB_EXPR_FUNC( hb_compExprUseAssign ) HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); /* QUESTION: Can we replace DUPLICATE+POP with a single PUT opcode */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHUNREF ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHUNREF ); HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); } break; @@ -2260,7 +2136,7 @@ static HB_EXPR_FUNC( hb_compExprUseAssign ) HB_EXPR_USE( pObj, HB_EA_POP_PCODE ); pObj->value.asMessage.pParms = NULL; /* to suppress duplicated releasing */ /* Remove the return value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } else { @@ -2288,7 +2164,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlusEq ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2328,7 +2204,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinusEq ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2368,7 +2244,7 @@ static HB_EXPR_FUNC( hb_compExprUseMultEq ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2408,7 +2284,7 @@ static HB_EXPR_FUNC( hb_compExprUseDivEq ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2448,7 +2324,7 @@ static HB_EXPR_FUNC( hb_compExprUseModEq ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2488,7 +2364,7 @@ static HB_EXPR_FUNC( hb_compExprUseExpEq ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2528,7 +2404,7 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2545,17 +2421,17 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - lEndPos = HB_EXPR_PCODE1( hb_compGenJumpTrue, 0 ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + lEndPos = HB_GEN_FUNC1( JumpTrue, 0 ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenJumpHere, lEndPos ); + HB_GEN_FUNC1( JumpHere, lEndPos ); } else { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_OR ); + HB_GEN_FUNC1( PCode1, HB_P_OR ); } break; @@ -2567,7 +2443,7 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) { LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - lEndPos = HB_EXPR_PCODE1( hb_compGenJumpTrue, 0 ); + lEndPos = HB_GEN_FUNC1( JumpTrue, 0 ); /* NOTE: This will not generate a runtime error if incompatible * data type is used */ @@ -2582,17 +2458,17 @@ static HB_EXPR_FUNC( hb_compExprUseOr ) HB_COMP_PARAM->fMeaningful = fMeaningful; } #endif - HB_EXPR_PCODE1( hb_compGenJumpHere, lEndPos ); + HB_GEN_FUNC1( JumpHere, lEndPos ); } else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -2613,7 +2489,7 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2630,17 +2506,17 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - lEndPos = HB_EXPR_PCODE1( hb_compGenJumpFalse, 0 ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + lEndPos = HB_GEN_FUNC1( JumpFalse, 0 ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenJumpHere, lEndPos ); + HB_GEN_FUNC1( JumpHere, lEndPos ); } else { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_AND ); + HB_GEN_FUNC1( PCode1, HB_P_AND ); } break; @@ -2652,7 +2528,7 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) { LONG lEndPos; HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - lEndPos = HB_EXPR_PCODE1( hb_compGenJumpFalse, 0 ); + lEndPos = HB_GEN_FUNC1( JumpFalse, 0 ); /* NOTE: This will not generate a runtime error if incompatible * data type is used */ @@ -2667,17 +2543,17 @@ static HB_EXPR_FUNC( hb_compExprUseAnd ) HB_COMP_PARAM->fMeaningful = fMeaningful; } #endif - HB_EXPR_PCODE1( hb_compGenJumpHere, lEndPos ); + HB_GEN_FUNC1( JumpHere, lEndPos ); } else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -2702,7 +2578,7 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) { pExpr->value.asLogical = ! pExpr->value.asLogical; pSelf->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */ - HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + HB_COMP_EXPR_DELETE( pSelf ); pSelf = pExpr; } else if( pExpr->ExprType == HB_EO_NOT && HB_SUPPORT_HARBOUR ) @@ -2712,13 +2588,13 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) */ pExpr->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */ pExpr = pExpr->value.asOperator.pLeft; - HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + HB_COMP_EXPR_DELETE( pSelf ); pSelf = pExpr; } break; } case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2731,7 +2607,7 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_NOT ); + HB_GEN_FUNC1( PCode1, HB_P_NOT ); break; case HB_EA_POP_PCODE: @@ -2748,16 +2624,16 @@ static HB_EXPR_FUNC( hb_compExprUseNot ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_DELETE( pSelf->value.asOperator.pLeft ); break; } return pSelf; @@ -2774,7 +2650,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2786,7 +2662,7 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_EQUAL ); + HB_GEN_FUNC1( PCode1, HB_P_EQUAL ); break; case HB_EA_POP_PCODE: @@ -2804,12 +2680,12 @@ static HB_EXPR_FUNC( hb_compExprUseEqual ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -2832,7 +2708,7 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2844,7 +2720,7 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_EXACTLYEQUAL ); + HB_GEN_FUNC1( PCode1, HB_P_EXACTLYEQUAL ); break; case HB_EA_POP_PCODE: @@ -2862,12 +2738,12 @@ static HB_EXPR_FUNC( hb_compExprUseEQ ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -2888,7 +2764,7 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2900,7 +2776,7 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_LESS ); + HB_GEN_FUNC1( PCode1, HB_P_LESS ); break; case HB_EA_POP_PCODE: @@ -2918,12 +2794,12 @@ static HB_EXPR_FUNC( hb_compExprUseLT ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -2944,7 +2820,7 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -2956,7 +2832,7 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_GREATER ); + HB_GEN_FUNC1( PCode1, HB_P_GREATER ); break; case HB_EA_POP_PCODE: @@ -2974,12 +2850,12 @@ static HB_EXPR_FUNC( hb_compExprUseGT ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3000,7 +2876,7 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3013,7 +2889,7 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_LESSEQUAL ); + HB_GEN_FUNC1( PCode1, HB_P_LESSEQUAL ); break; case HB_EA_POP_PCODE: @@ -3031,12 +2907,12 @@ static HB_EXPR_FUNC( hb_compExprUseLE ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3057,7 +2933,7 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3070,7 +2946,7 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_GREATEREQUAL ); + HB_GEN_FUNC1( PCode1, HB_P_GREATEREQUAL ); break; case HB_EA_POP_PCODE: @@ -3088,12 +2964,12 @@ static HB_EXPR_FUNC( hb_compExprUseGE ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3114,7 +2990,7 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3127,7 +3003,7 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_NOTEQUAL ); + HB_GEN_FUNC1( PCode1, HB_P_NOTEQUAL ); break; case HB_EA_POP_PCODE: @@ -3145,12 +3021,12 @@ static HB_EXPR_FUNC( hb_compExprUseNE ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3173,7 +3049,7 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3186,7 +3062,7 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INSTRING ); + HB_GEN_FUNC1( PCode1, HB_P_INSTRING ); break; case HB_EA_POP_PCODE: @@ -3204,12 +3080,12 @@ static HB_EXPR_FUNC( hb_compExprUseIN ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3230,7 +3106,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3254,7 +3130,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) pLeft->value.asNum.val.d == 1 ) { HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC ); + HB_GEN_FUNC1( PCode1, HB_P_INC ); break; } else if( pLeft->value.asNum.NumType == HB_ET_LONG ? @@ -3262,7 +3138,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) pLeft->value.asNum.val.d == -1 ) { HB_EXPR_USE( pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DEC ); + HB_GEN_FUNC1( PCode1, HB_P_DEC ); break; } } @@ -3273,7 +3149,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) pRight->value.asNum.val.d == 1 ) { HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC ); + HB_GEN_FUNC1( PCode1, HB_P_INC ); break; } else if( pRight->value.asNum.NumType == HB_ET_LONG ? @@ -3281,7 +3157,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) pRight->value.asNum.val.d == -1 ) { HB_EXPR_USE( pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DEC ); + HB_GEN_FUNC1( PCode1, HB_P_DEC ); break; } } @@ -3289,7 +3165,7 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) #endif HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PLUS ); + HB_GEN_FUNC1( PCode1, HB_P_PLUS ); break; case HB_EA_POP_PCODE: @@ -3307,12 +3183,12 @@ static HB_EXPR_FUNC( hb_compExprUsePlus ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3333,7 +3209,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3355,7 +3231,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) pRight->value.asNum.val.d == 1 ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DEC ); + HB_GEN_FUNC1( PCode1, HB_P_DEC ); break; } else if( pRight->value.asNum.NumType == HB_ET_LONG ? @@ -3363,7 +3239,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) pRight->value.asNum.val.d == -1 ) { HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_INC ); + HB_GEN_FUNC1( PCode1, HB_P_INC ); break; } } @@ -3371,7 +3247,7 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) #endif HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MINUS ); + HB_GEN_FUNC1( PCode1, HB_P_MINUS ); break; case HB_EA_POP_PCODE: @@ -3389,12 +3265,12 @@ static HB_EXPR_FUNC( hb_compExprUseMinus ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3415,7 +3291,7 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3428,7 +3304,7 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MULT ); + HB_GEN_FUNC1( PCode1, HB_P_MULT ); break; case HB_EA_POP_PCODE: @@ -3446,12 +3322,12 @@ static HB_EXPR_FUNC( hb_compExprUseMult ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3472,7 +3348,7 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3485,7 +3361,7 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DIVIDE ); + HB_GEN_FUNC1( PCode1, HB_P_DIVIDE ); break; case HB_EA_POP_PCODE: @@ -3503,12 +3379,12 @@ static HB_EXPR_FUNC( hb_compExprUseDiv ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3529,7 +3405,7 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3542,7 +3418,7 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MODULUS ); + HB_GEN_FUNC1( PCode1, HB_P_MODULUS ); break; case HB_EA_POP_PCODE: @@ -3560,12 +3436,12 @@ static HB_EXPR_FUNC( hb_compExprUseMod ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3583,7 +3459,7 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3596,7 +3472,7 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POWER ); + HB_GEN_FUNC1( PCode1, HB_P_POWER ); break; case HB_EA_POP_PCODE: @@ -3614,12 +3490,12 @@ static HB_EXPR_FUNC( hb_compExprUsePower ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: @@ -3647,13 +3523,13 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) else pExpr->value.asNum.val.l = - pExpr->value.asNum.val.l; pSelf->ExprType = HB_ET_NONE; /* do not delete operator parameter - we are still using it */ - HB_EXPR_PCODE1( hb_compExprDelete, pSelf ); + HB_COMP_EXPR_DELETE( pSelf ); pSelf = pExpr; } break; } case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3665,7 +3541,7 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) case HB_EA_PUSH_PCODE: HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_NEGATE ); + HB_GEN_FUNC1( PCode1, HB_P_NEGATE ); break; case HB_EA_POP_PCODE: @@ -3682,17 +3558,17 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ) else { HB_EXPR_USE( pSelf, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); + HB_GEN_FUNC1( PCode1, HB_P_POP ); } break; case HB_EA_STATEMENT: - hb_compErrorSyntax( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_SYNTAX( pSelf ); break; case HB_EA_DELETE: if( pSelf->value.asOperator.pLeft ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_DELETE( pSelf->value.asOperator.pLeft ); break; } return pSelf; @@ -3708,7 +3584,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreInc ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3732,7 +3608,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreInc ) case HB_EA_DELETE: if( pSelf->value.asOperator.pLeft ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_DELETE( pSelf->value.asOperator.pLeft ); break; } return pSelf; @@ -3748,7 +3624,7 @@ static HB_EXPR_FUNC( hb_compExprUsePreDec ) break; case HB_EA_ARRAY_AT: - hb_compErrorType( HB_COMP_PARAM, pSelf ); + HB_COMP_ERROR_TYPE( pSelf ); break; case HB_EA_ARRAY_INDEX: @@ -3772,8 +3648,1017 @@ static HB_EXPR_FUNC( hb_compExprUsePreDec ) case HB_EA_DELETE: if( pSelf->value.asOperator.pLeft ) - HB_EXPR_PCODE1( hb_compExprDelete, pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_DELETE( pSelf->value.asOperator.pLeft ); break; } return pSelf; } + +/* ************************************************************************* */ + +/* This generates a push pcode for a codeblock (with no macro expression or + with late evaluation of a macro) +*/ +#if defined( HB_MACRO_SUPPORT ) +static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, HB_COMP_DECL ) +#else +static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, BOOL bLateEval, HB_COMP_DECL ) +#endif +{ + HB_EXPR_PTR pExpr, pNext; + HB_EXPR_PTR * pPrev; + + /* Define requested local variables + */ +#if defined( HB_MACRO_SUPPORT ) + hb_macroCodeBlockStart( HB_COMP_PARAM ); + HB_PCODE_DATA->pLocals = pSelf->value.asCodeblock.pLocals; + HB_PCODE_DATA->fVParams = + ( pSelf->value.asCodeblock.flags & HB_BLOCK_VPARAMS ) != 0; +#else + hb_compCodeBlockStart( HB_COMP_PARAM, bLateEval ); + HB_COMP_PARAM->functions.pLast->fVParams = + ( pSelf->value.asCodeblock.flags & HB_BLOCK_VPARAMS ) != 0; + + { + HB_CBVAR_PTR pVar; + + pVar = pSelf->value.asCodeblock.pLocals; + while( pVar ) + { + hb_compVariableAdd( HB_COMP_PARAM, pVar->szName, pVar->bType ); + pVar =pVar->pNext; + } + } + + HB_EXPR_PCODE0( hb_compLinePushIfDebugger ); +#endif + pExpr = pSelf->value.asCodeblock.pExprList; + pPrev = &pSelf->value.asCodeblock.pExprList; + while( pExpr ) + { + if( pExpr->ExprType == HB_ET_MACRO && + pExpr->value.asMacro.SubType != HB_ET_MACRO_SYMBOL && + pExpr->value.asMacro.SubType != HB_ET_MACRO_REFER && + pExpr->value.asMacro.SubType != HB_ET_MACRO_ALIASED ) + { + /* Clipper allows for list expressions in a codeblock + * macro := "1,2" + * EVAL( {|| ¯o} ) + */ + pExpr->value.asMacro.SubType |= HB_ET_MACRO_PARE; + } + + /* store next expression in case the current will be reduced + * NOTE: During reduction the expression can be replaced by the + * new one - this will break the linked list of expressions. + */ + pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ + pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); + /* Generate push/pop pcodes for all expresions except the last one + * The value of the last expression is used as a return value + * of a codeblock evaluation + */ + /* NOTE: This will genereate warnings if constant value is + * used as an expression - some operators will generate it too + * e.g. + * EVAL( {|| 3+5, func()} ) + */ + *pPrev = pExpr; /* store a new expression into the previous one */ + pExpr->pNext = pNext; /* restore the link to next expression */ +#if defined( HB_MACRO_SUPPORT ) + if( pNext ) + HB_EXPR_USE( pExpr, HB_EA_PUSH_POP ); + else + HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); +#else + if( pNext && bLateEval ) + HB_EXPR_USE( pExpr, HB_EA_PUSH_POP ); + else + HB_EXPR_USE( pExpr, HB_EA_PUSH_PCODE ); +#endif + pPrev = &pExpr->pNext; + pExpr = pNext; + } +#if defined( HB_MACRO_SUPPORT ) + hb_macroCodeBlockEnd( HB_COMP_PARAM ); +#else + if( bLateEval ) + hb_compCodeBlockEnd( HB_COMP_PARAM ); + else + hb_compCodeBlockRewind( HB_COMP_PARAM ); +#endif +} + +/* This generates a push pcode for early evaluation of a macro +*/ +#if !defined(HB_MACRO_SUPPORT) +static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf, HB_COMP_DECL ) +{ + HB_EXPR_PTR pExpr; + + /* check first expression */ + pExpr = pSelf->value.asCodeblock.pExprList; + if( pExpr->ExprType == HB_ET_MACRO && pExpr->value.asMacro.cMacroOp ) + { + /* simple macro variable expansion: &variable + * 'szMacro' is a variable name + * {|| &variable} => &( '{||' + variable +'}' ) + */ + HB_EXPR_PTR pVar, pNew; + + pVar = hb_compExprNewVar( pExpr->value.asMacro.szMacro, HB_COMP_PARAM ); + pNew = hb_compExprNewString( "{||", 3, FALSE, HB_COMP_PARAM ); + pNew = hb_compExprSetOperand( hb_compExprNewPlus( pNew, HB_COMP_PARAM ), pVar, HB_COMP_PARAM ); + pNew = hb_compExprSetOperand( hb_compExprNewPlus( pNew, HB_COMP_PARAM ), hb_compExprNewString( "}", 1, FALSE, HB_COMP_PARAM ), HB_COMP_PARAM ); + pNew = hb_compExprNewMacro( pNew, 0, NULL, HB_COMP_PARAM ); + HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE ); + HB_COMP_EXPR_DELETE( pNew ); + } + else + { + /* everything else is macro compiled at runtime + * {|| &variable+1} => &( '{|| &variable+1}' ) + */ + HB_EXPR_PTR pNew; + + hb_compExprCodeblockPush( pSelf, FALSE, HB_COMP_PARAM ); + pNew = hb_compExprNewMacro( hb_compExprNewString( pSelf->value.asCodeblock.string, pSelf->value.asCodeblock.length, FALSE, HB_COMP_PARAM ), 0, NULL, HB_COMP_PARAM ); + HB_EXPR_USE( pNew, HB_EA_PUSH_PCODE ); + HB_COMP_EXPR_DELETE( pNew ); + hb_compCodeBlockStop( HB_COMP_PARAM ); + } +} +#endif /*HB_MACRO_SUPPORT*/ + + +static void hb_compExprPushSendPop( HB_EXPR_PTR pSelf, HB_COMP_DECL ) +{ + if( pSelf->value.asMessage.pObject ) + { + /* Push _message */ + if( pSelf->value.asMessage.szMessage ) + { + HB_GEN_FUNC2( MessageData, pSelf->value.asMessage.szMessage, TRUE ); + } + else + { + if( pSelf->value.asMessage.pMessage->ExprType == HB_ET_MACRO ) + /* o:¯o := value + * set ASSIGN flag in macro expression + * it's cleared just after use + */ + pSelf->value.asMessage.pMessage->value.asMacro.SubType |= HB_ET_MACRO_ASSIGN; + + HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); + } + /* Push object */ + HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_PUSH_PCODE ); + } + else /* WITH OBJECT */ + { + /* Push _message and object */ + if( pSelf->value.asMessage.szMessage ) + { + HB_GEN_FUNC2( MessageData, pSelf->value.asMessage.szMessage, FALSE ); + } + else + { + if( pSelf->value.asMessage.pMessage->ExprType == HB_ET_MACRO ) + /* o:¯o := value + * set ASSIGN flag in macro expression + * it's cleared just after use + */ + pSelf->value.asMessage.pMessage->value.asMacro.SubType |= HB_ET_MACRO_ASSIGN; + + HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); + /* Push object using WITHOBJECTMESSAGE pcode */ + HB_GEN_FUNC2( Message, NULL, FALSE ); + } + } +} + +static void hb_compExprPushSendPush( HB_EXPR_PTR pSelf, HB_COMP_DECL ) +{ + if( pSelf->value.asMessage.pObject ) + { + /* Push message */ + if( pSelf->value.asMessage.szMessage ) + { + HB_GEN_FUNC2( Message, pSelf->value.asMessage.szMessage, TRUE ); + } + else + { + HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); + } + /* Push object */ + HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_PUSH_PCODE ); + } + else /* WITH OBJECT */ + { + if( pSelf->value.asMessage.szMessage ) + { + /* Push message and object */ + HB_GEN_FUNC2( Message, pSelf->value.asMessage.szMessage, FALSE ); + } + else + { + /* Push message */ + HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); + /* Push object using WITHOBJECTMESSAGE pcode */ + HB_GEN_FUNC2( Message, NULL, FALSE ); + } + } +} + +static void hb_compExprPushSendPopPush( HB_EXPR_PTR pObj, HB_EXPR_PTR pValue, + BOOL fPreOp, BYTE bOper, HB_COMP_DECL ) +{ + if( HB_SUPPORT_HARBOUR ) + { + hb_compExprPushSendPop( pObj, HB_COMP_PARAM ); + /* duplicate object variable */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + /* Push message */ + if( pObj->value.asMessage.szMessage ) + { + /* TRUE used intnetionally to not push object variable in WITH OBJECT */ + HB_GEN_FUNC2( Message, pObj->value.asMessage.szMessage, TRUE ); + } + else + { + HB_EXPR_USE( pObj->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); + } + HB_GEN_FUNC2( PCode2, HB_P_SWAP, 0 ); + HB_GEN_FUNC2( PCode2, HB_P_SENDSHORT, 0 ); + if( fPreOp ) + { + /* push the result on the stack */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + HB_GEN_FUNC2( PCode2, HB_P_SWAP, 2 ); + } + } + else + { + if( fPreOp ) + { + /* push current value - it will be a result of whole expression */ + HB_EXPR_USE( pObj, HB_EA_PUSH_PCODE ); + } + hb_compExprPushSendPop( pObj, HB_COMP_PARAM ); + hb_compExprPushSendPush( pObj, HB_COMP_PARAM ); + HB_GEN_FUNC2( PCode2, HB_P_SENDSHORT, 0 ); + } + /* push increment value */ + if( pValue ) + { + HB_EXPR_USE( pValue, HB_EA_PUSH_PCODE ); + } + /* do operation */ + HB_GEN_FUNC1( PCode1, bOper ); + /* Now do the assignment - call pop message with one argument */ + HB_GEN_FUNC2( PCode2, HB_P_SENDSHORT, 1 ); + if( fPreOp ) + { + /* pop the unneeded value left by assignment message from the stack */ + HB_GEN_FUNC1( PCode1, HB_P_POP ); + } +} + +/* Generates pcodes for compound operators += -= *= /= %= ^= + * + * pExpr is an expression created by hb_compExprNewEq functions + */ +/* NOTE: COMPATIBILITY ISSUE: + * The HB_SUPPORT_HARBOUR in code below determines + * the way the chained send messages are handled. + * For example, the following code: + * + * a:b( COUNT() ):c += 1 + * + * will be handled as: + * + * a:b( COUNT() ):c := a:b( COUNT() ):c + 1 + * + * in strict Clipper compatibility mode + * (HB_SUPPORT_HARBOUR is not set: -kc compiler switch ) and + * + * temp := a:b( COUNT() ), temp:c += 1 + * + * in non-strict mode (-kh). + * In practice in Clipper it will call COUNT() function two times: the + * first time before addition and the second one after addition - in Harbour, + * COUNT() function will be called only once, before addition. + * The Harbour (non-strict) method is: + * 1) faster + * 2) it guarantees that the same instance variable of the same object will + * be changed + */ + +static void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) +{ + BYTE bNewOp; + + if( HB_SUPPORT_HARBOUR ) + { + switch( bOpEq ) + { + case HB_P_PLUS: + bNewOp = HB_P_PLUSEQ; + break; + case HB_P_MINUS: + bNewOp = HB_P_MINUSEQ; + break; + case HB_P_MULT: + bNewOp = HB_P_MULTEQ; + break; + case HB_P_DIVIDE: + bNewOp = HB_P_DIVEQ; + break; + case HB_P_MODULUS: + bNewOp = HB_P_MODEQ; + break; + case HB_P_POWER: + bNewOp = HB_P_EXPEQ; + break; + default: + bNewOp = bOpEq; + break; + } + } + else + bNewOp = bOpEq; + + /* NOTE: an object instance variable needs special handling + */ + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) + { + + if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) + { + hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); + } +#ifdef HB_USE_OBJMSG_REF + else if( bOpEq != bNewOp ) + { + hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); + /* push increment value */ + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + } +#endif + else + { + hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, + pSelf->value.asOperator.pRight, + FALSE, bOpEq, HB_COMP_PARAM ); + } + return; + } + else if( bOpEq != bNewOp ) + { + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO ) + { + USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; + if( usType == HB_ET_MACRO_VAR ) + { + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; + return; + } + } +#ifdef HB_USE_ARRAYAT_REF + /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) + { + /* Note: change type to array reference */ + pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; + + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + return; + } +#endif + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) + { +#if defined( HB_MACRO_SUPPORT ) + { +#else + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR && + pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC && + ( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ) ) + { + if( hb_compExprIsInteger( pSelf->value.asOperator.pRight ) ) + { + short iIncrement = ( short ) pSelf->value.asOperator.pRight->value.asNum.val.l; + + if( bOpEq != HB_P_MINUS || iIncrement >= -INT16_MAX ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + BYTE buffer[ 5 ]; + + if( bOpEq == HB_P_MINUS ) + iIncrement = -iIncrement; + + buffer[ 0 ] = HB_P_LOCALADDINT; + buffer[ 1 ] = HB_LOBYTE( iLocal ); + buffer[ 2 ] = HB_HIBYTE( iLocal ); + buffer[ 3 ] = HB_LOBYTE( iIncrement ); + buffer[ 4 ] = HB_HIBYTE( iIncrement ); + HB_GEN_FUNC2( PCodeN, buffer, 5 ); + + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + return; + } + } + } +#endif + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + return; + } + } + } + /* push old value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + /* push increment value */ + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + /* perform operation and duplicate the new value */ + HB_GEN_FUNC1( PCode1, bOpEq ); + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + /* pop the new value into variable and leave the copy on the stack */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); +} + +/* Generates pcodes for = syntax + * used standalone as a statement (it cannot leave the value on the stack) + */ +static void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) +{ + BYTE bNewOp; + + if( HB_SUPPORT_HARBOUR ) + { + switch( bOpEq ) + { + case HB_P_PLUS: + bNewOp = HB_P_PLUSEQPOP; + break; + case HB_P_MINUS: + bNewOp = HB_P_MINUSEQPOP; + break; + case HB_P_MULT: + bNewOp = HB_P_MULTEQPOP; + break; + case HB_P_DIVIDE: + bNewOp = HB_P_DIVEQPOP; + break; + case HB_P_MODULUS: + bNewOp = HB_P_MODEQPOP; + break; + case HB_P_POWER: + bNewOp = HB_P_EXPEQPOP; + break; + default: + bNewOp = bOpEq; + break; + } + } + else + bNewOp = bOpEq; + + /* NOTE: an object instance variable needs special handling + */ + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) + { + if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) + { + hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); + } +#ifdef HB_USE_OBJMSG_REF + else if( bOpEq != bNewOp ) + { + hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); + /* push increment value */ + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + } +#endif + else + { + hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, + pSelf->value.asOperator.pRight, + FALSE, bOpEq, HB_COMP_PARAM ); + /* pop the unneeded value from the stack */ + HB_GEN_FUNC1( PCode1, HB_P_POP ); + } + return; + } + else if( bOpEq != bNewOp ) + { + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO ) + { + USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; + if( usType == HB_ET_MACRO_VAR ) + { + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; + return; + } + } +#ifdef HB_USE_ARRAYAT_REF + /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) + { + /* Note: change type to array reference */ + pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; + + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + return; + } +#endif + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) + { + HB_EXPRTYPE iOldType; +#if defined( HB_MACRO_SUPPORT ) + { +#else + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR && + pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC && + ( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ) ) + { + if( hb_compExprIsInteger( pSelf->value.asOperator.pRight ) ) + { + short iIncrement = ( short ) pSelf->value.asOperator.pRight->value.asNum.val.l; + + if( bOpEq != HB_P_MINUS || iIncrement >= -INT16_MAX ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + BYTE buffer[ 5 ]; + + if( bOpEq == HB_P_MINUS ) + iIncrement = -iIncrement; + + buffer[ 0 ] = HB_P_LOCALADDINT; + buffer[ 1 ] = HB_LOBYTE( iLocal ); + buffer[ 2 ] = HB_HIBYTE( iLocal ); + buffer[ 3 ] = HB_LOBYTE( iIncrement ); + buffer[ 4 ] = HB_HIBYTE( iIncrement ); + HB_GEN_FUNC2( PCodeN, buffer, 5 ); + return; + } + } + } +#endif + /* NOTE: direct type change */ + iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, bNewOp ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + return; + } + } + } + /* push old value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + /* push increment value */ + HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); + /* add */ + HB_GEN_FUNC1( PCode1, bOpEq ); + /* pop the new value into variable and remove it from the stack */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); +} + +/* Generates the pcodes for pre- increment/decrement expressions + */ +static void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) +{ + /* NOTE: an object instance variable needs special handling + */ + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) + { + if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) + { + hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); + } +#ifdef HB_USE_OBJMSG_REF + else if( HB_SUPPORT_HARBOUR ) + { + hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); + /* increase/decrease operation, leave unreferenced value on stack */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ ); + } +#endif + else + { + hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL, + FALSE, bOper, HB_COMP_PARAM ); + } + return; + } + else if( HB_SUPPORT_HARBOUR ) + { + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO && + pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR ) + { + USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; + + /* increase/decrease operation, leave unreferenced value on stack */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ ); + return; + } +#ifdef HB_USE_ARRAYAT_REF + /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) + { + /* push reference to current value */ + /* Note: change type to array reference */ + pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; + + /* increase/decrease operation, leave unreferenced value on stack */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ ); + return; + } +#endif +#if !defined( HB_MACRO_SUPPORT ) + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) + { + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + if( bOper == HB_P_INC ) + { + HB_GEN_FUNC3( PCode3, HB_P_LOCALINCPUSH, HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ) ); + } + else + { + HB_GEN_FUNC3( PCode3, HB_P_LOCALDEC, HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ) ); + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + } + } + else + { + /* NOTE: direct type change */ + HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + } + return; + } + } +#endif + } + + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + /* Increment */ + HB_GEN_FUNC1( PCode1, bOper ); + /* duplicate a value */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + /* pop new value and leave the duplicated copy of it on the stack */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); +} + +/* Generates the pcodes for post- increment/decrement expressions + */ +static void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) +{ + /* NOTE: an object instance variable needs special handling + */ + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) + { + if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) + { + hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); + } +#ifdef HB_USE_OBJMSG_REF + else if( HB_SUPPORT_HARBOUR ) + { + /* push reference to current value */ + hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); + /* Duplicate the reference and unref the original one - + * it will be the result of whole expression + */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLUNREF ); + /* increment/decrement the value */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + } +#endif + else + { + hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL, + TRUE, bOper, HB_COMP_PARAM ); + } + return; + } + else if( HB_SUPPORT_HARBOUR ) + { + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO && + pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR ) + { + USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; + + /* Duplicate the reference and unref the original one - + * it will be the result of whole expression + */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLUNREF ); + /* increase/decrease operation */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + return; + } +#ifdef HB_USE_ARRAYAT_REF + /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) + { + /* push reference to current value */ + /* Note: change type to array reference */ + pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; + + /* Duplicate the reference and unref the original one - + * it will be the result of whole expression + */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLUNREF ); + /* increase/decrease operation */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + return; + } +#endif +#if !defined( HB_MACRO_SUPPORT ) + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) + { + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC3( PCode3, ( bOper == HB_P_INC ) ? HB_P_LOCALINC : HB_P_LOCALDEC, + HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ) ); + } + else + { + /* NOTE: direct type change */ + HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, HB_P_DUPLUNREF ); + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + } + return; + } + } +#endif + } + + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + /* Duplicate value */ + HB_GEN_FUNC1( PCode1, HB_P_DUPLICATE ); + /* Increment */ + HB_GEN_FUNC1( PCode1, bOper ); + /* pop new value from the stack */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); +} + +/* Generates the pcodes for increment/decrement operations + * used standalone as a statement + */ +static void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) +{ + /* NOTE: an object instance variable needs special handling + */ + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) + { + if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) + { + hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); + } +#ifdef HB_USE_OBJMSG_REF + else if( HB_SUPPORT_HARBOUR ) + { + /* push reference to current value */ + hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); + HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF ); + /* increment/decrement the value */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + } +#endif + else + { + hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL, + FALSE, bOper, HB_COMP_PARAM ); + /* pop the value from the stack */ + HB_GEN_FUNC1( PCode1, HB_P_POP ); + } + return; + } + else if( HB_SUPPORT_HARBOUR ) + { + if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO && + pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR ) + { + USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; + /* NOTE: direct type change */ + pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; + + /* increase/decrease operation */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + return; + } +#ifdef HB_USE_ARRAYAT_REF + /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) + { + /* push reference to current value */ + /* Note: change type to array reference */ + pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; + /* increase/decrease operation */ + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + return; + } +#endif +#if !defined( HB_MACRO_SUPPORT ) + else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) + { + int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && + iScope != HB_VS_UNDECLARED ) + { + if( iScope == HB_VS_LOCAL_VAR ) + { + int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); + + HB_GEN_FUNC3( PCode3, ( bOper == HB_P_INC ) ? HB_P_LOCALINC : HB_P_LOCALDEC, + HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ) ); + } + else + { + /* NOTE: direct type change */ + HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; + pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC1( PCode1, ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP ); + pSelf->value.asOperator.pLeft->ExprType = iOldType; + } + return; + } + } +#endif + } + + /* Push current value */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); + /* Increment */ + HB_GEN_FUNC1( PCode1, bOper ); + /* pop new value from the stack */ + HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); +} + +/* Generate pcode for aliased expression which contains macro operator on + * the left or right side of the alias operator + * expression->¯o or ¯o->expression or ¯o->¯o + */ +static void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_COMP_DECL ) +{ + HB_EXPR_PTR pAlias, pVar; + + /* Alias->Var + */ + pAlias = pAliasedVar->value.asAlias.pAlias; + pVar = pAliasedVar->value.asAlias.pVar; + if( pAlias->ExprType == HB_ET_ALIAS ) + { + /* database alias */ + /* Push alias identifier as string so it can be joined with + * variable at runtime + * NOTE: + * ALIAS->&var is the same as &( "ALIAS->" + var ) + * + */ + HB_GEN_FUNC2( PushString, pAlias->value.asSymbol, strlen( pAlias->value.asSymbol ) + 1 ); + HB_EXPR_USE( pVar, HB_EA_PUSH_PCODE ); + if( bAction == HB_EA_PUSH_PCODE ) + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHALIASED ); + else + HB_GEN_FUNC1( PCode1, HB_P_MACROPOPALIASED ); + } + else if( pVar->ExprType == HB_ET_VARIABLE ) + { + /* NOTE: + * ¯o->var is the same as: &( macro + "->var" ) + */ + HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); + HB_GEN_FUNC2( PushString, pVar->value.asSymbol, strlen( pVar->value.asSymbol ) + 1 ); + if( bAction == HB_EA_PUSH_PCODE ) + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHALIASED ); + else + HB_GEN_FUNC1( PCode1, HB_P_MACROPOPALIASED ); + } + else + { + HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); + HB_EXPR_USE( pVar, HB_EA_PUSH_PCODE ); + if( bAction == HB_EA_PUSH_PCODE ) + HB_GEN_FUNC1( PCode1, HB_P_MACROPUSHALIASED ); + else + HB_GEN_FUNC1( PCode1, HB_P_MACROPOPALIASED ); + } + + /* Always add byte to pcode indicating requested macro compiler flag. */ + HB_GEN_FUNC1( PCode1, HB_MACRO_GENFLAGS ); +} + + +/* Reduces the list of expressions + * + * pExpr is the first expression on the list + */ +static ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL ) +{ + HB_EXPR_PTR pNext; + HB_EXPR_PTR * pPrev; + ULONG ulCnt = 0; + + /* NOTE: During optimalization an expression on the list can be + * replaced by the new one + */ + + pPrev = &pExpr->value.asList.pExprList; + pExpr = pExpr->value.asList.pExprList; + while( pExpr ) + { + pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ + pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); + *pPrev = pExpr; /* store a new expression into the previous one */ + pExpr->pNext = pNext; /* restore the link to next expression */ + pPrev = &pExpr->pNext; + pExpr = pNext; + ++ulCnt; + } + return ulCnt; +} diff --git a/harbour/include/hbexprc.c b/harbour/include/hbexprc.c deleted file mode 100644 index 9e8e0fc92b..0000000000 --- a/harbour/include/hbexprc.c +++ /dev/null @@ -1,942 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Compiler Expression Optimizer - utilities - * - * Copyright 1999 Ryszard Glab - * 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/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include -#include "hbcomp.h" -#include "hbmacro.ch" - -#define HB_USE_ARRAYAT_REF -/* Temporary disabled optimization with references to object variables - until we will not have extended reference items in our HVM [druzus] */ -/* #define HB_USE_OBJMSG_REF */ - -/* ************************************************************************* */ - -void hb_compExprPushSendPop( HB_EXPR_PTR pSelf, HB_COMP_DECL ) -{ - if( pSelf->value.asMessage.pObject ) - { - /* Push _message */ - if( pSelf->value.asMessage.szMessage ) - { - HB_EXPR_PCODE2( hb_compGenMessageData, pSelf->value.asMessage.szMessage, TRUE ); - } - else - { - if( pSelf->value.asMessage.pMessage->ExprType == HB_ET_MACRO ) - /* o:¯o := value - * set ASSIGN flag in macro expression - * it's cleared just after use - */ - pSelf->value.asMessage.pMessage->value.asMacro.SubType |= HB_ET_MACRO_ASSIGN; - - HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); - } - /* Push object */ - HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_PUSH_PCODE ); - } - else /* WITH OBJECT */ - { - /* Push _message and object */ - if( pSelf->value.asMessage.szMessage ) - { - HB_EXPR_PCODE2( hb_compGenMessageData, pSelf->value.asMessage.szMessage, FALSE ); - } - else - { - if( pSelf->value.asMessage.pMessage->ExprType == HB_ET_MACRO ) - /* o:¯o := value - * set ASSIGN flag in macro expression - * it's cleared just after use - */ - pSelf->value.asMessage.pMessage->value.asMacro.SubType |= HB_ET_MACRO_ASSIGN; - - HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); - /* Push object using WITHOBJECTMESSAGE pcode */ - HB_EXPR_PCODE2( hb_compGenMessage, NULL, FALSE ); - } - } -} - -void hb_compExprPushSendPush( HB_EXPR_PTR pSelf, HB_COMP_DECL ) -{ - if( pSelf->value.asMessage.pObject ) - { - /* Push message */ - if( pSelf->value.asMessage.szMessage ) - { - HB_EXPR_PCODE2( hb_compGenMessage, pSelf->value.asMessage.szMessage, TRUE ); - } - else - { - HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); - } - /* Push object */ - HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_PUSH_PCODE ); - } - else /* WITH OBJECT */ - { - if( pSelf->value.asMessage.szMessage ) - { - /* Push message and object */ - HB_EXPR_PCODE2( hb_compGenMessage, pSelf->value.asMessage.szMessage, FALSE ); - } - else - { - /* Push message */ - HB_EXPR_USE( pSelf->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); - /* Push object using WITHOBJECTMESSAGE pcode */ - HB_EXPR_PCODE2( hb_compGenMessage, NULL, FALSE ); - } - } -} - -static void hb_compExprPushSendPopPush( HB_EXPR_PTR pObj, HB_EXPR_PTR pValue, - BOOL fPreOp, BYTE bOper, HB_COMP_DECL ) -{ - if( HB_SUPPORT_HARBOUR ) - { - hb_compExprPushSendPop( pObj, HB_COMP_PARAM ); - /* duplicate object variable */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - /* Push message */ - if( pObj->value.asMessage.szMessage ) - { - /* TRUE used intnetionally to not push object variable in WITH OBJECT */ - HB_EXPR_PCODE2( hb_compGenMessage, pObj->value.asMessage.szMessage, TRUE ); - } - else - { - HB_EXPR_USE( pObj->value.asMessage.pMessage, HB_EA_PUSH_PCODE ); - } - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SWAP, 0 ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 0 ); - if( fPreOp ) - { - /* push the result on the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SWAP, 2 ); - } - } - else - { - if( fPreOp ) - { - /* push current value - it will be a result of whole expression */ - HB_EXPR_USE( pObj, HB_EA_PUSH_PCODE ); - } - hb_compExprPushSendPop( pObj, HB_COMP_PARAM ); - hb_compExprPushSendPush( pObj, HB_COMP_PARAM ); - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 0 ); - } - /* push increment value */ - if( pValue ) - { - HB_EXPR_USE( pValue, HB_EA_PUSH_PCODE ); - } - /* do operation */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); - /* Now do the assignment - call pop message with one argument */ - HB_EXPR_PCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 1 ); - if( fPreOp ) - { - /* pop the unneeded value left by assignment message from the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); - } -} - -void hb_compExprDelOperator( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - if( pExpr->value.asOperator.pLeft ) - HB_EXPR_PCODE1( hb_compExprDelete, pExpr->value.asOperator.pLeft ); - if( pExpr->value.asOperator.pRight ) - HB_EXPR_PCODE1( hb_compExprDelete, pExpr->value.asOperator.pRight ); -} - - -/* Generates pcodes for compound operators += -= *= /= %= ^= - * - * pExpr is an expression created by hb_compExprNewEq functions - */ -/* NOTE: COMPATIBILITY ISSUE: - * The HB_SUPPORT_HARBOUR in code below determines - * the way the chained send messages are handled. - * For example, the following code: - * - * a:b( COUNT() ):c += 1 - * - * will be handled as: - * - * a:b( COUNT() ):c := a:b( COUNT() ):c + 1 - * - * in strict Clipper compatibility mode - * (HB_SUPPORT_HARBOUR is not set: -kc compiler switch ) and - * - * temp := a:b( COUNT() ), temp:c += 1 - * - * in non-strict mode (-kh). - * In practice in Clipper it will call COUNT() function two times: the - * first time before addition and the second one after addition - in Harbour, - * COUNT() function will be called only once, before addition. - * The Harbour (non-strict) method is: - * 1) faster - * 2) it guarantees that the same instance variable of the same object will - * be changed - */ - -void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) -{ - BYTE bNewOp; - - if( HB_SUPPORT_HARBOUR ) - { - switch( bOpEq ) - { - case HB_P_PLUS: - bNewOp = HB_P_PLUSEQ; - break; - case HB_P_MINUS: - bNewOp = HB_P_MINUSEQ; - break; - case HB_P_MULT: - bNewOp = HB_P_MULTEQ; - break; - case HB_P_DIVIDE: - bNewOp = HB_P_DIVEQ; - break; - case HB_P_MODULUS: - bNewOp = HB_P_MODEQ; - break; - case HB_P_POWER: - bNewOp = HB_P_EXPEQ; - break; - default: - bNewOp = bOpEq; - break; - } - } - else - bNewOp = bOpEq; - - /* NOTE: an object instance variable needs special handling - */ - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) - { - - if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) - { - hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); - } -#ifdef HB_USE_OBJMSG_REF - else if( bOpEq != bNewOp ) - { - hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); - /* push increment value */ - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - } -#endif - else - { - hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, - pSelf->value.asOperator.pRight, - FALSE, bOpEq, HB_COMP_PARAM ); - } - return; - } - else if( bOpEq != bNewOp ) - { - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO ) - { - USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; - if( usType == HB_ET_MACRO_VAR ) - { - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; - return; - } - } -#ifdef HB_USE_ARRAYAT_REF - /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) - { - /* Note: change type to array reference */ - pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; - - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - return; - } -#endif - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) - { -#if defined( HB_MACRO_SUPPORT ) - { -#else - int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && - iScope != HB_VS_UNDECLARED ) - { - if( iScope == HB_VS_LOCAL_VAR && - pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC && - ( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ) ) - { - if( hb_compExprIsInteger( pSelf->value.asOperator.pRight ) ) - { - short iIncrement = ( short ) pSelf->value.asOperator.pRight->value.asNum.val.l; - - if( bOpEq != HB_P_MINUS || iIncrement >= -INT16_MAX ) - { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - BYTE buffer[ 5 ]; - - if( bOpEq == HB_P_MINUS ) - iIncrement = -iIncrement; - - buffer[ 0 ] = HB_P_LOCALADDINT; - buffer[ 1 ] = HB_LOBYTE( iLocal ); - buffer[ 2 ] = HB_HIBYTE( iLocal ); - buffer[ 3 ] = HB_LOBYTE( iIncrement ); - buffer[ 4 ] = HB_HIBYTE( iIncrement ); - hb_compGenPCodeN( buffer, 5, HB_COMP_PARAM ); - - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - return; - } - } - } -#endif - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; - - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - return; - } - } - } - /* push old value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* push increment value */ - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - /* perform operation and duplicate the new value */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - /* pop the new value into variable and leave the copy on the stack */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); -} - -/* Generates pcodes for = syntax - * used standalone as a statement (it cannot leave the value on the stack) - */ -void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ) -{ - BYTE bNewOp; - - if( HB_SUPPORT_HARBOUR ) - { - switch( bOpEq ) - { - case HB_P_PLUS: - bNewOp = HB_P_PLUSEQPOP; - break; - case HB_P_MINUS: - bNewOp = HB_P_MINUSEQPOP; - break; - case HB_P_MULT: - bNewOp = HB_P_MULTEQPOP; - break; - case HB_P_DIVIDE: - bNewOp = HB_P_DIVEQPOP; - break; - case HB_P_MODULUS: - bNewOp = HB_P_MODEQPOP; - break; - case HB_P_POWER: - bNewOp = HB_P_EXPEQPOP; - break; - default: - bNewOp = bOpEq; - break; - } - } - else - bNewOp = bOpEq; - - /* NOTE: an object instance variable needs special handling - */ - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) - { - if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) - { - hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); - } -#ifdef HB_USE_OBJMSG_REF - else if( bOpEq != bNewOp ) - { - hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); - /* push increment value */ - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - } -#endif - else - { - hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, - pSelf->value.asOperator.pRight, - FALSE, bOpEq, HB_COMP_PARAM ); - /* pop the unneeded value from the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); - } - return; - } - else if( bOpEq != bNewOp ) - { - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO ) - { - USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; - if( usType == HB_ET_MACRO_VAR ) - { - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; - return; - } - } -#ifdef HB_USE_ARRAYAT_REF - /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) - { - /* Note: change type to array reference */ - pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; - - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - return; - } -#endif - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) - { - HB_EXPRTYPE iOldType; -#if defined( HB_MACRO_SUPPORT ) - { -#else - int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && - iScope != HB_VS_UNDECLARED ) - { - if( iScope == HB_VS_LOCAL_VAR && - pSelf->value.asOperator.pRight->ExprType == HB_ET_NUMERIC && - ( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ) ) - { - if( hb_compExprIsInteger( pSelf->value.asOperator.pRight ) ) - { - short iIncrement = ( short ) pSelf->value.asOperator.pRight->value.asNum.val.l; - - if( bOpEq != HB_P_MINUS || iIncrement >= -INT16_MAX ) - { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - BYTE buffer[ 5 ]; - - if( bOpEq == HB_P_MINUS ) - iIncrement = -iIncrement; - - buffer[ 0 ] = HB_P_LOCALADDINT; - buffer[ 1 ] = HB_LOBYTE( iLocal ); - buffer[ 2 ] = HB_HIBYTE( iLocal ); - buffer[ 3 ] = HB_LOBYTE( iIncrement ); - buffer[ 4 ] = HB_HIBYTE( iIncrement ); - hb_compGenPCodeN( buffer, 5, HB_COMP_PARAM ); - return; - } - } - } -#endif - /* NOTE: direct type change */ - iOldType = pSelf->value.asOperator.pLeft->ExprType; - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; - - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, bNewOp ); - pSelf->value.asOperator.pLeft->ExprType = iOldType; - return; - } - } - } - /* push old value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* push increment value */ - HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE ); - /* add */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOpEq ); - /* pop the new value into variable and remove it from the stack */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); -} - -/* Generates the pcodes for pre- increment/decrement expressions - */ -void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) -{ - /* NOTE: an object instance variable needs special handling - */ - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) - { - if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) - { - hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); - } -#ifdef HB_USE_OBJMSG_REF - else if( HB_SUPPORT_HARBOUR ) - { - hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); - /* increase/decrease operation, leave unreferenced value on stack */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); - } -#endif - else - { - hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL, - FALSE, bOper, HB_COMP_PARAM ); - } - return; - } - else if( HB_SUPPORT_HARBOUR ) - { - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO && - pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR ) - { - USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; - - /* increase/decrease operation, leave unreferenced value on stack */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); - return; - } -#ifdef HB_USE_ARRAYAT_REF - /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) - { - /* push reference to current value */ - /* Note: change type to array reference */ - pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; - - /* increase/decrease operation, leave unreferenced value on stack */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); - return; - } -#endif -#if !defined( HB_MACRO_SUPPORT ) - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) - { - int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && - iScope != HB_VS_UNDECLARED ) - { - if( iScope == HB_VS_LOCAL_VAR ) - { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - if( bOper == HB_P_INC ) - { - hb_compGenPCode3( HB_P_LOCALINCPUSH, HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); - } - else - { - hb_compGenPCode3( HB_P_LOCALDEC, HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - } - } - else - { - /* NOTE: direct type change */ - HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQ : HB_P_DECEQ, HB_COMP_PARAM ); - pSelf->value.asOperator.pLeft->ExprType = iOldType; - } - return; - } - } -#endif - } - - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* Increment */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); - /* duplicate a value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - /* pop new value and leave the duplicated copy of it on the stack */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); -} - -/* Generates the pcodes for post- increment/decrement expressions - */ -void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) -{ - /* NOTE: an object instance variable needs special handling - */ - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) - { - if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) - { - hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); - } -#ifdef HB_USE_OBJMSG_REF - else if( HB_SUPPORT_HARBOUR ) - { - /* push reference to current value */ - hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); - /* Duplicate the reference and unref the original one - - * it will be the result of whole expression - */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); - /* increment/decrement the value */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - } -#endif - else - { - hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL, - TRUE, bOper, HB_COMP_PARAM ); - } - return; - } - else if( HB_SUPPORT_HARBOUR ) - { - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO && - pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR ) - { - USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; - - /* Duplicate the reference and unref the original one - - * it will be the result of whole expression - */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); - /* increase/decrease operation */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - return; - } -#ifdef HB_USE_ARRAYAT_REF - /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) - { - /* push reference to current value */ - /* Note: change type to array reference */ - pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; - - /* Duplicate the reference and unref the original one - - * it will be the result of whole expression - */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); - /* increase/decrease operation */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - return; - } -#endif -#if !defined( HB_MACRO_SUPPORT ) - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) - { - int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && - iScope != HB_VS_UNDECLARED ) - { - if( iScope == HB_VS_LOCAL_VAR ) - { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - hb_compGenPCode3( ( bOper == HB_P_INC ) ? HB_P_LOCALINC : HB_P_LOCALDEC, - HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); - } - else - { - /* NOTE: direct type change */ - HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLUNREF ); - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - pSelf->value.asOperator.pLeft->ExprType = iOldType; - } - return; - } - } -#endif - } - - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* Duplicate value */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_DUPLICATE ); - /* Increment */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); - /* pop new value from the stack */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); -} - -/* Generates the pcodes for increment/decrement operations - * used standalone as a statement - */ -void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, BYTE bOper, HB_COMP_DECL ) -{ - /* NOTE: an object instance variable needs special handling - */ - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND ) - { - if( pSelf->value.asOperator.pLeft->value.asMessage.pParms ) - { - hb_compErrorLValue( HB_COMP_PARAM, pSelf->value.asOperator.pLeft ); - } -#ifdef HB_USE_OBJMSG_REF - else if( HB_SUPPORT_HARBOUR ) - { - /* push reference to current value */ - hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF ); - /* increment/decrement the value */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - } -#endif - else - { - hb_compExprPushSendPopPush( pSelf->value.asOperator.pLeft, NULL, - FALSE, bOper, HB_COMP_PARAM ); - /* pop the value from the stack */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_POP ); - } - return; - } - else if( HB_SUPPORT_HARBOUR ) - { - if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_MACRO && - pSelf->value.asOperator.pLeft->value.asMacro.SubType == HB_ET_MACRO_VAR ) - { - USHORT usType = pSelf->value.asOperator.pLeft->value.asMacro.SubType; - /* NOTE: direct type change */ - pSelf->value.asOperator.pLeft->value.asMacro.SubType = HB_ET_MACRO_REFER; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asMacro.SubType = usType; - - /* increase/decrease operation */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - return; - } -#ifdef HB_USE_ARRAYAT_REF - /* NOTE: code for arrays is differ to correctly handle a[ i++ ]++ */ - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_ARRAYAT ) - { - /* push reference to current value */ - /* Note: change type to array reference */ - pSelf->value.asOperator.pLeft->value.asList.reference = TRUE; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - pSelf->value.asOperator.pLeft->value.asList.reference = FALSE; - /* increase/decrease operation */ - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - return; - } -#endif -#if !defined( HB_MACRO_SUPPORT ) - else if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_VARIABLE ) - { - int iScope = hb_compVariableScope( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - if( iScope != HB_VS_LOCAL_FIELD && iScope != HB_VS_GLOBAL_FIELD && - iScope != HB_VS_UNDECLARED ) - { - if( iScope == HB_VS_LOCAL_VAR ) - { - int iLocal = hb_compLocalGetPos( HB_COMP_PARAM, pSelf->value.asOperator.pLeft->value.asSymbol ); - - hb_compGenPCode3( ( bOper == HB_P_INC ) ? HB_P_LOCALINC : HB_P_LOCALDEC, - HB_LOBYTE( iLocal ), HB_HIBYTE( iLocal ), HB_COMP_PARAM ); - } - else - { - /* NOTE: direct type change */ - HB_EXPRTYPE iOldType = pSelf->value.asOperator.pLeft->ExprType; - pSelf->value.asOperator.pLeft->ExprType = HB_ET_VARREF; - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - hb_compGenPCode1( ( bOper == HB_P_INC ) ? HB_P_INCEQPOP : HB_P_DECEQPOP, HB_COMP_PARAM ); - pSelf->value.asOperator.pLeft->ExprType = iOldType; - } - return; - } - } -#endif - } - - /* Push current value */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_PUSH_PCODE ); - /* Increment */ - HB_EXPR_PCODE1( hb_compGenPCode1, bOper ); - /* pop new value from the stack */ - HB_EXPR_USE( pSelf->value.asOperator.pLeft, HB_EA_POP_PCODE ); -} - -/* Generate pcode for aliased expression which contains macro operator on - * the left or right side of the alias operator - * expression->¯o or ¯o->expression or ¯o->¯o - */ -void hb_compExprUseAliasMacro( HB_EXPR_PTR pAliasedVar, BYTE bAction, HB_COMP_DECL ) -{ - HB_EXPR_PTR pAlias, pVar; - - /* Alias->Var - */ - pAlias = pAliasedVar->value.asAlias.pAlias; - pVar = pAliasedVar->value.asAlias.pVar; - if( pAlias->ExprType == HB_ET_ALIAS ) - { - /* database alias */ - /* Push alias identifier as string so it can be joined with - * variable at runtime - * NOTE: - * ALIAS->&var is the same as &( "ALIAS->" + var ) - * - */ - HB_EXPR_PCODE2( hb_compGenPushString, pAlias->value.asSymbol, strlen( pAlias->value.asSymbol ) + 1 ); - HB_EXPR_USE( pVar, HB_EA_PUSH_PCODE ); - if( bAction == HB_EA_PUSH_PCODE ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); - else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); - } - else if( pVar->ExprType == HB_ET_VARIABLE ) - { - /* NOTE: - * ¯o->var is the same as: &( macro + "->var" ) - */ - HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); - HB_EXPR_PCODE2( hb_compGenPushString, pVar->value.asSymbol, strlen( pVar->value.asSymbol ) + 1 ); - if( bAction == HB_EA_PUSH_PCODE ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); - else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); - } - else - { - HB_EXPR_USE( pAlias, HB_EA_PUSH_PCODE ); - HB_EXPR_USE( pVar, HB_EA_PUSH_PCODE ); - if( bAction == HB_EA_PUSH_PCODE ) - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPUSHALIASED ); - else - HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROPOPALIASED ); - } - - /* Always add byte to pcode indicating requested macro compiler flag. */ - HB_EXPR_PCODE1( hb_compGenPCode1, HB_MACRO_GENFLAGS ); -} - - -/* Reduces the list of expressions - * - * pExpr is the first expression on the list - */ -ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL ) -{ - HB_EXPR_PTR pNext; - HB_EXPR_PTR * pPrev; - ULONG ulCnt = 0; - - /* NOTE: During optimalization an expression on the list can be - * replaced by the new one - */ - - pPrev = &pExpr->value.asList.pExprList; - pExpr = pExpr->value.asList.pExprList; - while( pExpr ) - { - pNext = pExpr->pNext; /* store next expression in case the current will be reduced */ - pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE ); - *pPrev = pExpr; /* store a new expression into the previous one */ - pExpr->pNext = pNext; /* restore the link to next expression */ - pPrev = &pExpr->pNext; - pExpr = pNext; - ++ulCnt; - } - return ulCnt; -} diff --git a/harbour/include/hbexprop.h b/harbour/include/hbexprop.h index cbd40e645a..0ca520dd17 100644 --- a/harbour/include/hbexprop.h +++ b/harbour/include/hbexprop.h @@ -64,11 +64,6 @@ HB_EXTERN_BEGIN typedef HB_EXPR_FUNC( HB_EXPR_FUNC_ ); typedef HB_EXPR_FUNC_ *HB_EXPR_FUNC_PTR; -extern const HB_EXPR_FUNC_PTR hb_comp_ExprTable[]; - -#define HB_EXPR_USE( pSelf, iMessage ) \ - hb_comp_ExprTable[ (pSelf)->ExprType ]( (pSelf), (iMessage), HB_COMP_PARAM ) - typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage, HB_COMP_DECL ); #define HB_EXPR_PCODE0( action ) action( HB_COMP_PARAM ) #define HB_EXPR_PCODE1( action, p1 ) action( (p1), HB_COMP_PARAM ) @@ -76,13 +71,16 @@ typedef HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage, HB_COMP_DE #define HB_EXPR_PCODE3( action, p1, p2, p3 ) action( (p1), (p2), (p3), HB_COMP_PARAM ) #define HB_EXPR_PCODE4( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4), HB_COMP_PARAM ) -#ifdef HB_MACRO_SUPPORT -extern HB_EXPR_PTR hb_macroExprNew( HB_COMP_DECL ); -#else -extern void hb_compExprLstDealloc( HB_COMP_DECL ); +#if defined( HB_MACRO_SUPPORT ) +#define hb_comp_ExprTable hb_macro_ExprTable +#endif + +#if !defined( HB_COMMON_SUPPORT ) +extern const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ]; +#define HB_EXPR_USE( pSelf, iMessage ) \ + hb_comp_ExprTable[ (pSelf)->ExprType ]( (pSelf), (iMessage), HB_COMP_PARAM ) #endif -extern HB_EXPR_PTR hb_compExprNew( HB_EXPRTYPE, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprNewEmpty( HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprNewNil( HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprNewDouble( double, BYTE, BYTE, HB_COMP_DECL ); @@ -142,6 +140,7 @@ extern HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprAddListExpr( HB_EXPR_PTR, HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR, char *, BYTE, HB_COMP_DECL ); +extern void hb_compExprCBVarDel( HB_CBVAR_PTR ); extern HB_EXPR_PTR hb_compExprAddCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR ); extern HB_EXPR_PTR hb_compExprMacroAsAlias( HB_EXPR_PTR ); @@ -153,7 +152,7 @@ extern ULONG hb_compExprListLen( HB_EXPR_PTR ); extern ULONG hb_compExprParamListLen( HB_EXPR_PTR ); extern ULONG hb_compExprMacroListLen( HB_EXPR_PTR ); extern ULONG hb_compExprParamListCheck( HB_COMP_DECL, HB_EXPR_PTR ); -extern void hb_compExprClear( HB_EXPR_PTR, HB_COMP_DECL ); + extern const char * hb_compExprDescription( HB_EXPR_PTR ); extern int hb_compExprType( HB_EXPR_PTR ); extern int hb_compExprIsInteger( HB_EXPR_PTR ); @@ -165,30 +164,13 @@ extern int hb_compExprAsStringLen( HB_EXPR_PTR ); extern char * hb_compExprAsString( HB_EXPR_PTR ); extern char * hb_compExprAsSymbol( HB_EXPR_PTR ); -extern void hb_compExprFree( HB_EXPR_PTR, HB_COMP_DECL ); -extern void hb_compExprErrorType( HB_EXPR_PTR, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR, HB_COMP_DECL ); -extern void hb_compExprCBVarDel( HB_CBVAR_PTR ); extern BOOL hb_compExprIsValidMacro( char *, ULONG, BOOL *, HB_COMP_DECL ); -extern void hb_compExprDelete( HB_EXPR_PTR, HB_COMP_DECL ); + extern HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL ); -extern HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR, HB_COMP_DECL ); -extern HB_EXPR_PTR hb_compExprGenPush( HB_EXPR_PTR, HB_COMP_DECL ); -extern HB_EXPR_PTR hb_compExprGenPop( HB_EXPR_PTR, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL ); extern void hb_compExprDelOperator( HB_EXPR_PTR, HB_COMP_DECL ); -extern void hb_compExprUseOperEq( HB_EXPR_PTR, BYTE, HB_COMP_DECL ); -extern void hb_compExprPushPreOp( HB_EXPR_PTR, BYTE, HB_COMP_DECL ); -extern void hb_compExprPushPostOp( HB_EXPR_PTR, BYTE, HB_COMP_DECL ); -extern void hb_compExprUsePreOp( HB_EXPR_PTR, BYTE, HB_COMP_DECL ); -extern void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL ); -extern void hb_compExprPushSendPop( HB_EXPR_PTR pSelf, HB_COMP_DECL ); -extern void hb_compExprPushSendPush( HB_EXPR_PTR pSelf, HB_COMP_DECL ); -extern void hb_compExprUseAliasMacro( HB_EXPR_PTR, BYTE, HB_COMP_DECL ); - -extern HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR, HB_COMP_DECL ); -extern ULONG hb_compExprReduceList( HB_EXPR_PTR, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL ); extern HB_EXPR_PTR hb_compExprReduceDiv( HB_EXPR_PTR pSelf, HB_COMP_DECL ); diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index dd4c68e5d7..70fdac4872 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -103,6 +103,13 @@ extern ULONG hb_macroAutoSetMacro( ULONG ulFlag ); extern BOOL hb_macroLexNew( HB_MACRO_PTR pMacro ); extern void hb_macroLexDelete( HB_MACRO_PTR pMacro ); +extern HB_EXPR_PTR hb_macroExprGenPush( HB_EXPR_PTR, HB_COMP_DECL ); +extern HB_EXPR_PTR hb_macroExprGenPop( HB_EXPR_PTR, HB_COMP_DECL ); + +extern HB_EXPR_PTR hb_macroExprNewArrayAt( HB_EXPR_PTR pArray, HB_EXPR_PTR pIndex, HB_COMP_DECL ); +extern HB_EXPR_PTR hb_macroExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COMP_DECL ); +extern HB_EXPR_PTR hb_macroExprNewSend( HB_EXPR_PTR pObject, char * szMessage, HB_EXPR_PTR pMessage, HB_COMP_DECL ); + /* Size of pcode buffer incrementation */ #define HB_PCODE_SIZE 512 @@ -110,45 +117,46 @@ extern void hb_macroLexDelete( HB_MACRO_PTR pMacro ); /* Declarations for functions macro.c */ #if defined( HB_MACRO_SUPPORT ) -extern void hb_compGenPCode1( BYTE byte, HB_COMP_DECL ); -extern void hb_compGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL ); -extern void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL ); -extern void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL ); -extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ); +extern void hb_macroGenPCode1( BYTE byte, HB_COMP_DECL ); +extern void hb_macroGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL ); +extern void hb_macroGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL ); +extern void hb_macroGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL ); +extern void hb_macroGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ); -extern int hb_compLocalVarGetPos( char * szVarName, HB_COMP_DECL ); -extern ULONG hb_compGenJump( LONG lOffset, HB_COMP_DECL ); -extern ULONG hb_compGenJumpFalse( LONG lOffset, HB_COMP_DECL ); -extern void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL ); -extern void hb_compGenJumpHere( ULONG ulOffset, HB_COMP_DECL ); -extern ULONG hb_compGenJumpTrue( LONG lOffset, HB_COMP_DECL ); +extern ULONG hb_macroGenJump( LONG lOffset, HB_COMP_DECL ); +extern ULONG hb_macroGenJumpFalse( LONG lOffset, HB_COMP_DECL ); +extern void hb_macroGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL ); +extern void hb_macroGenJumpHere( ULONG ulOffset, HB_COMP_DECL ); +extern ULONG hb_macroGenJumpTrue( LONG lOffset, HB_COMP_DECL ); -extern void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_COMP_DECL ); - -extern void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_COMP_DECL ); -extern void hb_compGenPushLong( HB_LONG lNumber, HB_COMP_DECL ); -extern void hb_compGenPushDate( HB_LONG lNumber, HB_COMP_DECL ); -extern void hb_compGenMessage( char * szMsgName, BOOL bIsObject, HB_COMP_DECL ); -extern void hb_compGenMessageData( char * szMsg, BOOL bIsObject, HB_COMP_DECL ); -extern void hb_compGenPopVar( char * szVarName, HB_COMP_DECL ); -extern void hb_compGenPopAliasedVar( char * szVarName, +extern void hb_macroGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_COMP_DECL ); +extern void hb_macroGenPushLong( HB_LONG lNumber, HB_COMP_DECL ); +extern void hb_macroGenPushDate( HB_LONG lNumber, HB_COMP_DECL ); +extern void hb_macroGenMessage( char * szMsgName, BOOL bIsObject, HB_COMP_DECL ); +extern void hb_macroGenMessageData( char * szMsg, BOOL bIsObject, HB_COMP_DECL ); +extern void hb_macroGenPopVar( char * szVarName, HB_COMP_DECL ); +extern void hb_macroGenPopAliasedVar( char * szVarName, BOOL bPushAliasValue, char * szAlias, long lWorkarea, HB_COMP_DECL ); -extern void hb_compGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ); -extern void hb_compGenPushVarRef( char * szVarName, HB_COMP_DECL ); -extern void hb_compGenPushAliasedVar( char * szVarName, +extern void hb_macroGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ); +extern void hb_macroGenPushVarRef( char * szVarName, HB_COMP_DECL ); +extern void hb_macroGenPushMemvarRef( char * szVarName, HB_COMP_DECL ); +extern void hb_macroGenPushAliasedVar( char * szVarName, BOOL bPushAliasValue, char * szAlias, long lWorkarea, HB_COMP_DECL ); -extern void hb_compGenPushLogical( int iTrueFalse, HB_COMP_DECL ); -extern void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ); -extern void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ); -extern void hb_compGenPushFunSym( char * szFunName, HB_COMP_DECL ); -extern void hb_compGenPushFunRef( char * szFunName, HB_COMP_DECL ); -extern void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_COMP_DECL ); -extern void hb_compCodeBlockStart( HB_COMP_DECL ); -extern void hb_compCodeBlockEnd( HB_COMP_DECL ); +extern void hb_macroGenPushLogical( int iTrueFalse, HB_COMP_DECL ); +extern void hb_macroGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ); +extern void hb_macroGenPushFunCall( char * szFunName, HB_COMP_DECL ); +extern void hb_macroGenPushFunSym( char * szFunName, HB_COMP_DECL ); +extern void hb_macroGenPushFunRef( char * szFunName, HB_COMP_DECL ); +extern void hb_macroGenPushString( char * szText, ULONG ulStrLen, HB_COMP_DECL ); + +extern void hb_macroCodeBlockStart( HB_COMP_DECL ); +extern void hb_macroCodeBlockEnd( HB_COMP_DECL ); + +extern BOOL hb_macroIsValidMacroText( char *, ULONG ); #endif /* HB_MACRO_SUPPORT */ diff --git a/harbour/makefile.bc b/harbour/makefile.bc index a883c52b2b..57c72c09f5 100644 --- a/harbour/makefile.bc +++ b/harbour/makefile.bc @@ -231,7 +231,7 @@ all : $(HB_DEST_DIRS) $(HB_BUILD_TARGETS) # Helper targets # -BasicLibs : $(COMMON_LIB) $(PP_LIB) +BasicLibs : $(COMMON_LIB) $(COMPILER_LIB) $(PP_LIB) BasicExes : $(HARBOUR_EXE) StdLibs : $(STANDARD_STATIC_HBLIBS) @@ -302,6 +302,13 @@ $(PP_LIB) : $(PP_LIB_OBJS) +) ! #********************************************************** +$(COMPILER_LIB) : $(COMPILER_LIB_OBJS) + IF EXIST "$(COMPILER_LIB)" $(DEL) "$(COMPILER_LIB)" > NUL + $(MKLIB) "$(COMPILER_LIB)" $(ARFLAGS) @&&! ++$(**: = &^ ++) +! +#********************************************************** $(VM_LIB) :: BasicExes $(VM_LIB) :: $(VM_LIB_OBJS) IF EXIST "$(VM_LIB)" $(DEL) "$(VM_LIB)" > NUL @@ -469,6 +476,7 @@ $(CFLAGS) -e$(HARBOUR_EXE) $(**: = ^ ) +$(COMPILER_LIB) $(COMMON_LIB) $(PP_LIB) ! diff --git a/harbour/makefile.vc b/harbour/makefile.vc index 747d34f3f1..dd9e778c30 100644 --- a/harbour/makefile.vc +++ b/harbour/makefile.vc @@ -174,9 +174,15 @@ DLL_OBJS = $(TMP_DLL_OBJS:obj\vc=obj\dll\vc) {$(OBJ_DIR)}.c{$(OBJ_DIR)}.obj:: $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $< #******************************************************* +{$(MAIN_DIR)}.c{$(OBJ_DIR)}.obj:: + $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $< +#******************************************************* {$(COMMON_DIR)}.c{$(OBJ_DIR)}.obj:: $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $< #******************************************************* +{$(COMPILER_DIR)}.c{$(OBJ_DIR)}.obj:: + $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $< +#******************************************************* {$(PP_DIR)}.c{$(OBJ_DIR)}.obj:: $(CC) $(CLIBFLAGS) -Fo$(OBJ_DIR)\ $< #******************************************************* @@ -399,9 +405,15 @@ DLL_OBJS = $(TMP_DLL_OBJS:obj\vc=obj\dll\vc) {$(DLL_OBJ_DIR)}.c{$(DLL_OBJ_DIR)}.obj:: $(CC) $(CLIBFLAGSDLL) -Fo$(DLL_OBJ_DIR)\ $< #******************************************************* +{$(MAIN_DIR)}.c{$(DLL_OBJ_DIR)}.obj:: + $(CC) $(CLIBFLAGSDLL) -Fo$(DLL_OBJ_DIR)\ $< +#******************************************************* {$(COMMON_DIR)}.c{$(DLL_OBJ_DIR)}.obj:: $(CC) $(CLIBFLAGSDLL) -Fo$(DLL_OBJ_DIR)\ $< #******************************************************* +{$(COMPILER_DIR)}.c{$(DLL_OBJ_DIR)}.obj:: + $(CC) $(CLIBFLAGSDLL) -Fo$(DLL_OBJ_DIR)\ $< +#******************************************************* {$(PP_DIR)}.c{$(DLL_OBJ_DIR)}.obj:: $(CC) $(CLIBFLAGSDLL) -Fo$(DLL_OBJ_DIR)\ $< #******************************************************* @@ -654,7 +666,7 @@ all : $(HB_DEST_DIRS) $(HB_BUILD_TARGETS) # Helper targets - disabled for Msvc # -#BasicLibs : $(COMMON_LIB) $(PP_LIB) +#BasicLibs : $(COMMON_LIB) $(COMPILER_LIB) $(PP_LIB) #BasicExes : $(HARBOUR_EXE) #StdLibs : $(STANDARD_STATIC_HBLIBS) @@ -721,6 +733,9 @@ $(COMMON_LIB) : $(COMMON_LIB_OBJS) $(PP_LIB) : $(PP_LIB_OBJS) $(MKLIB) /out:$@ $** #********************************************************** +$(COMPILER_LIB) : $(COMPILER_LIB_OBJS) + $(MKLIB) /out:$@ $** +#********************************************************** $(VM_LIB) : $(VM_LIB_OBJS) $(MKLIB) /out:$@ $** #********************************************************** @@ -799,6 +814,7 @@ $(LDFLAGS) $(**: = ^ ) $(COMMON_LIB) +$(COMPILER_LIB) $(PP_LIB) << #********************************************************** diff --git a/harbour/source/Makefile b/harbour/source/Makefile index 77b2041e50..38e29c7642 100644 --- a/harbour/source/Makefile +++ b/harbour/source/Makefile @@ -27,6 +27,7 @@ DIRS=\ common \ pp \ compiler \ + main \ rtl \ vm \ macro \ diff --git a/harbour/source/common/expropt1.c b/harbour/source/common/expropt1.c index c5f6382473..3e1f8310b8 100644 --- a/harbour/source/common/expropt1.c +++ b/harbour/source/common/expropt1.c @@ -59,11 +59,6 @@ #include "hbmacro.h" #include "hbcomp.h" -/* memory allocation - */ -#define HB_XGRAB( size ) hb_xgrab( (size) ) -#define HB_XFREE( pPtr ) hb_xfree( (void *)(pPtr) ) - static const char * s_OperTable[ HB_EXPR_COUNT ] = { "", "NIL", @@ -122,6 +117,69 @@ static const char * s_OperTable[ HB_EXPR_COUNT ] = { "--" }; +/* Table with operators precedence + * NOTE: + * HB_ET_NIL is used for an ordinary values and post- operators + * HB_ET_NONE is used for invalid syntax, e.g. var := var1 += 2 + */ +static const BYTE s_PrecedTable[ HB_EXPR_COUNT ] = { + HB_ET_NIL, /* HB_ET_NONE = 0, */ + HB_ET_NIL, /* HB_ET_NIL, */ + HB_ET_NIL, /* HB_ET_NUMERIC, */ + HB_ET_NIL, /* HB_ET_DATE, */ + HB_ET_NIL, /* HB_ET_STRING, */ + HB_ET_NIL, /* HB_ET_CODEBLOCK, */ + HB_ET_NIL, /* HB_ET_LOGICAL, */ + HB_ET_NIL, /* HB_ET_SELF, */ + HB_ET_NIL, /* HB_ET_ARRAY, */ + HB_ET_NIL, /* HB_ET_VARREF, */ + HB_ET_NIL, /* HB_ET_REFERENCE, */ + HB_ET_NIL, /* HB_ET_FUNREF, */ + HB_ET_NIL, /* HB_ET_IIF, */ + HB_ET_NIL, /* HB_ET_LIST, */ + HB_ET_NIL, /* HB_ET_ARGLIST, */ + HB_ET_NIL, /* HB_ET_MACROARGLIST,*/ + HB_ET_NIL, /* HB_ET_ARRAYAT, */ + HB_ET_NIL, /* HB_ET_MACRO, */ + HB_ET_NIL, /* HB_ET_FUNCALL, */ + HB_ET_NIL, /* HB_ET_ALIASVAR, */ + HB_ET_NIL, /* HB_ET_ALIASEXPR, */ + HB_ET_NIL, /* HB_ET_SEND, */ + HB_ET_NIL, /* HB_ET_FUNNAME, */ + HB_ET_NIL, /* HB_ET_ALIAS, */ + HB_ET_NIL, /* HB_ET_RTVARIABLE, */ + HB_ET_NIL, /* HB_ET_VARIABLE, */ + HB_ET_NIL, /* HB_EO_POSTINC, post-operators */ + HB_ET_NIL, /* HB_EO_POSTDEC, */ + HB_ET_NONE, /* HB_EO_ASSIGN, assigments */ + HB_ET_NONE, /* HB_EO_PLUSEQ, Invalid syntax */ + HB_ET_NONE, /* HB_EO_MINUSEQ, */ + HB_ET_NONE, /* HB_EO_MULTEQ, */ + HB_ET_NONE, /* HB_EO_DIVEQ, */ + HB_ET_NONE, /* HB_EO_MODEQ, */ + HB_ET_NONE, /* HB_EO_EXPEQ, */ + HB_EO_OR, /* HB_EO_OR, logical operators */ + HB_EO_AND, /* HB_EO_AND, */ + HB_ET_NIL, /* HB_EO_NOT, */ + HB_EO_EQUAL, /* HB_EO_EQUAL, relational operators */ + HB_EO_EQUAL, /* HB_EO_EQ, */ + HB_EO_EQUAL, /* HB_EO_LT, */ + HB_EO_EQUAL, /* HB_EO_GT, */ + HB_EO_EQUAL, /* HB_EO_LE, */ + HB_EO_EQUAL, /* HB_EO_GE, */ + HB_EO_EQUAL, /* HB_EO_NE, */ + HB_EO_EQUAL, /* HB_EO_IN, */ + HB_EO_PLUS, /* HB_EO_PLUS, addition */ + HB_EO_PLUS, /* HB_EO_MINUS, */ + HB_EO_MULT, /* HB_EO_MULT, multiple */ + HB_EO_MULT, /* HB_EO_DIV, */ + HB_EO_MULT, /* HB_EO_MOD, */ + HB_EO_POWER, /* HB_EO_POWER, */ + HB_ET_NIL, /* HB_EO_NEGATE, sign operator */ + HB_ET_NIL, /* HB_EO_PREINC, */ + HB_ET_NIL /* HB_EO_PREDEC, pre-operators */ +}; + /* ************************************************************************* */ /* Increase a reference counter (this allows to share the same expression @@ -233,7 +291,7 @@ char *hb_compExprAsSymbol( HB_EXPR_PTR pExpr ) HB_EXPR_PTR hb_compExprNewEmpty( HB_COMP_DECL ) { - return hb_compExprNew( HB_ET_NONE, HB_COMP_PARAM ); + return HB_COMP_EXPR_NEW( HB_ET_NONE ); } HB_EXPR_PTR hb_compExprNewDouble( double dValue, BYTE ucWidth, BYTE ucDec, @@ -243,7 +301,7 @@ HB_EXPR_PTR hb_compExprNewDouble( double dValue, BYTE ucWidth, BYTE ucDec, HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewDouble(%f, %i, %p)", dValue, ucDec, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_NUMERIC, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_NUMERIC ); pExpr->value.asNum.val.d = dValue; pExpr->value.asNum.bWidth = ucWidth; @@ -260,7 +318,7 @@ HB_EXPR_PTR hb_compExprNewLong( HB_LONG lValue, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewLong(%" PFHL "d, %p)", lValue, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_NUMERIC, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_NUMERIC ); pExpr->value.asNum.val.l = lValue; pExpr->value.asNum.bDec = 0; @@ -276,7 +334,7 @@ HB_EXPR_PTR hb_compExprNewDate( HB_LONG lValue, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewDate(%" PFHL "d, %p)", lValue, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_DATE, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_DATE ); pExpr->value.asNum.val.l = lValue; pExpr->ValType = HB_EV_DATE; @@ -290,7 +348,7 @@ HB_EXPR_PTR hb_compExprNewString( char *szValue, ULONG ulLen, BOOL fDealloc, HB_ HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewString(%s)", szValue)); - pExpr = hb_compExprNew( HB_ET_STRING, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_STRING ); pExpr->value.asString.string = szValue; pExpr->value.asString.dealloc = fDealloc; @@ -322,7 +380,7 @@ HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR pArrList, HB_COMP_DECL ) if( pExpr->ExprType == HB_ET_NONE && pExpr->pNext == NULL ) { pArrList->value.asList.pExprList = NULL; - HB_EXPR_PCODE1( hb_compExprDelete, pExpr ); + HB_COMP_EXPR_FREE( pExpr ); } else { @@ -349,7 +407,7 @@ HB_EXPR_PTR hb_compExprNewCodeBlock( char *string, int iLen, int iFlags, HB_COMP HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewCodeBlock(%s,%d,%d,%p)",string, iLen, iFlags, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_CODEBLOCK, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_CODEBLOCK ); pExpr->value.asCodeblock.pExprList = NULL; pExpr->value.asCodeblock.pLocals = NULL; /* this will hold local variables declarations */ @@ -384,7 +442,7 @@ HB_EXPR_PTR hb_compExprNewLogical( int iValue, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewLogical(%i,%p)", iValue, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_LOGICAL, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_LOGICAL ); pExpr->value.asLogical = iValue; pExpr->ValType = HB_EV_LOGICAL; @@ -399,7 +457,7 @@ HB_EXPR_PTR hb_compExprNewNil( HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewNil(%p)", HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_NIL, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_NIL ); pExpr->ValType = HB_EV_NIL; return pExpr; @@ -411,7 +469,7 @@ HB_EXPR_PTR hb_compExprNewSelf( HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewSelf(%p)", HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_SELF, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_SELF ); pExpr->ValType = HB_EV_OBJECT; return pExpr; @@ -423,7 +481,7 @@ HB_EXPR_PTR hb_compExprNewVarRef( char * szVarName, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewVarRef(%s,%p)", szVarName, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_VARREF, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_VARREF ); pExpr->value.asSymbol = szVarName; pExpr->ValType = HB_EV_VARREF; @@ -436,7 +494,7 @@ HB_EXPR_PTR hb_compExprNewFunRef( char * szFunName, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewFunRef(%s,%p)", szFunName, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_FUNREF, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNREF ); pExpr->value.asSymbol = szFunName; pExpr->ValType = HB_EV_FUNREF; @@ -449,7 +507,7 @@ HB_EXPR_PTR hb_compExprNewRef( HB_EXPR_PTR pRefer, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewRef(%p,%p)", pRefer, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_REFERENCE, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_REFERENCE ); pExpr->value.asReference = pRefer; pExpr->ValType = HB_EV_VARREF; @@ -464,7 +522,7 @@ HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR pMacroExpr, { HB_EXPR_PTR pExpr; - pExpr = hb_compExprNew( HB_ET_MACRO, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_MACRO ); if( szName ) { HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewMacro(%s)", szName)); @@ -511,7 +569,7 @@ HB_EXPR_PTR hb_compExprNewAliasVar( HB_EXPR_PTR pAlias, HB_EXPR_PTR pVariable, HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewAliasVar()")); - pExpr = hb_compExprNew( HB_ET_ALIASVAR, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIASVAR ); pExpr->value.asAlias.pAlias = pAlias; pExpr->value.asAlias.pVar = pVariable; @@ -537,7 +595,7 @@ HB_EXPR_PTR hb_compExprNewAliasExpr( HB_EXPR_PTR pAlias, HB_EXPR_PTR pExpList, HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewAliasExpr()")); - pExpr = hb_compExprNew( HB_ET_ALIASEXPR, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIASEXPR ); pExpr->value.asAlias.pAlias = pAlias; pExpr->value.asAlias.pExpList = pExpList; @@ -587,7 +645,7 @@ HB_EXPR_PTR hb_compExprNewList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewList()")); - pExpr = hb_compExprNew( HB_ET_LIST, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_LIST ); pExpr->value.asList.pExprList = pFirstItem; pExpr->value.asList.reference = FALSE; return pExpr; @@ -601,7 +659,7 @@ HB_EXPR_PTR hb_compExprNewArgList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewArgList()")); - pExpr = hb_compExprNew( HB_ET_ARGLIST, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_ARGLIST ); pExpr->value.asList.pExprList = pFirstItem; pExpr->value.asList.reference = FALSE; return pExpr; @@ -615,7 +673,7 @@ HB_EXPR_PTR hb_compExprNewArgRef( HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewArgRef()")); - pExpr = hb_compExprNew( HB_ET_ARGLIST, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_ARGLIST ); pExpr->value.asList.pExprList = NULL; pExpr->value.asList.reference = TRUE; return pExpr; @@ -629,7 +687,7 @@ HB_EXPR_PTR hb_compExprNewMacroArgList( HB_EXPR_PTR pFirstItem, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewMacroArgList()")); - pExpr = hb_compExprNew( HB_ET_MACROARGLIST, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_MACROARGLIST ); pExpr->value.asList.pExprList = pFirstItem; pExpr->value.asList.reference = FALSE; return pExpr; @@ -661,7 +719,7 @@ HB_EXPR_PTR hb_compExprNewVar( char * szName, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewVar(%s,%p)", szName, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_VARIABLE, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_VARIABLE ); pExpr->value.asSymbol = szName; return pExpr; } @@ -678,7 +736,7 @@ HB_EXPR_PTR hb_compExprNewRTVar( char * szName, HB_EXPR_PTR pMacroVar, HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewRTVar(%s, %p, %p)", szName, pMacroVar, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_RTVAR, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_RTVAR ); pExpr->value.asRTVar.szName = szName; pExpr->value.asRTVar.pMacro = pMacroVar; if( pMacroVar ) @@ -694,7 +752,7 @@ HB_EXPR_PTR hb_compExprNewFunName( char * szName, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewFunName(%s,%p)", szName, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_FUNNAME, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_FUNNAME ); pExpr->value.asSymbol = szName; return pExpr; } @@ -707,7 +765,7 @@ HB_EXPR_PTR hb_compExprNewAlias( char * szName, HB_COMP_DECL ) HB_TRACE(HB_TR_DEBUG, ("hb_compExprNewAlias(%s,%p)", szName, HB_COMP_PARAM)); - pExpr = hb_compExprNew( HB_ET_ALIAS, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_ET_ALIAS ); pExpr->value.asSymbol = szName; return pExpr; } @@ -717,7 +775,7 @@ HB_EXPR_PTR hb_compExprNewAlias( char * szName, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewEqual( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_EQUAL, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_EQUAL ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -725,7 +783,7 @@ HB_EXPR_PTR hb_compExprNewEqual( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPlus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_PLUS, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PLUS ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -733,7 +791,7 @@ HB_EXPR_PTR hb_compExprNewPlus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewMinus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_MINUS, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MINUS ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -741,7 +799,7 @@ HB_EXPR_PTR hb_compExprNewMinus( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewMult( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_MULT, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MULT ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -749,7 +807,7 @@ HB_EXPR_PTR hb_compExprNewMult( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewDiv( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_DIV, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_DIV ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -757,7 +815,7 @@ HB_EXPR_PTR hb_compExprNewDiv( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewMod( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_MOD, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MOD ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -765,7 +823,7 @@ HB_EXPR_PTR hb_compExprNewMod( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPower( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_POWER, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_POWER ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -773,7 +831,7 @@ HB_EXPR_PTR hb_compExprNewPower( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPostInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_POSTINC, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_POSTINC ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -781,7 +839,7 @@ HB_EXPR_PTR hb_compExprNewPostInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPostDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_POSTDEC, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_POSTDEC ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -789,7 +847,7 @@ HB_EXPR_PTR hb_compExprNewPostDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPreInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_PREINC, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PREINC ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -797,7 +855,7 @@ HB_EXPR_PTR hb_compExprNewPreInc( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPreDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_PREDEC, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PREDEC ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -805,7 +863,7 @@ HB_EXPR_PTR hb_compExprNewPreDec( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewPlusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_PLUSEQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_PLUSEQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -813,7 +871,7 @@ HB_EXPR_PTR hb_compExprNewPlusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewMinusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_MINUSEQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MINUSEQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -821,7 +879,7 @@ HB_EXPR_PTR hb_compExprNewMinusEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewMultEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_MULTEQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MULTEQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -829,7 +887,7 @@ HB_EXPR_PTR hb_compExprNewMultEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewDivEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_DIVEQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_DIVEQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -837,7 +895,7 @@ HB_EXPR_PTR hb_compExprNewDivEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewModEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_MODEQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_MODEQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -845,7 +903,7 @@ HB_EXPR_PTR hb_compExprNewModEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewExpEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_EXPEQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_EXPEQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -853,7 +911,7 @@ HB_EXPR_PTR hb_compExprNewExpEq( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewAnd( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_AND, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_AND ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -861,7 +919,7 @@ HB_EXPR_PTR hb_compExprNewAnd( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewOr( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_OR, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_OR ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -878,7 +936,7 @@ HB_EXPR_PTR hb_compExprNewNot( HB_EXPR_PTR pNotExpr, HB_COMP_DECL ) } else { - pExpr = hb_compExprNew( HB_EO_NOT, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_EO_NOT ); pExpr->value.asOperator.pLeft = pNotExpr; pExpr->value.asOperator.pRight = NULL; } @@ -888,7 +946,7 @@ HB_EXPR_PTR hb_compExprNewNot( HB_EXPR_PTR pNotExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewEQ( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_EQ, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_EQ ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -896,7 +954,7 @@ HB_EXPR_PTR hb_compExprNewEQ( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewLT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_LT, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_LT ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -904,7 +962,7 @@ HB_EXPR_PTR hb_compExprNewLT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewGT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_GT, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_GT ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -912,7 +970,7 @@ HB_EXPR_PTR hb_compExprNewGT( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewLE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_LE, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_LE ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -920,7 +978,7 @@ HB_EXPR_PTR hb_compExprNewLE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewGE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_GE, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_GE ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -928,7 +986,7 @@ HB_EXPR_PTR hb_compExprNewGE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewNE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_NE, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_NE ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -936,7 +994,7 @@ HB_EXPR_PTR hb_compExprNewNE( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) HB_EXPR_PTR hb_compExprNewIN( HB_EXPR_PTR pLeftExpr, HB_COMP_DECL ) { - HB_EXPR_PTR pExpr = hb_compExprNew( HB_EO_IN, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_EO_IN ); pExpr->value.asOperator.pLeft = pLeftExpr; pExpr->value.asOperator.pRight = NULL; return pExpr; @@ -964,13 +1022,113 @@ HB_EXPR_PTR hb_compExprNewNegate( HB_EXPR_PTR pNegExpr, HB_COMP_DECL ) } else { - pExpr = hb_compExprNew( HB_EO_NEGATE, HB_COMP_PARAM ); + pExpr = HB_COMP_EXPR_NEW( HB_EO_NEGATE ); pExpr->value.asOperator.pLeft = pNegExpr; pExpr->value.asOperator.pRight = NULL; } return pExpr; } +/* Handles (expression := expression) syntax + */ +HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr, + HB_COMP_DECL ) +{ + HB_EXPR_PTR pExpr; + + HB_TRACE(HB_TR_DEBUG, ("hb_compExprAssign()")); + + pExpr = HB_COMP_EXPR_NEW( HB_EO_ASSIGN ); + pExpr->value.asOperator.pLeft = pLeftExpr; + pExpr->value.asOperator.pRight = pRightExpr; + return pExpr; +} + +void hb_compExprDelOperator( HB_EXPR_PTR pExpr, HB_COMP_DECL ) +{ + if( pExpr->value.asOperator.pLeft ) + HB_COMP_EXPR_FREE( pExpr->value.asOperator.pLeft ); + if( pExpr->value.asOperator.pRight ) + HB_COMP_EXPR_FREE( pExpr->value.asOperator.pRight ); +} + +/* Sets the argument of an operation found previously + */ +HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR pExpr, HB_EXPR_PTR pItem, HB_COMP_DECL ) +{ + BYTE ucRight; + + ucRight = s_PrecedTable[ pItem->ExprType ]; + + if( ucRight == HB_ET_NIL ) + { + /* the right side of an operator is an ordinary value + * e.g. a := 1 + */ + pExpr->value.asOperator.pRight = pItem; + } + else if( ucRight == HB_ET_NONE ) + { + /* the right side of an operator is an invalid expression + * e.g. + * a := 1 + b:=2 + * a := 1 + b += 2 + */ + + if( pExpr->ExprType >= HB_EO_PLUSEQ && pExpr->ExprType <= HB_EO_EXPEQ ) + { + } + else + { + HB_COMP_ERROR_SYNTAX( pItem ); + } + pExpr->value.asOperator.pRight = pItem; /* set it anyway */ + } + else + { + /* the right side of an operator is an expression with other operator + * e.g. a := 2 + b * 3 + * We have to set the proper order of evaluation using + * precedence rules + */ + BYTE ucLeft = s_PrecedTable[ pExpr->ExprType ]; + if( ucLeft < ucRight || + ( ucLeft == ucRight && HB_COMP_ISSUPPORTED( HB_COMPFLAG_SHORTCUTS ) && + ( ucLeft == HB_EO_OR || ucLeft == HB_EO_AND ) ) ) + { + /* Left operator has a lower precedence then the right one + * e.g. a + b * c + * pItem -> b * c -> L=b R=c O=* + * pExpr -> a + -> l=a r= o=+ + * + * -> a + (b * c) -> Left=a Right=(b * c) Oper=+ + * Left := l + * Right := L (O) R := pItem + * Oper := o + */ + pExpr->value.asOperator.pRight = pItem; + } + else + { + /* Left operator has the same or higer precedence then the right one + * e.g. a * b + c + * pItem -> b + c -> L=b R=c O=+ + * pExpr -> a * -> l=a r= o=* + * + * -> (a * b) + c -> Lelf=(a * b) Right=c Oper=+ + * Left := l (o) L + * Right := R + * Oper := O + */ + pItem->value.asOperator.pLeft = hb_compExprSetOperand( pExpr, pItem->value.asOperator.pLeft, HB_COMP_PARAM ); + pExpr = pItem; + } + } + + return pExpr; +} + + /* ************************************************************************* */ /* Handles prefix¯o-> and ¯o.sufix-> in macro compiler @@ -986,21 +1144,6 @@ HB_EXPR_PTR hb_compExprMacroAsAlias( HB_EXPR_PTR pExpr ) return pExpr; } -/* Handles (expression := expression) syntax - */ -HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr, - HB_COMP_DECL ) -{ - HB_EXPR_PTR pExpr; - - HB_TRACE(HB_TR_DEBUG, ("hb_compExprAssign()")); - - pExpr = hb_compExprNew( HB_EO_ASSIGN, HB_COMP_PARAM ); - pExpr->value.asOperator.pLeft = pLeftExpr; - pExpr->value.asOperator.pRight = pRightExpr; - return pExpr; -} - /* Return a number of elements on the linked list */ ULONG hb_compExprListLen( HB_EXPR_PTR pExpr ) @@ -1125,3 +1268,103 @@ ULONG hb_compExprParamListCheck( HB_COMP_DECL, HB_EXPR_PTR pExpr ) return ulLen; } + +/* Create a new declaration for codeblock local variable + */ +static HB_CBVAR_PTR hb_compExprCBVarNew( char * szVarName, BYTE bType ) +{ + HB_CBVAR_PTR pVar; + + HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarNew(%s)", szVarName)); + + pVar = ( HB_CBVAR_PTR ) hb_xgrab( sizeof( HB_CBVAR ) ); + + pVar->szName = szVarName; + pVar->bType = bType; + pVar->pNext = NULL; + pVar->bUsed = FALSE; + + return pVar; +} + +/* Add a new local variable declaration + */ +HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR pCB, char * szVarName, BYTE bType, + HB_COMP_DECL ) +{ + HB_CBVAR_PTR pVar; + + HB_TRACE(HB_TR_DEBUG, ("hb_compExprCBVarAdd(%s)", szVarName)); + + if( pCB->value.asCodeblock.pLocals ) + { + /* add it to the end of the list + */ + pVar = pCB->value.asCodeblock.pLocals; + while( pVar ) + { + if( strcmp( szVarName, pVar->szName ) == 0 ) + HB_COMP_ERROR_DUPLVAR( szVarName ); + + if( pVar->pNext ) + pVar = pVar->pNext; + else + { + pVar->pNext = hb_compExprCBVarNew( szVarName, bType ); + break; + } + } + } + else + pCB->value.asCodeblock.pLocals = hb_compExprCBVarNew( szVarName, bType ); + + return pCB; +} + +/* NOTE: This deletes all linked variables + */ +void hb_compExprCBVarDel( HB_CBVAR_PTR pVars ) +{ + HB_CBVAR_PTR pDel; + + while( pVars ) + { + pDel = pVars; + pVars = pVars->pNext; + hb_xfree( pDel ); + } +} + +/* Creates a set/get codeblock for passed expression used in __GET + * + * {|var| IIF( var==NIL, , :=var )} + */ +HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL ) +{ + HB_EXPR_PTR pIIF; + HB_EXPR_PTR pSet; + + /* create {|var| expression + * NOTE: this is not a valid variable name so there will be no collisions + */ + /* create var==NIL */ + pIIF = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "~1", HB_COMP_PARAM ), HB_COMP_PARAM ), + hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ); + /* create ( var==NIL, */ + pIIF = hb_compExprNewList( pIIF, HB_COMP_PARAM ); + /* create ( var==NIL, , */ + pIIF = hb_compExprAddListExpr( pIIF, pExpr ); + /* create var */ + pSet =hb_compExprNewVar( "~1", HB_COMP_PARAM ); + /* create :=var */ + pSet = hb_compExprAssign( hb_compExprClone( pExpr ), pSet, HB_COMP_PARAM ); + /* create ( var==nil, , :=var ) */ + pIIF = hb_compExprAddListExpr( pIIF, pSet ); + /* create IIF() expression */ + pIIF = hb_compExprNewIIF( pIIF ); + /* create a codeblock + */ + return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd( + hb_compExprNewCodeBlock( NULL, 0, 0, HB_COMP_PARAM ), + "~1", ' ', HB_COMP_PARAM ), pIIF ); +} diff --git a/harbour/source/common/expropt2.c b/harbour/source/common/expropt2.c index a013e4419e..727adc5065 100644 --- a/harbour/source/common/expropt2.c +++ b/harbour/source/common/expropt2.c @@ -81,7 +81,7 @@ static HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pLeft->value.asString.string = szString; pLeft->value.asString.dealloc = TRUE; } - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pRight ); return pLeft; } @@ -105,8 +105,8 @@ HB_EXPR_PTR hb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pSelf->value.asNum.NumType = HB_ET_LONG; pSelf->ExprType = HB_ET_NUMERIC; pSelf->ValType = HB_EV_NUMERIC; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } } } @@ -196,8 +196,8 @@ HB_EXPR_PTR hb_compExprReduceDiv( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* The expression was reduced - delete old components */ pSelf->ValType = HB_EV_NUMERIC; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } } else @@ -271,8 +271,8 @@ HB_EXPR_PTR hb_compExprReduceMult( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } pSelf->ExprType = HB_ET_NUMERIC; pSelf->ValType = HB_EV_NUMERIC; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else { @@ -348,8 +348,8 @@ HB_EXPR_PTR hb_compExprReduceMinus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } pSelf->ExprType = HB_ET_NUMERIC; pSelf->ValType = HB_EV_NUMERIC; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else if( pLeft->ExprType == HB_ET_DATE && pRight->ExprType == HB_ET_DATE ) { @@ -358,8 +358,8 @@ HB_EXPR_PTR hb_compExprReduceMinus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pSelf->value.asNum.NumType = HB_ET_LONG; pSelf->ExprType = HB_ET_NUMERIC; pSelf->ValType = HB_EV_NUMERIC; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else if( pLeft->ExprType == HB_ET_DATE && pRight->ExprType == HB_ET_NUMERIC ) { @@ -373,8 +373,8 @@ HB_EXPR_PTR hb_compExprReduceMinus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } pSelf->ExprType = HB_ET_DATE; pSelf->ValType = HB_EV_DATE; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else if( pLeft->ExprType == HB_ET_STRING && pRight->ExprType == HB_ET_STRING ) { @@ -451,8 +451,8 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } pSelf->ExprType = HB_ET_NUMERIC; pSelf->ValType = HB_EV_NUMERIC; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else if( pRight->ExprType == HB_ET_DATE ) { @@ -462,8 +462,8 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pSelf->value.asNum.val.l = pRight->value.asNum.val.l + ( HB_LONG ) pLeft->value.asNum.val.d; pSelf->ExprType = HB_ET_DATE; pSelf->ValType = HB_EV_DATE; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else if( HB_SUPPORT_HARBOUR && ( pLeft->value.asNum.NumType == HB_ET_LONG ? @@ -474,9 +474,9 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * data type is used */ pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pRight; - hb_compExprFree( pLeft, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); } else { @@ -494,8 +494,8 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pSelf->value.asNum.val.l = pLeft->value.asNum.val.l + ( HB_LONG ) pRight->value.asNum.val.d; pSelf->ExprType = HB_ET_DATE; pSelf->ValType = HB_EV_DATE; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); } else if( HB_SUPPORT_HARBOUR && ( pRight->value.asNum.NumType == HB_ET_LONG ? @@ -506,9 +506,9 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * data type is used */ pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pLeft; - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pRight ); } else { @@ -521,16 +521,16 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) if( pRight->ulLength == 0 ) { pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pLeft; - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pRight ); } else if( pLeft->ulLength == 0 ) { pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pRight; - hb_compExprFree( pLeft, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); } else { @@ -555,7 +555,7 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL ) if( fReduce ) { pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = hb_compExprReducePlusStrings( pLeft, pRight, HB_COMP_PARAM ); } } @@ -590,8 +590,8 @@ HB_EXPR_PTR hb_compExprReduceIN( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * "" $ "XXX" = .T. * "" $ "" = .T. */ - hb_compExprFree( pSelf->value.asOperator.pLeft, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asOperator.pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf->value.asOperator.pLeft ); + HB_COMP_EXPR_FREE( pSelf->value.asOperator.pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -620,8 +620,8 @@ HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * .T. != .F. = .T. */ BOOL bResult = ( pLeft->value.asLogical != pRight->value.asLogical ); - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -636,8 +636,8 @@ HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) */ if( ( pLeft->ulLength | pRight->ulLength ) == 0 ) { - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = FALSE; @@ -667,8 +667,8 @@ HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } break; } - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -676,8 +676,8 @@ HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) break; case HB_ET_NIL: - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = FALSE; @@ -710,8 +710,8 @@ HB_EXPR_PTR hb_compExprReduceGE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * .F. >= .T. = .f. */ BOOL bResult = ! ( ! pLeft->value.asLogical && pRight->value.asLogical ); - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -739,8 +739,8 @@ HB_EXPR_PTR hb_compExprReduceGE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } break; } - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -774,8 +774,8 @@ HB_EXPR_PTR hb_compExprReduceLE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * .F. <= .T. = .T. */ BOOL bResult = ! ( pLeft->value.asLogical && ! pRight->value.asLogical ); - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -803,8 +803,8 @@ HB_EXPR_PTR hb_compExprReduceLE( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } break; } - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -838,8 +838,8 @@ HB_EXPR_PTR hb_compExprReduceGT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * .F. > .T. = .F. */ BOOL bResult = ( pLeft->value.asLogical && ! pRight->value.asLogical ); - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -867,8 +867,8 @@ HB_EXPR_PTR hb_compExprReduceGT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } break; } - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -902,8 +902,8 @@ HB_EXPR_PTR hb_compExprReduceLT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) * .T. < .F. = .F. */ BOOL bResult = ( ! pLeft->value.asLogical && pRight->value.asLogical ); - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -931,8 +931,8 @@ HB_EXPR_PTR hb_compExprReduceLT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } break; } - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -964,8 +964,8 @@ HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL ) case HB_ET_LOGICAL: { BOOL bResult = ( pLeft->value.asLogical == pRight->value.asLogical ); - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -986,8 +986,8 @@ HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL ) memcmp( pLeft->value.asString.string, pRight->value.asString.string, pLeft->ulLength ) == 0; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -1013,8 +1013,8 @@ HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL ) bResult = ( pLeft->value.asNum.val.d == pRight->value.asNum.val.l ); break; } - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -1022,8 +1022,8 @@ HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL ) break; case HB_ET_NIL: - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = TRUE; @@ -1050,8 +1050,8 @@ HB_EXPR_PTR hb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL ) BOOL bResult; bResult = pLeft->value.asLogical && pRight->value.asLogical; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -1063,17 +1063,17 @@ HB_EXPR_PTR hb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* .T. .AND. expr => expr */ - hb_compExprFree( pLeft, HB_COMP_PARAM); + HB_COMP_EXPR_FREE( pLeft ); pSelf->ExprType = HB_ET_NONE; /* don't delete expression components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pRight; } else { /* .F. .AND. expr => .F. */ - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); /* discard expression */ + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); /* discard expression */ pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = FALSE; @@ -1086,17 +1086,17 @@ HB_EXPR_PTR hb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* expr .AND. .T. => expr */ - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_NONE; /* don't delete expression components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pLeft; } else { /* expr .AND. .F. => .F. */ - hb_compExprFree( pLeft, HB_COMP_PARAM ); /* discard expression */ - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); /* discard expression */ + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = FALSE; @@ -1117,8 +1117,8 @@ HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL ) BOOL bResult; bResult = pLeft->value.asLogical || pRight->value.asLogical; - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = bResult; @@ -1130,8 +1130,8 @@ HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* .T. .OR. expr => .T. */ - hb_compExprFree( pLeft, HB_COMP_PARAM ); - hb_compExprFree( pRight, HB_COMP_PARAM ); /* discard expression */ + HB_COMP_EXPR_FREE( pLeft ); + HB_COMP_EXPR_FREE( pRight ); /* discard expression */ pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = TRUE; @@ -1140,9 +1140,9 @@ HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* .F. .OR. expr => expr */ - hb_compExprFree( pLeft, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); pSelf->ExprType = HB_ET_NONE; /* don't delete expression components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pRight; } } @@ -1153,8 +1153,8 @@ HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* expr .OR. .T. => .T. */ - hb_compExprFree( pLeft, HB_COMP_PARAM ); /* discard expression */ - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pLeft ); /* discard expression */ + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_LOGICAL; pSelf->ValType = HB_EV_LOGICAL; pSelf->value.asLogical = TRUE; @@ -1163,9 +1163,9 @@ HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { /* expr .OR. .F. => expr */ - hb_compExprFree( pRight, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pRight ); pSelf->ExprType = HB_ET_NONE; /* don't delete expression components */ - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); pSelf = pLeft; } } @@ -1197,18 +1197,18 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pExpr = pExpr->pNext; /* skip to TRUE expression */ /* delete condition - it is no longer needed */ - hb_compExprFree( pSelf->value.asList.pExprList, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf->value.asList.pExprList ); /* assign NULL to a start of expressions list to suppress * deletion of expression's components - we are deleting them * here */ pSelf->value.asList.pExprList = NULL; - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); /* store the TRUE expression as a result of reduction */ pSelf = pExpr; pExpr = pExpr->pNext; /* skip to FALSE expression */ - hb_compExprFree( pExpr, HB_COMP_PARAM ); /* delete FALSE expr */ + HB_COMP_EXPR_FREE( pExpr ); /* delete FALSE expr */ pSelf->pNext = NULL; } else @@ -1218,17 +1218,17 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pExpr = pExpr->pNext; /* skip to TRUE expression */ /* delete condition - it is no longer needed */ - hb_compExprFree( pSelf->value.asList.pExprList, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf->value.asList.pExprList ); /* assign NULL to a start of expressions list to suppress * deletion of expression's components - we are deleting them * here */ pSelf->value.asList.pExprList = NULL; - hb_compExprFree( pSelf, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf ); /* store the FALSE expression as a result of reduction */ pSelf = pExpr->pNext; - hb_compExprFree( pExpr, HB_COMP_PARAM ); /* delete TRUE expr */ + HB_COMP_EXPR_FREE( pExpr ); /* delete TRUE expr */ pSelf->pNext = NULL; } @@ -1253,7 +1253,7 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pExpr->ExprType == HB_ET_REFERENCE || pExpr->ExprType == HB_ET_FUNREF ) { - hb_compExprErrorType( pExpr, HB_COMP_PARAM ); + HB_COMP_ERROR_TYPE( pExpr ); } return pSelf; } @@ -1275,7 +1275,7 @@ HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pSelf = pSelf->value.asList.pExprList; pExpr->value.asList.pExprList = NULL; - hb_compExprFree( pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pExpr ); } return pSelf; @@ -1302,11 +1302,11 @@ BOOL hb_compExprReduceAT( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pText->ulLength ), HB_COMP_PARAM ); } - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pParms, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pParms ); memcpy( pSelf, pReduced, sizeof( HB_EXPR ) ); - hb_compExprClear( pReduced, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pReduced ); return TRUE; } else @@ -1326,7 +1326,7 @@ BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_COMP_DECL ) can be divided by 256 but it's not zero, in this case it will return an empty string instead of a Chr(0). [vszakats] */ - HB_EXPR_PTR pExpr = hb_compExprNew( HB_ET_STRING, HB_COMP_PARAM ); + HB_EXPR_PTR pExpr = HB_COMP_EXPR_NEW( HB_ET_STRING ); pExpr->ValType = HB_EV_STRING; if( pArg->value.asNum.NumType == HB_ET_LONG ) @@ -1356,10 +1356,10 @@ BOOL hb_compExprReduceCHR( HB_EXPR_PTR pSelf, HB_COMP_DECL ) pExpr->ulLength = 1; } - hb_compExprFree( pParms, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pParms ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); - hb_compExprClear( pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pExpr ); return TRUE; } @@ -1375,10 +1375,10 @@ BOOL hb_compExprReduceLEN( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { HB_EXPR_PTR pExpr = hb_compExprNewLong( pArg->ulLength, HB_COMP_PARAM ); - hb_compExprFree( pParms, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pParms ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); - hb_compExprClear( pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pExpr ); return TRUE; } return FALSE; @@ -1394,10 +1394,10 @@ BOOL hb_compExprReduceASC( HB_EXPR_PTR pSelf, HB_COMP_DECL ) HB_EXPR_PTR pExpr = hb_compExprNewLong( ( UCHAR ) pArg->value.asString.string[0], HB_COMP_PARAM ); - hb_compExprFree( pParms, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pParms ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); - hb_compExprClear( pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pExpr ); return TRUE; } return FALSE; @@ -1416,10 +1416,10 @@ BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) hb_dateEncStr( pArg->value.asString.string ), HB_COMP_PARAM ); - hb_compExprFree( pParms, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pParms ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); - hb_compExprClear( pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pExpr ); return TRUE; } } @@ -1427,10 +1427,10 @@ BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL ) { HB_EXPR_PTR pExpr = hb_compExprNewDate( 0, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pParms, HB_COMP_PARAM ); - hb_compExprFree( pSelf->value.asFunCall.pFunName, HB_COMP_PARAM ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pParms ); + HB_COMP_EXPR_FREE( pSelf->value.asFunCall.pFunName ); memcpy( pSelf, pExpr, sizeof( HB_EXPR ) ); - hb_compExprClear( pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pExpr ); return TRUE; } diff --git a/harbour/source/compiler/Makefile b/harbour/source/compiler/Makefile index 7c84335876..7176cff149 100644 --- a/harbour/source/compiler/Makefile +++ b/harbour/source/compiler/Makefile @@ -45,14 +45,8 @@ C_SOURCES=\ ppcomp.c \ expropta.c \ exproptb.c \ - exproptc.c \ complex.c \ + hbmain.c \ - -C_MAIN=harbour.c - -LIBS=\ - pp \ - common \ - -include $(TOP)$(ROOT)config/bin.cf +LIBNAME=compiler +include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/source/compiler/exproptc.c b/harbour/source/compiler/exproptc.c deleted file mode 100644 index 7f477dd6a7..0000000000 --- a/harbour/source/compiler/exproptc.c +++ /dev/null @@ -1,10 +0,0 @@ -/* - * $Id$ - */ - -/* hbexprc.c is also included from ../macro/macro.c - * However it produces a slighty different code if used in - * macro compiler (there is an additional parameter passed to some functions) - * 1.11 - ignore this magic number - this is used to force compilation -*/ -#include "hbexprc.c" diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 05664b7835..1ad69410cc 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -251,7 +251,7 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun expressions which we freed ourself. %destructor { - hb_compExprDelete( $$, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( $$ ); } Argument ExtArgument ArgList ... */ @@ -345,34 +345,34 @@ ParamList : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM * stop compilation if invalid syntax will be used. */ Statement : ExecFlow CrlfStmnt - | IfInline CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | FunCall CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | AliasExpr CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | ObjectMethod CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | IfInline CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | FunCall CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | AliasExpr CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ObjectMethod CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } | MacroVar CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) - hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); else - hb_compExprDelete( hb_compErrorSyntax( HB_COMP_PARAM, $1 ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( HB_COMP_ERROR_SYNTAX( $1 ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } | MacroExpr CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) - hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); else - hb_compExprDelete( hb_compErrorSyntax( HB_COMP_PARAM, $1 ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( HB_COMP_ERROR_SYNTAX( $1 ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | PareExpList CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | ExprPreOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | ExprPostOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | ExprOperEq CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | ExprEqual CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } - | DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1, HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | PareExpList CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprPreOp CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprPostOp CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprOperEq CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprEqual CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | ExprAssign CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } + | DoProc CrlfStmnt { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( $1, HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } | BREAK CrlfStmnt { hb_compGenBreak( HB_COMP_PARAM ); hb_compGenPCode2( HB_P_DOSHORT, 0, HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; } | BREAK { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf { - hb_compGenBreak( HB_COMP_PARAM ); hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM ); + hb_compGenBreak( HB_COMP_PARAM ); HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) ); hb_compGenPCode2( HB_P_DOSHORT, 1, HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; } @@ -400,7 +400,7 @@ Statement : ExecFlow CrlfStmnt { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); } - hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM ); /* TODO: check if return value agree with declared value */ + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) ); /* TODO: check if return value agree with declared value */ hb_compGenPCode2( HB_P_RETVALUE, HB_P_ENDPROC, HB_COMP_PARAM ); if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_PROCEDURE ) { /* procedure returns a value */ @@ -635,19 +635,19 @@ FieldAlias : FIELD ALIASOP { $$ = hb_compExprNewAlias( "FIELD", H /* ignore _FIELD-> or FIELD-> if a real alias is specified */ -FieldVarAlias : FieldAlias VarAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = $2; } - | FieldAlias NumAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = $2; } - | FieldAlias PareExpListAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = $2; } - | FieldAlias MacroVarAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = $2; } - | FieldAlias MacroExprAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = $2; } - | FieldAlias NilAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias LiteralAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias LogicalAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias CodeBlockAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias SelfAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias ArrayAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias ArrayAtAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } - | FieldAlias IfInlineAlias { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } +FieldVarAlias : FieldAlias VarAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = $2; } + | FieldAlias NumAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = $2; } + | FieldAlias PareExpListAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = $2; } + | FieldAlias MacroVarAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = $2; } + | FieldAlias MacroExprAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = $2; } + | FieldAlias NilAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias LiteralAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias LogicalAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias CodeBlockAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias SelfAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias ArrayAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias ArrayAtAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } + | FieldAlias IfInlineAlias { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } ; AliasId : IdentName { $$ = hb_compExprNewVar( $1, HB_COMP_PARAM ); } @@ -659,18 +659,18 @@ AliasVar : NumAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB | MacroVarAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB_COMP_PARAM ); } | MacroExprAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB_COMP_PARAM ); } | PareExpListAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB_COMP_PARAM ); } - | NilAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } - | LiteralAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } - | LogicalAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } - | CodeBlockAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } - | SelfAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } - | ArrayAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } - | ArrayAtAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | VariableAtAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | IfInlineAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | FunCallAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | ObjectDataAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | ObjectMethodAlias AliasId { hb_compExprDelete( $2, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ + | NilAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } + | LiteralAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } + | LogicalAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } + | CodeBlockAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } + | SelfAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } + | ArrayAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } + | ArrayAtAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ + | VariableAtAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ + | IfInlineAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ + | FunCallAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ + | ObjectDataAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ + | ObjectMethodAlias AliasId { HB_COMP_EXPR_DELETE( $2 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ | VarAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB_COMP_PARAM ); } | FieldAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB_COMP_PARAM ); } | FieldVarAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2, HB_COMP_PARAM ); } @@ -687,7 +687,7 @@ AliasExpr : NumAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2 | MacroVarAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2, HB_COMP_PARAM ); } | MacroExprAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2, HB_COMP_PARAM ); } | PareExpListAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2, HB_COMP_PARAM ); } - | FieldAlias PareExpList { hb_compExprDelete( $1, HB_COMP_PARAM ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } /* QUESTION: Clipper reports error here - we can handle it */ + | FieldAlias PareExpList { HB_COMP_EXPR_DELETE( $1 ); $$ = hb_compErrorAlias( HB_COMP_PARAM, $2 ); } /* QUESTION: Clipper reports error here - we can handle it */ ; /* Array expressions access @@ -1046,20 +1046,20 @@ ExtVarDef : VarDef | MacroVar AsType { hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, $1, HB_COMP_PARAM ), FALSE ); } | MacroVar AsType INASSIGN Expression - { hb_compExprDelete( hb_compExprGenPush( $4, HB_COMP_PARAM ), HB_COMP_PARAM ); + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( $4, HB_COMP_PARAM ) ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, $1, HB_COMP_PARAM ), TRUE ); } | MacroVar DimList { USHORT uCount = (USHORT) hb_compExprListLen( $2 ); - hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $2, HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, $1, HB_COMP_PARAM ), TRUE ); } | MacroVar DimList AsArray { USHORT uCount = (USHORT) hb_compExprListLen( $2 ); - hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $2, HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, $1, HB_COMP_PARAM ), TRUE ); } @@ -1091,18 +1091,18 @@ VarDef : IdentName AsType { hb_compVariableAdd( HB_COMP_PARAM, $1, HB_COMP_P if( HB_COMP_PARAM->iVarScope == VS_STATIC ) { hb_compStaticDefStart( HB_COMP_PARAM ); /* switch to statics pcode buffer */ - hb_compExprDelete( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( $1, HB_COMP_PARAM ), $6, HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( $1, HB_COMP_PARAM ), $6, HB_COMP_PARAM ), HB_COMP_PARAM ) ); hb_compStaticDefEnd( HB_COMP_PARAM ); hb_compGenStaticName( $1, HB_COMP_PARAM ); } else if( HB_COMP_PARAM->iVarScope == VS_PUBLIC || HB_COMP_PARAM->iVarScope == VS_PRIVATE ) { - hb_compExprDelete( hb_compExprGenPush( $6, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $6, HB_COMP_PARAM ) ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( $1, NULL, HB_COMP_PARAM ), TRUE ); } else { - hb_compExprDelete( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( $1, HB_COMP_PARAM ), $6, HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( $1, HB_COMP_PARAM ), $6, HB_COMP_PARAM ), HB_COMP_PARAM ) ); } HB_COMP_PARAM->iVarScope = $3; } @@ -1265,7 +1265,7 @@ DummyArgList : DummyArgument | DummyArgList ',' DummyArgument ; -DummyArgument : EmptyExpression { hb_compExprDelete( $1, HB_COMP_PARAM ); } +DummyArgument : EmptyExpression { HB_COMP_EXPR_DELETE( $1 ); } ; FormalList : IdentName AsType { hb_compDeclaredParameterAdd( HB_COMP_PARAM, $1, HB_COMP_PARAM->cVarType ); } @@ -1303,7 +1303,7 @@ IfEndif : IfBegin EndIf { hb_compGenJumpHere( $1, HB_COMP_ IfBegin : IF Expression { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf - { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( $2, HB_COMP_PARAM ) ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } EmptyStats { $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $5, HB_COMP_PARAM ); } ; @@ -1314,7 +1314,7 @@ IfElse : ELSE Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_C IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); } Expression Crlf - { hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM ); + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } EmptyStats @@ -1324,7 +1324,7 @@ IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE | IfElseIf ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); } Expression Crlf - { hb_compExprDelete( hb_compExprGenPush( $4, HB_COMP_PARAM ), HB_COMP_PARAM ); + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( $4, HB_COMP_PARAM ) ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } EmptyStats @@ -1384,7 +1384,7 @@ DoCaseBegin : DoCaseStart Cases : CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf { - hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } EmptyStats @@ -1396,7 +1396,7 @@ Cases : CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf | Cases CASE { hb_compLinePushIfInside( HB_COMP_PARAM ); } Expression Crlf { - hb_compExprDelete( hb_compExprGenPush( $4, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $4, HB_COMP_PARAM ) ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } EmptyStats @@ -1415,7 +1415,7 @@ Otherwise : OTHERWISE {hb_compLinePushIfDebugger( HB_COMP_PARAM ); } Crlf { HB_ DoWhile : WhileBegin Expression Crlf { - hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $2, HB_COMP_PARAM ) ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); } EmptyStats @@ -1473,9 +1473,9 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */ iSign = $8 ? hb_compExprAsNumSign( $8 ) : 1; if( $8 ) - hb_compExprClear( hb_compExprGenPush( hb_compExprSetOperand( hb_compExprNewPlusEq( $2, HB_COMP_PARAM ), $8, HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprSetOperand( hb_compExprNewPlusEq( $2, HB_COMP_PARAM ), $8, HB_COMP_PARAM ), HB_COMP_PARAM ) ); else - hb_compExprClear( hb_compExprGenPush( hb_compExprNewPreInc( $2, HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprNewPreInc( $2, HB_COMP_PARAM ), HB_COMP_PARAM ) ); hb_compGenJumpHere( $9, HB_COMP_PARAM ); hb_compExprGenPush( $7, HB_COMP_PARAM ); /* end */ if( iSign ) @@ -1490,10 +1490,10 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */ hb_compLoopEnd( HB_COMP_PARAM ); if( hb_compExprAsSymbol( $2 ) ) hb_compForEnd( HB_COMP_PARAM, hb_compExprAsSymbol( $2 ) ); - hb_compExprDelete( $7, HB_COMP_PARAM ); - hb_compExprDelete( $5, HB_COMP_PARAM ); /* deletes $5, $2, $4 */ + HB_COMP_EXPR_DELETE( $7 ); + HB_COMP_EXPR_DELETE( $5 ); /* deletes $5, $2, $4 */ if( $8 ) - hb_compExprDelete( $8, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( $8 ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; } ; @@ -1568,8 +1568,8 @@ ForEach : FOREACH ForList IN ForArgs /* 1 2 3 4 */ hb_compLoopEnd( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; hb_compEnumEnd( HB_COMP_PARAM, $2 ); - hb_compExprDelete( $2, HB_COMP_PARAM ); - hb_compExprDelete( $4, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( $2 ); + HB_COMP_EXPR_DELETE( $4 ); } ; @@ -1610,7 +1610,7 @@ SwitchStart : DOSWITCH } Expression Crlf { - hb_compExprDelete( hb_compExprGenPush( $3, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) ); } ; @@ -1777,7 +1777,7 @@ DoArgument : IdentName { $$ = hb_compExprNewVarRef( $1, HB_COMP_PARAM ); WithObject : WITHOBJECT Expression Crlf { hb_compLinePushIfInside( HB_COMP_PARAM ); - hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( $2, HB_COMP_PARAM ) ); $$ = HB_COMP_PARAM->functions.pLast->lPCodePos; hb_compGenPCode1( HB_P_WITHOBJECTSTART, HB_COMP_PARAM ); HB_COMP_PARAM->wWithObjectCnt++; @@ -2115,9 +2115,9 @@ static void hb_compRTVariableGen( HB_COMP_DECL, char * szCreateFun ) while( pVar ) { if( pVar->bPopValue ) - hb_compExprDelete( hb_compExprGenPop( pVar->pVar, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPop( pVar->pVar, HB_COMP_PARAM ) ); else - hb_compExprDelete( pVar->pVar, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pVar->pVar ); pDel = pVar; pVar = pVar->pPrev; hb_xfree( pDel ); @@ -2133,7 +2133,7 @@ void hb_compRTVariableKill( HB_COMP_DECL ) { pVar = HB_COMP_PARAM->rtvars; - hb_compExprDelete( pVar->pVar, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pVar->pVar ); HB_COMP_PARAM->rtvars = pVar->pPrev; hb_xfree( pVar ); } @@ -2146,7 +2146,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D { USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); hb_compVariableAdd( HB_COMP_PARAM, szName, 'A' ); - hb_compExprDelete( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( szName, NULL, HB_COMP_PARAM ), TRUE ); } @@ -2167,7 +2167,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D /* now pop an array */ hb_compExprGenPop( pVar, HB_COMP_PARAM ); /* delete all used expressions */ - hb_compExprDelete( pAssign, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pAssign ); hb_compStaticDefEnd( HB_COMP_PARAM ); } else @@ -2175,9 +2175,9 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); hb_compVariableAdd( HB_COMP_PARAM, szName, 'A' ); - hb_compExprDelete( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); - hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName, HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPop( hb_compExprNewVar( szName, HB_COMP_PARAM ), HB_COMP_PARAM ) ); } } @@ -2419,12 +2419,12 @@ static void hb_compSwitchEnd( HB_COMP_DECL ) { if( hb_compExprIsLong(pCase->pExpr) || hb_compExprIsString(pCase->pExpr) ) { - hb_compExprDelete( hb_compExprGenPush( pCase->pExpr, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( pCase->pExpr, HB_COMP_PARAM ) ); hb_compGenJumpThere( hb_compGenJump( 0, HB_COMP_PARAM ), pCase->ulOffset, HB_COMP_PARAM ); } else { - hb_compExprDelete( pCase->pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pCase->pExpr ); } } pCase = pCase->pNext; @@ -2468,7 +2468,7 @@ void hb_compSwitchKill( HB_COMP_DECL ) while( HB_COMP_PARAM->pSwitch->pCases ) { pCase = HB_COMP_PARAM->pSwitch->pCases; - hb_compExprDelete( pCase->pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pCase->pExpr ); HB_COMP_PARAM->pSwitch->pCases = pCase->pNext; hb_xfree( (void *) pCase ); } @@ -2490,12 +2490,12 @@ static HB_EXPR_PTR hb_compCheckPassByRef( HB_COMP_DECL, HB_EXPR_PTR pExpr ) if( pExpr->value.asFunCall.pFunName->ExprType == HB_ET_MACRO ) { pExpr = pExpr->value.asFunCall.pFunName; - hb_compExprClear( pDelExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pDelExpr ); } else { pExpr = hb_compExprNewFunRef( hb_compExprAsSymbol( pExpr ), HB_COMP_PARAM ); - hb_compExprDelete( pDelExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pDelExpr ); } return pExpr; } @@ -2507,7 +2507,7 @@ static HB_EXPR_PTR hb_compCheckPassByRef( HB_COMP_DECL, HB_EXPR_PTR pExpr ) { HB_EXPR_PTR pDelExpr = pExpr; pExpr = pExpr->value.asReference; - hb_compExprClear( pDelExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pDelExpr ); } szDesc = hb_compExprAsSymbol( pExpr ); diff --git a/harbour/source/compiler/harbour.yyc b/harbour/source/compiler/harbour.yyc index 6bac6c0bd9..cf93f214eb 100644 --- a/harbour/source/compiler/harbour.yyc +++ b/harbour/source/compiler/harbour.yyc @@ -4277,30 +4277,30 @@ yyreduce: case 57: #line 348 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 58: #line 349 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 59: #line 350 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 60: #line 351 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 61: #line 352 "harbour.y" { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) - hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); else - hb_compExprDelete( hb_compErrorSyntax( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( HB_COMP_ERROR_SYNTAX( (yyvsp[(1) - (2)].asExpr) ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; @@ -4308,46 +4308,46 @@ yyreduce: case 62: #line 358 "harbour.y" { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) - hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); else - hb_compExprDelete( hb_compErrorSyntax( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( HB_COMP_ERROR_SYNTAX( (yyvsp[(1) - (2)].asExpr) ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 63: #line 364 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 64: #line 365 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 65: #line 366 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 66: #line 367 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 67: #line 368 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 68: #line 369 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 69: #line 370 "harbour.y" - { hb_compExprDelete( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenStatement( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; case 70: @@ -4364,7 +4364,7 @@ yyreduce: case 72: #line 374 "harbour.y" { - hb_compGenBreak( HB_COMP_PARAM ); hb_compExprDelete( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + hb_compGenBreak( HB_COMP_PARAM ); HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ) ); hb_compGenPCode2( HB_P_DOSHORT, 1, HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags |= FUN_BREAK_CODE; ;} @@ -4411,7 +4411,7 @@ yyreduce: { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); } - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); /* TODO: check if return value agree with declared value */ + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ) ); /* TODO: check if return value agree with declared value */ hb_compGenPCode2( HB_P_RETVALUE, HB_P_ENDPROC, HB_COMP_PARAM ); if( HB_COMP_PARAM->functions.pLast->bFlags & FUN_PROCEDURE ) { /* procedure returns a value */ @@ -4751,67 +4751,67 @@ yyreduce: case 161: #line 638 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} break; case 162: #line 639 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} break; case 163: #line 640 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} break; case 164: #line 641 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} break; case 165: #line 642 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = (yyvsp[(2) - (2)].asExpr); ;} break; case 166: #line 643 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 167: #line 644 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 168: #line 645 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 169: #line 646 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 170: #line 647 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 171: #line 648 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 172: #line 649 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 173: #line 650 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 174: @@ -4841,62 +4841,62 @@ yyreduce: case 181: #line 662 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 182: #line 663 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 183: #line 664 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 184: #line 665 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 185: #line 666 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 186: #line 667 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 187: #line 668 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 188: #line 669 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 189: #line 670 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 190: #line 671 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 191: #line 672 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 192: #line 673 "harbour.y" - { hb_compExprDelete( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(2) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(1) - (2)].asExpr) ); ;} break; case 193: @@ -4941,7 +4941,7 @@ yyreduce: case 201: #line 690 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (2)].asExpr) ); (yyval.asExpr) = hb_compErrorAlias( HB_COMP_PARAM, (yyvsp[(2) - (2)].asExpr) ); ;} break; case 202: @@ -5647,7 +5647,7 @@ yyreduce: case 416: #line 1049 "harbour.y" - { hb_compExprDelete( hb_compExprGenPush( (yyvsp[(4) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(4) - (4)].asExpr), HB_COMP_PARAM ) ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, (yyvsp[(1) - (4)].asExpr), HB_COMP_PARAM ), TRUE ); ;} break; @@ -5656,7 +5656,7 @@ yyreduce: #line 1053 "harbour.y" { USHORT uCount = (USHORT) hb_compExprListLen( (yyvsp[(2) - (2)].asExpr) ); - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ), TRUE ); ;} @@ -5666,7 +5666,7 @@ yyreduce: #line 1060 "harbour.y" { USHORT uCount = (USHORT) hb_compExprListLen( (yyvsp[(2) - (3)].asExpr) ); - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( NULL, (yyvsp[(1) - (3)].asExpr), HB_COMP_PARAM ), TRUE ); ;} @@ -5715,18 +5715,18 @@ yyreduce: if( HB_COMP_PARAM->iVarScope == VS_STATIC ) { hb_compStaticDefStart( HB_COMP_PARAM ); /* switch to statics pcode buffer */ - hb_compExprDelete( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( (yyvsp[(1) - (6)].string), HB_COMP_PARAM ), (yyvsp[(6) - (6)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( (yyvsp[(1) - (6)].string), HB_COMP_PARAM ), (yyvsp[(6) - (6)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); hb_compStaticDefEnd( HB_COMP_PARAM ); hb_compGenStaticName( (yyvsp[(1) - (6)].string), HB_COMP_PARAM ); } else if( HB_COMP_PARAM->iVarScope == VS_PUBLIC || HB_COMP_PARAM->iVarScope == VS_PRIVATE ) { - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(6) - (6)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(6) - (6)].asExpr), HB_COMP_PARAM ) ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( (yyvsp[(1) - (6)].string), NULL, HB_COMP_PARAM ), TRUE ); } else { - hb_compExprDelete( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( (yyvsp[(1) - (6)].string), HB_COMP_PARAM ), (yyvsp[(6) - (6)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( (yyvsp[(1) - (6)].string), HB_COMP_PARAM ), (yyvsp[(6) - (6)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); } HB_COMP_PARAM->iVarScope = (yyvsp[(3) - (6)].iNumber); ;} @@ -5955,7 +5955,7 @@ yyreduce: case 463: #line 1268 "harbour.y" - { hb_compExprDelete( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); ;} + { HB_COMP_EXPR_DELETE( (yyvsp[(1) - (1)].asExpr) ); ;} break; case 464: @@ -6045,7 +6045,7 @@ yyreduce: case 489: #line 1306 "harbour.y" - { hb_compExprDelete( hb_compExprGenPush( (yyvsp[(2) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); (yyval.iNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (4)].asExpr), HB_COMP_PARAM ) ); (yyval.iNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} break; case 490: @@ -6065,7 +6065,7 @@ yyreduce: case 494: #line 1317 "harbour.y" - { hb_compExprDelete( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ) ); (yyval.iNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} break; @@ -6084,7 +6084,7 @@ yyreduce: case 497: #line 1327 "harbour.y" - { hb_compExprDelete( hb_compExprGenPush( (yyvsp[(4) - (5)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + { HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(4) - (5)].asExpr), HB_COMP_PARAM ) ); (yyval.iNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} break; @@ -6159,7 +6159,7 @@ yyreduce: case 512: #line 1386 "harbour.y" { - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ) ); (yyval.iNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} break; @@ -6181,7 +6181,7 @@ yyreduce: case 515: #line 1398 "harbour.y" { - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(4) - (5)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(4) - (5)].asExpr), HB_COMP_PARAM ) ); (yyval.iNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} break; @@ -6213,7 +6213,7 @@ yyreduce: case 522: #line 1417 "harbour.y" { - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ) ); (yyval.lNumber) = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); ;} break; @@ -6295,9 +6295,9 @@ yyreduce: iSign = (yyvsp[(8) - (12)].asExpr) ? hb_compExprAsNumSign( (yyvsp[(8) - (12)].asExpr) ) : 1; if( (yyvsp[(8) - (12)].asExpr) ) - hb_compExprClear( hb_compExprGenPush( hb_compExprSetOperand( hb_compExprNewPlusEq( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprSetOperand( hb_compExprNewPlusEq( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); else - hb_compExprClear( hb_compExprGenPush( hb_compExprNewPreInc( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( hb_compExprGenPush( hb_compExprNewPreInc( (yyvsp[(2) - (12)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ) ); hb_compGenJumpHere( (yyvsp[(9) - (12)].lNumber), HB_COMP_PARAM ); hb_compExprGenPush( (yyvsp[(7) - (12)].asExpr), HB_COMP_PARAM ); /* end */ if( iSign ) @@ -6312,10 +6312,10 @@ yyreduce: hb_compLoopEnd( HB_COMP_PARAM ); if( hb_compExprAsSymbol( (yyvsp[(2) - (12)].asExpr) ) ) hb_compForEnd( HB_COMP_PARAM, hb_compExprAsSymbol( (yyvsp[(2) - (12)].asExpr) ) ); - hb_compExprDelete( (yyvsp[(7) - (12)].asExpr), HB_COMP_PARAM ); - hb_compExprDelete( (yyvsp[(5) - (12)].asExpr), HB_COMP_PARAM ); /* deletes $5, $2, $4 */ + HB_COMP_EXPR_DELETE( (yyvsp[(7) - (12)].asExpr) ); + HB_COMP_EXPR_DELETE( (yyvsp[(5) - (12)].asExpr) ); /* deletes $5, $2, $4 */ if( (yyvsp[(8) - (12)].asExpr) ) - hb_compExprDelete( (yyvsp[(8) - (12)].asExpr), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( (yyvsp[(8) - (12)].asExpr) ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; ;} break; @@ -6434,8 +6434,8 @@ yyreduce: hb_compLoopEnd( HB_COMP_PARAM ); HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN; hb_compEnumEnd( HB_COMP_PARAM, (yyvsp[(2) - (10)].asExpr) ); - hb_compExprDelete( (yyvsp[(2) - (10)].asExpr), HB_COMP_PARAM ); - hb_compExprDelete( (yyvsp[(4) - (10)].asExpr), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( (yyvsp[(2) - (10)].asExpr) ); + HB_COMP_EXPR_DELETE( (yyvsp[(4) - (10)].asExpr) ); ;} break; @@ -6491,7 +6491,7 @@ yyreduce: case 559: #line 1612 "harbour.y" { - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ) ); ;} break; @@ -6699,7 +6699,7 @@ yyreduce: #line 1778 "harbour.y" { hb_compLinePushIfInside( HB_COMP_PARAM ); - hb_compExprDelete( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( (yyvsp[(2) - (3)].asExpr), HB_COMP_PARAM ) ); (yyval.lNumber) = HB_COMP_PARAM->functions.pLast->lPCodePos; hb_compGenPCode1( HB_P_WITHOBJECTSTART, HB_COMP_PARAM ); HB_COMP_PARAM->wWithObjectCnt++; @@ -7257,9 +7257,9 @@ static void hb_compRTVariableGen( HB_COMP_DECL, char * szCreateFun ) while( pVar ) { if( pVar->bPopValue ) - hb_compExprDelete( hb_compExprGenPop( pVar->pVar, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPop( pVar->pVar, HB_COMP_PARAM ) ); else - hb_compExprDelete( pVar->pVar, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pVar->pVar ); pDel = pVar; pVar = pVar->pPrev; hb_xfree( pDel ); @@ -7275,7 +7275,7 @@ void hb_compRTVariableKill( HB_COMP_DECL ) { pVar = HB_COMP_PARAM->rtvars; - hb_compExprDelete( pVar->pVar, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pVar->pVar ); HB_COMP_PARAM->rtvars = pVar->pPrev; hb_xfree( pVar ); } @@ -7288,7 +7288,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D { USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); hb_compVariableAdd( HB_COMP_PARAM, szName, 'A' ); - hb_compExprDelete( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); hb_compRTVariableAdd( HB_COMP_PARAM, hb_compExprNewRTVar( szName, NULL, HB_COMP_PARAM ), TRUE ); } @@ -7309,7 +7309,7 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D /* now pop an array */ hb_compExprGenPop( pVar, HB_COMP_PARAM ); /* delete all used expressions */ - hb_compExprDelete( pAssign, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pAssign ); hb_compStaticDefEnd( HB_COMP_PARAM ); } else @@ -7317,9 +7317,9 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue, HB_COMP_D USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); hb_compVariableAdd( HB_COMP_PARAM, szName, 'A' ); - hb_compExprDelete( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( pInitValue, HB_COMP_PARAM ) ); hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), HB_COMP_PARAM ); - hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName, HB_COMP_PARAM ), HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPop( hb_compExprNewVar( szName, HB_COMP_PARAM ), HB_COMP_PARAM ) ); } } @@ -7561,12 +7561,12 @@ static void hb_compSwitchEnd( HB_COMP_DECL ) { if( hb_compExprIsLong(pCase->pExpr) || hb_compExprIsString(pCase->pExpr) ) { - hb_compExprDelete( hb_compExprGenPush( pCase->pExpr, HB_COMP_PARAM ), HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( hb_compExprGenPush( pCase->pExpr, HB_COMP_PARAM ) ); hb_compGenJumpThere( hb_compGenJump( 0, HB_COMP_PARAM ), pCase->ulOffset, HB_COMP_PARAM ); } else { - hb_compExprDelete( pCase->pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pCase->pExpr ); } } pCase = pCase->pNext; @@ -7610,7 +7610,7 @@ void hb_compSwitchKill( HB_COMP_DECL ) while( HB_COMP_PARAM->pSwitch->pCases ) { pCase = HB_COMP_PARAM->pSwitch->pCases; - hb_compExprDelete( pCase->pExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pCase->pExpr ); HB_COMP_PARAM->pSwitch->pCases = pCase->pNext; hb_xfree( (void *) pCase ); } @@ -7632,12 +7632,12 @@ static HB_EXPR_PTR hb_compCheckPassByRef( HB_COMP_DECL, HB_EXPR_PTR pExpr ) if( pExpr->value.asFunCall.pFunName->ExprType == HB_ET_MACRO ) { pExpr = pExpr->value.asFunCall.pFunName; - hb_compExprClear( pDelExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pDelExpr ); } else { pExpr = hb_compExprNewFunRef( hb_compExprAsSymbol( pExpr ), HB_COMP_PARAM ); - hb_compExprDelete( pDelExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_DELETE( pDelExpr ); } return pExpr; } @@ -7649,7 +7649,7 @@ static HB_EXPR_PTR hb_compCheckPassByRef( HB_COMP_DECL, HB_EXPR_PTR pExpr ) { HB_EXPR_PTR pDelExpr = pExpr; pExpr = pExpr->value.asReference; - hb_compExprClear( pDelExpr, HB_COMP_PARAM ); + HB_COMP_EXPR_CLEAR( pDelExpr ); } szDesc = hb_compExprAsSymbol( pExpr ); diff --git a/harbour/source/compiler/hbcomp.c b/harbour/source/compiler/hbcomp.c index 6b9a04581a..d75b62dbc3 100644 --- a/harbour/source/compiler/hbcomp.c +++ b/harbour/source/compiler/hbcomp.c @@ -53,6 +53,144 @@ #include "hbcomp.h" +static HB_EXPR_PTR hb_compExprAlloc( HB_COMP_DECL ) +{ + PHB_EXPRLST pExpItm = ( PHB_EXPRLST ) hb_xgrab( sizeof( HB_EXPRLST ) ); + + pExpItm->pNext = HB_COMP_PARAM->pExprLst; + HB_COMP_PARAM->pExprLst = pExpItm; + if( pExpItm->pNext ) + { + pExpItm->pPrev = pExpItm->pNext->pPrev; + pExpItm->pNext->pPrev = pExpItm; + pExpItm->pPrev->pNext = pExpItm; + } + else + pExpItm->pPrev = pExpItm->pNext = pExpItm; + + return &pExpItm->Expression; +} + +static void hb_compExprDealloc( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + if( HB_COMP_PARAM->pExprLst ) + { + PHB_EXPRLST pExpItm = ( PHB_EXPRLST ) pExpr; + + pExpItm->pNext->pPrev = pExpItm->pPrev; + pExpItm->pPrev->pNext = pExpItm->pNext; + if( pExpItm == HB_COMP_PARAM->pExprLst ) + { + if( pExpItm->pNext == pExpItm ) + HB_COMP_PARAM->pExprLst = NULL; + else + HB_COMP_PARAM->pExprLst = pExpItm->pNext; + } + hb_xfree( pExpItm ); + } +} + +static HB_EXPR_PTR hb_compExprNew( HB_COMP_DECL, HB_EXPRTYPE iType ) +{ + HB_EXPR_PTR pExpr; + + HB_TRACE(HB_TR_DEBUG, ("hb_compExprNew(%p,%i)", HB_COMP_PARAM, iType)); + + pExpr = hb_compExprAlloc( HB_COMP_PARAM ); + pExpr->ExprType = iType; + pExpr->pNext = NULL; + pExpr->ValType = HB_EV_UNKNOWN; + pExpr->Counter = 1; + + return pExpr; +} + +/* Delete self - all components will be deleted somewhere else + */ +static void hb_compExprClear( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + if( --pExpr->Counter == 0 ) + hb_compExprDealloc( HB_COMP_PARAM, pExpr ); +} + +/* Delete all components and delete self + */ +static void hb_compExprDelete( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_compExprDelete(%p,%p)", HB_COMP_PARAM, pExpr)); + if( pExpr && --pExpr->Counter == 0 ) + { + HB_EXPR_USE( pExpr, HB_EA_DELETE ); + hb_compExprDealloc( HB_COMP_PARAM, pExpr ); + } +} + +/* Delete all components and delete self + */ +static void hb_compExprFree( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_compExprFree()")); + if( --pExpr->Counter == 0 ) + { + HB_EXPR_USE( pExpr, HB_EA_DELETE ); + hb_compExprDealloc( HB_COMP_PARAM, pExpr ); + } +} + +void hb_compExprLstDealloc( HB_COMP_DECL ) +{ + if( HB_COMP_PARAM->pExprLst ) + { + PHB_EXPRLST pExpItm, pExp; + pExpItm = pExp = HB_COMP_PARAM->pExprLst; + HB_COMP_PARAM->pExprLst = NULL; + do + { + hb_compExprDelete( HB_COMP_PARAM, &pExp->Expression ); + pExp = pExp->pNext; + } + while( pExp != pExpItm ); + do + { + PHB_EXPRLST pFree = pExp; + pExp = pExp->pNext; + hb_xfree( pFree ); + } + while( pExp != pExpItm ); + } +} + +static HB_EXPR_PTR hb_compErrorType( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + const char * szDesc = hb_compExprDescription( pExpr ); + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_INVALID_TYPE, szDesc, NULL ); + return pExpr; +} + +static HB_EXPR_PTR hb_compErrorSyntax( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + const char * szDesc = hb_compExprDescription( pExpr ); + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, szDesc, NULL ); + return pExpr; +} + +static void hb_compErrorDuplVar( HB_COMP_DECL, const char * szVarName ) +{ + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_VAR_DUPL, szVarName, NULL ); +} + +static const HB_COMP_FUNCS s_comp_funcs = +{ + hb_compExprNew, + hb_compExprClear, + hb_compExprFree, + hb_compExprDelete, + + hb_compErrorType, + hb_compErrorSyntax, + hb_compErrorDuplVar, +}; + HB_COMP_PTR hb_comp_new( void ) { HB_COMP_PTR pComp = NULL; @@ -67,6 +205,7 @@ HB_COMP_PTR hb_comp_new( void ) /* initialize default settings */ pComp->mode = HB_MODE_COMPILER; + pComp->funcs = &s_comp_funcs; pComp->pLex->pPP = pPP; diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 0a465cacab..30a3ce6511 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -188,13 +188,6 @@ HB_EXPR_PTR hb_compErrorLValue( HB_COMP_DECL, HB_EXPR_PTR pExpr ) return pExpr; } -HB_EXPR_PTR hb_compErrorType( HB_COMP_DECL, HB_EXPR_PTR pExpr ) -{ - const char * szDesc = hb_compExprDescription( pExpr ); - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_INVALID_TYPE, szDesc, NULL ); - return pExpr; -} - HB_EXPR_PTR hb_compErrorIndex( HB_COMP_DECL, HB_EXPR_PTR pExpr ) { const char * szDesc = hb_compExprDescription( pExpr ); @@ -209,13 +202,6 @@ HB_EXPR_PTR hb_compErrorBound( HB_COMP_DECL, HB_EXPR_PTR pExpr ) return pExpr; } -HB_EXPR_PTR hb_compErrorSyntax( HB_COMP_DECL, HB_EXPR_PTR pExpr ) -{ - const char * szDesc = hb_compExprDescription( pExpr ); - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, szDesc, NULL ); - return pExpr; -} - HB_EXPR_PTR hb_compErrorAlias( HB_COMP_DECL, HB_EXPR_PTR pExpr ) { const char * szDesc = hb_compExprDescription( pExpr ); @@ -230,11 +216,6 @@ HB_EXPR_PTR hb_compErrorStatic( HB_COMP_DECL, const char * szVarName, HB_EXPR_PT return pExpr; } -void hb_compErrorDuplVar( HB_COMP_DECL, const char * szVarName ) -{ - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_VAR_DUPL, szVarName, NULL ); -} - HB_EXPR_PTR hb_compWarnMeaningless( HB_COMP_DECL, HB_EXPR_PTR pExpr ) { if( !HB_COMP_PARAM->fMeaningful ) diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/hbmain.c similarity index 95% rename from harbour/source/compiler/harbour.c rename to harbour/source/compiler/hbmain.c index 22417a99c2..6596654589 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/hbmain.c @@ -122,7 +122,7 @@ static void hb_compMainExit( HB_COMP_DECL ) hb_xexit(); } -int main( int argc, char * argv[] ) +int compMain( int argc, char * argv[] ) { HB_COMP_DECL; int iStatus = EXIT_SUCCESS; @@ -300,307 +300,6 @@ int isatty( int handle ) #endif */ -/* ------------------------------------------------------------------------- */ -/* FM statistic module */ -/* ------------------------------------------------------------------------- */ - -/* remove this 'undef' when number of memory leaks will be reduced to - reasonable size */ -/* #undef HB_FM_STATISTICS */ - - -#ifdef HB_FM_STATISTICS - -#define HB_MEMINFO_SIGNATURE 0xDEADBEAF -#define HB_MEMSTR_BLOCK_MAX 256 - -#ifndef HB_MEMFILER -# define HB_MEMFILER 0xff -#endif - -typedef struct _HB_MEMINFO -{ - struct _HB_MEMINFO * pPrevBlock; - struct _HB_MEMINFO * pNextBlock; - ULONG ulSize; - UINT32 Signature; -} HB_MEMINFO, * PHB_MEMINFO; - -#ifdef HB_ALLOC_ALIGNMENT -# define HB_MEMINFO_SIZE ( ( sizeof( HB_MEMINFO ) + HB_ALLOC_ALIGNMENT - 1 ) - \ - ( sizeof( HB_MEMINFO ) + HB_ALLOC_ALIGNMENT - 1 ) % HB_ALLOC_ALIGNMENT ) -#else -# define HB_MEMINFO_SIZE sizeof( HB_MEMINFO ) -#endif - -static PHB_MEMINFO s_pMemBlocks = NULL; -static LONG s_ulMemoryBlocks = 0; /* memory blocks used */ -static LONG s_ulMemoryMaxBlocks = 0; /* maximum number of used memory blocks */ -static LONG s_ulMemoryMaxConsumed = 0; /* memory size consumed */ -static LONG s_ulMemoryConsumed = 0; /* memory max size consumed */ - -#endif /* HB_FM_STATISTICS */ - -void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ -{ - void * pMem; - - if( ulSize == 0 ) - hb_errInternal( HB_EI_XGRABNULLSIZE, "hb_xgrab requested to allocate zero bytes", NULL, NULL ); - -#ifdef HB_FM_STATISTICS - pMem = malloc( ulSize + HB_MEMINFO_SIZE + sizeof( UINT32 ) ); - if( pMem ) - { - if( s_pMemBlocks ) - s_pMemBlocks->pPrevBlock = ( PHB_MEMINFO ) pMem; - ( ( PHB_MEMINFO ) pMem )->pNextBlock = s_pMemBlocks; - ( ( PHB_MEMINFO ) pMem )->pPrevBlock = NULL; - s_pMemBlocks = ( PHB_MEMINFO ) pMem; - ( ( PHB_MEMINFO ) pMem )->ulSize = ulSize; - ( ( PHB_MEMINFO ) pMem )->Signature = HB_MEMINFO_SIGNATURE; - HB_PUT_LE_UINT32( ( ( BYTE * ) pMem ) + HB_MEMINFO_SIZE + ulSize, HB_MEMINFO_SIGNATURE ); - - s_ulMemoryConsumed += ulSize; - if( s_ulMemoryMaxConsumed < s_ulMemoryConsumed ) - s_ulMemoryMaxConsumed = s_ulMemoryConsumed; - s_ulMemoryBlocks++; - if( s_ulMemoryMaxBlocks < s_ulMemoryBlocks ) - s_ulMemoryMaxBlocks = s_ulMemoryBlocks; - pMem = ( BYTE * ) pMem + HB_MEMINFO_SIZE; -#ifdef HB_PARANOID_MEM_CHECK - memset( HB_MEM_PTR( pMem ), HB_MEMFILER, ulSize ); -#endif - } - else -#else - pMem = malloc( ulSize ); - if( ! pMem ) -#endif - hb_errInternal( HB_EI_XGRABALLOC, "hb_xgrab can't allocate memory", NULL, NULL ); - - return pMem; -} - -void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ -{ -#ifdef HB_FM_STATISTICS - PHB_MEMINFO pMemBlock; - ULONG ulMemSize; - void * pResult; - - if( ulSize == 0 ) - { - if( pMem ) - hb_xfree( pMem ); - return NULL; - } - else if( ! pMem ) - return hb_xgrab( ulSize ); - - pMemBlock = ( PHB_MEMINFO ) ( ( BYTE * ) pMem - HB_MEMINFO_SIZE ); - ulMemSize = pMemBlock->ulSize; - - if( pMemBlock->Signature != HB_MEMINFO_SIGNATURE ) - hb_errInternal( HB_EI_XREALLOCINV, "hb_xrealloc called with an invalid pointer", NULL, NULL ); - - if( HB_GET_LE_UINT32( ( ( BYTE * ) pMem ) + ulMemSize ) != HB_MEMINFO_SIGNATURE ) - hb_errInternal( HB_EI_XMEMOVERFLOW, "Memory buffer overflow", NULL, NULL ); - - HB_PUT_LE_UINT32( ( ( BYTE * ) pMem ) + ulMemSize, 0 ); - - pResult = realloc( pMemBlock, ulSize + HB_MEMINFO_SIZE + sizeof( UINT32 ) ); - if( pResult ) - { - if( s_pMemBlocks == pMemBlock ) - s_pMemBlocks = ( PHB_MEMINFO ) pResult; - else - ( ( PHB_MEMINFO ) pResult )->pPrevBlock->pNextBlock = ( PHB_MEMINFO ) pResult; - - if( ( ( PHB_MEMINFO ) pResult )->pNextBlock ) - ( ( PHB_MEMINFO ) pResult )->pNextBlock->pPrevBlock = ( PHB_MEMINFO ) pResult; - s_ulMemoryConsumed += ( ulSize - ulMemSize ); - - if( s_ulMemoryMaxConsumed < s_ulMemoryConsumed ) - s_ulMemoryMaxConsumed = s_ulMemoryConsumed; - - ( ( PHB_MEMINFO ) pResult )->ulSize = ulSize; /* size of the memory block */ - HB_PUT_LE_UINT32( ( ( BYTE * ) pResult ) + ulSize + HB_MEMINFO_SIZE, HB_MEMINFO_SIGNATURE ); - pResult = ( BYTE * ) pResult + HB_MEMINFO_SIZE; - } -#else - void * pResult = realloc( pMem, ulSize ); -#endif - - if( ! pResult && ulSize ) - hb_errInternal( HB_EI_XREALLOC, "hb_xrealloc can't reallocate memory", NULL, NULL ); - - return pResult; -} - -void hb_xfree( void * pMem ) /* frees fixed memory */ -{ - if( pMem ) - { -#ifdef HB_FM_STATISTICS - PHB_MEMINFO pMemBlock = ( PHB_MEMINFO ) ( ( BYTE * ) pMem - HB_MEMINFO_SIZE ); - - if( pMemBlock->Signature != HB_MEMINFO_SIGNATURE ) - hb_errInternal( HB_EI_XFREEINV, "hb_xfree called with an invalid pointer", NULL, NULL ); - - if( HB_GET_LE_UINT32( ( ( BYTE * ) pMem ) + pMemBlock->ulSize ) != HB_MEMINFO_SIGNATURE ) - hb_errInternal( HB_EI_XMEMOVERFLOW, "Memory buffer overflow", NULL, NULL ); - - s_ulMemoryConsumed -= pMemBlock->ulSize; - s_ulMemoryBlocks--; - if( s_pMemBlocks == pMemBlock ) - s_pMemBlocks = pMemBlock->pNextBlock; - else - pMemBlock->pPrevBlock->pNextBlock = pMemBlock->pNextBlock; - - if( pMemBlock->pNextBlock ) - pMemBlock->pNextBlock->pPrevBlock = pMemBlock->pPrevBlock; - - pMemBlock->Signature = 0; - HB_PUT_LE_UINT32( ( ( BYTE * ) pMem ) + pMemBlock->ulSize, 0 ); - pMem = ( BYTE * ) pMem - HB_MEMINFO_SIZE; -#endif - free( pMem ); - } - else - hb_errInternal( HB_EI_XFREENULL, "hb_xfree called with a NULL pointer", NULL, NULL ); -} - -ULONG hb_xquery( USHORT uiMode ) -{ - ULONG ulResult = 0; - -#ifdef HB_FM_STATISTICS - switch( uiMode ) - { - case HB_MEM_USED: - ulResult = s_ulMemoryConsumed; - break; - - case HB_MEM_USEDMAX: - ulResult = s_ulMemoryMaxConsumed; - break; - } -#else - HB_SYMBOL_UNUSED( uiMode ); -#endif - return ulResult; -} - -#ifdef HB_FM_STATISTICS -static char * hb_memToStr( char * szBuffer, void * pMem, ULONG ulSize ) -{ - unsigned char *byMem = ( BYTE * ) pMem; - char * pDest = szBuffer; - int iSize, i, iPrintable; - - if( ulSize > HB_MEMSTR_BLOCK_MAX ) - iSize = HB_MEMSTR_BLOCK_MAX; - else - iSize = ( int ) ulSize; - - iPrintable = 0; - for( i = 0; i < iSize; ++i ) - if( ( byMem[ i ] & 0x7f ) >= 0x20 ) - iPrintable++; - - if( ( iPrintable * 100 ) / iSize > 70 ) /* more then 70% printable chars */ - { - /* format as string of original chars */ - for( i = 0; i < iSize; ++i ) - if( ( byMem[ i ] & 0x7f ) >= 0x20 ) - * pDest++ = byMem[ i ]; - else - * pDest++ = '.'; - } - else - { - /* format as hex */ - for( i = 0; i < iSize; ++i ) - { - int iLo = byMem[ i ] & 0x0f, iHi = byMem[ i ] >> 4; - * pDest++ = '\\'; - * pDest++ = iHi < 9 ? '0' + iHi : 'A' - 10 + iHi; - * pDest++ = iLo < 9 ? '0' + iLo : 'A' - 10 + iLo; - } - } - * pDest = '\0'; - - return szBuffer; -} -#endif - -void hb_xexit( void ) -{ -#ifdef HB_FM_STATISTICS - if( s_ulMemoryBlocks /* || hb_cmdargCheck( "INFO" ) */ ) - { - char szBuffer[ HB_MAX( 3 * HB_MEMSTR_BLOCK_MAX + 1, 100 ) ]; - PHB_MEMINFO pMemBlock; - int i; - - hb_conOutErr( hb_conNewLine(), 0 ); - hb_conOutErr( "----------------------------------------", 0 ); - hb_conOutErr( hb_conNewLine(), 0 ); - snprintf( szBuffer, sizeof( szBuffer ), "Total memory allocated: %lu bytes (%lu blocks)", s_ulMemoryMaxConsumed, s_ulMemoryMaxBlocks ); - hb_conOutErr( szBuffer, 0 ); - - if( s_ulMemoryBlocks ) - { - hb_conOutErr( hb_conNewLine(), 0 ); - snprintf( szBuffer, sizeof( szBuffer ), "WARNING! Memory allocated but not released: %lu bytes (%lu blocks)", s_ulMemoryConsumed, s_ulMemoryBlocks ); - hb_conOutErr( szBuffer, 0 ); - } - - hb_conOutErr( hb_conNewLine(), 0 ); - - for( i = 1, pMemBlock = s_pMemBlocks; pMemBlock; ++i, pMemBlock = pMemBlock->pNextBlock ) - HB_TRACE( HB_TR_ERROR, ( "Block %i %p (size %lu) \"%s\"", i, - ( char * ) pMemBlock + HB_MEMINFO_SIZE, pMemBlock->ulSize, - hb_memToStr( szBuffer, ( char * ) pMemBlock + HB_MEMINFO_SIZE, - pMemBlock->ulSize ) ) ); - } -#endif -} - -void hb_conOutErr( const char * pStr, ULONG ulLen ) -{ - if( ulLen == 0 ) - ulLen = strlen( pStr ); - - fprintf( hb_comp_errFile, "%.*s", ( int ) ulLen, pStr ); -} - -char * hb_conNewLine( void ) -{ - return "\n"; -} - -/* NOTE: Use as minimal calls from here, as possible. - Don't allocate memory from this function. [vszakats] */ -void hb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 ) -{ - char buffer[ 1024 ]; - - HB_TRACE(HB_TR_DEBUG, ("hb_errInternal(%lu, %s, %s, %s)", ulIntCode, szText, szPar1, szPar2)); - - hb_conOutErr( hb_conNewLine(), 0 ); - snprintf( buffer, sizeof( buffer ), "Unrecoverable error %lu: ", ulIntCode ); - hb_conOutErr( buffer, 0 ); - if( szText ) - { - snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 ); - hb_conOutErr( buffer, 0 ); - } - hb_conOutErr( hb_conNewLine(), 0 ); - exit( EXIT_FAILURE ); -} - /* ------------------------------------------------------------------------- */ /** ACTIONS **/ /* ------------------------------------------------------------------------- */ @@ -2733,6 +2432,30 @@ void hb_compLinePushIfDebugger( HB_COMP_DECL ) } } +/* + * Function generates passed pcode for passed runtime variable + * (field or memvar) + */ +static void hb_compGenVarPCode( BYTE bPCode, char * szVarName, HB_COMP_DECL ) +{ + USHORT wVar; + PCOMSYMBOL pSym; + + /* Check if this variable name is placed into the symbol table + */ + pSym = hb_compSymbolFind( HB_COMP_PARAM, szVarName, &wVar, HB_SYM_MEMVAR ); + if( ! pSym ) + pSym = hb_compSymbolAdd( HB_COMP_PARAM, szVarName, &wVar, HB_SYM_MEMVAR ); + pSym->cScope |= VS_MEMVAR; + + if( bPCode == HB_P_PUSHALIASEDFIELD && wVar <= 255 ) + hb_compGenPCode2( HB_P_PUSHALIASEDFIELDNEAR, ( BYTE ) wVar, HB_COMP_PARAM ); + else if( bPCode == HB_P_POPALIASEDFIELD && wVar <= 255 ) + hb_compGenPCode2( HB_P_POPALIASEDFIELDNEAR, ( BYTE ) wVar, HB_COMP_PARAM ); + else + hb_compGenPCode3( bPCode, HB_LOBYTE( wVar ), HB_HIBYTE( wVar ), HB_COMP_PARAM ); +} + /* * Function generates pcode for undeclared variable */ @@ -2799,30 +2522,6 @@ static void hb_compGenFieldPCode( HB_COMP_DECL, BYTE bPCode, int wVar, char * sz hb_compGenVarPCode( bPCode, szVarName, HB_COMP_PARAM ); } -/* - * Function generates passed pcode for passed runtime variable - * (field or memvar) - */ -void hb_compGenVarPCode( BYTE bPCode, char * szVarName, HB_COMP_DECL ) -{ - USHORT wVar; - PCOMSYMBOL pSym; - - /* Check if this variable name is placed into the symbol table - */ - pSym = hb_compSymbolFind( HB_COMP_PARAM, szVarName, &wVar, HB_SYM_MEMVAR ); - if( ! pSym ) - pSym = hb_compSymbolAdd( HB_COMP_PARAM, szVarName, &wVar, HB_SYM_MEMVAR ); - pSym->cScope |= VS_MEMVAR; - - if( bPCode == HB_P_PUSHALIASEDFIELD && wVar <= 255 ) - hb_compGenPCode2( HB_P_PUSHALIASEDFIELDNEAR, ( BYTE ) wVar, HB_COMP_PARAM ); - else if( bPCode == HB_P_POPALIASEDFIELD && wVar <= 255 ) - hb_compGenPCode2( HB_P_POPALIASEDFIELDNEAR, ( BYTE ) wVar, HB_COMP_PARAM ); - else - hb_compGenPCode3( bPCode, HB_LOBYTE( wVar ), HB_HIBYTE( wVar ), HB_COMP_PARAM ); -} - /* sends a message to an object */ /* bIsObject = TRUE if we are sending a message to real object bIsObject is FALSE if we are sending a message to an object specified @@ -3146,6 +2845,11 @@ void hb_compGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ) } } +void hb_compGenPushMemvarRef( char * szVarName, HB_COMP_DECL ) /* generates the pcode to push memvar variable by reference to the virtual machine stack */ +{ + hb_compGenVarPCode( HB_P_PUSHMEMVARREF, szVarName, HB_COMP_PARAM ); +} + void hb_compGenPushVarRef( char * szVarName, HB_COMP_DECL ) /* generates the pcode to push a variable by reference to the virtual machine stack */ { int iVar; @@ -3484,7 +3188,7 @@ static void hb_compCheckDuplVars( HB_COMP_DECL, PVAR pVar, char * szVarName ) { if( ! strcmp( pVar->szName, szVarName ) ) { - hb_compErrorDuplVar( HB_COMP_PARAM, szVarName ); + HB_COMP_ERROR_DUPLVAR( szVarName ); break; } else @@ -4335,7 +4039,7 @@ void hb_compStaticDefEnd( HB_COMP_DECL ) /* * Start a new fake-function that will hold pcodes for a codeblock */ -void hb_compCodeBlockStart( BOOL bLateEval, HB_COMP_DECL ) +void hb_compCodeBlockStart( HB_COMP_DECL, BOOL bLateEval ) { PFUNCTION pBlock; diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index e937efa08e..6d0c00000a 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -544,7 +544,9 @@ void hb_compPCodeEval( PFUNCTION pFunc, HB_PCODE_FUNC_PTR * pFunctions, void * c if( ulSkip == 0 ) { - fprintf( hb_comp_errFile, "--- Invalid (zero) opcode %i size in hb_compPCodeEval() ---\n", opcode ); + char szOpcode[ 16 ]; + snprintf( szOpcode, sizeof( szOpcode ), "%i", opcode ); + hb_errInternal( HB_EI_COMPBADOPSIZE, "Invalid (zero) opcode %s size in hb_compPCodeEval()", szOpcode, NULL ); ++ulPos; } #if 0 @@ -555,15 +557,18 @@ void hb_compPCodeEval( PFUNCTION pFunc, HB_PCODE_FUNC_PTR * pFunctions, void * c */ if( hb_comp_pcode_len[ opcode ] != 0 && hb_comp_pcode_len[ opcode ] != ulSkip ) { - fprintf( stderr, "Wrong PCODE (%d) size (%ld!=%d)\n", opcode, ulSkip, hb_comp_pcode_len[ opcode ] ); - fflush(stderr); + char szMsg[ 100 ]; + snprintf( szMsg, sizeof( szMsg ), "Wrong PCODE (%d) size (%ld!=%d)", opcode, ulSkip, hb_comp_pcode_len[ opcode ] ); + hb_errInternal( HB_EI_COMPBADOPSIZE, szMsg, NULL, NULL ); } #endif ulPos += ulSkip; } else { - fprintf( hb_comp_errFile, "--- Invalid opcode %i in hb_compPCodeEval() ---\n", opcode ); + char szOpcode[ 16 ]; + snprintf( szOpcode, sizeof( szOpcode ), "%i", opcode ); + hb_errInternal( HB_EI_COMPBADOPCODE, "Invalid opcode: %s in hb_compPCodeEval()", szOpcode, NULL ); ++ulPos; } } @@ -591,7 +596,9 @@ void hb_compPCodeTrace( PFUNCTION pFunc, HB_PCODE_FUNC_PTR * pFunctions, void * } else { - fprintf( hb_comp_errFile, "--- Invalid opcode %i in hb_compPCodeTrace() ---\n", opcode ); + char szOpcode[ 16 ]; + snprintf( szOpcode, sizeof( szOpcode ), "%i", opcode ); + hb_errInternal( HB_EI_COMPBADOPCODE, "Invalid opcode: %s in hb_compPCodeTrace()", szOpcode, NULL ); ++ulPos; } } diff --git a/harbour/source/macro/Makefile b/harbour/source/macro/Makefile index 8376bebe37..9f6577a982 100644 --- a/harbour/source/macro/Makefile +++ b/harbour/source/macro/Makefile @@ -32,7 +32,6 @@ YACC_HEADERS=\ C_SOURCES=\ macroa.c \ macrob.c \ - macroc.c \ macrolex.c \ diff --git a/harbour/source/macro/macro.y b/harbour/source/macro/macro.y index f2117e305e..a756da8983 100644 --- a/harbour/source/macro/macro.y +++ b/harbour/source/macro/macro.y @@ -238,27 +238,27 @@ static void hb_macroIdentNew( HB_COMP_DECL, char * ); Main : Expression '\n' { HB_MACRO_DATA->exprType = hb_compExprType( $1 ); if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH ) - hb_compExprGenPush( $1, HB_COMP_PARAM ); + hb_macroExprGenPush( $1, HB_COMP_PARAM ); else - hb_compExprGenPop( $1, HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); + hb_macroExprGenPop( $1, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); } | Expression { HB_MACRO_DATA->exprType = hb_compExprType( $1 ); if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH ) - hb_compExprGenPush( $1, HB_COMP_PARAM ); + hb_macroExprGenPush( $1, HB_COMP_PARAM ); else - hb_compExprGenPop( $1, HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); + hb_macroExprGenPop( $1, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); } | AsParamList { HB_MACRO_DATA->exprType = hb_compExprType( $1 ); if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH ) - hb_compExprGenPush( $1, HB_COMP_PARAM ); + hb_macroExprGenPush( $1, HB_COMP_PARAM ); else - hb_compExprGenPop( $1, HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); + hb_macroExprGenPop( $1, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); } | Expression error { HB_TRACE(HB_TR_DEBUG, ("macro -> invalid expression: %s", HB_MACRO_DATA->string)); @@ -424,10 +424,10 @@ VariableAt : NumValue ArrayIndex { $$ = $2; } /* Function call */ -FunCall : IDENTIFIER '(' ArgList ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( $1, HB_COMP_PARAM ), $3, HB_COMP_PARAM ); +FunCall : IDENTIFIER '(' ArgList ')' { $$ = hb_macroExprNewFunCall( hb_compExprNewFunName( $1, HB_COMP_PARAM ), $3, HB_COMP_PARAM ); HB_MACRO_CHECK( $$ ); } - | MacroVar '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3, HB_COMP_PARAM ); + | MacroVar '(' ArgList ')' { $$ = hb_macroExprNewFunCall( $1, $3, HB_COMP_PARAM ); HB_MACRO_CHECK( $$ ); } ; @@ -450,9 +450,9 @@ ExtArgument : EPSILON { $$ = hb_compExprNewArgRef( HB_COMP_PARAM ); } /* Object's instance variable */ -ObjectData : LeftExpression ':' IDENTIFIER { $$ = hb_compExprNewSend( $1, $3, NULL, HB_COMP_PARAM ); } - | LeftExpression ':' MacroVar { $$ = hb_compExprNewSend( $1, NULL, $3, HB_COMP_PARAM ); } - | LeftExpression ':' MacroExpr { $$ = hb_compExprNewSend( $1, NULL, $3, HB_COMP_PARAM ); } +ObjectData : LeftExpression ':' IDENTIFIER { $$ = hb_macroExprNewSend( $1, $3, NULL, HB_COMP_PARAM ); } + | LeftExpression ':' MacroVar { $$ = hb_macroExprNewSend( $1, NULL, $3, HB_COMP_PARAM ); } + | LeftExpression ':' MacroExpr { $$ = hb_macroExprNewSend( $1, NULL, $3, HB_COMP_PARAM ); } ; /* Object's method @@ -643,9 +643,9 @@ ArrayIndex : IndexList ']' /* NOTE: $0 represents the expression before ArrayIndex * Don't use ArrayIndex in other context than as an array index! */ -IndexList : '[' ExtExpression { $$ = hb_compExprNewArrayAt( $0, $2, HB_COMP_PARAM ); } - | IndexList ',' ExtExpression { $$ = hb_compExprNewArrayAt( $1, $3, HB_COMP_PARAM ); } - | IndexList ']' '[' ExtExpression { $$ = hb_compExprNewArrayAt( $1, $4, HB_COMP_PARAM ); } +IndexList : '[' ExtExpression { $$ = hb_macroExprNewArrayAt( $0, $2, HB_COMP_PARAM ); } + | IndexList ',' ExtExpression { $$ = hb_macroExprNewArrayAt( $1, $3, HB_COMP_PARAM ); } + | IndexList ']' '[' ExtExpression { $$ = hb_macroExprNewArrayAt( $1, $4, HB_COMP_PARAM ); } ; ElemList : ExtArgument { $$ = hb_compExprNewList( $1, HB_COMP_PARAM ); } @@ -728,7 +728,7 @@ HB_MIDENT, * HB_MIDENT_PTR; /* Allocates memory for Expression holder structure and stores it * on the linked list */ -HB_EXPR_PTR hb_macroExprNew( HB_COMP_DECL ) +static HB_EXPR_PTR hb_macroExprAlloc( HB_COMP_DECL ) { HB_MEXPR_PTR pMExpr = ( HB_MEXPR_PTR ) hb_xgrab( sizeof( HB_MEXPR ) ); pMExpr->pPrev = ( HB_MEXPR_PTR ) HB_MACRO_DATA->pExprLst; @@ -744,6 +744,54 @@ static void hb_macroIdentNew( HB_COMP_DECL, char * szIdent ) HB_MACRO_DATA->pIdentLst = ( void * ) pMIdent; } +static HB_EXPR_PTR hb_macroExprNew( HB_COMP_DECL, HB_EXPRTYPE iType ) +{ + HB_EXPR_PTR pExpr; + + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprNew(%p,%i)", HB_COMP_PARAM, iType)); + + pExpr = hb_macroExprAlloc( HB_COMP_PARAM ); + pExpr->ExprType = iType; + pExpr->pNext = NULL; + pExpr->ValType = HB_EV_UNKNOWN; + pExpr->Counter = 1; + + return pExpr; +} + +/* Delete self - all components will be deleted somewhere else + */ +static void hb_macroExprClear( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_SYMBOL_UNUSED( HB_COMP_PARAM ); + if( --pExpr->Counter == 0 ) + pExpr->ExprType = HB_ET_NONE; +} + +/* Delete all components and delete self + */ +static void hb_macroExprDelete( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprDelete(%p,%p)", HB_COMP_PARAM, pExpr)); + if( pExpr && --pExpr->Counter == 0 ) + { + HB_EXPR_USE( pExpr, HB_EA_DELETE ); + pExpr->ExprType = HB_ET_NONE; + } +} + +/* Delete all components and delete self + */ +static void hb_macroExprFree( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprFree()")); + if( --pExpr->Counter == 0 ) + { + HB_EXPR_USE( pExpr, HB_EA_DELETE ); + pExpr->ExprType = HB_ET_NONE; + } +} + /* Deallocate all memory used by expression optimizer */ static void hb_macroLstFree( HB_MACRO_PTR pMacro ) { @@ -752,7 +800,7 @@ static void hb_macroLstFree( HB_MACRO_PTR pMacro ) HB_MEXPR_PTR pMExpr = ( HB_MEXPR_PTR ) pMacro->pExprLst; do { - hb_compExprDelete( &pMExpr->Expression, pMacro ); + hb_macroExprDelete( pMacro, &pMExpr->Expression ); pMExpr = pMExpr->pPrev; } while( pMExpr ); @@ -774,10 +822,43 @@ static void hb_macroLstFree( HB_MACRO_PTR pMacro ) } } +static HB_EXPR_PTR hb_macroErrorType( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + hb_macroError( EG_ARG, HB_COMP_PARAM ); + return pExpr; +} + +static HB_EXPR_PTR hb_macroErrorSyntax( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + hb_macroError( EG_SYNTAX, HB_COMP_PARAM ); + return pExpr; +} + +static void hb_macroErrorDuplVar( HB_COMP_DECL, const char * szVarName ) +{ + HB_SYMBOL_UNUSED( szVarName ); + hb_macroError( EG_SYNTAX, HB_COMP_PARAM ); +} + + +static const HB_COMP_FUNCS s_macro_funcs = +{ + hb_macroExprNew, + hb_macroExprClear, + hb_macroExprFree, + hb_macroExprDelete, + + hb_macroErrorType, + hb_macroErrorSyntax, + hb_macroErrorDuplVar, +}; + int hb_macroYYParse( HB_MACRO_PTR pMacro ) { int iResult; + pMacro->funcs = &s_macro_funcs; + if( hb_macroLexNew( pMacro ) ) { pMacro->status = HB_MACRO_CONT; diff --git a/harbour/source/macro/macro.yyc b/harbour/source/macro/macro.yyc index 8c65e8d5a0..c2e3e8fbe3 100644 --- a/harbour/source/macro/macro.yyc +++ b/harbour/source/macro/macro.yyc @@ -2022,10 +2022,10 @@ yyreduce: { HB_MACRO_DATA->exprType = hb_compExprType( (yyvsp[(1) - (2)].asExpr) ); if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH ) - hb_compExprGenPush( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); + hb_macroExprGenPush( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); else - hb_compExprGenPop( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); + hb_macroExprGenPop( (yyvsp[(1) - (2)].asExpr), HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); ;} break; @@ -2034,10 +2034,10 @@ yyreduce: { HB_MACRO_DATA->exprType = hb_compExprType( (yyvsp[(1) - (1)].asExpr) ); if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH ) - hb_compExprGenPush( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); + hb_macroExprGenPush( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); else - hb_compExprGenPop( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); + hb_macroExprGenPop( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); ;} break; @@ -2046,10 +2046,10 @@ yyreduce: { HB_MACRO_DATA->exprType = hb_compExprType( (yyvsp[(1) - (1)].asExpr) ); if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_PUSH ) - hb_compExprGenPush( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); + hb_macroExprGenPush( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); else - hb_compExprGenPop( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); + hb_macroExprGenPop( (yyvsp[(1) - (1)].asExpr), HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM ); ;} break; @@ -2361,14 +2361,14 @@ yyreduce: case 63: #line 427 "macro.y" - { (yyval.asExpr) = hb_compExprNewFunCall( hb_compExprNewFunName( (yyvsp[(1) - (4)].string), HB_COMP_PARAM ), (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ); + { (yyval.asExpr) = hb_macroExprNewFunCall( hb_compExprNewFunName( (yyvsp[(1) - (4)].string), HB_COMP_PARAM ), (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ); HB_MACRO_CHECK( (yyval.asExpr) ); ;} break; case 64: #line 430 "macro.y" - { (yyval.asExpr) = hb_compExprNewFunCall( (yyvsp[(1) - (4)].asExpr), (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ); + { (yyval.asExpr) = hb_macroExprNewFunCall( (yyvsp[(1) - (4)].asExpr), (yyvsp[(3) - (4)].asExpr), HB_COMP_PARAM ); HB_MACRO_CHECK( (yyval.asExpr) ); ;} break; @@ -2405,17 +2405,17 @@ yyreduce: case 73: #line 453 "macro.y" - { (yyval.asExpr) = hb_compExprNewSend( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].string), NULL, HB_COMP_PARAM ); ;} + { (yyval.asExpr) = hb_macroExprNewSend( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].string), NULL, HB_COMP_PARAM ); ;} break; case 74: #line 454 "macro.y" - { (yyval.asExpr) = hb_compExprNewSend( (yyvsp[(1) - (3)].asExpr), NULL, (yyvsp[(3) - (3)].asExpr), HB_COMP_PARAM ); ;} + { (yyval.asExpr) = hb_macroExprNewSend( (yyvsp[(1) - (3)].asExpr), NULL, (yyvsp[(3) - (3)].asExpr), HB_COMP_PARAM ); ;} break; case 75: #line 455 "macro.y" - { (yyval.asExpr) = hb_compExprNewSend( (yyvsp[(1) - (3)].asExpr), NULL, (yyvsp[(3) - (3)].asExpr), HB_COMP_PARAM ); ;} + { (yyval.asExpr) = hb_macroExprNewSend( (yyvsp[(1) - (3)].asExpr), NULL, (yyvsp[(3) - (3)].asExpr), HB_COMP_PARAM ); ;} break; case 76: @@ -2741,17 +2741,17 @@ yyreduce: case 193: #line 646 "macro.y" - { (yyval.asExpr) = hb_compExprNewArrayAt( (yyvsp[(0) - (2)].asExpr), (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); ;} + { (yyval.asExpr) = hb_macroExprNewArrayAt( (yyvsp[(0) - (2)].asExpr), (yyvsp[(2) - (2)].asExpr), HB_COMP_PARAM ); ;} break; case 194: #line 647 "macro.y" - { (yyval.asExpr) = hb_compExprNewArrayAt( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].asExpr), HB_COMP_PARAM ); ;} + { (yyval.asExpr) = hb_macroExprNewArrayAt( (yyvsp[(1) - (3)].asExpr), (yyvsp[(3) - (3)].asExpr), HB_COMP_PARAM ); ;} break; case 195: #line 648 "macro.y" - { (yyval.asExpr) = hb_compExprNewArrayAt( (yyvsp[(1) - (4)].asExpr), (yyvsp[(4) - (4)].asExpr), HB_COMP_PARAM ); ;} + { (yyval.asExpr) = hb_macroExprNewArrayAt( (yyvsp[(1) - (4)].asExpr), (yyvsp[(4) - (4)].asExpr), HB_COMP_PARAM ); ;} break; case 196: @@ -3083,7 +3083,7 @@ HB_MIDENT, * HB_MIDENT_PTR; /* Allocates memory for Expression holder structure and stores it * on the linked list */ -HB_EXPR_PTR hb_macroExprNew( HB_COMP_DECL ) +static HB_EXPR_PTR hb_macroExprAlloc( HB_COMP_DECL ) { HB_MEXPR_PTR pMExpr = ( HB_MEXPR_PTR ) hb_xgrab( sizeof( HB_MEXPR ) ); pMExpr->pPrev = ( HB_MEXPR_PTR ) HB_MACRO_DATA->pExprLst; @@ -3099,6 +3099,54 @@ static void hb_macroIdentNew( HB_COMP_DECL, char * szIdent ) HB_MACRO_DATA->pIdentLst = ( void * ) pMIdent; } +static HB_EXPR_PTR hb_macroExprNew( HB_COMP_DECL, HB_EXPRTYPE iType ) +{ + HB_EXPR_PTR pExpr; + + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprNew(%p,%i)", HB_COMP_PARAM, iType)); + + pExpr = hb_macroExprAlloc( HB_COMP_PARAM ); + pExpr->ExprType = iType; + pExpr->pNext = NULL; + pExpr->ValType = HB_EV_UNKNOWN; + pExpr->Counter = 1; + + return pExpr; +} + +/* Delete self - all components will be deleted somewhere else + */ +static void hb_macroExprClear( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_SYMBOL_UNUSED( HB_COMP_PARAM ); + if( --pExpr->Counter == 0 ) + pExpr->ExprType = HB_ET_NONE; +} + +/* Delete all components and delete self + */ +static void hb_macroExprDelete( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprDelete(%p,%p)", HB_COMP_PARAM, pExpr)); + if( pExpr && --pExpr->Counter == 0 ) + { + HB_EXPR_USE( pExpr, HB_EA_DELETE ); + pExpr->ExprType = HB_ET_NONE; + } +} + +/* Delete all components and delete self + */ +static void hb_macroExprFree( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_macroExprFree()")); + if( --pExpr->Counter == 0 ) + { + HB_EXPR_USE( pExpr, HB_EA_DELETE ); + pExpr->ExprType = HB_ET_NONE; + } +} + /* Deallocate all memory used by expression optimizer */ static void hb_macroLstFree( HB_MACRO_PTR pMacro ) { @@ -3107,7 +3155,7 @@ static void hb_macroLstFree( HB_MACRO_PTR pMacro ) HB_MEXPR_PTR pMExpr = ( HB_MEXPR_PTR ) pMacro->pExprLst; do { - hb_compExprDelete( &pMExpr->Expression, pMacro ); + hb_macroExprDelete( pMacro, &pMExpr->Expression ); pMExpr = pMExpr->pPrev; } while( pMExpr ); @@ -3129,10 +3177,43 @@ static void hb_macroLstFree( HB_MACRO_PTR pMacro ) } } +static HB_EXPR_PTR hb_macroErrorType( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + hb_macroError( EG_ARG, HB_COMP_PARAM ); + return pExpr; +} + +static HB_EXPR_PTR hb_macroErrorSyntax( HB_COMP_DECL, HB_EXPR_PTR pExpr ) +{ + hb_macroError( EG_SYNTAX, HB_COMP_PARAM ); + return pExpr; +} + +static void hb_macroErrorDuplVar( HB_COMP_DECL, const char * szVarName ) +{ + HB_SYMBOL_UNUSED( szVarName ); + hb_macroError( EG_SYNTAX, HB_COMP_PARAM ); +} + + +static const HB_COMP_FUNCS s_macro_funcs = +{ + hb_macroExprNew, + hb_macroExprClear, + hb_macroExprFree, + hb_macroExprDelete, + + hb_macroErrorType, + hb_macroErrorSyntax, + hb_macroErrorDuplVar, +}; + int hb_macroYYParse( HB_MACRO_PTR pMacro ) { int iResult; + pMacro->funcs = &s_macro_funcs; + if( hb_macroLexNew( pMacro ) ) { pMacro->status = HB_MACRO_CONT; diff --git a/harbour/source/macro/macroc.c b/harbour/source/macro/macroc.c deleted file mode 100644 index ec57ac4c90..0000000000 --- a/harbour/source/macro/macroc.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * $Id$ - */ - -/* hbexprc.c is also included from ../compiler/exproptc.c - * However it produces a slighty different code if used in - * macro compiler (there is an additional parameter passed to some functions) - * 1.10 - ignore this magic number - this is used to force compilation -*/ - -#define HB_MACRO_SUPPORT - -#include "hbmacro.h" -#include "hbcomp.h" - -#include "hbexprc.c" diff --git a/harbour/source/main/Makefile b/harbour/source/main/Makefile new file mode 100644 index 0000000000..2ff419c0d0 --- /dev/null +++ b/harbour/source/main/Makefile @@ -0,0 +1,16 @@ +# +# $Id$ +# + +ROOT = ../../ + +C_SOURCES=\ + +C_MAIN=harbour.c + +LIBS=\ + pp \ + common \ + compiler \ + +include $(TOP)$(ROOT)config/bin.cf diff --git a/harbour/source/main/harbour.c b/harbour/source/main/harbour.c new file mode 100644 index 0000000000..524e0bfb16 --- /dev/null +++ b/harbour/source/main/harbour.c @@ -0,0 +1,367 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * + * Copyright 2007 Przemyslaw Czerpak + * 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/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "hbcomp.h" + +int main( int argc, char * argv[] ) +{ + return compMain( argc, argv ); +} + +/* ------------------------------------------------------------------------- */ +/* FM statistic module */ +/* ------------------------------------------------------------------------- */ + +/* remove this 'undef' when number of memory leaks will be reduced to + reasonable size */ +/* #undef HB_FM_STATISTICS */ + + +#ifdef HB_FM_STATISTICS + +#define HB_MEMINFO_SIGNATURE 0xDEADBEAF +#define HB_MEMSTR_BLOCK_MAX 256 + +#ifndef HB_MEMFILER +# define HB_MEMFILER 0xff +#endif + +typedef struct _HB_MEMINFO +{ + struct _HB_MEMINFO * pPrevBlock; + struct _HB_MEMINFO * pNextBlock; + ULONG ulSize; + UINT32 Signature; +} HB_MEMINFO, * PHB_MEMINFO; + +#ifdef HB_ALLOC_ALIGNMENT +# define HB_MEMINFO_SIZE ( ( sizeof( HB_MEMINFO ) + HB_ALLOC_ALIGNMENT - 1 ) - \ + ( sizeof( HB_MEMINFO ) + HB_ALLOC_ALIGNMENT - 1 ) % HB_ALLOC_ALIGNMENT ) +#else +# define HB_MEMINFO_SIZE sizeof( HB_MEMINFO ) +#endif + +static PHB_MEMINFO s_pMemBlocks = NULL; +static LONG s_ulMemoryBlocks = 0; /* memory blocks used */ +static LONG s_ulMemoryMaxBlocks = 0; /* maximum number of used memory blocks */ +static LONG s_ulMemoryMaxConsumed = 0; /* memory size consumed */ +static LONG s_ulMemoryConsumed = 0; /* memory max size consumed */ + +#endif /* HB_FM_STATISTICS */ + +void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on failure */ +{ + void * pMem; + + if( ulSize == 0 ) + hb_errInternal( HB_EI_XGRABNULLSIZE, "hb_xgrab requested to allocate zero bytes", NULL, NULL ); + +#ifdef HB_FM_STATISTICS + pMem = malloc( ulSize + HB_MEMINFO_SIZE + sizeof( UINT32 ) ); + if( pMem ) + { + if( s_pMemBlocks ) + s_pMemBlocks->pPrevBlock = ( PHB_MEMINFO ) pMem; + ( ( PHB_MEMINFO ) pMem )->pNextBlock = s_pMemBlocks; + ( ( PHB_MEMINFO ) pMem )->pPrevBlock = NULL; + s_pMemBlocks = ( PHB_MEMINFO ) pMem; + ( ( PHB_MEMINFO ) pMem )->ulSize = ulSize; + ( ( PHB_MEMINFO ) pMem )->Signature = HB_MEMINFO_SIGNATURE; + HB_PUT_LE_UINT32( ( ( BYTE * ) pMem ) + HB_MEMINFO_SIZE + ulSize, HB_MEMINFO_SIGNATURE ); + + s_ulMemoryConsumed += ulSize; + if( s_ulMemoryMaxConsumed < s_ulMemoryConsumed ) + s_ulMemoryMaxConsumed = s_ulMemoryConsumed; + s_ulMemoryBlocks++; + if( s_ulMemoryMaxBlocks < s_ulMemoryBlocks ) + s_ulMemoryMaxBlocks = s_ulMemoryBlocks; + pMem = ( BYTE * ) pMem + HB_MEMINFO_SIZE; +#ifdef HB_PARANOID_MEM_CHECK + memset( HB_MEM_PTR( pMem ), HB_MEMFILER, ulSize ); +#endif + } + else +#else + pMem = malloc( ulSize ); + if( ! pMem ) +#endif + hb_errInternal( HB_EI_XGRABALLOC, "hb_xgrab can't allocate memory", NULL, NULL ); + + return pMem; +} + +void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ +{ +#ifdef HB_FM_STATISTICS + PHB_MEMINFO pMemBlock; + ULONG ulMemSize; + void * pResult; + + if( ulSize == 0 ) + { + if( pMem ) + hb_xfree( pMem ); + return NULL; + } + else if( ! pMem ) + return hb_xgrab( ulSize ); + + pMemBlock = ( PHB_MEMINFO ) ( ( BYTE * ) pMem - HB_MEMINFO_SIZE ); + ulMemSize = pMemBlock->ulSize; + + if( pMemBlock->Signature != HB_MEMINFO_SIGNATURE ) + hb_errInternal( HB_EI_XREALLOCINV, "hb_xrealloc called with an invalid pointer", NULL, NULL ); + + if( HB_GET_LE_UINT32( ( ( BYTE * ) pMem ) + ulMemSize ) != HB_MEMINFO_SIGNATURE ) + hb_errInternal( HB_EI_XMEMOVERFLOW, "Memory buffer overflow", NULL, NULL ); + + HB_PUT_LE_UINT32( ( ( BYTE * ) pMem ) + ulMemSize, 0 ); + + pResult = realloc( pMemBlock, ulSize + HB_MEMINFO_SIZE + sizeof( UINT32 ) ); + if( pResult ) + { + if( s_pMemBlocks == pMemBlock ) + s_pMemBlocks = ( PHB_MEMINFO ) pResult; + else + ( ( PHB_MEMINFO ) pResult )->pPrevBlock->pNextBlock = ( PHB_MEMINFO ) pResult; + + if( ( ( PHB_MEMINFO ) pResult )->pNextBlock ) + ( ( PHB_MEMINFO ) pResult )->pNextBlock->pPrevBlock = ( PHB_MEMINFO ) pResult; + s_ulMemoryConsumed += ( ulSize - ulMemSize ); + + if( s_ulMemoryMaxConsumed < s_ulMemoryConsumed ) + s_ulMemoryMaxConsumed = s_ulMemoryConsumed; + + ( ( PHB_MEMINFO ) pResult )->ulSize = ulSize; /* size of the memory block */ + HB_PUT_LE_UINT32( ( ( BYTE * ) pResult ) + ulSize + HB_MEMINFO_SIZE, HB_MEMINFO_SIGNATURE ); + pResult = ( BYTE * ) pResult + HB_MEMINFO_SIZE; + } +#else + void * pResult = realloc( pMem, ulSize ); +#endif + + if( ! pResult && ulSize ) + hb_errInternal( HB_EI_XREALLOC, "hb_xrealloc can't reallocate memory", NULL, NULL ); + + return pResult; +} + +void hb_xfree( void * pMem ) /* frees fixed memory */ +{ + if( pMem ) + { +#ifdef HB_FM_STATISTICS + PHB_MEMINFO pMemBlock = ( PHB_MEMINFO ) ( ( BYTE * ) pMem - HB_MEMINFO_SIZE ); + + if( pMemBlock->Signature != HB_MEMINFO_SIGNATURE ) + hb_errInternal( HB_EI_XFREEINV, "hb_xfree called with an invalid pointer", NULL, NULL ); + + if( HB_GET_LE_UINT32( ( ( BYTE * ) pMem ) + pMemBlock->ulSize ) != HB_MEMINFO_SIGNATURE ) + hb_errInternal( HB_EI_XMEMOVERFLOW, "Memory buffer overflow", NULL, NULL ); + + s_ulMemoryConsumed -= pMemBlock->ulSize; + s_ulMemoryBlocks--; + if( s_pMemBlocks == pMemBlock ) + s_pMemBlocks = pMemBlock->pNextBlock; + else + pMemBlock->pPrevBlock->pNextBlock = pMemBlock->pNextBlock; + + if( pMemBlock->pNextBlock ) + pMemBlock->pNextBlock->pPrevBlock = pMemBlock->pPrevBlock; + + pMemBlock->Signature = 0; + HB_PUT_LE_UINT32( ( ( BYTE * ) pMem ) + pMemBlock->ulSize, 0 ); + pMem = ( BYTE * ) pMem - HB_MEMINFO_SIZE; +#endif + free( pMem ); + } + else + hb_errInternal( HB_EI_XFREENULL, "hb_xfree called with a NULL pointer", NULL, NULL ); +} + +ULONG hb_xquery( USHORT uiMode ) +{ + ULONG ulResult = 0; + +#ifdef HB_FM_STATISTICS + switch( uiMode ) + { + case HB_MEM_USED: + ulResult = s_ulMemoryConsumed; + break; + + case HB_MEM_USEDMAX: + ulResult = s_ulMemoryMaxConsumed; + break; + } +#else + HB_SYMBOL_UNUSED( uiMode ); +#endif + return ulResult; +} + +#ifdef HB_FM_STATISTICS +static char * hb_memToStr( char * szBuffer, void * pMem, ULONG ulSize ) +{ + unsigned char *byMem = ( BYTE * ) pMem; + char * pDest = szBuffer; + int iSize, i, iPrintable; + + if( ulSize > HB_MEMSTR_BLOCK_MAX ) + iSize = HB_MEMSTR_BLOCK_MAX; + else + iSize = ( int ) ulSize; + + iPrintable = 0; + for( i = 0; i < iSize; ++i ) + if( ( byMem[ i ] & 0x7f ) >= 0x20 ) + iPrintable++; + + if( ( iPrintable * 100 ) / iSize > 70 ) /* more then 70% printable chars */ + { + /* format as string of original chars */ + for( i = 0; i < iSize; ++i ) + if( ( byMem[ i ] & 0x7f ) >= 0x20 ) + * pDest++ = byMem[ i ]; + else + * pDest++ = '.'; + } + else + { + /* format as hex */ + for( i = 0; i < iSize; ++i ) + { + int iLo = byMem[ i ] & 0x0f, iHi = byMem[ i ] >> 4; + * pDest++ = '\\'; + * pDest++ = iHi < 9 ? '0' + iHi : 'A' - 10 + iHi; + * pDest++ = iLo < 9 ? '0' + iLo : 'A' - 10 + iLo; + } + } + * pDest = '\0'; + + return szBuffer; +} +#endif + +void hb_xexit( void ) +{ +#ifdef HB_FM_STATISTICS + if( s_ulMemoryBlocks /* || hb_cmdargCheck( "INFO" ) */ ) + { + char szBuffer[ HB_MAX( 3 * HB_MEMSTR_BLOCK_MAX + 1, 100 ) ]; + PHB_MEMINFO pMemBlock; + int i; + + hb_conOutErr( hb_conNewLine(), 0 ); + hb_conOutErr( "----------------------------------------", 0 ); + hb_conOutErr( hb_conNewLine(), 0 ); + snprintf( szBuffer, sizeof( szBuffer ), "Total memory allocated: %lu bytes (%lu blocks)", s_ulMemoryMaxConsumed, s_ulMemoryMaxBlocks ); + hb_conOutErr( szBuffer, 0 ); + + if( s_ulMemoryBlocks ) + { + hb_conOutErr( hb_conNewLine(), 0 ); + snprintf( szBuffer, sizeof( szBuffer ), "WARNING! Memory allocated but not released: %lu bytes (%lu blocks)", s_ulMemoryConsumed, s_ulMemoryBlocks ); + hb_conOutErr( szBuffer, 0 ); + } + + hb_conOutErr( hb_conNewLine(), 0 ); + + for( i = 1, pMemBlock = s_pMemBlocks; pMemBlock; ++i, pMemBlock = pMemBlock->pNextBlock ) + HB_TRACE( HB_TR_ERROR, ( "Block %i %p (size %lu) \"%s\"", i, + ( char * ) pMemBlock + HB_MEMINFO_SIZE, pMemBlock->ulSize, + hb_memToStr( szBuffer, ( char * ) pMemBlock + HB_MEMINFO_SIZE, + pMemBlock->ulSize ) ) ); + } +#endif +} + +/* NOTE: Use as minimal calls from here, as possible. + Don't allocate memory from this function. [vszakats] */ +void hb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 ) +{ + char buffer[ 1024 ]; + + HB_TRACE(HB_TR_DEBUG, ("hb_errInternal(%lu, %s, %s, %s)", ulIntCode, szText, szPar1, szPar2)); + + hb_conOutErr( hb_conNewLine(), 0 ); + snprintf( buffer, sizeof( buffer ), "Unrecoverable error %lu: ", ulIntCode ); + hb_conOutErr( buffer, 0 ); + if( szText ) + { + snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 ); + hb_conOutErr( buffer, 0 ); + } + hb_conOutErr( hb_conNewLine(), 0 ); + exit( EXIT_FAILURE ); +} + +void hb_conOutErr( const char * pStr, ULONG ulLen ) +{ + if( ulLen == 0 ) + ulLen = strlen( pStr ); + + fprintf( hb_comp_errFile, "%.*s", ( int ) ulLen, pStr ); +} + +void hb_conOutStd( const char * pStr, ULONG ulLen ) +{ + if( ulLen == 0 ) + ulLen = strlen( pStr ); + + printf( "%.*s", ( int ) ulLen, pStr ); +} + +char * hb_conNewLine( void ) +{ + return "\n"; +} diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 03a505760b..18ac67ee45 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -940,7 +940,7 @@ HB_FUNC( HB_SETMACRO ) /* ************************************************************************* */ /* returns the order + 1 of a variable if defined or zero */ -int hb_compLocalVarGetPos( char * szVarName, HB_COMP_DECL ) +static int hb_macroLocalVarGetPos( char * szVarName, HB_COMP_DECL ) { int iVar = 1; HB_CBVAR_PTR pVars = HB_PCODE_DATA->pLocals; @@ -963,10 +963,8 @@ int hb_compLocalVarGetPos( char * szVarName, HB_COMP_DECL ) return 0; } -BOOL hb_compIsValidMacroText( HB_COMP_DECL, char * szText, ULONG ulLen ) +BOOL hb_macroIsValidMacroText( char * szText, ULONG ulLen ) { - HB_SYMBOL_UNUSED( HB_COMP_PARAM ); - if( ulLen ) { while( --ulLen ) @@ -984,55 +982,55 @@ BOOL hb_compIsValidMacroText( HB_COMP_DECL, char * szText, ULONG ulLen ) return FALSE; } -ULONG hb_compGenJump( LONG lOffset, HB_COMP_DECL ) +ULONG hb_macroGenJump( LONG lOffset, HB_COMP_DECL ) { if( lOffset == 0 ) - hb_compGenPCode4( HB_P_JUMPFAR, 0, 0, 0, HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_JUMPFAR, 0, 0, 0, HB_COMP_PARAM ); else if( HB_LIM_INT8( lOffset ) ) - hb_compGenPCode2( HB_P_JUMPNEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode2( HB_P_JUMPNEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM ); else if( HB_LIM_INT16( lOffset ) ) - hb_compGenPCode3( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM ); else if( HB_LIM_INT24( lOffset ) ) - hb_compGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM ); else hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM ); return HB_PCODE_DATA->lPCodePos - 3; } -ULONG hb_compGenJumpFalse( LONG lOffset, HB_COMP_DECL ) +ULONG hb_macroGenJumpFalse( LONG lOffset, HB_COMP_DECL ) { if( lOffset == 0 ) - hb_compGenPCode4( HB_P_JUMPFALSEFAR, 0, 0, 0, HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_JUMPFALSEFAR, 0, 0, 0, HB_COMP_PARAM ); else if( HB_LIM_INT8( lOffset ) ) - hb_compGenPCode2( HB_P_JUMPFALSENEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode2( HB_P_JUMPFALSENEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM ); else if( HB_LIM_INT16( lOffset ) ) - hb_compGenPCode3( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM ); else if( HB_LIM_INT24( lOffset ) ) - hb_compGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM ); else hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM ); return HB_PCODE_DATA->lPCodePos - 3; } -ULONG hb_compGenJumpTrue( LONG lOffset, HB_COMP_DECL ) +ULONG hb_macroGenJumpTrue( LONG lOffset, HB_COMP_DECL ) { if( lOffset == 0 ) - hb_compGenPCode4( HB_P_JUMPTRUEFAR, 0, 0, 0, HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_JUMPTRUEFAR, 0, 0, 0, HB_COMP_PARAM ); else if( HB_LIM_INT8( lOffset ) ) - hb_compGenPCode2( HB_P_JUMPTRUENEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode2( HB_P_JUMPTRUENEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM ); else if( HB_LIM_INT16( lOffset ) ) - hb_compGenPCode3( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM ); else if( HB_LIM_INT24( lOffset ) ) - hb_compGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM ); else hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM ); return HB_PCODE_DATA->lPCodePos - 3; } -void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL ) +void hb_macroGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL ) { BYTE * pCode = HB_PCODE_DATA->pCode; LONG lOffset = ulTo - ulFrom + 1; @@ -1043,15 +1041,15 @@ void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL ) hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM ); } -void hb_compGenJumpHere( ULONG ulOffset, HB_COMP_DECL ) +void hb_macroGenJumpHere( ULONG ulOffset, HB_COMP_DECL ) { - hb_compGenJumpThere( ulOffset, HB_PCODE_DATA->lPCodePos, HB_COMP_PARAM ); + hb_macroGenJumpThere( ulOffset, HB_PCODE_DATA->lPCodePos, HB_COMP_PARAM ); } /* * Function generates pcode for passed memvar name */ -void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_COMP_DECL ) +static void hb_macroMemvarGenPCode( BYTE bPCode, char * szVarName, HB_COMP_DECL ) { BYTE byBuf[ sizeof( HB_DYNS_PTR ) + 1 ]; HB_DYNS_PTR pSym; @@ -1075,11 +1073,11 @@ void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_COMP_DECL ) byBuf[ 0 ] = bPCode; HB_PUT_PTR( &byBuf[ 1 ], pSym ); - hb_compGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM ); + hb_macroGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM ); } /* generates the pcode to push a symbol on the virtual machine stack */ -void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_COMP_DECL ) +void hb_macroGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_COMP_DECL ) { BYTE byBuf[ sizeof( HB_DYNS_PTR ) + 1 ]; HB_DYNS_PTR pSym; @@ -1115,56 +1113,56 @@ void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_ byBuf[ 0 ] = HB_P_MPUSHSYM; HB_PUT_PTR( &byBuf[ 1 ], pSym ); - hb_compGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM ); + hb_macroGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM ); } /* generates the pcode to push a long number on the virtual machine stack */ -void hb_compGenPushLong( HB_LONG lNumber, HB_COMP_DECL ) +void hb_macroGenPushLong( HB_LONG lNumber, HB_COMP_DECL ) { if( lNumber == 0 ) { - hb_compGenPCode1( HB_P_ZERO, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ZERO, HB_COMP_PARAM ); } else if( lNumber == 1 ) { - hb_compGenPCode1( HB_P_ONE, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ONE, HB_COMP_PARAM ); } else if( HB_LIM_INT8( lNumber ) ) { - hb_compGenPCode2( HB_P_PUSHBYTE, (BYTE) lNumber, HB_COMP_PARAM ); + hb_macroGenPCode2( HB_P_PUSHBYTE, (BYTE) lNumber, HB_COMP_PARAM ); } else if( HB_LIM_INT16( lNumber ) ) { - hb_compGenPCode3( HB_P_PUSHINT, HB_LOBYTE( lNumber ), HB_HIBYTE( lNumber ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_PUSHINT, HB_LOBYTE( lNumber ), HB_HIBYTE( lNumber ), HB_COMP_PARAM ); } else if( HB_LIM_INT32( lNumber ) ) { BYTE pBuffer[ 5 ]; pBuffer[ 0 ] = HB_P_PUSHLONG; HB_PUT_LE_UINT32( pBuffer + 1, lNumber ); - hb_compGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM ); + hb_macroGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM ); } else { BYTE pBuffer[ 9 ]; pBuffer[ 0 ] = HB_P_PUSHLONGLONG; HB_PUT_LE_UINT64( pBuffer + 1, lNumber ); - hb_compGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM ); + hb_macroGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM ); } } /* generates the pcode to push a date on the virtual machine stack */ -void hb_compGenPushDate( HB_LONG lNumber, HB_COMP_DECL ) +void hb_macroGenPushDate( HB_LONG lNumber, HB_COMP_DECL ) { BYTE pBuffer[ 5 ]; pBuffer[ 0 ] = HB_P_PUSHDATE; HB_PUT_LE_UINT32( pBuffer + 1, lNumber ); - hb_compGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM ); + hb_macroGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM ); } /* sends a message to an object */ -void hb_compGenMessage( char * szMsgName, BOOL bIsObject, HB_COMP_DECL ) +void hb_macroGenMessage( char * szMsgName, BOOL bIsObject, HB_COMP_DECL ) { BYTE byBuf[ sizeof( HB_DYNS_PTR ) + 1 ]; @@ -1174,50 +1172,50 @@ void hb_compGenMessage( char * szMsgName, BOOL bIsObject, HB_COMP_DECL ) byBuf[ 0 ] = HB_P_MMESSAGE; HB_PUT_PTR( &byBuf[ 1 ], pSym ); - hb_compGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM ); + hb_macroGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM ); HB_SYMBOL_UNUSED( bIsObject ); /* used in full compiler only */ } /* generates an underscore-symbol name for a data assignment */ -void hb_compGenMessageData( char * szMsg, BOOL bIsObject, HB_COMP_DECL ) +void hb_macroGenMessageData( char * szMsg, BOOL bIsObject, HB_COMP_DECL ) { char * szResult; - HB_TRACE(HB_TR_DEBUG, ("hb_compGenMessageData(%s)", szMsg)); + HB_TRACE(HB_TR_DEBUG, ("hb_macroGenMessageData(%s)", szMsg)); szResult = hb_xstrcpy( NULL, "_", szMsg, NULL ); - hb_compGenMessage( szResult, bIsObject, HB_COMP_PARAM ); + hb_macroGenMessage( szResult, bIsObject, HB_COMP_PARAM ); hb_xfree( szResult ); } /* generates the pcode to pop a value from the virtual machine stack onto a variable */ -void hb_compGenPopVar( char * szVarName, HB_COMP_DECL ) +void hb_macroGenPopVar( char * szVarName, HB_COMP_DECL ) { int iVar; - iVar = hb_compLocalVarGetPos( szVarName, HB_COMP_PARAM ); + iVar = hb_macroLocalVarGetPos( szVarName, HB_COMP_PARAM ); if( iVar ) { /* this is a codeblock parameter */ - hb_compGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM ); } else { /* TODO: memvars created inside TYPE() function should have PUBLIC scope */ - hb_compMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM ); } } /* generates the pcode to pop a value from the virtual machine stack onto * an aliased variable */ -void hb_compGenPopAliasedVar( char * szVarName, +void hb_macroGenPopAliasedVar( char * szVarName, BOOL bPushAliasValue, char * szAlias, long lWorkarea, HB_COMP_DECL ) { - HB_TRACE(HB_TR_DEBUG, ("hb_compGenPopAliasedVar(%s->%s)",szAlias,szVarName)); + HB_TRACE(HB_TR_DEBUG, ("hb_macroGenPopAliasedVar(%s->%s)",szAlias,szVarName)); if( bPushAliasValue ) { @@ -1229,22 +1227,22 @@ void hb_compGenPopAliasedVar( char * szVarName, ( iLen >= 4 && iLen <= 6 && strncmp( szAlias, "MEMVAR", iLen ) == 0 ) ) ) { /* M-> or MEMV-> or MEMVA-> or MEMVAR-> variable */ /* TODO: memvars created inside TYPE() function should have PUBLIC scope */ - hb_compMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM ); } else if( iLen >= 4 && iLen <= 5 && strncmp( szAlias, "FIELD", iLen ) == 0 ) { /* FIELD-> */ - hb_compMemvarGenPCode( HB_P_MPOPFIELD, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPOPFIELD, szVarName, HB_COMP_PARAM ); } else { /* database alias */ - hb_compGenPushSymbol( szAlias, FALSE, TRUE, HB_COMP_PARAM ); - hb_compMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_COMP_PARAM ); + hb_macroGenPushSymbol( szAlias, FALSE, TRUE, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_COMP_PARAM ); } } else { - hb_compGenPushLong( lWorkarea, HB_COMP_PARAM ); - hb_compMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_COMP_PARAM ); + hb_macroGenPushLong( lWorkarea, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_COMP_PARAM ); } } else @@ -1254,54 +1252,60 @@ void hb_compGenPopAliasedVar( char * szVarName, * here if passed name is either a field or a memvar */ /* TODO: memvars created inside TYPE() function should have PUBLIC scope */ - hb_compMemvarGenPCode( HB_P_MPOPALIASEDVAR, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPOPALIASEDVAR, szVarName, HB_COMP_PARAM ); } } /* generates the pcode to push a nonaliased variable value to the virtual * machine stack */ -void hb_compGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ) +void hb_macroGenPushVar( char * szVarName, BOOL bMacroVar, HB_COMP_DECL ) { int iVar; HB_SYMBOL_UNUSED( bMacroVar ); - iVar = hb_compLocalVarGetPos( szVarName, HB_COMP_PARAM ); + iVar = hb_macroLocalVarGetPos( szVarName, HB_COMP_PARAM ); if( iVar ) { /* this is a codeblock parameter */ - hb_compGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM ); } else { - hb_compMemvarGenPCode( HB_P_MPUSHVARIABLE, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHVARIABLE, szVarName, HB_COMP_PARAM ); } } /* generates the pcode to push a variable by reference to the virtual machine stack */ -void hb_compGenPushVarRef( char * szVarName, HB_COMP_DECL ) +void hb_macroGenPushVarRef( char * szVarName, HB_COMP_DECL ) { USHORT iVar; - iVar = hb_compLocalVarGetPos( szVarName, HB_COMP_PARAM ); + iVar = hb_macroLocalVarGetPos( szVarName, HB_COMP_PARAM ); if( iVar ) - hb_compGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM ); else { - hb_compMemvarGenPCode( HB_P_MPUSHMEMVARREF, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHMEMVARREF, szVarName, HB_COMP_PARAM ); } } - /* generates the pcode to push an aliased variable value to the virtual - * machine stack - */ -void hb_compGenPushAliasedVar( char * szVarName, +/* generates the pcode to push a variable by reference to the virtual machine stack */ +void hb_macroGenPushMemvarRef( char * szVarName, HB_COMP_DECL ) +{ + hb_macroMemvarGenPCode( HB_P_MPUSHMEMVARREF, szVarName, HB_COMP_PARAM ); +} + +/* generates the pcode to push an aliased variable value to the virtual + * machine stack + */ +void hb_macroGenPushAliasedVar( char * szVarName, BOOL bPushAliasValue, char * szAlias, long lWorkarea, HB_COMP_DECL ) { - HB_TRACE(HB_TR_DEBUG, ("hb_compGenPushAliasedVar(%s->%s)",szAlias,szVarName)); + HB_TRACE(HB_TR_DEBUG, ("hb_macroGenPushAliasedVar(%s->%s)",szAlias,szVarName)); if( bPushAliasValue ) { @@ -1316,22 +1320,22 @@ void hb_compGenPushAliasedVar( char * szVarName, if( szAlias[ 0 ] == 'M' && ( iLen == 1 || ( iLen >= 4 && iLen <= 6 && strncmp( szAlias, "MEMVAR", iLen ) == 0 ) ) ) { /* M-> or MEMV-> or MEMVA-> or MEMVAR-> variable */ - hb_compMemvarGenPCode( HB_P_MPUSHMEMVAR, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHMEMVAR, szVarName, HB_COMP_PARAM ); } else if( iLen >= 4 && iLen <= 5 && strncmp( szAlias, "FIELD", iLen ) == 0 ) { /* FIELD-> */ - hb_compMemvarGenPCode( HB_P_MPUSHFIELD, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHFIELD, szVarName, HB_COMP_PARAM ); } else { /* database alias */ - hb_compGenPushSymbol( szAlias, FALSE, TRUE, HB_COMP_PARAM ); - hb_compMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_COMP_PARAM ); + hb_macroGenPushSymbol( szAlias, FALSE, TRUE, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_COMP_PARAM ); } } else { - hb_compGenPushLong( lWorkarea, HB_COMP_PARAM ); - hb_compMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_COMP_PARAM ); + hb_macroGenPushLong( lWorkarea, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_COMP_PARAM ); } } else @@ -1340,21 +1344,21 @@ void hb_compGenPushAliasedVar( char * szVarName, * NOTE: An alias will be determined at runtime then we cannot decide * here if passed name is either a field or a memvar */ - hb_compMemvarGenPCode( HB_P_MPUSHALIASEDVAR, szVarName, HB_COMP_PARAM ); + hb_macroMemvarGenPCode( HB_P_MPUSHALIASEDVAR, szVarName, HB_COMP_PARAM ); } } /* pushes a logical value on the virtual machine stack , */ -void hb_compGenPushLogical( int iTrueFalse, HB_COMP_DECL ) +void hb_macroGenPushLogical( int iTrueFalse, HB_COMP_DECL ) { if( iTrueFalse ) - hb_compGenPCode1( HB_P_TRUE, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_TRUE, HB_COMP_PARAM ); else - hb_compGenPCode1( HB_P_FALSE, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_FALSE, HB_COMP_PARAM ); } /* generates the pcode to push a double number on the virtual machine stack */ -void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ) +void hb_macroGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ) { BYTE pBuffer[ sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ) + 1 ]; @@ -1363,10 +1367,10 @@ void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL pBuffer[ 1 + sizeof( double ) ] = bWidth; pBuffer[ 1 + sizeof( double ) + sizeof( BYTE ) ] = bDec; - hb_compGenPCodeN( pBuffer, 1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ), HB_COMP_PARAM ); + hb_macroGenPCodeN( pBuffer, 1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ), HB_COMP_PARAM ); } -void hb_compGenPushFunSym( char * szFunName, HB_COMP_DECL ) +void hb_macroGenPushFunSym( char * szFunName, HB_COMP_DECL ) { char * szFunction; @@ -1375,47 +1379,47 @@ void hb_compGenPushFunSym( char * szFunName, HB_COMP_DECL ) { /* Abbreviated function name was used - change it for whole name */ - hb_compGenPushSymbol( szFunction, TRUE, FALSE, HB_COMP_PARAM ); + hb_macroGenPushSymbol( szFunction, TRUE, FALSE, HB_COMP_PARAM ); } else { HB_MACRO_DATA->status |= HB_MACRO_UDF; /* this is used in hb_macroGetType */ - hb_compGenPushSymbol( szFunName, TRUE, FALSE, HB_COMP_PARAM ); + hb_macroGenPushSymbol( szFunName, TRUE, FALSE, HB_COMP_PARAM ); } } -void hb_compGenPushFunCall( char * szFunName, HB_COMP_DECL ) +void hb_macroGenPushFunCall( char * szFunName, HB_COMP_DECL ) { - hb_compGenPushFunSym( szFunName, HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_PUSHNIL, HB_COMP_PARAM ); + hb_macroGenPushFunSym( szFunName, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_PUSHNIL, HB_COMP_PARAM ); } -void hb_compGenPushFunRef( char * szFunName, HB_COMP_DECL ) +void hb_macroGenPushFunRef( char * szFunName, HB_COMP_DECL ) { char * szFunction; /* if abbreviated function name was used - change it for whole name */ szFunction = hb_compReservedName( szFunName ); - hb_compGenPushSymbol( szFunction ? szFunction : szFunName, + hb_macroGenPushSymbol( szFunction ? szFunction : szFunName, TRUE, FALSE, HB_COMP_PARAM ); } /* generates the pcode to push a string on the virtual machine stack */ -void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_COMP_DECL ) +void hb_macroGenPushString( char * szText, ULONG ulStrLen, HB_COMP_DECL ) { if( ulStrLen <= UINT24_MAX ) { if( ulStrLen <= USHRT_MAX ) - hb_compGenPCode3( HB_P_MPUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_MPUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_COMP_PARAM ); else - hb_compGenPCode4( HB_P_MPUSHSTRLARGE, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_ULBYTE( ulStrLen ), HB_COMP_PARAM ); - hb_compGenPCodeN( ( BYTE * ) szText, ulStrLen, HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_MPUSHSTRLARGE, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_ULBYTE( ulStrLen ), HB_COMP_PARAM ); + hb_macroGenPCodeN( ( BYTE * ) szText, ulStrLen, HB_COMP_PARAM ); } else hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM ); } -void hb_compGenPCode1( BYTE byte, HB_COMP_DECL ) +void hb_macroGenPCode1( BYTE byte, HB_COMP_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1425,7 +1429,7 @@ void hb_compGenPCode1( BYTE byte, HB_COMP_DECL ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte; } -void hb_compGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL ) +void hb_macroGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1436,7 +1440,7 @@ void hb_compGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte2; } -void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL ) +void hb_macroGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1448,7 +1452,7 @@ void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL ) pFunc->pCode[ pFunc->lPCodePos++ ] = byte3; } -void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL ) +void hb_macroGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1461,7 +1465,7 @@ void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_D pFunc->pCode[ pFunc->lPCodePos++ ] = byte4; } -void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ) +void hb_macroGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ) { HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA; @@ -1487,7 +1491,7 @@ void hb_macroError( int iError, HB_COMP_DECL ) /* * Start a new pcode buffer for a codeblock */ -void hb_compCodeBlockStart( HB_COMP_DECL ) +void hb_macroCodeBlockStart( HB_COMP_DECL ) { HB_PCODE_INFO_PTR pCB; @@ -1508,7 +1512,7 @@ void hb_compCodeBlockStart( HB_COMP_DECL ) pCB->pLocals = NULL; } -void hb_compCodeBlockEnd( HB_COMP_DECL ) +void hb_macroCodeBlockEnd( HB_COMP_DECL ) { HB_PCODE_INFO_PTR pCodeblock; /* pointer to the current codeblock */ ULONG ulSize; @@ -1547,17 +1551,17 @@ void hb_compCodeBlockEnd( HB_COMP_DECL ) * is stored in dynamic memory pool instead of static memory */ if( ulSize <= USHRT_MAX ) - hb_compGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_COMP_PARAM ); + hb_macroGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_COMP_PARAM ); else { ++ulSize; - hb_compGenPCode4( HB_P_MPUSHBLOCKLARGE, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_ULBYTE( ulSize ), HB_COMP_PARAM ); + hb_macroGenPCode4( HB_P_MPUSHBLOCKLARGE, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_ULBYTE( ulSize ), HB_COMP_PARAM ); } - hb_compGenPCode2( HB_LOBYTE( wParms ), HB_HIBYTE( wParms ), HB_COMP_PARAM ); + hb_macroGenPCode2( HB_LOBYTE( wParms ), HB_HIBYTE( wParms ), HB_COMP_PARAM ); /* copy a codeblock pcode buffer */ - hb_compGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, HB_COMP_PARAM ); - hb_compGenPCode1( HB_P_ENDBLOCK, HB_COMP_PARAM ); /* finish the codeblock */ + hb_macroGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, HB_COMP_PARAM ); + hb_macroGenPCode1( HB_P_ENDBLOCK, HB_COMP_PARAM ); /* finish the codeblock */ /* free memory allocated for a codeblock */ hb_xfree( ( void * ) pCodeblock->pCode );