2007-04-12 13:55 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbpp.h
  * harbour/include/hbcomp.h
  * harbour/source/compiler/hbgenerr.c
  * harbour/source/compiler/ppcomp.c
  * harbour/source/pp/ppcore.c
  * harbour/source/pp/pplib.c
  * harbour/utils/hbpp/hbpp.c
  * harbour/utils/hbpp/hbppcore.c
  * harbour/utils/hbpp/hbppdef.h
    * changed error and warning messages to const char *

  * harbour/source/compiler/genhrb.c
    * rewritten to work on memory buffers and with new compiler code

  * harbour/include/hbcomp.h
  * harbour/include/hbcompdf.h
  * harbour/source/compiler/hbmain.c
  * harbour/source/main/harbour.c
    + added LANG_PORT_OBJ_BUF which allow to generate .hrb files into
      memory buffers

  * harbour/source/compiler/hbcmplib.c
    + added HB_COMPILEBUF() functions which returns compiled .hrb file
      as string item

  * harbour/source/vm/runner.c
    + added support for executing compiled .hrb files stored in string
      items in __HRBRUN() function - it works just like in __HRBLOAD()

  * harbour/harbour.spec
  * harbour/utils/hbrun/hbrun.prg
    + added default include directories to hbrun
    * use HB_COMPILEBUF() instead of HB_COMPILE() to eliminate temporary
      files
This commit is contained in:
Przemyslaw Czerpak
2007-04-12 11:57:04 +00:00
parent 836215df9d
commit 23bc767460
18 changed files with 317 additions and 193 deletions

View File

@@ -8,6 +8,42 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-04-12 13:55 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbpp.h
* harbour/include/hbcomp.h
* harbour/source/compiler/hbgenerr.c
* harbour/source/compiler/ppcomp.c
* harbour/source/pp/ppcore.c
* harbour/source/pp/pplib.c
* harbour/utils/hbpp/hbpp.c
* harbour/utils/hbpp/hbppcore.c
* harbour/utils/hbpp/hbppdef.h
* changed error and warning messages to const char *
* harbour/source/compiler/genhrb.c
* rewritten to work on memory buffers and with new compiler code
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/source/compiler/hbmain.c
* harbour/source/main/harbour.c
+ added LANG_PORT_OBJ_BUF which allow to generate .hrb files into
memory buffers
* harbour/source/compiler/hbcmplib.c
+ added HB_COMPILEBUF() functions which returns compiled .hrb file
as string item
* harbour/source/vm/runner.c
+ added support for executing compiled .hrb files stored in string
items in __HRBRUN() function - it works just like in __HRBLOAD()
* harbour/harbour.spec
* harbour/utils/hbrun/hbrun.prg
+ added default include directories to hbrun
* use HB_COMPILEBUF() instead of HB_COMPILE() to eliminate temporary
files
2007-04-12 11:14 UTC+0300 Chen Kedem <niki@actcom.co.il>
* source/rtl/tget.prg
! Fix bug#1672233 - Picture masks for Logical GET variables.

View File

@@ -351,6 +351,7 @@ if [ "%{!?_with_static:1}" ]
then
unset HB_GTALLEG
export L_USR="${CC_L_USR} -L${HB_LIB_INSTALL} -l%{name} -lncurses %{!?_without_gtsln:-lslang} %{!?_without_gpm:-lgpm} %{!?_without_x11:-L/usr/X11R6/%{_lib} -lX11}"
export PRG_USR="\"-D_DEFAULT_INC_DIR='${_DEFAULT_INC_DIR}'\" ${PRG_USR}"
for utl in hbmake hbrun hbpp hbdoc
do

View File

@@ -179,8 +179,8 @@ extern void hb_compLoopKill( HB_COMP_DECL );
extern void hb_compRTVariableKill( HB_COMP_DECL );
extern void hb_compElseIfKill( HB_COMP_DECL );
extern void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ); /* generic parsing error management function */
extern void hb_compGenWarning( HB_COMP_DECL, char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2); /* generic parsing warning management function */
extern void hb_compGenError( HB_COMP_DECL, const char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ); /* generic parsing error management function */
extern void hb_compGenWarning( HB_COMP_DECL, const char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2); /* generic parsing warning management function */
extern BOOL hb_compForEachVarError( HB_COMP_DECL, char * ); /* checks if it is FOR EACH enumerator variable and generates a warning */
@@ -270,7 +270,7 @@ extern BOOL hb_compCheckUnclosedStru( HB_COMP_DECL );
#define HB_GEN_FUNC3( func, p1,p2,p3 ) hb_compGen##func( p1, p2, p3, HB_COMP_PARAM )
#define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_compGen##func( p1, p2, p3, p4, HB_COMP_PARAM )
extern int compMain( int argc, char * argv[] );
extern int hb_compMain( int argc, char * argv[], BYTE ** pBufPtr, ULONG * pulSize );
extern void hb_compExprLstDealloc( HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR, HB_COMP_DECL );
@@ -331,12 +331,14 @@ extern void hb_compStripFuncLines( PFUNCTION pFunc );
/* output related functions defined in gen*.c */
extern void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME ); /* generates the C language output */
extern void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME ); /* generates the portable objects */
extern void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME ); /* generates the .NET IL language output */
extern void hb_compGenJava( HB_COMP_DECL, PHB_FNAME ); /* generates the Java language output */
extern void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME ); /* generates the portable objects */
extern void hb_compGenObj32( HB_COMP_DECL, PHB_FNAME ); /* generates OBJ 32 bits */
extern void hb_compGenCObj( HB_COMP_DECL, PHB_FNAME ); /* generates platform dependant object module */
extern void hb_compGenBufPortObj( HB_COMP_DECL, BYTE ** pBufPtr, ULONG * pulSize ); /* generates the portable objects to memory buffer */
extern void hb_compGenCRealCode( HB_COMP_DECL, PFUNCTION pFunc, FILE * yyc );
extern void hb_compGenCString( FILE * yyc, BYTE * pText, ULONG ulLen );
@@ -348,14 +350,14 @@ extern void hb_compIdentifierClose( HB_COMP_DECL ); /* release the table of iden
/* global readonly variables used by compiler
*/
extern char * hb_comp_szErrors[];
extern char * hb_comp_szWarnings[];
extern const char * hb_comp_szErrors[];
extern const char * hb_comp_szWarnings[];
/* table with PCODEs' length */
extern const BYTE hb_comp_pcode_len[];
extern const BYTE hb_comp_pcode_len[];
/* file handle for error messages */
extern FILE *hb_comp_errFile;
extern FILE * hb_comp_errFile;
/* identifier types for hb_compIdentifierNew() */
#define HB_IDENT_STATIC 0

View File

@@ -70,6 +70,7 @@ typedef enum
LANG_OBJ32, /* DOS/Windows 32 bits <file.obj> */
LANG_JAVA, /* Java <file.java> */
LANG_PORT_OBJ, /* Portable objects <file.hrb> */
LANG_PORT_OBJ_BUF, /* Portable objects in memory buffer */
LANG_OBJ_MODULE /* Platform dependant object module <file.obj> */
} LANGUAGES; /* supported Harbour output languages */
@@ -593,6 +594,9 @@ typedef struct _HB_COMP
PHB_FNAME pOutPath;
PHB_FNAME pPpoPath;
ULONG ulOutBufSize; /* memory output buffer size */
BYTE * pOutBuf; /* memory output buffer address */
ULONG lastLinePos; /* position of last opcode with line number */
int lastLine; /* last generated in PCODE line number */
int currLine; /* currently compiled line number */

View File

@@ -92,7 +92,7 @@ typedef HB_PP_CLOSE_FUNC_( HB_PP_CLOSE_FUNC );
typedef HB_PP_CLOSE_FUNC * PHB_PP_CLOSE_FUNC;
/* function to generate errors */
#define HB_PP_ERROR_FUNC_( func ) void func( void *, char **, char, int, const char *, const char * )
#define HB_PP_ERROR_FUNC_( func ) void func( void *, const char **, char, int, const char *, const char * )
typedef HB_PP_ERROR_FUNC_( HB_PP_ERROR_FUNC );
typedef HB_PP_ERROR_FUNC * PHB_PP_ERROR_FUNC;

View File

@@ -9,6 +9,9 @@
* Copyright 1999 Eddie Runia <eddie@runia.com>
* www - http://www.harbour-project.org
*
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* rewritten to work on memory buffers and with new compiler code
*
* 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
@@ -32,15 +35,104 @@
#define SYM_FUNC 1 /* Defined function */
#define SYM_EXTERN 2 /* Previously defined function */
static PFUNCTION hb_compFirstFunc( HB_COMP_DECL )
{
PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst;
if( ! HB_COMP_PARAM->fStartProc )
pFunc = pFunc->pNext;
return pFunc;
}
static ULONG hb_compHrbSize( HB_COMP_DECL, ULONG * pulSymbols, ULONG * pulFunctions )
{
PFUNCTION pFunc;
PCOMSYMBOL pSym;
ULONG ulSize;
* pulSymbols = * pulFunctions = 0;
/* count total size */
ulSize = 10; /* signature[4] + version[2] + symbols_number[4] */
pSym = HB_COMP_PARAM->symbols.pFirst;
while( pSym )
{
( * pulSymbols )++;
ulSize += strlen( pSym->szName ) + 3; /* \0 + symscope[1] + symtype[1] */
pSym = pSym->pNext;
}
ulSize += 4; /* functions_number[4] */
/* Generate functions data */
pFunc = hb_compFirstFunc( HB_COMP_PARAM );
while( pFunc )
{
( * pulFunctions )++;
ulSize += strlen( pFunc->szName ) + 5 + pFunc->lPCodePos; /* \0 + func_size[4] + function_body */
pFunc = pFunc->pNext;
}
return ulSize;
}
void hb_compGenBufPortObj( HB_COMP_DECL, BYTE ** pBufPtr, ULONG * pulSize )
{
PFUNCTION pFunc;
PCOMSYMBOL pSym;
ULONG ulSymbols, ulFunctions, ulLen;
BYTE * ptr;
* pulSize = hb_compHrbSize( HB_COMP_PARAM, &ulSymbols, &ulFunctions );
/* additional 0 byte is for passing buffer directly as string item */
ptr = * pBufPtr = ( BYTE * ) hb_xgrab( * pulSize + 1 );
memcpy( ptr, "\300HRB", 4 ); /* signature */
ptr += 4;
HB_PUT_LE_UINT16( ptr, 2 ); /* version number */
ptr += 2;
HB_PUT_LE_UINT32( ptr, ulSymbols ); /* number of symbols */
ptr += 4;
/* generate the symbol table */
pSym = HB_COMP_PARAM->symbols.pFirst;
while( pSym )
{
ulLen = strlen( pSym->szName ) + 1;
memcpy( ptr, pSym->szName, ulLen );
ptr += ulLen;
*ptr++ = pSym->cScope;
/* symbol type */
/* if( hb_compFunctionFind( HB_COMP_PARAM, pSym->szName ) ) */
if( pSym->cScope & HB_FS_LOCAL )
*ptr++ = SYM_FUNC; /* function defined in this module */
else if( hb_compFunCallFind( HB_COMP_PARAM, pSym->szName ) )
*ptr++ = SYM_EXTERN; /* external function */
else
*ptr++ = SYM_NOLINK; /* other symbol */
pSym = pSym->pNext;
}
HB_PUT_LE_UINT32( ptr, ulFunctions ); /* number of functions */
ptr += 4;
/* generate functions data */
pFunc = hb_compFirstFunc( HB_COMP_PARAM );
while( pFunc )
{
ulLen = strlen( pFunc->szName ) + 1;
memcpy( ptr, pFunc->szName, ulLen );
ptr += ulLen;
HB_PUT_LE_UINT32( ptr, pFunc->lPCodePos ); /* function size */
ptr += 4;
memcpy( ptr, pFunc->pCode, pFunc->lPCodePos ); /* function body */
ptr += pFunc->lPCodePos;
pFunc = pFunc->pNext;
}
}
void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME pFileName )
{
char szFileName[ _POSIX_PATH_MAX + 1 ];
PFUNCTION pFunc /*= HB_COMP_PARAM->functions.pFirst*/;
PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst;
ULONG lPCodePos;
LONG lSymbols;
ULONG ulCodeLength;
FILE * yyc; /* file handle for C output */
ULONG ulSize;
BYTE * pHrbBody;
FILE * yyc;
if( ! pFileName->szExtension )
pFileName->szExtension = ".hrb";
@@ -59,88 +151,12 @@ void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME pFileName )
fflush( stdout );
}
/* writes the symbol table */
lSymbols = 0; /* Count number of symbols */
while( pSym )
{
lSymbols++;
pSym = pSym->pNext;
}
fputc( ( BYTE ) 192, yyc );
fputs( "HRB", yyc );
fputc( 2, yyc );
fputc( 0, yyc );
fputc( ( BYTE ) ( ( lSymbols ) & 255 ), yyc ); /* Write number symbols */
fputc( ( BYTE ) ( ( lSymbols >> 8 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( lSymbols >> 16 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( lSymbols >> 24 ) & 255 ), yyc );
pSym = HB_COMP_PARAM->symbols.pFirst;
while( pSym )
{
fputs( pSym->szName, yyc );
fputc( 0, yyc );
fputc( pSym->cScope, yyc );
/* specify the function address if it is a defined function or an
external called function */
#if 0
if( hb_compFunctionFind( HB_COMP_PARAM, pSym->szName ) )
#else
if( pSym->cScope & HB_FS_LOCAL )
#endif
fputc( SYM_FUNC, yyc ); /* function defined in this module */
else if( hb_compFunCallFind( HB_COMP_PARAM, pSym->szName ) )
fputc( SYM_EXTERN, yyc ); /* external function */
else
fputc( SYM_NOLINK, yyc ); /* other symbol */
pSym = pSym->pNext;
}
pFunc = HB_COMP_PARAM->functions.pFirst;
if( ! HB_COMP_PARAM->fStartProc )
pFunc = pFunc->pNext;
lSymbols = 0; /* Count number of symbols */
while( pFunc )
{
lSymbols++;
pFunc = pFunc->pNext;
}
fputc( ( BYTE ) ( ( lSymbols ) & 255 ), yyc ); /* Write number symbols */
fputc( ( BYTE ) ( ( lSymbols >> 8 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( lSymbols >> 16 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( lSymbols >> 24 ) & 255 ), yyc );
/* Generate functions data
*/
pFunc = HB_COMP_PARAM->functions.pFirst;
if( ! HB_COMP_PARAM->fStartProc )
pFunc = pFunc->pNext;
while( pFunc )
{
fputs( pFunc->szName, yyc );
fputc( 0, yyc );
ulCodeLength = pFunc->lPCodePos;
fputc( ( BYTE ) ( ( ulCodeLength ) & 255 ), yyc ); /* Write size */
fputc( ( BYTE ) ( ( ulCodeLength >> 8 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( ulCodeLength >> 16 ) & 255 ), yyc );
fputc( ( BYTE ) ( ( ulCodeLength >> 24 ) & 255 ), yyc );
lPCodePos = 0;
while( lPCodePos < pFunc->lPCodePos )
fputc( pFunc->pCode[ lPCodePos++ ], yyc );
pFunc = pFunc->pNext;
}
hb_compGenBufPortObj( HB_COMP_PARAM, &pHrbBody, &ulSize );
fwrite( pHrbBody, ulSize, 1, yyc );
hb_xfree( pHrbBody );
fclose( yyc );
if( ! HB_COMP_PARAM->fQuiet )
printf( "Done.\n" );
}

View File

@@ -53,19 +53,83 @@
#include "hbapi.h"
#include "hbcomp.h"
HB_FUNC( HB_COMPILE )
static void hb_compGenArgList( int iFirst, int * pArgC, char *** pArgV )
{
PHB_ITEM pParam, pItem;
ULONG ul;
int iPCount = hb_pcount(), argc = 0, i;
char ** argv, * szParam;
char ** argv;
argv = ( char ** ) hb_xgrab( sizeof( char * ) * ( iPCount + 1 ) );
for( i = 1; i <= iPCount; ++i )
for( i = iFirst; i <= iPCount; ++i )
{
szParam = hb_parc( i );
if( szParam )
argv[ argc++ ] = szParam;
pParam = hb_param( i, HB_IT_ARRAY | HB_IT_STRING );
if( pParam )
{
if( HB_IS_ARRAY( pParam ) )
{
ul = hb_arrayLen( pParam );
if( ul ) do
{
pItem = hb_arrayGetItemPtr( pParam, ul );
if( pItem && HB_IS_STRING( pItem ) )
++argc;
}
while( --ul );
}
else if( HB_IS_STRING( pParam ) )
++argc;
}
}
argv = ( char ** ) hb_xgrab( sizeof( char * ) * ( argc + 1 ) );
argc = 0;
for( i = iFirst; i <= iPCount; ++i )
{
pParam = hb_param( i, HB_IT_ARRAY | HB_IT_STRING );
if( pParam )
{
if( HB_IS_ARRAY( pParam ) )
{
ul = hb_arrayLen( pParam );
if( ul ) do
{
pItem = hb_arrayGetItemPtr( pParam, ul );
if( pItem && HB_IS_STRING( pItem ) )
argv[ argc++ ] = hb_itemGetCPtr( pItem );
}
while( --ul );
}
else if( HB_IS_STRING( pParam ) )
argv[ argc++ ] = hb_itemGetCPtr( pParam );
}
}
argv[ argc ] = NULL;
hb_retni( compMain( argc, argv ) );
* pArgC = argc;
* pArgV = argv;
}
HB_FUNC( HB_COMPILE )
{
int argc;
char ** argv;
hb_compGenArgList( 1, &argc, &argv );
hb_retni( hb_compMain( argc, argv, NULL, NULL ) );
hb_xfree( argv );
}
HB_FUNC( HB_COMPILEBUF )
{
int iResult, argc;
char ** argv;
BYTE * pBuffer;
ULONG ulLen;
hb_compGenArgList( 1, &argc, &argv );
iResult = hb_compMain( argc, argv, &pBuffer, &ulLen );
hb_xfree( argv );
if( iResult == EXIT_SUCCESS && pBuffer )
hb_retclen_buffer( ( char * ) pBuffer, ulLen );
}

View File

@@ -29,7 +29,7 @@
#include "hbcomp.h"
/* Table with parse errors */
char * hb_comp_szErrors[] =
const char * hb_comp_szErrors[] =
{
"Statement not allowed outside of procedure or function",
"Redefinition of procedure or function: '%s'",
@@ -103,7 +103,7 @@ char * hb_comp_szErrors[] =
/* 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.
*/
char * hb_comp_szWarnings[] =
const char * hb_comp_szWarnings[] =
{
"1Ambiguous reference: '%s'",
"1Ambiguous reference, assuming memvar: '%s'",
@@ -138,7 +138,7 @@ char * hb_comp_szWarnings[] =
"0Invalid variable '%s' for enumerator message"
};
void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
void hb_compGenError( HB_COMP_DECL, const char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
{
if( !HB_COMP_PARAM->fExit && ( cPrefix == 'F' || !HB_COMP_PARAM->fError ) )
{
@@ -164,9 +164,9 @@ void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError,
}
}
void hb_compGenWarning( HB_COMP_DECL, char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2)
void hb_compGenWarning( HB_COMP_DECL, const char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2)
{
char * szText = szWarnings[ iWarning - 1 ];
const char * szText = szWarnings[ iWarning - 1 ];
if( !HB_COMP_PARAM->fExit && ( szText[ 0 ] - '0' <= HB_COMP_PARAM->iWarnings ) )
{

View File

@@ -67,7 +67,6 @@
extern unsigned _stklen = UINT_MAX;
#endif
static void hb_compGenOutput( HB_COMP_DECL, int );
static void hb_compCompileEnd( HB_COMP_DECL );
static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile );
@@ -116,12 +115,13 @@ static void hb_compMainExit( HB_COMP_DECL )
hb_xfree( pAutoOpen );
}
hb_comp_free( HB_COMP_PARAM );
if( HB_COMP_PARAM->pOutBuf )
hb_xfree( HB_COMP_PARAM->pOutBuf );
hb_xexit();
hb_comp_free( HB_COMP_PARAM );
}
int compMain( int argc, char * argv[] )
int hb_compMain( int argc, char * argv[], BYTE ** pBufPtr, ULONG * pulSize )
{
HB_COMP_DECL;
int iStatus = EXIT_SUCCESS;
@@ -130,7 +130,7 @@ int compMain( int argc, char * argv[] )
#if defined( HOST_OS_UNIX_COMPATIBLE )
hb_comp_errFile = stderr;
#else
#else
hb_comp_errFile = stdout;
#endif
@@ -148,6 +148,11 @@ int compMain( int argc, char * argv[] )
hb_compChkCompilerSwitch( HB_COMP_PARAM, argc, argv );
if( !HB_COMP_PARAM->fExit )
{
if( pBufPtr && pulSize )
{
HB_COMP_PARAM->iLanguage = LANG_PORT_OBJ_BUF;
}
if( HB_COMP_PARAM->fLogo )
hb_compPrintLogo();
@@ -205,6 +210,22 @@ int compMain( int argc, char * argv[] )
if( HB_COMP_PARAM->iErrorCount > 0 )
iStatus = EXIT_FAILURE;
if( pBufPtr && pulSize )
{
if( iStatus == EXIT_SUCCESS )
{
* pBufPtr = HB_COMP_PARAM->pOutBuf;
* pulSize = HB_COMP_PARAM->ulOutBufSize;
HB_COMP_PARAM->pOutBuf = NULL;
HB_COMP_PARAM->ulOutBufSize = 0;
}
else
{
* pBufPtr = NULL;
* pulSize = 0;
}
}
hb_compMainExit( HB_COMP_PARAM );
return iStatus;
@@ -4268,6 +4289,10 @@ static void hb_compGenOutput( HB_COMP_DECL, int iLanguage )
hb_compGenPortObj( HB_COMP_PARAM, HB_COMP_PARAM->pFileName );
break;
case LANG_PORT_OBJ_BUF:
hb_compGenBufPortObj( HB_COMP_PARAM, &HB_COMP_PARAM->pOutBuf, &HB_COMP_PARAM->ulOutBufSize );
break;
case LANG_OBJ_MODULE:
hb_compGenCObj( HB_COMP_PARAM, HB_COMP_PARAM->pFileName );
break;

View File

@@ -31,7 +31,7 @@
#include <errno.h>
static void hb_pp_ErrorGen( void * cargo,
char * szMsgTable[], char cPrefix, int iErrorCode,
const char * szMsgTable[], char cPrefix, int iErrorCode,
const char * szParam1, const char * szParam2 )
{
HB_COMP_DECL = ( HB_COMP_PTR ) cargo;

View File

@@ -55,7 +55,12 @@
int main( int argc, char * argv[] )
{
return compMain( argc, argv );
int iResult;
iResult = hb_compMain( argc, argv, NULL, NULL );
hb_xexit();
return iResult;
}
/* ------------------------------------------------------------------------- */

View File

@@ -99,13 +99,13 @@
/* warning messages */
static char * hb_pp_szWarnings[] =
static const char * hb_pp_szWarnings[] =
{
"1Redefinition or duplicate definition of #define %s" /* C1005 */
};
/* error messages */
static char * hb_pp_szErrors[] =
static const char * hb_pp_szErrors[] =
{
"Illegal character: '\\x%s'", /* C2004 */
"Unterminated string: '%s'", /* C2007 */
@@ -218,7 +218,7 @@ static void hb_pp_disp( PHB_PP_STATE pState, const char * szMessage )
static void hb_pp_error( PHB_PP_STATE pState, char type, int iError, const char * szParam )
{
char ** szMsgTable = type == 'W' ? hb_pp_szWarnings : hb_pp_szErrors;
const char ** szMsgTable = type == 'W' ? hb_pp_szWarnings : hb_pp_szErrors;
if( pState->pErrorFunc )
{

View File

@@ -58,7 +58,7 @@
#include "hbapierr.h"
#include "hbvm.h"
static void hb_pp_ErrorMessage( void * cargo, char * szMsgTable[],
static void hb_pp_ErrorMessage( void * cargo, const char * szMsgTable[],
char cPrefix, int iCode,
const char * szParam1, const char * szParam2 )
{

View File

@@ -92,6 +92,8 @@ typedef struct
PHB_SYMBOLS pModuleSymbols;
} HRB_BODY, * PHRB_BODY;
static const BYTE szHead[] = { 192,'H','R','B' };
#define SYM_NOLINK 0 /* Symbol does not have to be linked */
#define SYM_FUNC 1 /* Defined function */
@@ -100,7 +102,6 @@ typedef struct
static int hb_hrbReadHead( char * szBody, ULONG ulBodySize, ULONG * pulBodyOffset )
{
BYTE szHead[] = { (BYTE)192,'H','R','B' };
char * pVersion;
HB_TRACE(HB_TR_DEBUG, ("hb_hrbReadHead(%p,%lu,%p)", szBody, ulBodySize, pulBodyOffset ));
@@ -108,7 +109,7 @@ static int hb_hrbReadHead( char * szBody, ULONG ulBodySize, ULONG * pulBodyOffse
if( ulBodySize < 6 || memcmp( szHead, szBody, 4 ) )
return 0;
pVersion = szBody + *pulBodyOffset + 4;
pVersion = szBody + 4;
*pulBodyOffset += 6;
return HB_PCODE_MKSHORT( pVersion );
@@ -572,47 +573,43 @@ static void hb_hrbDo( PHRB_BODY pHrbBody, int argc, char * argv[] )
*/
HB_FUNC( __HRBRUN )
{
int argc = hb_pcount();
ULONG ulLen = hb_parclen( 1 );
if( argc >= 1 && ISCHAR( 1 ) )
if( ulLen > 0 )
{
PHRB_BODY pHrbBody = hb_hrbLoadFromFile( hb_parc( 1 ) );
char * fileOrBody = hb_parc( 1 );
PHRB_BODY pHrbBody;
if( ulLen > 4 && memcmp( szHead, fileOrBody, 4 ) == 0 )
pHrbBody = hb_hrbLoad( fileOrBody, ulLen );
else
pHrbBody = hb_hrbLoadFromFile( fileOrBody );
if( pHrbBody )
{
int argc = hb_pcount(), i;
char **argv = NULL;
int i;
if( argc > 1 )
{
argv = (char**) hb_xgrab( sizeof(char*) * (argc-1) );
for( i=0; i<argc-1; i++ )
{
argv[i] = hb_parcx( i+2 );
}
}
hb_hrbDo( pHrbBody, argc-1, argv );
if( argv )
{
hb_xfree( argv );
}
hb_hrbUnLoad( pHrbBody );
hb_retl( TRUE );
}
else
{
hb_retl( FALSE );
}
}
else
{
hb_errRT_BASE( EG_ARG, 9999, NULL, "__HRBRUN", HB_ERR_ARGS_BASEPARAMS );
}
}
HB_FUNC( __HRBLOAD )
@@ -621,19 +618,13 @@ HB_FUNC( __HRBLOAD )
if( ulLen > 0 )
{
BYTE szHead[] = { 192,'H','R','B' };
char * fileOrBody = hb_parc( 1 );
PHRB_BODY pHrbBody;
/* If parameter string */
if( fileOrBody && ulLen > 4 && memcmp( szHead, fileOrBody, 4 ) == 0 )
{
if( ulLen > 4 && memcmp( szHead, fileOrBody, 4 ) == 0 )
pHrbBody = hb_hrbLoad( fileOrBody, ulLen );
}
else
{
pHrbBody = hb_hrbLoadFromFile( fileOrBody );
}
if( pHrbBody )
{
@@ -646,24 +637,18 @@ HB_FUNC( __HRBLOAD )
argv = ( char ** ) hb_xgrab( sizeof( char * ) * ( argc - 1 ) );
for( i = 0; i < argc - 1; i++ )
{
argv[i] = hb_parcx( i + 2 );
}
}
hb_hrbInit( pHrbBody, argc - 1, argv );
if( argv )
{
hb_xfree( argv );
}
}
hb_retptr( ( void *) pHrbBody );
}
else
{
hb_errRT_BASE( EG_ARG, 9998, NULL, "__HRBLOAD", HB_ERR_ARGS_BASEPARAMS );
}
}
HB_FUNC( __HRBDO )
@@ -681,22 +666,16 @@ HB_FUNC( __HRBDO )
argv = ( char ** ) hb_xgrab( sizeof( char * ) * ( argc - 1 ) );
for( i = 0; i < argc - 1; i++ )
{
argv[i] = hb_parcx( i + 2 );
}
}
hb_hrbDo( pHrbBody, argc - 1, argv );
if( argv )
{
hb_xfree( argv );
}
}
else
{
hb_errRT_BASE( EG_ARG, 9999, NULL, "__HRBDO", HB_ERR_ARGS_BASEPARAMS );
}
}
HB_FUNC( __HRBUNLOAD )
@@ -704,13 +683,9 @@ HB_FUNC( __HRBUNLOAD )
PHRB_BODY pHrbBody = ( PHRB_BODY ) hb_parptr( 1 );
if( pHrbBody )
{
hb_hrbUnLoad( pHrbBody );
}
else
{
hb_errRT_BASE( EG_ARG, 9999, NULL, "__HRBUNLOAD", HB_ERR_ARGS_BASEPARAMS );
}
}
HB_FUNC( __HRBGETFU )
@@ -731,14 +706,10 @@ HB_FUNC( __HRBGETFU )
hb_xfree( szName );
if( ulPos < pHrbBody->ulSymbols )
{
hb_itemPutSymbol( hb_stackReturnItem(), pHrbBody->pSymRead + ulPos );
}
}
else
{
hb_errRT_BASE( EG_ARG, 9999, NULL, "__HRBGETFU", HB_ERR_ARGS_BASEPARAMS );
}
}
HB_FUNC( __HRBDOFU )
@@ -754,14 +725,10 @@ HB_FUNC( __HRBDOFU )
hb_vmPushNil();
for( i = 2; i <= argc; i++ ) /* Push other params */
{
hb_vmPush( hb_stackItemFromBase( i ) );
}
hb_vmDo( argc - 1 ); /* Run function */
}
else
{
hb_errRT_BASE( EG_ARG, 9999, NULL, "__HRBDOFU", HB_ERR_ARGS_BASEPARAMS );
}
}

View File

@@ -448,7 +448,7 @@ static void AddSearchPath( char * szPath, HB_PATHNAMES * * pSearchList )
pPath->szPath = szPath;
}
void hb_compGenError( HB_COMP_DECL, char * _szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
void hb_compGenError( HB_COMP_DECL, const char * _szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
{
HB_TRACE(HB_TR_DEBUG, ("hb_compGenError(%p, %c, %d, %s, %s)", _szErrors, cPrefix, iError, szError1, szError2));
@@ -464,7 +464,7 @@ void hb_compGenError( HB_COMP_DECL, char * _szErrors[], char cPrefix, int iError
*/
}
void hb_compGenWarning( HB_COMP_DECL, char* _szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2)
void hb_compGenWarning( HB_COMP_DECL, const char* _szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2)
{
HB_TRACE(HB_TR_DEBUG, ("hb_compGenWarning(%p, %c, %d, %s, %s)", _szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
@@ -472,7 +472,7 @@ void hb_compGenWarning( HB_COMP_DECL, char* _szWarnings[], char cPrefix, int iWa
if( s_iWarnings )
{
char *szText = _szWarnings[ iWarning - 1 ];
const char *szText = _szWarnings[ iWarning - 1 ];
if( (szText[ 0 ] - '0') <= s_iWarnings )
{

View File

@@ -208,7 +208,7 @@ char *hb_pp_STD_CH = NULL;
static BOOL s_bArray = FALSE;
/* Table with parse errors */
char *hb_pp_szErrors[] = {
const char *hb_pp_szErrors[] = {
"Can\'t open #include file: \'%s\'; %s",
"#else does not match #ifdef",
"#endif does not match #ifdef",
@@ -233,7 +233,7 @@ char *hb_pp_szErrors[] = {
};
/* Table with warnings */
char *hb_pp_szWarnings[] = {
const char *hb_pp_szWarnings[] = {
"1Redefinition or duplicate definition of #define %s",
"1No directives in command definitions file"
};

View File

@@ -147,8 +147,8 @@ extern int hb_comp_iLinePRG;
extern int hb_pp_lInclude;
extern int * hb_pp_aCondCompile;
extern int hb_pp_nCondCompile;
extern char * hb_pp_szErrors[];
extern char * hb_pp_szWarnings[];
extern const char * hb_pp_szErrors[];
extern const char * hb_pp_szWarnings[];
extern int hb_pp_nEmptyStrings;
extern int hb_pp_LastOutLine;
extern int hb_pp_StreamBlock;

View File

@@ -72,7 +72,7 @@
collision with user function in HRB file with that name. [ckedem]
*/
FUNCTION _APPMAIN( cHRBFile, ... )
LOCAL xRetVal, cPRGFile, cRMFile, cPath, cName, cExt, cDrive
LOCAL xRetVal, cPath, cName, cExt, cDrive, aIncDir
IF Empty( cHRBFile )
OutStd( "Harbour Runner" + HB_OSNewLine() +;
@@ -81,29 +81,33 @@ FUNCTION _APPMAIN( cHRBFile, ... )
"Syntax: hbrun <hrbfile[.hrb|.prg]> [parameters]" + HB_OSNewLine() + ;
HB_OSNewLine() +;
"Note: Linked with " + Version() + HB_OSNewLine() )
ERRORLEVEL( 1 )
ELSE
HB_FNAMESPLIT( cHRBFile, @cPath, @cName, @cExt, @cDrive )
IF LOWER( cExt ) == ".prg"
cPRGFile := cHRBFile
xRetVal := HB_FTEMPCREATE(,,, @cHRBFile )
IF xRetVal == -1
RETURN xRetVal
ENDIF
FCLOSE( xRetVal )
FERASE( cHRBFile )
HB_FNAMESPLIT( cHRBFile, @cPath, @cName, @cExt, @cDrive )
cRMFile := cHRBFile := HB_FNAMEMERGE( cPath, cName, ".hrb", cDrive )
xRetVal := HB_COMPILE( HB_ARGV( 0 ), "-n", "-w", "-es2", "-q0", ;
"-gh", "-o"+cHRBFile, cPRGFile )
IF xRetVal != 0
RETURN xRetVal
ENDIF
ENDIF
xRetVal := __hrbRun( cHRBFile, ... )
ENDIF
IF !EMPTY( cRMFile )
FERASE( cRMFile )
IF LOWER( cExt ) == ".prg"
aIncDir := {}
#ifdef _DEFAULT_INC_DIR
AADD( aIncDir, "-I" + _DEFAULT_INC_DIR )
#endif
cPath := getenv( "HB_INC_INSTALL" )
IF !EMPTY( cPath )
AADD( aIncDir, "-I" + cPath )
ENDIF
#ifdef __PLATFORM__UNIX
AADD( aIncDir, "-I/usr/include/harbour" )
AADD( aIncDir, "-I/usr/local/include/harbour" )
#endif
cHRBFile := HB_COMPILEBUF( HB_ARGV( 0 ), "-n", "-w", "-es2", "-q0", ;
aIncDir, cHRBFile )
IF cHRBFile == NIL
ERRORLEVEL( 1 )
ELSE
xRetVal := __hrbRun( cHRBFile, ... )
ENDIF
ELSE
xRetVal := __hrbRun( cHRBFile, ... )
ENDIF
ENDIF
RETURN xRetVal