2017-09-08 16:00 UTC Viktor Szakats (vszakats users.noreply.github.com)
* *
* partial sync with the 3.4 fork codebase. These are the things
synces for the most part:
- copyright headers
- grammar/typos in comments and some readmes
- comment/whitespace/decorations
- variable scoping in C files
- DO CASE/SWITCH and some other alternate syntax usage
- minimal amount of human readable text in strings
- minor code updates
- HB_TRACE() void * casts for pointers and few other changes to
avoid C compiler warnings
- various other, minor code cleanups
- only Harbour/C code/headers were touched in src, utils, contrib,
include. No 3rd party code, no make files, and with just a few
exceptions, no 'tests' code was touched.
- certain components were not touched were 3.4 diverged too much
already, like f.e. hbmk2, hbssl, hbcurl, hbexpat
- the goal was that no actual program logic should be altered by
these changes. Except some possible minor exceptions, any such
change is probably a bug in this patch.
It's a massive patch, if you find anything broken after it, please
open an Issue with the details. Build test was done on macOS.
The goal is make it easier to see what actual code/logic was changed
in 3.4 compared to 3.2 and to make patches easier to apply in both
ways.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Compiler command line and environment parameters checking
|
||||
* Compiler command-line and environment parameters checking
|
||||
*
|
||||
* Copyright 2015 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
@@ -119,7 +119,7 @@ static void hb_compChkIgnoredInfo( HB_COMP_DECL, const char * szSwitch )
|
||||
char buffer[ 64 ];
|
||||
|
||||
hb_snprintf( buffer, sizeof( buffer ),
|
||||
"Ignored unsupported command line option: %s\n", szSwitch );
|
||||
"Ignored unsupported command-line option: %s\n", szSwitch );
|
||||
hb_compOutStd( HB_COMP_PARAM, buffer );
|
||||
}
|
||||
|
||||
@@ -455,6 +455,7 @@ static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch,
|
||||
break;
|
||||
default:
|
||||
szSwPtr = hb_compChkOptionAddPath( HB_COMP_PARAM, szSwPtr, fEnv );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -592,6 +593,7 @@ static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch,
|
||||
default:
|
||||
ch = -1;
|
||||
--szSwPtr;
|
||||
break;
|
||||
}
|
||||
if( ch == -1 )
|
||||
break;
|
||||
@@ -693,6 +695,7 @@ static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch,
|
||||
/* fallthrough */
|
||||
default:
|
||||
HB_COMP_PARAM->fQuiet = HB_TRUE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -838,7 +841,7 @@ static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch,
|
||||
return "";
|
||||
}
|
||||
|
||||
/* check command line parameters */
|
||||
/* check command-line parameters */
|
||||
void hb_compChkCommandLine( HB_COMP_DECL, int argc, const char * const argv[] )
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -44,11 +44,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbcomp.h"
|
||||
|
||||
|
||||
/* ============================ I18N ============================ */
|
||||
static PHB_I18NTABLE hb_compI18nCreate( void )
|
||||
{
|
||||
PHB_I18NTABLE pI18n;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* compiler lexer which converts PP tokens to the ones which
|
||||
* grammar parser generated by bison can understand
|
||||
* Compiler lexer which converts PP tokens to the ones which
|
||||
* grammar parser generated by bison can understand
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
@@ -45,8 +45,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbpp.h"
|
||||
#include "hbcomp.h"
|
||||
#include "hbpp.h"
|
||||
#include "hbdate.h"
|
||||
#include "harboury.h"
|
||||
|
||||
@@ -378,7 +378,7 @@ static int hb_comp_dayTimeDecode( PHB_COMP_LEX pLex, PHB_PP_TOKEN pToken,
|
||||
* VFP accepts slash, dot or hyphen as date delimiter and
|
||||
* 12 or 24-hour formatted time,
|
||||
* If only hours are included in time part then comma have to
|
||||
* be used to separate date and time parts or it's necesary
|
||||
* be used to separate date and time parts or it's necessary
|
||||
* to follow the hours with a colon.
|
||||
* { ^ <YEAR> <sep:/.-> <MONTH> <sep:/.-> <DAY> [[<sep2:,>]
|
||||
* [ <HOUR> [ : <MIN> [ : <SEC> [ . <FRAQ> ] ] ] [AM|PP] ] }
|
||||
@@ -872,7 +872,7 @@ int hb_comp_yylex( YYSTYPE * yylval_ptr, HB_COMP_DECL )
|
||||
if( ! HB_SUPPORT_HARBOUR && HB_COMP_PARAM->iSyntaxCheckOnly < 2 )
|
||||
{
|
||||
/* Clipper does not like end[], end(), end->, end-- & end++ at
|
||||
the begining of line */
|
||||
the beginning of line */
|
||||
if( HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_LEFT_PB ||
|
||||
HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_LEFT_SB ||
|
||||
HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_INC ||
|
||||
@@ -974,7 +974,7 @@ int hb_comp_yylex( YYSTYPE * yylval_ptr, HB_COMP_DECL )
|
||||
if( ! HB_SUPPORT_HARBOUR && HB_COMP_PARAM->iSyntaxCheckOnly < 2 )
|
||||
{
|
||||
/* Clipper does not like NEXT[], NEXT(), NEXT->,
|
||||
NEXT++ & NEXT-- at the begining of line */
|
||||
NEXT++ & NEXT-- at the beginning of line */
|
||||
if( HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_LEFT_PB ||
|
||||
HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_LEFT_SB ||
|
||||
HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_INC ||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hbexpra.c is also included from ../macro/macro.c
|
||||
* However it produces a slighty different code if used in
|
||||
* However it produces a slightly different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
*/
|
||||
#include "hbexpra.c"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hbexprb.c is also included from ../macro/macro.c
|
||||
* However it produces a slighty different code if used in
|
||||
* However it produces a slightly different code if used in
|
||||
* macro compiler (there is an additional parameter passed to some functions)
|
||||
*/
|
||||
#include "hbexprb.c"
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
* their web site at https://www.gnu.org/).
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -167,7 +167,6 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the
|
||||
PHB_HINLINE pInline;
|
||||
FILE * yyc; /* file handle for C output */
|
||||
HB_BOOL fHasHbInline = HB_FALSE;
|
||||
int iFuncSuffix;
|
||||
|
||||
hb_fsFNameMerge( szFileName, pFileName );
|
||||
if( ! pFileName->szExtension )
|
||||
@@ -210,6 +209,8 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the
|
||||
|
||||
if( pFunc )
|
||||
{
|
||||
int iFuncSuffix;
|
||||
|
||||
hb_compDumpFindCFunc( HB_COMP_PARAM );
|
||||
|
||||
pInline = HB_COMP_PARAM->inlines.pFirst;
|
||||
@@ -497,8 +498,8 @@ static void hb_compGenCByteStr( FILE * yyc, const HB_BYTE * pText, HB_SIZE nLen
|
||||
{
|
||||
HB_BYTE uchr = ( HB_BYTE ) pText[ nPos ];
|
||||
/*
|
||||
* NOTE: After optimization some Chr(n) can be converted
|
||||
* into a string containing nonprintable characters.
|
||||
* NOTE: After optimization some Chr( n ) can be converted
|
||||
* into a string containing non-printable characters.
|
||||
*
|
||||
* TODO: add switch to use hexadecimal format "%#04x"
|
||||
*/
|
||||
@@ -515,7 +516,7 @@ static void hb_compGenCLocalName( PHB_HFUNC pFunc, int iLocal, HB_SIZE nPCodePos
|
||||
|
||||
if( cargo->nEndBlockPos > nPCodePos )
|
||||
{
|
||||
/* we are accesing variables within a codeblock */
|
||||
/* we are accessing variables within a codeblock */
|
||||
/* the names of codeblock variable are lost */
|
||||
if( iLocal < 0 )
|
||||
fprintf( cargo->yyc, "\t/* localvar%i */", -iLocal );
|
||||
@@ -2666,7 +2667,7 @@ static const PHB_GENC_FUNC s_verbose_table[] = {
|
||||
hb_p_enumend,
|
||||
hb_p_switch,
|
||||
hb_p_pushdate,
|
||||
/* optimalization of inlined math operations (+=, -= */
|
||||
/* optimization of inlined math operations (+=, -= */
|
||||
hb_p_pluseqpop,
|
||||
hb_p_minuseqpop,
|
||||
hb_p_multeqpop,
|
||||
|
||||
@@ -77,8 +77,8 @@ void hb_compGenCString( FILE * yyc, const HB_BYTE * pText, HB_SIZE nLen )
|
||||
{
|
||||
HB_BYTE uchr = ( HB_BYTE ) pText[ nPos ];
|
||||
/*
|
||||
* NOTE: After optimization some Chr(n) can be converted
|
||||
* into a string containing nonprintable characters.
|
||||
* NOTE: After optimization some Chr( n ) can be converted
|
||||
* into a string containing non-printable characters.
|
||||
*
|
||||
* ? is escaped to avoid conflicts with trigraph sequences which
|
||||
* are part of ANSI C standard
|
||||
@@ -1639,7 +1639,7 @@ static HB_GENC_FUNC( hb_p_seqend )
|
||||
|
||||
HB_GENC_LABEL();
|
||||
|
||||
if( nOffset == 4 ) /* no RECOVER clasue */
|
||||
if( nOffset == 4 ) /* no RECOVER clause */
|
||||
fprintf( cargo->yyc, "\tbreak;\n\t}\n\tif( hb_xvmSeqEnd() ) break;\n" );
|
||||
else /* RECOVER exists */
|
||||
fprintf( cargo->yyc, "\tif( hb_xvmSeqEndTest() ) break;\n\tgoto lab%05" HB_PFS "u;\n\t}\n",
|
||||
@@ -2344,7 +2344,7 @@ static const PHB_GENC_FUNC s_verbose_table[] = {
|
||||
hb_p_enumend,
|
||||
hb_p_switch,
|
||||
hb_p_pushdate,
|
||||
/* optimalization of inlined math operations (+=, -= */
|
||||
/* optimization of inlined math operations (+=, -= */
|
||||
hb_p_pluseqpop,
|
||||
hb_p_minuseqpop,
|
||||
hb_p_multeqpop,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Compiler Harbour Portable Object (.hrb) generation
|
||||
*
|
||||
* Copyright 1999 Eddie Runia <eddie@runia.com>
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* rewritten to work on memory buffers and with new compiler code
|
||||
*
|
||||
@@ -17,9 +16,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
* their web site at https://www.gnu.org/).
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -92,12 +91,12 @@ void hb_compGenBufPortObj( HB_COMP_DECL, HB_BYTE ** pBufPtr, HB_SIZE * pnSize )
|
||||
nLen = strlen( pSym->szName ) + 1;
|
||||
memcpy( ptr, pSym->szName, nLen );
|
||||
ptr += nLen;
|
||||
/* TOFIX: this conversion strips upper byte from symbol scope
|
||||
/* FIXME: this conversion strips upper byte from symbol scope
|
||||
* Now we added workaround for it by using some strict
|
||||
* bit order and restoring some others at runtime when
|
||||
* .hrb file is loaded but we should create new format
|
||||
* for .hrb files in which this field will have at least
|
||||
* 16bit [druzus]
|
||||
* 16-bit [druzus]
|
||||
*/
|
||||
*ptr++ = ( HB_BYTE ) pSym->cScope;
|
||||
/* symbol type */
|
||||
|
||||
@@ -83,8 +83,8 @@ static void hb_compLoopExit( HB_COMP_DECL );
|
||||
static void hb_compLoopHere( HB_COMP_DECL );
|
||||
static long hb_compLoopCount( HB_COMP_DECL );
|
||||
|
||||
static void * hb_compElseIfGen( HB_COMP_DECL, void * pFirstElseIf, HB_SIZE nOffset ); /* generates a support structure for elseifs pcode fixups */
|
||||
static void hb_compElseIfFix( HB_COMP_DECL, void * pIfElseIfs ); /* implements the ElseIfs pcode fixups */
|
||||
static void * hb_compElseIfGen( HB_COMP_DECL, void * pFirstElseIf, HB_SIZE nOffset ); /* generates a support structure for ELSEIFs pcode fixups */
|
||||
static void hb_compElseIfFix( HB_COMP_DECL, void * pIfElseIfs ); /* implements the ELSEIFs pcode fixups */
|
||||
|
||||
static void hb_compRTVariableAdd( HB_COMP_DECL, PHB_EXPR, HB_BOOL );
|
||||
static void hb_compRTVariableGen( HB_COMP_DECL, const char * );
|
||||
@@ -191,9 +191,9 @@ extern void yyerror( HB_COMP_DECL, const char * ); /* parsing error manageme
|
||||
%token THREAD
|
||||
|
||||
/*the lowest precedence*/
|
||||
/*postincrement and postdecrement*/
|
||||
/*post-increment and post-decrement*/
|
||||
%left POST
|
||||
/*assigment - from right to left*/
|
||||
/*assignment - from right to left*/
|
||||
%right INASSIGN
|
||||
%right PLUSEQ MINUSEQ
|
||||
%right MULTEQ DIVEQ MODEQ
|
||||
@@ -210,7 +210,7 @@ extern void yyerror( HB_COMP_DECL, const char * ); /* parsing error manageme
|
||||
%right '*' '/' '%'
|
||||
%right POWER
|
||||
%right UNARY
|
||||
/*preincrement and predecrement*/
|
||||
/*pre-increment and pre-decrement*/
|
||||
%right PRE
|
||||
/*special operators*/
|
||||
%right ALIASOP '&' '@'
|
||||
@@ -1083,7 +1083,7 @@ PareExpListAlias : PareExpList ALIASOP
|
||||
;
|
||||
|
||||
/* NOTE: Clipper allows to pass variable by reference only as
|
||||
* function arguments, IIF() 2-nd and 3-rd arguments and as
|
||||
* function arguments, iif() 2nd and 3rd arguments and as
|
||||
* explicit array items {...@var...}
|
||||
* AFAIK these are also the only one places where empty expressions in
|
||||
* the parenthesis expressions list are accepted
|
||||
@@ -1839,7 +1839,7 @@ BeginSeq : BEGINSEQ /* 1 */
|
||||
{
|
||||
if( $<lNumber>4 != lLoopCount )
|
||||
{
|
||||
/* ALWAYS statement after RECOVER with EXIT/LOOP statments */
|
||||
/* ALWAYS statement after RECOVER with EXIT/LOOP statements */
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ALWAYS_AFTER_EXIT, "EXIT/LOOP", NULL );
|
||||
}
|
||||
--HB_COMP_PARAM->functions.pLast->wAlwaysCounter;
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbcomp.h"
|
||||
|
||||
static void s_pp_msg( void * cargo, int iErrorFmt, int iLine,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* allocate/free new compiler context
|
||||
* Allocate/free new compiler context
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
*
|
||||
@@ -44,7 +44,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbcomp.h"
|
||||
|
||||
static PHB_EXPR hb_compExprAlloc( HB_COMP_DECL )
|
||||
@@ -90,7 +89,7 @@ static PHB_EXPR hb_compExprNew( HB_COMP_DECL, HB_EXPRTYPE iType )
|
||||
{
|
||||
PHB_EXPR pExpr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNew(%p,%i)", HB_COMP_PARAM, iType ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compExprNew(%p,%i)", ( void * ) HB_COMP_PARAM, iType ) );
|
||||
|
||||
pExpr = hb_compExprAlloc( HB_COMP_PARAM );
|
||||
pExpr->ExprType = iType;
|
||||
@@ -263,13 +262,13 @@ PHB_COMP hb_comp_new( void )
|
||||
HB_COMPFLAG_SHORTCUTS;
|
||||
|
||||
pComp->fSwitchCase = HB_FALSE;
|
||||
pComp->fPPO = HB_FALSE; /* flag indicating, is ppo output needed */
|
||||
pComp->fPPO = HB_FALSE; /* flag indicating, is .ppo output needed */
|
||||
pComp->fLineNumbers = HB_TRUE; /* holds if we need pcodes with line numbers */
|
||||
pComp->fAnyWarning = HB_FALSE; /* holds if there was any warning during the compilation process */
|
||||
pComp->fAutoMemvarAssume = HB_FALSE; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
|
||||
pComp->fForceMemvars = HB_FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
|
||||
pComp->fForceMemvars = HB_FALSE; /* holds if memvars are assumed when accessing undeclared variable (-v)*/
|
||||
pComp->fDebugInfo = HB_FALSE; /* holds if generate debugger required info */
|
||||
pComp->fHideSource = HB_FALSE; /* do not stor .prg file names in PCODE */
|
||||
pComp->fHideSource = ! pComp->fDebugInfo; /* do not store .prg file names in PCODE */
|
||||
pComp->fNoStartUp = HB_FALSE; /* C code generation embed HB_FS_FIRST or not */
|
||||
pComp->fCredits = HB_FALSE; /* print credits */
|
||||
pComp->fBuildInfo = HB_FALSE; /* print build info */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* generate line information for debugger
|
||||
* Generate line information for debugger
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* dead (unaccessible) PCODE eliminator
|
||||
* Dead (unaccessible) PCODE eliminator
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
||||
*
|
||||
@@ -490,7 +490,7 @@ static const PHB_CODETRACE_FUNC s_codeTraceFuncTable[] =
|
||||
hb_p_default, /* HB_P_ENUMEND */
|
||||
hb_p_switch, /* HB_P_SWITCH */
|
||||
hb_p_default, /* HB_P_PUSHDATE */
|
||||
/* optimalization of inlined math operations */
|
||||
/* optimization of inlined math operations */
|
||||
hb_p_default, /* HB_P_PLUSEQPOP */
|
||||
hb_p_default, /* HB_P_MINUSEQPOP */
|
||||
hb_p_default, /* HB_P_MULTEQPOP */
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -14,9 +14,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file LICENSE.txt. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA (or visit https://www.gnu.org/licenses/).
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * cFuncName; /* function name */
|
||||
int iMinParam; /* min no of parms it needs */
|
||||
int iMaxParam; /* max no of parms need */
|
||||
const char * cFuncName; /* function name */
|
||||
int iMinParam; /* min number of parameters needed */
|
||||
int iMaxParam; /* max number of parameters needed */
|
||||
} HB_FUNCINFO, * PHB_FUNCINFO;
|
||||
|
||||
|
||||
@@ -107,11 +107,9 @@ static const HB_FUNCINFO s_stdFunc[] =
|
||||
{ "YEAR" , 1, 1 }
|
||||
};
|
||||
|
||||
#define HB_STD_FUNCOUNT ( sizeof( s_stdFunc ) / sizeof( HB_FUNCINFO ) )
|
||||
|
||||
HB_BOOL hb_compFunCallCheck( HB_COMP_DECL, const char * szFuncCall, int iArgs )
|
||||
{
|
||||
unsigned int uiFirst = 0, uiLast = HB_STD_FUNCOUNT - 1, uiMiddle;
|
||||
unsigned int uiFirst = 0, uiLast = HB_SIZEOFARRAY( s_stdFunc ) - 1, uiMiddle;
|
||||
int iLen = ( int ) strlen( szFuncCall ), iCmp;
|
||||
|
||||
/* Respect 4 or more letters shortcuts
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version, with one exception:
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -14,9 +14,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
* their web site at https://www.gnu.org/).
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -58,8 +58,8 @@ const char * const hb_comp_szErrors[] =
|
||||
"Jump offset too long",
|
||||
"Can't create output file '%s'",
|
||||
"Can't create preprocessed output file '%s'",
|
||||
"Bad command line option '%s'",
|
||||
"Bad command line parameter '%s'",
|
||||
"Bad command-line option '%s'",
|
||||
"Bad command-line parameter '%s'",
|
||||
"Invalid filename '%s'",
|
||||
"Mayhem in CASE handler",
|
||||
"Operation not supported for data type '%s'",
|
||||
@@ -109,7 +109,7 @@ const char * const hb_comp_szErrors[] =
|
||||
|
||||
/* Table with parse warnings */
|
||||
/* NOTE: The first character stores the warning's level that triggers this
|
||||
* warning. The warning's level is set by -w<n> command line option.
|
||||
* warning. The warning's level is set by -w<n> command-line option.
|
||||
*/
|
||||
const char * const hb_comp_szWarnings[] =
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -14,15 +14,14 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file LICENSE.txt. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA (or visit https://www.gnu.org/licenses/).
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "hbhash.h"
|
||||
#include "hbcomp.h"
|
||||
|
||||
#define HB_IDENT_TABLE_SIZE 509UL
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* generate table with jump labels
|
||||
* Generate table with jump labels
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
||||
*
|
||||
@@ -321,7 +321,7 @@ static const PHB_LABEL_FUNC s_GenLabelFuncTable[] =
|
||||
NULL, /* HB_P_ENUMEND */
|
||||
NULL, /* HB_P_SWITCH */
|
||||
NULL, /* HB_P_PUSHDATE */
|
||||
/* optimalization of inlined math operations */
|
||||
/* optimization of inlined math operations */
|
||||
NULL, /* HB_P_PLUSEQPOP */
|
||||
NULL, /* HB_P_MINUSEQPOP */
|
||||
NULL, /* HB_P_MULTEQPOP */
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
* Compiler main file
|
||||
*
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetechsoft.com>
|
||||
* Copyright 2000 Ron Pinkas <Ron@Profit-Master.com>
|
||||
* (hb_compPrepareJumps(), hb_compOptimizeJumps(), hb_compOptimizeFrames(),
|
||||
* hb_compDeclaredParameterAdd(), hb_compClassAdd(), hb_compClassFind(),
|
||||
* hb_compMethodAdd(), hb_compMethodFind(), hb_compDeclaredAdd())
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -14,30 +18,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
* their web site at https://www.gnu.org/).
|
||||
*
|
||||
* The following parts are Copyright of the individual authors.
|
||||
*
|
||||
* Copyright 2000 RonPinkas <Ron@Profit-Master.com>
|
||||
* hb_compPrepareJumps()
|
||||
* hb_compOptimizeJumps()
|
||||
* hb_compOptimizeFrames()
|
||||
* hb_compDeclaredParameterAdd()
|
||||
* hb_compClassAdd()
|
||||
* hb_compClassFind()
|
||||
* hb_compMethodAdd()
|
||||
* hb_compMethodFind()
|
||||
* hb_compDeclaredAdd()
|
||||
*
|
||||
* See COPYING.txt for licensing terms.
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Avoid tracing in preprocessor/compiler.
|
||||
*/
|
||||
/* Avoid tracing in preprocessor/compiler. */
|
||||
#if ! defined( HB_TRACE_UTILS )
|
||||
#if defined( HB_TRACE_LEVEL )
|
||||
#undef HB_TRACE_LEVEL
|
||||
@@ -45,7 +32,6 @@
|
||||
#endif
|
||||
|
||||
#include "hbcomp.h"
|
||||
#include "hbhash.h"
|
||||
#include "hbset.h"
|
||||
|
||||
static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuffer, int iStartLine );
|
||||
@@ -63,7 +49,6 @@ int hb_compMainExt( int argc, const char * const argv[],
|
||||
int iStatus = EXIT_SUCCESS, iFileCount = 0;
|
||||
int iFileCase, iDirCase, iDirSep;
|
||||
HB_BOOL fTrimFN;
|
||||
int i;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compMain()" ) );
|
||||
|
||||
@@ -88,7 +73,7 @@ int hb_compMainExt( int argc, const char * const argv[],
|
||||
/* First check the environment variables */
|
||||
hb_compChkEnvironment( HB_COMP_PARAM );
|
||||
|
||||
/* Then check command line arguments
|
||||
/* Then check command-line arguments
|
||||
This will override duplicated environment settings */
|
||||
hb_compChkCommandLine( HB_COMP_PARAM, argc, argv );
|
||||
|
||||
@@ -137,7 +122,8 @@ int hb_compMainExt( int argc, const char * const argv[],
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Process all files passed via the command line. */
|
||||
int i;
|
||||
/* Process all files passed via the command-line. */
|
||||
for( i = 1; i < argc && ! HB_COMP_PARAM->fExit; i++ )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "main LOOP(%i,%s)", i, argv[ i ] ) );
|
||||
@@ -269,9 +255,8 @@ static int hb_compReadClpFile( HB_COMP_DECL, const char * szClpFile )
|
||||
return iStatus;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ACTIONS */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* --- ACTIONS --- */
|
||||
|
||||
|
||||
static PHB_HSYMBOL hb_compSymbolAdd( HB_COMP_DECL, const char * szSymbolName, HB_USHORT * pwPos, HB_BOOL bFunction )
|
||||
@@ -735,7 +720,7 @@ PHB_HVAR hb_compVariableFind( HB_COMP_DECL, const char * szVarName, int * piPos,
|
||||
*
|
||||
* NOTE: Clipper creates such a codeblock however at the
|
||||
* time of codeblock evaluation it generates a runtime error:
|
||||
* 'bound error: array acccess'
|
||||
* 'bound error: array access'
|
||||
* Called from: (b)STATICS$(0)
|
||||
*/
|
||||
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ILLEGAL_INIT, "(b)", szVarName );
|
||||
@@ -909,7 +894,7 @@ static int hb_compVariableScope( HB_COMP_DECL, const char * szVarName )
|
||||
void hb_compPushMacroVar( HB_COMP_DECL, const char * szVarName )
|
||||
{
|
||||
/* save and restore iEarlyEvalPass to not disable early
|
||||
evaluation when only macrovar and/or macrotex is used */
|
||||
evaluation when only macrovar and/or macrotext is used */
|
||||
int iEarlyEvalPass = HB_COMP_PARAM->functions.pLast->iEarlyEvalPass;
|
||||
|
||||
hb_compGenPushVar( szVarName, HB_COMP_PARAM );
|
||||
@@ -929,7 +914,7 @@ void hb_compPushMacroText( HB_COMP_DECL, const char * szText, HB_SIZE nLen, HB_B
|
||||
if( szText[ n++ ] == '&' )
|
||||
{
|
||||
char szSymName[ HB_SYMBOL_NAME_LEN + 1 ];
|
||||
int iSize = 0, iScope;
|
||||
int iSize = 0;
|
||||
|
||||
/* Check if macro operator is used inside a string
|
||||
* Macro operator is ignored if it is the last char or
|
||||
@@ -955,6 +940,8 @@ void hb_compPushMacroText( HB_COMP_DECL, const char * szText, HB_SIZE nLen, HB_B
|
||||
|
||||
if( iSize )
|
||||
{
|
||||
int iScope;
|
||||
|
||||
szSymName[ iSize ] = '\0';
|
||||
|
||||
/* NOTE: All variables are assumed memvars in macro compiler -
|
||||
@@ -1318,7 +1305,7 @@ PHB_VARTYPE hb_compVarTypeNew( HB_COMP_DECL, HB_BYTE cVarType, const char* szFro
|
||||
}
|
||||
|
||||
/* Add to the end of list. I hope it will help the most usual type (' ', NULL)
|
||||
to be in the begining of the list, and it will be found faster. [Mindaugas] */
|
||||
to be in the beginning of the list, and it will be found faster. [Mindaugas] */
|
||||
pVT = ( PHB_VARTYPE ) hb_xgrab( sizeof( HB_VARTYPE ) );
|
||||
pVT->pNext = NULL;
|
||||
pVT->cVarType = cVarType;
|
||||
@@ -1390,7 +1377,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
* [ no jump targets or stack modification here ]
|
||||
* HB_P_JUMP{FALSE|TRUE}*,
|
||||
*
|
||||
* I'll think about sth like that later, [druzus]
|
||||
* I'll think about something like that later, [druzus]
|
||||
*/
|
||||
switch( pCode[ nJumpAddr ] )
|
||||
{
|
||||
@@ -1547,7 +1534,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
/* First Scan NOOPS - Adjust Jump addresses. */
|
||||
for( nNOOP = 0; nNOOP < HB_COMP_PARAM->functions.pLast->nNOOPs; nNOOP++ )
|
||||
{
|
||||
/* Adjusting preceding jumps that pooint to code beyond the current NOOP
|
||||
/* Adjusting preceding jumps that point to code beyond the current NOOP
|
||||
or trailing backward jumps pointing to lower address. */
|
||||
for( nJump = 0; nJump < HB_COMP_PARAM->functions.pLast->nJumps; nJump++ )
|
||||
{
|
||||
@@ -1589,7 +1576,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
pNOOPs[ nNOOP ] < ( HB_SIZE ) ( nJumpAddr + nOffset ) )
|
||||
plSizes[ nJump ]--;
|
||||
}
|
||||
else /* if( nOffset < 0 ) - backword (negative) jump */
|
||||
else /* if( nOffset < 0 ) - backward (negative) jump */
|
||||
{
|
||||
/* Only if points to code prior the current fix. */
|
||||
if( pNOOPs[ nNOOP ] < nJumpAddr &&
|
||||
@@ -1638,7 +1625,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL )
|
||||
}
|
||||
|
||||
nOptimized = nNextByte = 0;
|
||||
/* Second Scan, after all adjustements been made, we can copy the optimized code. */
|
||||
/* Second Scan, after all adjustments been made, we can copy the optimized code. */
|
||||
for( nNOOP = 0; nNOOP < HB_COMP_PARAM->functions.pLast->nNOOPs; nNOOP++ )
|
||||
{
|
||||
nBytes2Copy = ( pNOOPs[ nNOOP ] - nNextByte );
|
||||
@@ -1897,7 +1884,7 @@ static void hb_compFinalizeFunction( HB_COMP_DECL ) /* fixes all last defined fu
|
||||
}
|
||||
|
||||
/*
|
||||
* This function creates and initialises the HB_HFUNC structure
|
||||
* This function creates and initializes the HB_HFUNC structure
|
||||
*/
|
||||
static PHB_HFUNC hb_compFunctionNew( HB_COMP_DECL, const char * szName, HB_SYMBOLSCOPE cScope )
|
||||
{
|
||||
@@ -2229,7 +2216,7 @@ static void hb_compAnnounce( HB_COMP_DECL, const char * szFunName )
|
||||
PHB_HFUNC pFunc;
|
||||
|
||||
/* Clipper call this function after compiling .prg module where ANNOUNCE
|
||||
* symbol was deined not after compiling all .prg modules and search for
|
||||
* symbol was defined not after compiling all .prg modules and search for
|
||||
* public ANNOUNCEd function/procedure in all compiled so far modules
|
||||
* and then for static one in currently compiler module.
|
||||
*/
|
||||
@@ -2564,10 +2551,10 @@ static void hb_compGenVariablePCode( HB_COMP_DECL, HB_BYTE bPCode, const char *
|
||||
/*
|
||||
* NOTE:
|
||||
* Clipper always assumes a memvar variable if undeclared variable
|
||||
* is popped (a value is asssigned to a variable).
|
||||
* is popped (a value is assigned to a variable).
|
||||
*/
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
bGenCode = HB_COMP_PARAM->fForceMemvars; /* harbour compatibility */
|
||||
bGenCode = HB_COMP_PARAM->fForceMemvars; /* Harbour compatibility */
|
||||
else
|
||||
bGenCode = ( HB_COMP_PARAM->fForceMemvars || bPCode == HB_P_POPVARIABLE );
|
||||
|
||||
@@ -2707,7 +2694,7 @@ void hb_compGenPopVar( const char * szVarName, HB_COMP_DECL ) /* generates the p
|
||||
case HB_VS_LOCAL_VAR:
|
||||
case HB_VS_CBLOCAL_VAR:
|
||||
/* local variable */
|
||||
/* local variables used in a coddeblock will not be adjusted
|
||||
/* local variables used in a codeblock will not be adjusted
|
||||
* if PARAMETERS statement will be used then it is safe to
|
||||
* use 2 bytes for LOCALNEAR
|
||||
*/
|
||||
@@ -2767,7 +2754,7 @@ void hb_compGenPopMemvar( const char * szVarName, HB_COMP_DECL )
|
||||
hb_compGenVarPCode( HB_P_POPMEMVAR, szVarName, HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
/* generates the pcode to push a nonaliased variable value to the virtual
|
||||
/* generates the pcode to push a non-aliased variable value to the virtual
|
||||
* machine stack
|
||||
* bMacroVar is HB_TRUE if macro &szVarName context
|
||||
*/
|
||||
@@ -2787,7 +2774,7 @@ void hb_compGenPushVar( const char * szVarName, HB_COMP_DECL )
|
||||
case HB_VS_LOCAL_VAR:
|
||||
case HB_VS_CBLOCAL_VAR:
|
||||
/* local variable */
|
||||
/* local variables used in a coddeblock will not be adjusted
|
||||
/* local variables used in a codeblock will not be adjusted
|
||||
* if PARAMETERS statement will be used then it is safe to
|
||||
* use 2 bytes for LOCALNEAR
|
||||
*/
|
||||
@@ -3159,8 +3146,6 @@ void hb_compGenPushString( const char * szText, HB_SIZE nStrLen, HB_COMP_DECL )
|
||||
|
||||
void hb_compNOOPfill( PHB_HFUNC pFunc, HB_SIZE nFrom, HB_ISIZ nCount, HB_BOOL fPop, HB_BOOL fCheck )
|
||||
{
|
||||
HB_SIZE n;
|
||||
|
||||
while( nCount-- )
|
||||
{
|
||||
if( fPop )
|
||||
@@ -3170,6 +3155,8 @@ void hb_compNOOPfill( PHB_HFUNC pFunc, HB_SIZE nFrom, HB_ISIZ nCount, HB_BOOL fP
|
||||
}
|
||||
else if( fCheck && pFunc->pCode[ nFrom ] == HB_P_NOOP && pFunc->nNOOPs )
|
||||
{
|
||||
HB_SIZE n;
|
||||
|
||||
for( n = 0; n < pFunc->nNOOPs; ++n )
|
||||
{
|
||||
if( pFunc->pNOOPs[ n ] == nFrom )
|
||||
@@ -3193,7 +3180,6 @@ static void hb_compRemovePCODE( HB_COMP_DECL, HB_SIZE nPos, HB_SIZE nCount,
|
||||
HB_BOOL fCanMove )
|
||||
{
|
||||
PHB_HFUNC pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
HB_SIZE n;
|
||||
|
||||
if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_OPTJUMP ) || ! fCanMove )
|
||||
{
|
||||
@@ -3206,6 +3192,8 @@ static void hb_compRemovePCODE( HB_COMP_DECL, HB_SIZE nPos, HB_SIZE nCount,
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_SIZE n;
|
||||
|
||||
memmove( pFunc->pCode + nPos, pFunc->pCode + nPos + nCount,
|
||||
pFunc->nPCodePos - nPos - nCount );
|
||||
pFunc->nPCodePos -= nCount;
|
||||
@@ -3270,7 +3258,7 @@ HB_BOOL hb_compHasJump( PHB_HFUNC pFunc, HB_SIZE nPos )
|
||||
}
|
||||
|
||||
/* Generate the opcode to open BEGIN/END sequence
|
||||
* This code is simmilar to JUMP opcode - the offset will be filled with
|
||||
* This code is similar to JUMP opcode - the offset will be filled with
|
||||
* - either the address of HB_P_SEQEND opcode if there is no RECOVER clause
|
||||
* - or the address of RECOVER code
|
||||
*/
|
||||
@@ -3286,10 +3274,10 @@ HB_SIZE hb_compSequenceBegin( HB_COMP_DECL )
|
||||
}
|
||||
|
||||
/* Generate the opcode to close BEGIN/END sequence
|
||||
* This code is simmilar to JUMP opcode - the offset will be filled with
|
||||
* This code is similar to JUMP opcode - the offset will be filled with
|
||||
* the address of first line after END SEQUENCE
|
||||
* This opcode will be executed if recover code was not requested (as the
|
||||
* last statement in code beetwen BEGIN ... RECOVER) or if BREAK was requested
|
||||
* last statement in code between BEGIN ... RECOVER) or if BREAK was requested
|
||||
* and there was no matching RECOVER clause.
|
||||
*/
|
||||
HB_SIZE hb_compSequenceEnd( HB_COMP_DECL )
|
||||
@@ -3311,7 +3299,7 @@ HB_SIZE hb_compSequenceAlways( HB_COMP_DECL )
|
||||
}
|
||||
|
||||
/* Remove unnecessary opcodes in case there were no executable statements
|
||||
* beetwen BEGIN and RECOVER sequence
|
||||
* between BEGIN and RECOVER sequence
|
||||
*/
|
||||
void hb_compSequenceFinish( HB_COMP_DECL, HB_SIZE nStartPos, HB_SIZE nEndPos,
|
||||
HB_SIZE nAlways, HB_BOOL fUsualStmts, HB_BOOL fRecover,
|
||||
@@ -3453,7 +3441,7 @@ static void hb_compStaticDefThreadSet( HB_COMP_DECL )
|
||||
{
|
||||
if( HB_COMP_PARAM->pInitFunc )
|
||||
{
|
||||
HB_USHORT uiCount = 0, uiVar = 0;
|
||||
HB_USHORT uiCount = 0;
|
||||
PHB_HFUNC pFunc;
|
||||
PHB_HVAR pVar;
|
||||
|
||||
@@ -3469,10 +3457,12 @@ static void hb_compStaticDefThreadSet( HB_COMP_DECL )
|
||||
}
|
||||
pFunc = pFunc->pNext;
|
||||
}
|
||||
|
||||
if( uiCount )
|
||||
{
|
||||
HB_SIZE nSize = ( ( HB_SIZE ) uiCount << 1 ) + 3;
|
||||
HB_BYTE * pBuffer = ( HB_BYTE * ) hb_xgrab( nSize ), *ptr;
|
||||
HB_USHORT uiVar = 0;
|
||||
pBuffer[ 0 ] = HB_P_THREADSTATICS;
|
||||
pBuffer[ 1 ] = HB_LOBYTE( uiCount );
|
||||
pBuffer[ 2 ] = HB_HIBYTE( uiCount );
|
||||
@@ -3566,8 +3556,6 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
HB_SIZE nSize;
|
||||
HB_USHORT wLocals = 0; /* number of referenced local variables */
|
||||
HB_USHORT wLocalsCnt, wLocalsLen;
|
||||
HB_USHORT wPos;
|
||||
int iLocalPos;
|
||||
PHB_HVAR pVar;
|
||||
|
||||
pCodeblock = HB_COMP_PARAM->functions.pLast;
|
||||
@@ -3666,7 +3654,7 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
pVar = pCodeblock->pDetached;
|
||||
while( wLocals-- )
|
||||
{
|
||||
wPos = hb_compVariableGetPos( pFunc->pLocals, pVar->szName );
|
||||
HB_USHORT wPos = hb_compVariableGetPos( pFunc->pLocals, pVar->szName );
|
||||
hb_compGenPCode2( HB_LOBYTE( wPos ), HB_HIBYTE( wPos ), HB_COMP_PARAM );
|
||||
pVar = pVar->pNext;
|
||||
}
|
||||
@@ -3674,6 +3662,8 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
|
||||
if( HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
int iLocalPos;
|
||||
|
||||
hb_compGenModuleName( HB_COMP_PARAM, pFuncName );
|
||||
|
||||
/* generate the name of referenced local variables */
|
||||
@@ -3721,7 +3711,7 @@ void hb_compCodeBlockEnd( HB_COMP_DECL )
|
||||
pFunc->pStatics = pCodeblock->pStatics;
|
||||
pVar = pCodeblock->pStatics;
|
||||
pCodeblock->pStatics = NULL;
|
||||
/* change stati variables names to avoid conflicts */
|
||||
/* change static variables names to avoid conflicts */
|
||||
while( pVar )
|
||||
{
|
||||
char szName[ HB_SYMBOL_NAME_LEN + 4 ];
|
||||
@@ -4174,7 +4164,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff
|
||||
PHB_MODULE pModule;
|
||||
HB_BOOL fGenCode = HB_TRUE;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compCompile(%s,%p,%d)", szPrg, szBuffer, iStartLine ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_compCompile(%s,%p,%d)", szPrg, ( const void * ) szBuffer, iStartLine ) );
|
||||
|
||||
hb_compSaveSwitches( HB_COMP_PARAM, &switches );
|
||||
/* Initialize support variables */
|
||||
@@ -4195,7 +4185,6 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff
|
||||
( pModule || szBuffer ) )
|
||||
{
|
||||
char szFileName[ HB_PATH_MAX ]; /* filename to parse */
|
||||
char szPpoName[ HB_PATH_MAX ];
|
||||
HB_BOOL fSkip = HB_FALSE;
|
||||
|
||||
/* Clear and reinitialize preprocessor state */
|
||||
@@ -4246,6 +4235,8 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff
|
||||
|
||||
if( ! fSkip )
|
||||
{
|
||||
char szPpoName[ HB_PATH_MAX ];
|
||||
|
||||
if( HB_COMP_PARAM->fPPT )
|
||||
{
|
||||
hb_compPpoFile( HB_COMP_PARAM, szFileName, ".ppt", szPpoName );
|
||||
|
||||
@@ -473,7 +473,6 @@ static HB_OPT_FUNC( hb_p_jumpfar )
|
||||
HB_BYTE * pAddr = &pFunc->pCode[ nPCodePos + 1 ];
|
||||
HB_ISIZ nOffset = HB_PCODE_MKINT24( pAddr );
|
||||
HB_SIZE nNewPos = nPCodePos + nOffset;
|
||||
HB_BOOL fLine = HB_FALSE;
|
||||
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
@@ -483,12 +482,15 @@ static HB_OPT_FUNC( hb_p_jumpfar )
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_BOOL fLine = HB_FALSE;
|
||||
|
||||
if( pFunc->pCode[ nNewPos ] == HB_P_LINE )
|
||||
{
|
||||
fLine = HB_TRUE;
|
||||
nNewPos += 3;
|
||||
nOffset += 3;
|
||||
}
|
||||
|
||||
switch( pFunc->pCode[ nNewPos ] )
|
||||
{
|
||||
case HB_P_JUMPFAR:
|
||||
@@ -1179,7 +1181,7 @@ static void hb_compPCodeEnumScanLocals( PHB_HFUNC pFunc, PHB_OPT_LOCAL pLocals )
|
||||
case HB_P_PUSHBLOCKLARGE:
|
||||
{
|
||||
HB_BYTE * pCode = &pFunc->pCode[ nPos + 5 ];
|
||||
HB_USHORT usVarCount, usVar;
|
||||
HB_USHORT usVarCount;
|
||||
|
||||
if( pFunc->pCode[ nPos ] == HB_P_PUSHBLOCKLARGE )
|
||||
pCode++;
|
||||
@@ -1187,6 +1189,7 @@ static void hb_compPCodeEnumScanLocals( PHB_HFUNC pFunc, PHB_OPT_LOCAL pLocals )
|
||||
usVarCount = HB_PCODE_MKUSHORT( pCode );
|
||||
while( usVarCount-- )
|
||||
{
|
||||
HB_USHORT usVar;
|
||||
pCode += 2;
|
||||
usVar = HB_PCODE_MKUSHORT( pCode );
|
||||
if( usVar > 0 )
|
||||
@@ -1339,7 +1342,7 @@ static int hb_compPCodeTraceAssignedUnused( PHB_HFUNC pFunc, HB_SIZE nPos, HB_BY
|
||||
if( hb_compPCodeTraceAssignedUnused( pFunc, nPos2, pMap, isLocal, fCanBreak ) )
|
||||
return 1;
|
||||
}
|
||||
else if( pFunc->pCode[ nPos ] == HB_P_SWITCH ) /* Switch is multiplace jump */
|
||||
else if( pFunc->pCode[ nPos ] == HB_P_SWITCH ) /* Switch is multi-place jump */
|
||||
{
|
||||
HB_USHORT us, usCount = HB_PCODE_MKUSHORT( pFunc->pCode + nPos + 1 );
|
||||
|
||||
@@ -1368,13 +1371,13 @@ static void hb_compPCodeEnumAssignedUnused( HB_COMP_DECL, PHB_HFUNC pFunc, PHB_O
|
||||
{
|
||||
HB_BYTE * pMap;
|
||||
HB_SIZE nPos = 0, nLastPos = 0;
|
||||
HB_SHORT isLocal;
|
||||
HB_USHORT usLine = 0;
|
||||
|
||||
pMap = ( HB_BYTE * ) hb_xgrab( pFunc->nPCodePos );
|
||||
|
||||
while( nPos < pFunc->nPCodePos )
|
||||
{
|
||||
HB_SHORT isLocal;
|
||||
int iCheck = 0;
|
||||
|
||||
if( pFunc->pCode[ nPos ] == HB_P_POPLOCAL ||
|
||||
@@ -1472,8 +1475,8 @@ static void hb_compPCodeEnumAssignedUnused( HB_COMP_DECL, PHB_HFUNC pFunc, PHB_O
|
||||
{
|
||||
char szFun[ 256 ];
|
||||
|
||||
/* TOFIX: We calculate line number by simple tracking last HB_P_LINE,
|
||||
but it can work bad, if line number optimizator is clever enough.
|
||||
/* FIXME: We calculate line number by simple tracking last HB_P_LINE,
|
||||
but it can work bad, if line number optimizer is clever enough.
|
||||
To obtain real line number we need one more tree scan or other
|
||||
algorithm. [Mindaugas] */
|
||||
|
||||
@@ -1560,7 +1563,6 @@ static void hb_compPCodeEnumRenumberLocals( PHB_HFUNC pFunc, PHB_OPT_LOCAL pLoca
|
||||
{
|
||||
HB_BYTE * pVar = &pFunc->pCode[ nPos + 5 ];
|
||||
HB_USHORT usVarCount;
|
||||
HB_SHORT isVar;
|
||||
|
||||
if( pFunc->pCode[ nPos ] == HB_P_PUSHBLOCKLARGE )
|
||||
pVar++;
|
||||
@@ -1568,6 +1570,8 @@ static void hb_compPCodeEnumRenumberLocals( PHB_HFUNC pFunc, PHB_OPT_LOCAL pLoca
|
||||
usVarCount = HB_PCODE_MKUSHORT( pVar );
|
||||
while( usVarCount-- )
|
||||
{
|
||||
HB_SHORT isVar;
|
||||
|
||||
pVar += 2;
|
||||
isVar = HB_PCODE_MKSHORT( pVar );
|
||||
|
||||
@@ -1593,11 +1597,10 @@ void hb_compPCodeTraceOptimizer( HB_COMP_DECL )
|
||||
{
|
||||
PHB_HFUNC pFunc = HB_COMP_PARAM->functions.pLast;
|
||||
PHB_OPT_LOCAL pLocals;
|
||||
PHB_HVAR pVar, * ppVar;
|
||||
PHB_HVAR pVar;
|
||||
HB_USHORT usLocalCount, usIndex;
|
||||
HB_BOOL fBool;
|
||||
|
||||
/* Many (perhaps ALL) functions of pcode trace optimization dependes on pcodes.
|
||||
/* Many (perhaps ALL) functions of pcode trace optimization depends on pcodes.
|
||||
Please, check these functions if new pcode is added, or existing changed.
|
||||
Special attention should be paid, if new pcode introduces branching, codeblocks,
|
||||
or are related to parameters, local variables. [Mindaugas] */
|
||||
@@ -1615,8 +1618,8 @@ void hb_compPCodeTraceOptimizer( HB_COMP_DECL )
|
||||
if( ! usLocalCount )
|
||||
return;
|
||||
|
||||
/* TOFIX: Support for PARAMETER sentence is not implemented.
|
||||
The temporary solution is to disable optmisation at all if PARAMETER is used. */
|
||||
/* FIXME: Support for PARAMETER sentence is not implemented.
|
||||
The temporary solution is to disable optimization at all if PARAMETER is used. */
|
||||
{
|
||||
HB_SIZE nPos = 0;
|
||||
|
||||
@@ -1646,7 +1649,7 @@ void hb_compPCodeTraceOptimizer( HB_COMP_DECL )
|
||||
* if .F.
|
||||
* x := 1
|
||||
* endif
|
||||
* return
|
||||
* return
|
||||
* [druzus]
|
||||
*/
|
||||
#if 0
|
||||
@@ -1695,18 +1698,21 @@ void hb_compPCodeTraceOptimizer( HB_COMP_DECL )
|
||||
/* Delete unused */
|
||||
if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_OPTJUMP ) && ! HB_COMP_PARAM->fDebugInfo )
|
||||
{
|
||||
fBool = 0;
|
||||
HB_BOOL fBool = HB_FALSE;
|
||||
|
||||
for( usIndex = pFunc->wParamCount; usIndex < usLocalCount; usIndex++ )
|
||||
{
|
||||
if( pLocals[ usIndex ].bFlags == 0 )
|
||||
{
|
||||
fBool = 1;
|
||||
fBool = HB_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( fBool )
|
||||
{
|
||||
PHB_HVAR * ppVar;
|
||||
|
||||
usIndex = usLocalCount = 0;
|
||||
ppVar = & pFunc->pLocals;
|
||||
pVar = pFunc->pLocals;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version, with one exception:
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -14,13 +14,12 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
* their web site at https://www.gnu.org/).
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
* (or visit their website at https://www.gnu.org/licenses/).
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbcomp.h"
|
||||
#include "hbassert.h"
|
||||
|
||||
@@ -251,7 +250,7 @@ const HB_BYTE hb_comp_pcode_len[] = {
|
||||
1, /* HB_P_ENUMEND */
|
||||
3, /* HB_P_SWITCH */
|
||||
5, /* HB_P_PUSHDATE */
|
||||
/* optimalization of inlined math operations */
|
||||
/* optimization of inlined math operations */
|
||||
1, /* HB_P_PLUSEQPOP */
|
||||
1, /* HB_P_MINUSEQPOP */
|
||||
1, /* HB_P_MULTEQPOP */
|
||||
@@ -443,7 +442,7 @@ static PHB_PCODE_FUNC s_psize_table[] =
|
||||
NULL, /* HB_P_ENUMEND */
|
||||
NULL, /* HB_P_SWITCH */
|
||||
NULL, /* HB_P_PUSHDATE */
|
||||
/* optimalization of inlined math operations */
|
||||
/* optimization of inlined math operations */
|
||||
NULL, /* HB_P_PLUSEQPOP */
|
||||
NULL, /* HB_P_MINUSEQPOP */
|
||||
NULL, /* HB_P_MULTEQPOP */
|
||||
@@ -516,7 +515,6 @@ void hb_compPCodeEval( PHB_HFUNC pFunc, const PHB_PCODE_FUNC * pFunctions, void
|
||||
{
|
||||
HB_SIZE nPos = 0;
|
||||
HB_SIZE nSkip;
|
||||
HB_BYTE opcode;
|
||||
|
||||
/* Make sure that table is correct */
|
||||
assert( sizeof( hb_comp_pcode_len ) == HB_P_LAST_PCODE );
|
||||
@@ -524,7 +522,7 @@ void hb_compPCodeEval( PHB_HFUNC pFunc, const PHB_PCODE_FUNC * pFunctions, void
|
||||
|
||||
while( nPos < pFunc->nPCodePos )
|
||||
{
|
||||
opcode = pFunc->pCode[ nPos ];
|
||||
HB_BYTE opcode = pFunc->pCode[ nPos ];
|
||||
if( opcode < HB_P_LAST_PCODE )
|
||||
{
|
||||
PHB_PCODE_FUNC pCall = pFunctions[ opcode ];
|
||||
|
||||
@@ -232,7 +232,7 @@ static const PHB_STRIP_FUNC s_stripLines_table[] =
|
||||
NULL, /* HB_P_ENUMEND */
|
||||
NULL, /* HB_P_SWITCH */
|
||||
NULL, /* HB_P_PUSHDATE */
|
||||
/* optimalization of inlined math operations */
|
||||
/* optimization of inlined math operations */
|
||||
NULL, /* HB_P_PLUSEQPOP */
|
||||
NULL, /* HB_P_MINUSEQPOP */
|
||||
NULL, /* HB_P_MULTEQPOP */
|
||||
|
||||
@@ -46,9 +46,6 @@
|
||||
|
||||
#include "hbcomp.h"
|
||||
|
||||
/*
|
||||
* Prints available options
|
||||
*/
|
||||
void hb_compPrintUsage( HB_COMP_DECL, const char * szSelf )
|
||||
{
|
||||
static const char * s_szOptions[] =
|
||||
@@ -115,9 +112,7 @@ void hb_compPrintUsage( HB_COMP_DECL, const char * szSelf )
|
||||
hb_compOutStd( HB_COMP_PARAM, s_szOptions[ iLine ] );
|
||||
}
|
||||
|
||||
/*
|
||||
* List of compatibility/features modes
|
||||
*/
|
||||
/* List of compatibility/features modes */
|
||||
void hb_compPrintModes( HB_COMP_DECL )
|
||||
{
|
||||
static const char * s_szOptions[] =
|
||||
@@ -165,15 +160,12 @@ void hb_compPrintModes( HB_COMP_DECL )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints credits
|
||||
*/
|
||||
void hb_compPrintCredits( HB_COMP_DECL )
|
||||
{
|
||||
hb_compOutStd( HB_COMP_PARAM,
|
||||
"\n"
|
||||
"Credits: The Harbour Team at harbour-project.org\n"
|
||||
" (replace space with @ in e-mail addresses)\n"
|
||||
"Credits: The Harbour Team\n"
|
||||
" (replace space with @ in email addresses)\n"
|
||||
"\n"
|
||||
"Alejandro de Garate (alex_degarate hotmail com)\n"
|
||||
"Aleksander Czajczynski <hb fki.pl>\n"
|
||||
@@ -264,9 +256,6 @@ void hb_compPrintCredits( HB_COMP_DECL )
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints logo
|
||||
*/
|
||||
void hb_compPrintLogo( HB_COMP_DECL )
|
||||
{
|
||||
char * szVer = hb_verHarbour();
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbcomp.h"
|
||||
|
||||
static void hb_pp_ErrorGen( void * cargo,
|
||||
@@ -303,9 +302,9 @@ static HB_BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch,
|
||||
else
|
||||
{
|
||||
if( iValue )
|
||||
iValue = HB_COMP_PARAM->supported & iFlag ? 0 : 1;
|
||||
iValue = ( HB_COMP_PARAM->supported & iFlag ) ? 0 : 1;
|
||||
else
|
||||
iValue = HB_COMP_PARAM->supported & iFlag ? 1 : 0;
|
||||
iValue = ( HB_COMP_PARAM->supported & iFlag ) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +414,7 @@ void hb_compInitPP( HB_COMP_DECL, PHB_PP_OPEN_FUNC pOpenFunc )
|
||||
|
||||
hb_pp_initDynDefines( HB_COMP_PARAM->pLex->pPP, ! HB_COMP_PARAM->fNoArchDefs );
|
||||
|
||||
/* Add /D and /undef: command line or envvar defines */
|
||||
/* Add /D and /undef: command-line or envvar defines */
|
||||
hb_compChkSetDefines( HB_COMP_PARAM );
|
||||
|
||||
/* add extended definitions files (-u+<file>) */
|
||||
|
||||
Reference in New Issue
Block a user