2007-04-11 22:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/compiler/harbour.y
  * harbour/source/compiler/harbour.yyc
    ! fixed some possible false warning messages

  * harbour/include/hboo.ch
  * harbour/source/vm/classes.c
    + added support for HB_OO_MSG_PROPERTY and HB_OO_MSG_CLASSPROPERTY
      to make some xHarbour users happy ;-)

  * harbour/common.mak
  * harbour/harbour.spec
  * harbour/include/hbcompdf.h
  * harbour/source/compiler/Makefile
  + harbour/source/compiler/hbcmplib.c
    + added HB_COMPILE() function - it accepts exactly the same parameters
      as harbour compiler and makes the same job :-)

  * harbour/utils/hbrun/Makefile
  * harbour/utils/hbrun/hbrun.prg
    + added support for compilation and direct execution of .prg files
      Now hbrun can accept as first parameter .hrb or .prg file and if
      it's .prg file it's compiled and then executed just like .hrb one.
      In *nixes if you copy compiled hbrun to /usr/bin directory then
      you can add to your .prg files as first line:
         #!/usr/bin/hbrun
      and then after setting executable attribute you can directly
      execute them, f.e.:
         ./test.prg
      If you are using Linux then you can also chose default gt driver
      by dding to above line: //gt<name>
      F.e.
         #!/usr/bin/hbrun //gtstd
This commit is contained in:
Przemyslaw Czerpak
2007-04-11 20:01:18 +00:00
parent 9d1de9cdfa
commit 046d1ea4d7
12 changed files with 210 additions and 33 deletions

View File

@@ -8,6 +8,39 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-04-11 22:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
! fixed some possible false warning messages
* harbour/include/hboo.ch
* harbour/source/vm/classes.c
+ added support for HB_OO_MSG_PROPERTY and HB_OO_MSG_CLASSPROPERTY
to make some xHarbour users happy ;-)
* harbour/common.mak
* harbour/harbour.spec
* harbour/include/hbcompdf.h
* harbour/source/compiler/Makefile
+ harbour/source/compiler/hbcmplib.c
+ added HB_COMPILE() function - it accepts exactly the same parameters
as harbour compiler and makes the same job :-)
* harbour/utils/hbrun/Makefile
* harbour/utils/hbrun/hbrun.prg
+ added support for compilation and direct execution of .prg files
Now hbrun can accept as first parameter .hrb or .prg file and if
it's .prg file it's compiled and then executed just like .hrb one.
In *nixes if you copy compiled hbrun to /usr/bin directory then
you can add to your .prg files as first line:
#!/usr/bin/hbrun
and then after setting executable attribute you can directly
execute them, f.e.:
./test.prg
If you are using Linux then you can also chose default gt driver
by dding to above line: //gt<name>
F.e.
#!/usr/bin/hbrun //gtstd
2007-04-11 15:25 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* harbour/contrib/libnf/mouse1.prg

View File

@@ -256,6 +256,7 @@ COMPILER_LIB_OBJS = \
$(OBJ_DIR)\complex.obj \
$(OBJ_DIR)\cmdcheck.obj \
$(OBJ_DIR)\hbcomp.obj \
$(OBJ_DIR)\hbcmplib.obj \
$(OBJ_DIR)\hbdead.obj \
$(OBJ_DIR)\hbstripl.obj \
$(OBJ_DIR)\hbusage.obj \

View File

@@ -455,23 +455,25 @@ druzus@uran:~/tmp$ ls -l foo
----------------------------------------------------------------------
In this RPM you will find additional wonderful tools: /usr/bin/pprun
In this RPM you will find additional wonderful tools: /usr/bin/hbrun
You can run clipper/xbase compatible source files with it if you only
put in their first line:
#!/usr/bin/pprun
#!/usr/bin/hbrun
For example:
----------------------------------------------------------------------
druzus@uran:~/tmp$ cat foo.prg
#!/usr/bin/pprun
#!/usr/bin/hbrun
function main()
? "Hello, World!, This is a script !!! :-)"
?
return nil
druzus@uran:~/tmp$ chmod +x foo.prg
druzus@uran:~/tmp$ ./foo.prg
Hello, World!, This is a script !!! :-)
I hope this RPM is useful. Have fun with %{dname}.

View File

@@ -623,8 +623,8 @@ typedef struct _HB_COMP
int iGenCOutput; /* C code generation should be verbose (use comments) or not */
int ilastLineErr; /* line numer with last syntax error */
BOOL fExit; /* force breaking compilation process */
BOOL fQuiet; /* be quiet during compilation (-q) */
BOOL fExit; /* force breaking compilation process */
BOOL fPPO; /* flag indicating, is ppo output needed */
BOOL fPPT; /* flag indicating, is ppt output needed */
BOOL fStartProc; /* holds if we need to create the starting procedure */

View File

@@ -107,6 +107,11 @@
#define HB_OO_MSG_PERFORM 15
#define HB_OO_MSG_DELEGATE 16
/* to make xHarbour users happy ;-) */
#define HB_OO_PROPERTY 32
#define HB_OO_MSG_PROPERTY HB_OO_PROPERTY + HB_OO_MSG_DATA /* Auto management of DATA */
#define HB_OO_MSG_CLASSPROPERTY HB_OO_PROPERTY + HB_OO_MSG_CLASSDATA /* Auto management of CLASSDATA */
/* Data */
#define HB_OO_DATA_SYMBOL 1
#define HB_OO_DATA_VALUE 2

View File

@@ -31,6 +31,7 @@ C_SOURCES=\
genjava.c \
genobj32.c \
gencli.c \
hbcmplib.c \
hbcomp.c \
hbfunchk.c \
hbgenerr.c \

View File

@@ -1390,13 +1390,13 @@ DoCase : DoCaseBegin
;
EndCase : ENDCASE
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
}
| END
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
}
;
@@ -1461,7 +1461,7 @@ DoWhile : WhileBegin Expression Crlf
--HB_COMP_PARAM->wWhileCounter;
hb_compLoopEnd( HB_COMP_PARAM );
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
}
}
;
WhileBegin : WHILE { $$ = HB_COMP_PARAM->functions.pLast->lPCodePos; hb_compLinePushIfInside( HB_COMP_PARAM ); ++HB_COMP_PARAM->wWhileCounter; hb_compLoopStart( HB_COMP_PARAM ); }
@@ -1525,7 +1525,7 @@ ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */
HB_COMP_EXPR_DELETE( $<asExpr>5 ); /* deletes $5, $2, $4 */
if( $<asExpr>8 )
HB_COMP_EXPR_DELETE( $<asExpr>8 );
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
}
;
@@ -1597,7 +1597,7 @@ ForEach : FOREACH ForList IN ForArgs /* 1 2 3 4 */
hb_compGenJumpHere( $<lNumber>9, HB_COMP_PARAM );
hb_compLoopEnd( HB_COMP_PARAM );
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
hb_compEnumEnd( HB_COMP_PARAM, $2 );
HB_COMP_EXPR_DELETE( $2 );
HB_COMP_EXPR_DELETE( $4 );
@@ -1696,6 +1696,7 @@ BeginSeq : BEGINSEQ /* 1 */
}
AlwaysSeq /* 8 */
{ /* 9 */
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
if( $<lNumber>8 )
{
/* replace END address with ALWAYS address in
@@ -1714,7 +1715,6 @@ BeginSeq : BEGINSEQ /* 1 */
}
hb_compSequenceFinish( HB_COMP_PARAM, $<lNumber>2, $<lNumber>5, $<lNumber>8,
$<lNumber>4 != 0, $<lNumber>6 != 0 );
HB_COMP_PARAM->functions.pLast->bFlags &= ~FUN_WITH_RETURN;
}
END /* 10 */
;
@@ -1725,13 +1725,13 @@ AlwaysSeq : /* no always */ { $<lNumber>$ = 0; }
Always : ALWAYS
{
HB_COMP_PARAM->functions.pLast->bFlags &= ~FUN_BREAK_CODE;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
$<lNumber>$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
hb_compSequenceAlways( HB_COMP_PARAM );
}
;
RecoverSeq : /* no recover */ { $<lNumber>$ = 0; }
RecoverSeq : /* no recover */ { $<lNumber>$ = 0; HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
| RecoverEmpty Crlf EmptyStats
| RecoverUsing Crlf EmptyStats
;

View File

@@ -6247,16 +6247,16 @@ yyreduce:
case 519:
#line 1393 "harbour.y"
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
;}
break;
case 520:
#line 1398 "harbour.y"
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
;}
break;
@@ -6359,7 +6359,7 @@ yyreduce:
--HB_COMP_PARAM->wWhileCounter;
hb_compLoopEnd( HB_COMP_PARAM );
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
;}
;}
break;
case 539:
@@ -6441,7 +6441,7 @@ yyreduce:
HB_COMP_EXPR_DELETE( (yyvsp[(5) - (12)].asExpr) ); /* deletes $5, $2, $4 */
if( (yyvsp[(8) - (12)].asExpr) )
HB_COMP_EXPR_DELETE( (yyvsp[(8) - (12)].asExpr) );
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
;}
break;
@@ -6557,7 +6557,7 @@ yyreduce:
hb_compGenJumpHere( (yyvsp[(9) - (10)].lNumber), HB_COMP_PARAM );
hb_compLoopEnd( HB_COMP_PARAM );
HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_WITH_RETURN;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
hb_compEnumEnd( HB_COMP_PARAM, (yyvsp[(2) - (10)].asExpr) );
HB_COMP_EXPR_DELETE( (yyvsp[(2) - (10)].asExpr) );
HB_COMP_EXPR_DELETE( (yyvsp[(4) - (10)].asExpr) );
@@ -6686,6 +6686,7 @@ yyreduce:
case 588:
#line 1698 "harbour.y"
{ /* 9 */
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
if( (yyvsp[(8) - (8)].lNumber) )
{
/* replace END address with ALWAYS address in
@@ -6704,7 +6705,6 @@ yyreduce:
}
hb_compSequenceFinish( HB_COMP_PARAM, (yyvsp[(2) - (8)].lNumber), (yyvsp[(5) - (8)].lNumber), (yyvsp[(8) - (8)].lNumber),
(yyvsp[(4) - (8)].lNumber) != 0, (yyvsp[(6) - (8)].lNumber) != 0 );
HB_COMP_PARAM->functions.pLast->bFlags &= ~FUN_WITH_RETURN;
;}
break;
@@ -6716,7 +6716,7 @@ yyreduce:
case 592:
#line 1727 "harbour.y"
{
HB_COMP_PARAM->functions.pLast->bFlags &= ~FUN_BREAK_CODE;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
(yyval.lNumber) = HB_COMP_PARAM->functions.pLast->lPCodePos;
hb_compSequenceAlways( HB_COMP_PARAM );
;}
@@ -6724,7 +6724,7 @@ yyreduce:
case 593:
#line 1734 "harbour.y"
{ (yyval.lNumber) = 0; ;}
{ (yyval.lNumber) = 0; HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; ;}
break;
case 596:

View File

@@ -0,0 +1,71 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* HB_COMPILE() - compiler interface
*
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "hbapi.h"
#include "hbcomp.h"
HB_FUNC( HB_COMPILE )
{
int iPCount = hb_pcount(), argc = 0, i;
char ** argv, * szParam;
argv = ( char ** ) hb_xgrab( sizeof( char * ) * ( iPCount + 1 ) );
for( i = 1; i <= iPCount; ++i )
{
szParam = hb_parc( i );
if( szParam )
argv[ argc++ ] = szParam;
}
argv[ argc ] = NULL;
hb_retni( compMain( argc, argv ) );
hb_xfree( argv );
}

View File

@@ -2202,7 +2202,7 @@ static BOOL hb_clsAddMsg( USHORT uiClass, char * szMessage,
if( !fOK )
{
hb_errRT_BASE( EG_ARG, 3000, NULL, "__CLSADDMSG", HB_ERR_ARGS_BASEPARAMS );
hb_errRT_BASE( EG_ARG, 3000, NULL, &hb_errFuncName, HB_ERR_ARGS_BASEPARAMS );
return FALSE;
}
@@ -2460,11 +2460,38 @@ HB_FUNC( __CLSADDMSG )
{
nType = szMessage[ 0 ] == '_' ? HB_OO_MSG_ASSIGN : HB_OO_MSG_ACCESS;
}
if( nType == HB_OO_MSG_CLASSDATA )
else if( nType == HB_OO_MSG_CLASSDATA )
{
nType = szMessage[ 0 ] == '_' ? HB_OO_MSG_CLSASSIGN :
HB_OO_MSG_CLSACCESS;
}
/* to make xHarbour users happy ;-) */
else if( nType == HB_OO_MSG_PROPERTY ||
nType == HB_OO_MSG_CLASSPROPERTY )
{
char szAssign[ HB_SYMBOL_NAME_LEN + 1 ];
int iLen = ( int ) hb_parclen( 1 );
if( iLen >= HB_SYMBOL_NAME_LEN )
iLen = HB_SYMBOL_NAME_LEN - 1;
szAssign[ 0 ] = '_';
memcpy( szAssign + 1, szMessage, iLen );
szAssign[ iLen ] = '\0';
uiScope = ( uiScope | HB_OO_CLSTP_EXPORTED ) &
~( HB_OO_CLSTP_PROTECTED | HB_OO_CLSTP_HIDDEN );
if( nType == HB_OO_MSG_PROPERTY )
{
hb_clsAddMsg( uiClass, szAssign, HB_OO_MSG_ASSIGN,
uiScope & ~HB_OO_CLSTP_PERSIST, pFunction, pInit );
nType = HB_OO_MSG_ACCESS;
}
else
{
hb_clsAddMsg( uiClass, szAssign, HB_OO_MSG_CLSASSIGN,
uiScope & ~HB_OO_CLSTP_PERSIST, pFunction, pInit );
nType = HB_OO_MSG_CLSACCESS;
}
}
hb_clsAddMsg( uiClass, szMessage, nType, uiScope, pFunction, pInit );
}

View File

@@ -25,5 +25,6 @@ LIBS=\
macro \
pp \
common \
compiler \
include $(TOP)$(ROOT)config/bin.cf

View File

@@ -9,6 +9,9 @@
* Copyright 1999 Ryszard Glab <rglab@imid.med.pl>
* www - http://www.harbour-project.org
*
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* added support for dynamic compilation and execution of .prg files
*
* 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)
@@ -50,24 +53,57 @@
*
*/
/*
* Please remember that in *nixes if you copy compiled version
* of this program to /usr/bin directory then you can add to your
* .prg files as first line:
* #!/usr/bin/hbrun
* and then after setting executable attribute you can directly execute
* your .prg files
* If you are using Linux then you can also chose default gt driver by
* adding to above line: //gt<name>
* F.e.
* #!/usr/bin/hbrun //gtstd
*/
#include "hbextern.ch"
/* NOTE: Undocumented CA-Clipper _APPMAIN is used instead of Main to avoid
collision with user function in HRB file with that name. [ckedem]
*/
FUNCTION _APPMAIN( cHRBFile, cPar1, cPar2, cPar3, cPar4, cPar5, cPar6, cPar7, cPar8, cPar9 )
LOCAL xRetVal
FUNCTION _APPMAIN( cHRBFile, ... )
LOCAL xRetVal, cPRGFile, cRMFile, cPath, cName, cExt, cDrive
IF Empty( cHRBFile )
OutStd( "Harbour Runner" + HB_OSNewLine() +;
"Copyright 1999-2006, http://www.harbour-project.org" + HB_OSNewLine() +;
HB_OSNewLine() +;
"Syntax: hbrun <hrbfile[.hrb]> [parameters]" + HB_OSNewLine() +;
"Syntax: hbrun <hrbfile[.hrb|.prg]> [parameters]" + HB_OSNewLine() + ;
HB_OSNewLine() +;
"Note: Linked with " + Version() + HB_OSNewLine() )
ELSE
xRetVal := __hrbRun( cHRBFile, cPar1, cPar2, cPar3, cPar4, cPar5, cPar6, cPar7, cPar8, cPar9 )
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 )
ENDIF
RETURN xRetVal