Enrico Maria Giordano
2024-03-23 10:05:46 UTC
This is a sample (kindly provided by Rao). Ron can you look at it?
function Main()
local a := 20
local b := 0
Add500( a, @b )
? Version(), b // 520 Harbour
// 0 xHarbour
Inkey( 0 )
return nil
function add500(...)
PValue( 2, PValue( 1 ) + 500 )
return nil
// This is from pvalue.c
#pragma BEGINDUMP
#include "hbvmopt.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbstack.h"
HB_FUNC( PVALUE )
{
USHORT uiParam = ( USHORT ) hb_parni( 1 ), uiParams;
PHB_ITEM * pBase = HB_VM_STACK.pItems + ( hb_stackBaseItem()
)->item.asSymbol.pCargo->stackbase; /* Skip function + self */
uiParams = ( *pBase )->item.asSymbol.pCargo->arguments;
if( uiParam && uiParam <= uiParams ) /* Valid number */
{
USHORT uiOffset;
PHB_ITEM pItem;
if( ( *pBase )->item.asSymbol.pCargo->params == HB_VAR_PARAM_FLAG )
uiOffset = ( *pBase )->item.asSymbol.pCargo->locals;
else
uiOffset = 0;
pItem = *( pBase + 1 + uiParam + uiOffset );
hb_itemReturn( pItem );
if( hb_pcount() > 1 && HB_IS_BYREF( pItem ) )
hb_itemCopy( pItem, hb_param( 2, HB_IT_ANY ) );
}
else
hb_ret(); /* return NIL */
}
#pragma ENDDUMP
// This is from Harbour pvalue.c
/*
#include "hbvmint.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbstack.h"
HB_FUNC( HB_PVALUE )
{
HB_ISIZ nOffset =
hb_stackBaseItem()->item.asSymbol.stackstate->nBaseItem;
HB_USHORT uiParam = ( HB_USHORT ) hb_parni( 1 );
if( uiParam && uiParam <= hb_stackItem( nOffset
)->item.asSymbol.paramcnt )
{
PHB_ITEM pItem = hb_stackItem( nOffset + 1 + uiParam );
if( hb_pcount() > 1 )
hb_itemCopyToRef( pItem, hb_param( 2, HB_IT_ANY ) );
hb_itemReturn( HB_IS_BYREF( pItem ) ? hb_itemUnRef( pItem ) :
pItem );
}
}
*/
function Main()
local a := 20
local b := 0
Add500( a, @b )
? Version(), b // 520 Harbour
// 0 xHarbour
Inkey( 0 )
return nil
function add500(...)
PValue( 2, PValue( 1 ) + 500 )
return nil
// This is from pvalue.c
#pragma BEGINDUMP
#include "hbvmopt.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbstack.h"
HB_FUNC( PVALUE )
{
USHORT uiParam = ( USHORT ) hb_parni( 1 ), uiParams;
PHB_ITEM * pBase = HB_VM_STACK.pItems + ( hb_stackBaseItem()
)->item.asSymbol.pCargo->stackbase; /* Skip function + self */
uiParams = ( *pBase )->item.asSymbol.pCargo->arguments;
if( uiParam && uiParam <= uiParams ) /* Valid number */
{
USHORT uiOffset;
PHB_ITEM pItem;
if( ( *pBase )->item.asSymbol.pCargo->params == HB_VAR_PARAM_FLAG )
uiOffset = ( *pBase )->item.asSymbol.pCargo->locals;
else
uiOffset = 0;
pItem = *( pBase + 1 + uiParam + uiOffset );
hb_itemReturn( pItem );
if( hb_pcount() > 1 && HB_IS_BYREF( pItem ) )
hb_itemCopy( pItem, hb_param( 2, HB_IT_ANY ) );
}
else
hb_ret(); /* return NIL */
}
#pragma ENDDUMP
// This is from Harbour pvalue.c
/*
#include "hbvmint.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbstack.h"
HB_FUNC( HB_PVALUE )
{
HB_ISIZ nOffset =
hb_stackBaseItem()->item.asSymbol.stackstate->nBaseItem;
HB_USHORT uiParam = ( HB_USHORT ) hb_parni( 1 );
if( uiParam && uiParam <= hb_stackItem( nOffset
)->item.asSymbol.paramcnt )
{
PHB_ITEM pItem = hb_stackItem( nOffset + 1 + uiParam );
if( hb_pcount() > 1 )
hb_itemCopyToRef( pItem, hb_param( 2, HB_IT_ANY ) );
hb_itemReturn( HB_IS_BYREF( pItem ) ? hb_itemUnRef( pItem ) :
pItem );
}
}
*/
--
Enrico Maria Giordano
http://www.emagsoftware.it
http://www.emagsoftware.it/emgmusic
http://www.emagsoftware.it/spectrum
http://www.emagsoftware.it/tbosg
Enrico Maria Giordano
http://www.emagsoftware.it
http://www.emagsoftware.it/emgmusic
http://www.emagsoftware.it/spectrum
http://www.emagsoftware.it/tbosg