diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b48d1eff5a..6e3b201549 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,63 @@ +19990817-07:30 GMT+1 Victor Szel + * source/vm/hvm.c + source/rtl/errorapi.c + source/rtl/classes.c + source/rtl/fm.c + source/rtl/itemapi.c + source/rtl/transfrm.c + include/errors.ch + + printf()s changed to a call to hb_errInternal() instead. + * hb_callStackShow() modified so that it uses the same format as + the standard error handler. + + * include/initsymc.h + include/initsymd.h + source/rtl/errorapi.c + + Harbour callable __errRT_BASE() function added. + + * include/errorapi.h + source/rdd/dbcmd.c + source/rtl/errorapi.c + source/rtl/arrays.c + source/rtl/classes.c + source/rtl/copyfile.c + source/rtl/dates.c + source/rtl/do.c + source/rtl/errorapi.c + source/rtl/filesys.c + source/rtl/inkey.c + source/rtl/math.c + source/rtl/memvars.c + source/rtl/set.c + source/rtl/strings.c + source/rtl/transfrm.c + source/tools/dates2.c + source/vm/hvm.c + * hb_error*() -> hb_err*() + - removed obsolete hb_errorNat*() prototypes. + + * include/hberrors.h + include/hbpp.h + source/compiler/harbour.y + source/hbpp/*.c + source/hbpp/stdalone/*.c + + Added the ability to display warnings in standard format. + ! Adjusted and corrected to help display of HBPP.EXE + + * source/rtl/objfunc.prg + doc/subcodes.txt + * Got rid of the QOUT() type runtime-error messages, there's now + a more comprehensive, standard error checking system, which throws + Harbour errors. + ! Some small bugs fixed. (checking argument after usage, additional + parameters passed in one place - typo) + + * include/hboo.ch + source/rtl/objfunc.prg + source/rtl/tclass.prg + source/tools/stringp.prg + * DATA_VAL -> DATA_VALUE + 19990816-21:57 GMT+1 Victor Szel * source/rtl/console.c tests/working/colorind.prg @@ -101,43 +161,43 @@ ClassCreate -> __clsNew ClassInstance -> __clsInst __InstSuper -> __clsInstSuper - ClassAdd -> __clsAddMsg - ClassDel -> __clsDelMsg - ClassMod -> __clsModMsg + ClassAdd -> __clsAddMsg + ClassDel -> __clsDelMsg + ClassMod -> __clsModMsg WClsDatas -> __cls_CntClsData - __wDatas -> __cls_CntData + __wDatas -> __cls_CntData __wDataDec -> __cls_DecData __wDataInc -> __cls_IncData - aOMethod -> __objGetMethodList - aOData -> __objGetMsgList - aOGet -> __objGetValueList - aOSet -> __objSetValueList - oClone -> __objClone + aOMethod -> __objGetMethodList + aOData -> __objGetMsgList + aOGet -> __objGetValueList + aOSet -> __objSetValueList + oClone -> __objClone ClassName -> __objGetClsName - oSend -> __objSendMsg + oSend -> __objSendMsg isMessage -> __objHasMsg - IsData -> __objHasData - IsMethod -> __objHasMethod + IsData -> __objHasData + IsMethod -> __objHasMethod oAddMethod -> __objAddMethod oAddInline -> __objAddInLine - oAddData -> __objAddData + oAddData -> __objAddData oModMethod -> __objModMethod oModInline -> __objModInLine oDelMethod -> __objDelMethod oDelInline -> __objDelInLine - oDelData -> __objDelData + oDelData -> __objDelData - ClassH -> __msgClsH + ClassH -> __msgClsH ClassName -> __msgClsName - ClassSel -> __msgClsSel + ClassSel -> __msgClsSel SelectSuper -> __msgSuper EvalInline -> __msgEvalInline GetClassData -> __msgGetClsData SetClassData -> __msgSetClsData - GetData -> __msgGetData - SetData -> __msgSetData - Virtual -> __msgVirtual + GetData -> __msgGetData + SetData -> __msgSetData + Virtual -> __msgVirtual DictRealloc -> hb_clsDictRealloc ReleaseClass -> hb_clsRelease @@ -191,33 +251,33 @@ 19990815-18:45 GMT+2 Ryszard Glab *source/rtl/hvm.c - * added 'hb_vm' prefix to alias/field related functions - * some functions declared 'static' + * added 'hb_vm' prefix to alias/field related functions + * some functions declared 'static' *include/ctoharb.h - - removed declarations of internal virtual machine functions + - removed declarations of internal virtual machine functions *source/compiler/harbour.y - * changed an error description for incorrect use of PARAMETERS - statement - * added type casting to compile under C++ compilers - * static frame is correctly generated if static variable - is used in a codeblock only + * changed an error description for incorrect use of PARAMETERS + statement + * added type casting to compile under C++ compilers + * static frame is correctly generated if static variable + is used in a codeblock only *include/extend.h - - removed obsolete declaration of hb_memvarNewSymbol() + - removed obsolete declaration of hb_memvarNewSymbol() *include/hb_vmpub.h - + added definition of callback function HB_DYNS_FUNC used - to enumerate dynamic symbols + + added definition of callback function HB_DYNS_FUNC used + to enumerate dynamic symbols *source/vm/dynsym.c - + new function hb_dynsymEval() that enumerates dynamic symbols - by calling specified HB_DYNS_FUNC * function + + new function hb_dynsymEval() that enumerates dynamic symbols + by calling specified HB_DYNS_FUNC * function *source/rtl/memvars.c - + added __MVCLEAR function to release all PRIVATE and PUBLIC - variables (this function is used in CLEAR MEMORY statement) + + added __MVCLEAR function to release all PRIVATE and PUBLIC + variables (this function is used in CLEAR MEMORY statement) 19990815-19:59 GMT+3 Alexander Kresin * source/rtl/tbrowse.prg diff --git a/harbour/doc/subcodes.txt b/harbour/doc/subcodes.txt index fa509cbdf3..51de39209d 100644 --- a/harbour/doc/subcodes.txt +++ b/harbour/doc/subcodes.txt @@ -1296,6 +1296,62 @@ start from 3000 * $END$ */ +/* $DOC$ + * $SUBCODE$ + * BASE/3101 + * $CATEGORY$ + * arguments + * $ONELINER$ + * Invalid argument passed to an object/class function + * $DESCRIPTION$ + * One passed argument is not of the required type. + * $FUNCTION$ + * __OBJ*() + * $STATUS$ + * Harbour specific + * $SEEALSO$ + * + * $END$ + */ + +/* $DOC$ + * $SUBCODE$ + * BASE/3102 + * $CATEGORY$ + * arguments + * $ONELINER$ + * A symbol should be modified or deleted from a class, but the symbol + * doesn't exist. + * $DESCRIPTION$ + * A symbol should be modified or deleted from a class, but the symbol + * doesn't exist. + * $FUNCTION$ + * __OBJ*() + * $STATUS$ + * Harbour specific + * $SEEALSO$ + * + * $END$ + */ + +/* $DOC$ + * $SUBCODE$ + * BASE/3103 + * $CATEGORY$ + * arguments + * $ONELINER$ + * A symbol should be added to a class, but the symbol already exists. + * $DESCRIPTION$ + * A symbol should be added to a class, but the symbol already exists. + * $FUNCTION$ + * __OBJ*() + * $STATUS$ + * Harbour specific + * $SEEALSO$ + * + * $END$ + */ + /* ************************************************************************** */ /* $DOC$ diff --git a/harbour/include/error.ch b/harbour/include/error.ch index 14ea2d4940..8c15c78007 100644 --- a/harbour/include/error.ch +++ b/harbour/include/error.ch @@ -60,4 +60,8 @@ #define EG_NOTARRAY 49 /* Harbour special */ #define EG_CONDITION 50 /* Harbour special */ +/* Internal errors */ +#define EI_NOERRORBLOCK 1 +#define EI_RECOVERY 2 + #endif /* _ERROR_CH */ diff --git a/harbour/include/errorapi.h b/harbour/include/errorapi.h index 9ea54109bd..3cb9c0f4f6 100644 --- a/harbour/include/errorapi.h +++ b/harbour/include/errorapi.h @@ -97,15 +97,12 @@ extern void hb_errRelease ( PHB_ITEM pError ); /* Error launchers */ -extern void hb_errorInternal ( ULONG ulIntCode, char * szText, char * szModul, WORD wLine, char * szPar1, char * szPar2, char * szPar3 ); +extern void hb_errInternal ( ULONG ulIntCode, char * szText, char * szPar1, char * szPar2 ); -extern void hb_errorRT_BASE ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); -extern WORD hb_errorRT_BASE_Ext1 ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags ); -extern void hb_errorRT_TERMINAL ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); -extern void hb_errorRT_DBCMD ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); -extern void hb_errorRT_TOOLS ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); - -extern char * hb_errorNatDescription ( ULONG ulGenCode ); /* Reads error description in national language */ -extern char * hb_errorNatInternal ( ULONG ulIntCode ); /* Reads internal error description in national language */ +extern void hb_errRT_BASE ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); +extern WORD hb_errRT_BASE_Ext1 ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags ); +extern void hb_errRT_TERMINAL ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); +extern void hb_errRT_DBCMD ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); +extern void hb_errRT_TOOLS ( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ); #endif /* HB_ERRORAPI_H_ */ diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 74108ab8cf..ace7473eb0 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -33,8 +33,8 @@ their web site at http://www.gnu.org/). */ -#ifndef HB_ERROR_H_ -#define HB_ERROR_H_ +#ifndef HB_ERRORS_H_ +#define HB_ERRORS_H_ /* * Errors generated by Harbour compiler @@ -91,7 +91,9 @@ #define ERR_WRONG_DIRECTIVE 9 #define ERR_EXPLICIT 10 -extern void GenError( char* _szErrors[], char, int, char*, char * ); /* generic parsing error management function */ -extern void GenWarning( int, char*, char * ); /* generic parsing warning management function */ +#define WARN_NONDIRECTIVE 1 -#endif /* HB_ERROR_H_ */ +extern void GenError( char* _szErrors[], char, int, char*, char * ); /* generic parsing error management function */ +extern void GenWarning( char* _szWarnings[], char, int, char*, char * ); /* generic parsing warning management function */ + +#endif /* HB_ERRORS_H_ */ diff --git a/harbour/include/hboo.ch b/harbour/include/hboo.ch index 9de7ceca2d..806049dd9a 100644 --- a/harbour/include/hboo.ch +++ b/harbour/include/hboo.ch @@ -15,6 +15,6 @@ #define MET_SUPER 5 #define DATA_SYMBOL 1 -#define DATA_VAL 2 +#define DATA_VALUE 2 #endif /* _HBOO_CH */ diff --git a/harbour/include/hbpp.h b/harbour/include/hbpp.h index eba76e0678..84107728d9 100644 --- a/harbour/include/hbpp.h +++ b/harbour/include/hbpp.h @@ -70,6 +70,9 @@ extern int lInclude; extern int *aCondCompile, nCondCompile; extern int nline; +extern char * _szPErrors[]; +extern char * _szPWarnings[]; + /* Needed support modules, but not contained in HBPP.C */ extern FILENAME *SplitFilename( char * ); /* splits filename into a path, a name and an extension */ diff --git a/harbour/include/initsymc.h b/harbour/include/initsymc.h index f80b036f6d..086164cc92 100644 --- a/harbour/include/initsymc.h +++ b/harbour/include/initsymc.h @@ -16,6 +16,7 @@ Descend__InitSymbols(); Dir__InitSymbols(); Environ__InitSymbols(); + Errorapi__InitSymbols(); Files__InitSymbols(); HardCR__InitSymbols(); Math__InitSymbols(); diff --git a/harbour/include/initsymd.h b/harbour/include/initsymd.h index c417ac0238..9f60760798 100644 --- a/harbour/include/initsymd.h +++ b/harbour/include/initsymd.h @@ -16,6 +16,7 @@ extern void Dates2__InitSymbols( void ); extern void Descend__InitSymbols( void ); extern void Dir__InitSymbols( void ); extern void Environ__InitSymbols( void ); +extern void Errorapi__InitSymbols( void ); extern void Files__InitSymbols( void ); extern void HardCR__InitSymbols( void ); extern void Math__InitSymbols( void ); diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 7cbc27f6f4..4a4f3f4757 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -40,7 +40,7 @@ #include #include #include -#include /* required for allocating and freeing memory */ +#include /* required for allocating and freeing memory */ #include #include "hbsetup.h" /* main configuration file */ #include "extend.h" @@ -60,36 +60,36 @@ #define OPT_DELIMITER "/-" #define IS_OPT_SEP( c ) (strchr(OPT_DELIMITER, (c))!=NULL) -extern FILE *yyin; /* currently yacc parsed file */ -extern int iLine; /* currently parsed file line number */ +extern FILE *yyin; /* currently yacc parsed file */ +extern int iLine; /* currently parsed file line number */ /* Following two lines added for preprocessor */ -extern int lPpo; /* flag indicating, is ppo output needed */ -extern FILE *yyppo; /* output .ppo file */ +extern int lPpo; /* flag indicating, is ppo output needed */ +extern FILE *yyppo; /* output .ppo file */ -typedef struct /* #include support */ +typedef struct /* #include support */ { - FILE * handle; /* handle of the opened file */ - void * pBuffer; /* buffer used by yacc */ - char * szFileName; /* name of the file */ - void * pPrev; /* pointer to the previous opened file */ - void * pNext; /* pointer to the next opened file */ - int iLine; /* currently processed line number */ -} _FILE, * PFILE; /* structure to hold an opened PRG or CH */ + FILE * handle; /* handle of the opened file */ + void * pBuffer; /* buffer used by yacc */ + char * szFileName; /* name of the file */ + void * pPrev; /* pointer to the previous opened file */ + void * pNext; /* pointer to the next opened file */ + int iLine; /* currently processed line number */ +} _FILE, * PFILE; /* structure to hold an opened PRG or CH */ typedef struct { - PFILE pLast; /* pointer to the last opened file */ - int iFiles; /* number of files currently opened */ -} FILES; /* structure to control several opened PRGs and CHs */ + PFILE pLast; /* pointer to the last opened file */ + int iFiles; /* number of files currently opened */ +} FILES; /* structure to control several opened PRGs and CHs */ int Include( char * szFileName, PATHNAMES *pSearchPath ); /* end #include support */ /* * flags for bFlags member */ -#define FUN_STATEMENTS 1 /* Function have at least one executable statement */ +#define FUN_STATEMENTS 1 /* Function have at least one executable statement */ #define FUN_USES_STATICS 2 /* Function uses static variables */ -#define FUN_PROCEDURE 4 /* This is a procedure that shouldn't return value */ +#define FUN_PROCEDURE 4 /* This is a procedure that shouldn't return value */ #define FUN_ILLEGAL_INIT 8 /* Attempt to initialize static variable with a function call */ #define FUN_USES_LOCAL_PARAMS 16 /* parameters are declared using () */ @@ -100,7 +100,7 @@ typedef struct __ELSEIF { WORD wOffset; struct __ELSEIF * pNext; -} _ELSEIF, * PELSEIF; /* support structure for else if pcode fixups */ +} _ELSEIF, * PELSEIF; /* support structure for else if pcode fixups */ typedef struct _LOOPEXIT { @@ -120,7 +120,7 @@ typedef struct __EXTERN { char * szName; struct __EXTERN * pNext; -} _EXTERN, * PEXTERN; /* support structure for extern symbols */ +} _EXTERN, * PEXTERN; /* support structure for extern symbols */ /* as they have to be placed on the symbol table later than the first public symbol */ FILENAME *SplitFilename( char * ); /* splits filename into a path, a name and an extension */ @@ -138,9 +138,9 @@ typedef struct _ALIASID struct _ALIASID *pPrev; } ALIASID, *ALIASID_PTR; -#define ALIAS_NUMBER 1 -#define ALIAS_NAME 2 -#define ALIAS_EVAL 3 +#define ALIAS_NUMBER 1 +#define ALIAS_NAME 2 +#define ALIAS_EVAL 3 void AliasAddInt( int ); void AliasAddExp( void ); @@ -153,12 +153,12 @@ void AliasRemove( void ); /* lex & yacc related prototypes */ void yyerror( char * ); /* parsing error management function */ -int yylex( void ); /* main lex token function, called by yyparse() */ -int yyparse( void ); /* main yacc parsing function */ +int yylex( void ); /* main lex token function, called by yyparse() */ +int yyparse( void ); /* main yacc parsing function */ #ifdef __cplusplus extern "C" int yywrap( void ); #else -int yywrap( void ); /* manages the EOF of current processed file */ +int yywrap( void ); /* manages the EOF of current processed file */ #endif /* Following line added for preprocessor */ void Hbpp_init ( void ); @@ -188,7 +188,7 @@ void AddSearchPath( char *, PATHNAMES * * ); /* add pathname to a search list */ void AddVar( char * szVarName ); /* add a new param, local, static variable to a function definition or a public or private */ PCOMSYMBOL AddSymbol( char *, WORD * ); void CheckDuplVars( PVAR pVars, char * szVarName, int iVarScope ); /*checks for duplicate variables definitions */ -void Dec( void ); /* generates the pcode to decrement the latest value on the virtual machine stack */ +void Dec( void ); /* generates the pcode to decrement the latest value on the virtual machine stack */ void DimArray( WORD wDimensions ); /* instructs the virtual machine to build an array with wDimensions */ void Do( BYTE bParams ); /* generates the pcode to execute a Clipper function discarding its result */ void Duplicate( void ); /* duplicates the virtual machine latest stack latest value and places it on the stack */ @@ -198,7 +198,7 @@ void FixElseIfs( void * pIfElseIfs ); /* implements the ElseIfs pcode fixups */ void FixReturns( void ); /* fixes all last defined function returns jumps offsets */ WORD FixSymbolPos( WORD ); /* converts symbol's compile-time position into generation-time position */ void Function( BYTE bParams ); /* generates the pcode to execute a Clipper function pushing its result */ -PFUNCTION FunctionNew( char *, char ); /* creates and initialises the _FUNC structure */ +PFUNCTION FunctionNew( char *, char ); /* creates and initialises the _FUNC structure */ void FunDef( char * szFunName, SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */ void GenArray( WORD wElements ); /* instructs the virtual machine to build an array and load elemnst from the stack */ void * GenElseIf( void * pFirstElseIf, WORD wOffset ); /* generates a support structure for elseifs pcode fixups */ @@ -210,32 +210,32 @@ WORD GetVarPos( PVAR pVars, char * szVarName ); /* returns the order + 1 of a va int GetLocalVarPos( char * szVarName ); /* returns the order + 1 of a local variable */ PCOMSYMBOL GetSymbol( char *, WORD * ); /* returns a symbol pointer from the symbol table */ PCOMSYMBOL GetSymbolOrd( WORD ); /* returns a symbol based on its index on the symbol table */ -void Inc( void ); /* generates the pcode to increment the latest value on the virtual machine stack */ -WORD Jump( int iOffset ); /* generates the pcode to jump to a specific offset */ -WORD JumpFalse( int iOffset ); /* generates the pcode to jump if false */ -void JumpHere( int iOffset ); /* returns the pcode pos where to set a jump offset */ +void Inc( void ); /* generates the pcode to increment the latest value on the virtual machine stack */ +WORD Jump( int iOffset ); /* generates the pcode to jump to a specific offset */ +WORD JumpFalse( int iOffset ); /* generates the pcode to jump if false */ +void JumpHere( int iOffset ); /* returns the pcode pos where to set a jump offset */ void JumpThere( int iOffset, WORD wTo ); /* sets a jump offset */ -WORD JumpTrue( int iOffset ); /* generates the pcode to jump if true */ -PFUNCTION KillFunction( PFUNCTION ); /* releases all memory allocated by function and returns the next one */ -PCOMSYMBOL KillSymbol( PCOMSYMBOL ); /* releases all memory allocated by symbol and returns the next one */ -void Line( void ); /* generates the pcode with the currently compiled source code line */ -void LineBody( void ); /* generates the pcode with the currently compiled source code line */ -void VariablePCode( BYTE , char * ); /* generates the pcode for memvar variable */ -void Message( char * szMsgName ); /* sends a message to an object */ -void MessageFix( char * szMsgName ); /* fix a generated message to an object */ -void MessageDupl( char * szMsgName ); /* fix a one generated message to an object and duplicate */ -void PopId( char * szVarName ); /* generates the pcode to pop a value from the virtual machine stack onto a variable */ +WORD JumpTrue( int iOffset ); /* generates the pcode to jump if true */ +PFUNCTION KillFunction( PFUNCTION ); /* releases all memory allocated by function and returns the next one */ +PCOMSYMBOL KillSymbol( PCOMSYMBOL ); /* releases all memory allocated by symbol and returns the next one */ +void Line( void ); /* generates the pcode with the currently compiled source code line */ +void LineBody( void ); /* generates the pcode with the currently compiled source code line */ +void VariablePCode( BYTE , char * ); /* generates the pcode for memvar variable */ +void Message( char * szMsgName ); /* sends a message to an object */ +void MessageFix( char * szMsgName ); /* fix a generated message to an object */ +void MessageDupl( char * szMsgName ); /* fix a one generated message to an object and duplicate */ +void PopId( char * szVarName ); /* generates the pcode to pop a value from the virtual machine stack onto a variable */ void PushDouble( double fNumber, BYTE bDec ); /* Pushes a number on the virtual machine stack */ -void PushFunCall( char * ); /* generates the pcode to push function's call */ -void PushId( char * szVarName ); /* generates the pcode to push a variable value to the virtual machine stack */ -void PushIdByRef( char * szVarName ); /* generates the pcode to push a variable by reference to the virtual machine stack */ -void PushInteger( int iNumber ); /* Pushes a integer number on the virtual machine stack */ -void PushLogical( int iTrueFalse ); /* pushes a logical value on the virtual machine stack */ -void PushLong( long lNumber ); /* Pushes a long number on the virtual machine stack */ -void PushNil( void ); /* Pushes nil on the virtual machine stack */ -void PushString( char * szText ); /* Pushes a string on the virtual machine stack */ +void PushFunCall( char * ); /* generates the pcode to push function's call */ +void PushId( char * szVarName ); /* generates the pcode to push a variable value to the virtual machine stack */ +void PushIdByRef( char * szVarName ); /* generates the pcode to push a variable by reference to the virtual machine stack */ +void PushInteger( int iNumber ); /* Pushes a integer number on the virtual machine stack */ +void PushLogical( int iTrueFalse ); /* pushes a logical value on the virtual machine stack */ +void PushLong( long lNumber ); /* Pushes a long number on the virtual machine stack */ +void PushNil( void ); /* Pushes nil on the virtual machine stack */ +void PushString( char * szText ); /* Pushes a string on the virtual machine stack */ void PushSymbol( char * szSymbolName, int iIsFunction ); /* Pushes a symbol on to the Virtual machine stack */ -void GenPCode1( BYTE ); /* generates 1 byte of pcode */ +void GenPCode1( BYTE ); /* generates 1 byte of pcode */ void GenPCode3( BYTE, BYTE, BYTE ); /* generates 3 bytes of pcode */ void GenPCodeN( BYTE * pBuffer, WORD wSize ); /* copy bytes to a pcode buffer */ char * SetData( char * szMsg ); /* generates an underscore-symbol name for a data assignment */ @@ -245,8 +245,8 @@ void FieldsSetAlias( char *, int ); int FieldsCount( void ); /* Codeblocks */ -void CodeBlockStart( void ); /* starts a codeblock creation */ -void CodeBlockEnd( void ); /* end of codeblock creation */ +void CodeBlockStart( void ); /* starts a codeblock creation */ +void CodeBlockEnd( void ); /* end of codeblock creation */ /* Static variables */ void StaticDefStart( void ); @@ -257,7 +257,7 @@ void StaticAssign( void ); /* checks if static variable is initialized with func void GenCCode( char *, char * ); /* generates the C language output */ void GenJava( char *, char * ); /* generates the Java language output */ void GenPascal( char *, char * ); /* generates the Pascal language output */ -void GenRC( char *, char * ); /* generates the RC language output */ +void GenRC( char *, char * ); /* generates the RC language output */ void GenPortObj( char *, char * ); /* generates the portable objects */ #ifdef HARBOUR_OBJ_GENERATION void GenObj32( char *, char * ); /* generates OBJ 32 bits */ @@ -272,12 +272,12 @@ void PrintUsage( char * ); typedef enum { - LANG_C, /* C language (by default) */ - LANG_JAVA, /* Java */ - LANG_PASCAL, /* Pascal */ - LANG_RESOURCES, /* Resources */ - LANG_PORT_OBJ /* Portable objects */ -} LANGUAGES; /* supported Harbour output languages */ + LANG_C, /* C language (by default) */ + LANG_JAVA, /* Java */ + LANG_PASCAL, /* Pascal */ + LANG_RESOURCES, /* Resources */ + LANG_PORT_OBJ /* Portable objects */ +} LANGUAGES; /* supported Harbour output languages */ #define VS_LOCAL 1 #define VS_STATIC 2 @@ -287,37 +287,37 @@ typedef enum #define VS_PUBLIC 128 #define VS_MEMVAR (VS_PUBLIC | VS_PRIVATE) int iVarScope = VS_LOCAL; /* holds the scope for next variables to be defined */ - /* different values for iVarScope */ + /* different values for iVarScope */ /* Table with parse errors */ char * _szCErrors[] = { "Statement not allowed outside of procedure or function", - "Redefinition of procedure or function: \'%s\'", - "Duplicate variable declaration: \'%s\'", - "%s declaration follows executable statement", - "Outer codeblock variable is out of reach: \'%s\'", - "Invalid numeric format '.'", - "Unterminated string: \'%s\'", - "Redefinition of predefined function %s: \'%s\'", - "Illegal initializer: \'%s\'", - "ENDIF does not match IF", - "ENDDO does not match WHILE", - "ENDCASE does not match DO CASE", - "NEXT does not match FOR", - "ELSE does not match IF", - "ELSEIF does not match IF", - "Syntax error: \'%s\'", - "Unclosed control structures at line: %i", - "%s statement with no loop in sight", - "Syntax error: \'%s\' in: \'%s\'", - "Incomplete statement: %s", - "Incorrect number of arguments: %s %s", - "Invalid lvalue", - "Invalid use of \'@\' (pass by reference): \'%s\'", - "Formal parameters already declared" - }; + "Redefinition of procedure or function: \'%s\'", + "Duplicate variable declaration: \'%s\'", + "%s declaration follows executable statement", + "Outer codeblock variable is out of reach: \'%s\'", + "Invalid numeric format '.'", + "Unterminated string: \'%s\'", + "Redefinition of predefined function %s: \'%s\'", + "Illegal initializer: \'%s\'", + "ENDIF does not match IF", + "ENDDO does not match WHILE", + "ENDCASE does not match DO CASE", + "NEXT does not match FOR", + "ELSE does not match IF", + "ELSEIF does not match IF", + "Syntax error: \'%s\'", + "Unclosed control structures at line: %i", + "%s statement with no loop in sight", + "Syntax error: \'%s\' in: \'%s\'", + "Incomplete statement: %s", + "Incorrect number of arguments: %s %s", + "Invalid lvalue", + "Invalid use of \'@\' (pass by reference): \'%s\'", + "Formal parameters already declared" + }; /* Table with parse warnings */ -char * _szWarnings[] = { +char * _szCWarnings[] = { "Ambiguous reference: \'%s\'", "Ambiguous reference, assuming memvar: \'%s\'", "Variable: \'%s\' declared but not used in function: \'%s\'", @@ -419,7 +419,7 @@ int EXTERNAL_LINKAGE sz_compare4( const void *pLookup, const void *pReserved ) iCmp = strncmp( (const char *)pLookup, *((const char * *)pReserved), 4 ); if( iCmp == 0 ) iCmp = strncmp( (const char *)pLookup, *((const char * *)pReserved), - strlen((const char *)pLookup) ); + strlen((const char *)pLookup) ); return iCmp; } @@ -432,17 +432,17 @@ FUNCTIONS functions, funcalls; PFUNCTION _pInitFunc; SYMBOLS symbols; -BOOL _bStartProc = TRUE; /* holds if we need to create the starting procedure */ -BOOL _bLineNumbers = TRUE; /* holds if we need pcodes with line numbers */ -BOOL _bQuiet = FALSE; /* quiet mode */ +BOOL _bStartProc = TRUE; /* holds if we need to create the starting procedure */ +BOOL _bLineNumbers = TRUE; /* holds if we need pcodes with line numbers */ +BOOL _bQuiet = FALSE; /* quiet mode */ BOOL _bSyntaxCheckOnly = FALSE; /* syntax check only */ -int _iLanguage = LANG_C; /* default Harbour generated output language */ +int _iLanguage = LANG_C; /* default Harbour generated output language */ BOOL _bRestrictSymbolLength = FALSE; /* generate 10 chars max symbols length */ -BOOL _bShortCuts = TRUE; /* .and. & .or. expressions shortcuts */ -BOOL _bWarnings = FALSE; /* enable parse warnings */ +BOOL _bShortCuts = TRUE; /* .and. & .or. expressions shortcuts */ +BOOL _bWarnings = FALSE; /* enable parse warnings */ BOOL _bAutoMemvarAssume = FALSE; /* holds if undeclared variables are automatically assumed MEMVAR */ -BOOL _bForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable */ -BOOL _bDebugInfo = FALSE; /* holds if generate debugger required info */ +BOOL _bForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable */ +BOOL _bDebugInfo = FALSE; /* holds if generate debugger required info */ /* This variable is used to flag if variables have to be passed by reference * - it is required in DO WITH statement @@ -455,7 +455,7 @@ BOOL _bForceByRefer = FALSE; /* This variable is true if the right value of assignment will be build. * It is used to temporarily cancel the above _bForceByRefer */ -BOOL _bRValue = FALSE; +BOOL _bRValue = FALSE; WORD _wSeqCounter = 0; WORD _wForCounter = 0; @@ -464,9 +464,9 @@ WORD _wWhileCounter = 0; WORD _wCaseCounter = 0; LONG _lMessageFix = 0; /* Position of the message which needs to be changed */ #ifdef HARBOUR_OBJ_GENERATION -BOOL _bObj32 = FALSE; /* generate OBJ 32 bits */ +BOOL _bObj32 = FALSE; /* generate OBJ 32 bits */ #endif -WORD _wStatics = 0; /* number of defined statics variables on the PRG */ +WORD _wStatics = 0; /* number of defined statics variables on the PRG */ PEXTERN pExterns = 0; PTR_LOOPEXIT pLoops = 0; PATHNAMES *_pIncludePath = NULL; @@ -477,21 +477,21 @@ PSTACK_VAL_TYPE pStackValType = 0; /* compile time stack values linked list */ char cVarType = ' '; /* current declared variable type */ #define LOOKUP 0 -extern int _iState; /* current parser state (defined in harbour.l */ +extern int _iState; /* current parser state (defined in harbour.l */ %} -%union /* special structure used by lex and yacc to share info */ +%union /* special structure used by lex and yacc to share info */ { - char * string; /* to hold a string returned by lex */ - int iNumber; /* to hold a number returned by lex */ - long lNumber; /* to hold a long number returned by lex */ + char * string; /* to hold a string returned by lex */ + int iNumber; /* to hold a number returned by lex */ + long lNumber; /* to hold a long number returned by lex */ struct { - double dNumber; /* to hold a double number returned by lex */ + double dNumber; /* to hold a double number returned by lex */ /* NOTE: Intentionally using "unsigned char" instead of "BYTE" */ unsigned char bDec; /* to hold the number of decimal points in the value */ } dNum; - void * pVoid; /* to hold any memory structure we may need */ + void * pVoid; /* to hold any memory structure we may need */ }; %token FUNCTION PROCEDURE IDENTIFIER RETURN NIL DOUBLE INASSIGN INTEGER INTLONG @@ -529,645 +529,645 @@ extern int _iState; /* current parser state (defined in harbour.l */ %right '\n' ';' ',' '=' /*the highest precedence*/ -%type IDENTIFIER LITERAL FunStart MethStart IdSend ObjectData AliasVar -%type DOUBLE +%type IDENTIFIER LITERAL FunStart MethStart IdSend ObjectData AliasVar +%type DOUBLE %type ArgList ElemList PareExpList ExpList FunCall FunScope IncDec %type Params ParamList Logical %type INTEGER BlockExpList Argument IfBegin VarId VarList MethParams ObjFunCall %type MethCall BlockList FieldList DoArgList VarAt %type INTLONG WhileBegin BlockBegin -%type IfElseIf Cases +%type IfElseIf Cases %% -Main : { Line(); } Source { - FixReturns(); /* fix all previous function returns offsets */ - if( ! _bQuiet ) printf( "\nsyntax ok\n" ); - } +Main : { Line(); } Source { + FixReturns(); /* fix all previous function returns offsets */ + if( ! _bQuiet ) printf( "\nsyntax ok\n" ); + } -Source : Crlf - | VarDefs - | FieldsDef - | MemvarDef - | Function - | Statement - | Line - | Source Crlf - | Source Function - | Source { LineBody(); } Statement - | Source VarDefs - | Source FieldsDef - | Source MemvarDef - | Source Line - ; +Source : Crlf + | VarDefs + | FieldsDef + | MemvarDef + | Function + | Statement + | Line + | Source Crlf + | Source Function + | Source { LineBody(); } Statement + | Source VarDefs + | Source FieldsDef + | Source MemvarDef + | Source Line + ; -Line : LINE INTEGER LITERAL Crlf - | LINE INTEGER LITERAL '@' LITERAL Crlf /* XBase++ style */ - ; +Line : LINE INTEGER LITERAL Crlf + | LINE INTEGER LITERAL '@' LITERAL Crlf /* XBase++ style */ + ; -Function : FunScope FUNCTION IDENTIFIER { cVarType = ' '; FunDef( $3, $1, 0 ); } Params Crlf {} - | FunScope PROCEDURE IDENTIFIER { cVarType = ' '; FunDef( $3, $1, FUN_PROCEDURE ); } Params Crlf {} - | FunScope DECLARE_FUN IDENTIFIER Params Crlf { cVarType = ' '; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_NUMERIC Crlf { cVarType = 'N'; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_CHARACTER Crlf { cVarType = 'C'; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_DATE Crlf { cVarType = 'D'; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_LOGICAL Crlf { cVarType = 'L'; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_ARRAY Crlf { cVarType = 'A'; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_OBJECT Crlf { cVarType = 'O'; AddSymbol( $3, NULL ); } - | FunScope DECLARE_FUN IDENTIFIER Params AS_BLOCK Crlf { cVarType = 'B'; AddSymbol( $3, NULL ); } - ; +Function : FunScope FUNCTION IDENTIFIER { cVarType = ' '; FunDef( $3, $1, 0 ); } Params Crlf {} + | FunScope PROCEDURE IDENTIFIER { cVarType = ' '; FunDef( $3, $1, FUN_PROCEDURE ); } Params Crlf {} + | FunScope DECLARE_FUN IDENTIFIER Params Crlf { cVarType = ' '; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_NUMERIC Crlf { cVarType = 'N'; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_CHARACTER Crlf { cVarType = 'C'; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_DATE Crlf { cVarType = 'D'; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_LOGICAL Crlf { cVarType = 'L'; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_ARRAY Crlf { cVarType = 'A'; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_OBJECT Crlf { cVarType = 'O'; AddSymbol( $3, NULL ); } + | FunScope DECLARE_FUN IDENTIFIER Params AS_BLOCK Crlf { cVarType = 'B'; AddSymbol( $3, NULL ); } + ; -FunScope : { $$ = FS_PUBLIC; } - | STATIC { $$ = FS_STATIC; } - | INIT { $$ = FS_INIT; } - | EXIT { $$ = FS_EXIT; } - ; +FunScope : { $$ = FS_PUBLIC; } + | STATIC { $$ = FS_STATIC; } + | INIT { $$ = FS_INIT; } + | EXIT { $$ = FS_EXIT; } + ; -Params : { $$ = 0; } - | '(' ')' { $$ = 0; } - | '(' { iVarScope = VS_PARAMETER; } ParamList ')' { $$ = $3; } - ; +Params : { $$ = 0; } + | '(' ')' { $$ = 0; } + | '(' { iVarScope = VS_PARAMETER; } ParamList ')' { $$ = $3; } + ; -ParamList : IDENTIFIER { cVarType = ' '; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_NUMERIC { cVarType = 'N'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_CHARACTER { cVarType = 'C'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_DATE { cVarType = 'D'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_LOGICAL { cVarType = 'L'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_ARRAY { cVarType = 'A'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_BLOCK { cVarType = 'B'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_OBJECT { cVarType = 'O'; AddVar( $1 ); $$ = 1; } - | ParamList ',' IDENTIFIER { AddVar( $3 ); $$++; } - ; +ParamList : IDENTIFIER { cVarType = ' '; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_NUMERIC { cVarType = 'N'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_CHARACTER { cVarType = 'C'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_DATE { cVarType = 'D'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_LOGICAL { cVarType = 'L'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_ARRAY { cVarType = 'A'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_BLOCK { cVarType = 'B'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_OBJECT { cVarType = 'O'; AddVar( $1 ); $$ = 1; } + | ParamList ',' IDENTIFIER { AddVar( $3 ); $$++; } + ; Statements : Statement - | Statements { Line(); } Statement - ; + | Statements { Line(); } Statement + ; -Statement : ExecFlow Crlf {} - | FunCall Crlf { Do( $1 ); } - | AliasFunc Crlf {} - | IfInline Crlf { GenPCode1( HB_P_POP ); } - | ObjectMethod Crlf { GenPCode1( HB_P_POP ); } - | VarUnary Crlf { GenPCode1( HB_P_POP ); } - | VarAssign Crlf { GenPCode1( HB_P_POP ); _bRValue =FALSE; } +Statement : ExecFlow Crlf {} + | FunCall Crlf { Do( $1 ); } + | AliasFunc Crlf {} + | IfInline Crlf { GenPCode1( HB_P_POP ); } + | ObjectMethod Crlf { GenPCode1( HB_P_POP ); } + | VarUnary Crlf { GenPCode1( HB_P_POP ); } + | VarAssign Crlf { GenPCode1( HB_P_POP ); _bRValue =FALSE; } - | IDENTIFIER '=' Expression Crlf { PopId( $1 ); } - | AliasVar '=' { $$=(void*)pAliasId; pAliasId=NULL; } Expression Crlf { pAliasId=(ALIASID_PTR) $3; PopId( $1 ); AliasRemove(); } - | AliasFunc '=' Expression Crlf { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | VarAt '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } - | FunCallArray '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } - | ObjectData '=' { MessageFix( SetData( $1 ) ); } Expression Crlf { Function( 1 ); GenPCode1( HB_P_POP ); } - | ObjectData ArrayIndex '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } - | ObjectMethod ArrayIndex '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } + | IDENTIFIER '=' Expression Crlf { PopId( $1 ); } + | AliasVar '=' { $$=(void*)pAliasId; pAliasId=NULL; } Expression Crlf { pAliasId=(ALIASID_PTR) $3; PopId( $1 ); AliasRemove(); } + | AliasFunc '=' Expression Crlf { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | VarAt '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } + | FunCallArray '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } + | ObjectData '=' { MessageFix( SetData( $1 ) ); } Expression Crlf { Function( 1 ); GenPCode1( HB_P_POP ); } + | ObjectData ArrayIndex '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } + | ObjectMethod ArrayIndex '=' Expression Crlf { GenPCode1( HB_P_ARRAYPUT ); GenPCode1( HB_P_POP ); } - | BREAK Crlf - | BREAK Expression Crlf - | RETURN Crlf { GenPCode1( HB_P_ENDPROC ); } - | RETURN Expression Crlf { GenPCode1( HB_P_RETVALUE ); GenPCode1( HB_P_ENDPROC ); } - | PUBLIC { iVarScope = VS_PUBLIC; } VarList Crlf - | PRIVATE { iVarScope = VS_PRIVATE; } VarList Crlf + | BREAK Crlf + | BREAK Expression Crlf + | RETURN Crlf { GenPCode1( HB_P_ENDPROC ); } + | RETURN Expression Crlf { GenPCode1( HB_P_RETVALUE ); GenPCode1( HB_P_ENDPROC ); } + | PUBLIC { iVarScope = VS_PUBLIC; } VarList Crlf + | PRIVATE { iVarScope = VS_PRIVATE; } VarList Crlf - | EXITLOOP Crlf { LoopExit(); } - | LOOP Crlf { LoopLoop(); } - | DoProc Crlf - | EXTERN ExtList Crlf - ; + | EXITLOOP Crlf { LoopExit(); } + | LOOP Crlf { LoopLoop(); } + | DoProc Crlf + | EXTERN ExtList Crlf + ; -ExtList : IDENTIFIER { AddExtern( $1 ); } - | ExtList ',' IDENTIFIER { AddExtern( $3 ); } - ; +ExtList : IDENTIFIER { AddExtern( $1 ); } + | ExtList ',' IDENTIFIER { AddExtern( $3 ); } + ; FunCall : FunStart ')' { $$=0; CheckArgs( $1, $$ ); } - | FunStart ArgList ')' { $$=$2; CheckArgs( $1, $$ ); } - ; + | FunStart ArgList ')' { $$=$2; CheckArgs( $1, $$ ); } + ; FunStart : IDENTIFIER '(' { StaticAssign(); PushFunCall( $1 ); $$ = $1; } - ; + ; MethCall : MethStart ')' { $$ = 0; } - | MethStart ArgList ')' { $$ = $2; } - ; + | MethStart ArgList ')' { $$ = $2; } + ; MethStart : IDENTIFIER '(' { StaticAssign(); Message( $1 ); $$ = $1; } - ; + ; ArgList : ',' { PushNil(); PushNil(); $$ = 2; } - | Argument { $$ = 1; } - | ArgList ',' { PushNil(); $$++; } - | ArgList ',' Argument { $$++; } - | ',' { PushNil(); } Argument { $$ = 2; } - ; + | Argument { $$ = 1; } + | ArgList ',' { PushNil(); $$++; } + | ArgList ',' Argument { $$++; } + | ',' { PushNil(); } Argument { $$ = 2; } + ; -Argument : Expression {} - | '@' IDENTIFIER { PushIdByRef( $2 ); } - | '@' IDENTIFIER '(' ')' { PushSymbol( $2, 1 ); GenPCode1( HB_P_FUNCPTR ); } - ; +Argument : Expression {} + | '@' IDENTIFIER { PushIdByRef( $2 ); } + | '@' IDENTIFIER '(' ')' { PushSymbol( $2, 1 ); GenPCode1( HB_P_FUNCPTR ); } + ; -MethParams : /* empty */ { $$ = 0; } - | ArgList { $$ = $1; } - ; +MethParams : /* empty */ { $$ = 0; } + | ArgList { $$ = $1; } + ; -ObjectData : IdSend IDENTIFIER { $$ = $2; _lMessageFix = functions.pLast->lPCodePos; Message( $2 ); Function( 0 ); } - | VarAt ':' IDENTIFIER { GenPCode1( HB_P_ARRAYAT ); $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } - | ObjFunCall IDENTIFIER { $$ = $2; _lMessageFix = functions.pLast->lPCodePos; Message( $2 ); Function( 0 ); } - | ObjFunArray ':' IDENTIFIER { $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } - | ObjectMethod ':' IDENTIFIER { $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } - | ObjectData ':' IDENTIFIER { $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } - | ObjectData ArrayIndex ':' IDENTIFIER { GenPCode1( HB_P_ARRAYAT ); $$ = $4; _lMessageFix = functions.pLast->lPCodePos; Message( $4 ); Function( 0 ); } - ; +ObjectData : IdSend IDENTIFIER { $$ = $2; _lMessageFix = functions.pLast->lPCodePos; Message( $2 ); Function( 0 ); } + | VarAt ':' IDENTIFIER { GenPCode1( HB_P_ARRAYAT ); $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } + | ObjFunCall IDENTIFIER { $$ = $2; _lMessageFix = functions.pLast->lPCodePos; Message( $2 ); Function( 0 ); } + | ObjFunArray ':' IDENTIFIER { $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } + | ObjectMethod ':' IDENTIFIER { $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } + | ObjectData ':' IDENTIFIER { $$ = $3; _lMessageFix = functions.pLast->lPCodePos; Message( $3 ); Function( 0 ); } + | ObjectData ArrayIndex ':' IDENTIFIER { GenPCode1( HB_P_ARRAYAT ); $$ = $4; _lMessageFix = functions.pLast->lPCodePos; Message( $4 ); Function( 0 ); } + ; ObjectMethod : IdSend IDENTIFIER { Message( $2 ); } '(' MethParams ')' { Function( $5 ); } - | VarAt ':' MethCall { Function( $3 ); GenPCode1( HB_P_ARRAYAT ); } - | ObjFunCall MethCall { Function( $2 ); } - | ObjFunArray ':' MethCall { Function( $3 ); } - | ObjectData ':' MethCall { Function( $3 ); } - | ObjectData ArrayIndex ':' MethCall { Function( $4 ); { GenPCode1( HB_P_ARRAYAT ); } } - | ObjectMethod ':' MethCall { Function( $3 ); } - ; + | VarAt ':' MethCall { Function( $3 ); GenPCode1( HB_P_ARRAYAT ); } + | ObjFunCall MethCall { Function( $2 ); } + | ObjFunArray ':' MethCall { Function( $3 ); } + | ObjectData ':' MethCall { Function( $3 ); } + | ObjectData ArrayIndex ':' MethCall { Function( $4 ); { GenPCode1( HB_P_ARRAYAT ); } } + | ObjectMethod ':' MethCall { Function( $3 ); } + ; -IdSend : IDENTIFIER ':' { PushId( $1 ); $$ = $1; } - ; +IdSend : IDENTIFIER ':' { PushId( $1 ); $$ = $1; } + ; ObjFunCall : FunCall ':' { Function( $1 ); $$ = $1; } - ; + ; FunCallArray : FunCall { Function( $1 ); } ArrayIndex - ; + ; ObjFunArray : FunCallArray ':' { GenPCode1( HB_P_ARRAYAT ); } - ; + ; -Expression : NIL { PushNil(); } - | DOUBLE { PushDouble( $1.dNumber,$1.bDec ); } - | INTEGER { PushInteger( $1 ); } - | INTLONG { PushLong( $1 ); } - | LITERAL { PushString( $1 ); } - | Variable - | VarUnary - | Logical { PushLogical( $1 ); } - | Operators {} - | FunCall { Function( $1 ); } - | IfInline {} - | Array {} - | CodeBlock {} - | ObjectMethod {} - | Macro {} - | AliasVar { PushId( $1 ); AliasRemove(); } - | AliasFunc {} - | PareExpList {} - | SELF { GenPCode1( HB_P_PUSHSELF ); } - ; +Expression : NIL { PushNil(); } + | DOUBLE { PushDouble( $1.dNumber,$1.bDec ); } + | INTEGER { PushInteger( $1 ); } + | INTLONG { PushLong( $1 ); } + | LITERAL { PushString( $1 ); } + | Variable + | VarUnary + | Logical { PushLogical( $1 ); } + | Operators {} + | FunCall { Function( $1 ); } + | IfInline {} + | Array {} + | CodeBlock {} + | ObjectMethod {} + | Macro {} + | AliasVar { PushId( $1 ); AliasRemove(); } + | AliasFunc {} + | PareExpList {} + | SELF { GenPCode1( HB_P_PUSHSELF ); } + ; IfInline : IIF '(' Expression ',' { $$ = JumpFalse( 0 ); } - IfInlExp ',' { $$ = Jump( 0 ); JumpHere( $5 ); } - IfInlExp ')' { JumpHere( $8 ); - if( _bWarnings ) - { - PSTACK_VAL_TYPE pFree; + IfInlExp ',' { $$ = Jump( 0 ); JumpHere( $5 ); } + IfInlExp ')' { JumpHere( $8 ); + if( _bWarnings ) + { + PSTACK_VAL_TYPE pFree; - if( pStackValType ) - { - pFree = pStackValType; - debug_msg( "\n***---IIF()\n", NULL ); + if( pStackValType ) + { + pFree = pStackValType; + debug_msg( "\n***---IIF()\n", NULL ); - pStackValType = pStackValType->pPrev; - OurFree( (void *)pFree ); - } - else - debug_msg( "\n***IIF() Compile time stack overflow\n", NULL ); - } - } + pStackValType = pStackValType->pPrev; + OurFree( (void *)pFree ); + } + else + debug_msg( "\n***IIF() Compile time stack overflow\n", NULL ); + } + } - | IF '(' Expression ',' { $$ = JumpFalse( 0 ); } - IfInlExp ',' { $$ = Jump( 0 ); JumpHere( $5 ); } - IfInlExp ')' { JumpHere( $8 ); + | IF '(' Expression ',' { $$ = JumpFalse( 0 ); } + IfInlExp ',' { $$ = Jump( 0 ); JumpHere( $5 ); } + IfInlExp ')' { JumpHere( $8 ); - if( _bWarnings ) - { - PSTACK_VAL_TYPE pFree; + if( _bWarnings ) + { + PSTACK_VAL_TYPE pFree; - if( pStackValType ) - { - pFree = pStackValType; - debug_msg( "\n***---IIF()\n", NULL ); + if( pStackValType ) + { + pFree = pStackValType; + debug_msg( "\n***---IIF()\n", NULL ); - pStackValType = pStackValType->pPrev; - OurFree( (void *)pFree ); - } - else - debug_msg( "\n***IIF() Compile time stack overflow\n", NULL ); - } - } - ; + pStackValType = pStackValType->pPrev; + OurFree( (void *)pFree ); + } + else + debug_msg( "\n***IIF() Compile time stack overflow\n", NULL ); + } + } + ; -IfInlExp : /* nothing => nil */ { PushNil(); } - | Expression - ; +IfInlExp : /* nothing => nil */ { PushNil(); } + | Expression + ; -Macro : '&' Variable - | '&' '(' Expression ')' - ; +Macro : '&' Variable + | '&' '(' Expression ')' + ; AliasVar : INTEGER ALIAS { AliasAddInt( $1 ); } IDENTIFIER { $$ = $4; } - | IDENTIFIER ALIAS { AliasAddStr( $1 ); } IDENTIFIER { $$ = $4; } - | PareExpList ALIAS { AliasAddExp(); } IDENTIFIER { $$ = $4; } - ; + | IDENTIFIER ALIAS { AliasAddStr( $1 ); } IDENTIFIER { $$ = $4; } + | PareExpList ALIAS { AliasAddExp(); } IDENTIFIER { $$ = $4; } + ; /* NOTE: In the case: * alias->( Expression ) * alias always selects a workarea even if it is MEMVAR or M */ AliasFunc : INTEGER ALIAS { AliasPush(); PushInteger( $1 ); AliasPop(); } PareExpList { AliasSwap(); } - | IDENTIFIER ALIAS { AliasPush(); PushSymbol( $1, 0 ); AliasPop(); } PareExpList { AliasSwap(); } - | PareExpList ALIAS { AliasPush(); AliasSwap(); } PareExpList { AliasSwap(); } - ; + | IDENTIFIER ALIAS { AliasPush(); PushSymbol( $1, 0 ); AliasPop(); } PareExpList { AliasSwap(); } + | PareExpList ALIAS { AliasPush(); AliasSwap(); } PareExpList { AliasSwap(); } + ; VarUnary : IDENTIFIER IncDec %prec POST { PushId( $1 ); Duplicate(); $2 ? Inc(): Dec(); PopId( $1 ); } - | IncDec IDENTIFIER %prec PRE { PushId( $2 ); $1 ? Inc(): Dec(); Duplicate(); PopId( $2 ); } - | VarAt IncDec %prec POST { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); $2 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $2 ? Dec(): Inc(); } - | IncDec VarAt %prec PRE { DupPCode( $2 ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray IncDec %prec POST { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $2 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $2 ? Dec(): Inc(); } - | IncDec FunCallArray %prec PRE { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData IncDec %prec POST { MessageDupl( SetData( $1 ) ); Function( 0 ); $2 ? Inc(): Dec(); Function( 1 ); $2 ? Dec(): Inc(); } - | IncDec ObjectData %prec PRE { MessageDupl( SetData( $2 ) ); Function( 0 ); $1 ? Inc(): Dec(); Function( 1 ); } - | ObjectData ArrayIndex IncDec %prec POST { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $3 ? Dec(): Inc(); } - | IncDec ObjectData ArrayIndex %prec PRE { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex IncDec %prec POST { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $3 ? Dec(): Inc(); } - | IncDec ObjectMethod ArrayIndex %prec PRE { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } - | AliasVar IncDec %prec POST { PushId( $1 ); Duplicate(); $2 ? Inc(): Dec(); PopId( $1 ); AliasRemove(); } - | IncDec AliasVar %prec PRE { PushId( $2 ); $1 ? Inc(): Dec(); Duplicate(); PopId( $2 ); AliasRemove(); } - ; + | IncDec IDENTIFIER %prec PRE { PushId( $2 ); $1 ? Inc(): Dec(); Duplicate(); PopId( $2 ); } + | VarAt IncDec %prec POST { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); $2 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $2 ? Dec(): Inc(); } + | IncDec VarAt %prec PRE { DupPCode( $2 ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray IncDec %prec POST { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $2 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $2 ? Dec(): Inc(); } + | IncDec FunCallArray %prec PRE { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData IncDec %prec POST { MessageDupl( SetData( $1 ) ); Function( 0 ); $2 ? Inc(): Dec(); Function( 1 ); $2 ? Dec(): Inc(); } + | IncDec ObjectData %prec PRE { MessageDupl( SetData( $2 ) ); Function( 0 ); $1 ? Inc(): Dec(); Function( 1 ); } + | ObjectData ArrayIndex IncDec %prec POST { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $3 ? Dec(): Inc(); } + | IncDec ObjectData ArrayIndex %prec PRE { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex IncDec %prec POST { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $3 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); $3 ? Dec(): Inc(); } + | IncDec ObjectMethod ArrayIndex %prec PRE { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); $1 ? Inc(): Dec(); GenPCode1( HB_P_ARRAYPUT ); } + | AliasVar IncDec %prec POST { PushId( $1 ); Duplicate(); $2 ? Inc(): Dec(); PopId( $1 ); AliasRemove(); } + | IncDec AliasVar %prec PRE { PushId( $2 ); $1 ? Inc(): Dec(); Duplicate(); PopId( $2 ); AliasRemove(); } + ; -IncDec : INC { $$ = 1; } - | DEC { $$ = 0; } - ; +IncDec : INC { $$ = 1; } + | DEC { $$ = 0; } + ; -Variable : VarId {} - | VarAt { GenPCode1( HB_P_ARRAYAT ); } - | FunCallArray { GenPCode1( HB_P_ARRAYAT ); } - | ObjectData {} - | ObjectData ArrayIndex { GenPCode1( HB_P_ARRAYAT ); } - | ObjectMethod ArrayIndex { GenPCode1( HB_P_ARRAYAT ); } - ; +Variable : VarId {} + | VarAt { GenPCode1( HB_P_ARRAYAT ); } + | FunCallArray { GenPCode1( HB_P_ARRAYAT ); } + | ObjectData {} + | ObjectData ArrayIndex { GenPCode1( HB_P_ARRAYAT ); } + | ObjectMethod ArrayIndex { GenPCode1( HB_P_ARRAYAT ); } + ; -VarId : IDENTIFIER { $$ = functions.pLast->lPCodePos; - if( _bForceByRefer && functions.pLast->szName && ! _bRValue ) - /* DO .. WITH uses reference to a variable - * if not inside a codeblock - */ - PushIdByRef( $1 ); - else - PushId( $1 ); - } - ; +VarId : IDENTIFIER { $$ = functions.pLast->lPCodePos; + if( _bForceByRefer && functions.pLast->szName && ! _bRValue ) + /* DO .. WITH uses reference to a variable + * if not inside a codeblock + */ + PushIdByRef( $1 ); + else + PushId( $1 ); + } + ; -VarAt : IDENTIFIER { $$ = functions.pLast->lPCodePos; PushId( $1 ); } ArrayIndex { $$ =$2; } - ; +VarAt : IDENTIFIER { $$ = functions.pLast->lPCodePos; PushId( $1 ); } ArrayIndex { $$ =$2; } + ; ArrayIndex : '[' IndexList ']' - | ArrayIndex { GenPCode1( HB_P_ARRAYAT ); } '[' IndexList ']' - ; + | ArrayIndex { GenPCode1( HB_P_ARRAYAT ); } '[' IndexList ']' + ; IndexList : Expression - | IndexList { GenPCode1( HB_P_ARRAYAT ); } ',' Expression - ; + | IndexList { GenPCode1( HB_P_ARRAYAT ); } ',' Expression + ; /*NOTE: If _bRValue is TRUE then the expression is on the right side of assignment * operator (or +=, -= ...) - in this case a variable is not pushed by * a reference it is a part of DO WITH ... statement */ VarAssign : IDENTIFIER INASSIGN { _bRValue = TRUE; } Expression { PopId( $1 ); PushId( $1 ); } - | IDENTIFIER PLUSEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); PopId( $1 ); PushId( $1 ); } - | IDENTIFIER MINUSEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); PopId( $1 ); PushId( $1 ); } - | IDENTIFIER MULTEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); PopId( $1 ); PushId( $1 ); } - | IDENTIFIER DIVEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); PopId( $1 ); PushId( $1 ); } - | IDENTIFIER EXPEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); PopId( $1 ); PushId( $1 ); } - | IDENTIFIER MODEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); PopId( $1 ); PushId( $1 ); } - | VarAt INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } - | VarAt PLUSEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } - | VarAt MINUSEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } - | VarAt MULTEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } - | VarAt DIVEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } - | VarAt EXPEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } - | VarAt MODEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray PLUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray MINUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray MULTEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray DIVEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray EXPEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } - | FunCallArray MODEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData INASSIGN { MessageFix ( SetData( $1 ) ); _bRValue = TRUE; } Expression { Function( 1 ); } - | ObjectData PLUSEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); Function( 1 ); } - | ObjectData MINUSEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); Function( 1 ); } - | ObjectData MULTEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); Function( 1 ); } - | ObjectData DIVEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); Function( 1 ); } - | ObjectData EXPEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); Function( 1 ); } - | ObjectData MODEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); Function( 1 ); } - | ObjectData ArrayIndex INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData ArrayIndex PLUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData ArrayIndex MINUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData ArrayIndex MULTEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData ArrayIndex DIVEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData ArrayIndex EXPEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectData ArrayIndex MODEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex PLUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex MINUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex MULTEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex DIVEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex EXPEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } - | ObjectMethod ArrayIndex MODEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } - | AliasVar INASSIGN { _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasVar PLUSEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_PLUS ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasVar MINUSEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_MINUS ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasVar MULTEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_MULT ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasVar DIVEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_DIVIDE ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasVar EXPEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_POWER ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasVar MODEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_MODULUS ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } - | AliasFunc INASSIGN Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | AliasFunc PLUSEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | AliasFunc MINUSEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | AliasFunc MULTEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | AliasFunc DIVEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | AliasFunc EXPEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - | AliasFunc MODEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } - ; + | IDENTIFIER PLUSEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); PopId( $1 ); PushId( $1 ); } + | IDENTIFIER MINUSEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); PopId( $1 ); PushId( $1 ); } + | IDENTIFIER MULTEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); PopId( $1 ); PushId( $1 ); } + | IDENTIFIER DIVEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); PopId( $1 ); PushId( $1 ); } + | IDENTIFIER EXPEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); PopId( $1 ); PushId( $1 ); } + | IDENTIFIER MODEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); PopId( $1 ); PushId( $1 ); } + | VarAt INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } + | VarAt PLUSEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } + | VarAt MINUSEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } + | VarAt MULTEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } + | VarAt DIVEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } + | VarAt EXPEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } + | VarAt MODEQ { DupPCode( $1 ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray PLUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray MINUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray MULTEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray DIVEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray EXPEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } + | FunCallArray MODEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData INASSIGN { MessageFix ( SetData( $1 ) ); _bRValue = TRUE; } Expression { Function( 1 ); } + | ObjectData PLUSEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); Function( 1 ); } + | ObjectData MINUSEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); Function( 1 ); } + | ObjectData MULTEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); Function( 1 ); } + | ObjectData DIVEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); Function( 1 ); } + | ObjectData EXPEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); Function( 1 ); } + | ObjectData MODEQ { MessageDupl( SetData( $1 ) ); Function( 0 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); Function( 1 ); } + | ObjectData ArrayIndex INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData ArrayIndex PLUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData ArrayIndex MINUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData ArrayIndex MULTEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData ArrayIndex DIVEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData ArrayIndex EXPEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectData ArrayIndex MODEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex INASSIGN { _bRValue = TRUE; } Expression { GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex PLUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex MINUSEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MINUS ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex MULTEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MULT ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex DIVEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_DIVIDE ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex EXPEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_POWER ); GenPCode1( HB_P_ARRAYPUT ); } + | ObjectMethod ArrayIndex MODEQ { GenPCode1( HB_P_DUPLTWO ); GenPCode1( HB_P_ARRAYAT ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_MODULUS ); GenPCode1( HB_P_ARRAYPUT ); } + | AliasVar INASSIGN { _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasVar PLUSEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_PLUS ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasVar MINUSEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_MINUS ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasVar MULTEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_MULT ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasVar DIVEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_DIVIDE ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasVar EXPEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_POWER ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasVar MODEQ { PushId( $1 ); _bRValue = TRUE; $$=(void*)pAliasId; pAliasId=NULL; } Expression { GenPCode1( HB_P_MODULUS ); pAliasId=(ALIASID_PTR) $3; PopId( $1 ); PushId( $1 ); AliasRemove(); } + | AliasFunc INASSIGN Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | AliasFunc PLUSEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | AliasFunc MINUSEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | AliasFunc MULTEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | AliasFunc DIVEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | AliasFunc EXPEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + | AliasFunc MODEQ Expression { --iLine; GenError( _szCErrors, 'E', ERR_INVALID_LVALUE, NULL, NULL ); } + ; Operators : Expression '=' Expression { GenPCode1( HB_P_EQUAL ); } /* compare */ - | Expression '+' Expression { GenPCode1( HB_P_PLUS ); } - | Expression '-' Expression { GenPCode1( HB_P_MINUS ); } - | Expression '*' Expression { GenPCode1( HB_P_MULT ); } - | Expression '/' Expression { GenPCode1( HB_P_DIVIDE ); } - | Expression '<' Expression { GenPCode1( HB_P_LESS ); } - | Expression '>' Expression { GenPCode1( HB_P_GREATER ); } - | Expression '$' Expression { GenPCode1( HB_P_INSTRING ); } - | Expression '%' Expression { GenPCode1( HB_P_MODULUS ); } - | Expression LE Expression { GenPCode1( HB_P_LESSEQUAL ); } - | Expression GE Expression { GenPCode1( HB_P_GREATEREQUAL ); } - | Expression AND { if( _bShortCuts ){ Duplicate(); $$ = JumpFalse( 0 ); } } - Expression { GenPCode1( HB_P_AND ); if( _bShortCuts ) JumpHere( $3 ); } - | Expression OR { if( _bShortCuts ){ Duplicate(); $$ = JumpTrue( 0 ); } } - Expression { GenPCode1( HB_P_OR ); if( _bShortCuts ) JumpHere( $3 ); } - | Expression EQ Expression { GenPCode1( HB_P_EXACTLYEQUAL ); } - | Expression NE1 Expression { GenPCode1( HB_P_NOTEQUAL ); } - | Expression NE2 Expression { GenPCode1( HB_P_NOTEQUAL ); } - | Expression POWER Expression { GenPCode1( HB_P_POWER ); } - | NOT Expression { GenPCode1( HB_P_NOT ); } - | '-' Expression %prec UNARY { GenPCode1( HB_P_NEGATE ); } - | '+' Expression %prec UNARY - | VarAssign { _bRValue = FALSE; } - ; + | Expression '+' Expression { GenPCode1( HB_P_PLUS ); } + | Expression '-' Expression { GenPCode1( HB_P_MINUS ); } + | Expression '*' Expression { GenPCode1( HB_P_MULT ); } + | Expression '/' Expression { GenPCode1( HB_P_DIVIDE ); } + | Expression '<' Expression { GenPCode1( HB_P_LESS ); } + | Expression '>' Expression { GenPCode1( HB_P_GREATER ); } + | Expression '$' Expression { GenPCode1( HB_P_INSTRING ); } + | Expression '%' Expression { GenPCode1( HB_P_MODULUS ); } + | Expression LE Expression { GenPCode1( HB_P_LESSEQUAL ); } + | Expression GE Expression { GenPCode1( HB_P_GREATEREQUAL ); } + | Expression AND { if( _bShortCuts ){ Duplicate(); $$ = JumpFalse( 0 ); } } + Expression { GenPCode1( HB_P_AND ); if( _bShortCuts ) JumpHere( $3 ); } + | Expression OR { if( _bShortCuts ){ Duplicate(); $$ = JumpTrue( 0 ); } } + Expression { GenPCode1( HB_P_OR ); if( _bShortCuts ) JumpHere( $3 ); } + | Expression EQ Expression { GenPCode1( HB_P_EXACTLYEQUAL ); } + | Expression NE1 Expression { GenPCode1( HB_P_NOTEQUAL ); } + | Expression NE2 Expression { GenPCode1( HB_P_NOTEQUAL ); } + | Expression POWER Expression { GenPCode1( HB_P_POWER ); } + | NOT Expression { GenPCode1( HB_P_NOT ); } + | '-' Expression %prec UNARY { GenPCode1( HB_P_NEGATE ); } + | '+' Expression %prec UNARY + | VarAssign { _bRValue = FALSE; } + ; -Logical : TRUEVALUE { $$ = 1; } - | FALSEVALUE { $$ = 0; } - ; +Logical : TRUEVALUE { $$ = 1; } + | FALSEVALUE { $$ = 0; } + ; -Array : '{' ElemList '}' { GenArray( $2 ); } - ; +Array : '{' ElemList '}' { GenArray( $2 ); } + ; -ElemList : /*empty array*/ { $$ = 0; } - | Expression { $$ = 1; } - | ElemList ',' { if( $$ == 0 ) { - PushNil(); - PushNil(); - $$ = 2; - } else { - PushNil(); - $$++; - } } - | ElemList ',' Expression { if( $$ == 0 ) - { - PushNil(); - $$ = 2; - } - else - $$++; } - ; +ElemList : /*empty array*/ { $$ = 0; } + | Expression { $$ = 1; } + | ElemList ',' { if( $$ == 0 ) { + PushNil(); + PushNil(); + $$ = 2; + } else { + PushNil(); + $$++; + } } + | ElemList ',' Expression { if( $$ == 0 ) + { + PushNil(); + $$ = 2; + } + else + $$++; } + ; CodeBlock : BlockBegin '|' BlockExpList '}' { CodeBlockEnd(); } - | BlockBegin BlockList '|' BlockExpList '}' { CodeBlockEnd(); } - ; + | BlockBegin BlockList '|' BlockExpList '}' { CodeBlockEnd(); } + ; BlockBegin : '{' '|' { CodeBlockStart(); } - ; + ; -BlockExpList : Expression { $$ = 1; } - | ',' { PushNil(); GenPCode1( HB_P_POP ); PushNil(); $$ = 2; } - | BlockExpList ',' { GenPCode1( HB_P_POP ); PushNil(); $$++; } - | BlockExpList ',' { GenPCode1( HB_P_POP ); } Expression { $$++; } - ; +BlockExpList : Expression { $$ = 1; } + | ',' { PushNil(); GenPCode1( HB_P_POP ); PushNil(); $$ = 2; } + | BlockExpList ',' { GenPCode1( HB_P_POP ); PushNil(); $$++; } + | BlockExpList ',' { GenPCode1( HB_P_POP ); } Expression { $$++; } + ; -BlockList : IDENTIFIER { cVarType = ' '; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_NUMERIC { cVarType = 'N'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_CHARACTER { cVarType = 'C'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_DATE { cVarType = 'D'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_LOGICAL { cVarType = 'L'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_ARRAY { cVarType = 'A'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_BLOCK { cVarType = 'B'; AddVar( $1 ); $$ = 1; } - | IDENTIFIER AS_OBJECT { cVarType = 'O'; AddVar( $1 ); $$ = 1; } - | BlockList ',' IDENTIFIER { AddVar( $3 ); $$++; } - ; +BlockList : IDENTIFIER { cVarType = ' '; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_NUMERIC { cVarType = 'N'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_CHARACTER { cVarType = 'C'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_DATE { cVarType = 'D'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_LOGICAL { cVarType = 'L'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_ARRAY { cVarType = 'A'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_BLOCK { cVarType = 'B'; AddVar( $1 ); $$ = 1; } + | IDENTIFIER AS_OBJECT { cVarType = 'O'; AddVar( $1 ); $$ = 1; } + | BlockList ',' IDENTIFIER { AddVar( $3 ); $$++; } + ; PareExpList: '(' ExpList ')' { $$ = $2; } - ; + ; -ExpList : Expression %prec POST { $$ = 1; } - | ExpList { GenPCode1( HB_P_POP ); } ',' Expression %prec POST { $$++; } - ; +ExpList : Expression %prec POST { $$ = 1; } + | ExpList { GenPCode1( HB_P_POP ); } ',' Expression %prec POST { $$++; } + ; VarDefs : LOCAL { iVarScope = VS_LOCAL; Line(); } VarList Crlf { cVarType = ' '; } - | STATIC { StaticDefStart() } VarList Crlf { StaticDefEnd( $3 ); } - | PARAMETERS { if( functions.pLast->bFlags & FUN_USES_LOCAL_PARAMS ) - GenError( _szCErrors, 'E', ERR_PARAMETERS_NOT_ALLOWED, NULL, NULL ); - else - functions.pLast->wParamNum=0; iVarScope = (VS_PRIVATE | VS_PARAMETER); } - MemvarList Crlf - ; + | STATIC { StaticDefStart() } VarList Crlf { StaticDefEnd( $3 ); } + | PARAMETERS { if( functions.pLast->bFlags & FUN_USES_LOCAL_PARAMS ) + GenError( _szCErrors, 'E', ERR_PARAMETERS_NOT_ALLOWED, NULL, NULL ); + else + functions.pLast->wParamNum=0; iVarScope = (VS_PRIVATE | VS_PARAMETER); } + MemvarList Crlf + ; -VarList : VarDef { $$ = 1; } - | VarList ',' VarDef { $$++; } - ; +VarList : VarDef { $$ = 1; } + | VarList ',' VarDef { $$++; } + ; -VarDef : IDENTIFIER { cVarType = ' '; AddVar( $1 ); } - | IDENTIFIER AS_NUMERIC { cVarType = 'N'; AddVar( $1 ); } - | IDENTIFIER AS_CHARACTER { cVarType = 'C'; AddVar( $1 ); } - | IDENTIFIER AS_LOGICAL { cVarType = 'L'; AddVar( $1 ); } - | IDENTIFIER AS_DATE { cVarType = 'D'; AddVar( $1 ); } - | IDENTIFIER AS_ARRAY { cVarType = 'A'; AddVar( $1 ); } - | IDENTIFIER AS_BLOCK { cVarType = 'B'; AddVar( $1 ); } - | IDENTIFIER AS_OBJECT { cVarType = 'O'; AddVar( $1 ); } - | IDENTIFIER INASSIGN Expression { cVarType = ' '; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_NUMERIC INASSIGN Expression { cVarType = 'N'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_CHARACTER INASSIGN Expression { cVarType = 'C'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_LOGICAL INASSIGN Expression { cVarType = 'L'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_DATE INASSIGN Expression { cVarType = 'D'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_ARRAY INASSIGN Expression { cVarType = 'A'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_BLOCK INASSIGN Expression { cVarType = 'B'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER AS_OBJECT INASSIGN Expression { cVarType = 'O'; AddVar( $1 ); PopId( $1 ); } - | IDENTIFIER '[' ExpList ']' { cVarType = ' '; AddVar( $1 ); DimArray( $3 ); PopId( $1 ); } - | IDENTIFIER '[' ExpList ']' AS_ARRAY { cVarType = 'A'; AddVar( $1 ); DimArray( $3 ); PopId( $1 ); } - ; +VarDef : IDENTIFIER { cVarType = ' '; AddVar( $1 ); } + | IDENTIFIER AS_NUMERIC { cVarType = 'N'; AddVar( $1 ); } + | IDENTIFIER AS_CHARACTER { cVarType = 'C'; AddVar( $1 ); } + | IDENTIFIER AS_LOGICAL { cVarType = 'L'; AddVar( $1 ); } + | IDENTIFIER AS_DATE { cVarType = 'D'; AddVar( $1 ); } + | IDENTIFIER AS_ARRAY { cVarType = 'A'; AddVar( $1 ); } + | IDENTIFIER AS_BLOCK { cVarType = 'B'; AddVar( $1 ); } + | IDENTIFIER AS_OBJECT { cVarType = 'O'; AddVar( $1 ); } + | IDENTIFIER INASSIGN Expression { cVarType = ' '; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_NUMERIC INASSIGN Expression { cVarType = 'N'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_CHARACTER INASSIGN Expression { cVarType = 'C'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_LOGICAL INASSIGN Expression { cVarType = 'L'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_DATE INASSIGN Expression { cVarType = 'D'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_ARRAY INASSIGN Expression { cVarType = 'A'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_BLOCK INASSIGN Expression { cVarType = 'B'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER AS_OBJECT INASSIGN Expression { cVarType = 'O'; AddVar( $1 ); PopId( $1 ); } + | IDENTIFIER '[' ExpList ']' { cVarType = ' '; AddVar( $1 ); DimArray( $3 ); PopId( $1 ); } + | IDENTIFIER '[' ExpList ']' AS_ARRAY { cVarType = 'A'; AddVar( $1 ); DimArray( $3 ); PopId( $1 ); } + ; FieldsDef : FIELD { iVarScope =VS_FIELD; } FieldList Crlf - ; + ; -FieldList : IDENTIFIER { cVarType = ' '; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_NUMERIC { cVarType = 'N'; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_CHARACTER { cVarType = 'C'; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_DATE { cVarType = 'D'; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_LOGICAL { cVarType = 'L'; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_ARRAY { cVarType = 'A'; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_BLOCK { cVarType = 'B'; $$=FieldsCount(); AddVar( $1 ); } - | IDENTIFIER AS_OBJECT { cVarType = 'O'; $$=FieldsCount(); AddVar( $1 ); } - | FieldList ',' IDENTIFIER { AddVar( $3 ); } - | FieldList IN IDENTIFIER { FieldsSetAlias( $3, $1 ); } - ; +FieldList : IDENTIFIER { cVarType = ' '; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_NUMERIC { cVarType = 'N'; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_CHARACTER { cVarType = 'C'; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_DATE { cVarType = 'D'; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_LOGICAL { cVarType = 'L'; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_ARRAY { cVarType = 'A'; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_BLOCK { cVarType = 'B'; $$=FieldsCount(); AddVar( $1 ); } + | IDENTIFIER AS_OBJECT { cVarType = 'O'; $$=FieldsCount(); AddVar( $1 ); } + | FieldList ',' IDENTIFIER { AddVar( $3 ); } + | FieldList IN IDENTIFIER { FieldsSetAlias( $3, $1 ); } + ; MemvarDef : MEMVAR { iVarScope = VS_MEMVAR; } MemvarList Crlf - ; + ; -MemvarList : IDENTIFIER { AddVar( $1 ); } - | MemvarList ',' IDENTIFIER { AddVar( $3 ); } - ; +MemvarList : IDENTIFIER { AddVar( $1 ); } + | MemvarList ',' IDENTIFIER { AddVar( $3 ); } + ; ExecFlow : IfEndif - | DoCase - | DoWhile - | ForNext - | BeginSeq - ; + | DoCase + | DoWhile + | ForNext + | BeginSeq + ; -IfEndif : IfBegin EndIf { JumpHere( $1 ); } - | IfBegin IfElse EndIf { JumpHere( $1 ); } - | IfBegin IfElseIf EndIf { JumpHere( $1 ); FixElseIfs( $2 ); } - | IfBegin IfElseIf IfElse EndIf { JumpHere( $1 ); FixElseIfs( $2 ); } - ; +IfEndif : IfBegin EndIf { JumpHere( $1 ); } + | IfBegin IfElse EndIf { JumpHere( $1 ); } + | IfBegin IfElseIf EndIf { JumpHere( $1 ); FixElseIfs( $2 ); } + | IfBegin IfElseIf IfElse EndIf { JumpHere( $1 ); FixElseIfs( $2 ); } + ; IfBegin : IF Expression { ++_wIfCounter; } Crlf { $$ = JumpFalse( 0 ); } - IfStats - { $$ = Jump( 0 ); JumpHere( $5 ); } - ; + IfStats + { $$ = Jump( 0 ); JumpHere( $5 ); } + ; -IfElse : ELSE Crlf IfStats - ; +IfElse : ELSE Crlf IfStats + ; IfElseIf : ELSEIF Expression Crlf { $$ = JumpFalse( 0 ); } - IfStats { $$ = GenElseIf( 0, Jump( 0 ) ); JumpHere( $4 ); } + IfStats { $$ = GenElseIf( 0, Jump( 0 ) ); JumpHere( $4 ); } - | IfElseIf ELSEIF Expression Crlf { $$ = JumpFalse( 0 ); } - IfStats { $$ = GenElseIf( $1, Jump( 0 ) ); JumpHere( $5 ); } - ; + | IfElseIf ELSEIF Expression Crlf { $$ = JumpFalse( 0 ); } + IfStats { $$ = GenElseIf( $1, Jump( 0 ) ); JumpHere( $5 ); } + ; -EndIf : ENDIF { --_wIfCounter; } - | END { --_wIfCounter; } - ; +EndIf : ENDIF { --_wIfCounter; } + | END { --_wIfCounter; } + ; IfStats : /* no statements */ - | Statements - ; + | Statements + ; -DoCase : DoCaseBegin - Cases - EndCase { FixElseIfs( $2 ); } +DoCase : DoCaseBegin + Cases + EndCase { FixElseIfs( $2 ); } - | DoCaseBegin - Otherwise - EndCase + | DoCaseBegin + Otherwise + EndCase - | DoCaseBegin - EndCase + | DoCaseBegin + EndCase - | DoCaseBegin - Cases - Otherwise - EndCase { FixElseIfs( $2 ); } - ; + | DoCaseBegin + Cases + Otherwise + EndCase { FixElseIfs( $2 ); } + ; -EndCase : ENDCASE { --_wCaseCounter; } - | END { --_wCaseCounter; } - ; +EndCase : ENDCASE { --_wCaseCounter; } + | END { --_wCaseCounter; } + ; DoCaseBegin : DOCASE { ++_wCaseCounter; } Crlf - ; + ; -Cases : CASE Expression Crlf { $$ = JumpFalse( 0 ); Line(); } CaseStmts { $$ = GenElseIf( 0, Jump( 0 ) ); JumpHere( $4 ); Line(); } - | Cases CASE Expression Crlf { $$ = JumpFalse( 0 ); Line(); } CaseStmts { $$ = GenElseIf( $1, Jump( 0 ) ); JumpHere( $5 ); Line(); } - ; +Cases : CASE Expression Crlf { $$ = JumpFalse( 0 ); Line(); } CaseStmts { $$ = GenElseIf( 0, Jump( 0 ) ); JumpHere( $4 ); Line(); } + | Cases CASE Expression Crlf { $$ = JumpFalse( 0 ); Line(); } CaseStmts { $$ = GenElseIf( $1, Jump( 0 ) ); JumpHere( $5 ); Line(); } + ; Otherwise : OTHERWISE Crlf CaseStmts - ; + ; CaseStmts : /* no statements */ - | Statements - ; + | Statements + ; DoWhile : WhileBegin Expression Crlf { $$ = JumpFalse( 0 ); } - { Jump( $1 - functions.pLast->lPCodePos ); } - EndWhile { JumpHere( $4 ); --_wWhileCounter; } + { Jump( $1 - functions.pLast->lPCodePos ); } + EndWhile { JumpHere( $4 ); --_wWhileCounter; } - | WhileBegin Expression Crlf { $$ = JumpFalse( 0 ); Line(); } - WhileStatements { LoopHere(); Jump( $1 - functions.pLast->lPCodePos ); } - EndWhile { JumpHere( $4 ); --_wWhileCounter; LoopEnd(); } - ; + | WhileBegin Expression Crlf { $$ = JumpFalse( 0 ); Line(); } + WhileStatements { LoopHere(); Jump( $1 - functions.pLast->lPCodePos ); } + EndWhile { JumpHere( $4 ); --_wWhileCounter; LoopEnd(); } + ; WhileBegin : WHILE { $$ = functions.pLast->lPCodePos; ++_wWhileCounter; LoopStart(); } - ; + ; WhileStatements : Statement - | WhileStatements Statement { Line(); } - ; + | WhileStatements Statement { Line(); } + ; EndWhile : END - | ENDDO - ; + | ENDDO + ; ForNext : FOR IDENTIFIER ForAssign Expression { PopId( $2 ); $$ = functions.pLast->lPCodePos; ++_wForCounter; LoopStart(); } - TO Expression { PushId( $2 ); } - StepExpr Crlf { GenPCode1( HB_P_FORTEST ); $$ = JumpTrue( 0 ); } - ForStatements { LoopHere(); PushId( $2 ); GenPCode1( HB_P_PLUS ); PopId( $2 ); Jump( $5 - functions.pLast->lPCodePos ); JumpHere( $11 ); LoopEnd(); } - ; + TO Expression { PushId( $2 ); } + StepExpr Crlf { GenPCode1( HB_P_FORTEST ); $$ = JumpTrue( 0 ); } + ForStatements { LoopHere(); PushId( $2 ); GenPCode1( HB_P_PLUS ); PopId( $2 ); Jump( $5 - functions.pLast->lPCodePos ); JumpHere( $11 ); LoopEnd(); } + ; ForAssign : '=' - | INASSIGN - ; + | INASSIGN + ; -StepExpr : /* default step expression */ { PushInteger( 1 ); } - | STEP Expression - ; +StepExpr : /* default step expression */ { PushInteger( 1 ); } + | STEP Expression + ; -ForStatements : ForStat NEXT { --_wForCounter; } - | ForStat NEXT IDENTIFIER { --_wForCounter; } - | NEXT { --_wForCounter; } - | NEXT IDENTIFIER { --_wForCounter; } - ; +ForStatements : ForStat NEXT { --_wForCounter; } + | ForStat NEXT IDENTIFIER { --_wForCounter; } + | NEXT { --_wForCounter; } + | NEXT IDENTIFIER { --_wForCounter; } + ; -ForStat : Statements { Line(); } - ; +ForStat : Statements { Line(); } + ; BeginSeq : BEGINSEQ { ++_wSeqCounter; } Crlf - SeqStatms - RecoverSeq - END { --_wSeqCounter; } - ; + SeqStatms + RecoverSeq + END { --_wSeqCounter; } + ; SeqStatms : /* empty */ - | Statements - ; + | Statements + ; RecoverSeq : /* no recover */ - | RecoverEmpty Crlf - | RecoverEmpty Crlf Statements - | RecoverUsing Crlf - | RecoverUsing Crlf Statements - ; + | RecoverEmpty Crlf + | RecoverEmpty Crlf Statements + | RecoverUsing Crlf + | RecoverUsing Crlf Statements + ; RecoverEmpty : RECOVER - ; + ; RecoverUsing : RECOVER USING IDENTIFIER - ; + ; /* NOTE: In Clipper all variables used in DO .. WITH are passed by reference * however if they are part of an expression then they are passed by value @@ -1175,26 +1175,26 @@ RecoverUsing : RECOVER USING IDENTIFIER * DO .. WITH ++variable * will pass the value of variable not a reference */ -DoProc : DO IDENTIFIER { PushSymbol( $2, 1 ); PushNil(); Do( 0 ); } - | DO IDENTIFIER { PushSymbol( $2, 1 ); PushNil(); _bForceByRefer=TRUE; } WITH DoArgList { Do( $5 ); _bForceByRefer=FALSE; } - | WHILE { PushSymbol( yy_strdup("WHILE"), 1 ); PushNil(); _bForceByRefer=TRUE; } WITH DoArgList { Do( $4 ); _bForceByRefer=FALSE; } - ; +DoProc : DO IDENTIFIER { PushSymbol( $2, 1 ); PushNil(); Do( 0 ); } + | DO IDENTIFIER { PushSymbol( $2, 1 ); PushNil(); _bForceByRefer=TRUE; } WITH DoArgList { Do( $5 ); _bForceByRefer=FALSE; } + | WHILE { PushSymbol( yy_strdup("WHILE"), 1 ); PushNil(); _bForceByRefer=TRUE; } WITH DoArgList { Do( $4 ); _bForceByRefer=FALSE; } + ; DoArgList : ',' { PushNil(); PushNil(); $$ = 2; } - | DoExpression { $$ = 1; } - | DoArgList ',' { PushNil(); $$++; } - | DoArgList ',' DoExpression { $$++; } - | ',' { PushNil(); } DoExpression { $$ = 2; } - ; + | DoExpression { $$ = 1; } + | DoArgList ',' { PushNil(); $$++; } + | DoArgList ',' DoExpression { $$++; } + | ',' { PushNil(); } DoExpression { $$ = 2; } + ; -DoExpression: Expression { _bForceByRefer=TRUE; } - ; +DoExpression: Expression { _bForceByRefer=TRUE; } + ; -Crlf : '\n' - | ';' - | '\n' Crlf - | ';' Crlf - ; +Crlf : '\n' + | ';' + | '\n' Crlf + | ';' Crlf + ; %% @@ -1217,7 +1217,7 @@ void * GenElseIf( void * pFirst, WORD wOffset ) { pLast = ( PELSEIF ) pFirst; while( pLast->pNext ) - pLast = pLast->pNext; + pLast = pLast->pNext; pLast->pNext = pElseIf; } return pFirst; @@ -1225,7 +1225,7 @@ void * GenElseIf( void * pFirst, WORD wOffset ) void GenError( char* _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 ) { - char * szLine = ( char * ) OurMalloc( 160 ); /*2 lines of text */ + char * szLine = ( char * ) OurMalloc( 160 ); /*2 lines of text */ printf( "\r%s(%i) ", files.pLast->szFileName, iLine ); printf( "Error %c%i ", cPrefix, iError ); sprintf( szLine, _szErrors[ iError - 1 ], szError1, szError2 ); @@ -1233,15 +1233,15 @@ void GenError( char* _szErrors[], char cPrefix, int iError, char * szError1, cha exit( 1 ); } -void GenWarning( int iWarning, char * szWarning1, char * szWarning2 ) +void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2) { - if( _bWarnings && iWarning < WARN_ASSIGN_SUSPECT ) /*TODO add switch to set level */ + if( _bWarnings && iWarning < WARN_ASSIGN_SUSPECT ) /* TODO: add switch to set level */ { - char * szLine = ( char * ) OurMalloc( 160 ); /*2 lines of text */ - printf( "\r%s(%i) ", files.pLast->szFileName, iLine ); - printf( "Warning W%i ", iWarning ); - sprintf( szLine, _szWarnings[ iWarning - 1 ], szWarning1, szWarning2 ); - printf( "%s\n", szLine ); + char * szLine = ( char * ) OurMalloc( 160 ); /*2 lines of text */ + printf( "\r%s(%i) ", files.pLast->szFileName, iLine ); + printf( "Warning %c%i ", cPrefix, iWarning ); + sprintf( szLine, _szWarnings[ iWarning - 1 ], szWarning1, szWarning2 ); + printf( "%s\n", szLine ); } } @@ -1260,7 +1260,7 @@ void EXTERNAL_LINKAGE close_on_exit( void ) int harbour_main( int argc, char * argv[] ) { int iStatus = 0, iArg = 1; - char szFileName[ _POSIX_PATH_MAX ]; /* filename to parse */ + char szFileName[ _POSIX_PATH_MAX ]; /* filename to parse */ char szPpoName[ _POSIX_PATH_MAX ]; char *szOutPath =""; @@ -1270,179 +1270,179 @@ int harbour_main( int argc, char * argv[] ) /* Command line options */ while( iArg < argc ) { - if( IS_OPT_SEP(argv[ iArg ][ 0 ])) - { - switch( argv[ iArg ][ 1 ] ) - { - case '1': - if( argv[ iArg ][ 2 ] == '0' ) - _bRestrictSymbolLength = TRUE; - break; + if( IS_OPT_SEP(argv[ iArg ][ 0 ])) + { + switch( argv[ iArg ][ 1 ] ) + { + case '1': + if( argv[ iArg ][ 2 ] == '0' ) + _bRestrictSymbolLength = TRUE; + break; - case 'a': - case 'A': - _bAutoMemvarAssume = TRUE; - break; + case 'a': + case 'A': + _bAutoMemvarAssume = TRUE; + break; - case 'b': - case 'B': - _bDebugInfo = TRUE; - _bLineNumbers = TRUE; - break; + case 'b': + case 'B': + _bDebugInfo = TRUE; + _bLineNumbers = TRUE; + break; - case 'd': - case 'D': /* defines a Lex #define from the command line */ - { - unsigned int i = 0; - char * szDefText = yy_strdup( argv[ iArg ] + 2 ); - while( i < strlen( szDefText ) && szDefText[ i ] != '=' ) - i++; - if( szDefText[ i ] != '=' ) - AddDefine( szDefText, 0 ); - else - { - szDefText[ i ] = 0; - AddDefine( szDefText, szDefText + i + 1 ); - } - free( szDefText ); - } - break; + case 'd': + case 'D': /* defines a Lex #define from the command line */ + { + unsigned int i = 0; + char * szDefText = yy_strdup( argv[ iArg ] + 2 ); + while( i < strlen( szDefText ) && szDefText[ i ] != '=' ) + i++; + if( szDefText[ i ] != '=' ) + AddDefine( szDefText, 0 ); + else + { + szDefText[ i ] = 0; + AddDefine( szDefText, szDefText + i + 1 ); + } + free( szDefText ); + } + break; #ifdef HARBOUR_OBJ_GENERATION - case 'f': - case 'F': - { - char * szUpper = yy_strupr( yy_strdup( &argv[ iArg ][ 2 ] ) ); - if( ! strcmp( szUpper, "OBJ32" ) ) - _bObj32 = TRUE; - free( szUpper ); - } - break; + case 'f': + case 'F': + { + char * szUpper = yy_strupr( yy_strdup( &argv[ iArg ][ 2 ] ) ); + if( ! strcmp( szUpper, "OBJ32" ) ) + _bObj32 = TRUE; + free( szUpper ); + } + break; #endif - case 'g': - case 'G': - switch( argv[ iArg ][ 2 ] ) - { - case 'c': - case 'C': - _iLanguage = LANG_C; - break; + case 'g': + case 'G': + switch( argv[ iArg ][ 2 ] ) + { + case 'c': + case 'C': + _iLanguage = LANG_C; + break; - case 'j': - case 'J': - _iLanguage = LANG_JAVA; - break; + case 'j': + case 'J': + _iLanguage = LANG_JAVA; + break; - case 'p': - case 'P': - _iLanguage = LANG_PASCAL; - break; + case 'p': + case 'P': + _iLanguage = LANG_PASCAL; + break; - case 'r': - case 'R': - _iLanguage = LANG_RESOURCES; - break; + case 'r': + case 'R': + _iLanguage = LANG_RESOURCES; + break; - case 'h': - case 'H': - _iLanguage = LANG_PORT_OBJ; - break; + case 'h': + case 'H': + _iLanguage = LANG_PORT_OBJ; + break; - default: - printf( "\nUnsupported output language option\n" ); - exit( 1 ); - } - break; + default: + printf( "\nUnsupported output language option\n" ); + exit( 1 ); + } + break; - case 'i': - case 'I': - AddSearchPath( argv[ iArg ]+2, &_pIncludePath ); - break; + case 'i': + case 'I': + AddSearchPath( argv[ iArg ]+2, &_pIncludePath ); + break; - case 'l': - case 'L': - _bLineNumbers = FALSE; - break; + case 'l': + case 'L': + _bLineNumbers = FALSE; + break; - case 'n': - case 'N': - _bStartProc = FALSE; - break; + case 'n': + case 'N': + _bStartProc = FALSE; + break; - case 'o': - case 'O': - szOutPath = argv[ iArg ]+2; - break; + case 'o': + case 'O': + szOutPath = argv[ iArg ]+2; + break; - /* Added for preprocessor needs */ - case 'p': - case 'P': - lPpo = 1; - break; + /* Added for preprocessor needs */ + case 'p': + case 'P': + lPpo = 1; + break; - case 'q': - case 'Q': - _bQuiet = TRUE; - break; + case 'q': + case 'Q': + _bQuiet = TRUE; + break; - case 's': - case 'S': - _bSyntaxCheckOnly = TRUE; - break; + case 's': + case 'S': + _bSyntaxCheckOnly = TRUE; + break; - case 'v': - case 'V': - _bForceMemvars = TRUE; - break; + case 'v': + case 'V': + _bForceMemvars = TRUE; + break; - case 'w': - case 'W': - _bWarnings = TRUE; - break; + case 'w': + case 'W': + _bWarnings = TRUE; + break; - case 'y': - case 'Y': - yydebug = TRUE; - break; + case 'y': + case 'Y': + yydebug = TRUE; + break; - case 'z': - case 'Z': - _bShortCuts = FALSE; - break; + case 'z': + case 'Z': + _bShortCuts = FALSE; + break; - default: - printf( "Invalid command line option: %s\n", - &argv[ iArg ][ 0 ] ); - break; - } - } - else - _pFileName =SplitFilename( argv[ iArg ] ); - iArg++; + default: + printf( "Invalid command line option: %s\n", + &argv[ iArg ][ 0 ] ); + break; + } + } + else + _pFileName =SplitFilename( argv[ iArg ] ); + iArg++; } if( !_bQuiet ) - printf( "Harbour compiler build %i%s (%04d.%02d.%02d)\n", - hb_build, hb_revision, hb_year, hb_month, hb_day ); + printf( "Harbour compiler build %i%s (%04d.%02d.%02d)\n", + hb_build, hb_revision, hb_year, hb_month, hb_day ); if( _pFileName ) { - if( !_pFileName->extension ) - _pFileName->extension =".prg"; - MakeFilename( szFileName, _pFileName ); - if ( lPpo ) - { - _pFileName->extension =".ppo"; - MakeFilename( szPpoName, _pFileName ); - yyppo = fopen ( szPpoName, "w" ); - } + if( !_pFileName->extension ) + _pFileName->extension =".prg"; + MakeFilename( szFileName, _pFileName ); + if ( lPpo ) + { + _pFileName->extension =".ppo"; + MakeFilename( szPpoName, _pFileName ); + yyppo = fopen ( szPpoName, "w" ); + } } else { - PrintUsage( argv[ 0 ] ); - return iStatus; + PrintUsage( argv[ 0 ] ); + return iStatus; } - files.iFiles = 0; /* initialize support variables */ + files.iFiles = 0; /* initialize support variables */ files.pLast = 0; functions.iCount = 0; functions.pFirst = 0; @@ -1460,110 +1460,110 @@ int harbour_main( int argc, char * argv[] ) if( Include( szFileName, NULL ) ) { - char * szInclude = getenv( "INCLUDE" ); + char * szInclude = getenv( "INCLUDE" ); - if( szInclude ) - { - char * pPath; - char * pDelim; + if( szInclude ) + { + char * pPath; + char * pDelim; - pPath = szInclude = yy_strdup( szInclude ); - while( (pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR )) != NULL ) - { - *pDelim = '\0'; - AddSearchPath( pPath, &_pIncludePath ); - pPath = pDelim + 1; - } - AddSearchPath( pPath, &_pIncludePath ); - } + pPath = szInclude = yy_strdup( szInclude ); + while( (pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR )) != NULL ) + { + *pDelim = '\0'; + AddSearchPath( pPath, &_pIncludePath ); + pPath = pDelim + 1; + } + AddSearchPath( pPath, &_pIncludePath ); + } - /* Generate the starting procedure frame - */ - if( _bStartProc ) - FunDef( yy_strupr( yy_strdup( _pFileName->name ) ), FS_PUBLIC, FUN_PROCEDURE ); - else - /* Don't pass the name of module if the code for starting procedure - * will be not generated. The name cannot be placed as first symbol - * because this symbol can be used as function call or memvar's name. - */ - FunDef( yy_strupr( yy_strdup( "" ) ), FS_PUBLIC, FUN_PROCEDURE ); + /* Generate the starting procedure frame + */ + if( _bStartProc ) + FunDef( yy_strupr( yy_strdup( _pFileName->name ) ), FS_PUBLIC, FUN_PROCEDURE ); + else + /* Don't pass the name of module if the code for starting procedure + * will be not generated. The name cannot be placed as first symbol + * because this symbol can be used as function call or memvar's name. + */ + FunDef( yy_strupr( yy_strdup( "" ) ), FS_PUBLIC, FUN_PROCEDURE ); - yyparse(); + yyparse(); - GenExterns(); /* generates EXTERN symbols names */ - fclose( yyin ); - files.pLast = NULL; + GenExterns(); /* generates EXTERN symbols names */ + fclose( yyin ); + files.pLast = NULL; #ifdef HARBOUR_OBJ_GENERATION - if( ! _bSyntaxCheckOnly && ! _bObj32 ) + if( ! _bSyntaxCheckOnly && ! _bObj32 ) #else - if( ! _bSyntaxCheckOnly ) + if( ! _bSyntaxCheckOnly ) #endif - { - if( _pInitFunc ) - { - PCOMSYMBOL pSym; + { + if( _pInitFunc ) + { + PCOMSYMBOL pSym; - /* Fix the number of static variables */ - _pInitFunc->pCode[ 1 ] =LOBYTE( _wStatics ); - _pInitFunc->pCode[ 2 ] =HIBYTE( _wStatics ); - _pInitFunc->wStaticsBase =_wStatics; + /* Fix the number of static variables */ + _pInitFunc->pCode[ 1 ] =LOBYTE( _wStatics ); + _pInitFunc->pCode[ 2 ] =HIBYTE( _wStatics ); + _pInitFunc->wStaticsBase =_wStatics; - pSym = AddSymbol( _pInitFunc->szName, NULL ); - pSym->cScope |= _pInitFunc->cScope; - functions.pLast->pNext = _pInitFunc; - ++functions.iCount; - } + pSym = AddSymbol( _pInitFunc->szName, NULL ); + pSym->cScope |= _pInitFunc->cScope; + functions.pLast->pNext = _pInitFunc; + ++functions.iCount; + } - /* we create a the output file */ - _pFileName->path = szOutPath; - switch( _iLanguage ) - { - case LANG_C: - _pFileName->extension =".c"; - MakeFilename( szFileName, _pFileName ); - GenCCode( szFileName, _pFileName->name ); - break; + /* we create a the output file */ + _pFileName->path = szOutPath; + switch( _iLanguage ) + { + case LANG_C: + _pFileName->extension =".c"; + MakeFilename( szFileName, _pFileName ); + GenCCode( szFileName, _pFileName->name ); + break; - case LANG_JAVA: - _pFileName->extension =".java"; - MakeFilename( szFileName, _pFileName ); - GenJava( szFileName, _pFileName->name ); - break; + case LANG_JAVA: + _pFileName->extension =".java"; + MakeFilename( szFileName, _pFileName ); + GenJava( szFileName, _pFileName->name ); + break; - case LANG_PASCAL: - _pFileName->extension =".pas"; - MakeFilename( szFileName, _pFileName ); - GenPascal( szFileName, _pFileName->name ); - break; + case LANG_PASCAL: + _pFileName->extension =".pas"; + MakeFilename( szFileName, _pFileName ); + GenPascal( szFileName, _pFileName->name ); + break; - case LANG_RESOURCES: - _pFileName->extension =".rc"; - MakeFilename( szFileName, _pFileName ); - GenRC( szFileName, _pFileName->name ); - break; + case LANG_RESOURCES: + _pFileName->extension =".rc"; + MakeFilename( szFileName, _pFileName ); + GenRC( szFileName, _pFileName->name ); + break; - case LANG_PORT_OBJ: - _pFileName->extension =".hrb"; - MakeFilename( szFileName, _pFileName ); - GenPortObj( szFileName, _pFileName->name ); - break; - } - } + case LANG_PORT_OBJ: + _pFileName->extension =".hrb"; + MakeFilename( szFileName, _pFileName ); + GenPortObj( szFileName, _pFileName->name ); + break; + } + } #ifdef HARBOUR_OBJ_GENERATION - if( _bObj32 ) - { - _pFileName->extension = ".obj"; - MakeFilename( szFileName, _pFileName ); - GenObj32( szFileName, _pFileName->name ); - } + if( _bObj32 ) + { + _pFileName->extension = ".obj"; + MakeFilename( szFileName, _pFileName ); + GenObj32( szFileName, _pFileName->name ); + } #endif - if ( lPpo ) fclose ( yyppo ); + if ( lPpo ) fclose ( yyppo ); } else { - printf( "Can't open input file: %s\n", szFileName ); - iStatus = 1; + printf( "Can't open input file: %s\n", szFileName ); + iStatus = 1; } OurFree( (void *) _pFileName ); } @@ -1579,33 +1579,33 @@ int harbour_main( int argc, char * argv[] ) void PrintUsage( char * szSelf ) { printf( "Syntax: %s [options]\n" - "\nOptions: \n" - "\t/a\t\tautomatic memvar declaration\n" - "\t/b\t\tdebug info\n" - "\t/d[=]\t#define \n" + "\nOptions: \n" + "\t/a\t\tautomatic memvar declaration\n" + "\t/b\t\tdebug info\n" + "\t/d[=]\t#define \n" #ifdef HARBOUR_OBJ_GENERATION - "\t/f\t\tgenerated object file\n" - "\t\t\t /fobj32 --> Windows/Dos 32 bits OBJ\n" + "\t/f\t\tgenerated object file\n" + "\t\t\t /fobj32 --> Windows/Dos 32 bits OBJ\n" #endif - "\t/g\t\tgenerated output language\n" - "\t\t\t /gc (C default) --> \n" - "\t\t\t /gh (HRB file) --> \n" - "\t\t\t /gj (Java) --> \n" - "\t\t\t /gp (Pascal) --> \n" - "\t\t\t /gr (Resources) --> \n" - "\t/i\tadd #include file search path\n" - "\t/l\t\tsuppress line number information\n" - "\t/n\t\tno implicit starting procedure\n" - "\t/o\tobject file drive and/or path\n" - "\t/p\t\tgenerate pre-processed output (.ppo) file\n" - "\t/q\t\tquiet\n" - "\t/s\t\tsyntax check only\n" - "\t/v\t\tvariables are assumed M->\n" - "\t/w\t\tenable warnings\n" - "\t/y\t\ttrace lex & yacc activity\n" - "\t/z\t\tsuppress shortcutting (.and. & .or.)\n" - "\t/10\t\trestrict symbol length to 10 characters\n" - , szSelf ); + "\t/g\t\tgenerated output language\n" + "\t\t\t /gc (C default) --> \n" + "\t\t\t /gh (HRB file) --> \n" + "\t\t\t /gj (Java) --> \n" + "\t\t\t /gp (Pascal) --> \n" + "\t\t\t /gr (Resources) --> \n" + "\t/i\tadd #include file search path\n" + "\t/l\t\tsuppress line number information\n" + "\t/n\t\tno implicit starting procedure\n" + "\t/o\tobject file drive and/or path\n" + "\t/p\t\tgenerate pre-processed output (.ppo) file\n" + "\t/q\t\tquiet\n" + "\t/s\t\tsyntax check only\n" + "\t/v\t\tvariables are assumed M->\n" + "\t/w\t\tenable warnings\n" + "\t/y\t\ttrace lex & yacc activity\n" + "\t/z\t\tsuppress shortcutting (.and. & .or.)\n" + "\t/10\t\trestrict symbol length to 10 characters\n" + , szSelf ); } /* @@ -1682,9 +1682,9 @@ char *MakeFilename( char *szFileName, FILENAME *pFileName ) { #if 0 fprintf(stderr, "path: |%s|\n" - "name: |%s|\n" - " ext: |%s|\n", - pFileName->path, pFileName->name, pFileName->extension); + "name: |%s|\n" + " ext: |%s|\n", + pFileName->path, pFileName->name, pFileName->extension); #endif if( pFileName->path && pFileName->path[ 0 ] ) @@ -1701,8 +1701,8 @@ char *MakeFilename( char *szFileName, FILENAME *pFileName ) */ if( !( IS_PATH_SEP(pFileName->name[ 0 ]) || IS_PATH_SEP(pFileName->path[ iLen-1 ]) ) ) { - szFileName[ iLen++ ] =PATH_DELIMITER[0]; - szFileName[ iLen ] ='\x0'; + szFileName[ iLen++ ] =PATH_DELIMITER[0]; + szFileName[ iLen ] ='\x0'; } } strcpy( szFileName+iLen, pFileName->name ); @@ -1744,7 +1744,7 @@ void AddSearchPath( char *szPath, PATHNAMES * *pSearchList ) { *pSearchList =pPath =(PATHNAMES *)OurMalloc( sizeof(PATHNAMES) ); } - pPath->pNext = NULL; + pPath->pNext = NULL; pPath->szPath = szPath; } @@ -1791,7 +1791,7 @@ void AddExtern( char * szExternName ) /* defines a new extern name */ { pLast = pExterns; while( pLast->pNext ) - pLast = pLast->pNext; + pLast = pLast->pNext; pLast->pNext = pExtern; } } @@ -1804,7 +1804,7 @@ void AddVar( char * szVarName ) if( ! _bStartProc && functions.iCount <= 1 && iVarScope == VS_LOCAL ) { /* Variable declaration is outside of function/procedure body. - In this case only STATIC and PARAMETERS variables are allowed. */ + In this case only STATIC and PARAMETERS variables are allowed. */ --iLine; GenError( _szCErrors, 'E', ERR_OUTSIDE, NULL, NULL ); } @@ -1830,7 +1830,7 @@ void AddVar( char * szVarName ) * value initialization */ if( _pInitFunc->bFlags & FUN_ILLEGAL_INIT ) - GenError( _szCErrors, 'E', ERR_ILLEGAL_INIT, szVarName, pFunc->szName ); + GenError( _szCErrors, 'E', ERR_ILLEGAL_INIT, szVarName, pFunc->szName ); } /* Check if a declaration of duplicated variable name is requested */ @@ -1840,7 +1840,7 @@ void AddVar( char * szVarName ) CheckDuplVars( pFunc->pFields, szVarName, iVarScope ); CheckDuplVars( pFunc->pStatics, szVarName, iVarScope ); if( !( iVarScope == VS_PRIVATE || iVarScope == VS_PUBLIC ) ) - CheckDuplVars( pFunc->pMemvars, szVarName, iVarScope ); + CheckDuplVars( pFunc->pMemvars, szVarName, iVarScope ); } else /* variable defined in a codeblock */ @@ -1861,148 +1861,148 @@ void AddVar( char * szVarName ) if( _bAutoMemvarAssume || iVarScope == VS_MEMVAR ) { - /** add this variable to the list of MEMVAR variables - */ - if( ! pFunc->pMemvars ) - pFunc->pMemvars = pVar; - else - { - pLastVar = pFunc->pMemvars; - while( pLastVar->pNext ) - pLastVar = pLastVar->pNext; - pLastVar->pNext = pVar; - } + /** add this variable to the list of MEMVAR variables + */ + if( ! pFunc->pMemvars ) + pFunc->pMemvars = pVar; + else + { + pLastVar = pFunc->pMemvars; + while( pLastVar->pNext ) + pLastVar = pLastVar->pNext; + pLastVar->pNext = pVar; + } } switch( iVarScope ) { - case VS_MEMVAR: - /* variable declared in MEMVAR statement */ - break; - case (VS_PARAMETER | VS_PRIVATE): - { - BOOL bNewParameter = FALSE; + case VS_MEMVAR: + /* variable declared in MEMVAR statement */ + break; + case (VS_PARAMETER | VS_PRIVATE): + { + BOOL bNewParameter = FALSE; - if( ++functions.pLast->wParamNum > functions.pLast->wParamCount ) - { - functions.pLast->wParamCount =functions.pLast->wParamNum; - bNewParameter = TRUE; - } + if( ++functions.pLast->wParamNum > functions.pLast->wParamCount ) + { + functions.pLast->wParamCount =functions.pLast->wParamNum; + bNewParameter = TRUE; + } - pSym =GetSymbol( szVarName, &wPos ); /* check if symbol exists already */ - if( ! pSym ) - pSym =AddSymbol( yy_strdup(szVarName), &wPos ); - pSym->cScope |=VS_MEMVAR; - GenPCode3( HB_P_PARAMETER, LOBYTE(wPos), HIBYTE(wPos) ); - GenPCode1( LOBYTE(functions.pLast->wParamNum) ); + pSym =GetSymbol( szVarName, &wPos ); /* check if symbol exists already */ + if( ! pSym ) + pSym =AddSymbol( yy_strdup(szVarName), &wPos ); + pSym->cScope |=VS_MEMVAR; + GenPCode3( HB_P_PARAMETER, LOBYTE(wPos), HIBYTE(wPos) ); + GenPCode1( LOBYTE(functions.pLast->wParamNum) ); - /* Add this variable to the local variables list - this will - * allow to use the correct positions for real local variables. - * The name of variable have to be hidden because we should - * not find this name on the local variables list. - * We have to use the new structure because it is used in - * memvars list already. - */ - if( bNewParameter ) - { - pVar = ( PVAR ) OurMalloc( sizeof( VAR ) ); - pVar->szName = yy_strdup( szVarName ); - pVar->szAlias = NULL; - pVar->cType = cVarType; - pVar->iUsed = 0; - pVar->pNext = NULL; - pVar->szName[ 0 ] ='!'; - if( ! pFunc->pLocals ) - pFunc->pLocals = pVar; - else - { - pLastVar = pFunc->pLocals; - while( pLastVar->pNext ) - pLastVar = pLastVar->pNext; - pLastVar->pNext = pVar; - } - } - } - break; - case VS_PRIVATE: - { - PushSymbol(yy_strdup("__MVPRIVATE"), 1); - PushNil(); - PushSymbol( yy_strdup(szVarName), 0 ); - Do( 1 ); - pSym =GetSymbol( szVarName, NULL ); - pSym->cScope |=VS_MEMVAR; - } - break; - case VS_PUBLIC: - { - PushSymbol(yy_strdup("__MVPUBLIC"), 1); - PushNil(); - PushSymbol( yy_strdup(szVarName), 0 ); - Do( 1 ); - pSym =GetSymbol( szVarName, NULL ); - pSym->cScope |=VS_MEMVAR; - } - break; + /* Add this variable to the local variables list - this will + * allow to use the correct positions for real local variables. + * The name of variable have to be hidden because we should + * not find this name on the local variables list. + * We have to use the new structure because it is used in + * memvars list already. + */ + if( bNewParameter ) + { + pVar = ( PVAR ) OurMalloc( sizeof( VAR ) ); + pVar->szName = yy_strdup( szVarName ); + pVar->szAlias = NULL; + pVar->cType = cVarType; + pVar->iUsed = 0; + pVar->pNext = NULL; + pVar->szName[ 0 ] ='!'; + if( ! pFunc->pLocals ) + pFunc->pLocals = pVar; + else + { + pLastVar = pFunc->pLocals; + while( pLastVar->pNext ) + pLastVar = pLastVar->pNext; + pLastVar->pNext = pVar; + } + } + } + break; + case VS_PRIVATE: + { + PushSymbol(yy_strdup("__MVPRIVATE"), 1); + PushNil(); + PushSymbol( yy_strdup(szVarName), 0 ); + Do( 1 ); + pSym =GetSymbol( szVarName, NULL ); + pSym->cScope |=VS_MEMVAR; + } + break; + case VS_PUBLIC: + { + PushSymbol(yy_strdup("__MVPUBLIC"), 1); + PushNil(); + PushSymbol( yy_strdup(szVarName), 0 ); + Do( 1 ); + pSym =GetSymbol( szVarName, NULL ); + pSym->cScope |=VS_MEMVAR; + } + break; } } else { switch( iVarScope ) { - case VS_LOCAL: - case VS_PARAMETER: - { WORD wLocal = 1; + case VS_LOCAL: + case VS_PARAMETER: + { WORD wLocal = 1; - if( ! pFunc->pLocals ) - pFunc->pLocals = pVar; - else - { - pLastVar = pFunc->pLocals; - while( pLastVar->pNext ) - { - pLastVar = pLastVar->pNext; - wLocal++; - } - pLastVar->pNext = pVar; - } - if( iVarScope == VS_PARAMETER ) - { - ++functions.pLast->wParamCount; - functions.pLast->bFlags |= FUN_USES_LOCAL_PARAMS; - } - if( _bDebugInfo ) - { - GenPCode3( HB_P_LOCALNAME, LOBYTE( wLocal ), HIBYTE( wLocal ) ); - GenPCodeN( (BYTE *)szVarName, strlen( szVarName ) ); - GenPCode1( 0 ); - } - } - break; + if( ! pFunc->pLocals ) + pFunc->pLocals = pVar; + else + { + pLastVar = pFunc->pLocals; + while( pLastVar->pNext ) + { + pLastVar = pLastVar->pNext; + wLocal++; + } + pLastVar->pNext = pVar; + } + if( iVarScope == VS_PARAMETER ) + { + ++functions.pLast->wParamCount; + functions.pLast->bFlags |= FUN_USES_LOCAL_PARAMS; + } + if( _bDebugInfo ) + { + GenPCode3( HB_P_LOCALNAME, LOBYTE( wLocal ), HIBYTE( wLocal ) ); + GenPCodeN( (BYTE *)szVarName, strlen( szVarName ) ); + GenPCode1( 0 ); + } + } + break; - case VS_STATIC: - if( ! pFunc->pStatics ) - pFunc->pStatics = pVar; - else - { - pLastVar = pFunc->pStatics; - while( pLastVar->pNext ) - pLastVar = pLastVar->pNext; - pLastVar->pNext = pVar; - } - break; + case VS_STATIC: + if( ! pFunc->pStatics ) + pFunc->pStatics = pVar; + else + { + pLastVar = pFunc->pStatics; + while( pLastVar->pNext ) + pLastVar = pLastVar->pNext; + pLastVar->pNext = pVar; + } + break; - case VS_FIELD: - if( ! pFunc->pFields ) - pFunc->pFields = pVar; - else - { - pLastVar = pFunc->pFields; - while( pLastVar->pNext ) - pLastVar = pLastVar->pNext; - pLastVar->pNext = pVar; - } - break; + case VS_FIELD: + if( ! pFunc->pFields ) + pFunc->pFields = pVar; + else + { + pLastVar = pFunc->pFields; + while( pLastVar->pNext ) + pLastVar = pLastVar->pNext; + pLastVar->pNext = pVar; + } + break; } } @@ -2120,21 +2120,21 @@ int Include( char * szFileName, PATHNAMES *pSearch ) if( pSearch ) { FILENAME *pFileName =SplitFilename( szFileName ); - char szFName[ _POSIX_PATH_MAX ]; /* filename to parse */ + char szFName[ _POSIX_PATH_MAX ]; /* filename to parse */ pFileName->name =szFileName; pFileName->extension =NULL; while( pSearch && !yyin ) { - pFileName->path =pSearch->szPath; - MakeFilename( szFName, pFileName ); - yyin = fopen( szFName, "r" ); - if( ! yyin ) - { - pSearch = pSearch->pNext; - if( ! pSearch ) - return 0; - } + pFileName->path =pSearch->szPath; + MakeFilename( szFName, pFileName ); + yyin = fopen( szFName, "r" ); + if( ! yyin ) + { + pSearch = pSearch->pNext; + if( ! pSearch ) + return 0; + } } OurFree( (void *) pFileName ); } @@ -2181,7 +2181,7 @@ int yywrap( void ) /* handles the EOF of the currently processed file */ files.pLast = ( PFILE ) ( ( PFILE ) files.pLast )->pPrev; iLine = files.pLast->iLine; if( ! _bQuiet ) - printf( "\nparsing file %s\n", files.pLast->szFileName ); + printf( "\nparsing file %s\n", files.pLast->szFileName ); #ifdef __cplusplus yy_delete_buffer( (YY_BUFFER_STATE) ( ( PFILE ) pLast )->pBuffer ); #else @@ -2274,7 +2274,7 @@ PFUNCTION FunctionNew( char *szName, SYMBOLSCOPE cScope ) */ void FunDef( char * szFunName, SYMBOLSCOPE cScope, int iType ) { - PCOMSYMBOL pSym; + PCOMSYMBOL pSym; PFUNCTION pFunc; char * *pFunction; @@ -2283,8 +2283,8 @@ void FunDef( char * szFunName, SYMBOLSCOPE cScope, int iType ) { /* The name of a function/procedure is already defined */ if( ( pFunc != functions.pFirst ) || _bStartProc ) - /* it is not a starting procedure that was automatically created */ - GenError( _szCErrors, 'E', ERR_FUNC_DUPL, szFunName, NULL ); + /* it is not a starting procedure that was automatically created */ + GenError( _szCErrors, 'E', ERR_FUNC_DUPL, szFunName, NULL ); } pFunction = (char * *)RESERVED_FUNC( szFunName ); @@ -2293,7 +2293,7 @@ void FunDef( char * szFunName, SYMBOLSCOPE cScope, int iType ) /* We are ignoring it when it is the name of PRG file and we are * not creating implicit starting procedure */ - GenError( _szCErrors, 'E', ERR_FUNC_RESERVED, *pFunction, szFunName ); + GenError( _szCErrors, 'E', ERR_FUNC_RESERVED, *pFunction, szFunName ); } FixReturns(); /* fix all previous function returns offsets */ @@ -2304,7 +2304,7 @@ void FunDef( char * szFunName, SYMBOLSCOPE cScope, int iType ) pSym = AddSymbol( szFunName, NULL ); if( cScope != FS_PUBLIC ) -/* pSym->cScope = FS_PUBLIC; */ +/* pSym->cScope = FS_PUBLIC; */ /* else */ pSym->cScope |= cScope; /* we may have a non public function and a object message */ @@ -2364,7 +2364,7 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag char chr; BOOL bEndProcRequired; - FILE * yyc; /* file handle for C output */ + FILE * yyc; /* file handle for C output */ #ifdef __WATCOMC__ szName =NULL; /* Watcom complains about unreachable code in if(0) */ @@ -2392,12 +2392,12 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag while( pFunc ) { if( pFunc->cScope & FS_STATIC || pFunc->cScope & FS_INIT || pFunc->cScope & FS_EXIT ) - fprintf( yyc, "static " ); + fprintf( yyc, "static " ); if( pFunc == _pInitFunc ) - fprintf( yyc, "HARBOUR hb_INITSTATICS( void );\n" ); /* NOTE: hb_ intentionally in lower case */ + fprintf( yyc, "HARBOUR hb_INITSTATICS( void );\n" ); /* NOTE: hb_ intentionally in lower case */ else - fprintf( yyc, "HARBOUR HB_%s( void );\n", pFunc->szName ); + fprintf( yyc, "HARBOUR HB_%s( void );\n", pFunc->szName ); pFunc = pFunc->pNext; } /* write functions prototypes for called functions outside this PRG */ @@ -2406,7 +2406,7 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag { pFTemp = GetFunction( pFunc->szName ); if( ! pFTemp || pFTemp == functions.pFirst ) - fprintf( yyc, "HARBOUR HB_%s( void );\n", pFunc->szName ); + fprintf( yyc, "HARBOUR HB_%s( void );\n", pFunc->szName ); pFunc = pFunc->pNext; } @@ -2424,47 +2424,47 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag { if( pSym->szName[ 0 ] == '(' ) { - /* Since the normal function cannot be INIT and EXIT at the same time - * we are using these two bits to mark the special function used to - * initialize static variables - */ - fprintf( yyc, "{ \"(_INITSTATICS)\", FS_INIT | FS_EXIT, hb_INITSTATICS, 0}" ); /* NOTE: hb_ intentionally in lower case */ + /* Since the normal function cannot be INIT and EXIT at the same time + * we are using these two bits to mark the special function used to + * initialize static variables + */ + fprintf( yyc, "{ \"(_INITSTATICS)\", FS_INIT | FS_EXIT, hb_INITSTATICS, 0}" ); /* NOTE: hb_ intentionally in lower case */ } else { - fprintf( yyc, "{ \"%s\", ", pSym->szName ); + fprintf( yyc, "{ \"%s\", ", pSym->szName ); - if( pSym->cScope & FS_STATIC ) - fprintf( yyc, "FS_STATIC" ); + if( pSym->cScope & FS_STATIC ) + fprintf( yyc, "FS_STATIC" ); - else if( pSym->cScope & FS_INIT ) - fprintf( yyc, "FS_INIT" ); + else if( pSym->cScope & FS_INIT ) + fprintf( yyc, "FS_INIT" ); - else if( pSym->cScope & FS_EXIT ) - fprintf( yyc, "FS_EXIT" ); + else if( pSym->cScope & FS_EXIT ) + fprintf( yyc, "FS_EXIT" ); - else - fprintf( yyc, "FS_PUBLIC" ); + else + fprintf( yyc, "FS_PUBLIC" ); - if( pSym->cScope & VS_MEMVAR ) - fprintf( yyc, " | FS_MEMVAR" ); + if( pSym->cScope & VS_MEMVAR ) + fprintf( yyc, " | FS_MEMVAR" ); - if( ( pSym->cScope != FS_MESSAGE ) && ( pSym->cScope & FS_MESSAGE ) ) /* only for non public symbols */ - fprintf( yyc, " | FS_MESSAGE" ); + if( ( pSym->cScope != FS_MESSAGE ) && ( pSym->cScope & FS_MESSAGE ) ) /* only for non public symbols */ + fprintf( yyc, " | FS_MESSAGE" ); - /* specify the function address if it is a defined function or an - external called function */ - if( GetFunction( pSym->szName ) ) /* is it a function defined in this module */ - fprintf( yyc, ", HB_%s, 0 }", pSym->szName ); - else if( GetFuncall( pSym->szName ) ) /* is it a function called from this module */ - fprintf( yyc, ", HB_%s, 0 }", pSym->szName ); - else - fprintf( yyc, ", 0, 0 }" ); /* memvar */ + /* specify the function address if it is a defined function or an + external called function */ + if( GetFunction( pSym->szName ) ) /* is it a function defined in this module */ + fprintf( yyc, ", HB_%s, 0 }", pSym->szName ); + else if( GetFuncall( pSym->szName ) ) /* is it a function called from this module */ + fprintf( yyc, ", HB_%s, 0 }", pSym->szName ); + else + fprintf( yyc, ", 0, 0 }" ); /* memvar */ } ++wSym; if( pSym != symbols.pLast ) - fprintf( yyc, ",\n" ); + fprintf( yyc, ",\n" ); pSym = pSym->pNext; } @@ -2479,736 +2479,736 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag while( pFunc ) { if( pFunc->cScope != FS_PUBLIC ) - fprintf( yyc, "static " ); + fprintf( yyc, "static " ); if( pFunc == _pInitFunc ) /* Is it (_INITSTATICS) */ - fprintf( yyc, "HARBOUR hb_INITSTATICS( void )\n{\n static BYTE pcode[] = { \n" ); /* NOTE: hb_ intentionally in lower case */ + fprintf( yyc, "HARBOUR hb_INITSTATICS( void )\n{\n static BYTE pcode[] = { \n" ); /* NOTE: hb_ intentionally in lower case */ else - fprintf( yyc, "HARBOUR HB_%s( void )\n{\n static BYTE pcode[] = { \n", pFunc->szName ); + fprintf( yyc, "HARBOUR HB_%s( void )\n{\n static BYTE pcode[] = { \n", pFunc->szName ); bEndProcRequired =TRUE; lPCodePos = 0; while( lPCodePos < pFunc->lPCodePos ) { - switch( pFunc->pCode[ lPCodePos ] ) - { - case HB_P_AND: - fprintf( yyc, " HB_P_AND,\n" ); - lPCodePos++; - break; - - case HB_P_ARRAYAT: - fprintf( yyc, " HB_P_ARRAYAT,\n" ); - lPCodePos++; - break; - - case HB_P_ARRAYPUT: - fprintf( yyc, " HB_P_ARRAYPUT,\n" ); - lPCodePos++; - break; - - case HB_P_DEC: - fprintf( yyc, " HB_P_DEC,\n" ); - lPCodePos++; - break; - - case HB_P_DIMARRAY: - w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_DIMARRAY, %i, %i,\t/* %i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], w ); - lPCodePos += 3; - break; - - case HB_P_DIVIDE: - fprintf( yyc, " HB_P_DIVIDE,\n" ); - lPCodePos++; - break; - - case HB_P_DO: - fprintf( yyc, " HB_P_DO, %i, %i,\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ] ); - lPCodePos += 3; - break; - - case HB_P_DUPLICATE: - fprintf( yyc, " HB_P_DUPLICATE,\n" ); - lPCodePos++; - break; - - case HB_P_DUPLTWO: - fprintf( yyc, " HB_P_DUPLTWO,\n" ); - lPCodePos++; - break; - - case HB_P_EQUAL: - fprintf( yyc, " HB_P_EQUAL,\n" ); - lPCodePos++; - break; - - case HB_P_EXACTLYEQUAL: - fprintf( yyc, " HB_P_EXACTLYEQUAL,\n" ); - lPCodePos++; - break; - - case HB_P_ENDBLOCK: - --iNestedCodeblock; - fprintf( yyc, " HB_P_ENDBLOCK,\n" ); - lPCodePos++; - break; - - case HB_P_ENDPROC: - lPCodePos++; - if( lPCodePos == pFunc->lPCodePos ) - { - bEndProcRequired =FALSE; - fprintf( yyc, " HB_P_ENDPROC\n" ); - } - else - fprintf( yyc, " HB_P_ENDPROC,\n" ); - break; - - case HB_P_FALSE: - fprintf( yyc, " HB_P_FALSE,\n" ); - lPCodePos++; - break; - - case HB_P_FORTEST: /* ER For tests. Step > 0 LESS */ - /* Step < 0 GREATER */ - fprintf( yyc, " HB_P_FORTEST,\n" ); - lPCodePos++; - break; - - case HB_P_FRAME: - { - PVAR pLocal = pFunc->pLocals; - BYTE bLocals = 0; - - while( pLocal ) - { - pLocal = pLocal->pNext; - bLocals++; - } - - if( bLocals || pFunc->wParamCount ) - fprintf( yyc, " HB_P_FRAME, %i, %i,\t\t/* locals, params */\n", - bLocals - pFunc->wParamCount, - pFunc->wParamCount ); - lPCodePos += 3; - } - break; - - case HB_P_FUNCPTR: - fprintf( yyc, " HB_P_FUNCPTR,\n" ); - lPCodePos++; - break; - - case HB_P_FUNCTION: - fprintf( yyc, " HB_P_FUNCTION, %i, %i,\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ] ); - lPCodePos += 3; - break; - - case HB_P_GENARRAY: - w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_GENARRAY, %i, %i,\t/* %i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], w ); - lPCodePos += 3; - break; - - case HB_P_GREATER: - fprintf( yyc, " HB_P_GREATER,\n" ); - lPCodePos++; - break; - - case HB_P_GREATEREQUAL: - fprintf( yyc, " HB_P_GREATEREQUAL,\n" ); - lPCodePos++; - break; - - case HB_P_INC: - fprintf( yyc, " HB_P_INC,\n" ); - lPCodePos++; - break; - - case HB_P_INSTRING: - fprintf( yyc, " HB_P_INSTRING,\n" ); - lPCodePos++; - break; - - case HB_P_JUMP: - /*if( 1 ) (lPCodePos + 3) < pFunc->lPCodePos ) */ - { - w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_JUMP, %i, %i,\t/* %i (abs: %05li) */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], w, lPCodePos + ( w ? w: 3 ) ); - } - lPCodePos += 3; - break; - - case HB_P_JUMPFALSE: - w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_JUMPFALSE, %i, %i,\t/* %i (abs: %05li) */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], w, lPCodePos + ( w ? w: 3 ) ); - lPCodePos += 3; - break; - - case HB_P_JUMPTRUE: - w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_JUMPTRUE, %i, %i,\t/* %i (abs: %05li) */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], w, lPCodePos + ( w ? w: 3 ) ); - lPCodePos += 3; - break; - - case HB_P_LESS: - fprintf( yyc, " HB_P_LESS,\n" ); - lPCodePos++; - break; - - case HB_P_LESSEQUAL: - fprintf( yyc, " HB_P_LESSEQUAL,\n" ); - lPCodePos++; - break; - - case HB_P_LINE: - fprintf( yyc, "/* %05li */", lPCodePos ); - w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_LINE, %i, %i,\t\t/* %i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], w ); - lPCodePos += 3; - break; - - case HB_P_LOCALNAME: - fprintf( yyc, " HB_P_LOCALNAME, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - ( char * ) pFunc->pCode + lPCodePos + 3 ); - lPCodePos += 3; - while( pFunc->pCode[ lPCodePos ] ) - { - chr = pFunc->pCode[ lPCodePos++ ]; - if( chr == '\'' || chr == '\\') - fprintf( yyc, " \'\\%c\',", chr ); - else - fprintf( yyc, " \'%c\',", chr ); - } - fprintf( yyc, " 0,\n" ); - lPCodePos++; - break; - - case HB_P_MESSAGE: - { - WORD wFixPos; - - wSym = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wSym ); - fprintf( yyc, " HB_P_MESSAGE, %i, %i, /* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wSym )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_MINUS: - fprintf( yyc, " HB_P_MINUS,\n" ); - lPCodePos++; - break; - - case HB_P_MODULENAME: - fprintf( yyc, " HB_P_MODULENAME, /* %s */\n", - ( char * ) pFunc->pCode + lPCodePos++ + 1 ); - while( pFunc->pCode[ lPCodePos ] ) - { - chr = pFunc->pCode[ lPCodePos++ ]; - if( chr == '\'' || chr == '\\') - fprintf( yyc, " \'\\%c\',", chr ); - else - fprintf( yyc, " \'%c\',", chr ); - } - fprintf( yyc, " 0,\n" ); - lPCodePos++; - break; - - case HB_P_MODULUS: - fprintf( yyc, " HB_P_MODULUS,\n" ); - lPCodePos++; - break; - - case HB_P_MULT: - fprintf( yyc, " HB_P_MULT,\n" ); - lPCodePos++; - break; - - case HB_P_NEGATE: - fprintf( yyc, " HB_P_NEGATE,\n" ); - lPCodePos++; - break; - - case HB_P_NOT: - fprintf( yyc, " HB_P_NOT,\n" ); - lPCodePos++; - break; - - case HB_P_NOTEQUAL: - fprintf( yyc, " HB_P_NOTEQUAL,\n" ); - lPCodePos++; - break; - - case HB_P_OR: - fprintf( yyc, " HB_P_OR,\n" ); - lPCodePos++; - break; - - case HB_P_PARAMETER: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_PARAMETER, %i, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - pFunc->pCode[ lPCodePos + 3 ], - GetSymbolOrd( wVar )->szName ); - lPCodePos += 4; - } - break; - - case HB_P_PLUS: - fprintf( yyc, " HB_P_PLUS,\n" ); - lPCodePos++; - break; - - case HB_P_POP: - fprintf( yyc, " HB_P_POP,\n" ); - lPCodePos++; - break; - - case HB_P_POPALIAS: - fprintf( yyc, " HB_P_POPALIAS,\n" ); - lPCodePos++; - break; - - case HB_P_POPALIASEDFIELD: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_POPALIASEDFIELD, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_POPFIELD: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_POPFIELD, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_POPLOCAL: - { - SHORT wVar = * ( ( SHORT *) &(pFunc->pCode )[ lPCodePos + 1 ] ); - /* Variable with negative order are local variables - * referenced in a codeblock -handle it with care - */ - if( iNestedCodeblock ) - { - /* we are accesing variables within a codeblock */ - /* the names of codeblock variable are lost */ - if( wVar < 0 ) - fprintf( yyc, " HB_P_POPLOCAL, %i, %i,\t/* localvar%i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - -wVar ); - else - fprintf( yyc, " HB_P_POPLOCAL, %i, %i,\t/* codeblockvar%i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - wVar ); - } - else - fprintf( yyc, " HB_P_POPLOCAL, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - GetVar( pFunc->pLocals, wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_POPMEMVAR: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_POPMEMVAR, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_POPSTATIC: - { - PVAR pVar; - PFUNCTION pTmp = functions.pFirst; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - while( pTmp->pNext && pTmp->pNext->wStaticsBase < wVar ) - pTmp =pTmp->pNext; - pVar = GetVar( pTmp->pStatics, wVar - pTmp->wStaticsBase ); - fprintf( yyc, " HB_P_POPSTATIC, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - pVar->szName ); - lPCodePos += 3; - } - break; - - case HB_P_POWER: - fprintf( yyc, " HB_P_POWER,\n" ); - lPCodePos++; - break; - - case HB_P_PUSHALIAS: - fprintf( yyc, " HB_P_PUSHALIAS,\n" ); - lPCodePos++; - break; - - case HB_P_PUSHALIASEDFIELD: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_PUSHALIASEDFIELD, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHBLOCK: - ++iNestedCodeblock; - fprintf( yyc, " HB_P_PUSHBLOCK, %i, %i,\t/* %i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256 ); - w = * ( ( WORD *) &( pFunc->pCode [ lPCodePos + 3 ] ) ); - fprintf( yyc, " %i, %i, \t/* number of local parameters (%i) */\n", - pFunc->pCode[ lPCodePos + 3 ], - pFunc->pCode[ lPCodePos + 4 ], w ); - wVar = * ( ( WORD *) &( pFunc->pCode [ lPCodePos + 5 ] ) ); - fprintf( yyc, " %i, %i, \t/* number of local variables (%i) */\n", - pFunc->pCode[ lPCodePos + 5 ], - pFunc->pCode[ lPCodePos + 6 ], wVar ); - lPCodePos += 7; /* codeblock size + number of parameters + number of local variables */ - /* create the table of referenced local variables */ - while( wVar-- ) - { - w = * ( ( WORD *) &( pFunc->pCode [ lPCodePos ] ) ); - fprintf( yyc, " %i, %i, \t/* %s */\n", - pFunc->pCode[ lPCodePos ], - pFunc->pCode[ lPCodePos + 1 ], - GetVar( pFunc->pLocals, w )->szName ); - lPCodePos +=2; - } - break; - - case HB_P_PUSHDOUBLE: - { - int i; - ++lPCodePos; - fprintf( yyc, " HB_P_PUSHDOUBLE, " ); - for( i = 0; i < sizeof( double ) + sizeof( BYTE ); ++i ) - fprintf( yyc, "%i, ", ( ( BYTE * ) pFunc->pCode )[ lPCodePos + i ] ); - fprintf( yyc, "/* %.*f, %d */\n", - *( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ), - *( ( double * ) &( pFunc->pCode[ lPCodePos ] ) ), - *( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ) ); - lPCodePos += sizeof( double ) + sizeof( BYTE ); - } - break; - - case HB_P_PUSHFIELD: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_PUSHFIELD, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHINT: - fprintf( yyc, " HB_P_PUSHINT, %i, %i, /* %i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256 ); - lPCodePos += 3; - break; - - case HB_P_PUSHLOCAL: - { - SHORT wVar = * ( ( SHORT *) &(pFunc->pCode )[ lPCodePos + 1 ] ); - /* Variable with negative order are local variables - * referenced in a codeblock -handle it with care - */ - if( iNestedCodeblock ) - { - /* we are accesing variables within a codeblock */ - /* the names of codeblock variable are lost */ - if( wVar < 0 ) - fprintf( yyc, " HB_P_PUSHLOCAL, %i, %i,\t/* localvar%i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - -wVar ); - else - fprintf( yyc, " HB_P_PUSHLOCAL, %i, %i,\t/* codeblockvar%i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - wVar ); - } - else - fprintf( yyc, " HB_P_PUSHLOCAL, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - GetVar( pFunc->pLocals, wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHLOCALREF: - { - SHORT wVar = * ( ( SHORT *) &(pFunc->pCode )[ lPCodePos + 1 ] ); - /* Variable with negative order are local variables - * referenced in a codeblock -handle it with care - */ - if( iNestedCodeblock ) - { - /* we are accesing variables within a codeblock */ - /* the names of codeblock variable are lost */ - if( wVar < 0 ) - fprintf( yyc, " HB_P_PUSHLOCALREF, %i, %i,\t/* localvar%i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - -wVar ); - else - fprintf( yyc, " HB_P_PUSHLOCALREF, %i, %i,\t/* codeblockvar%i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - wVar ); - } - else - fprintf( yyc, " HB_P_PUSHLOCALREF, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - GetVar( pFunc->pLocals, wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHLONG: - fprintf( yyc, " HB_P_PUSHLONG, %i, %i, %i, %i, /* %li */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - pFunc->pCode[ lPCodePos + 3 ], - pFunc->pCode[ lPCodePos + 4 ], - *( ( long * ) &( pFunc->pCode[ lPCodePos + 1 ] ) ) ); - lPCodePos +=( 1 + sizeof(long) ); - break; - - case HB_P_PUSHMEMVAR: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_PUSHMEMVAR, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHMEMVARREF: - { - WORD wFixPos; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wVar ); - fprintf( yyc, " HB_P_PUSHMEMVARREF, %i, %i,\t/* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wVar )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHNIL: - fprintf( yyc, " HB_P_PUSHNIL,\n" ); - lPCodePos++; - break; - - case HB_P_PUSHSELF: - fprintf( yyc, " HB_P_PUSHSELF,\n" ); - lPCodePos++; - break; - - case HB_P_PUSHSTATIC: - { - PVAR pVar; - PFUNCTION pTmp = functions.pFirst; - - wVar = pFunc->pCode[ lPCodePos + 1 ] +pFunc->pCode[ lPCodePos + 2 ] * 256; - while( pTmp->pNext && pTmp->pNext->wStaticsBase < wVar ) - pTmp =pTmp->pNext; - pVar = GetVar( pTmp->pStatics, wVar - pTmp->wStaticsBase ); - fprintf( yyc, " HB_P_PUSHSTATIC, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - pVar->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHSTATICREF: - { - PVAR pVar; - PFUNCTION pTmp = functions.pFirst; - - wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; - while( pTmp->pNext && pTmp->pNext->wStaticsBase < wVar ) - pTmp =pTmp->pNext; - pVar = GetVar( pTmp->pStatics, wVar - pTmp->wStaticsBase ); - fprintf( yyc, " HB_P_PUSHSTATICREF, %i, %i,\t/* %s */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], - pVar->szName ); - lPCodePos += 3; - } - break; - - case HB_P_PUSHSTR: - wLen = pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256; - fprintf( yyc, " HB_P_PUSHSTR, %i, %i, /* %i */\n", - pFunc->pCode[ lPCodePos + 1 ], - pFunc->pCode[ lPCodePos + 2 ], wLen ); - lPCodePos +=3; - while( wLen-- ) - { - chr = pFunc->pCode[ lPCodePos++ ]; - if( chr == '\'' || chr == '\\') - fprintf( yyc, " \'\\%c\',", chr ); - else - fprintf( yyc, " \'%c\',", chr ); - } - fprintf( yyc, "\n" ); - break; - - case HB_P_PUSHSYM: - { - WORD wFixPos; - - wSym = pFunc->pCode[ lPCodePos + 1 ] + - pFunc->pCode[ lPCodePos + 2 ] * 256; - wFixPos =FixSymbolPos( wSym ); - fprintf( yyc, " HB_P_PUSHSYM, %i, %i, /* %s */\n", - LOBYTE( wFixPos ), - HIBYTE( wFixPos ), - GetSymbolOrd( wSym )->szName ); - lPCodePos += 3; - } - break; - - case HB_P_RETVALUE: - fprintf( yyc, " HB_P_RETVALUE,\n" ); - lPCodePos++; - break; - - case HB_P_SFRAME: - /* we only generate it if there are statics used in this function */ - if( pFunc->bFlags & FUN_USES_STATICS ) - { - GetSymbol( _pInitFunc->szName, &w ); - w = FixSymbolPos( w ); - fprintf( yyc, " HB_P_SFRAME, %i, %i,\t\t/* symbol (_INITSTATICS) */\n", - LOBYTE( w ), HIBYTE( w ) ); - } - lPCodePos += 3; - break; - - case HB_P_STATICS: - { - GetSymbol( _pInitFunc->szName, &w ); - w = FixSymbolPos( w ); - fprintf( yyc, " HB_P_STATICS, %i, %i,\t\t/* symbol (_INITSTATICS) */\n", - LOBYTE( w ), HIBYTE( w ) ); - lPCodePos += 3; - } - break; - - case HB_P_SWAPALIAS: - fprintf( yyc, " HB_P_SWAPALIAS,\n" ); - lPCodePos++; - break; - - case HB_P_TRUE: - fprintf( yyc, " HB_P_TRUE,\n" ); - lPCodePos++; - break; - - case HB_P_ZERO: - fprintf( yyc, " HB_P_ZERO,\n" ); - lPCodePos++; - break; - - default: - printf( "Incorrect pcode value!\n" ); - lPCodePos = pFunc->lPCodePos; - break; - } + switch( pFunc->pCode[ lPCodePos ] ) + { + case HB_P_AND: + fprintf( yyc, " HB_P_AND,\n" ); + lPCodePos++; + break; + + case HB_P_ARRAYAT: + fprintf( yyc, " HB_P_ARRAYAT,\n" ); + lPCodePos++; + break; + + case HB_P_ARRAYPUT: + fprintf( yyc, " HB_P_ARRAYPUT,\n" ); + lPCodePos++; + break; + + case HB_P_DEC: + fprintf( yyc, " HB_P_DEC,\n" ); + lPCodePos++; + break; + + case HB_P_DIMARRAY: + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_DIMARRAY, %i, %i,\t/* %i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], w ); + lPCodePos += 3; + break; + + case HB_P_DIVIDE: + fprintf( yyc, " HB_P_DIVIDE,\n" ); + lPCodePos++; + break; + + case HB_P_DO: + fprintf( yyc, " HB_P_DO, %i, %i,\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ] ); + lPCodePos += 3; + break; + + case HB_P_DUPLICATE: + fprintf( yyc, " HB_P_DUPLICATE,\n" ); + lPCodePos++; + break; + + case HB_P_DUPLTWO: + fprintf( yyc, " HB_P_DUPLTWO,\n" ); + lPCodePos++; + break; + + case HB_P_EQUAL: + fprintf( yyc, " HB_P_EQUAL,\n" ); + lPCodePos++; + break; + + case HB_P_EXACTLYEQUAL: + fprintf( yyc, " HB_P_EXACTLYEQUAL,\n" ); + lPCodePos++; + break; + + case HB_P_ENDBLOCK: + --iNestedCodeblock; + fprintf( yyc, " HB_P_ENDBLOCK,\n" ); + lPCodePos++; + break; + + case HB_P_ENDPROC: + lPCodePos++; + if( lPCodePos == pFunc->lPCodePos ) + { + bEndProcRequired =FALSE; + fprintf( yyc, " HB_P_ENDPROC\n" ); + } + else + fprintf( yyc, " HB_P_ENDPROC,\n" ); + break; + + case HB_P_FALSE: + fprintf( yyc, " HB_P_FALSE,\n" ); + lPCodePos++; + break; + + case HB_P_FORTEST: /* ER For tests. Step > 0 LESS */ + /* Step < 0 GREATER */ + fprintf( yyc, " HB_P_FORTEST,\n" ); + lPCodePos++; + break; + + case HB_P_FRAME: + { + PVAR pLocal = pFunc->pLocals; + BYTE bLocals = 0; + + while( pLocal ) + { + pLocal = pLocal->pNext; + bLocals++; + } + + if( bLocals || pFunc->wParamCount ) + fprintf( yyc, " HB_P_FRAME, %i, %i,\t\t/* locals, params */\n", + bLocals - pFunc->wParamCount, + pFunc->wParamCount ); + lPCodePos += 3; + } + break; + + case HB_P_FUNCPTR: + fprintf( yyc, " HB_P_FUNCPTR,\n" ); + lPCodePos++; + break; + + case HB_P_FUNCTION: + fprintf( yyc, " HB_P_FUNCTION, %i, %i,\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ] ); + lPCodePos += 3; + break; + + case HB_P_GENARRAY: + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_GENARRAY, %i, %i,\t/* %i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], w ); + lPCodePos += 3; + break; + + case HB_P_GREATER: + fprintf( yyc, " HB_P_GREATER,\n" ); + lPCodePos++; + break; + + case HB_P_GREATEREQUAL: + fprintf( yyc, " HB_P_GREATEREQUAL,\n" ); + lPCodePos++; + break; + + case HB_P_INC: + fprintf( yyc, " HB_P_INC,\n" ); + lPCodePos++; + break; + + case HB_P_INSTRING: + fprintf( yyc, " HB_P_INSTRING,\n" ); + lPCodePos++; + break; + + case HB_P_JUMP: + /*if( 1 ) (lPCodePos + 3) < pFunc->lPCodePos ) */ + { + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_JUMP, %i, %i,\t/* %i (abs: %05li) */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], w, lPCodePos + ( w ? w: 3 ) ); + } + lPCodePos += 3; + break; + + case HB_P_JUMPFALSE: + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_JUMPFALSE, %i, %i,\t/* %i (abs: %05li) */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], w, lPCodePos + ( w ? w: 3 ) ); + lPCodePos += 3; + break; + + case HB_P_JUMPTRUE: + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_JUMPTRUE, %i, %i,\t/* %i (abs: %05li) */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], w, lPCodePos + ( w ? w: 3 ) ); + lPCodePos += 3; + break; + + case HB_P_LESS: + fprintf( yyc, " HB_P_LESS,\n" ); + lPCodePos++; + break; + + case HB_P_LESSEQUAL: + fprintf( yyc, " HB_P_LESSEQUAL,\n" ); + lPCodePos++; + break; + + case HB_P_LINE: + fprintf( yyc, "/* %05li */", lPCodePos ); + w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_LINE, %i, %i,\t\t/* %i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], w ); + lPCodePos += 3; + break; + + case HB_P_LOCALNAME: + fprintf( yyc, " HB_P_LOCALNAME, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + ( char * ) pFunc->pCode + lPCodePos + 3 ); + lPCodePos += 3; + while( pFunc->pCode[ lPCodePos ] ) + { + chr = pFunc->pCode[ lPCodePos++ ]; + if( chr == '\'' || chr == '\\') + fprintf( yyc, " \'\\%c\',", chr ); + else + fprintf( yyc, " \'%c\',", chr ); + } + fprintf( yyc, " 0,\n" ); + lPCodePos++; + break; + + case HB_P_MESSAGE: + { + WORD wFixPos; + + wSym = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wSym ); + fprintf( yyc, " HB_P_MESSAGE, %i, %i, /* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wSym )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_MINUS: + fprintf( yyc, " HB_P_MINUS,\n" ); + lPCodePos++; + break; + + case HB_P_MODULENAME: + fprintf( yyc, " HB_P_MODULENAME, /* %s */\n", + ( char * ) pFunc->pCode + lPCodePos++ + 1 ); + while( pFunc->pCode[ lPCodePos ] ) + { + chr = pFunc->pCode[ lPCodePos++ ]; + if( chr == '\'' || chr == '\\') + fprintf( yyc, " \'\\%c\',", chr ); + else + fprintf( yyc, " \'%c\',", chr ); + } + fprintf( yyc, " 0,\n" ); + lPCodePos++; + break; + + case HB_P_MODULUS: + fprintf( yyc, " HB_P_MODULUS,\n" ); + lPCodePos++; + break; + + case HB_P_MULT: + fprintf( yyc, " HB_P_MULT,\n" ); + lPCodePos++; + break; + + case HB_P_NEGATE: + fprintf( yyc, " HB_P_NEGATE,\n" ); + lPCodePos++; + break; + + case HB_P_NOT: + fprintf( yyc, " HB_P_NOT,\n" ); + lPCodePos++; + break; + + case HB_P_NOTEQUAL: + fprintf( yyc, " HB_P_NOTEQUAL,\n" ); + lPCodePos++; + break; + + case HB_P_OR: + fprintf( yyc, " HB_P_OR,\n" ); + lPCodePos++; + break; + + case HB_P_PARAMETER: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_PARAMETER, %i, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + pFunc->pCode[ lPCodePos + 3 ], + GetSymbolOrd( wVar )->szName ); + lPCodePos += 4; + } + break; + + case HB_P_PLUS: + fprintf( yyc, " HB_P_PLUS,\n" ); + lPCodePos++; + break; + + case HB_P_POP: + fprintf( yyc, " HB_P_POP,\n" ); + lPCodePos++; + break; + + case HB_P_POPALIAS: + fprintf( yyc, " HB_P_POPALIAS,\n" ); + lPCodePos++; + break; + + case HB_P_POPALIASEDFIELD: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_POPALIASEDFIELD, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_POPFIELD: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_POPFIELD, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_POPLOCAL: + { + SHORT wVar = * ( ( SHORT *) &(pFunc->pCode )[ lPCodePos + 1 ] ); + /* Variable with negative order are local variables + * referenced in a codeblock -handle it with care + */ + if( iNestedCodeblock ) + { + /* we are accesing variables within a codeblock */ + /* the names of codeblock variable are lost */ + if( wVar < 0 ) + fprintf( yyc, " HB_P_POPLOCAL, %i, %i,\t/* localvar%i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + -wVar ); + else + fprintf( yyc, " HB_P_POPLOCAL, %i, %i,\t/* codeblockvar%i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + wVar ); + } + else + fprintf( yyc, " HB_P_POPLOCAL, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + GetVar( pFunc->pLocals, wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_POPMEMVAR: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_POPMEMVAR, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_POPSTATIC: + { + PVAR pVar; + PFUNCTION pTmp = functions.pFirst; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + while( pTmp->pNext && pTmp->pNext->wStaticsBase < wVar ) + pTmp =pTmp->pNext; + pVar = GetVar( pTmp->pStatics, wVar - pTmp->wStaticsBase ); + fprintf( yyc, " HB_P_POPSTATIC, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + pVar->szName ); + lPCodePos += 3; + } + break; + + case HB_P_POWER: + fprintf( yyc, " HB_P_POWER,\n" ); + lPCodePos++; + break; + + case HB_P_PUSHALIAS: + fprintf( yyc, " HB_P_PUSHALIAS,\n" ); + lPCodePos++; + break; + + case HB_P_PUSHALIASEDFIELD: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_PUSHALIASEDFIELD, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHBLOCK: + ++iNestedCodeblock; + fprintf( yyc, " HB_P_PUSHBLOCK, %i, %i,\t/* %i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256 ); + w = * ( ( WORD *) &( pFunc->pCode [ lPCodePos + 3 ] ) ); + fprintf( yyc, " %i, %i, \t/* number of local parameters (%i) */\n", + pFunc->pCode[ lPCodePos + 3 ], + pFunc->pCode[ lPCodePos + 4 ], w ); + wVar = * ( ( WORD *) &( pFunc->pCode [ lPCodePos + 5 ] ) ); + fprintf( yyc, " %i, %i, \t/* number of local variables (%i) */\n", + pFunc->pCode[ lPCodePos + 5 ], + pFunc->pCode[ lPCodePos + 6 ], wVar ); + lPCodePos += 7; /* codeblock size + number of parameters + number of local variables */ + /* create the table of referenced local variables */ + while( wVar-- ) + { + w = * ( ( WORD *) &( pFunc->pCode [ lPCodePos ] ) ); + fprintf( yyc, " %i, %i, \t/* %s */\n", + pFunc->pCode[ lPCodePos ], + pFunc->pCode[ lPCodePos + 1 ], + GetVar( pFunc->pLocals, w )->szName ); + lPCodePos +=2; + } + break; + + case HB_P_PUSHDOUBLE: + { + int i; + ++lPCodePos; + fprintf( yyc, " HB_P_PUSHDOUBLE, " ); + for( i = 0; i < sizeof( double ) + sizeof( BYTE ); ++i ) + fprintf( yyc, "%i, ", ( ( BYTE * ) pFunc->pCode )[ lPCodePos + i ] ); + fprintf( yyc, "/* %.*f, %d */\n", + *( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ), + *( ( double * ) &( pFunc->pCode[ lPCodePos ] ) ), + *( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ) ); + lPCodePos += sizeof( double ) + sizeof( BYTE ); + } + break; + + case HB_P_PUSHFIELD: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_PUSHFIELD, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHINT: + fprintf( yyc, " HB_P_PUSHINT, %i, %i, /* %i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256 ); + lPCodePos += 3; + break; + + case HB_P_PUSHLOCAL: + { + SHORT wVar = * ( ( SHORT *) &(pFunc->pCode )[ lPCodePos + 1 ] ); + /* Variable with negative order are local variables + * referenced in a codeblock -handle it with care + */ + if( iNestedCodeblock ) + { + /* we are accesing variables within a codeblock */ + /* the names of codeblock variable are lost */ + if( wVar < 0 ) + fprintf( yyc, " HB_P_PUSHLOCAL, %i, %i,\t/* localvar%i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + -wVar ); + else + fprintf( yyc, " HB_P_PUSHLOCAL, %i, %i,\t/* codeblockvar%i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + wVar ); + } + else + fprintf( yyc, " HB_P_PUSHLOCAL, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + GetVar( pFunc->pLocals, wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHLOCALREF: + { + SHORT wVar = * ( ( SHORT *) &(pFunc->pCode )[ lPCodePos + 1 ] ); + /* Variable with negative order are local variables + * referenced in a codeblock -handle it with care + */ + if( iNestedCodeblock ) + { + /* we are accesing variables within a codeblock */ + /* the names of codeblock variable are lost */ + if( wVar < 0 ) + fprintf( yyc, " HB_P_PUSHLOCALREF, %i, %i,\t/* localvar%i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + -wVar ); + else + fprintf( yyc, " HB_P_PUSHLOCALREF, %i, %i,\t/* codeblockvar%i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + wVar ); + } + else + fprintf( yyc, " HB_P_PUSHLOCALREF, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + GetVar( pFunc->pLocals, wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHLONG: + fprintf( yyc, " HB_P_PUSHLONG, %i, %i, %i, %i, /* %li */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + pFunc->pCode[ lPCodePos + 3 ], + pFunc->pCode[ lPCodePos + 4 ], + *( ( long * ) &( pFunc->pCode[ lPCodePos + 1 ] ) ) ); + lPCodePos +=( 1 + sizeof(long) ); + break; + + case HB_P_PUSHMEMVAR: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_PUSHMEMVAR, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHMEMVARREF: + { + WORD wFixPos; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wVar ); + fprintf( yyc, " HB_P_PUSHMEMVARREF, %i, %i,\t/* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wVar )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHNIL: + fprintf( yyc, " HB_P_PUSHNIL,\n" ); + lPCodePos++; + break; + + case HB_P_PUSHSELF: + fprintf( yyc, " HB_P_PUSHSELF,\n" ); + lPCodePos++; + break; + + case HB_P_PUSHSTATIC: + { + PVAR pVar; + PFUNCTION pTmp = functions.pFirst; + + wVar = pFunc->pCode[ lPCodePos + 1 ] +pFunc->pCode[ lPCodePos + 2 ] * 256; + while( pTmp->pNext && pTmp->pNext->wStaticsBase < wVar ) + pTmp =pTmp->pNext; + pVar = GetVar( pTmp->pStatics, wVar - pTmp->wStaticsBase ); + fprintf( yyc, " HB_P_PUSHSTATIC, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + pVar->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHSTATICREF: + { + PVAR pVar; + PFUNCTION pTmp = functions.pFirst; + + wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256; + while( pTmp->pNext && pTmp->pNext->wStaticsBase < wVar ) + pTmp =pTmp->pNext; + pVar = GetVar( pTmp->pStatics, wVar - pTmp->wStaticsBase ); + fprintf( yyc, " HB_P_PUSHSTATICREF, %i, %i,\t/* %s */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], + pVar->szName ); + lPCodePos += 3; + } + break; + + case HB_P_PUSHSTR: + wLen = pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256; + fprintf( yyc, " HB_P_PUSHSTR, %i, %i, /* %i */\n", + pFunc->pCode[ lPCodePos + 1 ], + pFunc->pCode[ lPCodePos + 2 ], wLen ); + lPCodePos +=3; + while( wLen-- ) + { + chr = pFunc->pCode[ lPCodePos++ ]; + if( chr == '\'' || chr == '\\') + fprintf( yyc, " \'\\%c\',", chr ); + else + fprintf( yyc, " \'%c\',", chr ); + } + fprintf( yyc, "\n" ); + break; + + case HB_P_PUSHSYM: + { + WORD wFixPos; + + wSym = pFunc->pCode[ lPCodePos + 1 ] + + pFunc->pCode[ lPCodePos + 2 ] * 256; + wFixPos =FixSymbolPos( wSym ); + fprintf( yyc, " HB_P_PUSHSYM, %i, %i, /* %s */\n", + LOBYTE( wFixPos ), + HIBYTE( wFixPos ), + GetSymbolOrd( wSym )->szName ); + lPCodePos += 3; + } + break; + + case HB_P_RETVALUE: + fprintf( yyc, " HB_P_RETVALUE,\n" ); + lPCodePos++; + break; + + case HB_P_SFRAME: + /* we only generate it if there are statics used in this function */ + if( pFunc->bFlags & FUN_USES_STATICS ) + { + GetSymbol( _pInitFunc->szName, &w ); + w = FixSymbolPos( w ); + fprintf( yyc, " HB_P_SFRAME, %i, %i,\t\t/* symbol (_INITSTATICS) */\n", + LOBYTE( w ), HIBYTE( w ) ); + } + lPCodePos += 3; + break; + + case HB_P_STATICS: + { + GetSymbol( _pInitFunc->szName, &w ); + w = FixSymbolPos( w ); + fprintf( yyc, " HB_P_STATICS, %i, %i,\t\t/* symbol (_INITSTATICS) */\n", + LOBYTE( w ), HIBYTE( w ) ); + lPCodePos += 3; + } + break; + + case HB_P_SWAPALIAS: + fprintf( yyc, " HB_P_SWAPALIAS,\n" ); + lPCodePos++; + break; + + case HB_P_TRUE: + fprintf( yyc, " HB_P_TRUE,\n" ); + lPCodePos++; + break; + + case HB_P_ZERO: + fprintf( yyc, " HB_P_ZERO,\n" ); + lPCodePos++; + break; + + default: + printf( "Incorrect pcode value!\n" ); + lPCodePos = pFunc->lPCodePos; + break; + } } fprintf( yyc, "/* %05li */", lPCodePos ); if( bEndProcRequired ) - fprintf( yyc, " HB_P_ENDPROC };\n\n" ); + fprintf( yyc, " HB_P_ENDPROC };\n\n" ); else - fprintf( yyc, " };\n\n" ); + fprintf( yyc, " };\n\n" ); fprintf( yyc, " hb_vmExecute( pcode, symbols );\n}\n\n" ); pFunc = pFunc->pNext; } @@ -3315,7 +3315,7 @@ void GenExterns( void ) /* generates the symbols for the EXTERN names */ if( GetSymbol( pExterns->szName, NULL ) ) { if( ! GetFuncall( pExterns->szName ) ) - AddFunCall( pExterns->szName ); + AddFunCall( pExterns->szName ); } else { @@ -3335,13 +3335,13 @@ PFUNCTION GetFuncall( char * szFunctionName ) /* returns a previously called def while( pFunc ) { if( ! strcmp( pFunc->szName, szFunctionName ) ) - return pFunc; + return pFunc; else { - if( pFunc->pNext ) - pFunc = pFunc->pNext; - else - return 0; + if( pFunc->pNext ) + pFunc = pFunc->pNext; + else + return 0; } } return 0; @@ -3354,13 +3354,13 @@ PFUNCTION GetFunction( char * szFunctionName ) /* returns a previously defined f while( pFunc ) { if( ! strcmp( pFunc->szName, szFunctionName ) ) - return pFunc; + return pFunc; else { - if( pFunc->pNext ) - pFunc = pFunc->pNext; - else - return 0; + if( pFunc->pNext ) + pFunc = pFunc->pNext; + else + return 0; } } return 0; @@ -3384,30 +3384,30 @@ WORD GetVarPos( PVAR pVars, char * szVarName ) /* returns the order + 1 of a var { if( pVars->szName && ! strcmp( pVars->szName, szVarName ) ) { - if( _bWarnings ) - { - PSTACK_VAL_TYPE pNewStackType; + if( _bWarnings ) + { + PSTACK_VAL_TYPE pNewStackType; - pVars->iUsed = 1; + pVars->iUsed = 1; - pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); - pNewStackType->cType = pVars->cType; - pNewStackType->pPrev = pStackValType; + pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); + pNewStackType->cType = pVars->cType; + pNewStackType->pPrev = pStackValType; - pStackValType = pNewStackType; - debug_msg( "\n* *GetVarPos()\n", NULL ); - } - return wVar; + pStackValType = pNewStackType; + debug_msg( "\n* *GetVarPos()\n", NULL ); + } + return wVar; } else { - if( pVars->pNext ) - { - pVars = pVars->pNext; - wVar++; - } - else - return 0; + if( pVars->pNext ) + { + pVars = pVars->pNext; + wVar++; + } + else + return 0; } } return 0; @@ -3436,61 +3436,61 @@ int GetLocalVarPos( char * szVarName ) /* returns the order + 1 of a variable if pFunc =pFunc->pOwner; while( pFunc ) { - iVar =GetVarPos( pFunc->pLocals, szVarName ); - if( iVar ) - { - if( pFunc->pOwner ) - /* this variable is defined in a parent codeblock - * It is not possible to access a parameter of a codeblock in which - * the current codeblock is defined - */ - GenError( _szCErrors, 'E', ERR_OUTER_VAR, szVarName, NULL ); - else - { - /* We want to access a local variable defined in a function that - * owns this codeblock. We cannot access this variable in a normal - * way because at runtime the stack base will point to local - * variables of EVAL function. - * The codeblock cannot have static variables then we can use this - * structure to store temporarily all referenced local variables - */ - pFunc =functions.pLast; + iVar =GetVarPos( pFunc->pLocals, szVarName ); + if( iVar ) + { + if( pFunc->pOwner ) + /* this variable is defined in a parent codeblock + * It is not possible to access a parameter of a codeblock in which + * the current codeblock is defined + */ + GenError( _szCErrors, 'E', ERR_OUTER_VAR, szVarName, NULL ); + else + { + /* We want to access a local variable defined in a function that + * owns this codeblock. We cannot access this variable in a normal + * way because at runtime the stack base will point to local + * variables of EVAL function. + * The codeblock cannot have static variables then we can use this + * structure to store temporarily all referenced local variables + */ + pFunc =functions.pLast; - iVar =GetVarPos( pFunc->pStatics, szVarName ); - if( !iVar ) - { - /* this variable was not referenced yet - add it to the list */ - PVAR pVar; + iVar =GetVarPos( pFunc->pStatics, szVarName ); + if( !iVar ) + { + /* this variable was not referenced yet - add it to the list */ + PVAR pVar; - pVar = (PVAR) OurMalloc( sizeof(VAR) ); - pVar->szName = szVarName; - pVar->cType = ' '; - pVar->iUsed = 0; - pVar->pNext = NULL; + pVar = (PVAR) OurMalloc( sizeof(VAR) ); + pVar->szName = szVarName; + pVar->cType = ' '; + pVar->iUsed = 0; + pVar->pNext = NULL; - iVar = 1; /* first variable */ - if( ! pFunc->pStatics ) - pFunc->pStatics = pVar; - else - { - PVAR pLastVar = pFunc->pStatics; + iVar = 1; /* first variable */ + if( ! pFunc->pStatics ) + pFunc->pStatics = pVar; + else + { + PVAR pLastVar = pFunc->pStatics; - ++iVar; /* this will be at least second variable */ - while( pLastVar->pNext ) - { - pLastVar = pLastVar->pNext; - ++iVar; - } - pLastVar->pNext = pVar; - } - } - /* Use negative order to signal that we are accessing a local - * variable from a codeblock - */ - return (-iVar); - } - } - pFunc =pFunc->pOwner; + ++iVar; /* this will be at least second variable */ + while( pLastVar->pNext ) + { + pLastVar = pLastVar->pNext; + ++iVar; + } + pLastVar->pNext = pVar; + } + } + /* Use negative order to signal that we are accessing a local + * variable from a codeblock + */ + return (-iVar); + } + } + pFunc =pFunc->pOwner; } } } @@ -3548,7 +3548,7 @@ int GetFieldVarPos( char *szVarName, PFUNCTION *pOwner ) * where the codeblock is defined */ while( pFunc->pOwner ) - pFunc =pFunc->pOwner; + pFunc =pFunc->pOwner; iVar =GetVarPos( pFunc->pFields, szVarName ); } /* If not found on the list declared in current function then check @@ -3582,7 +3582,7 @@ int GetMemvarPos( char *szVarName ) * where the codeblock is defined */ while( pFunc->pOwner ) - pFunc =pFunc->pOwner; + pFunc =pFunc->pOwner; iVar =GetVarPos( pFunc->pMemvars, szVarName ); } /* if not found on the list declared in current function then check @@ -3614,19 +3614,19 @@ PCOMSYMBOL GetSymbol( char * szSymbolName, WORD * pwPos ) { if( ! strcmp( pSym->szName, szSymbolName ) ) { - if( pwPos ) - *pwPos =wCnt; - return pSym; + if( pwPos ) + *pwPos =wCnt; + return pSym; } else { - if( pSym->pNext ) - { - pSym = pSym->pNext; - ++wCnt; - } - else - return 0; + if( pSym->pNext ) + { + pSym = pSym->pNext; + ++wCnt; + } + else + return 0; } } return 0; @@ -3651,16 +3651,16 @@ WORD GetFunctionPos( char * szFunctionName ) /* return 0 if not found or order + while( pFunc ) { if( ! strcmp( pFunc->szName, szFunctionName ) && pFunc != functions.pFirst ) - return wFunction; + return wFunction; else { - if( pFunc->pNext ) - { - pFunc = pFunc->pNext; - wFunction++; - } - else - return 0; + if( pFunc->pNext ) + { + pFunc = pFunc->pNext; + wFunction++; + } + else + return 0; } } return 0; @@ -3676,17 +3676,17 @@ void Inc( void ) if( pStackValType ) { - sType[0] = pStackValType->cType; - sType[1] = 0; + sType[0] = pStackValType->cType; + sType[1] = 0; } else - debug_msg( "\n* *Inc() Compile time stack overflow\n", NULL ); + debug_msg( "\n* *Inc() Compile time stack overflow\n", NULL ); if( pStackValType && pStackValType->cType == ' ' ) - GenWarning( WARN_NUMERIC_SUSPECT, NULL, NULL ); + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_SUSPECT, NULL, NULL ); else if( pStackValType->cType != 'N' ) - GenWarning( WARN_NUMERIC_TYPE, sType, NULL ); + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_TYPE, sType, NULL ); } } @@ -3708,17 +3708,17 @@ WORD JumpFalse( int iOffset ) if( pStackValType ) { - sType[0] = pStackValType->cType; - sType[1] = 0; + sType[0] = pStackValType->cType; + sType[1] = 0; } else - debug_msg( "\n* *HB_P_JUMPFALSE Compile time stack overflow\n", NULL ); + debug_msg( "\n* *HB_P_JUMPFALSE Compile time stack overflow\n", NULL ); /* compile time Operand value */ if( pStackValType && pStackValType->cType == ' ' ) - GenWarning( WARN_LOGICAL_SUSPECT, NULL, NULL ); + GenWarning( _szCWarnings, 'W', WARN_LOGICAL_SUSPECT, NULL, NULL ); else if( pStackValType && pStackValType->cType != 'L') - GenWarning( WARN_LOGICAL_TYPE, sType, NULL ); + GenWarning( _szCWarnings, 'W', WARN_LOGICAL_TYPE, sType, NULL ); /* compile time assignment value has to be released */ pFree = pStackValType; @@ -3726,12 +3726,12 @@ WORD JumpFalse( int iOffset ) if( pStackValType ) { - pStackValType = pStackValType->pPrev; + pStackValType = pStackValType->pPrev; } if( pFree ) { - OurFree( (void *) pFree ); + OurFree( (void *) pFree ); } } @@ -3742,7 +3742,7 @@ void JumpThere( int iOffset, WORD wTo ) { BYTE * pCode = functions.pLast->pCode; - pCode[ ( WORD ) iOffset ] = LOBYTE( wTo - iOffset + 1 ); + pCode[ ( WORD ) iOffset ] = LOBYTE( wTo - iOffset + 1 ); pCode[ ( WORD ) iOffset + 1 ] = HIBYTE( wTo - iOffset + 1 ); } @@ -3762,17 +3762,17 @@ WORD JumpTrue( int iOffset ) if( pStackValType ) { - sType[0] = pStackValType->cType; - sType[1] = 0; + sType[0] = pStackValType->cType; + sType[1] = 0; } else - debug_msg( "\n* *HB_P_JUMPTRUE Compile time stack overflow\n", NULL ); + debug_msg( "\n* *HB_P_JUMPTRUE Compile time stack overflow\n", NULL ); /* compile time Operand value */ if( pStackValType && pStackValType->cType == ' ' ) - GenWarning( WARN_LOGICAL_SUSPECT, NULL, NULL ); + GenWarning( _szCWarnings, 'W', WARN_LOGICAL_SUSPECT, NULL, NULL ); else if( pStackValType && pStackValType->cType != 'L') - GenWarning( WARN_LOGICAL_TYPE, sType, NULL ); + GenWarning( _szCWarnings, 'W', WARN_LOGICAL_TYPE, sType, NULL ); /* compile time assignment value has to be released */ pFree = pStackValType; @@ -3780,12 +3780,12 @@ WORD JumpTrue( int iOffset ) if( pStackValType ) { - pStackValType = pStackValType->pPrev; + pStackValType = pStackValType->pPrev; } if( pFree ) { - OurFree( (void *) pFree ); + OurFree( (void *) pFree ); } } @@ -3806,7 +3806,7 @@ void LineBody( void ) /* generates the pcode with the currently compiled source { if( ! _bStartProc && functions.iCount <= 1 ) { - GenError( _szCErrors, 'E', ERR_OUTSIDE, NULL, NULL ); + GenError( _szCErrors, 'E', ERR_OUTSIDE, NULL, NULL ); } } @@ -3829,10 +3829,10 @@ void VariablePCode( BYTE bPCode, char * szVarName ) wVar =GetMemvarPos( szVarName ); if( ! wVar ) { - wVar =GetFieldVarPos( szVarName, &pOwnerFunc ); - if( ! wVar ) - GenWarning( ((bPCode==HB_P_POPMEMVAR) ? WARN_MEMVAR_ASSUMED : WARN_AMBIGUOUS_VAR), - szVarName, NULL ); + wVar =GetFieldVarPos( szVarName, &pOwnerFunc ); + if( ! wVar ) + GenWarning( _szCWarnings, 'W', ((bPCode==HB_P_POPMEMVAR) ? WARN_MEMVAR_ASSUMED : WARN_AMBIGUOUS_VAR), + szVarName, NULL ); } } else @@ -3840,10 +3840,10 @@ void VariablePCode( BYTE bPCode, char * szVarName ) wVar =GetFieldVarPos( szVarName, &pOwnerFunc ); if( wVar == 0 ) { - wVar =GetMemvarPos( szVarName ); - if( wVar == 0 ) - GenWarning( ((bPCode==HB_P_POPMEMVAR) ? WARN_MEMVAR_ASSUMED : WARN_AMBIGUOUS_VAR), - szVarName, NULL ); + wVar =GetMemvarPos( szVarName ); + if( wVar == 0 ) + GenWarning( _szCWarnings, 'W', ((bPCode==HB_P_POPMEMVAR) ? WARN_MEMVAR_ASSUMED : WARN_AMBIGUOUS_VAR), + szVarName, NULL ); } } @@ -3853,24 +3853,24 @@ void VariablePCode( BYTE bPCode, char * szVarName ) if( pField->szAlias ) { /* the alias was specified too */ - if( bPCode == HB_P_POPMEMVAR ) - bPCode =HB_P_POPALIASEDFIELD; - else if( bPCode == HB_P_PUSHMEMVAR ) - bPCode =HB_P_PUSHALIASEDFIELD; - else - /* pushing fields by reference is not allowed */ - GenError( _szCErrors, 'E', ERR_INVALID_REFER, szVarName, NULL ); - PushSymbol( yy_strdup( pField->szAlias ), 0 ); + if( bPCode == HB_P_POPMEMVAR ) + bPCode =HB_P_POPALIASEDFIELD; + else if( bPCode == HB_P_PUSHMEMVAR ) + bPCode =HB_P_PUSHALIASEDFIELD; + else + /* pushing fields by reference is not allowed */ + GenError( _szCErrors, 'E', ERR_INVALID_REFER, szVarName, NULL ); + PushSymbol( yy_strdup( pField->szAlias ), 0 ); } else { /* this is unaliased field */ - if( bPCode == HB_P_POPMEMVAR ) - bPCode =HB_P_POPFIELD; - else if( bPCode == HB_P_PUSHMEMVAR ) - bPCode =HB_P_PUSHFIELD; - else - /* pushing fields by reference is not allowed */ - GenError( _szCErrors, 'E', ERR_INVALID_REFER, szVarName, NULL ); + if( bPCode == HB_P_POPMEMVAR ) + bPCode =HB_P_POPFIELD; + else if( bPCode == HB_P_PUSHMEMVAR ) + bPCode =HB_P_PUSHFIELD; + else + /* pushing fields by reference is not allowed */ + GenError( _szCErrors, 'E', ERR_INVALID_REFER, szVarName, NULL ); } } @@ -3912,31 +3912,31 @@ void MessageDupl( char * szMsgName ) /* fix a generated message and duplicate t { WORD wSetSym; PCOMSYMBOL pSym; - BYTE bLoGetSym, bHiGetSym; /* get symbol */ - PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ + BYTE bLoGetSym, bHiGetSym; /* get symbol */ + PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ pSym =GetSymbol( szMsgName, &wSetSym ); if( ! pSym ) /* the symbol was not found on the symbol table */ pSym =AddSymbol( szMsgName, &wSetSym ); pSym->cScope |= FS_MESSAGE; - /* Get previously generated message */ + /* Get previously generated message */ bLoGetSym = pFunc->pCode[ _lMessageFix + 1]; bHiGetSym = pFunc->pCode[ _lMessageFix + 2]; pFunc->pCode[ _lMessageFix + 1 ] = LOBYTE( wSetSym ); pFunc->pCode[ _lMessageFix + 2 ] = HIBYTE( wSetSym ); - pFunc->lPCodePos -= 3; /* Remove unnecessary function call */ - Duplicate(); /* Duplicate object */ + pFunc->lPCodePos -= 3; /* Remove unnecessary function call */ + Duplicate(); /* Duplicate object */ GenPCode3( HB_P_MESSAGE, bLoGetSym, bHiGetSym ); - /* Generate new message */ + /* Generate new message */ } void MessageFix( char * szMsgName ) /* fix a generated message to an object */ { WORD wSym; PCOMSYMBOL pSym; - PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ + PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ pSym =GetSymbol( szMsgName, &wSym ); if( ! pSym ) /* the symbol was not found on the symbol table */ @@ -3945,7 +3945,7 @@ void MessageFix( char * szMsgName ) /* fix a generated message to an object */ pFunc->pCode[ _lMessageFix + 1 ] = LOBYTE( wSym ); pFunc->pCode[ _lMessageFix + 2 ] = HIBYTE( wSym ); - pFunc->lPCodePos -= 3; /* Remove unnecessary function call */ + pFunc->lPCodePos -= 3; /* Remove unnecessary function call */ } void PopId( char * szVarName ) /* generates the pcode to pop a value from the virtual machine stack onto a variable */ @@ -3956,63 +3956,63 @@ void PopId( char * szVarName ) /* generates the pcode to pop a value from the vi { iVar = GetLocalVarPos( szVarName ); if( iVar ) - GenPCode3( HB_P_POPLOCAL, LOBYTE( iVar ), HIBYTE( iVar ) ); + GenPCode3( HB_P_POPLOCAL, LOBYTE( iVar ), HIBYTE( iVar ) ); else { - iVar = GetStaticVarPos( szVarName ); - if( iVar ) - { - GenPCode3( HB_P_POPSTATIC, LOBYTE( iVar ), HIBYTE( iVar ) ); - functions.pLast->bFlags |= FUN_USES_STATICS; - } - else - { - VariablePCode( HB_P_POPMEMVAR, szVarName ); - } + iVar = GetStaticVarPos( szVarName ); + if( iVar ) + { + GenPCode3( HB_P_POPSTATIC, LOBYTE( iVar ), HIBYTE( iVar ) ); + functions.pLast->bFlags |= FUN_USES_STATICS; + } + else + { + VariablePCode( HB_P_POPMEMVAR, szVarName ); + } } } else { if( pAliasId->type == ALIAS_NAME ) { - if( pAliasId->alias.szAlias[0] == 'M' && pAliasId->alias.szAlias[1] == '\x0' ) - { /* M->variable */ - VariablePCode( HB_P_POPMEMVAR, szVarName ); - } - else - { - int iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", 4 ); - if( iCmp == 0 ) - iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", strlen(pAliasId->alias.szAlias) ); - if( iCmp == 0 ) - { /* MEMVAR-> or MEMVA-> or MEMV-> */ - VariablePCode( HB_P_POPMEMVAR, szVarName ); - } - else - { /* field variable */ - iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", 4 ); - if( iCmp == 0 ) - iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", strlen(pAliasId->alias.szAlias) ); - if( iCmp == 0 ) - { /* FIELD-> */ - FieldPCode( HB_P_POPFIELD, szVarName ); - } - else - { /* database alias */ - PushSymbol( yy_strdup( pAliasId->alias.szAlias ), 0 ); - FieldPCode( HB_P_POPALIASEDFIELD, szVarName ); - } - } - } + if( pAliasId->alias.szAlias[0] == 'M' && pAliasId->alias.szAlias[1] == '\x0' ) + { /* M->variable */ + VariablePCode( HB_P_POPMEMVAR, szVarName ); + } + else + { + int iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", 4 ); + if( iCmp == 0 ) + iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", strlen(pAliasId->alias.szAlias) ); + if( iCmp == 0 ) + { /* MEMVAR-> or MEMVA-> or MEMV-> */ + VariablePCode( HB_P_POPMEMVAR, szVarName ); + } + else + { /* field variable */ + iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", 4 ); + if( iCmp == 0 ) + iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", strlen(pAliasId->alias.szAlias) ); + if( iCmp == 0 ) + { /* FIELD-> */ + FieldPCode( HB_P_POPFIELD, szVarName ); + } + else + { /* database alias */ + PushSymbol( yy_strdup( pAliasId->alias.szAlias ), 0 ); + FieldPCode( HB_P_POPALIASEDFIELD, szVarName ); + } + } + } } else if( pAliasId->type == ALIAS_NUMBER ) { - PushInteger( pAliasId->alias.iAlias ); - FieldPCode( HB_P_POPALIASEDFIELD, szVarName ); + PushInteger( pAliasId->alias.iAlias ); + FieldPCode( HB_P_POPALIASEDFIELD, szVarName ); } else - /* Alias is already placed on stack */ - FieldPCode( HB_P_POPALIASEDFIELD, szVarName ); + /* Alias is already placed on stack */ + FieldPCode( HB_P_POPALIASEDFIELD, szVarName ); } @@ -4026,24 +4026,24 @@ void PopId( char * szVarName ) /* generates the pcode to pop a value from the vi if( pVarType ) { - sType[0] = pVarType->cType; - sType[1] = 0; + sType[0] = pVarType->cType; + sType[1] = 0; - /* skip back to the assigned value */ - pStackValType = pStackValType->pPrev; + /* skip back to the assigned value */ + pStackValType = pStackValType->pPrev; } else - debug_msg( "\n***PopId() Compile time stack overflow\n", NULL ); + debug_msg( "\n***PopId() Compile time stack overflow\n", NULL ); if( pVarType && pStackValType && pVarType->cType != ' ' && pStackValType->cType == ' ' ) - GenWarning( WARN_ASSIGN_SUSPECT, szVarName, sType ); + GenWarning( _szCWarnings, 'W', WARN_ASSIGN_SUSPECT, szVarName, sType ); else if( pVarType && pStackValType && pVarType->cType != ' ' && pVarType->cType != pStackValType->cType ) - GenWarning( WARN_ASSIGN_TYPE, szVarName, sType ); + GenWarning( _szCWarnings, 'W', WARN_ASSIGN_TYPE, szVarName, sType ); /* compile time variable has to be released */ if( pVarType ) { - OurFree( (void *) pVarType ); + OurFree( (void *) pVarType ); } debug_msg( "\n***--- Var at PopId()\n", NULL ); @@ -4054,16 +4054,16 @@ void PopId( char * szVarName ) /* generates the pcode to pop a value from the vi if( pStackValType ) { - pStackValType = pStackValType->pPrev; + pStackValType = pStackValType->pPrev; } else { - debug_msg( "\n***PopId() Compile time stack overflow\n", NULL ); + debug_msg( "\n***PopId() Compile time stack overflow\n", NULL ); } if( pFree ) { - OurFree( (void *) pFree ); + OurFree( (void *) pFree ); } } } @@ -4077,82 +4077,82 @@ void PushId( char * szVarName ) /* generates the pcode to push a variable value if( iVarScope == VS_STATIC && functions.pLast->szName ) { /* Reffering to any variable is not allowed during initialization - * of static variable - */ - _pInitFunc->bFlags |= FUN_ILLEGAL_INIT; + * of static variable + */ + _pInitFunc->bFlags |= FUN_ILLEGAL_INIT; } iVar = GetLocalVarPos( szVarName ); if( iVar ) - GenPCode3( HB_P_PUSHLOCAL, LOBYTE( iVar ), HIBYTE( iVar ) ); + GenPCode3( HB_P_PUSHLOCAL, LOBYTE( iVar ), HIBYTE( iVar ) ); else { - iVar = GetStaticVarPos( szVarName ); - if( iVar ) - { - GenPCode3( HB_P_PUSHSTATIC, LOBYTE( iVar ), HIBYTE( iVar ) ); - functions.pLast->bFlags |= FUN_USES_STATICS; - } - else - { - VariablePCode( HB_P_PUSHMEMVAR, szVarName ); - } + iVar = GetStaticVarPos( szVarName ); + if( iVar ) + { + GenPCode3( HB_P_PUSHSTATIC, LOBYTE( iVar ), HIBYTE( iVar ) ); + functions.pLast->bFlags |= FUN_USES_STATICS; + } + else + { + VariablePCode( HB_P_PUSHMEMVAR, szVarName ); + } } } else { if( pAliasId->type == ALIAS_NAME ) { - if( pAliasId->alias.szAlias[0] == 'M' && pAliasId->alias.szAlias[1] == '\x0' ) - { /* M->variable */ - VariablePCode( HB_P_PUSHMEMVAR, szVarName ); - } - else - { - int iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", 4 ); - if( iCmp == 0 ) - iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", strlen(pAliasId->alias.szAlias) ); - if( iCmp == 0 ) - { /* MEMVAR-> or MEMVA-> or MEMV-> */ - VariablePCode( HB_P_PUSHMEMVAR, szVarName ); - } - else - { /* field variable */ - iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", 4 ); - if( iCmp == 0 ) - iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", strlen(pAliasId->alias.szAlias) ); - if( iCmp == 0 ) - { /* FIELD-> */ - FieldPCode( HB_P_PUSHFIELD, szVarName ); - } - else - { /* database alias */ - PushSymbol( yy_strdup( pAliasId->alias.szAlias ), 0 ); - FieldPCode( HB_P_PUSHALIASEDFIELD, szVarName ); - } - } - } + if( pAliasId->alias.szAlias[0] == 'M' && pAliasId->alias.szAlias[1] == '\x0' ) + { /* M->variable */ + VariablePCode( HB_P_PUSHMEMVAR, szVarName ); + } + else + { + int iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", 4 ); + if( iCmp == 0 ) + iCmp = strncmp( pAliasId->alias.szAlias, "MEMVAR", strlen(pAliasId->alias.szAlias) ); + if( iCmp == 0 ) + { /* MEMVAR-> or MEMVA-> or MEMV-> */ + VariablePCode( HB_P_PUSHMEMVAR, szVarName ); + } + else + { /* field variable */ + iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", 4 ); + if( iCmp == 0 ) + iCmp = strncmp( pAliasId->alias.szAlias, "FIELD", strlen(pAliasId->alias.szAlias) ); + if( iCmp == 0 ) + { /* FIELD-> */ + FieldPCode( HB_P_PUSHFIELD, szVarName ); + } + else + { /* database alias */ + PushSymbol( yy_strdup( pAliasId->alias.szAlias ), 0 ); + FieldPCode( HB_P_PUSHALIASEDFIELD, szVarName ); + } + } + } } else if( pAliasId->type == ALIAS_NUMBER ) { - PushInteger( pAliasId->alias.iAlias ); - FieldPCode( HB_P_PUSHALIASEDFIELD, szVarName ); + PushInteger( pAliasId->alias.iAlias ); + FieldPCode( HB_P_PUSHALIASEDFIELD, szVarName ); } else - /* Alias is already placed on stack */ - FieldPCode( HB_P_PUSHALIASEDFIELD, szVarName ); + /* Alias is already placed on stack */ + FieldPCode( HB_P_PUSHALIASEDFIELD, szVarName ); } if( _bWarnings ) { - PSTACK_VAL_TYPE pNewStackType; + PSTACK_VAL_TYPE pNewStackType; - pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); - pNewStackType->cType = cVarType; - pNewStackType->pPrev = pStackValType; + pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); + pNewStackType->cType = cVarType; + pNewStackType->pPrev = pStackValType; - pStackValType = pNewStackType; - debug_msg( "\n***HB_P_PUSHMEMVAR\n ", NULL ); + pStackValType = pNewStackType; + debug_msg( "\n***HB_P_PUSHMEMVAR\n ", NULL ); } } @@ -4176,12 +4176,12 @@ void PushIdByRef( char * szVarName ) /* generates the pcode to push a variable b iVar = GetStaticVarPos( szVarName ); if( iVar ) { - GenPCode3( HB_P_PUSHSTATICREF, LOBYTE( iVar ), HIBYTE( iVar ) ); - functions.pLast->bFlags |= FUN_USES_STATICS; + GenPCode3( HB_P_PUSHSTATICREF, LOBYTE( iVar ), HIBYTE( iVar ) ); + functions.pLast->bFlags |= FUN_USES_STATICS; } else { - VariablePCode( HB_P_PUSHMEMVARREF, szVarName ); + VariablePCode( HB_P_PUSHMEMVARREF, szVarName ); } } } @@ -4343,7 +4343,7 @@ void PushSymbol( char * szSymbolName, int iIsFunction ) * (pName points to static data) */ if( pName ) - szSymbolName[ strlen( *pName ) ] ='\0'; + szSymbolName[ strlen( *pName ) ] ='\0'; } pSym = GetSymbol( szSymbolName, &wSym ); @@ -4351,12 +4351,12 @@ void PushSymbol( char * szSymbolName, int iIsFunction ) { pSym =AddSymbol( szSymbolName, &wSym ); if( iIsFunction ) - AddFunCall( szSymbolName ); + AddFunCall( szSymbolName ); } else { if( iIsFunction && ! GetFuncall( szSymbolName ) ) - AddFunCall( szSymbolName ); + AddFunCall( szSymbolName ); } GenPCode3( HB_P_PUSHSYM, LOBYTE( wSym ), HIBYTE( wSym ) ); @@ -4366,9 +4366,9 @@ void PushSymbol( char * szSymbolName, int iIsFunction ) char cType; if( iIsFunction ) - cType = pSym->cType; + cType = pSym->cType; else - cType = cVarType; + cType = cVarType; pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); pNewStackType->cType = cType; @@ -4385,12 +4385,12 @@ void CheckDuplVars( PVAR pVar, char * szVarName, int iVarScope ) { if( ! strcmp( pVar->szName, szVarName ) ) { - if( ! (iVarScope & VS_PARAMETER) ) - --iLine; - GenError( _szCErrors, 'E', ERR_VAR_DUPL, szVarName, NULL ); + if( ! (iVarScope & VS_PARAMETER) ) + --iLine; + GenError( _szCErrors, 'E', ERR_VAR_DUPL, szVarName, NULL ); } else - pVar = pVar->pNext; + pVar = pVar->pNext; } } @@ -4404,16 +4404,16 @@ void Dec( void ) if( pStackValType ) { - sType[0] = pStackValType->cType; - sType[1] = 0; + sType[0] = pStackValType->cType; + sType[1] = 0; } else - debug_msg( "\n***Dec() Compile time stack overflow\n", NULL ); + debug_msg( "\n***Dec() Compile time stack overflow\n", NULL ); if( pStackValType && pStackValType->cType == ' ' ) - GenWarning( WARN_NUMERIC_SUSPECT, NULL, NULL ); + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_SUSPECT, NULL, NULL ); else if( pStackValType->cType != 'N' ) - GenWarning( WARN_NUMERIC_TYPE, sType, NULL ); + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_TYPE, sType, NULL ); } } @@ -4434,31 +4434,31 @@ void Do( BYTE bParams ) /* Releasing the compile time stack items used as parameters to the function. */ for( i = abs( bParams ); i > 0; i-- ) { - pFree = pStackValType; - debug_msg( "\n***---Do() \n", NULL ); + pFree = pStackValType; + debug_msg( "\n***---Do() \n", NULL ); - if( pStackValType ) - pStackValType = pStackValType->pPrev; - else - debug_msg( "\n***Do() Compile time stack overflow\n", NULL ); + if( pStackValType ) + pStackValType = pStackValType->pPrev; + else + debug_msg( "\n***Do() Compile time stack overflow\n", NULL ); - if( pFree ) - { - OurFree( (void *) pFree ); - } + if( pFree ) + { + OurFree( (void *) pFree ); + } } /* releasing the compile time Nil symbol terminator */ pFree = pStackValType; debug_msg( "\n***---Do()\n", NULL ); if( pStackValType ) - pStackValType = pStackValType->pPrev; + pStackValType = pStackValType->pPrev; else - debug_msg( "\n***Do(2) Compile time stack overflow\n", NULL ); + debug_msg( "\n***Do(2) Compile time stack overflow\n", NULL ); if ( pFree ) { - OurFree( (void *) pFree ); + OurFree( (void *) pFree ); } /* releasing the compile time procedure value */ @@ -4467,12 +4467,12 @@ void Do( BYTE bParams ) if( pStackValType ) { - pStackValType = pStackValType->pPrev; + pStackValType = pStackValType->pPrev; } if ( pFree ) { - OurFree( (void *) pFree ); + OurFree( (void *) pFree ); } } } @@ -4497,30 +4497,30 @@ void FixReturns( void ) /* fixes all last defined function returns jumps offsets pVar = functions.pLast->pLocals; while ( pVar ) { - if( pVar->szName && functions.pLast->szName && ! pVar->iUsed ) - GenWarning( WARN_VAR_NOT_USED, pVar->szName, functions.pLast->szName ); + if( pVar->szName && functions.pLast->szName && ! pVar->iUsed ) + GenWarning( _szCWarnings, 'W', WARN_VAR_NOT_USED, pVar->szName, functions.pLast->szName ); - pVar = pVar->pNext; + pVar = pVar->pNext; } pVar = functions.pLast->pStatics; while ( pVar ) { - if( pVar->szName && functions.pLast->szName && ! pVar->iUsed ) - GenWarning( WARN_VAR_NOT_USED, pVar->szName, functions.pLast->szName ); + if( pVar->szName && functions.pLast->szName && ! pVar->iUsed ) + GenWarning( _szCWarnings, 'W', WARN_VAR_NOT_USED, pVar->szName, functions.pLast->szName ); - pVar = pVar->pNext; + pVar = pVar->pNext; } /* Clear the compile time stack values (should be empty at this point) */ while( pStackValType ) { - PSTACK_VAL_TYPE pFree; + PSTACK_VAL_TYPE pFree; - debug_msg( "\n***Compile time stack underflow - type: %c\n", pStackValType->cType ); - pFree = pStackValType; - pStackValType = pStackValType->pPrev; - OurFree( (void *) pFree ); + debug_msg( "\n***Compile time stack underflow - type: %c\n", pStackValType->cType ); + pFree = pStackValType; + pStackValType = pStackValType->pPrev; + OurFree( (void *) pFree ); } pStackValType = 0; } @@ -4532,7 +4532,7 @@ void FixReturns( void ) /* fixes all last defined function returns jumps offsets char cLine[ 64 ]; while( pLoop->pNext ) - pLoop =pLoop->pNext; + pLoop =pLoop->pNext; itoa( pLoop->wLine, cLine, 10 ); GenError( _szCErrors, 'E', ERR_UNCLOSED_STRU, cLine, NULL ); @@ -4552,18 +4552,18 @@ void Function( BYTE bParams ) /* Releasing the compile time stack items used as parameters to the function. */ for( i = abs( bParams ); i > 0; i-- ) { - pFree = pStackValType; - debug_msg( "\n***---Function() parameter %i \n", i ); + pFree = pStackValType; + debug_msg( "\n***---Function() parameter %i \n", i ); - if( pStackValType ) - pStackValType = pStackValType->pPrev; - else - debug_msg( "\n***Function() parameter %i Compile time stack overflow\n", i ); + if( pStackValType ) + pStackValType = pStackValType->pPrev; + else + debug_msg( "\n***Function() parameter %i Compile time stack overflow\n", i ); - if( pFree ) - { - OurFree( (void *) pFree ); - } + if( pFree ) + { + OurFree( (void *) pFree ); + } } /* releasing the compile time Nil symbol terminator */ @@ -4572,12 +4572,12 @@ void Function( BYTE bParams ) if( pStackValType ) { - pStackValType = pStackValType->pPrev; + pStackValType = pStackValType->pPrev; } if ( pFree ) { - OurFree( (void *) pFree ); + OurFree( (void *) pFree ); } } } @@ -4594,295 +4594,295 @@ void GenArray( WORD wElements ) /* Releasing the stack items used by the _GENARRAY (other than the 1st element). */ for( wIndex = wElements; wIndex > 1; wIndex-- ) { - pFree = pStackValType; - debug_msg( "\n***---element %i at GenArray()\n", wIndex ); + pFree = pStackValType; + debug_msg( "\n***---element %i at GenArray()\n", wIndex ); - if( pStackValType ) - pStackValType = pStackValType->pPrev; - else - debug_msg( "\n***GenArray() Compile time stack overflow\n", NULL ); + if( pStackValType ) + pStackValType = pStackValType->pPrev; + else + debug_msg( "\n***GenArray() Compile time stack overflow\n", NULL ); - if ( pFree ) - { - OurFree( (void *) pFree ); - } + if ( pFree ) + { + OurFree( (void *) pFree ); + } } if( wElements == 0 ) { - PSTACK_VAL_TYPE pNewStackType; + PSTACK_VAL_TYPE pNewStackType; - pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); - pNewStackType->cType = 'A'; - pNewStackType->pPrev = pStackValType; + pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); + pNewStackType->cType = 'A'; + pNewStackType->pPrev = pStackValType; - pStackValType = pNewStackType; - debug_msg( "\n***empty array in GenArray()\n ", NULL ); + pStackValType = pNewStackType; + debug_msg( "\n***empty array in GenArray()\n ", NULL ); } /* Using the either remaining 1st element place holder or a new item if empty array. */ if( pStackValType ) - pStackValType->cType = 'A'; + pStackValType->cType = 'A'; else - debug_msg( "\n***ArrrayGen() Compile time stack overflow\n", NULL ); + debug_msg( "\n***ArrrayGen() Compile time stack overflow\n", NULL ); } } void GenPCode1( BYTE byte ) { - PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ + PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ /* Releasing value consumed by HB_P_ARRAYPUT */ if( _bWarnings ) { if( byte == HB_P_PUSHSELF ) { - PSTACK_VAL_TYPE pNewStackType; + PSTACK_VAL_TYPE pNewStackType; - pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); - pNewStackType->cType = 'O'; - pNewStackType->pPrev = pStackValType; + pNewStackType = ( STACK_VAL_TYPE * )OurMalloc( sizeof( STACK_VAL_TYPE ) ); + pNewStackType->cType = 'O'; + pNewStackType->pPrev = pStackValType; - pStackValType = pNewStackType; - debug_msg( "\n***HB_P_PUSHSELF\n", NULL ); + pStackValType = pNewStackType; + debug_msg( "\n***HB_P_PUSHSELF\n", NULL ); } else if( byte == HB_P_ARRAYPUT ) { - PSTACK_VAL_TYPE pFree; + PSTACK_VAL_TYPE pFree; - /* Releasing compile time assignment value */ - pFree = pStackValType; - debug_msg( "\n***---ArrayPut()\n", NULL ); + /* Releasing compile time assignment value */ + pFree = pStackValType; + debug_msg( "\n***---ArrayPut()\n", NULL ); - if( pStackValType ) - pStackValType = pStackValType->pPrev; - else - debug_msg( "\n***HB_P_ARRAYPUT Compile time stack overflow\n", NULL ); + if( pStackValType ) + pStackValType = pStackValType->pPrev; + else + debug_msg( "\n***HB_P_ARRAYPUT Compile time stack overflow\n", NULL ); - if( pFree ) - { - OurFree( (void *) pFree ); - } + if( pFree ) + { + OurFree( (void *) pFree ); + } - /* Releasing compile time array element index value */ - pFree = pStackValType; - debug_msg( "\n***---HB_P_ARRAYPUT\n", NULL ); + /* Releasing compile time array element index value */ + pFree = pStackValType; + debug_msg( "\n***---HB_P_ARRAYPUT\n", NULL ); - if( pStackValType ) - pStackValType = pStackValType->pPrev; - else - debug_msg( "\n***HB_P_ARRAYPUT2 Compile time stack overflow\n", NULL ); + if( pStackValType ) + pStackValType = pStackValType->pPrev; + else + debug_msg( "\n***HB_P_ARRAYPUT2 Compile time stack overflow\n", NULL ); - if( pFree ) - { - OurFree( (void *) pFree ); - } + if( pFree ) + { + OurFree( (void *) pFree ); + } } else if( byte == HB_P_POP || byte == HB_P_RETVALUE || byte == HB_P_FORTEST || byte == HB_P_ARRAYAT ) { - PSTACK_VAL_TYPE pFree; + PSTACK_VAL_TYPE pFree; - pFree = pStackValType; - debug_msg( "\n***---HB_P_POP / HB_P_RETVALUE / HB_P_FORTEST / HB_P_ARRAYAT pCode: %i\n", byte ); + pFree = pStackValType; + debug_msg( "\n***---HB_P_POP / HB_P_RETVALUE / HB_P_FORTEST / HB_P_ARRAYAT pCode: %i\n", byte ); - if( pStackValType ) - pStackValType = pStackValType->pPrev; - else - debug_msg( "\n***pCode: %i Compile time stack overflow\n", byte ); + if( pStackValType ) + pStackValType = pStackValType->pPrev; + else + debug_msg( "\n***pCode: %i Compile time stack overflow\n", byte ); - if( pFree ) - { - OurFree( (void *) pFree ); - } + if( pFree ) + { + OurFree( (void *) pFree ); + } } else if( byte == HB_P_MULT || byte == HB_P_DIVIDE || byte == HB_P_MODULUS || byte == HB_P_POWER || byte == HB_P_NEGATE ) { - PSTACK_VAL_TYPE pOperand1 = 0, pOperand2; - char sType1[2], sType2[2]; + PSTACK_VAL_TYPE pOperand1 = 0, pOperand2; + char sType1[2], sType2[2]; - /* 2nd. Operand (stack top)*/ - pOperand2 = pStackValType; + /* 2nd. Operand (stack top)*/ + pOperand2 = pStackValType; - /* skip back to the 1st. operand */ - if( pOperand2 ) - { - pOperand1 = pOperand2->pPrev; - sType2[0] = pOperand1->cType; - sType2[1] = 0; - } - else - debug_msg( "\n***HB_P_MULT pCode: %i Compile time stack overflow\n", byte ); + /* skip back to the 1st. operand */ + if( pOperand2 ) + { + pOperand1 = pOperand2->pPrev; + sType2[0] = pOperand1->cType; + sType2[1] = 0; + } + else + debug_msg( "\n***HB_P_MULT pCode: %i Compile time stack overflow\n", byte ); - /* skip back to the 1st. operand */ - if( pOperand1 ) - { - sType1[0] = pOperand1->cType; - sType1[1] = 0; - } - else - debug_msg( "\n***HB_P_MULT2 pCode: %i Compile time stack overflow\n", byte ); + /* skip back to the 1st. operand */ + if( pOperand1 ) + { + sType1[0] = pOperand1->cType; + sType1[1] = 0; + } + else + debug_msg( "\n***HB_P_MULT2 pCode: %i Compile time stack overflow\n", byte ); - if( pOperand1 && pOperand1->cType != 'N' && pOperand1->cType != ' ' ) - GenWarning( WARN_NUMERIC_TYPE, sType1, NULL ); - else if( pOperand1 && pOperand1->cType == ' ' ) - GenWarning( WARN_NUMERIC_SUSPECT, NULL, NULL ); + if( pOperand1 && pOperand1->cType != 'N' && pOperand1->cType != ' ' ) + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_TYPE, sType1, NULL ); + else if( pOperand1 && pOperand1->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_SUSPECT, NULL, NULL ); - if( pOperand2 && pOperand2->cType != 'N' && pOperand2->cType != ' ' ) - GenWarning( WARN_NUMERIC_TYPE, sType2, NULL ); - else if( pOperand2 && pOperand2->cType == ' ' ) - GenWarning( WARN_NUMERIC_SUSPECT, NULL, NULL ); + if( pOperand2 && pOperand2->cType != 'N' && pOperand2->cType != ' ' ) + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_TYPE, sType2, NULL ); + else if( pOperand2 && pOperand2->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_NUMERIC_SUSPECT, NULL, NULL ); - /* compile time 2nd. operand has to be released */ - if( pOperand2 ) - { - OurFree( (void *) pOperand2 ); - } + /* compile time 2nd. operand has to be released */ + if( pOperand2 ) + { + OurFree( (void *) pOperand2 ); + } - /* compile time 1st. operand has to be released *but* result will be pushed and assumed numeric type */ - pStackValType = pOperand1; - pStackValType->cType = 'N'; + /* compile time 1st. operand has to be released *but* result will be pushed and assumed numeric type */ + pStackValType = pOperand1; + pStackValType->cType = 'N'; } else if( byte == HB_P_PLUS || byte == HB_P_MINUS ) { - PSTACK_VAL_TYPE pOperand1 = 0, pOperand2; - char sType1[2], sType2[2], cType = ' '; + PSTACK_VAL_TYPE pOperand1 = 0, pOperand2; + char sType1[2], sType2[2], cType = ' '; - /* 2nd. Operand (stack top)*/ - pOperand2 = pStackValType; + /* 2nd. Operand (stack top)*/ + pOperand2 = pStackValType; - /* skip back to the 1st. operand */ - if( pOperand2 ) - { - pOperand1 = pOperand2->pPrev; - sType2[0] = pOperand2->cType; - sType2[1] = 0; - } - else - debug_msg( "\n***HB_P_PLUS / HB_P_MINUS Compile time stack overflow\n", NULL ); + /* skip back to the 1st. operand */ + if( pOperand2 ) + { + pOperand1 = pOperand2->pPrev; + sType2[0] = pOperand2->cType; + sType2[1] = 0; + } + else + debug_msg( "\n***HB_P_PLUS / HB_P_MINUS Compile time stack overflow\n", NULL ); - if( pOperand1 ) - { - sType1[0] = pOperand1->cType; - sType1[1] = 0; - } - else - debug_msg( "\n***HB_P_PLUS / HB_P_MINUS2 Compile time stack overflow\n", NULL ); + if( pOperand1 ) + { + sType1[0] = pOperand1->cType; + sType1[1] = 0; + } + else + debug_msg( "\n***HB_P_PLUS / HB_P_MINUS2 Compile time stack overflow\n", NULL ); - if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType != ' ' && pOperand1->cType != pOperand2->cType ) - GenWarning( WARN_OPERANDS_INCOMPATBLE, sType1, sType2 ); - else if( pOperand1 && pOperand2 && pOperand2->cType != ' ' && pOperand1->cType == ' ' ) - GenWarning( WARN_OPERAND_SUSPECT, sType2, NULL ); - else if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType == ' ' ) - GenWarning( WARN_OPERAND_SUSPECT, sType1, NULL ); - else - cType = pOperand1->cType; + if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType != ' ' && pOperand1->cType != pOperand2->cType ) + GenWarning( _szCWarnings, 'W', WARN_OPERANDS_INCOMPATBLE, sType1, sType2 ); + else if( pOperand1 && pOperand2 && pOperand2->cType != ' ' && pOperand1->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_OPERAND_SUSPECT, sType2, NULL ); + else if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_OPERAND_SUSPECT, sType1, NULL ); + else + cType = pOperand1->cType; - /* compile time 2nd. operand has to be released */ - if( pOperand2 ) - { - OurFree( (void *) pOperand2 ); - } + /* compile time 2nd. operand has to be released */ + if( pOperand2 ) + { + OurFree( (void *) pOperand2 ); + } - /* compile time 1st. operand has to be released *but* result will be pushed and type as calculated */ - /* Resetting */ - pStackValType = pOperand1; - pStackValType->cType = cType; + /* compile time 1st. operand has to be released *but* result will be pushed and type as calculated */ + /* Resetting */ + pStackValType = pOperand1; + pStackValType->cType = cType; } else if( byte == HB_P_EQUAL || byte == HB_P_LESS || byte == HB_P_GREATER || byte == HB_P_INSTRING || byte == HB_P_LESSEQUAL || byte == HB_P_GREATEREQUAL || byte == HB_P_EXACTLYEQUAL || byte == HB_P_NOTEQUAL ) { - PSTACK_VAL_TYPE pOperand1 = 0, pOperand2; - char sType1[2], sType2[2]; + PSTACK_VAL_TYPE pOperand1 = 0, pOperand2; + char sType1[2], sType2[2]; - /* 2nd. Operand (stack top)*/ - pOperand2 = pStackValType; + /* 2nd. Operand (stack top)*/ + pOperand2 = pStackValType; - /* skip back to the 1st. operand */ - if( pOperand2 ) - { - pOperand1 = pOperand2->pPrev; - sType2[0] = pOperand2->cType; - sType2[1] = 0; - } - else - debug_msg( "\n***HB_P_EQUAL pCode: %i Compile time stack overflow\n", byte ); + /* skip back to the 1st. operand */ + if( pOperand2 ) + { + pOperand1 = pOperand2->pPrev; + sType2[0] = pOperand2->cType; + sType2[1] = 0; + } + else + debug_msg( "\n***HB_P_EQUAL pCode: %i Compile time stack overflow\n", byte ); - if( pOperand1 ) - { - sType1[0] = pOperand1->cType; - sType1[1] = 0; - } - else - debug_msg( "\n***HB_P_EQUAL2 pCode: %i Compile time stack overflow\n", byte ); + if( pOperand1 ) + { + sType1[0] = pOperand1->cType; + sType1[1] = 0; + } + else + debug_msg( "\n***HB_P_EQUAL2 pCode: %i Compile time stack overflow\n", byte ); - if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType != ' ' && pOperand1->cType != pOperand2->cType ) - GenWarning( WARN_OPERANDS_INCOMPATBLE, sType1, sType2 ); - else if( pOperand1 && pOperand2 && pOperand2->cType != ' ' && pOperand1->cType == ' ' ) - GenWarning( WARN_OPERAND_SUSPECT, sType2, NULL ); - else if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType == ' ' ) - GenWarning( WARN_OPERAND_SUSPECT, sType1, NULL ); + if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType != ' ' && pOperand1->cType != pOperand2->cType ) + GenWarning( _szCWarnings, 'W', WARN_OPERANDS_INCOMPATBLE, sType1, sType2 ); + else if( pOperand1 && pOperand2 && pOperand2->cType != ' ' && pOperand1->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_OPERAND_SUSPECT, sType2, NULL ); + else if( pOperand1 && pOperand2 && pOperand1->cType != ' ' && pOperand2->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_OPERAND_SUSPECT, sType1, NULL ); - /* compile time 2nd. operand has to be released */ - if( pOperand2 ) - { - OurFree( (void *) pOperand2 ); - } + /* compile time 2nd. operand has to be released */ + if( pOperand2 ) + { + OurFree( (void *) pOperand2 ); + } - /* compile time 1st. operand has to be released *but* result will be pushed and of type logical */ - if( pOperand1 ) - pOperand1->cType = 'L'; + /* compile time 1st. operand has to be released *but* result will be pushed and of type logical */ + if( pOperand1 ) + pOperand1->cType = 'L'; - /* Resetting */ - pStackValType = pOperand1; + /* Resetting */ + pStackValType = pOperand1; } else if( byte == HB_P_NOT ) { - char sType[2]; + char sType[2]; - if( pStackValType ) - { - sType[0] = pStackValType->cType; - sType[1] = 0; - } - else - debug_msg( "\n***HB_P_NOT Compile time stack overflow\n", NULL ); + if( pStackValType ) + { + sType[0] = pStackValType->cType; + sType[1] = 0; + } + else + debug_msg( "\n***HB_P_NOT Compile time stack overflow\n", NULL ); - if( pStackValType && pStackValType->cType == ' ' ) - GenWarning( WARN_LOGICAL_SUSPECT, NULL, NULL ); - else if( pStackValType && pStackValType->cType != 'L' ) - GenWarning( WARN_LOGICAL_TYPE, sType, NULL ); + if( pStackValType && pStackValType->cType == ' ' ) + GenWarning( _szCWarnings, 'W', WARN_LOGICAL_SUSPECT, NULL, NULL ); + else if( pStackValType && pStackValType->cType != 'L' ) + GenWarning( _szCWarnings, 'W', WARN_LOGICAL_TYPE, sType, NULL ); - /* compile time 1st. operand has to be released *but* result will be pushed and assumed logical */ - if( pStackValType ) - pStackValType->cType = 'L'; + /* compile time 1st. operand has to be released *but* result will be pushed and assumed logical */ + if( pStackValType ) + pStackValType->cType = 'L'; } } if( ! pFunc->pCode ) /* has been created the memory block to hold the pcode ? */ { - pFunc->pCode = (BYTE *) OurMalloc( PCODE_CHUNK ); + pFunc->pCode = (BYTE *) OurMalloc( PCODE_CHUNK ); pFunc->lPCodeSize = PCODE_CHUNK; - pFunc->lPCodePos = 0; + pFunc->lPCodePos = 0; } else if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 1 ) - pFunc->pCode = (BYTE *)OurRealloc( pFunc->pCode, pFunc->lPCodeSize += PCODE_CHUNK ); + pFunc->pCode = (BYTE *)OurRealloc( pFunc->pCode, pFunc->lPCodeSize += PCODE_CHUNK ); pFunc->pCode[ pFunc->lPCodePos++ ] = byte; } void GenPCode3( BYTE byte1, BYTE byte2, BYTE byte3 ) { - PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ + PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ if( ! pFunc->pCode ) /* has been created the memory block to hold the pcode ? */ { - pFunc->pCode = (BYTE *) OurMalloc( PCODE_CHUNK ); + pFunc->pCode = (BYTE *) OurMalloc( PCODE_CHUNK ); pFunc->lPCodeSize = PCODE_CHUNK; - pFunc->lPCodePos = 0; + pFunc->lPCodePos = 0; } else if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 3 ) - pFunc->pCode = (BYTE *) OurRealloc( pFunc->pCode, pFunc->lPCodeSize += PCODE_CHUNK ); + pFunc->pCode = (BYTE *) OurRealloc( pFunc->pCode, pFunc->lPCodeSize += PCODE_CHUNK ); pFunc->pCode[ pFunc->lPCodePos++ ] = byte1; pFunc->pCode[ pFunc->lPCodePos++ ] = byte2; @@ -4891,13 +4891,13 @@ void GenPCode3( BYTE byte1, BYTE byte2, BYTE byte3 ) void GenPCodeN( BYTE * pBuffer, WORD wSize ) { - PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ + PFUNCTION pFunc = functions.pLast; /* get the currently defined Clipper function */ if( ! pFunc->pCode ) /* has been created the memory block to hold the pcode ? */ { pFunc->lPCodeSize = ((wSize / PCODE_CHUNK) +1) * PCODE_CHUNK; - pFunc->pCode = (BYTE *) OurMalloc( pFunc->lPCodeSize ); - pFunc->lPCodePos = 0; + pFunc->pCode = (BYTE *) OurMalloc( pFunc->lPCodeSize ); + pFunc->lPCodePos = 0; } else if( pFunc->lPCodePos + wSize > pFunc->lPCodeSize ) { @@ -4936,7 +4936,7 @@ void CodeBlockStart() void CodeBlockEnd() { PFUNCTION pCodeblock; /* pointer to the current codeblock */ - PFUNCTION pFunc; /* poiter to a function that owns a codeblock */ + PFUNCTION pFunc; /* poiter to a function that owns a codeblock */ WORD wSize; WORD wLocals = 0; /* number of referenced local variables */ WORD wPos; @@ -5002,7 +5002,7 @@ void CodeBlockEnd() while( pVar ) { if( _bWarnings && pFunc->szName && pVar->szName && ! pVar->iUsed ) - GenWarning( WARN_BLOCKVAR_NOT_USED, pVar->szName, pFunc->szName ); + GenWarning( _szCWarnings, 'W', WARN_BLOCKVAR_NOT_USED, pVar->szName, pFunc->szName ); /* free used variables */ pFree = pVar; @@ -5015,10 +5015,10 @@ void CodeBlockEnd() if( _bWarnings ) { if( pStackValType ) - /* reusing the place holder of the result value */ - pStackValType->cType = 'B'; + /* reusing the place holder of the result value */ + pStackValType->cType = 'B'; else - debug_msg( "\n***CodeBlockEnd() Compile time stack overflow\n", NULL ); + debug_msg( "\n***CodeBlockEnd() Compile time stack overflow\n", NULL ); } } @@ -5082,7 +5082,7 @@ void StaticDefStart( void ) functions.pLast =_pInitFunc; PushInteger( 1 ); /* the number of static variables is unknown now */ GenPCode3( HB_P_STATICS, 0, 0 ); - GenPCode3( HB_P_SFRAME, 0, 0 ); /* frame for statics variables */ + GenPCode3( HB_P_SFRAME, 0, 0 ); /* frame for statics variables */ } else { @@ -5109,14 +5109,14 @@ void StaticDefEnd( WORD wCount ) if( pStackValType ) { - pFree = pStackValType; - debug_msg( "\n***---%i in StaticeDefEnd()\n", _wStatics ); + pFree = pStackValType; + debug_msg( "\n***---%i in StaticeDefEnd()\n", _wStatics ); - pStackValType = pStackValType->pPrev; - OurFree( (void *) pFree ); + pStackValType = pStackValType->pPrev; + OurFree( (void *) pFree ); } else - debug_msg( "\n***StaticDefEnd() Compile time stack overflow\n", NULL ); + debug_msg( "\n***StaticDefEnd() Compile time stack overflow\n", NULL ); } } @@ -5152,11 +5152,11 @@ static void LoopStart( void ) else pLoops = pLoop; - pLoop->pNext =NULL; + pLoop->pNext =NULL; pLoop->pExitList =NULL; pLoop->pLoopList =NULL; pLoop->wOffset =functions.pLast->lPCodePos; /* store the start position */ - pLoop->wLine =iLine; + pLoop->wLine =iLine; } /* @@ -5307,9 +5307,9 @@ char * yy_strdup( char *p ) } -#define SYM_NOLINK 0 /* Symbol does not have to be linked */ -#define SYM_FUNC 1 /* Defined function */ -#define SYM_EXTERN 2 /* Previously defined function */ +#define SYM_NOLINK 0 /* Symbol does not have to be linked */ +#define SYM_FUNC 1 /* Defined function */ +#define SYM_EXTERN 2 /* Previously defined function */ void GenPortObj( char *szFileName, char *szName ) { @@ -5485,9 +5485,9 @@ void GenPortObj( char *szFileName, char *szName ) case HB_P_ENDPROC: fputc( pFunc->pCode[ lPCodePos++ ], yyc ); - if( lPCodePos == pFunc->lPCodePos ) + if( lPCodePos == pFunc->lPCodePos ) bEndProcReq = FALSE; - break; + break; case HB_P_FRAME: /* update the number of local variables */ @@ -5638,10 +5638,10 @@ void GenPortObj( char *szFileName, char *szName ) typedef struct { - char * cFuncName; /* function name */ - int iMinParam; /* min no of parms it needs */ - /* iMinParam = -1, means no checking */ - int iMaxParam; /* max no of parms need */ + char * cFuncName; /* function name */ + int iMinParam; /* min no of parms it needs */ + /* iMinParam = -1, means no checking */ + int iMaxParam; /* max no of parms need */ } FUNCINFO, * PFUNCINFO; static FUNCINFO _StdFun[] = { @@ -5707,7 +5707,7 @@ static FUNCINFO _StdFun[] = { { "VALTYPE" , 1, 1 }, { "WORD" , 1, 1 }, { "YEAR" , 1, 1 }, -{ 0 , 0, 0 } +{ 0 , 0, 0 } }; void CheckArgs( char *cFuncCall, int iArgs ) @@ -5721,25 +5721,25 @@ void CheckArgs( char *cFuncCall, int iArgs ) { iCmp = strncmp( cFuncCall, f[i].cFuncName, 4 ); if( iCmp == 0 ) - iCmp = strncmp( cFuncCall, f[i].cFuncName, strlen(cFuncCall) ); + iCmp = strncmp( cFuncCall, f[i].cFuncName, strlen(cFuncCall) ); if( iCmp == 0 ) { - iPos = i; - break; + iPos = i; + break; } else - ++i; + ++i; } if( iPos >= 0 && ( f[iPos].iMinParam != -1 ) ) if( iArgs < f[iPos].iMinParam || iArgs > f[iPos].iMaxParam ) { - char *szMsg = ( char * ) OurMalloc( 30 ); + char *szMsg = ( char * ) OurMalloc( 30 ); - sprintf( szMsg, " Passed: %i Expected: %i", iArgs, f[iPos].iMinParam ); - GenError( _szCErrors, 'E', ERR_CHECKING_ARGS, cFuncCall, szMsg ); + sprintf( szMsg, " Passed: %i Expected: %i", iArgs, f[iPos].iMinParam ); + GenError( _szCErrors, 'E', ERR_CHECKING_ARGS, cFuncCall, szMsg ); - /* Clipper way */ - /* GenError( _szCErrors, 'E', ERR_CHECKING_ARGS, cFuncCall, NULL ); */ + /* Clipper way */ + /* GenError( _szCErrors, 'E', ERR_CHECKING_ARGS, cFuncCall, NULL ); */ } } diff --git a/harbour/source/hbpp/hbpp.c b/harbour/source/hbpp/hbpp.c index cda9759c65..ddb5dfa107 100644 --- a/harbour/source/hbpp/hbpp.c +++ b/harbour/source/hbpp/hbpp.c @@ -137,6 +137,12 @@ char * _szPErrors[] = { "Can\'t open include file \"%s\"", "#error: \'%s\'" }; +/* Table with parse warnings */ +char * _szPWarnings[] = +{ + "Non directive in include file" +}; + int ParseDirective( char* sLine ) { char sDirective[MAX_NAME]; diff --git a/harbour/source/hbpp/hbppint.c b/harbour/source/hbpp/hbppint.c index 7184827d58..5cd765765e 100644 --- a/harbour/source/hbpp/hbppint.c +++ b/harbour/source/hbpp/hbppint.c @@ -46,6 +46,7 @@ #endif #include #include "hbpp.h" +#include "hberrors.h" void Hbpp_init ( void ); int PreProcess( FILE*, FILE*, char *); @@ -158,7 +159,7 @@ int Hp_Parse( FILE* handl_i, FILE* handl_o ) *sLine = '\0'; } else - printf ( "\nWarning, non directive in include file\n"); + GenWarning( _szPWarnings, 'W', WARN_NONDIRECTIVE, NULL, NULL ); } } } diff --git a/harbour/source/hbpp/hbpplib.c b/harbour/source/hbpp/hbpplib.c index e938830108..d7f334f718 100644 --- a/harbour/source/hbpp/hbpplib.c +++ b/harbour/source/hbpp/hbpplib.c @@ -41,9 +41,11 @@ #include "extend.h" #include "itemapi.h" #include "init.h" +#include "hberrors.h" PATHNAMES *_pIncludePath = NULL; FILENAME *_pFileName = NULL; +BOOL _bWarnings = FALSE; HARBOUR HB_PREPROCESS(void); @@ -98,6 +100,18 @@ void GenError( char* _szErrors[], char cPrefix, int iError, char * szError1, cha exit( 1 ); } +void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2) +{ + if( _bWarnings && iWarning < WARN_ASSIGN_SUSPECT ) /* TODO: add switch to set level */ + { + char * szLine = ( char * ) OurMalloc( 160 ); /*2 lines of text */ + /* printf( "\r%s(%i) ", files.pLast->szFileName, iLine ); */ + printf( "Warning %c%i ", cPrefix, iWarning ); + sprintf( szLine, _szWarnings[ iWarning - 1 ], szWarning1, szWarning2 ); + printf( "%s\n", szLine ); + } +} + /* * Split given filename into path, name and extension */ diff --git a/harbour/source/hbpp/stdalone/hbpp.c b/harbour/source/hbpp/stdalone/hbpp.c index a47108d3ca..0d5d9352a1 100644 --- a/harbour/source/hbpp/stdalone/hbpp.c +++ b/harbour/source/hbpp/stdalone/hbpp.c @@ -42,6 +42,7 @@ #include #include #include "hbpp.h" +#include "hberrors.h" extern int pp_strAt(char *, int, char*, int); extern void pp_Stuff (char*, char*, int, int, int); @@ -54,17 +55,20 @@ char sLine[STR_SIZE], sOutLine[STR_SIZE]; PATHNAMES *_pIncludePath = NULL; FILENAME *_pFileName = NULL; +BOOL _bWarnings = FALSE; int main (int argc,char* argv[]) { FILE *handl_i,*handl_o; char szFileName[ _POSIX_PATH_MAX ]; char * szDefText; - int iArg = 1, i, lOutTable = 0, lOutNew = 0; + int iArg = 1, i; + BOOL bOutTable = FALSE; + BOOL bOutNew = FALSE; DEFINES *stdef = topDefine; COMMANDS *stcmd = topCommand; - printf( "\nHarbour preprocessor" ); + printf( "Harbour preprocessor\n" ); while( iArg < argc ) { if( IS_OPT_SEP(argv[ iArg ][ 0 ])) @@ -94,11 +98,15 @@ int main (int argc,char* argv[]) break; case 'o': case 'O': - lOutTable = 1; + bOutTable = TRUE; break; case 'n': case 'N': - lOutNew = 1; + bOutNew = TRUE; + break; + case 'w': + case 'W': + _bWarnings = TRUE; break; default: printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] ); @@ -115,14 +123,19 @@ int main (int argc,char* argv[]) if ((handl_i = fopen(szFileName, "r")) == NULL) { printf("\nCan't open %s\n",szFileName); return 1; } - printf( "\n\nParsing file %s\n", szFileName ); + printf( "\nParsing file %s\n", szFileName ); } else { - printf( "\nSyntax: Hbpp.exe [options]" ); - printf( "\nOptions:" ); - printf( "\n\t/d[=]\t#define " ); - if( lOutTable ) + printf( "Syntax: hbpp [options]\n" + "\nOptions: \n" + "\t/d[=]\t#define \n" + "\t/i\tadd #include file search path\n" + "\t/o\t\tcreates hbpp.out with all tables\n" + "\t/n\t\twith those only, which defined in your file\n" + "\t/w\t\tenable warnings\n"); + + if( bOutTable ) OutTable( NULL, NULL ); return 1; } @@ -157,9 +170,9 @@ int main (int argc,char* argv[]) Hp_Parse(handl_i,handl_o ); fclose(handl_i); fclose(handl_o); - if( lOutTable ) + if( bOutTable ) OutTable( NULL, NULL ); - else if( lOutNew ) + else if( bOutNew ) OutTable( stdef, stcmd ); printf( "\nOk" ); @@ -555,3 +568,15 @@ void GenError( char* _szErrors[], char cPrefix, int iError, char * szError1, cha printf( "%s\n\n", szLine ); exit( 1 ); } + +void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2) +{ + if( _bWarnings && iWarning < WARN_ASSIGN_SUSPECT ) /* TODO: add switch to set level */ + { + char * szLine = ( char * ) OurMalloc( 160 ); /*2 lines of text */ + /* printf( "\r%s(%i) ", files.pLast->szFileName, iLine ); */ + printf( "Warning %c%i ", cPrefix, iWarning ); + sprintf( szLine, _szWarnings[ iWarning - 1 ], szWarning1, szWarning2 ); + printf( "%s\n", szLine ); + } +} diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index a8c553fd6b..12f9e143ab 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -56,7 +56,7 @@ typedef struct _AREANODE typedef AREANODE * LPAREANODE; -/* TODO: must be changed to a hb_errorRT... */ +/* TODO: must be changed to a hb_errRT... */ static void MyError( char * szError, char * szParam ) { printf( "\n%s %s\n", szError, szParam ); diff --git a/harbour/source/rtl/arrays.c b/harbour/source/rtl/arrays.c index d28f571ce4..eb3cbc3365 100644 --- a/harbour/source/rtl/arrays.c +++ b/harbour/source/rtl/arrays.c @@ -87,12 +87,12 @@ char * hb_arrayGetDate( PHB_ITEM pArray, ULONG ulIndex, char * szDate ) } else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return szDate; @@ -114,12 +114,12 @@ BOOL hb_arrayGetBool( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return 0; } @@ -146,12 +146,12 @@ double hb_arrayGetDouble( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return 0; } @@ -198,12 +198,12 @@ void hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ) hb_itemCopy( pItem, pArray->item.asArray.value->pItems + ( ulIndex - 1 ) ); else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } @@ -222,12 +222,12 @@ char *hb_arrayGetString( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return ""; } @@ -247,12 +247,12 @@ ULONG hb_arrayGetStringLen( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return 0; } @@ -268,12 +268,12 @@ int hb_arrayGetType( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_BOUND, 1132, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return 0; } @@ -293,7 +293,7 @@ ULONG hb_arrayLen( PHB_ITEM pArray ) return pArray->item.asArray.value->ulLen; else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_ARRACCESS)); } return 0; } @@ -306,12 +306,12 @@ void hb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ) hb_itemCopy( pArray->item.asArray.value->pItems + ( ulIndex - 1 ), pItem ); else { - hb_errorRT_BASE(EG_BOUND, 1133, NULL, hb_langDGetErrorDesc(EG_ARRASSIGN)); + hb_errRT_BASE(EG_BOUND, 1133, NULL, hb_langDGetErrorDesc(EG_ARRASSIGN)); } } else { - hb_errorRT_BASE(EG_ARG, 1069, NULL, hb_langDGetErrorDesc(EG_ARRASSIGN)); + hb_errRT_BASE(EG_ARG, 1069, NULL, hb_langDGetErrorDesc(EG_ARRASSIGN)); } } @@ -374,7 +374,7 @@ void hb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, ULONG ulStart, ULONG ulCoun } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } } @@ -398,7 +398,7 @@ void hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } } @@ -422,7 +422,7 @@ void hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex ) } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } } @@ -496,7 +496,7 @@ int hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG ulStart, ULONG ulCount } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } return 0; } @@ -532,7 +532,7 @@ void hb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, ULONG ulStart, ULONG ulCoun } else { - hb_errorRT_BASE(EG_ARG, 2017, NULL, "AEVAL"); + hb_errRT_BASE(EG_ARG, 2017, NULL, "AEVAL"); } } @@ -558,7 +558,7 @@ void hb_arrayRelease( PHB_ITEM pArray ) } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } } @@ -596,7 +596,7 @@ void hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG ulStart, } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } } @@ -633,7 +633,7 @@ PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray ) } else { - hb_errorRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); + hb_errRT_BASE(EG_ARG, 1068, NULL, hb_langDGetErrorDesc(EG_NOTARRAY)); } return pDstArray; } @@ -663,7 +663,7 @@ HARBOUR HB_ARRAY( void ) if ( hb_parnl( tmp ) < 0 ) { - hb_errorRT_BASE( EG_BOUND, 1131, NULL, hb_langDGetErrorDesc( EG_ARRDIMENSION ) ); + hb_errRT_BASE( EG_BOUND, 1131, NULL, hb_langDGetErrorDesc( EG_ARRDIMENSION ) ); } } @@ -690,11 +690,11 @@ HARBOUR HB_AADD( void ) hb_itemCopy( &stack.Return, pValue ); } else - hb_errorRT_BASE( EG_ARG, 1123, NULL, "AADD" ); + hb_errRT_BASE( EG_ARG, 1123, NULL, "AADD" ); } else /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE( EG_ARGCOUNT, 3000, NULL, "AADD" ); + hb_errRT_BASE( EG_ARGCOUNT, 3000, NULL, "AADD" ); } HARBOUR HB_ASIZE( void ) diff --git a/harbour/source/rtl/classes.c b/harbour/source/rtl/classes.c index 140a27b9f1..b0d4e080c5 100644 --- a/harbour/source/rtl/classes.c +++ b/harbour/source/rtl/classes.c @@ -269,8 +269,7 @@ HARBOUR HB___CLSADDMSG(void) break; default: - printf( "Invalid method type from __clsAddMsg\n" ); - exit( 1 ); + hb_errInternal( 9999, "Invalid method type from __clsAddMsg", NULL, NULL ); break; } } @@ -485,7 +484,7 @@ HARBOUR HB___CLSMODMSG(void) else if( ( pFunc == __msgSetData ) || ( pFunc == __msgGetData ) ) { /* Not allowed for DATA */ /*hb_errPutDescription(pError, "__clsModMsg: Cannot modify a DATA item");*/ - hb_errorRT_BASE(EG_ARG, 3004, NULL, "__CLSMODMSG"); + hb_errRT_BASE(EG_ARG, 3004, NULL, "__CLSMODMSG"); } else /* Modify METHOD */ pClass->pMethods[ wAt ].pFunction = ( PHB_FUNC ) hb_parnl( 3 ); @@ -598,8 +597,7 @@ static void hb_clsDictRealloc( PCLASS pClass ) /* TODO: Implement it for very large classes */ if( pClass ) { - printf( "classes.c hb_clsDictRealloc() not implemented yet\n" ); - exit( 1 ); + hb_errInternal( 9999, "classes.c hb_clsDictRealloc() not implemented yet", NULL, NULL ); } } @@ -811,7 +809,7 @@ HARBOUR HB___OBJHASMSG(void) hb_retl( hb_objHasMsg( pObject, pString->item.asString.value ) != 0 ); else { - hb_errorRT_BASE(EG_ARG, 3000, NULL, "__OBJHASMSG"); + hb_errRT_BASE(EG_ARG, 3000, NULL, "__OBJHASMSG"); } } @@ -834,7 +832,7 @@ HARBOUR HB___OBJCLONE( void ) } else { - hb_errorRT_BASE(EG_ARG, 3001, NULL, "__OBJCLONE"); + hb_errRT_BASE(EG_ARG, 3001, NULL, "__OBJCLONE"); } } @@ -861,7 +859,7 @@ HARBOUR HB___OBJSENDMSG(void) } else { - hb_errorRT_BASE(EG_ARG, 3000, NULL, "__OBJSENDMSG"); + hb_errRT_BASE(EG_ARG, 3000, NULL, "__OBJSENDMSG"); } } @@ -1004,7 +1002,7 @@ HARBOUR HB___CLSINSTSUPER( void ) if( !IS_OBJECT( &stack.Return ) ) { /* hb_errPutDescription(pError, "INSTSUPER : Super class does not return an object"); */ - hb_errorRT_BASE(EG_ARG, 3002, NULL, "__CLSINSTSUPER"); + hb_errRT_BASE(EG_ARG, 3002, NULL, "__CLSINSTSUPER"); } for( w = 0; !bFound && w < wClasses; w++ ) @@ -1019,7 +1017,7 @@ HARBOUR HB___CLSINSTSUPER( void ) else { /* hb_errPutDescription(pError, "INSTSUPER : Cannot find super class"); */ - hb_errorRT_BASE(EG_ARG, 3003, NULL, "__CLSINSTSUPER"); + hb_errRT_BASE(EG_ARG, 3003, NULL, "__CLSINSTSUPER"); } } if( !bFound ) diff --git a/harbour/source/rtl/copyfile.c b/harbour/source/rtl/copyfile.c index 8710b6fe7b..d9723da2a2 100644 --- a/harbour/source/rtl/copyfile.c +++ b/harbour/source/rtl/copyfile.c @@ -65,7 +65,7 @@ HARBOUR HB___COPYFILE( void ) } else { - hb_errorRT_BASE(EG_ARG, 2010, NULL, "__COPYFILE"); + hb_errRT_BASE(EG_ARG, 2010, NULL, "__COPYFILE"); } } @@ -79,7 +79,7 @@ static BOOL hb_fsCopy(char* szSource, char* szDest, ULONG* ulWrittenTotal) while ((fhndSource = hb_fsOpen(( BYTE * ) szSource, FO_READ)) == FS_ERROR) { - if (hb_errorRT_BASE_Ext1(EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT) + if (hb_errRT_BASE_Ext1(EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT) { *ulWrittenTotal = (ULONG)-1L; break; @@ -90,7 +90,7 @@ static BOOL hb_fsCopy(char* szSource, char* szDest, ULONG* ulWrittenTotal) { while ((fhndDest = hb_fsCreate(( BYTE * ) szDest, FC_NORMAL)) == FS_ERROR) { - if (hb_errorRT_BASE_Ext1(EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT) + if (hb_errRT_BASE_Ext1(EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT) { *ulWrittenTotal = (ULONG)-2L; break; @@ -118,7 +118,7 @@ static BOOL hb_fsCopy(char* szSource, char* szDest, ULONG* ulWrittenTotal) { while ((usWritten = hb_fsWrite(fhndDest, buffer, usRead)) != usRead) { - if (hb_errorRT_BASE_Ext1(EG_WRITE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT) + if (hb_errRT_BASE_Ext1(EG_WRITE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ) == E_DEFAULT) { bRetVal = FALSE; break; diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index 05a8e83739..da14e0ac75 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -451,13 +451,13 @@ HARBOUR HB_DTOS( void ) } else { - hb_errorRT_BASE(EG_ARG, 1120, NULL, "DTOS"); + hb_errRT_BASE(EG_ARG, 1120, NULL, "DTOS"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "DTOS"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "DTOS"); } #endif } @@ -491,7 +491,7 @@ HARBOUR HB_DAY( void ) } else { - hb_errorRT_BASE(EG_ARG, 1114, NULL, "DAY"); + hb_errRT_BASE(EG_ARG, 1114, NULL, "DAY"); } } @@ -519,7 +519,7 @@ HARBOUR HB_MONTH( void ) } else { - hb_errorRT_BASE(EG_ARG, 1113, NULL, "MONTH"); + hb_errRT_BASE(EG_ARG, 1113, NULL, "MONTH"); } } @@ -547,7 +547,7 @@ HARBOUR HB_YEAR( void ) } else { - hb_errorRT_BASE(EG_ARG, 1112, NULL, "YEAR"); + hb_errRT_BASE(EG_ARG, 1112, NULL, "YEAR"); } } @@ -566,7 +566,7 @@ HARBOUR HB_TIME( void ) } else { - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "TIME"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "TIME"); } } @@ -586,7 +586,7 @@ HARBOUR HB_DATE( void ) else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "DATE"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "DATE"); } } long hb_dow( long d, long m, long y ) @@ -635,7 +635,7 @@ HARBOUR HB_DOW( void ) } else { - hb_errorRT_BASE(EG_ARG, 1115, NULL, "DOW"); + hb_errRT_BASE(EG_ARG, 1115, NULL, "DOW"); } } @@ -653,13 +653,13 @@ HARBOUR HB_CMONTH( void ) } else { - hb_errorRT_BASE(EG_ARG, 1116, NULL, "CMONTH"); + hb_errRT_BASE(EG_ARG, 1116, NULL, "CMONTH"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "CMONTH"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "CMONTH"); } } @@ -677,13 +677,13 @@ HARBOUR HB_CDOW( void ) } else { - hb_errorRT_BASE(EG_ARG, 1117, NULL, "CDOW"); + hb_errRT_BASE(EG_ARG, 1117, NULL, "CDOW"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "CDOW"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "CDOW"); } } @@ -694,6 +694,6 @@ HARBOUR HB_SECONDS( void ) else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "SECONDS"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "SECONDS"); } } diff --git a/harbour/source/rtl/do.c b/harbour/source/rtl/do.c index f53c34338c..3661f2cf09 100644 --- a/harbour/source/rtl/do.c +++ b/harbour/source/rtl/do.c @@ -102,7 +102,7 @@ HARBOUR HB_DO( void ) hb_vmDo( hb_pcount() - 1 ); } else - hb_errorRT_BASE( EG_NOFUNC, 1001, NULL, pItem->item.asString.value ); + hb_errRT_BASE( EG_NOFUNC, 1001, NULL, pItem->item.asString.value ); } else if( IS_BLOCK(pItem) ) { @@ -125,5 +125,5 @@ HARBOUR HB_DO( void ) hb_vmDo( hb_pcount() - 1 ); } else - hb_errorRT_BASE( EG_ARG, 3012, NULL, "DO" ); + hb_errRT_BASE( EG_ARG, 3012, NULL, "DO" ); } diff --git a/harbour/source/rtl/errorapi.c b/harbour/source/rtl/errorapi.c index a5baee29be..c5609f5c62 100644 --- a/harbour/source/rtl/errorapi.c +++ b/harbour/source/rtl/errorapi.c @@ -27,6 +27,16 @@ #include "itemapi.h" #include "errorapi.h" #include "langapi.h" +#include "init.h" + +HARBOUR HB___ERRRT_BASE(void); + +HB_INIT_SYMBOLS_BEGIN( Errorapi__InitSymbols ) +{ "__ERRRT_BASE" , FS_PUBLIC, HB___ERRRT_BASE , 0 } +HB_INIT_SYMBOLS_END( Errorapi__InitSymbols ) +#if ! defined(__GNUC__) +#pragma startup Errorapi__InitSymbols +#endif PHB_ITEM hb_errNew( void ) { @@ -54,9 +64,7 @@ WORD hb_errLaunch( PHB_ITEM pError ) if ( ! IS_BLOCK( &errorBlock ) ) { - /* TODO: Change to internal error: */ - printf( "No ERRORBLOCK() for error at: ???? (0)" ); - exit( 1 ); /* TODO: quit correctly */ + hb_errInternal( 9999, "No ERRORBLOCK() for error", NULL, NULL ); } /* NOTE: This must be called before the hb_vm*() calls */ @@ -112,9 +120,7 @@ WORD hb_errLaunch( PHB_ITEM pError ) if ( bFailure ) { - /* TODO: Change to internal error: */ - printf("Error recovery failure, ???? (0)"); - exit( 1 ); /* TODO: quit correctly */ + hb_errInternal( 9999, "Error recovery failure", NULL, NULL ); } } } @@ -357,7 +363,7 @@ PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags ) /* Wrappers for hb_errLaunch() */ -static WORD hb_errorRT_New +static WORD hb_errRT_New ( USHORT uiSeverity, char * szSubSystem, @@ -388,44 +394,50 @@ static WORD hb_errorRT_New return wRetVal; } -void hb_errorRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) +HARBOUR HB___ERRRT_BASE( void ) { - hb_errorRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); + hb_errRT_BASE( (ULONG) hb_parnl( 1 ), + (ULONG) hb_parnl( 2 ), + ISCHAR( 3 ) ? hb_parc( 3 ) : NULL, + hb_parc( 4 ) ); } -WORD hb_errorRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags ) +void hb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) { - return hb_errorRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags ); + hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); } -void hb_errorRT_TERMINAL( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) +WORD hb_errRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation, USHORT uiOsCode, USHORT uiFlags ) { - hb_errorRT_New( ES_ERROR, HB_ERR_SS_TERMINAL, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); + return hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags ); } -void hb_errorRT_DBCMD( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) +void hb_errRT_TERMINAL( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) { - hb_errorRT_New( ES_ERROR, HB_ERR_SS_DBCMD, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); + hb_errRT_New( ES_ERROR, HB_ERR_SS_TERMINAL, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); } -void hb_errorRT_TOOLS( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) +void hb_errRT_DBCMD( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) { - hb_errorRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); + hb_errRT_New( ES_ERROR, HB_ERR_SS_DBCMD, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); } -/* NOTES: Use as minimal calls from here, as possible. */ -/* Don't allocate memory from this function. */ +void hb_errRT_TOOLS( ULONG ulGenCode, ULONG ulSubCode, char * szDescription, char * szOperation ) +{ + hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE ); +} -void hb_errorInternal ( ULONG ulIntCode, char * szText, char * szModule, WORD wLine, char * szPar1, char * szPar2, char * szPar3 ) +/* NOTE: Use as minimal calls from here, as possible. */ +/* Don't allocate memory from this function. */ + +void hb_errInternal ( ULONG ulIntCode, char * szText, char * szPar1, char * szPar2 ) { char szError [ 256 ]; - if ( szModule ) - printf( "\n%s (%i) ", szModule, wLine ); + sprintf( szError, szText ? szText : hb_langDGetErrorIntr( ulIntCode ), szPar1, szPar2 ); + printf( "\nInternal error %lu: %s\n", ulIntCode, szError ); - sprintf( szError, szText ? szText : hb_langDGetErrorIntr( ulIntCode ), szPar1, szPar2, szPar3 ); - printf( "Internal error %lu: %s\n\n", ulIntCode, szError ); + hb_callStackShow(); - exit( 1 ); + exit( EXIT_FAILURE ); } - diff --git a/harbour/source/rtl/errorsys.prg b/harbour/source/rtl/errorsys.prg index 21d281038c..69c0480a5f 100644 --- a/harbour/source/rtl/errorsys.prg +++ b/harbour/source/rtl/errorsys.prg @@ -152,3 +152,4 @@ STATIC FUNCTION ErrorMessage(oError) RETURN cMessage //----------------------------------------------------------------------------// + diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 9ee2d13153..492b219aa8 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -434,7 +434,7 @@ BOOL hb_fsLock ( FHANDLE handle, ULONG start, position = hb_fsSeek( handle, start, 0 ); result = locking( handle, mode?_LK_UNLCK:_LK_LOCK,length ); hb_fsSeek( handle, position, 0 ); -#else +#else result = 1; last_error = FS_ERROR; #endif @@ -602,7 +602,7 @@ HARBOUR HB_FOPEN( void ) } else { - hb_errorRT_BASE(EG_ARG, 3006, NULL, "FOPEN"); + hb_errRT_BASE(EG_ARG, 3006, NULL, "FOPEN"); } hb_retni(file_handle); diff --git a/harbour/source/rtl/fm.c b/harbour/source/rtl/fm.c index 9dad5fe857..345acc7e06 100644 --- a/harbour/source/rtl/fm.c +++ b/harbour/source/rtl/fm.c @@ -27,6 +27,7 @@ #endif #include #include "extend.h" +#include "errorapi.h" ULONG ulMemoryBlocks = 0; ULONG ulMemoryMaxBlocks = 0; @@ -58,8 +59,7 @@ void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on fail if( ! pMem ) { - printf( "\n_xgrab error: can't allocate memory!\n" ); - exit( 1 ); + hb_errInternal( 9999, "hb_xgrab can't allocate memory", NULL, NULL ); } * ( ( ULONG * ) pMem ) = ulSize; /* we store the block size into it */ @@ -79,8 +79,7 @@ void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */ if( ! pResult ) { - printf( "\n_xrealloc error: can't reallocate memory!\n" ); - exit( 1 ); + hb_errInternal( 9999, "hb_xrealloc can't reallocate memory", NULL, NULL ); } * ( ( ULONG * ) pResult ) = ulSize; /* we store the block size into it */ @@ -102,7 +101,7 @@ void hb_xfree( void * pMem ) /* frees fixed memory */ if( pMem ) free( ( char * ) pMem - sizeof( ULONG ) ); else - printf( "\nCalling hb_xfree() with a null pointer!\n" ); + hb_errInternal( 9999, "hb_xfree called with a null pointer", NULL, NULL ); ulMemoryConsumed -= ulMemSize; ulMemoryBlocks--; diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 096ffc9956..83222d7fc7 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -221,7 +221,7 @@ void hb_inkeyPoll( void ) /* Poll the console keyboard to stuff the Harbour { int ch = 0; #if defined(OS_DOS_COMPATIBLE) || defined(HARBOUR_GCC_OS2) || defined(__IBMCPP__) || defined(_Windows) - /* The reason for including _Windows here is that kbhit() and getch() appear + /* The reason for including _Windows here is that kbhit() and getch() appear to work properly in console mode. For true Windows mode, changes are needed. */ #if defined(HARBOUR_GCC_OS2) /* Read from the keyboard with no echo, no wait, and no SIGSEV on Ctrl-C */ @@ -524,7 +524,7 @@ HARBOUR HB_INKEY( void ) if( wait && forever && ( event_mask & ( INKEY_ALL + INKEY_EXTENDED ) ) == 0 ) { /* There is no point in waiting forever for no input events! */ - hb_errorRT_BASE(EG_ARG, 3007, NULL, "INKEY"); + hb_errRT_BASE(EG_ARG, 3007, NULL, "INKEY"); } else { diff --git a/harbour/source/rtl/itemapi.c b/harbour/source/rtl/itemapi.c index ed4c90aa3c..7c18292dd2 100644 --- a/harbour/source/rtl/itemapi.c +++ b/harbour/source/rtl/itemapi.c @@ -25,6 +25,7 @@ #include "extend.h" #include "itemapi.h" #include "ctoharb.h" +#include "errorapi.h" #include "dates.h" #include "set.h" @@ -425,8 +426,7 @@ void hb_itemCopy( PHB_ITEM pDest, PHB_ITEM pSource ) if( pDest == pSource ) { - printf( "an item was going to be copied to itself from hb_itemCopy()\n" ); - exit( 1 ); + hb_errInternal( 9999, "An item was going to be copied to itself from hb_itemCopy()", NULL, NULL ); } memcpy( pDest, pSource, sizeof( HB_ITEM ) ); diff --git a/harbour/source/rtl/math.c b/harbour/source/rtl/math.c index 6248343085..f960d65ce8 100644 --- a/harbour/source/rtl/math.c +++ b/harbour/source/rtl/math.c @@ -65,13 +65,13 @@ HARBOUR HB_ABS( void ) } else { - hb_errorRT_BASE(EG_ARG, 1089, NULL, "ABS"); + hb_errRT_BASE(EG_ARG, 1089, NULL, "ABS"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "ABS"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "ABS"); } } @@ -89,13 +89,13 @@ HARBOUR HB_EXP( void ) } else { - hb_errorRT_BASE(EG_ARG, 1096, NULL, "EXP"); + hb_errRT_BASE(EG_ARG, 1096, NULL, "EXP"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "EXP"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "EXP"); } } @@ -107,13 +107,13 @@ HARBOUR HB_INT( void ) hb_retnl( hb_parnd( 1 ) ); else { - hb_errorRT_BASE(EG_ARG, 1090, NULL, "INT"); + hb_errRT_BASE(EG_ARG, 1090, NULL, "INT"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "INT"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "INT"); } } @@ -135,13 +135,13 @@ HARBOUR HB_LOG( void ) } else { - hb_errorRT_BASE(EG_ARG, 1095, NULL, "LOG"); + hb_errRT_BASE(EG_ARG, 1095, NULL, "LOG"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "LOG"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "LOG"); } } @@ -168,13 +168,13 @@ HARBOUR HB_MAX( void ) } else { - hb_errorRT_BASE(EG_ARG, 1093, NULL, "MAX"); + hb_errRT_BASE(EG_ARG, 1093, NULL, "MAX"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "MAX"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "MAX"); } } @@ -201,13 +201,13 @@ HARBOUR HB_MIN( void ) } else { - hb_errorRT_BASE(EG_ARG, 1092, NULL, "MIN"); + hb_errRT_BASE(EG_ARG, 1092, NULL, "MIN"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "MIN"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "MIN"); } } @@ -256,7 +256,7 @@ FUNCTION MOD(cl_num, cl_base) } else { - hb_errorRT_BASE(EG_ARG, 1085, NULL, "%"); + hb_errRT_BASE(EG_ARG, 1085, NULL, "%"); } } @@ -289,13 +289,13 @@ HARBOUR HB_ROUND( void ) } else { - hb_errorRT_BASE(EG_ARG, 1094, NULL, "ROUND"); + hb_errRT_BASE(EG_ARG, 1094, NULL, "ROUND"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "ROUND"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "ROUND"); } } @@ -321,13 +321,13 @@ HARBOUR HB_SQRT( void ) } else { - hb_errorRT_BASE(EG_ARG, 1097, NULL, "SQRT"); + hb_errRT_BASE(EG_ARG, 1097, NULL, "SQRT"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "SQRT"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "SQRT"); } } diff --git a/harbour/source/rtl/memvars.c b/harbour/source/rtl/memvars.c index 692eb3d610..f33a8dbe7d 100644 --- a/harbour/source/rtl/memvars.c +++ b/harbour/source/rtl/memvars.c @@ -363,7 +363,7 @@ void hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem ) } } else - hb_errorRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); + hb_errRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); } void hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ) @@ -388,10 +388,10 @@ void hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ) hb_itemCopy( pItem, pGetItem ); } else /* variable is not initialized */ - hb_errorRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); + hb_errRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); } else - hb_errorRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); + hb_errRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); } void hb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ) @@ -415,10 +415,10 @@ void hb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ) ++_globalTable[ pDyn->hMemvar ].counter; } else - hb_errorRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); + hb_errRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); } else - hb_errorRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); + hb_errRT_BASE( EG_NOVAR, 1003, NULL, pMemvarSymb->szName ); } /* @@ -444,7 +444,7 @@ static void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pVa else if( IS_STRING( pMemvar ) ) pDynVar =hb_dynsymGet( pMemvar->item.asString.value ); else - hb_errorRT_BASE( EG_ARG, 3008, NULL, "&" ); + hb_errRT_BASE( EG_ARG, 3008, NULL, "&" ); if( pDynVar ) hb_memvarCreateFromDynSymbol( pDynVar, bScope, pValue ); @@ -518,7 +518,7 @@ static void hb_memvarRelease( HB_ITEM_PTR pMemvar ) } } else - hb_errorRT_BASE( EG_ARG, 3008, NULL, "RELEASE" ); + hb_errRT_BASE( EG_ARG, 3008, NULL, "RELEASE" ); } diff --git a/harbour/source/rtl/objfunc.prg b/harbour/source/rtl/objfunc.prg index 55eb6dc774..92ca72d767 100644 --- a/harbour/source/rtl/objfunc.prg +++ b/harbour/source/rtl/objfunc.prg @@ -37,6 +37,7 @@ */ #include "hboo.ch" +#include "error.ch" // // := __objHasData( , ) @@ -45,7 +46,13 @@ // function __objHasData( oObject, cSymbol ) -return __objHasMsg( oObject, cSymbol ) .and. __objHasMsg( oObject, "_" + cSymbol ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJHASDATA") + endif + +return __objHasMsg( oObject, cSymbol ) .and. ; + __objHasMsg( oObject, "_" + cSymbol ) // @@ -55,7 +62,13 @@ return __objHasMsg( oObject, cSymbol ) .and. __objHasMsg( oObject, "_" + cSymbol // function __objHasMethod( oObject, cSymbol ) -return __objHasMsg( oObject, cSymbol ) .and. !__objHasMsg( oObject, "_" + cSymbol ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJHASMETHOD") + endif + +return __objHasMsg( oObject, cSymbol ) .and. ; + !__objHasMsg( oObject, "_" + cSymbol ) // // __objGetMsgList( , [lDataMethod] ) @@ -67,24 +80,33 @@ return __objHasMsg( oObject, cSymbol ) .and. !__objHasMsg( oObject, "_" + cSymbo // function __objGetMsgList( oObject, lDataMethod ) - local aInfo := aSort( oObject:ClassSel() ) - local aData := {} - local n := 1 - local nLen := Len( aInfo ) + local aInfo + local aData + local n + local nLen local lFoundDM // Found DATA ? - IF !(ValType(lDataMethod) == "L") + if !( ValType( oObject ) == "O" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJGETMSGLIST") + endif + + IF !( ValType( lDataMethod ) == "L" ) lDataMethod := .T. ENDIF + aInfo := aSort( oObject:ClassSel() ) + aData := {} + n := 1 + nLen := Len( aInfo ) + do while n <= nLen .and. Substr( aInfo[ n ], 1, 1 ) != "_" -/* If in range and no set function found yet ( set functions begin with a */ -/* leading underscore ). */ + /* If in range and no set function found yet ( set functions */ + /* begin with a leading underscore ). */ lFoundDM := !Empty( aScan( aInfo, "_" + aInfo[ n ], n + 1 ) ) -/* Find position of matching set function in array with all symbols */ + /* Find position of matching set function in array with all symbols */ if lFoundDM == lDataMethod // If found -> DATA // else METHOD @@ -103,6 +125,10 @@ return aData // function __objGetMethodList( oObject ) + if !( ValType( oObject ) == "O" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJGETMETHODLIST") + endif + return __objGetMsgList( oObject, .F. ) @@ -112,180 +138,215 @@ return __objGetMsgList( oObject, .F. ) // Basically the same as __objGetMsgList except that it returns a 2D array // containing : // -// [x][1] Symbol name -// [x][2] Value of DATA +// [x][DATA_SYMBOL] Symbol name +// [x][DATA_VALUE] Value of DATA // // aExcept is an optional list of DATA you do not want to collect // function __objGetValueList( oObject, aExcept ) - local aDataSymbol := __objGetMsgList( oObject ) - local nLen := Len( aDataSymbol ) - local aData := {} + local aDataSymbol + local nLen + local aData local cSymbol local n - IF !(ValType(aExcept) == "A") + if !( ValType( oObject ) == "O" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJGETVALUELIST") + endif + + IF !( ValType( aExcept ) == "A" ) aExcept := {} ENDIF + aDataSymbol := __objGetMsgList( oObject ) + nLen := Len( aDataSymbol ) + aData := {} + for n := 1 to nLen cSymbol := aDataSymbol[ n ] if Empty( aScan( aExcept, cSymbol ) ) aAdd( aData, { cSymbol, __objSendMsg( oObject, cSymbol ) } ) endif next n + return aData // // __objSetValueList( , ) // -// The reverse of __objGetValueList. +// The reverse of __objGetValueList. // It puts an 2D array of DATA into an object. // function __objSetValueList( oObject, aData ) - aEval( aData, ; - {|aItem| __objSendMsg( oObject, "_"+aItem[DATA_SYMBOL], aItem[DATA_VAL] ) } ) + if !( ValType( oObject ) == "O" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJSETVALUELIST") + endif + + aEval( aData,; + {|aItem| __objSendMsg( oObject, "_" + aItem[DATA_SYMBOL], aItem[DATA_VALUE] ) } ) return oObject // -// := __objAddMethod( , , ) +// := __objAddMethod( , , ) // // Add a method to an already existing class // -function __objAddMethod( oObj, cSymbol, nFuncPtr ) +function __objAddMethod( oObject, cSymbol, nFuncPtr ) - if __objHasMsg( oObj, cSymbol ) - QOut( "__objAddMethod: ", cSymbol, " already exists in class." ) - elseif ValType( nFuncPtr ) != "N" - QOut( "__objAddMethod: Argument type error " ) - elseif ValType( oObj ) != "O" - QOut( "__objAddMethod: Argument type error " ) - else - __clsAddMsg( oObj:ClassH, cSymbol, nFuncPtr, MET_METHOD ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) .or. ; + !( ValType( nFuncPtr ) == "N" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJADDMETHOD") endif -return oObj + + if !__objHasMsg( oObject, cSymbol ) + __clsAddMsg( oObject:ClassH, cSymbol, nFuncPtr, MET_METHOD ) + else + __errRT_BASE(EG_ARG, 3103, "Already existing symbol in class", "__OBJADDMETHOD") + endif + +return oObject // -// := __objAddInline( , , ) +// := __objAddInline( , , ) // // Add an INLINE to an already existing class // -function __objAddInline( oObj, cSymbol, bInline ) +function __objAddInline( oObject, cSymbol, bInline ) - if __objHasMsg( oObj, cSymbol ) - QOut( "__objAddInline: ", cSymbol, " already exists in class." ) - elseif ValType( bInline ) != "B" - QOut( "__objAddInline: Argument type error " ) - elseif ValType( oObj ) != "O" - QOut( "__objAddInline: Argument type error " ) - else - __clsAddMsg( oObj:ClassH, cSymbol, bInline, MET_INLINE ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJADDINLINE") endif -return oObj + + if !__objHasMsg( oObject, cSymbol ) + __clsAddMsg( oObject:ClassH, cSymbol, bInline, MET_INLINE ) + else + __errRT_BASE(EG_ARG, 3103, "Already existing symbol in class", "__OBJADDINLINE") + endif + +return oObject // -// := __objAddData( , ) +// := __objAddData( , ) // // Add a DATA to an already existing class // -function __objAddData( oObj, cSymbol ) +function __objAddData( oObject, cSymbol ) local nSeq - if __objHasMsg( oObj, cSymbol ) .or. __objHasMsg( oObj, "_" + cSymbol ) - QOut( "__objAddData: ", cSymbol, " already exists in class." ) - elseif ValType( oObj ) != "O" - QOut( "__objAddData: Argument type error " ) - else - nSeq := __cls_IncData( oObj:ClassH ) // Allocate new Seq# - __clsAddMsg( oObj:ClassH, cSymbol, nSeq, MET_DATA ) - __clsAddMsg( oObj:ClassH, "_" + cSymbol, nSeq, MET_DATA ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJADDDATA") endif -return oObj + + if !__objHasMsg( oObject, cSymbol ) .and. ; + !__objHasMsg( oObject, "_" + cSymbol ) + + nSeq := __cls_IncData( oObject:ClassH ) // Allocate new Seq# + __clsAddMsg( oObject:ClassH, cSymbol, nSeq, MET_DATA ) + __clsAddMsg( oObject:ClassH, "_" + cSymbol, nSeq, MET_DATA ) + else + __errRT_BASE(EG_ARG, 3103, "Already existing symbol in class", "__OBJADDDATA") + endif + +return oObject // -// := __objModMethod( , , ) +// := __objModMethod( , , ) // // Modify a method to an already existing class // -function __objModMethod( oObj, cSymbol, nFuncPtr ) +function __objModMethod( oObject, cSymbol, nFuncPtr ) - if !__objHasMethod( oObj, cSymbol ) - QOut( "__objModMethod: ", cSymbol, " does not exist in class." ) - elseif ValType( nFuncPtr ) != "N" - QOut( "__objModMethod: Argument type error " ) - elseif ValType( oObj ) != "O" - QOut( "__objModMethod: Argument type error " ) - else - __clsModMsg( oObj:ClassH, cSymbol, nFuncPtr ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) .or. ; + !( ValType( nFuncPtr ) == "N" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJMODMETHOD") endif -return oObj + + if __objHasMethod( oObject, cSymbol ) + __clsModMsg( oObject:ClassH, cSymbol, nFuncPtr ) + else + __errRT_BASE(EG_ARG, 3102, "Not existing symbol in class", "__OBJMODMETHOD") + endif + +return oObject // -// := __objModInline( , , ) +// := __objModInline( , , ) // // Modify an INLINE to an already existing class // -function __objModInline( oObj, cSymbol, bInline ) +function __objModInline( oObject, cSymbol, bInline ) - if !__objHasMethod( oObj, cSymbol ) - QOut( "__objModInline: ", cSymbol, " does not exist in class." ) - elseif ValType( bInline ) != "B" - QOut( "__objModInline: Argument type error " ) - elseif ValType( oObj ) != "O" - QOut( "__objModInline: Argument type error " ) - else - __clsModMsg( oObj:ClassH, cSymbol, bInline ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) .or. ; + !( ValType( bInline ) == "B" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJMODINLINE") endif -return oObj + + if __objHasMethod( oObject, cSymbol ) + __clsModMsg( oObject:ClassH, cSymbol, bInline ) + else + __errRT_BASE(EG_ARG, 3102, "Not existing symbol in class", "__OBJMODINLINE") + endif + +return oObject // -// := __objDelMethod( , ) +// := __objDelMethod( , ) // // Delete a method from an already existing class // -function __objDelMethod( oObj, cSymbol ) +function __objDelMethod( oObject, cSymbol ) - if !__objHasMethod( oObj, cSymbol ) - QOut( "__objDelMethod: ", cSymbol, " does not exist in class." ) - elseif ValType( oObj ) != "O" - QOut( "__objDelMethod: Argument type error " ) - else - __clsDelMsg( oObj:ClassH, cSymbol ) + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJDELMETHOD") endif -return oObj -function __objDelInline( oObj, cSymbol ) -return __objDelMethod( oObj, cSymbol ) // Same story + if __objHasMethod( oObject, cSymbol ) + __clsDelMsg( oObject:ClassH, cSymbol ) + else + __errRT_BASE(EG_ARG, 3102, "Not existing symbol in class", "__OBJDELMETHOD") + endif +return oObject + +function __objDelInline( oObject, cSymbol ) +return __objDelMethod( oObject, cSymbol ) // Same story // -// := __objDelData( , ) +// := __objDelData( , ) // // Delete a DATA from an already existing class // -function __objDelData( oObj, cSymbol ) +function __objDelData( oObject, cSymbol ) - local nSeq - - if !__objHasData( oObj, cSymbol ) - QOut( "__objDelData: ", cSymbol, " does not exist in class." ) - elseif ValType( oObj ) != "O" - QOut( "__objDelData: Argument type error " ) - else - __clsDelMsg( oObj:ClassH, cSymbol, ) - __clsDelMsg( oObj:ClassH, "_" + cSymbol ) - nSeq := __cls_DecData( oObj:ClassH ) // Decrease wData + if !( ValType( oObject ) == "O" ) .or. ; + !( ValType( cSymbol ) == "C" ) + __errRT_BASE(EG_ARG, 3101, NIL, "__OBJDELDATA") endif -return oObj + + if __objHasData( oObject, cSymbol ) + __clsDelMsg( oObject:ClassH, cSymbol ) + __clsDelMsg( oObject:ClassH, "_" + cSymbol ) + __cls_DecData( oObject:ClassH ) // Decrease wData + else + __errRT_BASE(EG_ARG, 3102, "Not existing symbol in class", "__OBJDELDATA") + endif + +return oObject diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 3b9efc666f..dd28808536 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -49,7 +49,7 @@ from "cvs log source/rtl/set.c". V 1.39 David G. Holm Made various changes after running through Gimpel Lint. - Added call hb_errorRT_TERMINAL() + Added call hb_errRT_TERMINAL() wrapper function upon failure to create an alternate file and/or a printer file (and/or an extra file, @@ -316,7 +316,7 @@ static int open_handle (char * file_name, BOOL bMode, char * def_ext) char * error_message = strerror( error ); char * message = ( char * )hb_xgrab( strlen( error_message ) + 64 ); sprintf( message, "Create error %d (%s)", error, error_message ); - hb_errorRT_TERMINAL( EG_CREATE, 2013, message, path ); + hb_errRT_TERMINAL( EG_CREATE, 2013, message, path ); hb_xfree( message ); } return handle; @@ -710,7 +710,7 @@ HARBOUR HB_SET (void) { if (set_number (pArg2, hb_set.HB_SET_DECIMALS) < 0) { - hb_errorRT_BASE(EG_ARG, 2020, NULL, "SET"); + hb_errRT_BASE(EG_ARG, 2020, NULL, "SET"); } else { @@ -754,7 +754,7 @@ HARBOUR HB_SET (void) { if (set_number (pArg2, hb_set.HB_SET_EPOCH) < 0) { - hb_errorRT_BASE(EG_ARG, 2020, NULL, "SET"); + hb_errRT_BASE(EG_ARG, 2020, NULL, "SET"); } else { @@ -817,7 +817,7 @@ HARBOUR HB_SET (void) { if (set_number (pArg2, hb_set.HB_SET_MARGIN) < 0) { - hb_errorRT_BASE(EG_ARG, 2020, NULL, "SET"); + hb_errRT_BASE(EG_ARG, 2020, NULL, "SET"); } else { @@ -835,7 +835,7 @@ HARBOUR HB_SET (void) { if (set_number (pArg2, hb_set.HB_SET_MESSAGE) < 0) { - hb_errorRT_BASE(EG_ARG, 2020, NULL, "SET"); + hb_errRT_BASE(EG_ARG, 2020, NULL, "SET"); } else { diff --git a/harbour/source/rtl/strings.c b/harbour/source/rtl/strings.c index 19063d22a9..ce7cc6186a 100644 --- a/harbour/source/rtl/strings.c +++ b/harbour/source/rtl/strings.c @@ -266,13 +266,13 @@ HARBOUR HB_LTRIM( void ) } else { - hb_errorRT_BASE(EG_ARG, 1101, NULL, "LTRIM"); + hb_errRT_BASE(EG_ARG, 1101, NULL, "LTRIM"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "LTRIM"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "LTRIM"); } } @@ -311,14 +311,14 @@ HARBOUR HB_RTRIM( void ) /* Clipper doesn't error, but only in RTRIM. TRIM() throws an error, though */ hb_retc(""); #else - hb_errorRT_BASE(EG_ARG, 1100, NULL, "RTRIM"); + hb_errRT_BASE(EG_ARG, 1100, NULL, "RTRIM"); #endif } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "RTRIM"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "RTRIM"); } } @@ -335,13 +335,13 @@ HARBOUR HB_TRIM( void ) } else { - hb_errorRT_BASE(EG_ARG, 1100, NULL, "TRIM"); + hb_errRT_BASE(EG_ARG, 1100, NULL, "TRIM"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "TRIM"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "TRIM"); } } @@ -585,13 +585,13 @@ HARBOUR HB_AT( void ) } else { - hb_errorRT_BASE(EG_ARG, 1108, NULL, "AT"); + hb_errRT_BASE(EG_ARG, 1108, NULL, "AT"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "AT"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "AT"); } } @@ -644,13 +644,13 @@ HARBOUR HB_CHR( void ) } else { - hb_errorRT_BASE(EG_ARG, 1104, NULL, "CHR"); + hb_errRT_BASE(EG_ARG, 1104, NULL, "CHR"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "CHR"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "CHR"); } } @@ -670,13 +670,13 @@ HARBOUR HB_ASC(void) } else { - hb_errorRT_BASE(EG_ARG, 1107, NULL, "ASC"); + hb_errRT_BASE(EG_ARG, 1107, NULL, "ASC"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "ASC"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "ASC"); } } @@ -705,18 +705,18 @@ HARBOUR HB_LEFT( void ) } else { - hb_errorRT_BASE(EG_ARG, 3009, NULL, "LEFT"); + hb_errRT_BASE(EG_ARG, 3009, NULL, "LEFT"); } } else { - hb_errorRT_BASE(EG_ARG, 1124, NULL, "LEFT"); + hb_errRT_BASE(EG_ARG, 1124, NULL, "LEFT"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "LEFT"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "LEFT"); } } @@ -811,13 +811,13 @@ HARBOUR HB_SUBSTR( void ) } else { - hb_errorRT_BASE(EG_ARG, 1110, NULL, "SUBSTR"); + hb_errRT_BASE(EG_ARG, 1110, NULL, "SUBSTR"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "SUBSTR"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "SUBSTR"); } } @@ -845,13 +845,13 @@ HARBOUR HB_LOWER( void ) } else { - hb_errorRT_BASE(EG_ARG, 1103, NULL, "LOWER"); + hb_errRT_BASE(EG_ARG, 1103, NULL, "LOWER"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "LOWER"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "LOWER"); } } @@ -879,13 +879,13 @@ HARBOUR HB_UPPER( void ) } else { - hb_errorRT_BASE(EG_ARG, 1102, NULL, "UPPER"); + hb_errRT_BASE(EG_ARG, 1102, NULL, "UPPER"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "UPPER"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "UPPER"); } } @@ -917,7 +917,7 @@ HARBOUR HB_REPLICATE( void ) } /* TODO: Check for string overflow */ - /* hb_errorRT_BASE(EG_STROVERFLOW, 1234, NULL, "REPLICATE"); */ + /* hb_errRT_BASE(EG_STROVERFLOW, 1234, NULL, "REPLICATE"); */ hb_retclen(szResult, lLen * lTimes); hb_xfree(szResult); @@ -927,13 +927,13 @@ HARBOUR HB_REPLICATE( void ) } else { - hb_errorRT_BASE(EG_ARG, 1106, NULL, "REPLICATE"); + hb_errRT_BASE(EG_ARG, 1106, NULL, "REPLICATE"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "REPLICATE"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "REPLICATE"); } } @@ -954,7 +954,7 @@ HARBOUR HB_SPACE( void ) char *szResult = (char *)hb_xgrab(lLen + 1); /* TODO: Check for string overflow */ - /* hb_errorRT_BASE(EG_STROVERFLOW, 1233, NULL, "SPACE"); */ + /* hb_errRT_BASE(EG_STROVERFLOW, 1233, NULL, "SPACE"); */ memset(szResult, ' ', lLen); hb_retclen(szResult, lLen); @@ -965,13 +965,13 @@ HARBOUR HB_SPACE( void ) } else { - hb_errorRT_BASE(EG_ARG, 1105, NULL, "SPACE"); + hb_errRT_BASE(EG_ARG, 1105, NULL, "SPACE"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "SPACE"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "SPACE"); } } @@ -1163,10 +1163,10 @@ HARBOUR HB_STRTRAN( void ) hb_retclen(szText, pText->item.asString.length); } else - hb_errorRT_BASE(EG_ARG, 3010, NULL, "STRTRAN"); + hb_errRT_BASE(EG_ARG, 3010, NULL, "STRTRAN"); } else - hb_errorRT_BASE(EG_ARG, 1126, NULL, "STRTRAN"); + hb_errRT_BASE(EG_ARG, 1126, NULL, "STRTRAN"); } /* returns the numeric value of a character string representation of a number */ @@ -1198,13 +1198,13 @@ HARBOUR HB_VAL( void ) } else { - hb_errorRT_BASE(EG_ARG, 1098, NULL, "VAL"); + hb_errRT_BASE(EG_ARG, 1098, NULL, "VAL"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "VAL"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "VAL"); } } @@ -1351,13 +1351,13 @@ HARBOUR HB_STR( void ) } else { - hb_errorRT_BASE(EG_ARG, 1099, NULL, "STR"); + hb_errRT_BASE(EG_ARG, 1099, NULL, "STR"); } } else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "STR"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "STR"); } } diff --git a/harbour/source/rtl/tclass.prg b/harbour/source/rtl/tclass.prg index 0435fbb0e6..0a17b7062a 100644 --- a/harbour/source/rtl/tclass.prg +++ b/harbour/source/rtl/tclass.prg @@ -121,7 +121,7 @@ static function Create() for n = 1 to nLenDatas __clsAddMsg( hClass, ::aDatas[ n ][ DATA_SYMBOL ], n + nDataBegin, MET_DATA, ; - ::aDatas[ n ][ DATA_VAL ] ) + ::aDatas[ n ][ DATA_VALUE ] ) __clsAddMsg( hClass, "_" + ::aDatas[ n ][ DATA_SYMBOL ], n + nDataBegin, MET_DATA ) next diff --git a/harbour/source/rtl/transfrm.c b/harbour/source/rtl/transfrm.c index 17c2389a84..cfc364fa1e 100644 --- a/harbour/source/rtl/transfrm.c +++ b/harbour/source/rtl/transfrm.c @@ -345,8 +345,7 @@ static char *NumPicture( char *szPic, long lPic, int iPicFlags, double dValue, } else { - printf( "\nNUMPICTURE: STR does not return string" ); - exit(1); + hb_errInternal( 9999, "NumPicture(): STR does not return string", NULL, NULL ); } return(szRet); } @@ -567,7 +566,7 @@ HARBOUR HB_TRANSFORM( void ) } default: { - hb_errorRT_BASE(EG_ARG, 1122, NULL, "TRANSFORM"); + hb_errRT_BASE(EG_ARG, 1122, NULL, "TRANSFORM"); } } } @@ -610,7 +609,7 @@ HARBOUR HB_TRANSFORM( void ) } default: { - hb_errorRT_BASE(EG_ARG, 1122, NULL, "TRANSFORM"); + hb_errRT_BASE(EG_ARG, 1122, NULL, "TRANSFORM"); } } } diff --git a/harbour/source/tools/dates2.c b/harbour/source/tools/dates2.c index fb663078f5..a2fec227c2 100644 --- a/harbour/source/tools/dates2.c +++ b/harbour/source/tools/dates2.c @@ -175,7 +175,7 @@ HARBOUR HB_ISLEAPYEAR( void ) } else { - hb_errorRT_TOOLS(EG_ARG, 4001, NULL, "ISLEAPYEAR"); + hb_errRT_TOOLS(EG_ARG, 4001, NULL, "ISLEAPYEAR"); } } diff --git a/harbour/source/tools/stringp.prg b/harbour/source/tools/stringp.prg index 4fdfeb7001..076b0ff1e4 100644 --- a/harbour/source/tools/stringp.prg +++ b/harbour/source/tools/stringp.prg @@ -126,7 +126,7 @@ function ToChar( xTxt, cSeparator, lDebug ) nLen := Len( aData ) for n := 1 to nLen // For each item : Recurse ! cOut += aData[n][DATA_SYMBOL] + ":" + ; - ToChar( aData[n][DATA_VAL], cSeparator, lDebug ) + ToChar( aData[n][DATA_VALUE], cSeparator, lDebug ) if n != nLen cOut += cSeparator endif diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index e0fe6c3269..a4e7c49732 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -160,9 +160,8 @@ int main( int argc, char * argv[] ) pSymStart =pDynSym->pSymbol; else { - printf( "Can\'t locate the starting procedure: \'%s\'", HARBOUR_START_PROCEDURE ); - exit(1); - } + hb_errInternal( 9999, "Can\'t locate the starting procedure: \'%s\'", HARBOUR_START_PROCEDURE, NULL ); + } } #endif @@ -602,9 +601,7 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols ) break; default: - printf( "The Harbour virtual machine can't run yet this PRG\n(unsuported pcode opcode: %i)\n", bCode ); - printf( "Line number %i in %s", stack.pBase->item.asSymbol.lineno, stack.pBase->item.asSymbol.value->szName ); - exit( 1 ); + hb_errInternal( 9999, "Unsupported VM opcode", NULL, NULL ); break; } } @@ -654,7 +651,7 @@ static void hb_vmAliasPop( void ) default: hb_itemClear( pItem ); - hb_errorRT_BASE( EG_BADALIAS, 1000, NULL, NULL ); + hb_errRT_BASE( EG_BADALIAS, 1000, NULL, NULL ); break; } @@ -710,7 +707,7 @@ void hb_vmAnd( void ) } else { - hb_errorRT_BASE(EG_ARG, 1078, NULL, ".AND."); + hb_errRT_BASE(EG_ARG, 1078, NULL, ".AND."); } } @@ -782,8 +779,7 @@ void hb_vmDimArray( WORD wDimensions ) /* generates a wDimensions Array and init if( wDimensions > 1 ) { - printf( "HVM.c DimArray() does not supports multiple dimensions yet!" ); - exit( 1 ); + hb_errInternal( 9999, "HVM.C hb_vmDimArray() does not supports multiple dimensions yet", NULL, NULL ); } /* @@ -823,17 +819,18 @@ void hb_vmDo( WORD wParams ) if( ! IS_SYMBOL( pItem ) ) { + /* QUESTION: Is this call needed ? [vszel] */ hb_stackShow(); - printf( "symbol item expected as a base from Do() in line %i\n", stack.pBase->item.asSymbol.lineno ); - exit( 1 ); + hb_errInternal( 9999, "Symbol item expected as a base from hb_vmDo()", NULL, NULL ); } -/* if( ! IS_NIL( pSelf ) ) +/* + if( ! IS_NIL( pSelf ) ) { hb_stackShow(); - printf( "invalid symbol type for self from Do()\n" ); - exit( 1 ); - } */ + hb_errInternal( 9999, "Invalid symbol type for self from hb_vmDo()", NULL, NULL ); + } +*/ pItem->item.asSymbol.lineno = 0; pItem->item.asSymbol.paramcnt = wParams; @@ -851,10 +848,7 @@ void hb_vmDo( WORD wParams ) if( ! pFunc ) { - printf( "internal error: message %s not implemented for class %s\n", - pSym->szName, hb_objGetClsName( pSelf ) ); - hb_callStackShow(); - exit( 1 ); + hb_errInternal( 9999, "Message %s not implemented for class %s", pSym->szName, hb_objGetClsName( pSelf ) ); } pFunc(); } @@ -863,9 +857,7 @@ void hb_vmDo( WORD wParams ) pFunc = pSym->pFunPtr; if( ! pFunc ) { - printf( "internal error: invalid function pointer (%s) from Do()\n", pSym->szName ); - hb_callStackShow(); - exit( 1 ); + hb_errInternal( 9999, "Invalid function pointer (%s) from hb_vmDo()", pSym->szName, NULL ); } pFunc(); } @@ -885,9 +877,7 @@ HARBOUR hb_vmDoBlock( void ) if( ! IS_BLOCK( pBlock ) ) { - printf( "internal error: codeblock expected from DoBlock()\n" ); - hb_callStackShow(); - exit( 1 ); + hb_errInternal( 9999, "Codeblock expected from hb_vmDoBlock()", NULL, NULL ); } /* Check for valid count of parameters */ @@ -941,8 +931,7 @@ HARBOUR HB_EVAL( void ) } else { - printf( "Not a valid codeblock on eval in line %i\n", stack.pBase->item.asSymbol.lineno ); - exit( 1 ); + hb_errInternal( 9999, "Not a valid codeblock on EVAL", NULL, NULL ); } } @@ -994,7 +983,7 @@ void hb_vmEqual( BOOL bExact ) else if( pItem1->type != pItem2->type ) { - hb_errorRT_BASE(EG_ARG, 1070, NULL, "=="); + hb_errRT_BASE(EG_ARG, 1070, NULL, "=="); } else @@ -1025,7 +1014,7 @@ void hb_vmForTest( void ) /* Test to check the end point of the FOR */ } else { - hb_errorRT_BASE(EG_ARG, 1073, NULL, "<"); + hb_errRT_BASE(EG_ARG, 1073, NULL, "<"); } } @@ -1050,8 +1039,7 @@ void hb_vmFuncPtr( void ) /* pushes a function address pointer. Removes the sym } else { - printf( "symbol item expected from FuncPtr()\n" ); - exit( 1 ); + hb_errInternal( 9999, "Symbol item expected from hb_vmFuncPtr()", NULL, NULL ); } } @@ -1122,7 +1110,7 @@ void hb_vmGreater( void ) else if( ( stack.pPos - 2 )->type != ( stack.pPos - 1 )->type ) { - hb_errorRT_BASE(EG_ARG, 1075, NULL, ">"); + hb_errRT_BASE(EG_ARG, 1075, NULL, ">"); } } @@ -1167,7 +1155,7 @@ void hb_vmGreaterEqual( void ) else if( ( stack.pPos - 2 )->type != ( stack.pPos - 1 )->type ) { - hb_errorRT_BASE(EG_ARG, 1076, NULL, ">="); + hb_errRT_BASE(EG_ARG, 1076, NULL, ">="); } } @@ -1189,7 +1177,7 @@ void hb_vmInc( void ) } else { - hb_errorRT_BASE(EG_ARG, 1086, NULL, "++"); + hb_errRT_BASE(EG_ARG, 1086, NULL, "++"); } } @@ -1209,7 +1197,7 @@ void hb_vmInstring( void ) } else { - hb_errorRT_BASE(EG_ARG, 1109, NULL, "$"); + hb_errRT_BASE(EG_ARG, 1109, NULL, "$"); } } @@ -1254,7 +1242,7 @@ void hb_vmLess( void ) else if( ( stack.pPos - 2 )->type != ( stack.pPos - 1 )->type ) { - hb_errorRT_BASE(EG_ARG, 1073, NULL, "<"); + hb_errRT_BASE(EG_ARG, 1073, NULL, "<"); } } @@ -1299,7 +1287,7 @@ void hb_vmLessEqual( void ) else if( ( stack.pPos - 2 )->type != ( stack.pPos - 1 )->type ) { - hb_errorRT_BASE(EG_ARG, 1074, NULL, "<="); + hb_errRT_BASE(EG_ARG, 1074, NULL, "<="); } } @@ -1337,7 +1325,7 @@ void hb_vmNot( void ) if( IS_LOGICAL( pItem ) ) pItem->item.asLogical.value = ! pItem->item.asLogical.value; else - hb_errorRT_BASE(EG_ARG, 1077, NULL, ".NOT."); + hb_errRT_BASE(EG_ARG, 1077, NULL, ".NOT."); } void hb_vmNotEqual( void ) @@ -1380,7 +1368,7 @@ void hb_vmNotEqual( void ) else if( pItem1->type != pItem2->type ) { - hb_errorRT_BASE(EG_ARG, 1072, NULL, "<>"); + hb_errRT_BASE(EG_ARG, 1072, NULL, "<>"); } else @@ -1442,7 +1430,7 @@ void hb_vmMinus( void ) else if( IS_OBJECT( stack.pPos - 2 ) && hb_objHasMsg( stack.pPos - 2, "-" ) ) hb_vmOperatorCall( stack.pPos - 2, stack.pPos - 1, "-" ); else - hb_errorRT_BASE(EG_ARG, 1082, NULL, "-"); + hb_errRT_BASE(EG_ARG, 1082, NULL, "-"); } @@ -1496,7 +1484,7 @@ void hb_vmOr( void ) } else { - hb_errorRT_BASE(EG_ARG, 1079, NULL, ".OR."); + hb_errRT_BASE(EG_ARG, 1079, NULL, ".OR."); } } @@ -1551,7 +1539,7 @@ void hb_vmPlus( void ) hb_vmOperatorCall( pItem1, pItem2, "+" ); else - hb_errorRT_BASE( EG_ARG, 1081, NULL, "+" ); + hb_errRT_BASE( EG_ARG, 1081, NULL, "+" ); HB_DEBUG( "Plus\n" ); } @@ -1567,8 +1555,7 @@ long hb_vmPopDate( void ) } else { - printf( "incorrect item value trying to Pop a date value in line %i\n", stack.pBase->item.asSymbol.lineno ); - exit( 1 ); + hb_errInternal( 9999, "Incorrect item value trying to Pop a date value", NULL, NULL ); return 0; } } @@ -1605,9 +1592,8 @@ double hb_vmPopDouble( WORD *pwDec ) break; default: - printf( "Incorrect item type trying to Pop a double in line %i\n", stack.pBase->item.asSymbol.lineno ); - exit( 1 ); - d = 0; + hb_errInternal( 9999, "Incorrect item type trying to Pop a double", NULL, NULL ); + break; } stack.pPos->type = IT_NIL; HB_DEBUG( "hb_vmPopDouble\n" ); @@ -1658,7 +1644,7 @@ BOOL hb_vmPopLogical( void ) } else { - hb_errorRT_BASE(EG_ARG, 1066, NULL, hb_langDGetErrorDesc(EG_CONDITION)); + hb_errRT_BASE(EG_ARG, 1066, NULL, hb_langDGetErrorDesc(EG_CONDITION)); return 0; } } @@ -1693,9 +1679,8 @@ double hb_vmPopNumber( void ) break; default: - printf( "Incorrect item on the stack trying to pop a number in line %i\n", stack.pBase->item.asSymbol.lineno ); hb_stackShow(); - exit( 1 ); + hb_errInternal( 9999, "Incorrect item on the stack trying to pop a number", NULL, NULL ); break; } stack.pPos->type = IT_NIL; @@ -1976,9 +1961,7 @@ void hb_stackPop( void ) { if( --stack.pPos < stack.pItems ) { - printf( "internal error: stack underflow\n" ); - hb_callStackShow(); - exit( 1 ); + hb_errInternal( 9999, "Stack underflow", NULL, NULL ); } if( stack.pPos->type != IT_NIL ) hb_itemClear( stack.pPos ); @@ -1988,9 +1971,7 @@ void hb_stackDec( void ) { if( --stack.pPos < stack.pItems ) { - printf( "internal error: stack underflow\n" ); - hb_callStackShow(); - exit( 1 ); + hb_errInternal( 9999, "Stack underflow", NULL, NULL ); } } @@ -2318,7 +2299,7 @@ HARBOUR HB_LEN( void ) break; default: - hb_errorRT_BASE(EG_ARG, 1111, NULL, "LEN"); + hb_errRT_BASE(EG_ARG, 1111, NULL, "LEN"); break; } } @@ -2423,7 +2404,7 @@ HARBOUR HB_VALTYPE( void ) else { /* QUESTION: Clipper catches this at compile time! */ - hb_errorRT_BASE(EG_ARGCOUNT, 3000, NULL, "VALTYPE"); + hb_errRT_BASE(EG_ARGCOUNT, 3000, NULL, "VALTYPE"); } } @@ -2450,11 +2431,11 @@ void hb_callStackShow( void ) { pBase = stack.pItems + pBase->item.asSymbol.stackbase; if( ( pBase + 1 )->type == IT_ARRAY ) - printf( "%s:%s (%i)\n", hb_objGetClsName( pBase + 1 ), + printf( "Called from %s:%s(%i)\n", hb_objGetClsName( pBase + 1 ), pBase->item.asSymbol.value->szName, pBase->item.asSymbol.lineno ); else - printf( "%s (%i)\n", pBase->item.asSymbol.value->szName, + printf( "Called from %s(%i)\n", pBase->item.asSymbol.value->szName, pBase->item.asSymbol.lineno ); } } @@ -2534,6 +2515,6 @@ HARBOUR HB_PVALUE(void) /* PValue( ) hb_itemReturn( pBase + 1 + wParam ); else { - hb_errorRT_BASE(EG_ARG, 3011, NULL, "PVALUE"); + hb_errRT_BASE(EG_ARG, 3011, NULL, "PVALUE"); } }