ChangeLog 19991116-21:55

This commit is contained in:
Ryszard Glab
1999-11-16 21:06:31 +00:00
parent 44b878b566
commit ee515d4717
20 changed files with 10071 additions and 5118 deletions

View File

@@ -1,3 +1,58 @@
19991116-21:55 GMT+1 Ryszard Glab <rglab@imid.med.pl>
* source/compiler/harbour.y
* source/compiler/harbour.l
* source/compiler/harbour.c
* source/compiler/expropt.c
* source/compiler/genc.c
* source/compiler/genhrb.c
* source/compiler/genobj32.c
* source/compiler/genjava.c
* new implementation of grammar rules - many new syntax supported
* new expression optimizer
* start of introducing new functions' naming scheme 'hb_comp'
* nonprintable characters (CR/LF/TAB, etc.) are inserted into
generated C code using hexdecimal numbers instead of quoted char
(they can appear as a result of expression optimization)
* source/pp/hbpp.c
* source/pp/hbppint.c
* source/pp/hblib.c
* source/pp/stdalone/hbpp.c
* changes to support new functions' naming scheme 'hb_comp'
*include/pcode.h
*HB_P_ARRAYAAT -> HB_P_ARRAYPUSH
HB_P_ARRAYAPUT -> HB_P_ARRAYPOP - it removes value from the stack
This is compatible with the handling of usual variables
*source/debug/debugger.prg
* corrected the following syntax:
something <operator> other := another
for example:
? 2 + a:=5 -1
This syntax is not allowed in Clipper and in new Harbour rules too
It should be used:
? 2 + (a:=5) -1
* doc/compiler.txt
* added description of incompatibility with Clipper in object
handling
* include/compiler.h
* new structures related to expression optimizer
* include/hberrors.h
* new errors: Invalid type, invalid syntax, invalid alias
* new warning: meaningless expression
* source/vm/hvm.c
* change in handling of HB_P_FORTEST opcode used in FOR/NEXT loop
* Renamed ArrayAt -> ArrayPush
* Renamed ArrayPut -> ArrayPop - it removes the value from the
eval stack now
19991116-15:05 GMT+1 Victor Szel <info@szelvesz.hu>
* source/rtl/memvars.c
! __MSAVE() Modified to save MEMVARs with names longer than 10 chars, the

View File

@@ -151,7 +151,7 @@ Compilation in batch mode.
Known incompatibilities between harbour and clipper compilers
=============================================================
NOTE:
NOTE:
If you want 100% compatible compiler and runtime libraries then
you have to define HARBOUR_STRICT_CLIPPER_COMPATIBILITY option. This
option should be defined in include/hbsetup.h file (in fact this
@@ -160,10 +160,10 @@ characters only). This change have to be done before invoking
the make utility.
Handling of undeclared variables
Handling of undeclared variables
--------------------------------
When a value is assigned to an undeclared variable and '-v' command
line option is not used then the Clipper compiler assumes that the variable
line option is not used then the Clipper compiler assumes that the variable
is a PRIVATE or a PUBLIC variable and generates POPM (pop memvar) opcode.
When a value of undeclared variable is accessed and '-v' command line
option is not used the Clipper compiler generates PUSHV (push variable)
@@ -171,8 +171,8 @@ opcode that determines the type of variable at runtime. If the field with
requested name exists in a current workarea then its value is used. If there
is no field then a PRIVATE or a PUBLIC variable is used (if exists).
The Harbour compiler generates an opcode to determine the type of variable
at runtime (POPVARIABLE or PUSHVARIABLE) in both cases (assignment and access).
The Harbour compiler generates an opcode to determine the type of variable
at runtime (POPVARIABLE or PUSHVARIABLE) in both cases (assignment and access).
The difference can be checked by the following code:
@@ -208,3 +208,33 @@ why the Harbour compiler uses the usual PUSHMEMVARREF opcode in such
cases. Notice that the runtime behavior is the same in Clipper and
in Harbour - the generated opcodes are different only.
Handling of object messages
---------------------------
The HARBOUR_STRICT_CLIPPER_COMPATIBILITY setting determines
the way the chained send messages are handled.
For example, the following code:
a:b( COUNT() ):c += 1
will be handled as:
a:b( COUNT() ):c := a:b( COUNT() ):c + 1
in strict Clipper compatibility mode and
temp := a:b( COUNT() ), temp:c += 1
in non-strict mode.
In practice in Clipper it will call COUNT() function two times: the
first time before addition and the second one after addition - in Harbour,
COUNT() function will be called only once, before addition.
The Harbour (non-strict) method is:
1) faster
2) it guarantees that the same instance variable of the same object will
be changed
(See also: source/compiler/expropt.c)

View File

@@ -36,10 +36,40 @@
#ifndef HB_COMPILER_H_
#define HB_COMPILER_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <malloc.h> /* required for allocating and freeing memory */
#include <ctype.h>
#include <time.h>
#include "hbsetup.h"
#include "extend.h"
#include "pcode.h" /* pcode values */
#include "hberrors.h"
#include "hbpp.h"
#include "hbver.h"
/* compiler related declarations */
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 */
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 */
/* locals, static, public variables support */
typedef struct _VAR
{
@@ -50,6 +80,9 @@ typedef struct _VAR
struct _VAR * pNext; /* pointer to next defined variable */
} VAR, * PVAR;
/* pcode chunks bytes size */
#define PCODE_CHUNK 100
/* structure to hold a Clipper defined function */
typedef struct __FUNC /* functions definition support */
{
@@ -65,7 +98,6 @@ typedef struct __FUNC /* functions definition support */
BYTE * pCode; /* pointer to a memory block where pcode is stored */
ULONG lPCodeSize; /* total memory size for pcode */
ULONG lPCodePos; /* actual pcode offset */
LONG lLastPushPos; /* pointer to last push operation, used by push/pop optimizer */
int iStaticsBase; /* base for this function statics */
struct __FUNC * pOwner; /* pointer to the function/procedure that owns the codeblock */
struct __FUNC * pNext; /* pointer to the next defined function */
@@ -96,8 +128,63 @@ typedef struct
int iCount; /* number of defined symbols */
} SYMBOLS;
extern PFUNCTION GetFunction( char * szFunName ); /* locates a previously defined function */
extern USHORT GetFunctionPos( char * szSymbolName ); /* returns the index + 1 of a function on the functions defined list */
typedef struct HB_EXPR_
{
union
{
char *asString; /* literal strings */
char *asSymbol; /* variable name */
BOOL asLogical; /* logical value */
struct
{
long lVal; /* long value */
double dVal; /* double value */
unsigned char bDec; /* unsigned char used intentionally */
unsigned char NumType; /* used to distinguish LONG and DOUBLE */
} asNum;
struct
{
struct HB_EXPR_ *pVar; /* macro variable */
char * szNameExt; /* text after the macro terminator */
} asMacro;
struct
{
struct HB_EXPR_ *pExprList; /* list elements */
struct HB_EXPR_ *pIndex; /* array index, others */
} asList;
struct
{
struct HB_EXPR_ *pAlias; /* alias expression */
char * szVarName; /* aliased variable */
struct HB_EXPR_ *pExpList; /* aliased expression list */
} asAlias;
struct
{
char * szFunName; /* function name */
struct HB_EXPR_ *pParms; /* function call parameters */
} asFunCall;
struct
{
struct HB_EXPR_ *pObject; /* object */
char * szMessage; /* message */
struct HB_EXPR_ *pParms; /* method parameters */
} asMessage;
struct
{
struct HB_EXPR_ *pLeft; /* object */
struct HB_EXPR_ *pRight; /* object */
} asOperator;
} value;
ULONG ulLength;
unsigned char ExprType; /* internal expression type */
USHORT ValType; /* language level value type */
struct HB_EXPR_ *pNext; /* next expression in the list of expressions */
} HB_EXPR, *HB_EXPR_PTR;
extern PFUNCTION GetFunction( char * szFunName ); /* locates a previously defined function */
extern USHORT GetFunctionPos( char * szSymbolName ); /* returns the index + 1 of a function on the functions defined list */
extern void * hb_xgrab( ULONG lSize ); /* allocates memory, exists on failure */
extern void * hb_xrealloc( void * pMem, ULONG lSize ); /* reallocates memory */
@@ -106,24 +193,18 @@ extern void hb_xfree( void * pMem ); /* frees memory */
char * yy_strdup( char * p ); /* this will exit if there is not enough memory */
char * yy_strupr( char * p );
#if 0
static void __yy_memcpy( char * from, char * to, int count ); /* Bison prototype */
#endif
extern USHORT FixSymbolPos( USHORT ); /* converts symbol's compile-time position into generation-time position */
extern PFUNCTION GetFuncall( char * szFunName ); /* locates a previously defined called function */
extern PVAR GetVar( PVAR pVars, USHORT wOrder ); /* returns a variable if defined or zero */
extern PCOMSYMBOL GetSymbol( char *, USHORT * ); /* returns a symbol pointer from the symbol table */
extern PCOMSYMBOL GetSymbolOrd( USHORT ); /* returns a symbol based on its index on the symbol table */
extern PCOMSYMBOL hb_compGetSymbol( char *, USHORT * ); /* returns a symbol pointer from the symbol table */
extern PCOMSYMBOL hb_compGetSymbolOrd( USHORT ); /* returns a symbol based on its index on the symbol table */
extern PFUNCTION KillFunction( PFUNCTION ); /* releases all memory allocated by function and returns the next one */
extern PCOMSYMBOL KillSymbol( PCOMSYMBOL ); /* releases all memory allocated by symbol and returns the next one */
extern FUNCTIONS functions, funcalls;
extern PFUNCTION _pInitFunc;
extern SYMBOLS symbols;
extern PHB_FNAME _pFileName;
extern BOOL _bQuiet;
extern BOOL _bStartProc;
extern char _szPrefix[ 20 ]; /* holds the prefix added to the generated symbol init function name (in C output currently) */
extern BOOL _bGenCVerbose;
extern char * _szCErrors[];
#define VS_LOCAL 1
#define VS_STATIC 2
#define VS_FIELD 4
@@ -132,12 +213,286 @@ extern char * _szCErrors[];
#define VS_PUBLIC 128
#define VS_MEMVAR ( VS_PUBLIC | VS_PRIVATE )
/* flags for bFlags member */
#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_ILLEGAL_INIT 8 /* Attempt to initialize static variable with a function call */
#define FUN_USES_LOCAL_PARAMS 16 /* parameters are declared using () */
#define FUN_WITH_RETURN 32 /* there was RETURN statement in previous line */
/*
* flags for bFlags member
*/
#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_ILLEGAL_INIT 8 /* Attempt to initialize static variable with a function call */
#define FUN_USES_LOCAL_PARAMS 16 /* parameters are declared using () */
#define FUN_WITH_RETURN 32 /* there was RETURN statement in previous line */
/* Support for aliased expressions
*/
typedef struct _ALIASID
{
char type;
union {
int iAlias;
char * szAlias;
} alias;
struct _ALIASID * pPrev;
} ALIASID, *ALIASID_PTR;
#define ALIAS_NUMBER 1
#define ALIAS_NAME 2
#define ALIAS_EVAL 3
typedef struct __EXTERN
{
char * szName;
struct __EXTERN * pNext;
} _EXTERN, * PEXTERN; /* support structure for extern symbols */
/* as they have to be placed on the symbol table later than the first public symbol */
typedef struct _LOOPEXIT
{
ULONG ulOffset;
int iLine;
USHORT wSeqCounter;
struct _LOOPEXIT * pLoopList;
struct _LOOPEXIT * pExitList;
struct _LOOPEXIT * pNext;
} LOOPEXIT, * PTR_LOOPEXIT; /* support structure for EXIT and LOOP statements */
typedef struct __ELSEIF
{
ULONG ulOffset;
struct __ELSEIF * pNext;
} _ELSEIF, * PELSEIF; /* support structure for else if pcode fixups */
/* Support for parenthesized expressions
*/
typedef struct _EXPLIST
{
BYTE * prevPCode; /* pcode buffer used at the start of expression */
ULONG prevSize;
ULONG prevPos;
BYTE * exprPCode; /* pcode buffer for current expression */
ULONG exprSize;
struct _EXPLIST *pPrev; /* previous expression in the list */
struct _EXPLIST *pNext; /* next expression in the list */
} EXPLIST, *EXPLIST_PTR;
/* production related functions */
void AliasAddInt( int );
void AliasAddExp( void );
void AliasAddStr( char * );
void AliasPush( void );
void AliasPop( void );
void AliasSwap( void );
void AliasAdd( ALIASID_PTR );
void AliasRemove( void );
void ExpListPush( void ); /* pushes the new expression on the stack */
void ExpListPop( int ); /* pops previous N expressions */
PFUNCTION hb_compAddFunCall( char * szFuntionName );
void hb_compAddExtern( char * szExternName ); /* defines a new extern name */
void hb_compAddVar( char * szVarName, char cType ); /* add a new param, local, static variable to a function definition or a public or private */
PCOMSYMBOL hb_compAddSymbol( char *, USHORT * );
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 hb_compGenDoProc( 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 */
void DupPCode( ULONG ulStart ); /* duplicates the current generated pcode from an offset */
void FieldPCode( BYTE , char * ); /* generates the pcode for database field */
void FixElseIfs( void * pIfElseIfs ); /* implements the ElseIfs pcode fixups */
void FixReturns( void ); /* fixes all last defined function returns jumps offsets */
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 */
void hb_compFunDef( char * szFunName, HB_SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */
void GenArray( int iElements ); /* instructs the virtual machine to build an array and load elemnst from the stack */
void hb_compGenBreak( void ); /* generate code for BREAK statement */
void * GenElseIf( void * pFirstElseIf, ULONG ulOffset ); /* generates a support structure for elseifs pcode fixups */
void hb_compGenExterns( void ); /* generates the symbols for the EXTERN names */
void GenIfInline( void ); /* generates pcodes for IIF( expr1, expr2, expr3 ) */
int GetFieldVarPos( char *, PFUNCTION ); /* return if passed name is a field variable */
int GetMemvarPos( char *, PFUNCTION ); /* return if passed name is a memvar variable */
USHORT GetVarPos( PVAR pVars, char * szVarName ); /* returns the order + 1 of a variable if defined or zero */
int GetLocalVarPos( char * szVarName ); /* returns the order + 1 of a local variable */
void Inc( void ); /* generates the pcode to increment the latest value on the virtual machine stack */
ULONG hb_compGenJump( LONG lOffset ); /* generates the pcode to jump to a specific offset */
ULONG hb_compGenJumpFalse( LONG lOffset ); /* generates the pcode to jump if false */
void hb_compGenJumpHere( ULONG ulOffset ); /* returns the pcode pos where to set a jump offset */
void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo ); /* sets a jump offset */
ULONG hb_compGenJumpTrue( LONG lOffset ); /* generates the pcode to jump if true */
void Line( void ); /* generates the pcode with the currently compiled source code line */
void LineDebug( 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 undeclared variable */
void MemvarPCode( BYTE , char * ); /* generates the pcode for memvar variable */
void hb_compGenMessage( char * szMsgName ); /* sends a message to an object */
void hb_compGenMessageData( char * szMsg ); /* generates an underscore-symbol name for a data assignment */
void hb_compGenPopVar( char * szVarName ); /* generates the pcode to pop a value from the virtual machine stack onto a variable */
void hb_compGenPushDouble( double fNumber, BYTE bDec ); /* Pushes a number on the virtual machine stack */
void hb_compGenPushFunCall( char * ); /* generates the pcode to push function's call */
void hb_compGenPushVar( char * szVarName ); /* generates the pcode to push a variable value to the virtual machine stack */
void hb_compGenPushVarRef( char * szVarName ); /* generates the pcode to push a variable by reference to the virtual machine stack */
void hb_compGenPushInteger( int iNumber ); /* Pushes a integer number on the virtual machine stack */
void hb_compGenPushLogical( int iTrueFalse ); /* pushes a logical value on the virtual machine stack */
void hb_compGenPushLong( long lNumber ); /* Pushes a long number on the virtual machine stack */
void hb_compGenPushNil( void ); /* Pushes nil on the virtual machine stack */
void hb_compGenPushString( char * szText, ULONG ulLen ); /* Pushes a string on the virtual machine stack */
void hb_compPushSymbol( char * szSymbolName, int iIsFunction ); /* Pushes a symbol on to the Virtual machine stack */
/* Codeblocks */
void hb_compCodeBlockStart( void ); /* starts a codeblock creation */
void hb_compCodeBlockEnd( void ); /* end of codeblock creation */
void hb_compGenPushFunRef( char * );
void hb_compGenPCode1( BYTE ); /* generates 1 byte of pcode */
void hb_compGenPCode3( BYTE, BYTE, BYTE ); /* generates 3 bytes of pcode */
void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize ); /* copy bytes to a pcode buffer */
ULONG SequenceBegin( void );
ULONG SequenceEnd( void );
void SequenceFinish( ULONG, int );
/* Managing value type */
extern void ValTypePush( char cType ); /* Pushes the type of expression (used with -w3 option */
extern void ValTypePop( int );
extern void ValTypePlus( void );
extern void ValTypeRelational( void );
extern void ValTypeCheck( char, int, int );
extern void ValTypeCheck2( char, int, int );
extern char ValTypeGet( void );
extern void ValTypePut( char );
extern void ValTypeAssign( char * );
extern void ValTypeReset( void );
/* support for FIELD declaration */
void FieldsSetAlias( char *, int );
int FieldsCount( void );
/* Static variables */
void hb_compStaticDefStart( void );
void hb_compStaticDefEnd( void );
HB_EXPR_PTR hb_compErrorStatic( char *, HB_EXPR_PTR );
HB_EXPR_PTR hb_compErrorType( HB_EXPR_PTR );
HB_EXPR_PTR hb_compErrorIndex( HB_EXPR_PTR );
HB_EXPR_PTR hb_compErrorSyntax( HB_EXPR_PTR );
HB_EXPR_PTR hb_compErrorLValue( HB_EXPR_PTR );
HB_EXPR_PTR hb_compErrorBound( HB_EXPR_PTR );
HB_EXPR_PTR hb_compErrorAlias( HB_EXPR_PTR );
void hb_compErrorDuplVar( char * );
HB_EXPR_PTR hb_compWarnMeaningless( HB_EXPR_PTR );
void hb_compCheckArgs( char *, int );
void hb_compGenError( char* _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 );
void hb_compGenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2);
/* variable used by compiler
*/
extern FUNCTIONS hb_comp_functions, hb_comp_funcalls;
extern SYMBOLS hb_comp_symbols;
extern PATHNAMES * hb_comp_pIncludePath;
extern PFUNCTION hb_comp_pInitFunc;
extern PHB_FNAME hb_comp_pFileName;
extern BOOL hb_comp_bStartProc;
extern BOOL hb_comp_bLineNumbers;
extern BOOL hb_comp_bQuiet;
extern BOOL hb_comp_bRestrictSymbolLength;
extern BOOL hb_comp_bShortCuts;
extern int hb_comp_iWarnings;
extern BOOL hb_comp_bAnyWarning;
extern BOOL hb_comp_bAutoMemvarAssume;
extern BOOL hb_comp_bForceMemvars;
extern BOOL hb_comp_bDebugInfo;
extern char hb_comp_szPrefix[ 20 ];
extern BOOL hb_comp_bGenCVerbose;
extern int hb_comp_iExitLevel;
extern int hb_comp_iFunctionCnt;
extern BOOL hb_comp_bExternal;
extern char hb_comp_cVarType;
extern int hb_comp_iVarScope;
extern BOOL hb_comp_bDontGenLineNum;
extern FILES hb_comp_files;
extern int hb_comp_iStaticCnt;
extern int hb_comp_iErrorCount;
extern PTR_LOOPEXIT hb_comp_pLoops;
extern USHORT hb_comp_wSeqCounter;
extern USHORT hb_comp_wForCounter;
extern USHORT hb_comp_wIfCounter;
extern USHORT hb_comp_wWhileCounter;
extern USHORT hb_comp_wCaseCounter;
extern char * hb_comp_szCErrors[];
extern char * hb_comp_szCWarnings[];
HB_EXPR_PTR hb_compExprNewEmpty( void );
HB_EXPR_PTR hb_compExprNewNil( void );
HB_EXPR_PTR hb_compExprNewDouble( double, unsigned char );
HB_EXPR_PTR hb_compExprNewLong( LONG );
HB_EXPR_PTR hb_compExprNewString( char * );
HB_EXPR_PTR hb_compExprNewLogical( int );
HB_EXPR_PTR hb_compExprNewSelf( void );
HB_EXPR_PTR hb_compExprNewCodeBlock( void );
HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewVar( char * );
HB_EXPR_PTR hb_compExprNewAliasVar( HB_EXPR_PTR, char * );
HB_EXPR_PTR hb_compExprNewAliasExpr( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewSymbol( char * );
HB_EXPR_PTR hb_compExprNewEQ( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewNE( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewLT( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewLE( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewGT( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewGE( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewIN( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPlus( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewMinus( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewMult( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewDiv( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewMod( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPower( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewAssign( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewEqual( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPlusEq( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewMinusEq( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewMultEq( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewDivEq( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewModEq( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewExpEq( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPostInc( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPostDec( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPreInc( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewPreDec( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewAnd( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewOr( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewNot( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewNegate( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR, char * );
HB_EXPR_PTR hb_compExprNewVarRef( char * );
HB_EXPR_PTR hb_compExprNewFunRef( char * );
HB_EXPR_PTR hb_compExprNewCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewFunCall( char *, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewFunCallArg( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewSend( HB_EXPR_PTR, char * );
HB_EXPR_PTR hb_compExprNewMethodCall( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewList( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewArgList( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprAddListExpr( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR, HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprGenPop( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprGenPush( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR );
ULONG hb_compExprListLen( HB_EXPR_PTR );
void hb_compExprDelete( HB_EXPR_PTR );
char * hb_compExprDescription( HB_EXPR_PTR );
HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR, char *, BYTE );
#endif /* HB_COMPILER_H_ */

View File

@@ -76,7 +76,10 @@
#define ERR_BADPARAM 35
#define ERR_BADFILENAME 36
#define ERR_MAYHEM_IN_CASE 37
#define ERR_ALIASEXP 38
#define ERR_INVALID_TYPE 38
#define ERR_INVALID_ALIAS 39
#define ERR_INVALID_INDEX 40
#define ERR_INVALID_BOUND 41
#define WARN_AMBIGUOUS_VAR 1
#define WARN_MEMVAR_ASSUMED 2
@@ -93,6 +96,7 @@
#define WARN_OPERAND_SUSPECT 13
#define WARN_LOGICAL_SUSPECT 14
#define WARN_NUMERIC_SUSPECT 15
#define WARN_MEANINGLESS 16
/*
* Errors generated by Harbour preprocessor
@@ -113,7 +117,7 @@
#define WARN_NONDIRECTIVE 1
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 */
extern void hb_compGenError( char * _szErrors[], char, int, char *, char * ); /* generic parsing error management function */
extern void hb_compGenWarning( char * _szWarnings[], char, int, char *, char * ); /* generic parsing warning management function */
#endif /* HB_ERRORS_H_ */

View File

@@ -111,10 +111,10 @@ extern void hb_xfree( void * pMem ); /* frees memory */
/* Needed support variables, but not contained in HBPP.C */
extern PATHNAMES * _pIncludePath;
extern PHB_FNAME _pFileName;
extern DEFINES * topDefine;
extern COMMANDS * topCommand;
extern COMMANDS * topTranslate;
#include "compiler.h"
#endif /* HB_PP_H_ */

View File

@@ -39,8 +39,8 @@
typedef enum
{
HB_P_AND, /* peforms the logical AND of two latest stack values, removes them and places result */
HB_P_ARRAYAT, /* places on the virtual machine stack an array element */
HB_P_ARRAYPUT, /* sets array element, the array and the index are both on the stack */
HB_P_ARRAYPUSH, /* places on the virtual machine stack an array element */
HB_P_ARRAYPOP, /* pops a value from the eval stack into an array element */
HB_P_ARRAYDIM, /* instructs the virtual machine to build an array with some specific dimensions */
HB_P_ARRAYGEN, /* instructs the virtual machine to build an array and load elemnst from the stack */
HB_P_EQUAL, /* check if the latest two values on the stack are equal, removing them and leaving there the result */

File diff suppressed because it is too large Load Diff

View File

@@ -33,17 +33,13 @@
*
*/
#include "extend.h"
#include "compiler.h"
#include "pcode.h"
#include "hberrors.h"
#include "hbver.h"
void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
{
char szFileName[ _POSIX_PATH_MAX ];
PFUNCTION pFunc = functions.pFirst, pFTemp;
PCOMSYMBOL pSym = symbols.pFirst;
PFUNCTION pFunc = hb_comp_functions.pFirst, pFTemp;
PCOMSYMBOL pSym = hb_comp_symbols.pFirst;
USHORT w, wLen, wSym, wVar;
USHORT iNestedCodeblock = 0;
ULONG lPCodePos;
@@ -59,11 +55,11 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
yyc = fopen( szFileName, "wb" );
if( ! yyc )
{
GenError( _szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
hb_compGenError( hb_comp_szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
return;
}
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
{
printf( "\nGenerating C source output to \'%s\'... ", szFileName );
fflush( stdout );
@@ -81,7 +77,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "#include \"hb_vmpub.h\"\n" );
fprintf( yyc, "#include \"init.h\"\n\n\n" );
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pFunc = pFunc->pNext; /* No implicit starting procedure */
/* write functions prototypes for PRG defined functions */
@@ -90,18 +86,18 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
if( pFunc->cScope & FS_STATIC || pFunc->cScope & FS_INIT || pFunc->cScope & FS_EXIT )
fprintf( yyc, "static " );
if( pFunc == _pInitFunc )
if( pFunc == hb_comp_pInitFunc )
fprintf( yyc, "HARBOUR hb_INITSTATICS( void );\n" ); /* NOTE: hb_ intentionally in lower case */
else
fprintf( yyc, "HARBOUR HB_%s( void );\n", pFunc->szName );
pFunc = pFunc->pNext;
}
/* write functions prototypes for called functions outside this PRG */
pFunc = funcalls.pFirst;
pFunc = hb_comp_funcalls.pFirst;
while( pFunc )
{
pFTemp = GetFunction( pFunc->szName );
if( ! pFTemp || pFTemp == functions.pFirst )
if( ! pFTemp || pFTemp == hb_comp_functions.pFirst )
fprintf( yyc, "extern HARBOUR HB_%s( void );\n", pFunc->szName );
pFunc = pFunc->pNext;
}
@@ -110,9 +106,9 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
/* Generate the wrapper that will initialize local symbol table
*/
yy_strupr( pFileName->szName );
fprintf( yyc, "\n\nHB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_%s%s )\n", _szPrefix, pFileName->szName );
fprintf( yyc, "\n\nHB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_%s%s )\n", hb_comp_szPrefix, pFileName->szName );
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pSym = pSym->pNext; /* starting procedure is always the first symbol */
wSym = 0; /* symbols counter */
@@ -159,25 +155,25 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
}
++wSym;
if( pSym != symbols.pLast )
if( pSym != hb_comp_symbols.pLast )
fprintf( yyc, ",\n" );
pSym = pSym->pNext;
}
fprintf( yyc, "\nHB_INIT_SYMBOLS_END( hb_vm_SymbolInit_%s%s )\n", _szPrefix, pFileName->szName );
fprintf( yyc, "#if ! defined(__GNUC__) && ! defined(_MSC_VER)\n #pragma startup hb_vm_SymbolInit_%s%s\n#endif\n\n\n", _szPrefix, pFileName->szName );
fprintf( yyc, "\nHB_INIT_SYMBOLS_END( hb_vm_SymbolInit_%s%s )\n", hb_comp_szPrefix, pFileName->szName );
fprintf( yyc, "#if ! defined(__GNUC__) && ! defined(_MSC_VER)\n #pragma startup hb_vm_SymbolInit_%s%s\n#endif\n\n\n", hb_comp_szPrefix, pFileName->szName );
/* Generate functions data
*/
pFunc = functions.pFirst;
if( ! _bStartProc )
pFunc = hb_comp_functions.pFirst;
if( ! hb_comp_bStartProc )
pFunc = pFunc->pNext; /* No implicit starting procedure */
while( pFunc )
{
if( pFunc->cScope != FS_PUBLIC )
fprintf( yyc, "static " );
if( pFunc == _pInitFunc ) /* Is it (_INITSTATICS) */
if( pFunc == hb_comp_pInitFunc ) /* Is it (_INITSTATICS) */
fprintf( yyc, "HARBOUR hb_INITSTATICS( void )" ); /* NOTE: hb_ intentionally in lower case */
else
fprintf( yyc, "HARBOUR HB_%s( void )", pFunc->szName );
@@ -195,13 +191,13 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
lPCodePos++;
break;
case HB_P_ARRAYAT:
fprintf( yyc, "\tHB_P_ARRAYAT,\n" );
case HB_P_ARRAYPUSH:
fprintf( yyc, "\tHB_P_ARRAYPUSH,\n" );
lPCodePos++;
break;
case HB_P_ARRAYPUT:
fprintf( yyc, "\tHB_P_ARRAYPUT,\n" );
case HB_P_ARRAYPOP:
fprintf( yyc, "\tHB_P_ARRAYPOP,\n" );
lPCodePos++;
break;
@@ -215,7 +211,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_ARRAYDIM, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i */", w );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i */", w );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
@@ -296,7 +292,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_FRAME, %i, %i,",
bLocals - pFunc->wParamCount,
pFunc->wParamCount );
if( _bGenCVerbose ) fprintf( yyc, "\t/* locals, params */" );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* locals, params */" );
fprintf( yyc, "\n" );
}
lPCodePos += 3;
@@ -320,7 +316,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_ARRAYGEN, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i */", w );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i */", w );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
@@ -348,11 +344,12 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
case HB_P_JUMP:
/* if( 1 ) ( lPCodePos + 3 ) < pFunc->lPCodePos ) */
{
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
SHORT sPos;
sPos = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
fprintf( yyc, "\tHB_P_JUMP, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", sPos, lPCodePos + ( sPos ? sPos : 3 ) );
fprintf( yyc, "\n" );
}
lPCodePos += 3;
@@ -363,7 +360,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_JUMPFALSE, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
@@ -373,7 +370,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_JUMPTRUE, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
@@ -389,13 +386,13 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
break;
case HB_P_LINE:
if( _bGenCVerbose ) fprintf( yyc, "/* %05li */ ", lPCodePos );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "/* %05li */ ", lPCodePos );
else fprintf( yyc, "\t" );
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
fprintf( yyc, "HB_P_LINE, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i */", w );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i */", w );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
@@ -404,7 +401,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_LOCALNAME, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", ( char * ) pFunc->pCode + lPCodePos + 3 );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", ( char * ) pFunc->pCode + lPCodePos + 3 );
fprintf( yyc, "\n" );
lPCodePos += 3;
while( pFunc->pCode[ lPCodePos ] )
@@ -428,7 +425,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_MESSAGE, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wSym )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wSym )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -441,9 +438,9 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
case HB_P_MODULENAME:
fprintf( yyc, "\tHB_P_MODULENAME," );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", ( char * ) pFunc->pCode + lPCodePos + 1 );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", ( char * ) pFunc->pCode + lPCodePos++ + 1 );
fprintf( yyc, "\n" );
lPCodePos++;
lPCodePos++;
while( pFunc->pCode[ lPCodePos ] )
{
chr = pFunc->pCode[ lPCodePos++ ];
@@ -496,7 +493,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ),
pFunc->pCode[ lPCodePos + 3 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 4;
}
@@ -526,7 +523,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPALIASEDFIELD, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -541,7 +538,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPFIELD, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -562,7 +559,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPLOCAL, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* localvar%i */", -wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* localvar%i */", -wVar );
fprintf( yyc, "\n" );
}
else
@@ -570,7 +567,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPLOCAL, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* codeblockvar%i */", wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* codeblockvar%i */", wVar );
fprintf( yyc, "\n" );
}
}
@@ -579,7 +576,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPLOCAL, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, wVar )->szName );
fprintf( yyc, "\n" );
}
lPCodePos += 3;
@@ -595,7 +592,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPMEMVAR, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -604,7 +601,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
case HB_P_POPSTATIC:
{
PVAR pVar;
PFUNCTION pTmp = functions.pFirst;
PFUNCTION pTmp = hb_comp_functions.pFirst;
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar )
@@ -613,7 +610,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPSTATIC, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", pVar->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", pVar->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -628,7 +625,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_POPVARIABLE, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -654,7 +651,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHALIASEDFIELD, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -666,7 +663,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHBLOCK, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i */",
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i */",
pFunc->pCode[ lPCodePos + 1 ] +
pFunc->pCode[ lPCodePos + 2 ] * 256 );
fprintf( yyc, "\n" );
@@ -675,14 +672,14 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\t%i, %i,",
pFunc->pCode[ lPCodePos + 3 ],
pFunc->pCode[ lPCodePos + 4 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* number of local parameters (%i) */", w );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* number of local parameters (%i) */", w );
fprintf( yyc, "\n" );
wVar = * ( ( USHORT * ) &( pFunc->pCode [ lPCodePos + 5 ] ) );
fprintf( yyc, "\t%i, %i,",
pFunc->pCode[ lPCodePos + 5 ],
pFunc->pCode[ lPCodePos + 6 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* number of local variables (%i) */", wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* number of local variables (%i) */", wVar );
fprintf( yyc, "\n" );
lPCodePos += 7; /* codeblock size + number of parameters + number of local variables */
@@ -693,7 +690,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\t%i, %i,",
pFunc->pCode[ lPCodePos ],
pFunc->pCode[ lPCodePos + 1 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, w )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, w )->szName );
fprintf( yyc, "\n" );
lPCodePos +=2;
}
@@ -706,7 +703,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHDOUBLE, " );
for( i = 0; i < sizeof( double ) + sizeof( BYTE ); ++i )
fprintf( yyc, "%i,", ( ( BYTE * ) pFunc->pCode )[ lPCodePos + i ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %.*f, %d */",
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %.*f, %d */",
*( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ),
*( ( double * ) &( pFunc->pCode[ lPCodePos ] ) ),
*( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ) );
@@ -725,7 +722,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHFIELD, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -735,7 +732,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHINT, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i */",
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i */",
pFunc->pCode[ lPCodePos + 1 ] +
pFunc->pCode[ lPCodePos + 2 ] * 256 );
fprintf( yyc, "\n" );
@@ -757,7 +754,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHLOCAL, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* localvar%i */", -wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* localvar%i */", -wVar );
fprintf( yyc, "\n" );
}
else
@@ -765,7 +762,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHLOCAL, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* codeblockvar%i */", wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* codeblockvar%i */", wVar );
fprintf( yyc, "\n" );
}
}
@@ -774,7 +771,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHLOCAL, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, wVar )->szName );
fprintf( yyc, "\n" );
}
lPCodePos += 3;
@@ -796,7 +793,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHLOCALREF, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* localvar%i */", -wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* localvar%i */", -wVar );
fprintf( yyc, "\n" );
}
else
@@ -804,7 +801,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHLOCALREF, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* codeblockvar%i */", wVar );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* codeblockvar%i */", wVar );
fprintf( yyc, "\n" );
}
}
@@ -813,7 +810,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHLOCALREF, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetVar( pFunc->pLocals, wVar )->szName );
fprintf( yyc, "\n" );
}
lPCodePos += 3;
@@ -826,7 +823,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
pFunc->pCode[ lPCodePos + 2 ],
pFunc->pCode[ lPCodePos + 3 ],
pFunc->pCode[ lPCodePos + 4 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %li */", *( ( long * ) &( pFunc->pCode[ lPCodePos + 1 ] ) ) );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %li */", *( ( long * ) &( pFunc->pCode[ lPCodePos + 1 ] ) ) );
fprintf( yyc, "\n" );
lPCodePos += ( 1 + sizeof( long ) );
break;
@@ -841,7 +838,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHMEMVAR, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -857,7 +854,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHMEMVARREF, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -876,7 +873,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
case HB_P_PUSHSTATIC:
{
PVAR pVar;
PFUNCTION pTmp = functions.pFirst;
PFUNCTION pTmp = hb_comp_functions.pFirst;
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar )
@@ -885,7 +882,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHSTATIC, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", pVar->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", pVar->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -894,7 +891,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
case HB_P_PUSHSTATICREF:
{
PVAR pVar;
PFUNCTION pTmp = functions.pFirst;
PFUNCTION pTmp = hb_comp_functions.pFirst;
wVar = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar )
@@ -903,7 +900,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHSTATICREF, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", pVar->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", pVar->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -915,18 +912,28 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHSTR, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i */", wLen );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i */", wLen );
lPCodePos +=3;
if( wLen > 0 )
{
unsigned char uchr;
fprintf( yyc, "\n\t" );
while( wLen-- )
{
chr = pFunc->pCode[ lPCodePos++ ];
if( chr == '\'' || chr == '\\')
fprintf( yyc, "\'\\%c\', ", chr );
uchr = ( unsigned char ) ( pFunc->pCode[ lPCodePos++ ] );
/*
* NOTE: After optimization some CHR(n) can be converted
* into a string containing nonprintable characters.
*
* TODO: add switch to use hexadecimal format "%#04x"
*/
if( ( uchr < (unsigned char) ' ' ) || ( uchr >= 127 ) )
fprintf( yyc, "%i, ", uchr );
else if( strchr( "\'\\\"", uchr ) )
fprintf( yyc, "%i, ", uchr );
else
fprintf( yyc, "\'%c\', ", chr );
fprintf( yyc, "\'%c\', ", uchr );
}
}
fprintf( yyc, "\n" );
@@ -942,7 +949,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHSYM, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wSym )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wSym )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -958,7 +965,7 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_PUSHVARIABLE, %i, %i,",
HB_LOBYTE( wFixPos ),
HB_HIBYTE( wFixPos ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %s */", GetSymbolOrd( wVar )->szName );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %s */", hb_compGetSymbolOrd( wVar )->szName );
fprintf( yyc, "\n" );
lPCodePos += 3;
}
@@ -974,19 +981,19 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fprintf( yyc, "\tHB_P_SEQBEGIN, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
case HB_P_SEQEND:
if( _bGenCVerbose ) fprintf( yyc, "/* %05li */ ", lPCodePos );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "/* %05li */ ", lPCodePos );
else fprintf( yyc, "\t" );
w = pFunc->pCode[ lPCodePos + 1 ] + pFunc->pCode[ lPCodePos + 2 ] * 256;
fprintf( yyc, "HB_P_SEQEND, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
pFunc->pCode[ lPCodePos + 2 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* %i (abs: %05li) */", w, lPCodePos + ( w ? w : 3 ) );
fprintf( yyc, "\n" );
lPCodePos += 3;
break;
@@ -1000,11 +1007,11 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
/* we only generate it if there are statics used in this function */
if( pFunc->bFlags & FUN_USES_STATICS )
{
GetSymbol( _pInitFunc->szName, &w );
hb_compGetSymbol( hb_comp_pInitFunc->szName, &w );
w = FixSymbolPos( w );
fprintf( yyc, "\tHB_P_SFRAME, %i, %i,",
HB_LOBYTE( w ), HB_HIBYTE( w ) );
if( _bGenCVerbose ) fprintf( yyc, "\t/* symbol (_INITSTATICS) */" );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* symbol (_INITSTATICS) */" );
fprintf( yyc, "\n" );
}
lPCodePos += 3;
@@ -1012,14 +1019,14 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
case HB_P_STATICS:
GetSymbol( _pInitFunc->szName, &w );
hb_compGetSymbol( hb_comp_pInitFunc->szName, &w );
w = FixSymbolPos( w );
fprintf( yyc, "\tHB_P_STATICS, %i, %i, %i, %i,",
HB_LOBYTE( w ),
HB_HIBYTE( w ),
pFunc->pCode[ lPCodePos + 3 ],
pFunc->pCode[ lPCodePos + 4 ] );
if( _bGenCVerbose ) fprintf( yyc, "\t/* symbol (_INITSTATICS), %i statics */", pFunc->pCode[ lPCodePos + 3 ] + pFunc->pCode[ lPCodePos + 4 ] * 256 );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "\t/* symbol (_INITSTATICS), %i statics */", pFunc->pCode[ lPCodePos + 3 ] + pFunc->pCode[ lPCodePos + 4 ] * 256 );
fprintf( yyc, "\n" );
lPCodePos += 5;
break;
@@ -1049,13 +1056,13 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
if( bEndProcRequired )
{
if( _bGenCVerbose ) fprintf( yyc, "/* %05li */ ", lPCodePos );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "/* %05li */ ", lPCodePos );
else fprintf( yyc, "\t" );
fprintf( yyc, "HB_P_ENDPROC\n" );
}
else
{
if( _bGenCVerbose ) fprintf( yyc, "/* %05li */\n", lPCodePos );
if( hb_comp_bGenCVerbose ) fprintf( yyc, "/* %05li */\n", lPCodePos );
}
fprintf( yyc, " };\n\n" );
@@ -1065,22 +1072,22 @@ void GenCCode( PHB_FNAME pFileName ) /* generates the C language output */
fclose( yyc );
pFunc = functions.pFirst;
pFunc = hb_comp_functions.pFirst;
while( pFunc )
pFunc = KillFunction( pFunc );
pFunc = funcalls.pFirst;
pFunc = hb_comp_funcalls.pFirst;
while( pFunc )
{
funcalls.pFirst = pFunc->pNext;
hb_comp_funcalls.pFirst = pFunc->pNext;
hb_xfree( ( void * ) pFunc ); /* NOTE: szName will be released by KillSymbol() */
pFunc = funcalls.pFirst;
pFunc = hb_comp_funcalls.pFirst;
}
pSym = symbols.pFirst;
pSym = hb_comp_symbols.pFirst;
while( pSym )
pSym = KillSymbol( pSym );
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
printf( "Done.\n" );
}

View File

@@ -33,10 +33,7 @@
*
*/
#include "extend.h"
#include "compiler.h"
#include "pcode.h"
#include "hberrors.h"
#define SYM_NOLINK 0 /* Symbol does not have to be linked */
#define SYM_FUNC 1 /* Defined function */
@@ -45,8 +42,8 @@
void GenPortObj( PHB_FNAME pFileName )
{
char szFileName[ _POSIX_PATH_MAX ];
PFUNCTION pFunc /*= functions.pFirst */;
PCOMSYMBOL pSym = symbols.pFirst;
PFUNCTION pFunc /*= hb_comp_functions.pFirst */;
PCOMSYMBOL pSym = hb_comp_symbols.pFirst;
USHORT w, wLen, wVar;
LONG lPCodePos;
LONG lPad;
@@ -62,11 +59,11 @@ void GenPortObj( PHB_FNAME pFileName )
yyc = fopen( szFileName, "wb" );
if( ! yyc )
{
GenError( _szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
hb_compGenError( hb_comp_szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
return;
}
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
{
printf( "\nGenerating Harbour Portable Object output to \'%s\'... ", szFileName );
fflush( stdout );
@@ -74,7 +71,7 @@ void GenPortObj( PHB_FNAME pFileName )
/* writes the symbol table */
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pSym = pSym->pNext; /* starting procedure is always the first symbol */
lSymbols = 0; /* Count number of symbols */
@@ -88,8 +85,8 @@ void GenPortObj( PHB_FNAME pFileName )
fputc( ( BYTE ) ( ( lSymbols >> 16 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( lSymbols >> 24 ) & 255 ), yyc );
pSym = symbols.pFirst;
if( ! _bStartProc )
pSym = hb_comp_symbols.pFirst;
if( ! hb_comp_bStartProc )
pSym = pSym->pNext; /* starting procedure is always the first symbol */
while( pSym )
@@ -121,8 +118,8 @@ void GenPortObj( PHB_FNAME pFileName )
pSym = pSym->pNext;
}
pFunc = functions.pFirst;
if( ! _bStartProc )
pFunc = hb_comp_functions.pFirst;
if( ! hb_comp_bStartProc )
pFunc = pFunc->pNext;
lSymbols = 0; /* Count number of symbols */
@@ -138,8 +135,8 @@ void GenPortObj( PHB_FNAME pFileName )
/* Generate functions data
*/
pFunc = functions.pFirst;
if( ! _bStartProc )
pFunc = hb_comp_functions.pFirst;
if( ! hb_comp_bStartProc )
pFunc = pFunc->pNext; /* No implicit starting procedure */
while( pFunc )
@@ -166,8 +163,8 @@ void GenPortObj( PHB_FNAME pFileName )
switch( pFunc->pCode[ lPCodePos ] )
{
case HB_P_AND:
case HB_P_ARRAYAT:
case HB_P_ARRAYPUT:
case HB_P_ARRAYPUSH:
case HB_P_ARRAYPOP:
case HB_P_DEC:
case HB_P_DIVIDE:
case HB_P_DUPLICATE:
@@ -339,7 +336,7 @@ void GenPortObj( PHB_FNAME pFileName )
/* we only generate it if there are statics used in this function */
if( pFunc->bFlags & FUN_USES_STATICS )
{
GetSymbol( _pInitFunc->szName, &w );
hb_compGetSymbol( hb_comp_pInitFunc->szName, &w );
w = FixSymbolPos( w );
fputc( pFunc->pCode[ lPCodePos ], yyc );
fputc( HB_LOBYTE( w ), yyc );
@@ -351,7 +348,7 @@ void GenPortObj( PHB_FNAME pFileName )
break;
case HB_P_STATICS:
GetSymbol( _pInitFunc->szName, &w );
hb_compGetSymbol( hb_comp_pInitFunc->szName, &w );
w = FixSymbolPos( w );
fputc( pFunc->pCode[ lPCodePos ], yyc );
fputc( HB_LOBYTE( w ), yyc );
@@ -389,6 +386,7 @@ void GenPortObj( PHB_FNAME pFileName )
fclose( yyc );
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
printf( "Done.\n" );
}

View File

@@ -52,8 +52,8 @@ static int _nChar = 0;
void GenJava( PHB_FNAME pFileName )
{
char szFileName[ _POSIX_PATH_MAX ];
PFUNCTION pFunc /*= functions.pFirst */;
PCOMSYMBOL pSym = symbols.pFirst;
PFUNCTION pFunc /*= hb_comp_functions.pFirst */;
PCOMSYMBOL pSym = hb_comp_symbols.pFirst;
USHORT w, wLen, wVar;
LONG lPCodePos;
LONG lPad;
@@ -69,11 +69,11 @@ void GenJava( PHB_FNAME pFileName )
yyc = fopen( szFileName, "wb" );
if( ! yyc )
{
GenError( _szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
hb_compGenError( hb_comp_szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
return;
}
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
{
printf( "\nGenerating Java source output to \'%s\'... ", szFileName );
fflush( stdout );
@@ -93,7 +93,7 @@ void GenJava( PHB_FNAME pFileName )
/* writes the symbol table */
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pSym = pSym->pNext; /* starting procedure is always the first symbol */
lSymbols = 0; /* Count number of symbols */
@@ -107,8 +107,8 @@ void GenJava( PHB_FNAME pFileName )
hb_fputc( ( BYTE ) ( ( lSymbols >> 16 ) & 255 ), yyc );
hb_fputc( ( BYTE ) ( ( lSymbols >> 24 ) & 255 ), yyc );
pSym = symbols.pFirst;
if( ! _bStartProc )
pSym = hb_comp_symbols.pFirst;
if( ! hb_comp_bStartProc )
pSym = pSym->pNext; /* starting procedure is always the first symbol */
while( pSym )
@@ -140,8 +140,8 @@ void GenJava( PHB_FNAME pFileName )
pSym = pSym->pNext;
}
pFunc = functions.pFirst;
if( ! _bStartProc )
pFunc = hb_comp_functions.pFirst;
if( ! hb_comp_bStartProc )
pFunc = pFunc->pNext;
lSymbols = 0; /* Count number of symbols */
@@ -157,8 +157,8 @@ void GenJava( PHB_FNAME pFileName )
/* Generate functions data
*/
pFunc = functions.pFirst;
if( ! _bStartProc )
pFunc = hb_comp_functions.pFirst;
if( ! hb_comp_bStartProc )
pFunc = pFunc->pNext; /* No implicit starting procedure */
while( pFunc )
@@ -185,8 +185,8 @@ void GenJava( PHB_FNAME pFileName )
switch( pFunc->pCode[ lPCodePos ] )
{
case HB_P_AND:
case HB_P_ARRAYAT:
case HB_P_ARRAYPUT:
case HB_P_ARRAYPUSH:
case HB_P_ARRAYPOP:
case HB_P_DEC:
case HB_P_DIVIDE:
case HB_P_DUPLICATE:
@@ -358,7 +358,7 @@ void GenJava( PHB_FNAME pFileName )
/* we only generate it if there are statics used in this function */
if( pFunc->bFlags & FUN_USES_STATICS )
{
GetSymbol( _pInitFunc->szName, &w );
hb_compGetSymbol( hb_comp_pInitFunc->szName, &w );
w = FixSymbolPos( w );
hb_fputc( pFunc->pCode[ lPCodePos ], yyc );
hb_fputc( HB_LOBYTE( w ), yyc );
@@ -370,7 +370,7 @@ void GenJava( PHB_FNAME pFileName )
break;
case HB_P_STATICS:
GetSymbol( _pInitFunc->szName, &w );
hb_compGetSymbol( hb_comp_pInitFunc->szName, &w );
w = FixSymbolPos( w );
hb_fputc( pFunc->pCode[ lPCodePos ], yyc );
hb_fputc( HB_LOBYTE( w ), yyc );
@@ -415,7 +415,7 @@ void GenJava( PHB_FNAME pFileName )
fclose( yyc );
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
printf( "Done.\n" );
}

View File

@@ -82,11 +82,11 @@ void GenObj32( PHB_FNAME pFileName )
if( ! ( hObjFile = fopen( szFileName, "wb" ) ) )
{
GenError( _szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
hb_compGenError( hb_comp_szCErrors, 'E', ERR_CREATE_OUTPUT, szFileName, NULL );
return;
}
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
{
printf( "\nGenerating Windows/DOS OBJ32 output to \'%s\'... ", szFileName );
fflush( stdout );
@@ -103,20 +103,20 @@ void GenObj32( PHB_FNAME pFileName )
fclose( hObjFile );
if( ! _bQuiet )
if( ! hb_comp_bQuiet )
printf( "Done.\n" );
}
static ULONG GetSymbolsSize( void )
{
return ( symbols.iCount - ( _bStartProc ? 0: 1 ) ) * sizeof( HB_SYMB );
return ( hb_comp_symbols.iCount - ( hb_comp_bStartProc ? 0: 1 ) ) * sizeof( HB_SYMB );
}
static PCOMSYMBOL GetFirstSymbol( void )
{
PCOMSYMBOL pSymbol = symbols.pFirst;
PCOMSYMBOL pSymbol = hb_comp_symbols.pFirst;
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pSymbol = pSymbol->pNext;
return pSymbol;
@@ -136,9 +136,9 @@ static char * GetSymbolName( ULONG ulPos )
static ULONG GetPCodesSize( void )
{
ULONG ulTotal = 0;
PFUNCTION pFunction = functions.pFirst;
PFUNCTION pFunction = hb_comp_functions.pFirst;
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pFunction = pFunction->pNext;
while( pFunction )
@@ -260,9 +260,9 @@ static void GenerateDataSegment( FILE * hObjFile )
static void GenerateCodeSegment( FILE * hObjFile )
{
USHORT wFunctions = functions.iCount - ( _bStartProc ? 0: 1 );
USHORT wFunctions = hb_comp_functions.iCount - ( hb_comp_bStartProc ? 0: 1 );
ULONG ulSize = wFunctions * sizeof( prgFunction );
PFUNCTION pFunc = ( _bStartProc ? functions.pFirst: functions.pFirst->pNext );
PFUNCTION pFunc = ( hb_comp_bStartProc ? hb_comp_functions.pFirst: hb_comp_functions.pFirst->pNext );
USHORT w = 0;
DefineSegment( hObjFile, 2, /* "_TEXT" position + 1 into localNames */
@@ -299,10 +299,10 @@ static void GenerateExternals( FILE * hObjFile )
PFUNCTION pFunc, pFTemp;
/* calculate amount of externals */
pFunc = funcalls.pFirst;
pFunc = hb_comp_funcalls.pFirst;
while( pFunc )
{
if( ! ( pFTemp = GetFunction( pFunc->szName ) ) || pFTemp == functions.pFirst )
if( ! ( pFTemp = GetFunction( pFunc->szName ) ) || pFTemp == hb_comp_functions.pFirst )
wExternals++;
pFunc = pFunc->pNext;
}
@@ -312,10 +312,10 @@ static void GenerateExternals( FILE * hObjFile )
w = 1;
externNames[ 0 ] = "_hb_vmExecute";
pFunc = funcalls.pFirst;
pFunc = hb_comp_funcalls.pFirst;
while( pFunc )
{
if( ! ( pFTemp = GetFunction( pFunc->szName ) ) || pFTemp == functions.pFirst )
if( ! ( pFTemp = GetFunction( pFunc->szName ) ) || pFTemp == hb_comp_functions.pFirst )
externNames[ w++ ] = pFunc->szName;
pFunc = pFunc->pNext;
}
@@ -463,10 +463,10 @@ static void CodeSegment( FILE * hObjFile, BYTE * prgCode, ULONG ulPrgLen, USHORT
USHORT y;
USHORT wTotalLen = ( ulPrgLen * wFunctions ) + 4;
ULONG ul;
PFUNCTION pFunction = functions.pFirst;
ULONG ulPCodeOffset = ( symbols.iCount - ( _bStartProc ? 0: 1 ) ) * sizeof( HB_SYMB );
PFUNCTION pFunction = hb_comp_functions.pFirst;
ULONG ulPCodeOffset = ( hb_comp_symbols.iCount - ( hb_comp_bStartProc ? 0: 1 ) ) * sizeof( HB_SYMB );
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pFunction = pFunction->pNext;
putbyte( 0xA0, hObjFile );
@@ -503,11 +503,11 @@ static void DataSegment( FILE * hObjFile, BYTE * symbol, USHORT wSymLen, USHORT
USHORT w, y;
USHORT wTotalLen = 4 + ulSize;
PCOMSYMBOL pSymbol = GetFirstSymbol();
PFUNCTION pFunction = functions.pFirst;
PFUNCTION pFunction = hb_comp_functions.pFirst;
ULONG ulSymbolNameOffset = GetSymbolsSize() + GetPCodesSize();
ULONG ulFunctionOffset;
if( ! _bStartProc )
if( ! hb_comp_bStartProc )
pFunction = pFunction->pNext;
putbyte( 0xA0, hObjFile );

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -793,7 +793,7 @@ METHOD ClosePopup( nPopup ) CLASS TDbMenu
DispOutAt( 0, ::aItems[ nPopup ]:nCol,;
StrTran( ::aItems[ nPopup ]:cPrompt, "~", "" ), ::cClrPopup )
DispOutAt( 0, ::aItems[ nPopup ]:nCol + nAt := At( "~", ::aItems[ nPopup ]:cPrompt ) - 1,;
DispOutAt( 0, ::aItems[ nPopup ]:nCol + ( nAt := At( "~", ::aItems[ nPopup ]:cPrompt ) ) - 1,;
SubStr( ::aItems[ nPopup ]:cPrompt, nAt + 2, 1 ), ::cClrHotKey )
endif
// dispend()
@@ -832,8 +832,8 @@ METHOD Display() CLASS TDbMenu
DispOutAt( ::aItems[ n ]:nRow, ::aItems[ n ]:nCol,;
StrTran( ::aItems[ n ]:cPrompt, "~", "" ) )
DispOutAt( ::aItems[ n ]:nRow, ::aItems[ n ]:nCol + nAt := ;
At( "~", ::aItems[ n ]:cPrompt ) - 1 ,;
DispOutAt( ::aItems[ n ]:nRow, ::aItems[ n ]:nCol + ;
( nAt := At( "~", ::aItems[ n ]:cPrompt ) ) - 1 ,;
SubStr( ::aItems[ n ]:cPrompt, nAt + 2, 1 ), ::cClrHotKey )
endif
next
@@ -896,8 +896,8 @@ METHOD GoLeft() CLASS TDbMenu
DispOutAt( oMenuItem:nRow, oMenuItem:nCol,;
StrTran( oMenuItem:cPrompt, "~", "" ) )
DispOutAt( oMenuItem:nRow, oMenuItem:nCol + nAt := ;
At( "~", oMenuItem:cPrompt ) - 1 ,;
DispOutAt( oMenuItem:nRow, oMenuItem:nCol + ;
( nAt := At( "~", oMenuItem:cPrompt ) ) - 1 ,;
SubStr( oMenuItem:cPrompt, nAt + 2, 1 ), ::cClrHotKey )
endif
if ::nOpenPopup > 1
@@ -929,8 +929,8 @@ METHOD GoRight() CLASS TDbMenu
DispOutAt( oMenuItem:nRow, oMenuItem:nCol ,;
StrTran( oMenuItem:cPrompt, "~", "" ) )
DispOutAt( oMenuItem:nRow, oMenuItem:nCol + nAt := ;
At( "~", oMenuItem:cPrompt ) - 1 ,;
DispOutAt( oMenuItem:nRow, oMenuItem:nCol + ;
( nAt := At( "~", oMenuItem:cPrompt ) ) - 1 ,;
SubStr( oMenuItem:cPrompt, nAt + 2, 1 ), ::cClrHotKey )
endif
if ::nOpenPopup < Len( ::aItems )
@@ -968,15 +968,16 @@ METHOD ShowPopup( nPopup ) CLASS TDbMenu
DispOutAt( 0, ::aItems[ nPopup ]:nCol ,;
StrTran( ::aItems[ nPopup ]:cPrompt, "~", "" ), ::cClrHilite )
DispOutAt( 0, ::aItems[ nPopup ]:nCol + nAt := At( "~", ::aItems[ nPopup ]:cPrompt ) - 1 ,;
DispOutAt( 0, ::aItems[ nPopup ]:nCol + ;
( nAt := At( "~", ::aItems[ nPopup ]:cPrompt ) ) - 1 ,;
SubStr( ::aItems[ nPopup ]:cPrompt, nAt + 2, 1 ), ::cClrHotFocus )
else
oMenuItem = ::aItems[ nPopup ]
DispOutAt( oMenuItem:nRow, oMenuItem:nCol ,;
StrTran( oMenuItem:cPrompt, "~", "" ), ::cClrHilite )
DispOutAt( oMenuItem:nRow, oMenuItem:nCol + nAt := ;
At( "~", oMenuItem:cPrompt ) - 1 ,;
DispOutAt( oMenuItem:nRow, oMenuItem:nCol + ;
( nAt := At( "~", oMenuItem:cPrompt ) ) - 1 ,;
SubStr( oMenuItem:cPrompt, nAt + 2, 1 ), ::cClrHotFocus )
endif
@@ -1052,8 +1053,8 @@ METHOD Display( cClrText, cClrHotKey ) CLASS TDbMenuItem
DispOutAt( ::nRow, ::nCol ,;
StrTran( ::cPrompt, "~", "" ), cClrText )
DispOutAt( ::nRow, ::nCol + nAt := ;
At( "~", ::cPrompt ) - 1 ,;
DispOutAt( ::nRow, ::nCol + ;
( nAt := At( "~", ::cPrompt ) ) - 1 ,;
SubStr( ::cPrompt, nAt + 2, 1 ), cClrHotKey )
return nil

View File

@@ -184,7 +184,7 @@ int ParseDirective( char* sLine )
if ( i == 4 && memcmp ( sDirective, "ELSE", 4 ) == 0 )
{ /* --- #else --- */
if ( nCondCompile == 0 )
GenError( _szPErrors, 'P', ERR_DIRECTIVE_ELSE, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_DIRECTIVE_ELSE, NULL, NULL );
else if ( nCondCompile == 1 || aCondCompile[nCondCompile-2] )
aCondCompile[nCondCompile-1] = 1 - aCondCompile[nCondCompile-1];
}
@@ -192,7 +192,7 @@ int ParseDirective( char* sLine )
else if ( i == 5 && memcmp ( sDirective, "ENDIF", 5 ) == 0 )
{ /* --- #endif --- */
if ( nCondCompile == 0 )
GenError( _szPErrors, 'P', ERR_DIRECTIVE_ENDIF, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_DIRECTIVE_ENDIF, NULL, NULL );
else nCondCompile--;
}
@@ -209,7 +209,7 @@ int ParseDirective( char* sLine )
char cDelimChar;
if ( *sLine != '\"' && *sLine != '\'' && *sLine != '<' )
GenError( _szPErrors, 'P', ERR_WRONG_NAME, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_WRONG_NAME, NULL, NULL );
cDelimChar = *sLine;
if (cDelimChar == '<')
@@ -218,12 +218,12 @@ int ParseDirective( char* sLine )
sLine++; i = 0;
while ( *(sLine+i) != '\0' && *(sLine+i) != cDelimChar ) i++;
if ( *(sLine+i) != cDelimChar )
GenError( _szPErrors, 'P', ERR_WRONG_NAME, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_WRONG_NAME, NULL, NULL );
*(sLine+i) = '\0';
/* if ((handl_i = fopen(sLine, "r")) == NULL) */
if ( !OpenInclude( sLine, _pIncludePath, &handl_i, (cDelimChar == '>'), szInclude ) )
GenError( _szPErrors, 'P', ERR_CANNOT_OPEN, sLine, NULL );
if ( !OpenInclude( sLine, hb_comp_pIncludePath, &handl_i, (cDelimChar == '>'), szInclude ) )
hb_compGenError( _szPErrors, 'P', ERR_CANNOT_OPEN, sLine, NULL );
lInclude++;
Hp_Parse(handl_i, 0, szInclude );
lInclude--;
@@ -251,12 +251,12 @@ int ParseDirective( char* sLine )
else if ( i == 5 && memcmp ( sDirective, "ERROR", 5 ) == 0 )
/* --- #error --- */
GenError( _szPErrors, 'P', ERR_EXPLICIT, sLine, NULL );
hb_compGenError( _szPErrors, 'P', ERR_EXPLICIT, sLine, NULL );
else if ( i == 4 && memcmp ( sDirective, "LINE", 4 ) == 0 )
return -1;
else
GenError( _szPErrors, 'P', ERR_WRONG_DIRECTIVE, sDirective, NULL );
hb_compGenError( _szPErrors, 'P', ERR_WRONG_DIRECTIVE, sDirective, NULL );
}
return 0;
}
@@ -295,7 +295,7 @@ int ParseDefine( char* sLine)
lastdef->pars = ( npars <= 0 )? NULL : strodup ( pars );
}
else
GenError( _szPErrors, 'P', ERR_DEFINE_ABSENT, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_DEFINE_ABSENT, NULL, NULL );
return 0;
}
@@ -360,7 +360,7 @@ int ParseIfdef( char* sLine, int usl)
{
NextWord( &sLine, defname, FALSE );
if ( *defname == '\0' )
GenError( _szPErrors, 'P', ERR_DEFINE_ABSENT, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_DEFINE_ABSENT, NULL, NULL );
}
if ( nCondCompile == maxCondCompile )
{
@@ -463,7 +463,7 @@ void ParseCommand( char* sLine, int com_or_xcom, int com_or_tra )
if ( (ipos = pp_strAt( "=>", 2, sLine, strolen(sLine) )) > 0 )
stroncpy( mpatt, sLine, ipos-1 );
else
GenError( _szPErrors, 'P', ERR_COMMAND_DEFINITION, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_COMMAND_DEFINITION, NULL, NULL );
RemoveSlash( mpatt );
mlen = strotrim( mpatt );
@@ -530,13 +530,13 @@ void ConvertPatterns ( char *mpatt, int mlen, char *rpatt, int rlen )
{
if ( *(exppatt+explen-1) == '*' ) explen--;
else
GenError( _szPErrors, 'P', ERR_PATTERN_DEFINITION, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_PATTERN_DEFINITION, NULL, NULL );
}
else if ( exptype == '4' )
{
if ( *(exppatt+explen-1) == ')' ) explen--;
else
GenError( _szPErrors, 'P', ERR_PATTERN_DEFINITION, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_PATTERN_DEFINITION, NULL, NULL );
}
rmlen = i - ipos + 1;
/* Convert match marker into inner format */
@@ -751,7 +751,7 @@ int ParseExpression( char* sLine, char* sOutLine )
while ( ipos != 0 );
kolpass++;
if( kolpass > 20 && rezDef )
GenError( _szPErrors, 'P', ERR_RECURSE, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_RECURSE, NULL, NULL );
}
while ( rezDef || rezTra || rezCom );
@@ -2291,7 +2291,7 @@ BOOL OpenInclude( char * szFileName, PATHNAMES *pSearch, FILE** fptr, BOOL bStan
else
{
pFileName = hb_fsFNameSplit( szFileName );
pFileName->szPath = _pFileName->szPath;
pFileName->szPath = hb_comp_pFileName->szPath;
hb_fsFNameMerge( szInclude, pFileName );
*fptr = fopen( szInclude, "r" );
hb_xfree( pFileName );

View File

@@ -195,7 +195,7 @@ int Hp_Parse( FILE * handl_i, FILE * handl_o, char * szSource )
else
{
sprintf( szLine, "%d", iLine );
GenWarning( _szPWarnings, 'I', WARN_NONDIRECTIVE, szSource, szLine );
hb_compGenWarning( _szPWarnings, 'I', WARN_NONDIRECTIVE, szSource, szLine );
}
}
}

View File

@@ -50,8 +50,8 @@
#include "itemapi.h"
#include "hberrors.h"
PATHNAMES * _pIncludePath = NULL;
PHB_FNAME _pFileName = NULL;
PATHNAMES * hb_comp_pIncludePath = NULL;
PHB_FNAME hb_comp_pFileName = NULL;
jmp_buf s_env;
@@ -103,7 +103,7 @@ HARBOUR HB___PREPROCESS( void )
hb_retc( "" );
}
void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )
void hb_compGenError( char * _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )
{
HB_TRACE(HB_TR_DEBUG, ("GenError(%p, %c, %d, %s, %s)", _szErrors, cPrefix, iError, szError1, szError2));
@@ -118,7 +118,7 @@ void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, ch
longjmp( s_env, iError );
}
void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
void hb_compGenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
{
HB_TRACE(HB_TR_DEBUG, ("GenWarning(%p, %c, %d, %s, %s)", _szWarnings, cPrefix, iWarning, szWarning1, szWarning2));

View File

@@ -68,8 +68,8 @@ void AddSearchPath( char *, PATHNAMES * * ); /* add pathname to a search list */
char sLine[ STR_SIZE ], sOutLine[ STR_SIZE ];
PATHNAMES *_pIncludePath = NULL;
PHB_FNAME _pFileName = NULL;
PATHNAMES *hb_comp_pIncludePath = NULL;
PHB_FNAME hb_comp_pFileName = NULL;
int _iWarnings = 0;
int main( int argc, char * argv[] )
@@ -115,7 +115,7 @@ int main( int argc, char * argv[] )
break;
case 'i':
case 'I':
AddSearchPath( argv[ iArg ]+2, &_pIncludePath );
AddSearchPath( argv[ iArg ]+2, &hb_comp_pIncludePath );
break;
case 'o':
case 'O':
@@ -140,15 +140,15 @@ int main( int argc, char * argv[] )
break;
}
}
else _pFileName = hb_fsFNameSplit( argv[ iArg ] );
else hb_comp_pFileName = hb_fsFNameSplit( argv[ iArg ] );
iArg++;
}
if( _pFileName )
if( hb_comp_pFileName )
{
if( ! _pFileName->szExtension )
_pFileName->szExtension =".prg";
if( ! hb_comp_pFileName->szExtension )
hb_comp_pFileName->szExtension =".prg";
hb_fsFNameMerge( szFileName, _pFileName );
hb_fsFNameMerge( szFileName, hb_comp_pFileName );
if( ( handl_i = fopen( szFileName, "r" ) ) == NULL )
{
@@ -176,8 +176,8 @@ int main( int argc, char * argv[] )
return 1;
}
_pFileName->szExtension = ".ppo";
hb_fsFNameMerge( szFileName, _pFileName );
hb_comp_pFileName->szExtension = ".ppo";
hb_fsFNameMerge( szFileName, hb_comp_pFileName );
if( ( handl_o = fopen( szFileName, "wt" ) ) == NULL )
{
@@ -197,10 +197,10 @@ int main( int argc, char * argv[] )
while( ( pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR ) ) != NULL )
{
*pDelim = '\0';
AddSearchPath( pPath, &_pIncludePath );
AddSearchPath( pPath, &hb_comp_pIncludePath );
pPath = pDelim + 1;
}
AddSearchPath( pPath, &_pIncludePath );
AddSearchPath( pPath, &hb_comp_pIncludePath );
}
}
@@ -460,9 +460,9 @@ void AddSearchPath( char * szPath, PATHNAMES * * pSearchList )
pPath->szPath = szPath;
}
void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )
void hb_compGenError( char * _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 )
{
HB_TRACE(HB_TR_DEBUG, ("GenError(%p, %c, %d, %s, %s)", _szErrors, cPrefix, iError, szError1, szError2));
HB_TRACE(HB_TR_DEBUG, ("hb_compGenError(%p, %c, %d, %s, %s)", _szErrors, cPrefix, iError, szError1, szError2));
printf( "\r(%i) ", nline );
printf( "Error %c%04i ", cPrefix, iError );
@@ -472,9 +472,9 @@ void GenError( char * _szErrors[], char cPrefix, int iError, char * szError1, ch
exit( EXIT_FAILURE );
}
void GenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
void hb_compGenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
{
HB_TRACE(HB_TR_DEBUG, ("GenWarning(%p, %c, %d, %s, %s)", _szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
HB_TRACE(HB_TR_DEBUG, ("hb_compGenWarning(%p, %c, %d, %s, %s)", _szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
if( _iWarnings )
{
@@ -654,7 +654,7 @@ void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on fail
HB_TRACE(HB_TR_DEBUG, ("hb_xgrab(%lu)", ulSize));
if( ! pMem )
GenError( _szPErrors, 'P', ERR_PPMEMALLOC, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_PPMEMALLOC, NULL, NULL );
return pMem;
}
@@ -666,7 +666,7 @@ void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */
HB_TRACE(HB_TR_DEBUG, ("hb_xrealloc(%p, %lu)", pMem, ulSize));
if( ! pResult )
GenError( _szPErrors, 'P', ERR_PPMEMREALLOC, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_PPMEMREALLOC, NULL, NULL );
return pResult;
}
@@ -678,5 +678,5 @@ void hb_xfree( void * pMem ) /* frees fixed memory */
if( pMem )
free( pMem );
else
GenError( _szPErrors, 'P', ERR_PPMEMFREE, NULL, NULL );
hb_compGenError( _szPErrors, 'P', ERR_PPMEMFREE, NULL, NULL );
}

View File

@@ -106,8 +106,8 @@ static void hb_vmAnd( void ); /* performs the logical AND on the
static void hb_vmOr( void ); /* performs the logical OR on the latest two values, removes them and leaves result on the stack */
/* Array */
static void hb_vmArrayAt( void ); /* pushes an array element to the stack, removing the array and the index from the stack */
static void hb_vmArrayPut( void ); /* sets an array value and pushes the value on to the stack */
static void hb_vmArrayPush( void ); /* pushes an array element to the stack, removing the array and the index from the stack */
static void hb_vmArrayPop( void ); /* pops a value from the stack */
static void hb_vmArrayDim( USHORT uiDimensions ); /* generates an uiDimensions Array and initialize those dimensions from the stack values */
static void hb_vmArrayGen( ULONG ulElements ); /* generates an ulElements Array and fills it from the stack values */
static void hb_vmArrayNew( HB_ITEM_PTR, USHORT ); /* creates array */
@@ -479,13 +479,13 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols )
/* Array */
case HB_P_ARRAYAT:
hb_vmArrayAt();
case HB_P_ARRAYPUSH:
hb_vmArrayPush();
w++;
break;
case HB_P_ARRAYPUT:
hb_vmArrayPut();
case HB_P_ARRAYPOP:
hb_vmArrayPop();
w++;
break;
@@ -1816,41 +1816,41 @@ static void hb_vmInstring( void )
}
}
/* At this moment the eval stack should store:
* -3 -> <step value>
* -2 -> <current counter value>
* -1 -> <end value>
*/
static void hb_vmForTest( void ) /* Test to check the end point of the FOR */
{
int iDec;
double dStep;
BOOL bEqual;
HB_TRACE(HB_TR_DEBUG, ("hb_vmForTest()"));
while( ! IS_NUMERIC( hb_stack.pPos - 1 ) )
if( IS_NUMERIC( hb_stack.pPos - 1 ) )
{
PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1073, NULL, "<" );
int iDec;
double dCurrent, dEnd, dStep;
if( pResult )
dEnd = hb_vmPopDouble( &iDec );
if( IS_NUMERIC( hb_stack.pPos - 1 ) )
{
hb_stackPop();
hb_vmPush( pResult );
hb_itemRelease( pResult );
dCurrent = hb_vmPopDouble( &iDec );
if( IS_NUMERIC( hb_stack.pPos - 1 ) )
{
dStep = hb_vmPopDouble( &iDec );
if( dStep > 0 ) /* Positive loop. Use LESS */
hb_vmPushLogical( dCurrent <= dEnd );
else if( dStep < 0 ) /* Negative loop. Use GREATER */
hb_vmPushLogical( dCurrent >= dEnd );
}
else
hb_errRT_BASE( EG_ARG, 1073, NULL, "<" );
}
else
/* NOTE: Return from the inside. */
return;
hb_errRT_BASE( EG_ARG, 1073, NULL, "<" );
}
dStep = hb_vmPopDouble( &iDec );
/* NOTE: step of zero will cause endless loop, as in Clipper */
if( dStep > 0 ) /* Positive loop. Use LESS */
hb_vmLess();
else if( dStep < 0 ) /* Negative loop. Use GREATER */
hb_vmGreater();
bEqual = hb_vmPopLogical(); /* Logical should be on top of stack */
hb_vmPushNumber( dStep, iDec ); /* Push the step expression back on the stack */
hb_vmPushLogical( bEqual );
else
hb_errRT_BASE( EG_ARG, 1073, NULL, "<" );
}
/* ------------------------------- */
@@ -1958,7 +1958,7 @@ static void hb_vmOr( void )
/* Array */
/* ------------------------------- */
static void hb_vmArrayAt( void )
static void hb_vmArrayPush( void )
{
PHB_ITEM pIndex;
PHB_ITEM pArray;
@@ -2006,7 +2006,7 @@ static void hb_vmArrayAt( void )
}
}
static void hb_vmArrayPut( void )
static void hb_vmArrayPop( void )
{
PHB_ITEM pValue;
PHB_ITEM pIndex;
@@ -2015,9 +2015,9 @@ static void hb_vmArrayPut( void )
HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPut()"));
pValue = hb_stack.pPos - 1;
pIndex = hb_stack.pPos - 2;
pArray = hb_stack.pPos - 3;
pValue = hb_stack.pPos - 3;
pArray = hb_stack.pPos - 2;
pIndex = hb_stack.pPos - 1;
if( IS_INTEGER( pIndex ) )
ulIndex = pIndex->item.asInteger.value;
@@ -2040,6 +2040,7 @@ static void hb_vmArrayPut( void )
hb_itemCopy( pArray, pValue ); /* places pValue at pArray position */
hb_stackPop();
hb_stackPop();
hb_stackPop(); /* remove the value from the stack just like other POP operations */
}
}
@@ -2346,7 +2347,7 @@ void hb_vmDo( USHORT uiParams )
if( pSelfBase->uiPrevCls ) /* Is is a Super cast ? */
{
pSelfBase->uiClass = pSelfBase->uiPrevCls;
pSelfBase->uiPrevCls = NULL;
pSelfBase->uiPrevCls = 0;
}
}
}