2006-09-20 14:15 UTC+0100 Ryszard Glab <rglab//imid.med.pl>
* include/hbpcode.h
+ added new pcode HB_P_VFRAME
* include/hbapi.h
+ added USHORT paramdeclcnt to asSymbol structure
* include/hbstack.h
* source/vm/estack.c
+ added hb_stackLocalVariable() to acces local variables
* source/compiler/genc.c
* source/compiler/gencc.c
* source/compiler/harbour.c
* source/compiler/harbour.l
* source/compiler/harbour.y
* source/compiler/hbdead.c
* source/compiler/hbfix.c
* source/compiler/hblbl.c
* source/compiler/hbpcode.c
* source/compiler/hbstripl.c
* source/vm/hvm.c
+ added support for variable number of parameters in
functions/procedures
+ tests/varparam.prg
* example usage of new syntax for variable number of
parameters
* source/vm/arrayshb.c
* changed HB_APARAMS() to use current stack frame if no
arguments are passed ( HB_APARAMS() == HB_APARAMS(0) )
SYNTAX for variable number of parameters
1) [FUNCTION|PROCEDURE] name( ... )
or
2) [FUNCTION|PROCEDURE] name( var1, var2, varN, ... )
To access passed parameters use the following:
PCOUNT() - returns number of passed parameters
HB_PVALUE( iParamNum ) - returns <iParamNum> parameter
HB_APARAMS() - returns array with all passed parameters
or usual name of parameter variable in case of syntax 2)
This commit is contained in:
@@ -85,6 +85,7 @@ extern HB_STACK hb_stack;
|
||||
|
||||
extern HB_ITEM_PTR hb_stackItemFromTop( int nFromTop );
|
||||
extern HB_ITEM_PTR hb_stackItemFromBase( int nFromBase );
|
||||
extern HB_ITEM_PTR hb_stacklocalVariable( int *piFromBase );
|
||||
extern LONG hb_stackTopOffset( void );
|
||||
extern LONG hb_stackBaseOffset( void );
|
||||
extern LONG hb_stackTotalItems( void );
|
||||
@@ -183,6 +184,10 @@ extern void hb_stackClearMevarsBase( void );
|
||||
if( ++hb_stack.pPos == hb_stack.pEnd ) \
|
||||
hb_stackIncrease(); \
|
||||
} while ( 0 )
|
||||
#define hb_stackLocalVariable( p ) ((((*hb_stack.pBase)->item.asSymbol.paramcnt > (*hb_stack.pBase)->item.asSymbol.paramdeclcnt) && \
|
||||
(*(p)) > (*hb_stack.pBase)->item.asSymbol.paramdeclcnt ) ? \
|
||||
(* ( hb_stack.pBase + ( int ) ((*(p))+=((*hb_stack.pBase)->item.asSymbol.paramcnt - (*hb_stack.pBase)->item.asSymbol.paramdeclcnt)) + 1 ) ) : \
|
||||
(* ( hb_stack.pBase + ( int ) (*(p)) + 1 ) ) )
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user