* harbour/tests/codebl.prg
* harbour/tests/langmsg.prg
* harbour/utils/hbpptest/pp_test.prg
* harbour/utils/hbpptest/pretest.prg
* harbour/samples/pe/license.txt
* removed carriage return (\r) characters
* harbour/include/hbcomp.h
* harbour/include/hbapi.h
* harbour/include/hbcompdf.h
* harbour/include/hbexprb.c
* harbour/include/hbexprop.h
* harbour/source/vm/macro.c
* harbour/source/compiler/hbcomp.c
* harbour/source/compiler/complex.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.l
* harbour/source/compiler/harbour.y
* harbour/source/compiler/genjava.c
* harbour/source/compiler/hbcomp.c
* harbour/source/compiler/hbident.c
* harbour/source/compiler/hbpcode.c
* harbour/source/compiler/ppcomp.c
* separated HB_COMP and HB_MACRO definitions and added HB_COMMON
structure used when HB_COMMON_SUPPORT macro is set
* hide HB_MACRO internal definitions in hbapi.h when HB_MACRO_SUPPORT
is not set
These modifications should help in future compiler and macro compiler
integration into single binary.
+ added clipper compatible error message in unclosed structures
In general we should cleanup rules to make error reporting more
user friendly and Clipper compatible
% eliminated unnecessary allocations
+ added int mode member to common part of HB_COMP and HB_MACRO
structure. It's initialized to HB_MODE_MACRO or HB_MODE_COMPILER
+ add TOFIX note about memory leaks in cParamTypes and pParamClasses
members of COMDECLARED structure. It's a part of unfinished strong
typing code. I do not know what Ryszard plan to do with it so I'm
leaving it as is. The part of strong typing which were operating
on emulated HVM stack has been removed.
* removed static variables from genjava.c. Also gencli.c and genobj32.c
should be fixed but this will not make this code working so I haven't
touched it.
* changed 3-rd parameter of hb_compIdentifierNew() from BOOL to int.
Now it can have the following values: HB_IDENT_STATIC, HB_IDENT_FREE,
HB_IDENT_COPY. This modification will allow in the future using common
for static and dynamic symbol hash table without additional source code
changes. I also plan to use identifier hash table in PP the reduce
number of memory allocations and speed-up preprocessing by using
second level hashing for hash keys.
* harbour/source/common/expropt1.c
* harbour/source/common/expropt2.c
* changed HB_MACRO_SUPPORT to HB_COMMON_SUPPORT to automatically detect
possible conflicts between compiler and macro compiler
! removed first detected conflict which existed for long time
+ added hb_compExprMacroAsAlias() function to convert HB_ET_VARIABLE
expression to HB_ET_ALIAS.
* harbour/source/macro/macro.y
! fixed using prefix¯o-> and ¯o.sufix-> when macro cannot be
substituted by compiler, f.e.:
M->v := NIL
x := "&v.1->fld"
M->v := "v"
M->v1:= "data"
? &x
! fixed memory leak in macro substituted expression compilation
* harbour/source/vm/macro.c
! fixed initialization of some HB_MACRO members
! fixed value returned for type("&V->F") when alias does not exist
- removed not longer used hb_comp_bShortCuts global variable
172 lines
3.7 KiB
Plaintext
172 lines
3.7 KiB
Plaintext
//
|
|
// $Id$
|
|
//
|
|
|
|
STATIC cbStatic
|
|
|
|
Function Main()
|
|
Local a := TestBlocks()
|
|
LOCAL cb
|
|
|
|
qout( eval( a[ 1 ] ) ) // 23
|
|
qout( eval( a[ 2 ], 42 ) ) // 42
|
|
qout( eval( a[ 1 ] ) ) // 42
|
|
qout( eval( a[ 2 ], 15 ) ) // 15
|
|
|
|
mqout( 15, eval( a[ 1 ] ) ) // 15 15
|
|
mqout( 14, eval( a[ 1 ] ) ) // 14 15
|
|
mqout( 42, eval( a[ 2 ], 42 ) ) // 42 42
|
|
mqout( 14, eval( a[ 2 ], 42 ) ) // 14 42
|
|
mqout( 42, eval( a[ 1 ] ) ) // 42 42
|
|
mqout( 14, eval( a[ 1 ] ) ) // 14 42
|
|
|
|
GetArray( @a )
|
|
PrintArray( @a )
|
|
|
|
qout( "Test for variables passed by reference in a codeblock" )
|
|
DetachWithRefer()
|
|
|
|
qout( "Test for indirect detaching of local variables" )
|
|
DetachToStatic( 1 )
|
|
mqout( 2, EVAL( cbStatic, 1 ) )
|
|
mqout( 3, EVAL( cbStatic, 2 ) )
|
|
cb :=cbStatic
|
|
DetachToStatic( 100 )
|
|
mqout( 200, EVAL( cbStatic, 100 ) )
|
|
mqout( 300, EVAL( cbStatic, 200 ) )
|
|
mqout( 4, EVAL( cb, 3 ) )
|
|
|
|
ReferParam()
|
|
|
|
Return( NIL )
|
|
|
|
Static Function TestBlocks()
|
|
LOCAL nFoo := 23
|
|
Return( { {|| nFoo }, {|n| nFoo := n } } )
|
|
|
|
Static Function mqout( nExpected, nGot )
|
|
|
|
qout( nExpected, nGot )
|
|
|
|
Return( NIL )
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
PROCEDURE GetArray( a )
|
|
LOCAL i
|
|
|
|
a :=ARRAY( 100 )
|
|
FOR i:=1 TO 100
|
|
IF( (i % 6) == 0 )
|
|
a[ i-2 ] =NIL
|
|
a[ i-4 ] =NIL
|
|
ENDIF
|
|
a[ i ] := TestBlocks()
|
|
NEXT
|
|
|
|
RETURN
|
|
|
|
PROCEDURE PrintArray( a )
|
|
LOCAL i
|
|
|
|
FOR i:=1 TO 100
|
|
IF( a[i] != NIL )
|
|
EVAL( a[ i ][ 2 ], i )
|
|
mqout( i, EVAL( a[ i ][ 1 ] ) )
|
|
ENDIF
|
|
NEXT
|
|
|
|
RETURN
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
Function DetachWithRefer()
|
|
Local nTest
|
|
Local bBlock1 := MakeBlock()
|
|
Local bBlock2 := {|| DoThing( @nTest ), qout( nTest ) }
|
|
|
|
eval( bBlock1 )
|
|
eval( bBlock2 )
|
|
|
|
Return( NIL )
|
|
|
|
Function MakeBlock()
|
|
Local nTest
|
|
RETURN( {|| DoThing( @nTest ), qout( nTest ) } )
|
|
|
|
Function DoThing( n )
|
|
|
|
n := 42
|
|
|
|
Return( NIL )
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
FUNCTION DetachToStatic( n )
|
|
|
|
cbStatic ={|x| n+x}
|
|
|
|
RETURN NIL
|
|
|
|
// ------------------------------------------------------------
|
|
Function ReferParam()
|
|
Local bResult
|
|
|
|
? "Test for codeblock parameter passed by reference"
|
|
|
|
PassByValue( {|lEnd| ;
|
|
bResult := GetBlock( @lEnd ), ;
|
|
SetByRef( @lEnd ) } )
|
|
// Clipper & xHarbour it's .T.
|
|
//In Harbour it is .F.
|
|
? "Printed value in Clipper .T. =", Eval( bResult )
|
|
?
|
|
// Notice the Clipper bug: GetBlock is receiving the reference to
|
|
// the codeblock parameter than the value of EVAL(bResult) shouldn't
|
|
// depend on the order of block creation/value changing (GetBlock/SetRef).
|
|
|
|
PassByRef( {|lEnd| ;
|
|
bResult := GetBlock( @lEnd ), ;
|
|
SetByRef( @lEnd ) } )
|
|
// Clipper & xHarbour it's .T.
|
|
//In Harbour it is .F.
|
|
? "Printed value in Clipper .T. =", Eval( bResult )
|
|
?
|
|
|
|
? "2nd test for codeblock parameter passed by reference"
|
|
|
|
PassByValue( {|lEnd| ;
|
|
SetByRef( @lEnd ), ;
|
|
bResult := GetBlock( @lEnd ) } )
|
|
// Clipper & xHarbour it's .T.
|
|
//In Harbour it is .F.
|
|
? "Printed value in Clipper .F. =", Eval( bResult )
|
|
?
|
|
|
|
PassByRef( {|lEnd| ;
|
|
SetByRef( @lEnd ), ;
|
|
bResult := GetBlock( @lEnd ) } )
|
|
// Clipper & xHarbour it's .T.
|
|
//In Harbour it is .F.
|
|
? "Printed value in Clipper .F. =", Eval( bResult )
|
|
?
|
|
|
|
Return Nil
|
|
|
|
Static Function PassByValue( bBlock )
|
|
Local lSomeVar := .T.
|
|
Eval( bBlock, lSomeVar )
|
|
? "lSomeVar value in Clipper .T. =", lSomeVar
|
|
Return .T.
|
|
|
|
Static Function PassByRef( bBlock )
|
|
Local lSomeVar := .T.
|
|
Eval( bBlock, @lSomeVar )
|
|
? "lSomeVar value in Clipper .F. =", lSomeVar
|
|
Return .T.
|
|
|
|
Static Function SetByRef( lVar )
|
|
lVar := .F.
|
|
Return Nil
|
|
|
|
Static Function GetBlock( lVar )
|
|
Return {|| lVar }
|
|
// ------------------------------------------------------------
|