vm

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  
c:\harbour\source\vm
arrays.c
TypeFunctionSourceLine
STATIC VOIDhb_arrayReleaseItems( PHB_BASEARRAY pBaseArray )
static void hb_arrayReleaseItems( PHB_BASEARRAY pBaseArray )
{
   if( pBaseArray->ulLen )
   {
      HB_ITEM_PTR pItems = pBaseArray->pItems;
      ULONG ulLen = pBaseArray->ulLen;

      /*
       * clear the pBaseArray->pItems to avoid infinite loop in cross
       * referenced items when pBaseArray is not freed due to buggy
       * object destructor [druzus]
       */
      pBaseArray->pItems = NULL;
      pBaseArray->ulLen  = 0;

      while( ulLen-- )
      {
         if( HB_IS_COMPLEX( pItems + ulLen ) )
            hb_itemClear( pItems + ulLen );
      }
      hb_xfree( pItems );
   }
}
arrays.c80
VOIDhb_arrayPushBase( PHB_BASEARRAY pBaseArray )
void hb_arrayPushBase( PHB_BASEARRAY pBaseArray )
{
   PHB_ITEM pItem = hb_stackAllocItem();

   pItem->type = HB_IT_ARRAY;
   pItem->item.asArray.value = pBaseArray;
   hb_gcRefInc( pBaseArray );
}
arrays.c104
STATIC HB_GARBAGE_FUNC(hb_arrayReleaseGarbage )
static HB_GARBAGE_FUNC( hb_arrayReleaseGarbage )
{
   PHB_BASEARRAY pBaseArray = ( PHB_BASEARRAY ) Cargo;

   if( pBaseArray->uiClass )
   {
      /*
       * do not execute destructor for supercasted objects [druzus]
       */
      if( pBaseArray->uiPrevCls == 0 &&
          hb_clsHasDestructor( pBaseArray->uiClass ) )
      {
         hb_arrayPushBase( pBaseArray );
         hb_objDestructorCall( hb_stackItemFromTop( -1 ) );

         /* Clear object properities before hb_stackPop(), [druzus] */
         pBaseArray->uiClass = 0;
         hb_stackPop();

         /*
          * release array items before hb_gcRefCheck() to avoid double
          * pBaseArray freeing when it will have cross references to
          * self after executing buggy destructor [druzus]
          */
         hb_arrayReleaseItems( pBaseArray );
         hb_gcRefCheck( pBaseArray );
         return;
      }

      /*
       * This is only some additional protection for buggy code
       * which can store reference to this object in other class
       * destructor when executed from GC and it will only cause
       * RT error when user will try to send any message to this
       * object [druzus]
       */
      pBaseArray->uiClass = 0;
   }

   hb_arrayReleaseItems( pBaseArray );
}
arrays.c113
HB_EXPORT BOOLhb_arrayNew( PHB_ITEM pItem, ULONG ulLen )
HB_EXPORT BOOL hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ) /* creates a new array */
{
   PHB_BASEARRAY pBaseArray;
   PHB_ITEM pItems;
   ULONG ulPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayNew(%p, %lu)", pItem, ulLen));

   if( HB_IS_COMPLEX( pItem ) )
      hb_itemClear( pItem );

   /*
    * allocate memory for items before hb_gcAlloc() to be
    * safe for automatic GC activation in hb_xgrab() without
    * calling hb_gcLock()/hb_gcUnlock(). [druzus]
    */
   if( ulLen > 0 )
   {
      pItems = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) * ulLen );
      for( ulPos = 0; ulPos < ulLen; ++ulPos )
         ( pItems + ulPos )->type = HB_IT_NIL;
   }
   else
      pItems = NULL;

   pBaseArray = ( PHB_BASEARRAY ) hb_gcAlloc( sizeof( HB_BASEARRAY ), hb_arrayReleaseGarbage );
   pBaseArray->pItems     = pItems;
   pBaseArray->ulLen      = ulLen;
   pBaseArray->uiClass    = 0;
   pBaseArray->uiPrevCls  = 0;

   pItem->type = HB_IT_ARRAY;
   pItem->item.asArray.value = pBaseArray;

   return TRUE;
}
arrays.c156
HB_EXPORT BOOLhb_arraySize( PHB_ITEM pArray, ULONG ulLen )
HB_EXPORT BOOL hb_arraySize( PHB_ITEM pArray, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySize(%p, %lu)", pArray, ulLen));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;

      if( ulLen != pBaseArray->ulLen )
      {
         ULONG ulPos;

         if( pBaseArray->ulLen == 0 )
         {
            pBaseArray->pItems = ( PHB_ITEM ) hb_xgrab( ulLen * sizeof( HB_ITEM ) );

            for( ulPos = 0; ulPos < ulLen; ulPos++ )
               ( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
         }
         else
         {
            if( pBaseArray->ulLen < ulLen )
            {
               pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * ulLen );

               /* set value for new items */
               for( ulPos = pBaseArray->ulLen; ulPos < ulLen; ulPos++ )
                  ( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
            }
            else if( pBaseArray->ulLen > ulLen )
            {
               /* release old items */
               for( ulPos = ulLen; ulPos < pBaseArray->ulLen; ulPos++ )
               {
                  if( HB_IS_COMPLEX( pBaseArray->pItems + ulPos ) )
                     hb_itemClear( pBaseArray->pItems + ulPos );
               }

               if( ulLen == 0 )
               {
                  hb_xfree( pBaseArray->pItems );
                  pBaseArray->pItems = NULL;
               }
               else
                  pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * ulLen );
            }
         }

         pBaseArray->ulLen = ulLen;
      }

      return TRUE;
   }
   else
      return FALSE;
}
arrays.c193
HB_EXPORT ULONGhb_arrayLen( PHB_ITEM pArray )
HB_EXPORT ULONG hb_arrayLen( PHB_ITEM pArray )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayLen(%p)", pArray));

   if( HB_IS_ARRAY( pArray ) )
      return pArray->item.asArray.value->ulLen;
   else
      return 0;
}
arrays.c250
HB_EXPORT BOOLhb_arrayIsObject( PHB_ITEM pArray )
HB_EXPORT BOOL hb_arrayIsObject( PHB_ITEM pArray )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayIsObject(%p)", pArray));

   if( HB_IS_ARRAY( pArray ) )
      return pArray->item.asArray.value->uiClass != 0;
   else
      return FALSE;
}
arrays.c260
HB_EXPORT VOID *hb_arrayId( PHB_ITEM pArray )
HB_EXPORT void * hb_arrayId( PHB_ITEM pArray )
{
   if( HB_IS_ARRAY( pArray ) )
      return ( void * ) pArray->item.asArray.value;
   else
      return NULL;
}
arrays.c270
HB_EXPORT BOOLhb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pValue )
HB_EXPORT BOOL hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayAdd(%p, %p)", pArray, pValue));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = ( PHB_BASEARRAY ) pArray->item.asArray.value;

      if( pBaseArray->ulLen < ULONG_MAX )
      {
         hb_arraySize( pArray, pBaseArray->ulLen + 1 );
         pBaseArray = ( PHB_BASEARRAY ) pArray->item.asArray.value;
         hb_itemCopy( pBaseArray->pItems + ( pBaseArray->ulLen - 1 ), pValue );

         return TRUE;
      }
   }

   return FALSE;
}
arrays.c279
HB_EXPORT BOOLhb_arrayAddForward( PHB_ITEM pArray, PHB_ITEM pValue )
HB_EXPORT BOOL hb_arrayAddForward( PHB_ITEM pArray, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayAddForward(%p, %p)", pArray, pValue));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = ( PHB_BASEARRAY ) pArray->item.asArray.value;

      if( pBaseArray->ulLen < ULONG_MAX )
      {
         hb_arraySize( pArray, pBaseArray->ulLen + 1 );
         pBaseArray = ( PHB_BASEARRAY ) pArray->item.asArray.value;
         hb_itemForwardValue( pBaseArray->pItems + ( pBaseArray->ulLen - 1 ), pValue );

         return TRUE;
      }
   }

   return FALSE;
}
arrays.c300
HB_EXPORT BOOLhb_arrayDel( PHB_ITEM pArray, ULONG ulIndex )
HB_EXPORT BOOL hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayDel(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) )
   {
      ULONG ulLen = pArray->item.asArray.value->ulLen;

      if( ulIndex > 0 && ulIndex <= ulLen )
      {
         PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;

         if( ulIndex == ulLen )
         {
            hb_itemSetNil( pBaseArray->pItems + ulIndex - 1 );
         }
         else
         {
            for( ; ulIndex < ulLen; ++ulIndex )       /* move items */
               hb_itemMoveRef( pBaseArray->pItems + ulIndex - 1,
                               pBaseArray->pItems + ulIndex );
         }

         return TRUE;
      }
   }

   return FALSE;
}
arrays.c321
HB_EXPORT BOOLhb_arrayIns( PHB_ITEM pArray, ULONG ulIndex )
HB_EXPORT BOOL hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayIns(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) )
   {
      ULONG ulLen = pArray->item.asArray.value->ulLen;

      if( ulIndex > 0 && ulIndex <= ulLen )
      {
         PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;

         if( ulIndex == ulLen )
         {
            hb_itemSetNil( pBaseArray->pItems + ulIndex - 1 );
         }
         else
         {
            while( --ulLen >= ulIndex )                     /* move items */
               hb_itemMoveRef( pBaseArray->pItems + ulLen,
                               pBaseArray->pItems + ulLen - 1 );
         }

         return TRUE;
      }
   }

   return FALSE;
}
arrays.c351
HB_EXPORT BOOLhb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
HB_EXPORT BOOL hb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySet(%p, %lu, %p)", pArray, ulIndex, pItem));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemCopy( pArray->item.asArray.value->pItems + ( ulIndex - 1 ), pItem );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c381
HB_EXPORT BOOLhb_arraySetForward( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
HB_EXPORT BOOL hb_arraySetForward( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetForward(%p, %lu, %p)", pArray, ulIndex, pItem));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemMove( pArray->item.asArray.value->pItems + ( ulIndex - 1 ), pItem );
      return TRUE;
   }
   else
   {
      hb_itemClear( pItem );
      return FALSE;
   }
}
arrays.c394
HB_EXPORT BOOLhb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
HB_EXPORT BOOL hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGet(%p, %lu, %p)", pArray, ulIndex, pItem));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemCopy( pItem, pArray->item.asArray.value->pItems + ( ulIndex - 1 ) );
      return TRUE;
   }
   else
   {
      hb_itemSetNil( pItem );
      return FALSE;
   }
}
arrays.c410
HB_EXPORT BOOLhb_arrayGetItemRef( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
HB_EXPORT BOOL hb_arrayGetItemRef( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetItemRef(%p, %lu, %p)", pArray, ulIndex, pItem));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      if( pArray != pItem )
      {
         if( HB_IS_COMPLEX( pItem ) )
            hb_itemClear( pItem );
         hb_gcRefInc( pArray->item.asArray.value );
      }
      pItem->type = HB_IT_BYREF;
      pItem->item.asRefer.BasePtr.array = pArray->item.asArray.value;
      pItem->item.asRefer.value = ulIndex - 1;
      pItem->item.asRefer.offset = 0;
      return TRUE;
   }
   else
   {
      hb_itemSetNil( pItem );
      return FALSE;
   }
}
arrays.c426
PHB_ITEMhb_arrayGetItemPtr( PHB_ITEM pArray, ULONG ulIndex )
PHB_ITEM hb_arrayGetItemPtr( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetItemPtr(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return pArray->item.asArray.value->pItems + ulIndex - 1;
   else
      return NULL;
}
arrays.c451
CHAR *hb_arrayGetDS( PHB_ITEM pArray, ULONG ulIndex, char * szDate )
char * hb_arrayGetDS( PHB_ITEM pArray, ULONG ulIndex, char * szDate )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetDS(%p, %lu, %s)", pArray, ulIndex, szDate));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetDS( pArray->item.asArray.value->pItems + ulIndex - 1, szDate );
   else
      /* NOTE: Intentionally calling it with a bad parameter in order to get
               the default value from hb_itemGetDS(). [vszakats] */
      return hb_itemGetDS( NULL, szDate );
}
arrays.c465
LONGhb_arrayGetDL( PHB_ITEM pArray, ULONG ulIndex )
long hb_arrayGetDL( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetDL(%p, %lu)", pArray, ulIndex ));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetDL( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      /* NOTE: Intentionally calling it with a bad parameter in order to get
               the default value from hb_itemGetDL(). [vszakats] */
      return hb_itemGetDL( NULL );
}
arrays.c477
BOOLhb_arrayGetL( PHB_ITEM pArray, ULONG ulIndex )
BOOL hb_arrayGetL( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetL(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetL( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return FALSE;
}
arrays.c489
INThb_arrayGetNI( PHB_ITEM pArray, ULONG ulIndex )
int hb_arrayGetNI( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetNI(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetNI( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c499
LONGhb_arrayGetNL( PHB_ITEM pArray, ULONG ulIndex )
long hb_arrayGetNL( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetNL(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetNL( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c509
LONGLONGhb_arrayGetNLL( PHB_ITEM pArray, ULONG ulIndex )
LONGLONG hb_arrayGetNLL( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetNLL(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetNLL( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c520
HB_LONGhb_arrayGetNInt( PHB_ITEM pArray, ULONG ulIndex )
HB_LONG hb_arrayGetNInt( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetNLL(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetNInt( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c531
DOUBLEhb_arrayGetND( PHB_ITEM pArray, ULONG ulIndex )
double hb_arrayGetND( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetND(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetND( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c541
ULONGhb_arrayCopyC( PHB_ITEM pArray, ULONG ulIndex, char * szBuffer, ULONG ulLen )
ULONG hb_arrayCopyC( PHB_ITEM pArray, ULONG ulIndex, char * szBuffer, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayCopyC(%p, %lu, %s, %lu)", pArray, ulIndex, szBuffer, ulLen));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemCopyC( pArray->item.asArray.value->pItems + ulIndex - 1, szBuffer, ulLen );
   else
      return 0;
}
arrays.c551
CHAR *hb_arrayGetC( PHB_ITEM pArray, ULONG ulIndex )
char * hb_arrayGetC( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetC(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetC( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return NULL;
}
arrays.c561
CHAR *hb_arrayGetCPtr( PHB_ITEM pArray, ULONG ulIndex )
char * hb_arrayGetCPtr( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetCPtr(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetCPtr( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return ( char * ) "";
}
arrays.c571
ULONGhb_arrayGetCLen( PHB_ITEM pArray, ULONG ulIndex )
ULONG hb_arrayGetCLen( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetCLen(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetCLen( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c581
VOID *hb_arrayGetPtr( PHB_ITEM pArray, ULONG ulIndex )
void * hb_arrayGetPtr( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetPtr(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetPtr( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return NULL;
}
arrays.c591
VOID *hb_arrayGetPtrGC( PHB_ITEM pArray, ULONG ulIndex, HB_GARBAGE_FUNC_PTR pFunc )
void * hb_arrayGetPtrGC( PHB_ITEM pArray, ULONG ulIndex, HB_GARBAGE_FUNC_PTR pFunc )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetPtrGC(%p, %lu, %p)", pArray, ulIndex, pFunc));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetPtrGC( pArray->item.asArray.value->pItems + ulIndex - 1, pFunc );
   else
      return NULL;
}
arrays.c601
PHB_SYMBhb_arrayGetSymbol( PHB_ITEM pArray, ULONG ulIndex )
PHB_SYMB hb_arrayGetSymbol( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetSymbol(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemGetSymbol( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return NULL;
}
arrays.c611
HB_TYPEhb_arrayGetType( PHB_ITEM pArray, ULONG ulIndex )
HB_TYPE hb_arrayGetType( PHB_ITEM pArray, ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayGetType(%p, %lu)", pArray, ulIndex));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
      return hb_itemType( pArray->item.asArray.value->pItems + ulIndex - 1 );
   else
      return 0;
}
arrays.c622
HB_EXPORT BOOLhb_arraySetDS( PHB_ITEM pArray, ULONG ulIndex, const char * szDate )
HB_EXPORT BOOL hb_arraySetDS( PHB_ITEM pArray, ULONG ulIndex, const char * szDate )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetDS(%p, %lu, %s)", pArray, ulIndex, szDate));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutDS( pArray->item.asArray.value->pItems + ulIndex - 1, szDate );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c632
HB_EXPORT BOOLhb_arraySetDL( PHB_ITEM pArray, ULONG ulIndex, LONG lDate )
HB_EXPORT BOOL hb_arraySetDL( PHB_ITEM pArray, ULONG ulIndex, LONG lDate )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetDL(%p, %lu, %ld)", pArray, ulIndex, lDate));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutDL( pArray->item.asArray.value->pItems + ulIndex - 1, lDate );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c645
HB_EXPORT BOOLhb_arraySetL( PHB_ITEM pArray, ULONG ulIndex, BOOL fValue )
HB_EXPORT BOOL hb_arraySetL( PHB_ITEM pArray, ULONG ulIndex, BOOL fValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetL(%p, %lu, %d)", pArray, ulIndex, fValue));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutL( pArray->item.asArray.value->pItems + ulIndex - 1, fValue );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c658
HB_EXPORT BOOLhb_arraySetNI( PHB_ITEM pArray, ULONG ulIndex, int iNumber )
HB_EXPORT BOOL hb_arraySetNI( PHB_ITEM pArray, ULONG ulIndex, int iNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetNI(%p, %lu, %d)", pArray, ulIndex, iNumber));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutNI( pArray->item.asArray.value->pItems + ulIndex - 1, iNumber );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c671
HB_EXPORT BOOLhb_arraySetNL( PHB_ITEM pArray, ULONG ulIndex, LONG lNumber )
HB_EXPORT BOOL hb_arraySetNL( PHB_ITEM pArray, ULONG ulIndex, LONG lNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetNL(%p, %lu, %lu)", pArray, ulIndex, lNumber));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutNL( pArray->item.asArray.value->pItems + ulIndex - 1, lNumber );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c684
HB_EXPORT BOOLhb_arraySetNLL( PHB_ITEM pArray, ULONG ulIndex, LONGLONG llNumber )
HB_EXPORT BOOL hb_arraySetNLL( PHB_ITEM pArray, ULONG ulIndex, LONGLONG llNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetNLL(%p, %lu, %" PFLL "d)", pArray, ulIndex, llNumber));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutNLL( pArray->item.asArray.value->pItems + ulIndex - 1, llNumber );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c698
HB_EXPORT BOOLhb_arraySetNInt( PHB_ITEM pArray, ULONG ulIndex, HB_LONG lNumber )
HB_EXPORT BOOL hb_arraySetNInt( PHB_ITEM pArray, ULONG ulIndex, HB_LONG lNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetNInt(%p, %lu, %" PFHL "d)", pArray, ulIndex, lNumber));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutNInt( pArray->item.asArray.value->pItems + ulIndex - 1, lNumber );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c712
HB_EXPORT BOOLhb_arraySetND( PHB_ITEM pArray, ULONG ulIndex, double dNumber )
HB_EXPORT BOOL hb_arraySetND( PHB_ITEM pArray, ULONG ulIndex, double dNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetND(%p, %lu, %lf)", pArray, ulIndex, dNumber));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutND( pArray->item.asArray.value->pItems + ulIndex - 1, dNumber );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c725
HB_EXPORT BOOLhb_arraySetC( PHB_ITEM pArray, ULONG ulIndex, const char * szText )
HB_EXPORT BOOL hb_arraySetC( PHB_ITEM pArray, ULONG ulIndex, const char * szText )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetC(%p, %lu, %p)", pArray, ulIndex, szText));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutC( pArray->item.asArray.value->pItems + ulIndex - 1, szText );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c738
HB_EXPORT BOOLhb_arraySetCL( PHB_ITEM pArray, ULONG ulIndex, const char * szText, ULONG ulLen )
HB_EXPORT BOOL hb_arraySetCL( PHB_ITEM pArray, ULONG ulIndex, const char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetC(%p, %lu, %p, %lu)", pArray, ulIndex, szText, ulLen));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutCL( pArray->item.asArray.value->pItems + ulIndex - 1, szText, ulLen );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c751
HB_EXPORT BOOLhb_arraySetCPtr( PHB_ITEM pArray, ULONG ulIndex, char * szText, ULONG ulLen )
HB_EXPORT BOOL hb_arraySetCPtr( PHB_ITEM pArray, ULONG ulIndex, char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetCPtr(%p, %lu)", pArray, ulIndex, szText, ulLen));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutCLPtr( pArray->item.asArray.value->pItems + ulIndex - 1, szText, ulLen );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c764
HB_EXPORT BOOLhb_arraySetPtr( PHB_ITEM pArray, ULONG ulIndex, void * pValue )
HB_EXPORT BOOL hb_arraySetPtr( PHB_ITEM pArray, ULONG ulIndex, void * pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetPtr(%p, %lu, %p)", pArray, ulIndex, pValue));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutPtr( pArray->item.asArray.value->pItems + ulIndex - 1, pValue );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c777
HB_EXPORT BOOLhb_arraySetPtrGC( PHB_ITEM pArray, ULONG ulIndex, void * pValue )
HB_EXPORT BOOL hb_arraySetPtrGC( PHB_ITEM pArray, ULONG ulIndex, void * pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetPtrGC(%p, %lu, %p)", pArray, ulIndex, pValue));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutPtrGC( pArray->item.asArray.value->pItems + ulIndex - 1, pValue );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c790
HB_EXPORT BOOLhb_arraySetSymbol( PHB_ITEM pArray, ULONG ulIndex, PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_arraySetSymbol( PHB_ITEM pArray, ULONG ulIndex, PHB_SYMB pSymbol )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySetSymbol(%p, %lu, %p)", pArray, ulIndex, pSymbol));

   if( HB_IS_ARRAY( pArray ) && ulIndex > 0 && ulIndex <= pArray->item.asArray.value->ulLen )
   {
      hb_itemPutSymbol( pArray->item.asArray.value->pItems + ulIndex - 1, pSymbol );
      return TRUE;
   }
   else
      return FALSE;
}
arrays.c803
BOOLhb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult )
BOOL hb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayLast(%p, %p)", pArray, pResult));

   if( HB_IS_ARRAY( pArray ) )
   {
      if( pArray->item.asArray.value->ulLen > 0 )
         hb_itemCopy( pResult, pArray->item.asArray.value->pItems +
                             ( pArray->item.asArray.value->ulLen - 1 ) );
      else
         hb_itemSetNil( pResult );

      return TRUE;
   }

   hb_itemSetNil( pResult );

   return FALSE;
}
arrays.c816
BOOLhb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount )
BOOL hb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayFill(%p, %p, %p, %p)", pArray, pValue, pulStart, pulCount));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
      ULONG ulLen = pBaseArray->ulLen;
      ULONG ulStart;
      ULONG ulCount;

      if( pulStart && *pulStart )
         ulStart = *pulStart - 1;
      else
         ulStart = 0;

      if( ulStart < ulLen )
      {
         ulCount = ulLen - ulStart;
         if( pulCount && *pulCount < ulCount )
            ulCount = *pulCount;

         if( ulCount > 0 )
         {
            do
            {
               hb_itemCopy( pBaseArray->pItems + ulStart++, pValue );
            }
            while( --ulCount > 0 );
         }
      }

      return TRUE;
   }
   else
      return FALSE;
}
arrays.c836
ULONGhb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount, BOOL fExact )
ULONG hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount, BOOL fExact )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayScan(%p, %p, %p, %p, %d)", pArray, pValue, pulStart, pulCount, (int) fExact));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
      ULONG ulLen = pBaseArray->ulLen;
      ULONG ulStart;
      ULONG ulCount;

      if( pulStart && *pulStart )
         ulStart = *pulStart - 1;
      else
         ulStart = 0;

      if( ulStart < ulLen )
      {
         ulCount = ulLen - ulStart;
         if( pulCount && *pulCount < ulCount )
            ulCount = *pulCount;

         if( ulCount > 0 )
         {
            /* Make separate search loops for different types to find, so that
               the loop can be faster. */

            if( HB_IS_BLOCK( pValue ) )
            {
               do
               {
                  hb_vmPushSymbol( &hb_symEval );
                  hb_vmPush( pValue );
                  hb_vmPush( pBaseArray->pItems + ulStart );
                  hb_vmPushLong( ++ulStart );
                  hb_vmDo( 2 );

                  if( HB_IS_LOGICAL( hb_stackReturnItem() ) && hb_stackReturnItem()->item.asLogical.value )
                     return ulStart;
               }
               while( --ulCount > 0 && ulStart < pBaseArray->ulLen );
            }
            else if( HB_IS_STRING( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  /* NOTE: The order of the pItem and pValue parameters passed to
                           hb_itemStrCmp() is significant, please don't change it. [vszakats] */
                  if( HB_IS_STRING( pItem ) && hb_itemStrCmp( pItem, pValue, fExact ) == 0 )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( HB_IS_NUMERIC( pValue ) )
            {
               double dValue = hb_itemGetND( pValue );

               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_NUMERIC( pItem ) && hb_itemGetND( pItem ) == dValue )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( HB_IS_DATE( pValue ) )
            {
               long lValue = hb_itemGetDL( pValue ); /* NOTE: This is correct: Get the date as a long value. [vszakats] */

               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_DATE( pItem ) && hb_itemGetDL( pItem ) == lValue )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( HB_IS_LOGICAL( pValue ) )
            {
               BOOL bValue = hb_itemGetL( pValue );

               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_LOGICAL( pItem ) && hb_itemGetL( pItem ) == bValue )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( HB_IS_NIL( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_NIL( pItem ) )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( HB_IS_POINTER( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_POINTER( pItem ) &&
                      pItem->item.asPointer.value == pValue->item.asPointer.value )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( fExact && HB_IS_ARRAY( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_ARRAY( pItem ) &&
                      pItem->item.asArray.value == pValue->item.asArray.value )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
            else if( fExact && HB_IS_HASH( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart++;

                  if( HB_IS_HASH( pItem ) &&
                      pItem->item.asHash.value == pValue->item.asHash.value )
                     return ulStart;
               }
               while( --ulCount > 0 );
            }
         }
      }
   }

   return 0;
}
arrays.c874
ULONGhb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount, BOOL fExact )
ULONG hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount, BOOL fExact )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayRevScan(%p, %p, %p, %p, %d)", pArray, pValue, pulStart, pulCount, (int) fExact));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
      ULONG ulLen = pBaseArray->ulLen;
      ULONG ulStart;
      ULONG ulCount;

      if( pulStart && *pulStart )
         ulStart = *pulStart - 1;
      else
         ulStart = ulLen - 1;

      if( ulStart < ulLen )
      {
         ulCount = ulStart + 1;
         if( pulCount && *pulCount < ulCount )
            ulCount = *pulCount;

         if( ulCount > 0 )
         {
            /* Make separate search loops for different types to find, so that
               the loop can be faster. */

            if( HB_IS_BLOCK( pValue ) )
            {
               do
               {
                  hb_vmPushSymbol( &hb_symEval );
                  hb_vmPush( pValue );
                  hb_vmPush( pBaseArray->pItems + ulStart );
                  hb_vmPushLong( ulStart + 1 );
                  hb_vmDo( 2 );

                  if( HB_IS_LOGICAL( hb_stackReturnItem() ) && hb_stackReturnItem()->item.asLogical.value )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( HB_IS_STRING( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  /* NOTE: The order of the pItem and pValue parameters passed to
                           hb_itemStrCmp() is significant, please don't change it. [vszakats] */
                  if( HB_IS_STRING( pItem ) && hb_itemStrCmp( pItem, pValue, fExact ) == 0 )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( HB_IS_NUMERIC( pValue ) )
            {
               double dValue = hb_itemGetND( pValue );

               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_NUMERIC( pItem ) && hb_itemGetND( pItem ) == dValue )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( HB_IS_DATE( pValue ) )
            {
               long lValue = hb_itemGetDL( pValue ); /* NOTE: This is correct: Get the date as a long value. [vszakats] */

               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_DATE( pItem ) && hb_itemGetDL( pItem ) == lValue )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( HB_IS_LOGICAL( pValue ) )
            {
               BOOL bValue = hb_itemGetL( pValue );

               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_LOGICAL( pItem ) && hb_itemGetL( pItem ) == bValue )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( HB_IS_NIL( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_NIL( pItem ) )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( HB_IS_POINTER( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_POINTER( pItem ) &&
                      pItem->item.asPointer.value == pValue->item.asPointer.value )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( fExact && HB_IS_ARRAY( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_ARRAY( pItem ) &&
                      pItem->item.asArray.value == pValue->item.asArray.value )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
            else if( fExact && HB_IS_HASH( pValue ) )
            {
               do
               {
                  PHB_ITEM pItem = pBaseArray->pItems + ulStart;

                  if( HB_IS_HASH( pItem ) &&
                      pItem->item.asHash.value == pValue->item.asHash.value )
                     return ulStart + 1;
               }
               while( --ulCount && ulStart-- );
            }
         }
      }
   }

   return 0;
}
arrays.c1022
BOOLhb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, ULONG * pulStart, ULONG * pulCount )
BOOL hb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, ULONG * pulStart, ULONG * pulCount )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayEval(%p, %p, %p, %p)", pArray, bBlock, pulStart, pulCount));

   if( HB_IS_ARRAY( pArray ) && HB_IS_BLOCK( bBlock ) )
   {
      PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
      ULONG ulLen = pBaseArray->ulLen;
      ULONG ulStart;
      ULONG ulCount;

      if( pulStart && *pulStart )
         ulStart = *pulStart - 1;
      else
         ulStart = 0;

      if( ulStart < ulLen )
      {
         ulCount = ulLen - ulStart;
         if( pulCount && *pulCount < ulCount )
            ulCount = *pulCount;

         if( ulCount > 0 )
         {
            do
            {
               hb_vmPushSymbol( &hb_symEval );
               hb_vmPush( bBlock );
               hb_vmPush( pBaseArray->pItems + ulStart );
               hb_vmPushLong( ulStart + 1 );
               hb_vmDo( 2 );
            }
            while( --ulCount > 0 && ++ulStart < pBaseArray->ulLen );
            /*
             * checking for ulStart < pBaseArray->ulLen is fix for
             * possible GPF when codeblock decrease array size
             */
         }
      }

      return TRUE;
   }
   else
      return FALSE;
}
arrays.c1170
BOOLhb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG * pulStart, ULONG * pulCount, ULONG * pulTarget )
BOOL hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG * pulStart,
                   ULONG * pulCount, ULONG * pulTarget )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arrayCopy(%p, %p, %p, %p, %p)", pSrcArray, pDstArray, pulStart, pulCount, pulTarget));

   if( HB_IS_ARRAY( pSrcArray ) && HB_IS_ARRAY( pDstArray ) )
   {
      PHB_BASEARRAY pSrcBaseArray = pSrcArray->item.asArray.value;
      PHB_BASEARRAY pDstBaseArray = pDstArray->item.asArray.value;
      ULONG ulSrcLen = pSrcBaseArray->ulLen;
      ULONG ulDstLen = pDstBaseArray->ulLen;
      ULONG ulStart;
      ULONG ulCount;
      ULONG ulTarget;

      if( pulStart && ( *pulStart >= 1 ) )
         ulStart = *pulStart;
      else
         ulStart = 1;

      if( pulTarget && ( *pulTarget >= 1 ) )
         ulTarget = *pulTarget;
      else
         ulTarget = 1;

#ifdef HB_COMPAT_C53 /* From CA-Cl*pper 5.3a */
      if( ulStart <= ulSrcLen )
#else
      if( ulSrcLen > 0 )
#endif
      {
#ifndef HB_COMPAT_C53 /* From CA-Cl*pper 5.3a */
         if( ulStart > ulSrcLen )
            ulStart = ulSrcLen;
#endif
         if( pulCount && ( *pulCount <= ulSrcLen - ulStart ) )
            ulCount = *pulCount;
         else
            ulCount = ulSrcLen - ulStart + 1;

/* This is probably a bug, present in all versions of CA-Cl*pper. */
#if defined( HB_C52_STRICT ) || 1
         if( ulDstLen > 0 )
         {
            if( ulTarget > ulDstLen )
               ulTarget = ulDstLen;
#else
         if( ulTarget <= ulDstLen )
         {
#endif

            if( ulCount > ulDstLen - ulTarget )
               ulCount = ulDstLen - ulTarget + 1;

            for( ulTarget--, ulStart--; ulCount > 0; ulCount--, ulStart++, ulTarget++ )
               hb_itemCopy( pDstBaseArray->pItems + ulTarget, pSrcBaseArray->pItems + ulStart );
         }
      }

      return TRUE;
   }
   else
      return FALSE;
}

static void hb_arrayCloneBody( PHB_BASEARRAY pSrcBaseArray, PHB_BASEARRAY pDstBaseArray, PHB_NESTED_CLONED pClonedList )
{
   PHB_ITEM pSrcItem, pDstItem;
   ULONG ulLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayCloneBody(%p, %p, %p)", pSrcBaseArray, pDstBaseArray, pClonedList));

   pSrcItem = pSrcBaseArray->pItems;
   pDstItem = pDstBaseArray->pItems;

   pDstBaseArray->uiClass = pSrcBaseArray->uiClass;

   for( ulLen = pSrcBaseArray->ulLen; ulLen; --ulLen, ++pSrcItem, ++pDstItem )
      hb_cloneNested( pDstItem, pSrcItem, pClonedList );
}

void hb_cloneNested( PHB_ITEM pDstItem, PHB_ITEM pSrcItem, PHB_NESTED_CLONED pClonedList )
{
   /* Clipper clones nested array ONLY if NOT an Object!!! */
   if( HB_IS_ARRAY( pSrcItem ) && pSrcItem->item.asArray.value->uiClass == 0 )
   {
      PHB_NESTED_CLONED pCloned = pClonedList;
      PHB_BASEARRAY pBaseArray = pSrcItem->item.asArray.value;

      do
      {
         if( pCloned->value == ( void * ) pBaseArray )
            break;
         pCloned = pCloned->pNext;
      }
      while( pCloned );

      if( pCloned )
         hb_itemCopy( pDstItem, pCloned->pDest );
      else
      {
         hb_arrayNew( pDstItem, pBaseArray->ulLen );

         pCloned = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
         pCloned->value     = ( void * ) pBaseArray;
         pCloned->pDest     = pDstItem;
         pCloned->pNext     = pClonedList->pNext;
         pClonedList->pNext = pCloned;

         hb_arrayCloneBody( pBaseArray, pDstItem->item.asArray.value, pClonedList );
      }
   }
   else if( HB_IS_HASH( pSrcItem ) )
   {
      PHB_NESTED_CLONED pCloned = pClonedList;
      PHB_BASEHASH pBaseHash = pSrcItem->item.asHash.value;

      do
      {
         if( pCloned->value == ( void * ) pBaseHash )
            break;
         pCloned = pCloned->pNext;
      }
      while( pCloned );

      if( pCloned )
         hb_itemCopy( pDstItem, pCloned->pDest );
      else
      {
         pCloned = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
         pCloned->value     = ( void * ) pBaseHash;
         pCloned->pDest     = pDstItem;
         pCloned->pNext     = pClonedList->pNext;
         pClonedList->pNext = pCloned;

         hb_hashCloneBody( pSrcItem, pDstItem, pClonedList );
      }
   }
   else
      hb_itemCopy( pDstItem, pSrcItem );
}

HB_EXPORT PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
{
   PHB_ITEM pDstArray;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayClone(%p)", pSrcArray));

   pDstArray = hb_itemNew( NULL );
   if( HB_IS_ARRAY( pSrcArray ) )
   {
      PHB_NESTED_CLONED pClonedList, pCloned;
      PHB_BASEARRAY pSrcBaseArray = pSrcArray->item.asArray.value;
      ULONG ulSrcLen = pSrcBaseArray->ulLen;

      hb_arrayNew( pDstArray, ulSrcLen );
      pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
      pClonedList->value = ( void * ) pSrcBaseArray;
      pClonedList->pDest = pDstArray;
      pClonedList->pNext = NULL;

      hb_arrayCloneBody( pSrcBaseArray, pDstArray->item.asArray.value, pClonedList );

      do
      {
         pCloned = pClonedList;
         pClonedList = pClonedList->pNext;
         hb_xfree( pCloned );
      }
      while( pClonedList );
   }
   return pDstArray;
}

HB_EXPORT PHB_ITEM hb_arrayFromStack( USHORT uiLen )
{
   PHB_ITEM pArray = hb_itemNew( NULL );
   USHORT uiPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayFromStack(%hu)", uiLen));

   hb_arrayNew( pArray, uiLen );

   for( uiPos = 1; uiPos <= uiLen; uiPos++ )
   {
      hb_arraySet( pArray, uiPos, hb_stackItemFromTop( uiPos - uiLen - 1 ) );
   }

   return pArray;
}

PHB_ITEM hb_arrayFromParams( int iLevel )
{
   PHB_ITEM pArray;
   USHORT uiPos, uiPCount;
   LONG lBaseOffset;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayFromParams(%d)", iLevel));

   lBaseOffset = hb_stackBaseProcOffset( iLevel );
   if( lBaseOffset > 0 )
      uiPCount = hb_stackItem( lBaseOffset )->item.asSymbol.paramcnt;
   else
      uiPCount = 0;

   pArray = hb_itemArrayNew( uiPCount );
   for( uiPos = 1; uiPos <= uiPCount; uiPos++ )
   {
      hb_arraySet( pArray, uiPos, hb_stackItem( lBaseOffset + uiPos + 1 ) );
   }

   return pArray;
}

HB_EXPORT PHB_ITEM hb_arrayBaseParams( void )
{
   PHB_ITEM pArray;
   USHORT uiPos, uiPCount;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayBaseParams()"));

   pArray = hb_itemNew( NULL );
   uiPCount = hb_stackBaseItem()->item.asSymbol.paramcnt;

   hb_arrayNew( pArray, uiPCount );

   for( uiPos = 1; uiPos <= uiPCount; uiPos++ )
   {
      hb_arraySet( pArray, uiPos, hb_stackItemFromBase( uiPos ) );
   }

   return pArray;
}

HB_EXPORT PHB_ITEM hb_arraySelfParams( void )
{
   PHB_ITEM pArray;
   USHORT uiPos, uiPCount;

   HB_TRACE(HB_TR_DEBUG, ("hb_arraySelfParams()"));

   pArray = hb_itemNew( NULL );
   uiPCount = hb_stackBaseItem()->item.asSymbol.paramcnt;

   hb_arrayNew( pArray, uiPCount + 1 );

   for( uiPos = 0; uiPos <= uiPCount; uiPos++ )
   {
      hb_arraySet( pArray, uiPos + 1, hb_stackItemFromBase( uiPos ) );
   }

   return pArray;
}
arrays.c1219
arrayshb.c
TypeFunctionSourceLine
STATIC VOIDhb_arrayNewRagged( PHB_ITEM pArray, int iDimension )
static void hb_arrayNewRagged( PHB_ITEM pArray, int iDimension )
{
   ULONG ulElements;

   HB_TRACE(HB_TR_DEBUG, ("hb_arrayNewRagged(%p, %d)", pArray, iDimension));

   ulElements = ( ULONG ) hb_parnl( iDimension );

   /* create an array */
   hb_arrayNew( pArray, ulElements );

   if( ++iDimension <= hb_pcount() )
   {
      /* call self recursively to create next dimensions
       */
      while( ulElements )
         hb_arrayNewRagged( hb_arrayGetItemPtr( pArray, ulElements-- ), iDimension );
   }
}
arrayshb.c59
HB_FUNCARRAY(void)
HB_FUNC( ARRAY )
{
   int iPCount = hb_pcount();

   if( iPCount > 0 )
   {
      BOOL bError = FALSE;
      int iParam;

      for( iParam = 1; iParam <= iPCount; iParam++ )
      {
         if( ! ISNUM( iParam ) )
         {
            bError = TRUE;
            break;
         }

         if( hb_parnl( iParam ) < 0 ) /* || hb_parnl( iParam ) <= 4096 */
         {
#ifdef HB_C52_STRICT
            hb_errRT_BASE( EG_BOUND, 1131, NULL, hb_langDGetErrorDesc( EG_ARRDIMENSION ), 0 );
#else
            hb_errRT_BASE( EG_BOUND, 1131, NULL, hb_langDGetErrorDesc( EG_ARRDIMENSION ), HB_ERR_ARGS_BASEPARAMS );
#endif
            bError = TRUE;
            break;
         }
      }

      if( ! bError )
         hb_arrayNewRagged( hb_stackReturnItem(), 1 );
   }
}
arrayshb.c82
HB_FUNCAADD(void)
HB_FUNC( AADD )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

      if( pValue && hb_arrayAdd( pArray, pValue ) )
         hb_itemReturn( pValue );
      else
         hb_errRT_BASE( EG_BOUND, 1187, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
arrayshb.c116
HB_FUNCASIZE(void)
HB_FUNC( ASIZE )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray && ISNUM( 2 ) )
   {
      long lSize = hb_parnl( 2 );

      hb_arraySize( pArray, HB_MAX( lSize, 0 ) );

      hb_itemReturn( pArray ); /* ASize() returns the array itself */
   }
#ifdef HB_COMPAT_C53 /* From CA-Cl*pper 5.3a */
   else
#ifdef HB_C52_STRICT
      hb_errRT_BASE( EG_ARG, 2023, NULL, HB_ERR_FUNCNAME, 0 );
#else
      hb_errRT_BASE( EG_ARG, 2023, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#endif
#endif
}
arrayshb.c136
HB_FUNCATAIL(void)
HB_FUNC( ATAIL )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
      hb_arrayLast( pArray, hb_stackReturnItem() );
}
arrayshb.c158
HB_FUNCAINS(void)
HB_FUNC( AINS )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      long lPos = hb_parnl( 2 );

      if( lPos == 0 )
         lPos = 1;

      hb_arrayIns( pArray, lPos );

      hb_itemReturn( pArray ); /* AIns() returns the array itself */
   }
}
arrayshb.c166
HB_FUNCADEL(void)
HB_FUNC( ADEL )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      long lPos = hb_parnl( 2 );

      if( lPos == 0 )
         lPos = 1;

      hb_arrayDel( pArray, lPos );

      hb_itemReturn( pArray ); /* ADel() returns the array itself */
   }
}
arrayshb.c183
HB_FUNCAFILL(void)
HB_FUNC( AFILL )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

      hb_itemReturn( pArray ); /* AFill() returns the array itself */

      if( pValue )
      {
         ULONG ulStart, ulCount;
         LONG lStart = hb_parnl( 3 ), lCount = hb_parnl( 4 );

         /* Explicy lCount of 0 - Nothing to do! */
         if( ISNUM( 4 ) && lCount == 0 )
            return;
         /* Clipper aborts if negative start. */
         else if( lStart < 0 )
            return;
         /* Clipper allows Start to be of wrong type, or 0, and corrects it to 1. */
         else if( lStart == 0 )
            lStart = 1;
         if( lCount < 0 )
         {
            /* Clipper allows the Count to be negative, if start is 1, and corrects it to maximum elements. */
            if( lStart == 1 )
               ulCount = 0;
            /* Clipper aborts if negative count and start is not at 1. */
            else
               return;
         }
         ulStart = ( ULONG ) lStart;
         ulCount = ( ULONG ) lCount;
         hb_arrayFill( pArray,
                       pValue,
                       ISNUM( 3 ) ? &ulStart : NULL,
                       ISNUM( 4 ) ? &ulCount : NULL );
      }
   }
   else
#ifdef HB_C52_STRICT
      /* NOTE: In CA-Cl*pper AFILL() is written in a manner that it will
               call AEVAL() to do the job, so the error (if any) will also be
               thrown by AEVAL().  [vszakats] */
      hb_errRT_BASE( EG_ARG, 2017, NULL, "AEVAL", 0 );
#else
      hb_errRT_BASE( EG_ARG, 6004, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#endif
}
arrayshb.c200
HB_FUNCASCAN(void)
HB_FUNC( ASCAN )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

   if( pArray && pValue )
   {
      ULONG ulStart = hb_parnl( 3 );
      ULONG ulCount = hb_parnl( 4 );

      hb_retnint( hb_arrayScan( pArray, pValue,
                                ISNUM( 3 ) ? &ulStart : NULL,
                                ISNUM( 4 ) ? &ulCount : NULL,
                                FALSE ) );
   }
   else
      hb_retni( 0 );
}
arrayshb.c252
HB_FUNCHB_ASCAN(void)
HB_FUNC( HB_ASCAN )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

   if( pArray && pValue )
   {
      ULONG ulStart = hb_parnl( 3 );
      ULONG ulCount = hb_parnl( 4 );

      hb_retnint( hb_arrayScan( pArray, pValue,
                                ISNUM( 3 ) ? &ulStart : NULL,
                                ISNUM( 4 ) ? &ulCount : NULL,
                                hb_parl( 5 ) ) );
   }
   else
      hb_retni( 0 );
}
arrayshb.c271
HB_FUNCHB_RASCAN(void)
HB_FUNC( HB_RASCAN )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

   if( pArray && pValue )
   {
      ULONG ulStart = hb_parnl( 3 );
      ULONG ulCount = hb_parnl( 4 );

      hb_retnint( hb_arrayRevScan( pArray, pValue,
                                   ISNUM( 3 ) ? &ulStart : NULL,
                                   ISNUM( 4 ) ? &ulCount : NULL,
                                   hb_parl( 5 ) ) );
   }
   else
      hb_retni( 0 );
}
arrayshb.c291
HB_FUNCHB_AINS(void)
HB_FUNC( HB_AINS )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      long lPos = hb_parnl( 2 );

      if( lPos == 0 )
         lPos = 1;

      if( hb_pcount() >= 4 && ISLOG( 4 ) && hb_parl( 4 ) )
      {
         ULONG ulLen = hb_arrayLen( pArray ) + 1;
         if( lPos >= 1 && ( ULONG ) lPos <= ulLen )
            hb_arraySize( pArray, ulLen );
      }

      if( hb_arrayIns( pArray, lPos ) )
      {
         if( hb_pcount() >= 3 && !ISNIL( 3 ) )
            hb_arraySet( pArray, lPos, hb_param( 3, HB_IT_ANY ) );
      }
      hb_itemReturn( pArray ); /* AIns() returns the array itself */
   }
}
arrayshb.c310
HB_FUNCHB_ADEL(void)
HB_FUNC( HB_ADEL )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      long lPos = hb_parnl( 2 );

      if( lPos == 0 )
         lPos = 1;

      if( hb_arrayDel( pArray, lPos ) )
      {
         if( hb_pcount() >= 3 && ISLOG( 3 ) && hb_parl( 3 ) )
            hb_arraySize( pArray, hb_arrayLen( pArray ) - 1 );
      }
      hb_itemReturn( pArray ); /* ADel() returns the array itself */
   }
}
arrayshb.c337
HB_FUNCAEVAL(void)
HB_FUNC( AEVAL )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pBlock = hb_param( 2, HB_IT_BLOCK );

   if( pArray && pBlock )
   {
      ULONG ulStart = hb_parnl( 3 );
      ULONG ulCount = hb_parnl( 4 );

      hb_arrayEval( pArray,
                    pBlock,
                    ISNUM( 3 ) ? &ulStart : NULL,
                    ISNUM( 4 ) ? &ulCount : NULL );

      hb_itemReturn( hb_stackItemFromBase( 1 ) ); /* AEval() returns the array itself */
   }
   else
      hb_errRT_BASE( EG_ARG, 2017, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
arrayshb.c361
HB_FUNCACOPY(void)
HB_FUNC( ACOPY )
{
   PHB_ITEM pSrcArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pDstArray = hb_param( 2, HB_IT_ARRAY );

   if( pSrcArray && pDstArray )
   {
      /* CA-Cl*pper works this way. */
      if( ! hb_arrayIsObject( pSrcArray ) && ! hb_arrayIsObject( pDstArray ) )
      {
         ULONG ulStart = hb_parnl( 3 );
         ULONG ulCount = hb_parnl( 4 );
         ULONG ulTarget = hb_parnl( 5 );

         hb_arrayCopy( pSrcArray,
                       pDstArray,
                       ISNUM( 3 ) ? &ulStart : NULL,
                       ISNUM( 4 ) ? &ulCount : NULL,
                       ISNUM( 5 ) ? &ulTarget : NULL );
      }

      hb_itemReturn( hb_stackItemFromBase( 2 ) ); /* ACopy() returns the target array */
   }
}
arrayshb.c382
HB_FUNCACLONE(void)
HB_FUNC( ACLONE )
{
   PHB_ITEM pSrcArray = hb_param( 1, HB_IT_ARRAY );

   if( pSrcArray && ! hb_arrayIsObject( pSrcArray ) )
      hb_itemReturnRelease( hb_arrayClone( pSrcArray ) ); /* AClone() returns the new array */
}
arrayshb.c409
HB_FUNCHB_APARAMS(void)
HB_FUNC( HB_APARAMS )
{
   hb_itemReturnRelease( hb_arrayFromParams( hb_parni( 1 ) + 1 ) );
}
arrayshb.c417
asort.c
TypeFunctionSourceLine
STATIC BOOLhb_itemIsLess( PHB_ITEM pItem1, PHB_ITEM pItem2, PHB_ITEM pBlock, PHB_BASEARRAY pBaseArray, ULONG ulLast )
static BOOL hb_itemIsLess( PHB_ITEM pItem1, PHB_ITEM pItem2, PHB_ITEM pBlock, PHB_BASEARRAY pBaseArray, ULONG ulLast )
{
   if( pBlock )
   {
      hb_vmPushSymbol( &hb_symEval );
      hb_vmPush( pBlock );
      hb_vmPush( pItem1 );
      hb_vmPush( pItem2 );
      hb_vmSend( 2 );

      if( pBaseArray->ulLen <= ulLast )
         return FALSE;
      else if( HB_IS_LOGICAL( hb_stackReturnItem() ) )
         return hb_itemGetL( hb_stackReturnItem() );
   }

   /* Do native compare when no codeblock is supplied */

   if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
      return hb_itemStrCmp( pItem1, pItem2, FALSE ) < 0;
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
      return hb_itemGetNInt( pItem1 ) < hb_itemGetNInt( pItem2 );
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
      return hb_itemGetND( pItem1 ) < hb_itemGetND( pItem2 );
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
      return hb_itemGetDL( pItem1 ) < hb_itemGetDL( pItem2 );
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
      return hb_itemGetL( pItem1 ) < hb_itemGetL( pItem2 );
   else
   {
      /* NOTE: For non-matching types CA-Cl*pper sorts always like this:
               Array/Object Block String Logical Date Numeric NIL [jlalin] */

      int iWeight1;
      int iWeight2;

      if( HB_IS_ARRAY( pItem1 ) ) iWeight1 = 1;
      else if( HB_IS_BLOCK( pItem1 ) ) iWeight1 = 2;
      else if( HB_IS_STRING( pItem1 ) ) iWeight1 = 3;
      else if( HB_IS_LOGICAL( pItem1 ) ) iWeight1 = 4;
      else if( HB_IS_DATE( pItem1 ) ) iWeight1 = 5;
      else if( HB_IS_NUMERIC( pItem1 ) ) iWeight1 = 6;
      else iWeight1 = 7;

      if( HB_IS_ARRAY( pItem2 ) ) iWeight2 = 1;
      else if( HB_IS_BLOCK( pItem2 ) ) iWeight2 = 2;
      else if( HB_IS_STRING( pItem2 ) ) iWeight2 = 3;
      else if( HB_IS_LOGICAL( pItem2 ) ) iWeight2 = 4;
      else if( HB_IS_DATE( pItem2 ) ) iWeight2 = 5;
      else if( HB_IS_NUMERIC( pItem2 ) ) iWeight2 = 6;
      else iWeight2 = 7;

      return iWeight1 < iWeight2;
   }
}
asort.c66
STATIC LONGhb_arraySortQuickPartition( PHB_BASEARRAY pBaseArray, LONG lb, LONG ub, PHB_ITEM pBlock )
static LONG hb_arraySortQuickPartition( PHB_BASEARRAY pBaseArray, LONG lb, LONG ub, PHB_ITEM pBlock )
{
   LONG i, j;

   /* select pivot and exchange with 1st element */
   i = lb + ( ( ub - lb ) >> 1 );
   if( i != lb )
      hb_itemSwap( pBaseArray->pItems + lb, pBaseArray->pItems + i );

   /* sort lb+1..ub based on pivot */
   i = lb + 1;
   j = ub;

   for( ;; )
   {
      while( j >= i && !hb_itemIsLess( pBaseArray->pItems + j, pBaseArray->pItems + lb, pBlock, pBaseArray, j ) )
      {
         j--;
      }

      while( i < j && !hb_itemIsLess( pBaseArray->pItems + lb, pBaseArray->pItems + i, pBlock, pBaseArray, i ) )
      {
         i++;
      }

      if( i >= j )
      {
         break;
      }

      /* Swap the items */
      hb_itemSwap( pBaseArray->pItems + i, pBaseArray->pItems + j );
      j--;
      i++;
   }

   /* pivot belongs in pBaseArray->pItems[j] */
   if( j > lb && pBaseArray->ulLen > ( ULONG ) j )
      hb_itemSwap( pBaseArray->pItems + lb, pBaseArray->pItems + j );

   return j;
}
asort.c124
STATIC VOIDhb_arraySortQuick( PHB_BASEARRAY pBaseArray, LONG lb, LONG ub, PHB_ITEM pBlock )
static void hb_arraySortQuick( PHB_BASEARRAY pBaseArray, LONG lb, LONG ub, PHB_ITEM pBlock )
{
   LONG m;

   while( lb < ub )
   {
      if( ( ULONG ) ub >= pBaseArray->ulLen )
      {
         ub = pBaseArray->ulLen - 1;
         if( lb >= ub )
            break;
      }

      /* partition into two segments */
      m = hb_arraySortQuickPartition( pBaseArray, lb, ub, pBlock );

      /* sort the smallest partition to minimize stack requirements */
      if( m - lb <= ub - m )
      {
         hb_arraySortQuick( pBaseArray, lb, m - 1, pBlock );
         lb = m + 1;
      }
      else
      {
         hb_arraySortQuick( pBaseArray, m + 1, ub, pBlock );
         ub = m - 1;
      }
   }
}
asort.c169
BOOLhb_arraySort( PHB_ITEM pArray, ULONG * pulStart, ULONG * pulCount, PHB_ITEM pBlock )
BOOL hb_arraySort( PHB_ITEM pArray, ULONG * pulStart, ULONG * pulCount, PHB_ITEM pBlock )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_arraySort(%p, %p, %p, %p)", pArray, pulStart, pulCount, pBlock));

   if( HB_IS_ARRAY( pArray ) )
   {
      PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
      ULONG ulLen = pBaseArray->ulLen;
      ULONG ulStart;
      ULONG ulCount;
      ULONG ulEnd;

      if( pulStart && ( *pulStart >= 1 ) )
         ulStart = *pulStart;
      else
         ulStart = 1;

      if( ulStart <= ulLen )
      {
         if( pulCount && *pulCount >= 1 && ( *pulCount <= ulLen - ulStart ) )
            ulCount = *pulCount;
         else
            ulCount = ulLen - ulStart + 1;

         if( ulStart + ulCount > ulLen )             /* check range */
            ulCount = ulLen - ulStart + 1;

         ulEnd = ulCount + ulStart - 2;

         /* Optimize when only one or no element is to be sorted */
         if( ulCount > 1 )
            hb_arraySortQuick( pBaseArray, ulStart - 1, ulEnd, pBlock );
      }

      return TRUE;
   }
   else
      return FALSE;
}
asort.c199
HB_FUNCASORT(void)
HB_FUNC( ASORT )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray && ! hb_arrayIsObject( pArray ) )
   {
      ULONG ulStart = hb_parnl( 2 );
      ULONG ulCount = hb_parnl( 3 );

      hb_arraySort( pArray,
                    ISNUM( 2 ) ? &ulStart : NULL,
                    ISNUM( 3 ) ? &ulCount : NULL,
                    hb_param( 4, HB_IT_BLOCK ) );

      hb_itemReturn( pArray ); /* ASort() returns the array itself */
   }
}
asort.c239
break.c
TypeFunctionSourceLine
HB_FUNCBREAK(void)
HB_FUNC( BREAK )
{
   hb_vmRequestBreak( hb_param( 1, HB_IT_ANY ) );
}
break.c62
classes.c
TypeFunctionSourceLine
STATIC USHORThb_clsBucketPos( PHB_DYNS pMsg, USHORT uiMask )
static USHORT hb_clsBucketPos( PHB_DYNS pMsg, USHORT uiMask )
{
   /*
    * we can use PHB_DYNS address as base for hash key.
    * This value is perfectly unique and we do not need anything more
    * but it's not continuous so we will have to add dynamic BUCKETSIZE
    * modification to be 100% sure that we can resolve all symbol name
    * conflicts (though even without it it's rather theoretical problem).
    * [druzus]
    */

    /* Safely divide it by 16 - it's minimum memory allocated for single
     * HB_DYNS structure
     */
    /* 
    return ( ( USHORT ) ( ( HB_PTRDIFF ) pMsg >> 4 ) & uiMask ) << BUCKETBITS;
    */

   /* Using continuous symbol numbers we are 100% sure that we will cover
    * the whole 16bit area and we will never have any problems until number
    * of symbols is limited to 2^16. [druzus]
    */
   return ( pMsg->uiSymNum & uiMask ) << BUCKETBITS;
}
classes.c403
STATIC BOOLhb_clsDictRealloc( PCLASS pClass )
static BOOL hb_clsDictRealloc( PCLASS pClass )
{
   ULONG ulNewHashKey, ulLimit, ul;
#ifdef HB_MSG_POOL
   USHORT * puiMsgIdx;
#else
   PMETHOD pNewMethods;
#endif

   HB_TRACE(HB_TR_DEBUG, ("hb_clsDictRealloc(%p)", pClass));

   ulNewHashKey = ( ULONG ) pClass->uiHashKey + 1;
   ulLimit = ulNewHashKey << BUCKETBITS;

   do
   {
      ulNewHashKey <<= 1;
      if( ulNewHashKey > HASH_KEYMAX )
      {
         hb_errInternal( 6002, "Unable to realloc class message in __clsDictRealloc()", NULL, NULL );
         return FALSE;
      }

#ifdef HB_MSG_POOL
      puiMsgIdx = ( USHORT * ) hb_xgrab( ( ulNewHashKey << BUCKETBITS ) * sizeof( USHORT ) );
      memset( puiMsgIdx, 0, ( ulNewHashKey << BUCKETBITS ) * sizeof( USHORT ) );

      for( ul = 0; ul < ulLimit; ul++ )
      {
         USHORT uiMsg = pClass->puiMsgIdx[ ul ];
         if( pClass->puiMsgIdx[ ul ] )
         {
            USHORT uiBucket = BUCKETSIZE;
            USHORT * puiIdx = puiMsgIdx + hb_clsBucketPos(
                        pClass->pMethods[ uiMsg ].pMessage, ulNewHashKey - 1 );
            do
            {
               if( * puiIdx == 0 ) /* this message position is empty */
               {
                  * puiIdx = uiMsg;
                  break;
               }
               ++puiIdx;
            } while( --uiBucket );

            /* Not enough go back to the beginning */
            if( ! uiBucket )
            {
               hb_xfree( puiMsgIdx );
               break;
            }
         }
      }
   }
   while( ul < ulLimit );

   pClass->uiHashKey = ( USHORT ) ( ulNewHashKey - 1 );
   hb_xfree( pClass->puiMsgIdx );
   pClass->puiMsgIdx = puiMsgIdx;

#else

      pNewMethods = ( PMETHOD ) hb_xgrab( ( ulNewHashKey << BUCKETBITS ) * sizeof( METHOD ) );
      memset( pNewMethods, 0, ( ulNewHashKey << BUCKETBITS ) * sizeof( METHOD ) );

      for( ul = 0; ul < ulLimit; ul++ )
      {
         PHB_DYNS pMessage = ( PHB_DYNS ) pClass->pMethods[ ul ].pMessage;

         if( pMessage )
         {
            PMETHOD pMethod = pNewMethods + hb_clsBucketPos( pMessage, ulNewHashKey - 1 );
            USHORT uiBucket = BUCKETSIZE;

            do
            {
               if( ! pMethod->pMessage ) /* this message position is empty */
               {
                  memcpy( pMethod, pClass->pMethods + ul, sizeof( METHOD ) );
                  break;
               }
               ++pMethod;
            } while( --uiBucket );

            /* Not enough go back to the beginning */
            if( ! uiBucket )
            {
               hb_xfree( pNewMethods );
               break;
            }
         }
      }
   }
   while( ul < ulLimit );

   pClass->uiHashKey = ( USHORT ) ( ulNewHashKey - 1 );
   hb_xfree( pClass->pMethods );
   pClass->pMethods = pNewMethods;
#endif

   return TRUE;
}
classes.c429
} STATIC VOIDhb_clsDictInit( PCLASS pClass, USHORT uiHashKey )
static void hb_clsDictInit( PCLASS pClass, USHORT uiHashKey )
{
   ULONG ulSize;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsDictInit(%p,%hu)", pClass, uiHashKey));

   pClass->uiHashKey = uiHashKey;
#ifdef HB_MSG_POOL
   ulSize = ( ( ( ULONG ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( USHORT );
   pClass->puiMsgIdx = ( USHORT * ) hb_xgrab( ulSize );
   memset( pClass->puiMsgIdx, 0, ulSize );

   pClass->uiMethodCount = 1;
   pClass->pMethods = ( PMETHOD ) hb_xgrab( sizeof( METHOD ) );
   memset( pClass->pMethods, 0, sizeof( METHOD ) );
#else
   ulSize = ( ( ( ULONG ) uiHashKey + 1 ) << BUCKETBITS ) * sizeof( METHOD );
   pClass->pMethods = ( PMETHOD ) hb_xgrab( ulSize );
   memset( pClass->pMethods, 0, ulSize );
#endif
}
classes.c537
STATIC PMETHODhb_clsFindMsg( PCLASS pClass, PHB_DYNS pMsg )
static PMETHOD hb_clsFindMsg( PCLASS pClass, PHB_DYNS pMsg )
{
#ifdef HB_MSG_POOL

   USHORT uiBucket, * puiMsgIdx;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsFindMsg(%p,%p)", pClass, pMsg));

   puiMsgIdx = pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->uiHashKey );
   uiBucket = BUCKETSIZE;

   do
   {
      if( pClass->pMethods[ * puiMsgIdx ].pMessage == pMsg )
      {
         return &pClass->pMethods[ * puiMsgIdx ];
      }
      ++puiMsgIdx;
   }
   while( --uiBucket );

#else

   PMETHOD pMethod;
   USHORT uiBucket;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsFindMsg(%p,%p)", pClass, pMsg));

   pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->uiHashKey );
   uiBucket = BUCKETSIZE;

   do
   {
      if( pMethod->pMessage == pMsg )
         return pMethod;
      ++pMethod;
   }
   while( --uiBucket );
#endif

   return NULL;
}
classes.c559
STATIC PMETHODhb_clsAllocMsg( PCLASS pClass, PHB_DYNS pMsg )
static PMETHOD hb_clsAllocMsg( PCLASS pClass, PHB_DYNS pMsg )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_clsAllocMsg(%p,%p)", pClass, pMsg));

   do
   {

#ifdef HB_MSG_POOL

      USHORT uiBucket = BUCKETSIZE, * puiMsgIdx = pClass->puiMsgIdx +
                                    hb_clsBucketPos( pMsg, pClass->uiHashKey );

      do
      {
         if( * puiMsgIdx == 0 )
         {
            pClass->pMethods = ( PMETHOD ) hb_xrealloc( pClass->pMethods,
                           sizeof( METHOD ) * ( pClass->uiMethodCount + 1 ) );
            memset( &pClass->pMethods[ pClass->uiMethodCount ], 0, sizeof( METHOD ) );
            * puiMsgIdx = pClass->uiMethodCount++;
            return &pClass->pMethods[ * puiMsgIdx ];
         }
         else if( pClass->pMethods[ * puiMsgIdx ].pMessage == pMsg )
            return &pClass->pMethods[ * puiMsgIdx ];
         ++puiMsgIdx;
      }
      while( --uiBucket );

#else

      PMETHOD pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->uiHashKey );
      USHORT uiBucket = BUCKETSIZE;

      do
      {
         if( ! pMethod->pMessage || pMethod->pMessage == pMsg )
            return pMethod;
         ++pMethod;
      }
      while( --uiBucket );

#endif

   }
   while( hb_clsDictRealloc( pClass ) );

   return NULL;
}
classes.c602
STATIC BOOLhb_clsCanClearMethod( PMETHOD pMethod, BOOL fError )
static BOOL hb_clsCanClearMethod( PMETHOD pMethod, BOOL fError )
{
   HB_SYMBOL_UNUSED( pMethod );
   HB_SYMBOL_UNUSED( fError );
#if 0
   if( pMethod->pFuncSym == &s___msgSuper )
   {
      if( fError )
         hb_errRT_BASE( EG_ARG, 3000, "Cannot delete supercast messages", HB_ERR_FUNCNAME, 0 );
      return FALSE;
   }
#endif
   return TRUE;
}
classes.c651
STATIC VOIDhb_clsFreeMsg( PCLASS pClass, PHB_DYNS pMsg )
static void hb_clsFreeMsg( PCLASS pClass, PHB_DYNS pMsg )
{
#ifdef HB_MSG_POOL

   USHORT uiBucket, * puiMsgIdx;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsFreeMsg(%p,%p)", pClass, pMsg));


   puiMsgIdx = pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->uiHashKey );
   uiBucket = BUCKETSIZE;

   do
   {
      if( * puiMsgIdx && pClass->pMethods[ * puiMsgIdx ].pMessage == pMsg )
      {
         if( hb_clsCanClearMethod( &pClass->pMethods[ * puiMsgIdx ], TRUE ) )
         {
            memset( &pClass->pMethods[ * puiMsgIdx ], 0, sizeof( METHOD ) );
            * puiMsgIdx = 0;
            pClass->uiMethods--;       /* Decrease number of messages */
         }
         return;
      }
      ++puiMsgIdx;
   }
   while( --uiBucket );

#else

   PMETHOD pMethod;
   USHORT uiBucket;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsFreeMsg(%p,%p)", pClass, pMsg));

   pMethod = pClass->pMethods + hb_clsBucketPos( pMsg, pClass->uiHashKey );
   uiBucket = BUCKETSIZE;

   do
   {
      if( pMethod->pMessage == pMsg )
      {
         if( hb_clsCanClearMethod( pMethod, TRUE ) )
         {
            /* Move messages */
            while( --uiBucket )
            {
               memcpy( pMethod, pMethod + 1, sizeof( METHOD ) );
               pMethod++;
            }
            memset( pMethod, 0, sizeof( METHOD ) );
            pClass->uiMethods--;       /* Decrease number of messages */
         }
         return;
      }
      ++pMethod;
   }
   while( --uiBucket );

#endif
}
classes.c666
STATIC BOOLhb_clsHasParent( PCLASS pClass, PHB_DYNS pParentSym )
static BOOL hb_clsHasParent( PCLASS pClass, PHB_DYNS pParentSym )
{
   PMETHOD pMethod = hb_clsFindMsg( pClass, pParentSym );

   return pMethod && pMethod->pFuncSym == &s___msgSuper;
}
classes.c728
STATIC USHORThb_clsParentInstanceOffset( PCLASS pClass, PHB_DYNS pParentSym )
static USHORT hb_clsParentInstanceOffset( PCLASS pClass, PHB_DYNS pParentSym )
{
   PMETHOD pMethod = hb_clsFindMsg( pClass, pParentSym );

   return ( pMethod && pMethod->pFuncSym == &s___msgSuper ) ? pMethod->uiOffset : 0;
}
classes.c735
STATIC USHORThb_clsAddInitValue( PCLASS pClass, PHB_ITEM pItem, USHORT uiType, USHORT uiData, USHORT uiOffset, USHORT uiSprClass )
static USHORT hb_clsAddInitValue( PCLASS pClass, PHB_ITEM pItem,
                                  USHORT uiType, USHORT uiData,
                                  USHORT uiOffset, USHORT uiSprClass )
{
   PINITDATA pInitData;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsAddInitValue(%p,%p,%hu,%hu,%hu,%hu)", pClass, pItem, uiType, uiData, uiOffset, uiSprClass));

   if( ! pItem || HB_IS_NIL( pItem ) )
      return 0;

   if( ! pClass->uiInitDatas )
   {
      pClass->pInitData = ( PINITDATA ) hb_xgrab( sizeof( INITDATA ) );
      pInitData = pClass->pInitData + pClass->uiInitDatas++;
   }
   else
   {
      USHORT ui = pClass->uiInitDatas;
      pInitData = pClass->pInitData;
      do
      {
         if( pInitData->uiType == uiType &&
             pInitData->uiData + pInitData->uiOffset == uiData + uiOffset )
         {
            hb_itemRelease( pInitData->pInitValue );
            break;
         }
         ++pInitData;
      }
      while( --ui );

      if( ui == 0 )
      {
         pClass->pInitData = ( PINITDATA ) hb_xrealloc( pClass->pInitData,
                  ( ULONG ) ( pClass->uiInitDatas + 1 ) * sizeof( INITDATA ) );
         pInitData = pClass->pInitData + pClass->uiInitDatas++;
      }
   }

   pInitData->pInitValue = hb_itemClone( pItem );
   pInitData->uiType = uiType;
   pInitData->uiData = uiData;
   pInitData->uiOffset = uiOffset;
   pInitData->uiSprClass = uiSprClass;

   return pClass->uiInitDatas;
}
classes.c742
STATIC USHORThb_clsFindRealClassDataOffset( PMETHOD pMethod )
static USHORT hb_clsFindRealClassDataOffset( PMETHOD pMethod )
{
   PMETHOD pRealMth;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsFindRealClassDataOffset(%p)", pMethod));

   pRealMth = hb_clsFindMsg( s_pClasses[ pMethod->uiSprClass ],
                             pMethod->pMessage );
   if( pRealMth && pRealMth->uiSprClass == pMethod->uiSprClass &&
       ( pRealMth->pFuncSym == &s___msgSetClsData ||
         pRealMth->pFuncSym == &s___msgGetClsData ) )
   {
      return pRealMth->uiData;
   }
   return 0;
}
classes.c791
STATIC USHORThb_clsFindClassDataOffset( PCLASS pClass, PMETHOD pNewMethod )
static USHORT hb_clsFindClassDataOffset( PCLASS pClass, PMETHOD pNewMethod )
{
   USHORT uiData;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsFindClassDataOffset(%p,%p)", pClass, pNewMethod));

   uiData = hb_clsFindRealClassDataOffset( pNewMethod );
   if( uiData )
   {
      ULONG ulLimit = hb_clsMthNum( pClass );
      PMETHOD pMethod = pClass->pMethods;
      do
      {
         if( pMethod->pMessage && pMethod != pNewMethod &&
             pMethod->uiSprClass == pNewMethod->uiSprClass &&
             ( pMethod->pFuncSym == &s___msgSetClsData ||
               pMethod->pFuncSym == &s___msgGetClsData ) &&
             uiData == hb_clsFindRealClassDataOffset( pMethod ) )
         {
            return pMethod->uiData;
         }
         ++pMethod;
      }
      while( --ulLimit );
   }

   return 0;
}
classes.c808
STATIC BOOLhb_clsUpdateHiddenMessages( PMETHOD pSrcMethod, PMETHOD pDstMethod, PCLASS pDstClass )
static BOOL hb_clsUpdateHiddenMessages( PMETHOD pSrcMethod, PMETHOD pDstMethod,
                                        PCLASS pDstClass )
{
   PMETHOD pNewMethod = pSrcMethod;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsUpdateHiddenMessages(%p,%p,%p)", pSrcMethod, pDstMethod, pDstClass));

   if( ! pDstMethod->pMessage ||
       ( hb_clsCanClearMethod( pDstMethod, FALSE ) &&
         pDstMethod->uiPrevCls != pDstMethod->uiSprClass &&
         ( pDstMethod->uiScope & HB_OO_CLSTP_HIDDEN ) &&
         ( pDstMethod->uiScope & HB_OO_CLSTP_NONVIRTUAL ) ) )
   {
      while( pNewMethod &&
             pNewMethod->uiPrevCls != pNewMethod->uiSprClass &&
             ( pNewMethod->uiScope & HB_OO_CLSTP_HIDDEN ) &&
             ( pNewMethod->uiScope & HB_OO_CLSTP_NONVIRTUAL ) )
      {
         pNewMethod = hb_clsFindMsg( s_pClasses[ pNewMethod->uiPrevCls ],
                                     pNewMethod->pMessage );
      }
      if( pNewMethod && pNewMethod != pSrcMethod &&
          !( pNewMethod->uiScope & HB_OO_CLSTP_HIDDEN ) &&
          hb_clsCanClearMethod( pDstMethod, FALSE ) )
      {
         USHORT uiPrevCls = pDstMethod->uiPrevCls,
                uiPrevMth = pDstMethod->uiPrevMth;

         memcpy( pDstMethod, pNewMethod, sizeof( METHOD ) );
         pDstMethod->uiPrevCls = uiPrevCls;
         pDstMethod->uiPrevMth = uiPrevMth;
         pDstMethod->uiScope |= HB_OO_CLSTP_OVERLOADED | HB_OO_CLSTP_SUPER;
         if( pDstMethod->pFuncSym == &s___msgSetData ||
             pDstMethod->pFuncSym == &s___msgGetData )
         {
            pDstMethod->uiOffset = hb_clsParentInstanceOffset( pDstClass,
                           s_pClasses[ pDstMethod->uiSprClass ]->pClassSym );
         }
         else if( pDstMethod->pFuncSym == &s___msgSetClsData ||
                  pDstMethod->pFuncSym == &s___msgGetClsData )
         {
            PCLASS pSrcClass = s_pClasses[ pDstMethod->uiSprClass ];
            USHORT uiData;

            uiData = hb_clsFindClassDataOffset( pDstClass, pDstMethod );

            if( uiData == 0 )
            {
               uiData = ( USHORT ) hb_arrayLen( pDstClass->pClassDatas ) + 1;
               hb_arraySize( pDstClass->pClassDatas, uiData );
            }
            if( pDstMethod->uiOffset )
            {
               pDstMethod->uiOffset = hb_clsAddInitValue( pDstClass,
                  pSrcClass->pInitData[ pDstMethod->uiOffset - 1 ].pInitValue,
                  HB_OO_MSG_CLASSDATA, uiData, 0, pDstMethod->uiSprClass );
            }
            pDstMethod->uiData = uiData;
         }
         return TRUE;
      }
   }

   return FALSE;
}
classes.c837
STATIC VOIDhb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
{
   PMETHOD pMethod;
   ULONG ulLimit;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsCopyClass(%p,%p)", pClsDst, pClsSrc));

   hb_clsDictInit( pClsDst, pClsSrc->uiHashKey );
   pClsDst->fHasOnError = pClsSrc->fHasOnError;
   pClsDst->fHasDestructor = pClsSrc->fHasDestructor;

   /* CLASS DATA Not Shared ( new array, new value ) */
   pClsDst->pClassDatas  = hb_arrayClone( pClsSrc->pClassDatas );
   /* do not copy shared data array - just simply create new one */
   pClsDst->pSharedDatas = hb_itemArrayNew( 0 );
   pClsDst->pInlines = hb_arrayClone( pClsSrc->pInlines );
   pClsDst->uiDatas = pClsSrc->uiDatas;
   pClsDst->ulOpFlags = pClsSrc->ulOpFlags;

   if( pClsSrc->uiInitDatas )
   {
      ULONG ulSize = ( ULONG ) pClsSrc->uiInitDatas * sizeof( INITDATA );
      USHORT uiData;

      pClsDst->uiInitDatas = pClsSrc->uiInitDatas;
      pClsDst->pInitData = ( PINITDATA ) hb_xgrab( ulSize );
      memcpy( pClsDst->pInitData, pClsSrc->pInitData, ulSize );
      for( uiData = 0; uiData < pClsDst->uiInitDatas; ++uiData )
      {
         if( pClsDst->pInitData[ uiData ].uiType == HB_OO_MSG_INITIALIZED )
            pClsDst->pInitData[ uiData ].uiType = HB_OO_MSG_CLASSDATA;
         pClsDst->pInitData[ uiData ].pInitValue =
                        hb_itemNew( pClsDst->pInitData[ uiData ].pInitValue );
      }
   }

   ulLimit = hb_clsMthNum( pClsSrc );
#ifdef HB_MSG_POOL
   memcpy( pClsDst->puiMsgIdx, pClsSrc->puiMsgIdx,
      ( ( ( ULONG ) pClsSrc->uiHashKey + 1 ) << BUCKETBITS ) * sizeof( USHORT ) );
   pClsDst->uiMethodCount = pClsSrc->uiMethodCount;
   pClsDst->pMethods = ( PMETHOD ) hb_xrealloc( pClsDst->pMethods,
                                                ulLimit * sizeof( METHOD ) );
#endif
   memcpy( pClsDst->pMethods, pClsSrc->pMethods, ulLimit * sizeof( METHOD ) );
   pClsDst->uiMethods = pClsSrc->uiMethods;

   pMethod = pClsDst->pMethods;
   do
   {
      if( pMethod->pMessage )
      {
         hb_clsUpdateHiddenMessages( pMethod, pMethod, pClsDst );
         pMethod->uiScope |= HB_OO_CLSTP_SUPER;
      }
      ++pMethod;
   }
   while( --ulLimit );
}
classes.c903
STATIC BOOLhb_clsIsFriendSymbol( PCLASS pClass, PHB_SYMB pSym )
static BOOL hb_clsIsFriendSymbol( PCLASS pClass, PHB_SYMB pSym )
{
   USHORT uiCount;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsIsFriendSymbol(%p,%p)", pClass, pSym));

   if( pSym >= pClass->pFriendModule &&
       pSym < pClass->pFriendModule + pClass->uiFriendModule )
      return TRUE;

   for( uiCount = 0; uiCount < pClass->uiFriendSyms; ++uiCount )
   {
      if( pClass->pFriendSyms[ uiCount ] == pSym )
         return TRUE;
   }

   return FALSE;
}
classes.c963
STATIC VOIDhb_clsAddFriendSymbol( PCLASS pClass, PHB_SYMB pSym )
static void hb_clsAddFriendSymbol( PCLASS pClass, PHB_SYMB pSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_clsAddFriendSymbol(%p,%p)", pClass, pSym));

   if( ! hb_clsIsFriendSymbol( pClass, pSym ) )
   {
      if( pClass->uiFriendSyms == 0 )
      {
         pClass->pFriendSyms = ( PHB_SYMB * ) hb_xgrab( sizeof( PHB_SYMB ) );
         pClass->pFriendSyms[ 0 ] = pSym;
         pClass->uiFriendSyms++;
      }
      else 
      {
         pClass->pFriendSyms = ( PHB_SYMB * ) hb_xrealloc( pClass->pFriendSyms,
                           ( pClass->uiFriendSyms + 1 ) * sizeof( PHB_SYMB ) );
         pClass->pFriendSyms[ pClass->uiFriendSyms++ ] = pSym;
      }
   }
}
classes.c982
VOIDhb_clsInit( void )
void hb_clsInit( void )
{
   PHB_SYMB pOpSym;
   USHORT uiOperator;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsInit()"));

   for( uiOperator = 0, pOpSym = s_opSymbols; uiOperator <= HB_OO_MAX_OPERATOR;
        ++uiOperator, ++pOpSym )
   {
      pOpSym->pDynSym = hb_dynsymGetCase( pOpSym->szName );
   }

   s___msgDestructor.pDynSym  = hb_dynsymGetCase( s___msgDestructor.szName );
   s___msgOnError.pDynSym     = hb_dynsymGetCase( s___msgOnError.szName );

   s___msgClassName.pDynSym   = hb_dynsymGetCase( s___msgClassName.szName );  /* Standard messages */
   s___msgClassH.pDynSym      = hb_dynsymGetCase( s___msgClassH.szName );     /* Not present in classdef. */
   s___msgClassSel.pDynSym    = hb_dynsymGetCase( s___msgClassSel.szName );
   s___msgExec.pDynSym        = hb_dynsymGetCase( s___msgExec.szName );
   s___msgName.pDynSym        = hb_dynsymGetCase( s___msgName.szName );
   s___msgNew.pDynSym         = hb_dynsymGetCase( s___msgNew.szName );
   s___msgSymbol.pDynSym      = hb_dynsymGetCase( s___msgSymbol.szName );
   s___msgKeys.pDynSym        = hb_dynsymGetCase( s___msgKeys.szName );
   s___msgValues.pDynSym      = hb_dynsymGetCase( s___msgValues.szName );
/*
   s___msgClsParent.pDynSym   = hb_dynsymGetCase( s___msgClsParent.szName );
   s___msgClass.pDynSym       = hb_dynsymGetCase( s___msgClass.szName );
*/
   s___msgEnumIndex.pDynSym   = hb_dynsymGetCase( s___msgEnumIndex.szName );
   s___msgEnumBase.pDynSym    = hb_dynsymGetCase( s___msgEnumBase.szName );
   s___msgEnumKey.pDynSym     = hb_dynsymGetCase( s___msgEnumKey.szName );
   s___msgEnumValue.pDynSym   = hb_dynsymGetCase( s___msgEnumValue.szName );

   s___msgWithObjectPush.pDynSym = hb_dynsymGetCase( s___msgWithObjectPush.szName );
   s___msgWithObjectPop.pDynSym  = hb_dynsymGetCase( s___msgWithObjectPop.szName );


   s_uiClsSize = HB_CLASS_POOL_SIZE;
   s_uiClasses = 0;
   s_pClasses = ( PCLASS * ) hb_xgrab( sizeof( PCLASS ) * ( ( ULONG ) s_uiClsSize + 1 ) );
   s_pClasses[ 0 ] = NULL;
}
classes.c1003
VOIDhb_clsDoInit( void )
void hb_clsDoInit( void )
{
   static const char * s_pszFuncNames[] = 
      { "HBARRAY", "HBBLOCK", "HBCHARACTER", "HBDATE",
        "HBHASH", "HBLOGICAL", "HBNIL", "HBNUMERIC",
        "HBSYMBOL", "HBPOINTER" };
   static USHORT * s_puiHandles[] =
      { &s_uiArrayClass, &s_uiBlockClass, &s_uiCharacterClass, &s_uiDateClass,
        &s_uiHashClass, &s_uiLogicalClass, &s_uiNilClass, &s_uiNumericClass,
        &s_uiSymbolClass, &s_uiPointerClass };
   int i;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsDoInit()"));

   for( i = 0; i < ( int ) ( sizeof( s_puiHandles ) / sizeof( USHORT * ) ); ++i )
   {
      PHB_DYNS pFuncSym = hb_dynsymFindName( s_pszFuncNames[i] );
      if( pFuncSym && hb_dynsymIsFunction( pFuncSym ) )
      {
         PHB_ITEM pObject;
         hb_vmPushDynSym( pFuncSym );
         hb_vmPushNil();
         hb_vmDo( 0 );
         pObject = hb_stackReturnItem();
         if( HB_IS_OBJECT( pObject ) )
            *( s_puiHandles[i] ) = pObject->item.asArray.value->uiClass;
      }
   }
}
classes.c1050
STATIC VOIDhb_clsRelease( PCLASS pClass )
static void hb_clsRelease( PCLASS pClass )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_clsRelease(%p)", pClass));

   if( pClass->uiInitDatas )
   {
      USHORT ui = pClass->uiInitDatas;
      PINITDATA pInitData = pClass->pInitData;

      do
      {
         hb_itemRelease( pInitData->pInitValue );
         ++pInitData;
      }
      while( --ui );
      hb_xfree( pClass->pInitData );
   }

   if( pClass->szName )
      hb_xfree( pClass->szName );
   if( pClass->pMethods )
      hb_xfree( pClass->pMethods );
   if( pClass->uiFriendSyms )
      hb_xfree( pClass->pFriendSyms );
#ifdef HB_MSG_POOL
   if( pClass->puiMsgIdx )
      hb_xfree( pClass->puiMsgIdx );
#endif
   if( pClass->pClassDatas )
      hb_itemRelease( pClass->pClassDatas );
   if( pClass->pSharedDatas )
      hb_itemRelease( pClass->pSharedDatas );
   if( pClass->pInlines )
      hb_itemRelease( pClass->pInlines );

   hb_xfree( pClass );
}
classes.c1083
VOIDhb_clsReleaseAll( void )
void hb_clsReleaseAll( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_clsReleaseAll()"));

   if( s_uiClasses )
   {
      USHORT uiClass = s_uiClasses;

      /* It blocks destructor execution - don't move. [druzus] */
      s_uiClasses = 0;

      do
      {
         hb_clsRelease( s_pClasses[ uiClass ] );
      }
      while( --uiClass );

   }

   if( s_pClasses )
   {
      hb_xfree( s_pClasses );
      s_pClasses = NULL;
      s_uiClsSize = 0;
   }
}
classes.c1127
VOIDhb_clsIsClassRef( void )
void hb_clsIsClassRef( void )
{
   /*
    * All internal items are allocated with hb_itemNew()
    * GC knows them and scan itself so it's not necessary
    * to repeat scanning here [druzus].
    */
#if 0
   USHORT uiClass = s_uiClasses;

   HB_TRACE(HB_TR_DEBUG, ("hb_clsIsClassRef()"));

   while( uiClass )
   {
      PCLASS pClass = s_pClasses[ uiClass-- ];

      if( pClass->pInlines )
         hb_gcItemRef( pClass->pInlines );

      if( pClass->pClassDatas )
         hb_gcItemRef( pClass->pClassDatas );

      if( pClass->pSharedDatas )
         hb_gcItemRef( pClass->pSharedDatas );

      if( pClass->uiInitDatas )
      {
         USHORT ui = pClass->uiInitDatas;
         PINITDATA pInitData = pClass->pInitData;

         do
         {
            if( HB_IS_GCITEM( pInitData->pInitValue ) )
               hb_gcItemRef( pInitData->pInitValue );
            ++pInitData;
         }
         while( --ui );
      }
   }
#endif
}
classes.c1163
HB_EXPORT BOOLhb_clsIsParent( USHORT uiClass, const char * szParentName )
HB_EXPORT BOOL hb_clsIsParent( USHORT uiClass, const char * szParentName )
{
   if( uiClass && uiClass <= s_uiClasses )
   {
      PCLASS pClass = s_pClasses[ uiClass ];

      if( strcmp( pClass->szName, szParentName ) == 0 )
         return TRUE;
      else
      {
         PHB_DYNS pMsg = hb_dynsymFindName( szParentName );

         if( pMsg )
            return hb_clsHasParent( s_pClasses[ uiClass ], pMsg );
      }
   }

   return FALSE;
}
classes.c1205
HB_EXPORT USHORThb_objGetClass( PHB_ITEM pItem )
HB_EXPORT USHORT hb_objGetClass( PHB_ITEM pItem )
{
   if( pItem && HB_IS_ARRAY( pItem ) )
      return pItem->item.asArray.value->uiClass;
   else
      return 0;
}
classes.c1225
HB_EXPORT USHORThb_objSetClass( PHB_ITEM pItem, const char * szClass, const char * szFunc )
HB_EXPORT USHORT hb_objSetClass( PHB_ITEM pItem, const char * szClass, const char * szFunc )
{
   USHORT uiClass = 0;

   if( pItem && HB_IS_ARRAY( pItem ) &&
       pItem->item.asArray.value->uiClass == 0 )
   {
      uiClass = pItem->item.asArray.value->uiClass =
                                          hb_clsFindClass( szClass, szFunc );
   }
   return uiClass;
}
classes.c1233
STATIC USHORThb_objGetClassH( PHB_ITEM pObject )
static USHORT hb_objGetClassH( PHB_ITEM pObject )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_objGetClassH(%p)", pObject));

   if( HB_IS_ARRAY( pObject ) )
   {
      if( pObject->item.asArray.value->uiClass != 0 )
         return pObject->item.asArray.value->uiClass;
      else
         return s_uiArrayClass;
   }
   /* built in types */
   else if( HB_IS_NIL( pObject ) )
      return s_uiNilClass;

   else if( HB_IS_STRING( pObject ) )
      return s_uiCharacterClass;

   else if( HB_IS_NUMERIC( pObject ) )
      return s_uiNumericClass;

   else if( HB_IS_DATE( pObject ) )
      return s_uiDateClass;

   else if( HB_IS_LOGICAL( pObject ) )
      return s_uiLogicalClass;

   else if( HB_IS_BLOCK( pObject ) )
      return s_uiBlockClass;

   else if( HB_IS_HASH( pObject ) )
      return s_uiHashClass;

   else if( HB_IS_POINTER( pObject ) )
      return s_uiPointerClass;

   else if( HB_IS_SYMBOL( pObject ) )
      return s_uiSymbolClass;

   return 0;
}
classes.c1249
HB_EXPORT CONST CHAR *hb_objGetClsName( PHB_ITEM pObject )
HB_EXPORT const char * hb_objGetClsName( PHB_ITEM pObject )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_objGetClsName(%p)", pObject));

   if( HB_IS_ARRAY( pObject ) )
   {
      if( pObject->item.asArray.value->uiClass != 0 )
         return s_pClasses[ pObject->item.asArray.value->uiClass ]->szName;
      else
         return "ARRAY";
   }
   /* built in types */
   else if( HB_IS_NIL( pObject ) )
      return "NIL";

   else if( HB_IS_STRING( pObject ) )
      return "CHARACTER";

   else if( HB_IS_NUMERIC( pObject ) )
      return "NUMERIC";

   else if( HB_IS_DATE( pObject ) )
      return "DATE";

   else if( HB_IS_LOGICAL( pObject ) )
      return "LOGICAL";

   else if( HB_IS_BLOCK( pObject ) )
      return "BLOCK";

   else if( HB_IS_HASH( pObject ) )
      return "HASH";

   else if( HB_IS_POINTER( pObject ) )
      return "POINTER";

   else if( HB_IS_SYMBOL( pObject ) )
      return "SYMBOL";

   else 
      return "UNKNOWN";
}
classes.c1294
HB_EXPORT CONST CHAR *hb_clsName( USHORT uiClass )
HB_EXPORT const char * hb_clsName( USHORT uiClass )
{
   if( uiClass && uiClass <= s_uiClasses )
      return s_pClasses[ uiClass ]->szName;
   else
      return NULL;
}
classes.c1340
HB_EXPORT CONST CHAR *hb_clsFuncName( USHORT uiClass )
HB_EXPORT const char * hb_clsFuncName( USHORT uiClass )
{
   if( uiClass && uiClass <= s_uiClasses )
      return s_pClasses[ uiClass ]->pClassFuncSym ?
             s_pClasses[ uiClass ]->pClassFuncSym->szName :
             "";
   else
      return NULL;
}
classes.c1348
HB_EXPORT USHORThb_clsFindClass( const char * szClass, const char * szFunc )
HB_EXPORT USHORT hb_clsFindClass( const char * szClass, const char * szFunc )
{
   USHORT uiClass;

   for( uiClass = 1; uiClass <= s_uiClasses; uiClass++ )
   {
      if( strcmp( szClass, s_pClasses[ uiClass ]->szName ) == 0 &&
          ( !szFunc || ( !s_pClasses[ uiClass ]->pClassFuncSym ? !*szFunc :
            strcmp( szFunc, s_pClasses[ uiClass ]->pClassFuncSym->szName ) == 0 ) ) )
      {
         return uiClass;
      }
   }
   return 0;
}
classes.c1358
STATIC USHORThb_clsFindClassByFunc( PHB_SYMB pClassFuncSym )
static USHORT hb_clsFindClassByFunc( PHB_SYMB pClassFuncSym )
{
   USHORT uiClass;

   for( uiClass = 1; uiClass <= s_uiClasses; uiClass++ )
   {
      if( s_pClasses[ uiClass ]->pClassFuncSym == pClassFuncSym )
      {
         return uiClass;
      }
   }
   return 0;
}
classes.c1374
HB_EXPORT CONST CHAR *hb_objGetRealClsName( PHB_ITEM pObject, const char * szName )
HB_EXPORT const char * hb_objGetRealClsName( PHB_ITEM pObject, const char * szName )
{
   USHORT uiClass;

   HB_TRACE(HB_TR_DEBUG, ("hb_objGetrealClsName(%p,%s)", pObject, szName));

   uiClass = hb_objGetClassH( pObject );
   if( uiClass && uiClass <= uiClass )
   {
      PHB_DYNS pMsg = hb_dynsymFindName( szName );

      if( pMsg )
      {
         PMETHOD pMethod = hb_clsFindMsg( s_pClasses[ uiClass ], pMsg );
         if( pMethod )
            uiClass = pMethod->uiSprClass;
      }
      if( uiClass && uiClass <= s_uiClasses )
         return s_pClasses[ uiClass ]->szName;
   }

   return hb_objGetClsName( pObject );
}
classes.c1388
STATIC LONGhb_clsSenderOffset( void )
static LONG hb_clsSenderOffset( void )
{
   LONG lOffset = hb_stackBaseProcOffset( 1 );

   if( lOffset > 0 )
   {
      /* Is it inline method? */
      if( lOffset > 0 && HB_IS_BLOCK( hb_stackItem( lOffset + 1 ) ) &&
          ( hb_stackItem( lOffset )->item.asSymbol.value == &hb_symEval ||
            hb_stackItem( lOffset )->item.asSymbol.value->pDynSym ==
            hb_symEval.pDynSym ) )
      {
         lOffset = hb_stackItem( lOffset )->item.asSymbol.stackstate->lBaseItem;

         /* I do not like it but Class(y) makes sth like that. [druzus] */
         while( lOffset > 0 &&
                hb_stackItem( lOffset )->item.asSymbol.stackstate->uiClass == 0 )
            lOffset = hb_stackItem( lOffset )->item.asSymbol.stackstate->lBaseItem;
      }
      return lOffset;
   }
   return -1;
}
classes.c1418
STATIC USHORThb_clsSenderClasss( void )
static USHORT hb_clsSenderClasss( void )
{
   LONG lOffset = hb_clsSenderOffset();

   if( lOffset > 0 )
      return hb_stackItem( lOffset )->item.asSymbol.stackstate->uiClass;
   else
      return 0;
}
classes.c1444
STATIC USHORThb_clsSenderMethodClasss( void )
static USHORT hb_clsSenderMethodClasss( void )
{
   LONG lOffset = hb_clsSenderOffset();

   if( lOffset > 0 )
   {
      PHB_STACK_STATE pStack = hb_stackItem( lOffset )->item.asSymbol.stackstate;

      if( pStack->uiClass )
         return ( s_pClasses[ pStack->uiClass ]->pMethods +
                  pStack->uiMethod )->uiSprClass;
   }
   return 0;
}
classes.c1455
STATIC PHB_SYMBhb_clsSenderSymbol( void )
static PHB_SYMB hb_clsSenderSymbol( void )
{
   PHB_SYMB pSym = NULL;
   LONG lOffset = hb_clsSenderOffset();

   if( lOffset > 0 )
   {
      pSym = hb_stackItem( lOffset )->item.asSymbol.value;

      if( pSym == &hb_symEval || pSym->pDynSym == hb_symEval.pDynSym )
      {
         PHB_ITEM pBlock = hb_stackItem( lOffset + 1 );

         if( HB_IS_BLOCK( pBlock ) )
            pSym = pBlock->item.asBlock.value->pDefSymb;
      }
   }

   return hb_vmGetRealFuncSym( pSym );
}
classes.c1470
STATIC USHORThb_clsSenderObjectClasss( void )
static USHORT hb_clsSenderObjectClasss( void )
{
   LONG lOffset = hb_clsSenderOffset();

   if( lOffset > 0 )
   {
      PHB_ITEM pSender = hb_stackItem( lOffset + 1 );

      if( HB_IS_ARRAY( pSender ) )
         return pSender->item.asArray.value->uiClass;
   }
   return 0;
}
classes.c1491
STATIC PHB_SYMBhb_clsValidScope( PMETHOD pMethod, PHB_STACK_STATE pStack )
static PHB_SYMB hb_clsValidScope( PMETHOD pMethod, PHB_STACK_STATE pStack )
{
   if( pMethod->uiScope & ( HB_OO_CLSTP_HIDDEN | HB_OO_CLSTP_PROTECTED |
                            HB_OO_CLSTP_OVERLOADED ) )
   {
      USHORT uiSenderClass = hb_clsSenderMethodClasss();

      if( uiSenderClass )
      {
         if( uiSenderClass == pMethod->uiSprClass )
            return pMethod->pFuncSym;

         /*
          * Warning!!! Friends cannot access overloaded non virtual methods.
          * This feature is available _ONLY_ for real class members, [druzus]
          */
         if( pMethod->uiScope & HB_OO_CLSTP_OVERLOADED )
         {
            PCLASS pClass = s_pClasses[ uiSenderClass ];
            PMETHOD pHiddenMthd = hb_clsFindMsg( pClass, pMethod->pMessage );

            if( pHiddenMthd && ( pHiddenMthd->uiScope & HB_OO_CLSTP_NONVIRTUAL ) &&
                pHiddenMthd->uiSprClass == uiSenderClass )
            {
               pStack->uiClass = uiSenderClass;
               pStack->uiMethod = ( USHORT ) ( pHiddenMthd - pClass->pMethods );
               return pHiddenMthd->pFuncSym;
            }
         }

         if( pMethod->uiScope & HB_OO_CLSTP_HIDDEN )
         {
            if( ! hb_clsIsFriendSymbol( s_pClasses[ pMethod->uiSprClass ],
                              s_pClasses[ uiSenderClass ]->pClassFuncSym ) )
               return &s___msgScopeErr;
         }
         else if( pMethod->uiScope & HB_OO_CLSTP_PROTECTED &&
             ! hb_clsHasParent( s_pClasses[ pStack->uiClass ],
                                s_pClasses[ uiSenderClass ]->pClassSym ) &&
             ! hb_clsHasParent( s_pClasses[ uiSenderClass ],
                                s_pClasses[ pStack->uiClass ]->pClassSym ) &&
             ! hb_clsIsFriendSymbol( s_pClasses[ pMethod->uiSprClass ],
                                     s_pClasses[ uiSenderClass ]->pClassFuncSym ) &&
             ( pStack->uiClass == pMethod->uiSprClass ||
               ! hb_clsIsFriendSymbol( s_pClasses[ pStack->uiClass ],
                              s_pClasses[ uiSenderClass ]->pClassFuncSym ) ) )
            return &s___msgScopeErr;
      }
      else if( pMethod->uiScope & ( HB_OO_CLSTP_HIDDEN | HB_OO_CLSTP_PROTECTED ) )
      {
         PHB_SYMB pSym = hb_clsSenderSymbol();

         if( ! hb_clsIsFriendSymbol( s_pClasses[ pMethod->uiSprClass ], pSym ) )
         {
            if( ( pMethod->uiScope & HB_OO_CLSTP_HIDDEN ) ||
                ! hb_clsIsFriendSymbol( s_pClasses[ pStack->uiClass ], pSym ) )
               return &s___msgScopeErr;
         }
      }
   }

   return pMethod->pFuncSym;
}
classes.c1505
STATIC PHB_SYMBhb_clsScalarMethod( PCLASS pClass, PHB_DYNS pMsg, PHB_STACK_STATE pStack )
static PHB_SYMB hb_clsScalarMethod( PCLASS pClass, PHB_DYNS pMsg,
                                    PHB_STACK_STATE pStack )
{
   PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg );

   if( pStack )
   {
      pStack->uiClass = pClass->uiClass;
      if( pMethod )
      {
         pStack->uiMethod = ( USHORT ) ( pMethod - pClass->pMethods );
         return hb_clsValidScope( pMethod, pStack );
      }
   }
   else if( pMethod )
      return pMethod->pFuncSym;

   return NULL;
}
classes.c1569
STATIC VOIDhb_clsMakeSuperObject( PHB_ITEM pDest, PHB_ITEM pObject, USHORT uiSuperClass )
static void hb_clsMakeSuperObject( PHB_ITEM pDest, PHB_ITEM pObject,
                                   USHORT uiSuperClass )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_clsMakeSuperObject(%p, %p, %hu)", pDest, pObject, uiSuperClass));

   /* create a fake object array */
   hb_arrayNew( pDest, 1 );
   /* Now save the Self object as the 1st elem. */
   hb_arraySet( pDest, 1, pObject );
   /* And transform it into a fake object */
   /* backup of actual handel */
   pDest->item.asArray.value->uiPrevCls = hb_objGetClassH( pObject );
   /* superclass handel casting */
   pDest->item.asArray.value->uiClass = uiSuperClass;
}
classes.c1589
PHB_SYMBhb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage, PHB_STACK_STATE pStack )
PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage,
                          PHB_STACK_STATE pStack )
{
   PCLASS pClass = NULL;
   PHB_DYNS pMsg;

   HB_TRACE(HB_TR_DEBUG, ("hb_objGetMethod(%p, %p, %p)", pObject, pMessage, pStack));

   pMsg = pMessage->pDynSym;

   if( HB_IS_ARRAY( pObject ) )
   {
      if( pObject->item.asArray.value->uiClass )
      {
         pClass = s_pClasses[ pObject->item.asArray.value->uiClass ];
         if( pStack )
         {
            pStack->uiClass = pObject->item.asArray.value->uiClass;
            if( pObject->item.asArray.value->uiPrevCls )
            {
               if( pObject->item.asArray.value->ulLen )
               {
                  /*
                   * Copy real object - do not move! the same super casted
                   * object can be used more then once and we mustn't
                   * destroy it. We can safely use hb_stackReturnItem() here.
                   */
                  hb_itemCopy( hb_stackReturnItem(), pObject->item.asArray.value->pItems );
                  /* move real object back to the stack */
                  hb_itemMove( pObject, hb_stackReturnItem() );
               }
               else
                  /* Someone tried to manipulate with supercast array */
                  hb_itemClear( pObject );
            }
#ifdef HB_MSG_POOL
            {
               USHORT uiBucket = BUCKETSIZE, * puiMsgIdx =
                  pClass->puiMsgIdx + hb_clsBucketPos( pMsg, pClass->uiHashKey );

               do
               {
                  PMETHOD pMethod = &pClass->pMethods[ * puiMsgIdx ];
                  if( pMethod->pMessage == pMsg )
                  {
                     pStack->uiMethod = * puiMsgIdx;
                     return hb_clsValidScope( pMethod, pStack );
                  }
                  ++puiMsgIdx;
               }
               while( --uiBucket );
            }
#else
            {
               PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg );
               if( pMethod )
               {
                  pStack->uiMethod = ( USHORT ) ( pMethod - pClass->pMethods );
                  return hb_clsValidScope( pMethod, pStack );
               }
            }
#endif
         }
         else
         {
            PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg );
            if( pMethod )
               return pMethod->pFuncSym;
         }
      }
      else if( s_uiArrayClass )
      {
         pClass = s_pClasses[ s_uiArrayClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_BLOCK( pObject ) )
   {
      if( pMsg == hb_symEval.pDynSym )
         return &hb_symEval;
      else if( s_uiBlockClass )
      {
         pClass = s_pClasses[ s_uiBlockClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_BYREF( pObject ) )
   {
      if( pStack )
      {
         /* method of enumerator variable from FOR EACH statement
          */
         PHB_ITEM pEnum = hb_itemUnRefOnce( pObject );

         if( HB_IS_ENUM( pEnum ) )
         {
            /*
             * Do actions here - we already have unreferenced pEnum so
             * it will be a little bit faster but in the future it's
             * possible that I'll move it to separate function when
             * I'll add enumerators overloading. [druzus]
             */
            if( pMsg == s___msgEnumIndex.pDynSym )
            {
               hb_itemPutNL( hb_stackReturnItem(), pEnum->item.asEnum.offset );
               if( hb_pcount() > 0 && ISNUM( 1 ) )
                  pEnum->item.asEnum.offset = hb_itemGetNL( hb_param( 1, HB_IT_ANY ) );
               return &s___msgEnumIndex;
            }
            else if( pMsg == s___msgEnumKey.pDynSym )
            {
               PHB_ITEM pBase = HB_IS_BYREF( pEnum->item.asEnum.basePtr ) ?
                                hb_itemUnRef( pEnum->item.asEnum.basePtr ) :
                                pEnum->item.asEnum.basePtr;
               if( HB_IS_HASH( pBase ) )
               {
                  pBase = hb_hashGetKeyAt( pBase, pEnum->item.asEnum.offset );
                  if( pBase )
                     hb_itemCopy( hb_stackReturnItem(), pBase );
               }
               return &s___msgEnumKey;
            }
            else if( pMsg == s___msgEnumBase.pDynSym )
            {
               if( HB_IS_BYREF( pEnum->item.asEnum.basePtr ) )
                  hb_itemCopy( hb_stackReturnItem(),
                               hb_itemUnRef( pEnum->item.asEnum.basePtr ) );
               else
                  hb_itemCopy( hb_stackReturnItem(),
                               pEnum->item.asEnum.basePtr );
               if( hb_pcount() > 0 )
                  hb_itemCopy( pEnum->item.asEnum.basePtr,
                               hb_itemUnRef( hb_stackItemFromBase( 1 ) ) );
               return &s___msgEnumBase;
            }
            else if( pMsg == s___msgEnumValue.pDynSym )
            {
               pEnum = hb_itemUnRef( pEnum );
               hb_itemCopy( hb_stackReturnItem(), pEnum );
               if( hb_pcount() > 0 )
                  hb_itemCopy( pEnum, hb_itemUnRef( hb_stackItemFromBase( 1 ) ) );
               return &s___msgEnumValue;
            }
         }
      }
   }
   else if( HB_IS_SYMBOL( pObject ) )
   {
      if( s_uiSymbolClass )
      {
         pClass = s_pClasses[ s_uiSymbolClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
      if( pMsg == s___msgExec.pDynSym || pMsg == hb_symEval.pDynSym )
      {
         if( ! pObject->item.asSymbol.value->value.pFunPtr &&
               pObject->item.asSymbol.value->pDynSym )
            return pObject->item.asSymbol.value->pDynSym->pSymbol;
         else
            return pObject->item.asSymbol.value;
      }
      else if( pMsg == s___msgName.pDynSym )
      {
         hb_itemPutC( hb_stackReturnItem(),
                      pObject->item.asSymbol.value->szName );
         return &s___msgName;
      }
   }
   else if( HB_IS_HASH( pObject ) )
   {
      if( s_uiHashClass )
      {
         pClass = s_pClasses[ s_uiHashClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }

      if( pMsg == s___msgKeys.pDynSym )
      {
         hb_itemReturnRelease( hb_hashGetKeys( pObject ) );
         return &s___msgKeys;
      }
      else if( pMsg == s___msgValues.pDynSym )
      {
         hb_itemReturnRelease( hb_hashGetValues( pObject ) );
         return &s___msgValues;
      }
#if defined( HB_HASH_MSG_ITEMS )
      else
      {
         if( hb_pcount() == 1 && pMessage->szName[ 0 ] == '_' )
         {  /* ASSIGN */
            PHB_ITEM pIndex = hb_itemPutCConst( hb_stackAllocItem(), pMessage->szName + 1 );
            PHB_ITEM pDest = hb_hashGetItemPtr( pObject, pIndex, HB_HASH_AUTOADD_ASSIGN );
            hb_stackPop();
            if( pDest )
            {
               PHB_ITEM pValue = hb_param( 1, HB_IT_ANY );
               hb_itemCopyFromRef( pDest, pValue );
               hb_itemReturn( pValue );
               return &s___msgVirtual;
            }
         }
         else if( hb_pcount() == 0 )
         {  /* ACCESS */
            PHB_ITEM pIndex = hb_itemPutCConst( hb_stackAllocItem(), pMessage->szName );
            PHB_ITEM pValue = hb_hashGetItemPtr( pObject, pIndex, HB_HASH_AUTOADD_ACCESS );
            hb_stackPop();
            if( pValue )
            {
               hb_itemReturn( pValue );
               return &s___msgVirtual;
            }
         }
      }
#endif
   }
   else if( HB_IS_STRING( pObject ) )
   {
      if( s_uiCharacterClass )
      {
         pClass = s_pClasses[ s_uiCharacterClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_DATE( pObject ) )
   {
      if( s_uiDateClass )
      {
         pClass = s_pClasses[ s_uiDateClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_NUMERIC( pObject ) )
   {
      if( s_uiNumericClass )
      {
         pClass = s_pClasses[ s_uiNumericClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_LOGICAL( pObject ) )
   {
      if( s_uiLogicalClass )
      {
         pClass = s_pClasses[ s_uiLogicalClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_POINTER( pObject ) )
   {
      if( s_uiPointerClass )
      {
         pClass = s_pClasses[ s_uiPointerClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }
   else if( HB_IS_NIL( pObject ) )
   {
      if( s_uiNilClass )
      {
         pClass = s_pClasses[ s_uiNilClass ];
         {
            PHB_SYMB pExecSym = hb_clsScalarMethod( pClass, pMsg, pStack );
            if( pExecSym )
               return pExecSym;
         }
      }
   }

   /* Default messages here */
   if( pMsg == s___msgWithObjectPush.pDynSym )
   {
      if( pStack )
      {
         PHB_ITEM pItem = hb_stackWithObjectItem();
         if( pItem )
         {
            /* push current WITH OBJECT object */
            hb_itemCopy( hb_stackReturnItem(), pItem );
            return &s___msgWithObjectPush;
         }
      }
   }
   else if( pMsg == s___msgWithObjectPop.pDynSym )
   {
      if( pStack )
      {
         PHB_ITEM pItem = hb_stackWithObjectItem();
         if( pItem )
         {
            /* replace current WITH OBJECT object */
            hb_itemCopy( pItem, hb_stackItemFromBase( 1 ) );
            hb_itemCopy( hb_stackReturnItem(), pItem );
            return &s___msgWithObjectPop;
         }
      }
   }

   else if( pMsg == s___msgClassName.pDynSym )
      return &s___msgClassName;

   else if( pMsg == s___msgClassH.pDynSym )
      return &s___msgClassH;

   else if( pMsg == s___msgClassSel.pDynSym )
      return &s___msgClassSel;

/*
   else if( pMsg == s___msgClsParent.pDynSym )
      return &s___msgClsParent;

   else if( pMsg == s___msgClass.pDynSym )
      return &s___msgClass;
*/
   if( pStack )
   {
      if( pClass && pClass->fHasOnError )
      {
         PMETHOD pMethod = hb_clsFindMsg( pClass, s___msgOnError.pDynSym );
         if( pMethod )
         {
            pStack->uiMethod = ( USHORT ) ( pMethod - pClass->pMethods );
            return pMethod->pFuncSym;
         }
      }

      /* remove this line if you want default HVM error message */
      return &s___msgNoMethod;
   }
   return NULL;
}
classes.c1605
BOOLhb_objGetVarRef( PHB_ITEM pObject, PHB_SYMB pMessage, PHB_STACK_STATE pStack )
BOOL hb_objGetVarRef( PHB_ITEM pObject, PHB_SYMB pMessage,
                      PHB_STACK_STATE pStack )
{
   PHB_SYMB pExecSym;

#if defined( HB_HASH_MSG_ITEMS )
   if( HB_IS_HASH( pObject ) )
   {
      PHB_ITEM pIndex = hb_itemPutCConst( hb_stackAllocItem(), pMessage->szName + 1 );
      PHB_ITEM pValue = hb_hashGetItemRefPtr( pObject, pIndex );
      hb_stackPop();
      if( pValue )
         hb_itemReturn( pValue );
      return pValue != NULL;
   }
#endif

   pExecSym = hb_objGetMethod( pObject, pMessage, pStack );
   if( pExecSym )
   {
      if( pExecSym->value.pFunPtr == hb___msgSetData )
      {
         USHORT uiObjClass = pObject->item.asArray.value->uiClass;
         PCLASS pClass     = s_pClasses[ pStack->uiClass ];
         PMETHOD pMethod   = pClass->pMethods + pStack->uiMethod;
         ULONG ulIndex     = pMethod->uiData;

         if( pStack->uiClass != uiObjClass )
            ulIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
                                 s_pClasses[ pMethod->uiSprClass ]->pClassSym );
         else
            ulIndex += pMethod->uiOffset;

         /* will arise only if the class has been modified after first instance */
         if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed */
            hb_arraySize( pObject, ulIndex );   /* Make large enough */

         return hb_arrayGetItemRef( pObject, ulIndex, hb_stackReturnItem() );
      }
      else if( pExecSym->value.pFunPtr == hb___msgSetClsData )
      {
         PCLASS pClass   = s_pClasses[ pStack->uiClass ];
         PMETHOD pMethod = pClass->pMethods + pStack->uiMethod;

         return hb_arrayGetItemRef( pClass->pClassDatas, pMethod->uiData,
                                    hb_stackReturnItem() );
      }
      else if( pExecSym->value.pFunPtr == hb___msgSetShrData )
      {
         PCLASS pClass   = s_pClasses[ pStack->uiClass ];
         PMETHOD pMethod = pClass->pMethods + pStack->uiMethod;

         return hb_arrayGetItemRef( s_pClasses[ pMethod->uiSprClass ]->pSharedDatas,
                                    pMethod->uiData, hb_stackReturnItem() );
      }
      else if( pExecSym->value.pFunPtr == hb___msgScopeErr )
      {
         pExecSym->value.pFunPtr();
      }
      else
      {
         PCLASS pClass   = s_pClasses[ pStack->uiClass ];
         PMETHOD pMethod = pClass->pMethods + pStack->uiMethod;

         if( !pMethod->pAccMsg )
            pMethod->pAccMsg = hb_dynsymGetCase( pMessage->szName + 1 );

         return hb_vmMsgReference( pObject, pMessage->pDynSym, pMethod->pAccMsg );
      }
   }

   return FALSE;
}
classes.c1978
BOOLhb_clsHasDestructor( USHORT uiClass )
BOOL hb_clsHasDestructor( USHORT uiClass )
{
   if( uiClass && uiClass <= s_uiClasses )
      return s_pClasses[ uiClass ]->fHasDestructor;
   else
      return FALSE;
}
classes.c2052
STATIC VOIDhb_objSupperDestructorCall( PHB_ITEM pObject, PCLASS pClass )
static void hb_objSupperDestructorCall( PHB_ITEM pObject, PCLASS pClass )
{
   PMETHOD pMethod = pClass->pMethods;
   ULONG   ulLimit = hb_clsMthNum( pClass );
   BYTE * pbClasses;
   USHORT uiClass;

   pbClasses = ( BYTE * ) hb_xgrab( s_uiClasses + 1 );
   memset( pbClasses, 0, s_uiClasses + 1 );

   do
   {
      if( pMethod->pMessage )
      {
         if( pMethod->pFuncSym == &s___msgSuper )
         {
            PCLASS pSupperClass = s_pClasses[ pMethod->uiSprClass ];
            if( pSupperClass->fHasDestructor && pSupperClass != pClass )
               pbClasses[ pMethod->uiSprClass ] |= 1;
         }
         else if( pMethod->pMessage == s___msgDestructor.pDynSym )
            pbClasses[ pMethod->uiSprClass ] |= 2;
      }
      ++pMethod;
   }
   while( --ulLimit );

   for( uiClass = s_uiClasses; uiClass; --uiClass )
   {
      if( pbClasses[ uiClass ] == 1 )
      {
         PMETHOD pDestructor = hb_clsFindMsg( s_pClasses[ uiClass ],
                                              s___msgDestructor.pDynSym );
         if( pDestructor )
         {
            if( pbClasses[ pDestructor->uiSprClass ] == 1 )
            {
               hb_vmPushSymbol( &s___msgDestructor );
               hb_clsMakeSuperObject( hb_stackAllocItem(), pObject, uiClass );
               hb_vmSend( 0 );
               if( hb_vmRequestQuery() != 0 )
                  break;
               pbClasses[ pDestructor->uiSprClass ] |= 2;
            }
         }
      }
   }

   hb_xfree( pbClasses );
}
classes.c2063
VOIDhb_objDestructorCall( PHB_ITEM pObject )
void hb_objDestructorCall( PHB_ITEM pObject )
{
   if( HB_IS_OBJECT( pObject ) &&
       pObject->item.asArray.value->uiClass <= s_uiClasses )
   {
      PCLASS pClass = s_pClasses[ pObject->item.asArray.value->uiClass ];

      if( pClass->fHasDestructor )
      {
         if( hb_vmRequestReenter() )
         {
            hb_vmPushSymbol( &s___msgDestructor );
            hb_vmPush( pObject );
            hb_vmSend( 0 );
            if( hb_vmRequestQuery() == 0 )
               hb_objSupperDestructorCall( pObject, pClass );
            hb_vmRequestRestore();
         }
      }
   }
}
classes.c2117
BOOLhb_objHasOperator( PHB_ITEM pObject, USHORT uiOperator )
BOOL hb_objHasOperator( PHB_ITEM pObject, USHORT uiOperator )
{
   USHORT uiClass;

   HB_TRACE(HB_TR_DEBUG, ("hb_objHasOperator(%p,%hu)", pObject, uiOperator));

   uiClass = hb_objGetClassH( pObject );
   if( uiClass && uiClass <= s_uiClasses )
   {
      return ( s_pClasses[ uiClass ]->ulOpFlags & ( 1UL << uiOperator ) ) != 0;
   }

   return FALSE;
}
classes.c2142
BOOLhb_objOperatorCall( USHORT uiOperator, HB_ITEM_PTR pResult, PHB_ITEM pObject, PHB_ITEM pMsgArg1, PHB_ITEM pMsgArg2 )
BOOL hb_objOperatorCall( USHORT uiOperator, HB_ITEM_PTR pResult, PHB_ITEM pObject,
                         PHB_ITEM pMsgArg1, PHB_ITEM pMsgArg2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_objOperatorCall(%hu,%p,%p,%p,%p)", uiOperator, pResult, pObject, pMsgArg1, pMsgArg2));

   if( hb_objHasOperator( pObject, uiOperator ) )
   {
      hb_vmPushSymbol( s_opSymbols + uiOperator );
      hb_vmPush( pObject );
      hb_itemSetNil( hb_stackReturnItem() );
      if( pMsgArg1 )
      {
         hb_vmPush( pMsgArg1 );
         if( pMsgArg2 )
         {
            hb_vmPush( pMsgArg2 );
            hb_vmSend( 2 );
         }
         else
            hb_vmSend( 1 );
      }
      else
         hb_vmSend( 0 );

      /* store the return value */
      hb_itemMove( pResult, hb_stackReturnItem() );
      return TRUE;
   }
   return FALSE;
}
classes.c2160
HB_EXPORT BOOLhb_objHasMessage( PHB_ITEM pObject, PHB_DYNS pMessage )
HB_EXPORT BOOL hb_objHasMessage( PHB_ITEM pObject, PHB_DYNS pMessage )
{
   return hb_objGetMethod( pObject, pMessage->pSymbol, NULL ) != NULL;
}
classes.c2196
HB_EXPORT BOOLhb_objHasMsg( PHB_ITEM pObject, const char *szString )
HB_EXPORT BOOL hb_objHasMsg( PHB_ITEM pObject, const char *szString )
{
   PHB_DYNS pDynSym;

   HB_TRACE(HB_TR_DEBUG, ("hb_objHasMsg(%p, %s)", pObject, szString));

   pDynSym = hb_dynsymFindName( szString );
   if( pDynSym )
   {
      return hb_objGetMethod( pObject, pDynSym->pSymbol, NULL ) != NULL;
   }
   else
   {
      return FALSE;
   }
}
classes.c2204
HB_EXPORT PHB_ITEMhb_objSendMessage( PHB_ITEM pObject, PHB_DYNS pMsgSym, ULONG ulArg, ... )
HB_EXPORT PHB_ITEM hb_objSendMessage( PHB_ITEM pObject, PHB_DYNS pMsgSym, ULONG ulArg, ... )
{
   if( pObject && pMsgSym )
   {
      hb_vmPushSymbol( pMsgSym->pSymbol );
      hb_vmPush( pObject );

      if( ulArg )
      {
         unsigned long i;
         va_list ap;

         va_start( ap, ulArg );
         for( i = 0; i < ulArg; i++ )
         {
            hb_vmPush( va_arg( ap, PHB_ITEM ) );
         }
         va_end( ap );
      }
      hb_vmSend( (USHORT) ulArg );
   }
   else
      hb_errRT_BASE( EG_ARG, 3000, NULL, "__ObjSendMessage()", 0 );

   return hb_stackReturnItem();
}
classes.c2228
HB_EXPORT PHB_ITEMhb_objSendMsg( PHB_ITEM pObject, const char *sMsg, ULONG ulArg, ... )
HB_EXPORT PHB_ITEM hb_objSendMsg( PHB_ITEM pObject, const char *sMsg, ULONG ulArg, ... )
{
   hb_vmPushSymbol( hb_dynsymGet( sMsg )->pSymbol );
   hb_vmPush( pObject );
   if( ulArg )
   {
      unsigned long i;
      va_list ap;

      va_start( ap, ulArg );
      for( i = 0; i < ulArg; i++ )
      {
         hb_vmPush( va_arg( ap, PHB_ITEM ) );
      }
      va_end( ap );
   }
   hb_vmSend( (USHORT) ulArg );

   return hb_stackReturnItem();
}
classes.c2255
STATIC PHB_DYNShb_objGetMsgSym( PHB_ITEM pMessage )
static PHB_DYNS hb_objGetMsgSym( PHB_ITEM pMessage )
{
   PHB_DYNS pDynSym = NULL;

   if( pMessage )
   {
      const char * szMsg = NULL;

      if( HB_IS_STRING( pMessage ) )
         szMsg = pMessage->item.asString.value;
      else if( HB_IS_SYMBOL( pMessage ) )
      {
         pDynSym = pMessage->item.asSymbol.value->pDynSym;
         if( !pDynSym )
            szMsg = pMessage->item.asSymbol.value->szName;
      }

      if( szMsg && *szMsg )
         pDynSym = hb_dynsymGet( szMsg );
   }

   return pDynSym;
}
classes.c2276
STATIC PHB_SYMBhb_objGetFuncSym( PHB_ITEM pItem )
static PHB_SYMB hb_objGetFuncSym( PHB_ITEM pItem )
{
   if( pItem )
   {
      if( HB_IS_SYMBOL( pItem ) )
         return pItem->item.asSymbol.value;
      else if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( hb_itemGetCPtr( pItem ) );

         if( pDynSym && pDynSym->pSymbol->value.pFunPtr )
            return pDynSym->pSymbol;
      }
   }

   return NULL;
}
classes.c2300
HB_EXPORT VOIDhb_dbgObjSendMessage( int iProcLevel, PHB_ITEM pObject, PHB_ITEM pMessage, int iParamOffset )
HB_EXPORT void hb_dbgObjSendMessage( int iProcLevel, PHB_ITEM pObject, PHB_ITEM pMessage, int iParamOffset )
{
   PHB_DYNS pMsgSym;

   pMsgSym = hb_objGetMsgSym( pMessage );
   if( pObject && pMsgSym )
   {
      USHORT uiParams = 0;

      /* set requested sender class and method id for scope verification */
      if( iProcLevel > 0 )
      {
         int iLevel = hb_stackCallDepth();
         if( iProcLevel < iLevel )
         {
            LONG lOffset = hb_stackBaseProcOffset( iLevel - iProcLevel );
            if( lOffset > 0 )
            {
               PHB_ITEM pItem = hb_stackItem( lOffset );
               PHB_ITEM pBase = hb_stackBaseItem();
               pBase->item.asSymbol.stackstate->uiClass =
                                    pItem->item.asSymbol.stackstate->uiClass;
               pBase->item.asSymbol.stackstate->uiMethod =
                                    pItem->item.asSymbol.stackstate->uiMethod;
            }
         }
      }
      else if( iProcLevel == 0 )
      {
         /* set scope like for internal object messages to any visible
            method without respecting overloaded methods */
         USHORT uiClass = hb_objGetClassH( pObject );

         if( uiClass && uiClass <= s_uiClasses )
         {
            PMETHOD pMethod = hb_clsFindMsg( s_pClasses[ uiClass ], pMsgSym );
            if( pMethod )
            {
               PHB_ITEM pBase = hb_stackBaseItem();

               pBase->item.asSymbol.stackstate->uiClass = uiClass;
               pBase->item.asSymbol.stackstate->uiMethod =
                     ( USHORT ) ( pMethod - s_pClasses[ uiClass ]->pMethods );
            }
         }
      }

      hb_vmPushSymbol( pMsgSym->pSymbol );
      hb_vmPush( pObject );

      if( iParamOffset > 0 )
      {
         int iPCount = hb_pcount();

         while( iParamOffset <= iPCount )
         {
            hb_vmPush( hb_stackItemFromBase( iParamOffset ) );
            ++uiParams;
            ++iParamOffset;
         }
      }
      hb_vmSend( uiParams );
   }
   else
      hb_errRT_BASE( EG_ARG, 3000, NULL, "hb_dbgObjSendMessage()", 2, pObject, pMsgSym );
}
classes.c2318
STATIC USHORThb_clsUpdateScope( USHORT uiScope, BOOL fAssign )
static USHORT hb_clsUpdateScope( USHORT uiScope, BOOL fAssign )
{
   if( !fAssign )
      uiScope &= ~HB_OO_CLSTP_READONLY;
   else
   {
      uiScope &= ~HB_OO_CLSTP_PERSIST;

      if( ( uiScope & HB_OO_CLSTP_READONLY ) &&
         !( uiScope & HB_OO_CLSTP_HIDDEN ) )
      {
         /* Class(y) does not allow to write to HIDDEN+READONLY
            instance variables, [druzus] */

         uiScope &= ~HB_OO_CLSTP_READONLY;
         uiScope |= uiScope & HB_OO_CLSTP_PROTECTED ?
                       HB_OO_CLSTP_HIDDEN : HB_OO_CLSTP_PROTECTED;
      }
   }
   return uiScope;
}
classes.c2386
STATIC HB_TYPEhb_clsGetItemType( PHB_ITEM pItem, HB_TYPE nDefault )
static HB_TYPE hb_clsGetItemType( PHB_ITEM pItem, HB_TYPE nDefault )
{
   if( pItem )
   {
      if( HB_IS_STRING( pItem ) )
      {
         switch( hb_itemGetCPtr( pItem )[ 0 ] )
         {
            case 'C':
            case 'c':
            case '\0':
               if( hb_strnicmp( hb_itemGetCPtr( pItem ), "code", 4 ) == 0 )
                  return HB_IT_BLOCK;
               else
                  return HB_IT_STRING;

            case 'S':
            case 's':
               if( hb_strnicmp( hb_itemGetCPtr( pItem ), "str", 3 ) == 0 )
                  return HB_IT_STRING;
               else
                  return HB_IT_SYMBOL;

            case 'B':
            case 'b':
               return HB_IT_BLOCK;

            case 'D':
            case 'd':
               return HB_IT_DATE;

            case 'L':
            case 'l':
               return HB_IT_LOGICAL;

            case 'I':
            case 'i':
               return HB_IT_NUMINT;

            case 'N':
            case 'n':
               if( hb_stricmp( hb_itemGetCPtr( pItem ), "nil" ) == 0 )
                  return HB_IT_NIL;
               else
                  return HB_IT_NUMERIC;

            case 'A':
            case 'a':
               return HB_IT_ARRAY;

            case 'P':
            case 'p':
               return HB_IT_POINTER;

            case 'H':
            case 'h':
               return HB_IT_HASH;
         }
      }
      else if( HB_IS_ARRAY( pItem ) )
      {
         if( pItem->item.asArray.value->uiClass == 0 )
            return HB_IT_ARRAY;
      }
      else if( HB_IS_NUMINT( pItem ) )
         return HB_IT_NUMINT;

      else if( HB_IS_NUMERIC( pItem ) )
         return HB_IT_NUMERIC;

      else if( HB_IS_DATE( pItem ) )
         return HB_IT_DATE;

      else if( HB_IS_LOGICAL( pItem ) )
         return HB_IT_LOGICAL;

      else if( HB_IS_BLOCK( pItem ) )
         return HB_IT_BLOCK;

      else if( HB_IS_POINTER( pItem ) )
         return HB_IT_POINTER;

      else if( HB_IS_SYMBOL( pItem ) )
         return HB_IT_SYMBOL;

      else if( HB_IS_NIL( pItem ) )
         return HB_IT_NIL;
   }

   return nDefault;
}
classes.c2408
STATIC BOOLhb_clsAddMsg( USHORT uiClass, const char * szMessage, USHORT uiType, USHORT uiScope, PHB_ITEM pFunction, PHB_ITEM pInit )
static BOOL hb_clsAddMsg( USHORT uiClass, const char * szMessage,
                          USHORT uiType, USHORT uiScope,
                          PHB_ITEM pFunction, PHB_ITEM pInit )
{
   if( szMessage && uiClass && uiClass <= s_uiClasses )
   {
      PCLASS   pClass   = s_pClasses[ uiClass ];

      PHB_DYNS pMessage;
      PMETHOD  pNewMeth;
      USHORT   uiOperator, uiSprClass = 0, uiIndex = 0, uiPrevCls, uiPrevMth;
      PHB_SYMB pOpSym, pFuncSym = NULL;
      BOOL     fOK;
      ULONG    ulOpFlags = 0;

      if( pClass->fLocked )
         return FALSE;

      if( !( uiScope & ( HB_OO_CLSTP_EXPORTED | HB_OO_CLSTP_PROTECTED | HB_OO_CLSTP_HIDDEN ) ) )
         uiScope |= HB_OO_CLSTP_EXPORTED;

      /* translate names of operator overloading messages */
      if( uiType == HB_OO_MSG_DESTRUCTOR )
         pMessage = s___msgDestructor.pDynSym;
      else if( uiType == HB_OO_MSG_ONERROR )
         pMessage = s___msgOnError.pDynSym;
      else if( strcmp( "+", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_PLUS )->pDynSym;
      else if( strcmp( "-", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_MINUS )->pDynSym;
      else if( strcmp( "*", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_MULT )->pDynSym;
      else if( strcmp( "/", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_DIVIDE )->pDynSym;
      else if( strcmp( "%", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_MOD )->pDynSym;
      else if( strcmp( "^", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_POWER )->pDynSym;
      else if( strcmp( "**", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_POWER )->pDynSym;
      else if( strcmp( "++", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_INC )->pDynSym;
      else if( strcmp( "--", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_DEC )->pDynSym;
      else if( strcmp( "==", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_EXACTEQUAL )->pDynSym;
      else if( strcmp( "=", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_EQUAL )->pDynSym;
      else if( strcmp( "!=", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_NOTEQUAL )->pDynSym;
      else if( strcmp( "<>", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_NOTEQUAL )->pDynSym;
      else if( strcmp( "#", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_NOTEQUAL )->pDynSym;
      else if( strcmp( "<", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_LESS )->pDynSym;
      else if( strcmp( "<=", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_LESSEQUAL )->pDynSym;
      else if( strcmp( ">", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_GREATER )->pDynSym;
      else if( strcmp( ">=", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_GREATEREQUAL )->pDynSym;
      else if( strcmp( ":=", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_ASSIGN )->pDynSym;
      else if( strcmp( "$", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_INSTRING )->pDynSym;
      else if( strcmp( "$$", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_INCLUDE )->pDynSym;
      else if( strcmp( "!", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_NOT )->pDynSym;
      else if( hb_stricmp( ".NOT.", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_NOT )->pDynSym;
      else if( hb_stricmp( ".AND.", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_AND )->pDynSym;
      else if( hb_stricmp( ".OR.", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_OR )->pDynSym;
      else if( strcmp( "[]", szMessage ) == 0 )
         pMessage = ( s_opSymbols + HB_OO_OP_ARRAYINDEX )->pDynSym;
      else
         pMessage = hb_dynsymGet( szMessage );

      for( uiOperator = 0, pOpSym = s_opSymbols;
           uiOperator <= HB_OO_MAX_OPERATOR; ++uiOperator, ++pOpSym )
      {
         if( pOpSym->pDynSym == pMessage )
         {
            ulOpFlags |= 1UL << uiOperator;
            break;
         }
      }

      /* basic parameter validation */
      switch( uiType )
      {
         case HB_OO_MSG_METHOD:
         case HB_OO_MSG_ONERROR:
         case HB_OO_MSG_DESTRUCTOR:
            pFuncSym = hb_objGetFuncSym( pFunction );
            fOK = pFuncSym != NULL;
            break;

         case HB_OO_MSG_INLINE:
            fOK = pFunction && HB_IS_BLOCK( pFunction );
            break;

         case HB_OO_MSG_SUPER:
            uiIndex = ( USHORT ) hb_itemGetNI( pFunction );
            uiSprClass = ( USHORT ) hb_itemGetNI( pInit );
            fOK = uiSprClass && uiSprClass <= s_uiClasses &&
                  uiIndex <= pClass->uiDatas;
            break;

         case HB_OO_MSG_ASSIGN:
         case HB_OO_MSG_ACCESS:
            uiIndex = ( USHORT ) hb_itemGetNI( pFunction );
            /* This validation can break buggy .prg code which wrongly
             * sets data offsets but IMHO it will help to clean the code.
             * [druzus]
             */
            fOK = uiIndex && uiIndex <= pClass->uiDatas - pClass->uiDataFirst;
            break;

         case HB_OO_MSG_CLSASSIGN:
         case HB_OO_MSG_CLSACCESS:
            uiIndex = ( USHORT ) hb_itemGetNI( pFunction );
            fOK = uiIndex != 0;
            break;

         case HB_OO_MSG_DELEGATE:
         {
            PHB_DYNS pDelegMsg = hb_objGetMsgSym( pFunction );
            if( pDelegMsg )
            {
               pNewMeth = hb_clsFindMsg( pClass, pDelegMsg );
               if( pNewMeth )
                  uiIndex = ( USHORT ) ( pNewMeth - pClass->pMethods );
            }
            fOK = uiIndex != 0;
            break;
         }
         case HB_OO_MSG_REALCLASS:
         case HB_OO_MSG_VIRTUAL:
         case HB_OO_MSG_PERFORM:
            fOK = TRUE;
            break;

         default:
            fOK = FALSE;
      }

      if( !fOK )
      {
         hb_errRT_BASE( EG_ARG, 3000, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
         return FALSE;
      }

      pNewMeth = hb_clsAllocMsg( pClass, pMessage );
      if( ! pNewMeth )
         return FALSE;

      uiPrevCls = uiClass;
      uiPrevMth = ( USHORT ) ( pClass->pMethods - pNewMeth );

#ifndef HB_VIRTUAL_HIDDEN
      if( uiScope & HB_OO_CLSTP_HIDDEN )
         uiScope |= HB_OO_CLSTP_NONVIRTUAL;
#endif

      if( ! pNewMeth->pMessage )
         pClass->uiMethods++;           /* One more message */
      else
      {
         BOOL fOverLoad = ( pNewMeth->uiScope & HB_OO_CLSTP_OVERLOADED ) ||
                          ( ( pNewMeth->uiScope & HB_OO_CLSTP_NONVIRTUAL ) &&
                            pNewMeth->uiSprClass != uiClass );

         uiPrevCls = pNewMeth->uiPrevCls;
         uiPrevMth = pNewMeth->uiPrevMth;
         if( ! hb_clsCanClearMethod( pNewMeth, TRUE ) )
            return FALSE;

         memset( pNewMeth, 0, sizeof( METHOD ) );
         if( fOverLoad )
            uiScope |= HB_OO_CLSTP_OVERLOADED;
      }
      pNewMeth->pMessage = pMessage;
      pNewMeth->uiSprClass = uiClass;
      pNewMeth->uiPrevCls = uiPrevCls;
      pNewMeth->uiPrevMth = uiPrevMth;

      switch( uiType )
      {
         case HB_OO_MSG_METHOD:

            pNewMeth->pFuncSym = pFuncSym;
            pNewMeth->uiScope = uiScope;
            break;

         case HB_OO_MSG_ASSIGN:

            pNewMeth->uiScope = hb_clsUpdateScope( uiScope, TRUE );
            /* Class(y) does not allow to write to HIDDEN+READONLY
               instance variables, [druzus] */
            if( pNewMeth->uiScope & HB_OO_CLSTP_READONLY &&
                pNewMeth->uiScope & HB_OO_CLSTP_HIDDEN )
               pNewMeth->pFuncSym = &s___msgScopeErr;
            else
            {
               pNewMeth->pFuncSym = &s___msgSetData;
               pNewMeth->uiData = uiIndex;
               pNewMeth->uiOffset = pClass->uiDataFirst;
               pNewMeth->itemType = hb_clsGetItemType( pInit, 0 );
            }
            break;

         case HB_OO_MSG_ACCESS:

            pNewMeth->uiScope = hb_clsUpdateScope( uiScope, FALSE );
            pNewMeth->uiData = uiIndex;
            pNewMeth->uiOffset = pClass->uiDataFirst;
            hb_clsAddInitValue( pClass, pInit, HB_OO_MSG_DATA,
                                pNewMeth->uiData, pNewMeth->uiOffset, uiClass );
            pNewMeth->pFuncSym = &s___msgGetData;
            break;

         case HB_OO_MSG_CLSASSIGN:

            pNewMeth->uiData = uiIndex;
            pNewMeth->itemType = hb_clsGetItemType( pInit, 0 );
            pNewMeth->uiScope = hb_clsUpdateScope( uiScope, TRUE );
            /* Class(y) does not allow to write to HIDDEN+READONLY
               instance variables, [druzus] */
            if( pNewMeth->uiScope & HB_OO_CLSTP_READONLY &&
                pNewMeth->uiScope & HB_OO_CLSTP_HIDDEN )
               pNewMeth->pFuncSym = &s___msgScopeErr;
            else if( pNewMeth->uiScope & HB_OO_CLSTP_SHARED )
            {
               if( hb_arrayLen( pClass->pSharedDatas ) < ( ULONG ) pNewMeth->uiData )
                  hb_arraySize( pClass->pSharedDatas, pNewMeth->uiData );
               pNewMeth->pFuncSym = &s___msgSetShrData;
            }
            else
            {
               if( hb_arrayLen( pClass->pClassDatas ) < ( ULONG ) pNewMeth->uiData )
                  hb_arraySize( pClass->pClassDatas, pNewMeth->uiData );
               pNewMeth->pFuncSym = &s___msgSetClsData;
            }
            break;

         case HB_OO_MSG_CLSACCESS:

            pNewMeth->uiScope = hb_clsUpdateScope( uiScope, FALSE );
            pNewMeth->uiData = uiIndex;
            if( pNewMeth->uiScope & HB_OO_CLSTP_SHARED )
            {
               if( hb_arrayLen( pClass->pSharedDatas ) < ( ULONG ) pNewMeth->uiData )
                  hb_arraySize( pClass->pSharedDatas, pNewMeth->uiData );

               if( pInit && ! HB_IS_NIL( pInit ) ) /* Initializer found */
               {
                  /* Shared Classdata need to be initialized only once
                   * ACCESS/ASSIGN methods will be inherited by subclasses
                   * and will operate on this value so it's not necessary
                   * to keep the init value. [druzus]
                   */
                  pInit = hb_itemClone( pInit );
                  hb_arraySet( pClass->pSharedDatas, pNewMeth->uiData, pInit );
                  hb_itemRelease( pInit );
               }
               pNewMeth->pFuncSym = &s___msgGetShrData;
            }
            else
            {
               if( hb_arrayLen( pClass->pClassDatas ) < ( ULONG ) pNewMeth->uiData )
                  hb_arraySize( pClass->pClassDatas, pNewMeth->uiData );
               pNewMeth->uiOffset = hb_clsAddInitValue( pClass, pInit,
                           HB_OO_MSG_CLASSDATA, pNewMeth->uiData, 0, uiClass );
               pNewMeth->pFuncSym = &s___msgGetClsData;
            }
            break;

         case HB_OO_MSG_INLINE:

            pNewMeth->pFuncSym = &s___msgEvalInline;
            pNewMeth->uiScope = uiScope;
            hb_arrayAdd( pClass->pInlines, pFunction );
            pNewMeth->uiData = ( USHORT ) hb_arrayLen( pClass->pInlines );
            break;

         case HB_OO_MSG_VIRTUAL:

            pNewMeth->pFuncSym = &s___msgVirtual;
            pNewMeth->uiScope = uiScope;
            break;

         case HB_OO_MSG_SUPER:

            pNewMeth->uiSprClass = uiSprClass; /* store the super handel */
            pNewMeth->uiOffset = uiIndex; /* offset to instance area */
            pNewMeth->uiScope = uiScope;
            pNewMeth->pFuncSym = &s___msgSuper;
            break;

         case HB_OO_MSG_REALCLASS:
            pNewMeth->pFuncSym = &s___msgRealClass;
            pNewMeth->uiScope = uiScope;
            break;

         case HB_OO_MSG_PERFORM:
            pNewMeth->pFuncSym = &s___msgPerform;
            pNewMeth->uiScope = uiScope;
            break;

         case HB_OO_MSG_DELEGATE:
            pNewMeth->pFuncSym = &s___msgDelegate;
            pNewMeth->uiScope = uiScope;
            pNewMeth->uiData = uiIndex;
            break;

         case HB_OO_MSG_ONERROR:

            pNewMeth->pFuncSym = pFuncSym;
            pClass->fHasOnError = TRUE;
            break;

         case HB_OO_MSG_DESTRUCTOR:

            pNewMeth->pFuncSym = pFuncSym;
            pClass->fHasDestructor = TRUE;
            break;

         default:

            hb_errInternal( HB_EI_CLSINVMETHOD, NULL, "__clsAddMsg()", NULL );
            return FALSE;
      }

      pClass->ulOpFlags |= ulOpFlags;
   }

   return TRUE;   
}
classes.c2502
HB_FUNC__CLSADDMSG(void)
HB_FUNC( __CLSADDMSG )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   char * szMessage = hb_parc( 2 );

   if( szMessage && uiClass && uiClass <= s_uiClasses )
   {
      USHORT   nType     = ( USHORT ) hb_parni( 4 );
      USHORT   uiScope   = ( USHORT ) hb_parni( 6 );
      PHB_ITEM pFunction = hb_param( 3, HB_IT_ANY );
      PHB_ITEM pInit     = hb_param( 5, HB_IT_ANY );

      if( nType == HB_OO_MSG_DATA )
      {
         nType = szMessage[ 0 ] == '_' ? HB_OO_MSG_ASSIGN : HB_OO_MSG_ACCESS;
      }
      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( 2 );
         if( iLen >= HB_SYMBOL_NAME_LEN )
            iLen = HB_SYMBOL_NAME_LEN - 1;
         szAssign[ 0 ] = '_';
         memcpy( szAssign + 1, szMessage, iLen );
         szAssign[ iLen + 1 ] = '\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,
                          ( USHORT ) ( uiScope & ~HB_OO_CLSTP_PERSIST ),
                          pFunction, pInit );
            nType = HB_OO_MSG_ACCESS;
         }
         else
         {
            hb_clsAddMsg( uiClass, szAssign, HB_OO_MSG_CLSASSIGN,
                          ( USHORT ) ( uiScope & ~HB_OO_CLSTP_PERSIST ),
                          pFunction, pInit );
            nType = HB_OO_MSG_CLSACCESS;
         }
      }

      hb_clsAddMsg( uiClass, szMessage, nType, uiScope, pFunction, pInit );
   }
}
classes.c2943
STATIC USHORThb_clsNew( const char * szClassName, USHORT uiDatas, PHB_ITEM pSuperArray, PHB_SYMB pClassFunc, BOOL fModuleFriendly )
static USHORT hb_clsNew( const char * szClassName, USHORT uiDatas,
                         PHB_ITEM pSuperArray, PHB_SYMB pClassFunc,
                         BOOL fModuleFriendly )
{
   PCLASS pNewCls;
   PMETHOD pMethod;
   USHORT ui, uiSuper, uiSuperCls;
   USHORT * puiClassData = NULL, uiClassDataSize = 0;

   uiSuper  = ( USHORT ) ( pSuperArray ? hb_arrayLen( pSuperArray ) : 0 );
   pClassFunc = hb_vmGetRealFuncSym( pClassFunc );

   pNewCls = ( PCLASS ) hb_xgrab( sizeof( CLASS ) );
   memset( pNewCls, 0, sizeof( CLASS ) );

   HB_CLASS_LOCK

   if( s_uiClasses == s_uiClsSize )
   {
      s_uiClsSize += HB_CLASS_POOL_RESIZE;
      s_pClasses = ( PCLASS * ) hb_xrealloc( s_pClasses, sizeof( PCLASS ) *
                                             ( ( ULONG ) s_uiClsSize + 1 ) );
   }
   s_pClasses[ ++s_uiClasses ] = pNewCls;
   pNewCls->uiClass = s_uiClasses;

   HB_CLASS_UNLOCK

   pNewCls->szName = hb_strdup( szClassName );
   pNewCls->pClassSym = hb_dynsymGet( pNewCls->szName );
   if( !pClassFunc )
      pClassFunc = hb_vmGetRealFuncSym( pNewCls->pClassSym->pSymbol );
   pNewCls->pClassFuncSym = pClassFunc;
   if( fModuleFriendly )
      hb_vmFindModuleSymbols( pClassFunc, &pNewCls->pFriendModule,
                                          &pNewCls->uiFriendModule );

   for( ui = 1; ui <= uiSuper; ++ui )
   {
      uiSuperCls = ( USHORT ) hb_arrayGetNI( pSuperArray, ui );
      if( uiSuperCls && uiSuperCls < s_uiClasses )
      {
         PCLASS pSprCls;

         pSprCls = s_pClasses[ uiSuperCls ];
         if( ! hb_clsInited( pNewCls ) ) /* This is the first superclass */
         {
            hb_clsCopyClass( pNewCls, pSprCls );
         }
         else if( !hb_clsHasParent( pNewCls, pSprCls->pClassSym ) )
         {
            ULONG  ul, ulLimit;
            USHORT nLenClsDatas;

            /* create class data translation tables */
            nLenClsDatas  = ( USHORT ) hb_itemSize( pSprCls->pClassDatas );
            if( nLenClsDatas )
            {
               if( nLenClsDatas > uiClassDataSize )
               {
                  if( puiClassData )
                     puiClassData = ( USHORT * ) hb_xrealloc( puiClassData,
                                             sizeof( USHORT ) * nLenClsDatas );
                  else
                     puiClassData = ( USHORT * ) hb_xgrab( sizeof( USHORT ) *
                                                           nLenClsDatas );
                  uiClassDataSize = nLenClsDatas;
               }
               memset( puiClassData, 0, sizeof( USHORT ) * nLenClsDatas );
            }

            /* Copy super classs handles */
            ulLimit = hb_clsMthNum( pSprCls );
            for( ul = 0; ul < ulLimit; ++ul )
            {
               if( pSprCls->pMethods[ ul ].pMessage &&
                   pSprCls->pMethods[ ul ].pFuncSym == &s___msgSuper )
               {
                  PCLASS pCls = s_pClasses[ pSprCls->pMethods[ ul ].uiSprClass ];

                  pMethod = hb_clsAllocMsg( pNewCls,
                                            pSprCls->pMethods[ ul ].pMessage );
                  if( ! pMethod )
                     return 0;
                  if( pMethod->pMessage == NULL )
                  {
                     pNewCls->uiMethods++;
                     memcpy( pMethod, pSprCls->pMethods + ul, sizeof( METHOD ) );
                     pMethod->uiOffset = pNewCls->uiDatas;
                     pNewCls->uiDatas += pCls->uiDatas - pCls->uiDataFirst;
                  }
               }
            }

            /* add class casting if not exist */
            pMethod = hb_clsAllocMsg( pNewCls, pSprCls->pClassSym );
            if( ! pMethod )
               return 0;
            if( pMethod->pMessage == NULL )
            {
               pNewCls->uiMethods++;
               pMethod->pMessage = pSprCls->pClassSym;
               pMethod->uiSprClass = uiSuperCls;
               pMethod->uiScope = HB_OO_CLSTP_EXPORTED;
               pMethod->pFuncSym = &s___msgSuper;
               pMethod->uiOffset = pNewCls->uiDatas;
               pNewCls->uiDatas += pSprCls->uiDatas - pSprCls->uiDataFirst;
            }

            /* Copy instance area init data */
            if( pSprCls->uiInitDatas )
            {
               USHORT u;
               for( u = 0; u < pSprCls->uiInitDatas; ++u )
               {
                  if( pSprCls->pInitData[ u ].uiType == HB_OO_MSG_DATA )
                  {
                     USHORT uiCls = pSprCls->pInitData[ u ].uiSprClass;
                     hb_clsAddInitValue( pNewCls,
                        pSprCls->pInitData[ u ].pInitValue, HB_OO_MSG_DATA,
                        pSprCls->pInitData[ u ].uiData,
                        hb_clsParentInstanceOffset( pNewCls,
                                          s_pClasses[ uiCls ]->pClassSym ),
                        uiCls );
                  }
               }
            }

            /* Now working on other methods */
            ulLimit = hb_clsMthNum( pSprCls );
            for( ul = 0; ul < ulLimit; ++ul )
            {
               if( pSprCls->pMethods[ ul ].pMessage )
               {
                  pMethod = hb_clsAllocMsg( pNewCls, pSprCls->pMethods[ ul ].pMessage );
                  if( ! pMethod )
                     return 0;

                  /* Ok, this bucket is empty */
                  if( pMethod->pMessage == NULL )
                  {
                     /* Now, we can increment the msg count */
                     pNewCls->uiMethods++;
                     memcpy( pMethod, pSprCls->pMethods + ul, sizeof( METHOD ) );
                     if( ! hb_clsUpdateHiddenMessages( pMethod, pMethod, pNewCls ) )
                     {
                        if( pMethod->pFuncSym == &s___msgSetClsData ||
                            pMethod->pFuncSym == &s___msgGetClsData )
                        {
                           if( pMethod->uiData > nLenClsDatas )
                              hb_errInternal( HB_EI_CLSINVMETHOD, NULL, "__clsNew()", NULL );

                           if( puiClassData[ pMethod->uiData - 1 ] == 0 )
                           {
                              puiClassData[ pMethod->uiData - 1 ] = ( USHORT )
                                          hb_arrayLen( pNewCls->pClassDatas ) + 1;
                              hb_arraySize( pNewCls->pClassDatas,
                                            puiClassData[ pMethod->uiData - 1 ] );
                           }
                           if( pMethod->uiOffset )
                           {
                              pMethod->uiOffset = hb_clsAddInitValue( pNewCls,
                                 pSprCls->pInitData[ pMethod->uiOffset - 1 ].pInitValue,
                                 HB_OO_MSG_CLASSDATA, puiClassData[ pMethod->uiData - 1 ],
                                 0, uiSuperCls );
                           }
                           pMethod->uiData = puiClassData[ pMethod->uiData - 1 ];
                        }
                        else if( pMethod->pFuncSym == &s___msgSetData ||
                                 pMethod->pFuncSym == &s___msgGetData )
                        {
                           pMethod->uiOffset = hb_clsParentInstanceOffset( pNewCls,
                                 s_pClasses[ pMethod->uiSprClass ]->pClassSym );
                        }
                        pMethod->uiScope |= HB_OO_CLSTP_SUPER;
                     }
                  }
                  else
                  {
                     if( pSprCls->pMethods[ ul ].uiScope &
                         ( HB_OO_CLSTP_OVERLOADED | HB_OO_CLSTP_NONVIRTUAL ) )
                        pMethod->uiScope |= HB_OO_CLSTP_OVERLOADED;

                     hb_clsUpdateHiddenMessages( pSprCls->pMethods + ul, pMethod, pNewCls );
                  }
               }
            }
            pNewCls->ulOpFlags |= pSprCls->ulOpFlags;
         }
      }
   }
   if( puiClassData )
      hb_xfree( puiClassData );

   if( ! hb_clsInited( pNewCls ) )
   {
      hb_clsDictInit( pNewCls, HASH_KEY );
      pNewCls->pClassDatas  = hb_itemArrayNew( 0 );
      pNewCls->pSharedDatas = hb_itemArrayNew( 0 );
      pNewCls->pInlines     = hb_itemArrayNew( 0 );
   }

   /* add self class casting */
   if( hb_stricmp( pNewCls->szName, pNewCls->pClassSym->pSymbol->szName ) == 0 )
   {
      pMethod = hb_clsAllocMsg( pNewCls, pNewCls->pClassSym );
      if( ! pMethod )
         return 0;
      if( pMethod->pMessage == NULL )
      {
         pNewCls->uiMethods++;
         pMethod->pMessage = pNewCls->pClassSym;
         pMethod->uiSprClass = s_uiClasses;
         pMethod->uiScope = HB_OO_CLSTP_EXPORTED;
         pMethod->pFuncSym = &s___msgSuper;
         pMethod->uiOffset = pNewCls->uiDatas;
      }
   }
   pNewCls->uiDataFirst = pNewCls->uiDatas;
   pNewCls->uiDatas += uiDatas;

   return s_uiClasses;
}
classes.c2998
HB_FUNC__CLSNEW(void)
HB_FUNC( __CLSNEW )
{
   char * szClassName;
   PHB_ITEM pDatas, pSuperArray, pClassFunc, pModFriend;

   szClassName = hb_parc( 1 );

   pDatas = hb_param( 2, HB_IT_ANY );

   pSuperArray = hb_param( 3, HB_IT_ANY );
   if( pSuperArray && HB_IS_NIL( pSuperArray ) )
      pSuperArray = NULL;

   pClassFunc = hb_param( 4, HB_IT_ANY );
   if( pClassFunc && HB_IS_NIL( pClassFunc ) )
      pClassFunc = NULL;

   pModFriend = hb_param( 5, HB_IT_ANY );
   if( pModFriend && HB_IS_NIL( pModFriend ) )
      pModFriend = NULL;
   
   if( szClassName && 
       ( ! pDatas || HB_IS_NUMERIC( pDatas ) ) &&
       ( ! pSuperArray || HB_IS_ARRAY( pSuperArray ) ) &&
       ( ! pClassFunc || HB_IS_SYMBOL( pClassFunc ) ) &&
       ( ! pModFriend || HB_IS_LOGICAL( pModFriend ) ) )
   {
      USHORT uiClass;
      uiClass = hb_clsNew( szClassName, ( USHORT ) hb_itemGetNI( pDatas ),
                           pSuperArray, hb_itemGetSymbol( pClassFunc ),
                           hb_itemGetL( pModFriend ) );
      hb_retni( uiClass );
   }
   else
      hb_errRT_BASE( EG_ARG, 3000, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
classes.c3237
HB_FUNC__CLSADDFRIEND(void)
HB_FUNC( __CLSADDFRIEND )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   if( uiClass && uiClass <= s_uiClasses )
   {
      PCLASS pClass = s_pClasses[ uiClass ];

      if( !pClass->fLocked )
      {
         PHB_SYMB pSym = hb_vmGetRealFuncSym( hb_itemGetSymbol( hb_param( 2,
                                                         HB_IT_SYMBOL ) ) );
         if( pSym )
            hb_clsAddFriendSymbol( pClass, pSym );
      }
   }
}
classes.c3288
HB_FUNC__CLSDELMSG(void)
HB_FUNC( __CLSDELMSG )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   PHB_ITEM pString = hb_param( 2, HB_IT_STRING );

   if( uiClass && uiClass <= s_uiClasses && pString &&
       ! s_pClasses[ uiClass ]->fLocked )
   {
      PHB_DYNS pMsg = hb_dynsymFindName( pString->item.asString.value );

      if( pMsg )
         hb_clsFreeMsg( s_pClasses[ uiClass ], pMsg );
   }
}
classes.c3311
STATIC PHB_ITEMhb_clsInst( USHORT uiClass )
static PHB_ITEM hb_clsInst( USHORT uiClass )
{
   PHB_ITEM pSelf = NULL;

   if( uiClass && uiClass <= s_uiClasses )
   {
      PCLASS   pClass = s_pClasses[ uiClass ];

      pSelf = hb_itemNew( NULL );
      hb_arrayNew( pSelf, pClass->uiDatas );
      pSelf->item.asArray.value->uiClass = uiClass;

      /* Initialise value if initialisation was requested */
      if( pClass->uiInitDatas )
      {
         PINITDATA pInitData = pClass->pInitData;
         USHORT ui = pClass->uiInitDatas;
         PHB_ITEM pDestItm;

         do
         {
            if( pInitData->uiType == HB_OO_MSG_DATA )
               pDestItm = hb_arrayGetItemPtr( pSelf,
                                    pInitData->uiData + pInitData->uiOffset );
            else if( pInitData->uiType == HB_OO_MSG_CLASSDATA )
            {
               pDestItm = hb_arrayGetItemPtr( pClass->pClassDatas,
                                              pInitData->uiData );
               /* do not initialize it again */
               pInitData->uiType = HB_OO_MSG_INITIALIZED;
            }
            else
               pDestItm = NULL;

            if( pDestItm )
            {
               PHB_ITEM pInit = hb_itemClone( pInitData->pInitValue );
               hb_itemMove( pDestItm, pInit );
               hb_itemRelease( pInit );
            }
            ++pInitData;
         }
         while( --ui );
      }
   }

   return pSelf;
}
classes.c3335
HB_FUNC__CLSINST(void)
HB_FUNC( __CLSINST )
{
   PHB_ITEM pSelf = hb_clsInst( ( USHORT ) hb_parni( 1 ) );

   if( pSelf )
      hb_itemReturnRelease( pSelf );
}
classes.c3389
HB_FUNC__CLSLOCK(void)
HB_FUNC( __CLSLOCK )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   if( uiClass && uiClass <= s_uiClasses )
      s_pClasses[ uiClass ]->fLocked = TRUE;
}
classes.c3402
HB_FUNC__CLSMODMSG(void)
HB_FUNC( __CLSMODMSG )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   PHB_ITEM pString = hb_param( 2, HB_IT_STRING );

   if( uiClass && uiClass <= s_uiClasses && pString &&
       ! s_pClasses[ uiClass ]->fLocked )
   {
      PHB_DYNS pMsg = hb_dynsymFindName( pString->item.asString.value );

      if( pMsg )
      {
         PCLASS  pClass  = s_pClasses[ uiClass ];
         PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg );

         if( pMethod )
         { 
            PHB_SYMB pFuncSym = pMethod->pFuncSym;

            if( pFuncSym == &s___msgSetData || pFuncSym == &s___msgGetData )
            {
               hb_errRT_BASE( EG_ARG, 3004, "Cannot modify a DATA item", HB_ERR_FUNCNAME, 0 );
            }
            else if( pFuncSym == &s___msgEvalInline )
            {
               PHB_ITEM pBlock = hb_param( 3, HB_IT_BLOCK );

               if( pBlock == NULL )
                  hb_errRT_BASE( EG_ARG, 3000, "Cannot modify INLINE method", HB_ERR_FUNCNAME, 0 );
               else
                  hb_arraySet( s_pClasses[ pMethod->uiSprClass ]->pInlines,
                               pMethod->uiData, pBlock );
            }
            else                                      /* Modify METHOD */
            {
               pFuncSym = hb_objGetFuncSym( hb_param( 3, HB_IT_ANY ) );

               if( pFuncSym == NULL )
                  hb_errRT_BASE( EG_ARG, 3000, NULL, HB_ERR_FUNCNAME, 0 );
               else
                  pMethod->pFuncSym = pFuncSym;
            }
         }
      }
   }
}
classes.c3414
HB_FUNC__OBJGETCLSNAME(void)
HB_FUNC( __OBJGETCLSNAME )
{
   PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT );
   USHORT uiClass;

   if( pObject )
      uiClass = pObject->item.asArray.value->uiClass;
   else
      uiClass = ( USHORT ) hb_parni( 1 );

   hb_retc( hb_clsName( uiClass ) );
}
classes.c3467
HB_FUNC__OBJHASMSG(void)
HB_FUNC( __OBJHASMSG )
{
   PHB_DYNS pMessage = hb_objGetMsgSym( hb_param( 2, HB_IT_ANY ) );

   if( pMessage )
      hb_retl( hb_objHasMessage( hb_param( 1, HB_IT_ANY ), pMessage ) );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
classes.c3486
HB_FUNC__OBJSENDMSG(void)
HB_FUNC( __OBJSENDMSG )
{
   PHB_DYNS pMessage = hb_objGetMsgSym( hb_param( 2, HB_IT_ANY ) );

   if( pMessage )
   {
      USHORT uiPCount = hb_pcount();
      USHORT uiParam;

      hb_vmPushSymbol( pMessage->pSymbol );     /* Push message symbol */
      hb_vmPush( hb_param( 1, HB_IT_ANY ) );    /* Push object */

      for( uiParam = 3; uiParam <= uiPCount; ++uiParam )    /* Push arguments on stack */
      {
         hb_vmPush( hb_stackItemFromBase( uiParam ) );
      }
      hb_vmSend( ( USHORT ) ( uiPCount - 2 ) );             /* Execute message */
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 3000, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}
classes.c3501
HB_FUNC__OBJCLONE(void)
HB_FUNC( __OBJCLONE )
{
   PHB_ITEM pSrcObject = hb_param( 1, HB_IT_OBJECT );
   PHB_ITEM pDstObject;

   if( pSrcObject )
   {
      pDstObject = hb_arrayClone( pSrcObject );
      hb_itemReturnRelease( pDstObject );
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 3001, NULL, HB_ERR_FUNCNAME, 0 );
   }
}
classes.c3530
HB_FUNC__CLSINSTSUPER(void)
HB_FUNC( __CLSINSTSUPER )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL );
   USHORT uiClassH = 0, uiClass;
   PHB_SYMB pClassFuncSym = NULL;

   if( pItem )
   {
      if( HB_IS_SYMBOL( pItem ) )
         pClassFuncSym = hb_itemGetSymbol( pItem );
      else if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( hb_itemGetCPtr( pItem ) );
         if( pDynSym )
            pClassFuncSym = pDynSym->pSymbol;
      }
      pClassFuncSym = hb_vmGetRealFuncSym( pClassFuncSym );
   }

   if( pClassFuncSym )
   {
      uiClassH = hb_clsFindClassByFunc( pClassFuncSym );
      if( uiClassH == 0 )
      {
         hb_vmPushSymbol( pClassFuncSym );
         hb_vmPushNil();
         hb_vmFunction( 0 ); /* Execute super class */

         if( hb_vmRequestQuery() == 0 )
         {
            PHB_ITEM pObject = hb_stackReturnItem();

            if( HB_IS_OBJECT( pObject ) )
            {
               uiClass = pObject->item.asArray.value->uiClass;

               if( s_pClasses[ uiClass ]->pClassFuncSym == pClassFuncSym )
                  uiClassH = uiClass;
               else
               {
                  uiClassH = hb_clsFindClassByFunc( pClassFuncSym );
                  /* still not found, try to send NEW() message */
                  if( uiClassH == 0 )
                  {
                     hb_vmPushSymbol( &s___msgNew );
                     hb_vmPush( pObject );
                     hb_vmSend( 0 );

                     pObject = hb_stackReturnItem();
                     if( HB_IS_OBJECT( pObject ) )
                     {
                        uiClass = pObject->item.asArray.value->uiClass;
                        if( s_pClasses[ uiClass ]->pClassFuncSym == pClassFuncSym )
                           uiClassH = uiClass;
                     }
                  }
               }
            }

            /* This disables destructor execution for this object */
            if( uiClassH && HB_IS_OBJECT( pObject ) )
               pObject->item.asArray.value->uiClass = 0;
            else if( hb_vmRequestQuery() == 0 )
               hb_errRT_BASE( EG_ARG, 3002, "Super class does not return an object", HB_ERR_FUNCNAME, 0 );
         }
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 3003, "Cannot find super class", HB_ERR_FUNCNAME, 0 );

   hb_retni( uiClassH );
}
classes.c3551
HB_FUNC__CLSASSOCTYPE(void)
HB_FUNC( __CLSASSOCTYPE )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   PHB_ITEM pType = hb_param( 2, HB_IT_ANY );
   BOOL fResult = FALSE;

   if( uiClass && uiClass <= s_uiClasses && pType )
   {
      HB_TYPE nType = hb_clsGetItemType( pType, HB_IT_ANY );
      if( nType != HB_IT_ANY )
      {
         switch( nType )
         {
            case HB_IT_ARRAY:
               s_uiArrayClass = uiClass;
               break;
            case HB_IT_BLOCK:
               s_uiBlockClass = uiClass;
               break;
            case HB_IT_STRING:
               s_uiCharacterClass = uiClass;
               break;
            case HB_IT_DATE:
               s_uiDateClass = uiClass;
               break;
            case HB_IT_HASH:
               s_uiHashClass = uiClass;
               break;
            case HB_IT_LOGICAL:
               s_uiLogicalClass = uiClass;
               break;
            case HB_IT_NIL:
               s_uiNilClass = uiClass;
               break;
            case HB_IT_NUMERIC:
               s_uiNumericClass = uiClass;
               break;
            case HB_IT_SYMBOL:
               s_uiSymbolClass = uiClass;
               break;
            case HB_IT_POINTER:
               s_uiPointerClass = uiClass;
               break;
            default:
               uiClass = 0;
         }
         fResult = uiClass != 0;
      }
   }

   hb_retl( fResult );
}
classes.c3629
HB_FUNC__CLSCNTCLASSES(void)
HB_FUNC( __CLSCNTCLASSES )
{
   hb_retni( ( int ) s_uiClasses );
}
classes.c3687
HB_FUNC__CLS_CNTCLSDATA(void)
HB_FUNC( __CLS_CNTCLSDATA )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   hb_retni( uiClass && uiClass <= s_uiClasses ?
                  hb_arrayLen( s_pClasses[ uiClass ]->pClassDatas ) : 0 );
}
classes.c3697
HB_FUNC__CLS_CNTSHRDATA(void)
HB_FUNC( __CLS_CNTSHRDATA )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   hb_retni( uiClass && uiClass <= s_uiClasses ?
                  hb_arrayLen( s_pClasses[ uiClass ]->pSharedDatas ) : 0 );
}
classes.c3710
HB_FUNC__CLS_CNTDATA(void)
HB_FUNC( __CLS_CNTDATA )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   hb_retni( uiClass && uiClass <= s_uiClasses ?
             s_pClasses[ uiClass ]->uiDatas : 0 );
}
classes.c3723
HB_FUNC__CLS_DECDATA(void)
HB_FUNC( __CLS_DECDATA )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   if( uiClass && uiClass <= s_uiClasses &&
       s_pClasses[ uiClass ]->uiDatas > s_pClasses[ uiClass ]->uiDataFirst )
   {
      if( !s_pClasses[ uiClass ]->fLocked )
         s_pClasses[ uiClass ]->uiDatas--;
      hb_retni( s_pClasses[ uiClass ]->uiDatas - s_pClasses[ uiClass ]->uiDataFirst );
   }
   else
      hb_retni( 0 );
}
classes.c3736
HB_FUNC__CLS_INCDATA(void)
HB_FUNC( __CLS_INCDATA )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );

   if( uiClass && uiClass <= s_uiClasses )
   {
      if( !s_pClasses[ uiClass ]->fLocked )
         s_pClasses[ uiClass ]->uiDatas++;
      hb_retni( s_pClasses[ uiClass ]->uiDatas - s_pClasses[ uiClass ]->uiDataFirst );
   }
   else
      hb_retni( 0 );
}
classes.c3756
HB_FUNC__CLASSNEW(void)
HB_FUNC( __CLASSNEW )
{
   HB_FUNC_EXEC( __CLSNEW );
}
classes.c3776
HB_FUNC__CLASSINSTANCE(void)
HB_FUNC( __CLASSINSTANCE )
{
   HB_FUNC_EXEC( __CLSINST );
}
classes.c3785
HB_FUNC__CLASSADD(void)
HB_FUNC( __CLASSADD )
{
   HB_FUNC_EXEC( __CLSADDMSG );
}
classes.c3793
HB_FUNC__CLASSNAME(void)
HB_FUNC( __CLASSNAME )
{
   hb_retc( hb_clsName( ( USHORT ) hb_parni( 1 ) ) );
}
classes.c3801
HB_FUNC__CLASSSEL(void)
HB_FUNC( __CLASSSEL )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   PHB_ITEM pReturn = hb_itemNew( NULL );

   if( uiClass && uiClass <= s_uiClasses )
   {
      PCLASS  pClass  = s_pClasses[ uiClass ];
      PMETHOD pMethod = pClass->pMethods;
      ULONG   ulLimit = hb_clsMthNum( pClass ), ulPos = 0;

      hb_arrayNew( pReturn, pClass->uiMethods ); /* Create a transfer array */

      do
      {
         if( pMethod->pMessage )    /* Hash Entry used ? */
            hb_arraySetC( pReturn, ++ulPos, pMethod->pMessage->pSymbol->szName );
         ++pMethod;
      }
      while( --ulLimit );

      if( ulPos < ( ULONG ) pClass->uiMethods )
         hb_arraySize( pReturn, ulPos );
   }

   hb_itemReturnRelease( pReturn );
}
classes.c3808
HB_FUNC__GETMESSAGE(void)
HB_FUNC( __GETMESSAGE )
{
   hb_retc( hb_stackItem( hb_stackBaseItem()->item.asSymbol.stackstate->lBaseItem )->item.asSymbol.value->szName );
}
classes.c3836
HB_FUNC__CLSPARENT(void)
HB_FUNC( __CLSPARENT )
{
   hb_retl( hb_clsIsParent( ( USHORT ) hb_parni( 1 ) , hb_parc( 2 ) ) );
}
classes.c3842
HB_FUNC__SENDER(void)
HB_FUNC( __SENDER )
{
   LONG lOffset = hb_stackBaseProcOffset( 2 );

   if( lOffset > 0 )
   {
      PHB_ITEM pSelf = hb_stackItem( lOffset + 1 );

      /* Is it inline method? */
      if( lOffset > 0 && HB_IS_BLOCK( pSelf ) &&
          hb_stackItem( lOffset )->item.asSymbol.value == &hb_symEval )
      {
         pSelf = hb_stackItem( hb_stackItem( lOffset )->
                               item.asSymbol.stackstate->lBaseItem + 1 );
      }

      if( HB_IS_OBJECT( pSelf ) )
      {
         hb_itemReturn( pSelf );
      }
   }
}
classes.c3847
HB_FUNC__CLASSH(void)
HB_FUNC( __CLASSH )
{
   PHB_ITEM pObject = hb_param( 1, HB_IT_ANY );

   hb_retni( pObject ? hb_objGetClassH( pObject ) : 0 );
}
classes.c3870
STATIC HARBOURhb___msgClassH( void )
static HARBOUR hb___msgClassH( void )
{
   hb_retni( hb_stackBaseItem()->item.asSymbol.stackstate->uiClass );
}
classes.c3884
STATIC HARBOURhb___msgClassName( void )
static HARBOUR hb___msgClassName( void )
{
   USHORT uiClass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;

   if( uiClass )
      hb_retc( s_pClasses[ uiClass ]->szName );
   else
      hb_retc( hb_objGetClsName( hb_stackSelfItem() ) );
}
classes.c3895
STATIC HARBOURhb___msgClassSel( void )
static HARBOUR hb___msgClassSel( void )
{
   USHORT uiClass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;

   if( uiClass && uiClass <= s_uiClasses )
   {
      PHB_ITEM pReturn = hb_itemNew( NULL );
      PCLASS  pClass  = s_pClasses[ uiClass ];
      PMETHOD pMethod = pClass->pMethods;
      ULONG ulLimit = hb_clsMthNum( pClass ), ulPos = 0;
      USHORT nParam;

      nParam = hb_pcount() > 0 ? ( USHORT ) hb_parni( 1 ) : HB_MSGLISTALL;
      hb_arrayNew( pReturn, pClass->uiMethods );

      do
      {
         if( pMethod->pMessage )  /* Hash Entry used ? */
         {
            if( ( nParam == HB_MSGLISTALL )  ||
                ( nParam == HB_MSGLISTCLASS &&
                  (
                    ( pMethod->pFuncSym == &s___msgSetClsData ) ||
                    ( pMethod->pFuncSym == &s___msgGetClsData ) ||
                    ( pMethod->pFuncSym == &s___msgSetShrData ) ||
                    ( pMethod->pFuncSym == &s___msgGetShrData )
                  )
                ) ||
                ( nParam == HB_MSGLISTPURE &&
                  !(
                    ( pMethod->pFuncSym == &s___msgSetClsData ) ||
                    ( pMethod->pFuncSym == &s___msgGetClsData ) ||
                    ( pMethod->pFuncSym == &s___msgSetShrData ) ||
                    ( pMethod->pFuncSym == &s___msgGetShrData )
                   )
                )
              )
            {
               hb_arraySetC( pReturn, ++ulPos,
                             pMethod->pMessage->pSymbol->szName );
            }
         }
         ++pMethod;
      }
      while( --ulLimit && ulPos < ( ULONG ) pClass->uiMethods );

      if( ulPos < ( ULONG ) pClass->uiMethods )
         hb_arraySize( pReturn, ulPos );
      hb_itemReturnRelease( pReturn );
   }
}
classes.c3911
STATIC HARBOURhb___msgClass( void )
static HARBOUR hb___msgClass( void )
{
   hb_itemReturnForward( hb_stackSelfItem() );
}
classes.c3970
STATIC HARBOURhb___msgClassParent( void )
static HARBOUR hb___msgClassParent( void )
{
   char * szParentName = NULL;
   PHB_ITEM pItem;
   USHORT uiClass;

   uiClass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;
   pItemParam = hb_param( 1, HB_IT_ANY );

   if( pItemParam )
   {
      if( HB_IS_OBJECT( pItemParam ) )
         szParentName = hb_objGetClsName( pItemParam );
      else if( HB_IS_STRING( pItemParam ) )
         szParentName = hb_parc( pItemParam );
   }

   hb_retl( szParentName && hb_clsIsParent( uiClass , szParentName ) );
}
classes.c3980
STATIC HARBOURhb___msgEvalInline( void )
static HARBOUR hb___msgEvalInline( void )
{
   PHB_STACK_STATE pStack = hb_stackBaseItem()->item.asSymbol.stackstate;
   PCLASS pClass   = s_pClasses[ pStack->uiClass ];
   PMETHOD pMethod = pClass->pMethods + pStack->uiMethod;
   USHORT uiPCount = hb_pcount(), uiParam;
   PHB_ITEM pBlock;

   hb_vmPushSymbol( &hb_symEval );

   hb_vmPush( hb_arrayGetItemPtr( s_pClasses[ pMethod->uiSprClass ]->pInlines,
                                  pMethod->uiData ) );
   pBlock = hb_stackItemFromTop( -1 );    /* Push block */
   pBlock->item.asBlock.hclass = pStack->uiClass;
   pBlock->item.asBlock.method = pStack->uiMethod;

   hb_vmPush( hb_stackSelfItem() );       /* Push self as first argument */

   for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
   {
      hb_vmPush( hb_stackItemFromBase( uiParam ) );
   }

   hb_vmSend( ( USHORT ) ( uiPCount + 1 ) );
}
classes.c4009
STATIC HARBOURhb___msgPerform( void )
static HARBOUR hb___msgPerform( void )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );
   USHORT uiPCount = hb_pcount(), uiParam;
   PHB_SYMB pSym = NULL;

   if( pItem )
   {
      if( HB_IS_SYMBOL( pItem ) )
         pSym = pItem->item.asSymbol.value;
      
      else if( HB_IS_OBJECT( pItem ) &&
               s_pClasses[ pItem->item.asArray.value->uiClass ]->pClassSym ==
               s___msgSymbol.pDynSym )
      {
         /* Dirty hack */
         pItem = hb_arrayGetItemPtr( pItem, 1 );
         if( pItem && HB_IS_SYMBOL( pItem ) )
            pSym = pItem->item.asSymbol.value;
      }

      if( pSym )
      {
         hb_vmPushSymbol( pSym );
         hb_vmPush( hb_stackSelfItem() );

         for( uiParam = 2; uiParam <= uiPCount; uiParam++ )
         {
            hb_vmPush( hb_stackItemFromBase( uiParam ) );
         }
         hb_vmSend( ( USHORT ) ( uiPCount - 1 ) );
      }
   }
}
classes.c4040
STATIC HARBOURhb___msgDelegate( void )
static HARBOUR hb___msgDelegate( void )
{
   PCLASS pClass   = s_pClasses[
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ];
   PMETHOD pMethod = pClass->pMethods +
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
   PHB_SYMB pExecSym = pClass->pMethods[ pMethod->uiData ].pFuncSym;

   if( pExecSym && pExecSym->value.pFunPtr )
   {
      if( pExecSym->scope.value & HB_FS_PCODEFUNC )
         /* Running pCode dynamic function from .hrb */
         hb_vmExecute( pExecSym->value.pCodeFunc->pCode,
                    pExecSym->value.pCodeFunc->pSymbols );
      else
         pExecSym->value.pFunPtr();
   }
   else
   {
      hb___msgNoMethod();
   }
}
classes.c4075
STATIC HARBOURhb___msgNoMethod( void )
static HARBOUR hb___msgNoMethod( void )
{
   PHB_SYMB pSym = hb_itemGetSymbol( hb_stackBaseItem() );

#if 1  /* Clipper compatible error message */
   if( pSym->szName[ 0 ] == '_' )
      hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + 1, HB_ERR_ARGS_SELFPARAMS );
   else
      hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, pSym->szName, HB_ERR_ARGS_SELFPARAMS );
#else
   char szDesc[ 128 ];

   if( pSym->szName[ 0 ] == '_' )
   {
      snprintf( szDesc, sizeof( szDesc ), "Class: '%s' has no property", hb_objGetClsName( hb_stackSelfItem() ) );
      hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, szDesc, pSym->szName + 1, HB_ERR_ARGS_BASEPARAMS );
   }
   else
   {
      snprintf( szDesc, sizeof( szDesc ), "Class: '%s' has no exported method", hb_objGetClsName( hb_stackSelfItem() ) );
      hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, szDesc, pSym->szName, HB_ERR_ARGS_BASEPARAMS );
   }
#endif
}
classes.c4098
STATIC HARBOURhb___msgScopeErr( void )
static HARBOUR hb___msgScopeErr( void )
{
   char * pszProcName;
   PHB_ITEM pObject = hb_stackSelfItem();
   PMETHOD pMethod = s_pClasses[
      hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ]->pMethods +
      hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;

   pszProcName = hb_xstrcpy( NULL, hb_objGetClsName( pObject ), ":",
                             pMethod->pMessage->pSymbol->szName, NULL );
   if( pMethod->uiScope & HB_OO_CLSTP_HIDDEN )
      hb_errRT_BASE( EG_NOMETHOD, 41, "Scope violation (hidden)", pszProcName, 0 );
   else
      hb_errRT_BASE( EG_NOMETHOD, 42, "Scope violation (protected)", pszProcName, 0 );
   hb_xfree( pszProcName );
}
classes.c4128
STATIC HARBOURhb___msgTypeErr( void )
static HARBOUR hb___msgTypeErr( void )
{
   char * pszProcName;
   PHB_ITEM pObject = hb_stackSelfItem();
   PMETHOD pMethod = s_pClasses[
      hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ]->pMethods +
      hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;

   pszProcName = hb_xstrcpy( NULL, hb_objGetClsName( pObject ), ":",
                             pMethod->pMessage->pSymbol->szName + 1, NULL );
   hb_errRT_BASE( EG_NOMETHOD, 44, "Assigned value is wrong class", pszProcName, HB_ERR_ARGS_BASEPARAMS );
   hb_xfree( pszProcName );
}
classes.c4150
STATIC HARBOURhb___msgSuper( void )
static HARBOUR hb___msgSuper( void )
{
   PHB_STACK_STATE pStack = hb_stackBaseItem()->item.asSymbol.stackstate;

   hb_clsMakeSuperObject( hb_stackReturnItem(), hb_stackSelfItem(),
      s_pClasses[ pStack->uiClass ]->pMethods[ pStack->uiMethod ].uiSprClass );
}
classes.c4164
STATIC HARBOURhb___msgRealClass( void )
static HARBOUR hb___msgRealClass( void )
{
   PHB_ITEM pObject = hb_stackSelfItem();
   USHORT uiClass = hb_clsSenderMethodClasss();
   USHORT uiCurClass = hb_objGetClassH( pObject );

   if( uiClass && uiClass != uiCurClass &&
       hb_clsSenderObjectClasss() == uiCurClass )
   {
      hb_clsMakeSuperObject( hb_stackReturnItem(), pObject, uiClass );
   }
   else
   {
      hb_itemReturnForward( pObject );
   }
}
classes.c4177
STATIC HARBOURhb___msgGetClsData( void )
static HARBOUR hb___msgGetClsData( void )
{
   PCLASS pClass   = s_pClasses[
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ];
   PMETHOD pMethod = pClass->pMethods +
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;

   hb_arrayGet( pClass->pClassDatas, pMethod->uiData, hb_stackReturnItem() );
}
classes.c4200
STATIC HARBOURhb___msgSetClsData( void )
static HARBOUR hb___msgSetClsData( void )
{
   PCLASS pClass   = s_pClasses[
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ];
   PMETHOD pMethod = pClass->pMethods +
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
   PHB_ITEM pReturn = hb_param( 1, HB_IT_ANY );

   if( !pReturn )
      hb_arrayGet( pClass->pClassDatas, pMethod->uiData, hb_stackReturnItem() );

   else
   {
      if( pMethod->itemType &&
          ! ( pMethod->itemType & HB_ITEM_TYPERAW( pReturn ) ) )
      {
         if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) )
            hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) );
         else
         {
            (s___msgTypeErr.value.pFunPtr)();
            return;
         }
      }

      hb_arraySet( pClass->pClassDatas, pMethod->uiData, pReturn );
      hb_itemReturnForward( pReturn );
   }
}
classes.c4216
STATIC HARBOURhb___msgGetShrData( void )
static HARBOUR hb___msgGetShrData( void )
{
   PCLASS pClass   = s_pClasses[
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ];
   PMETHOD pMethod = pClass->pMethods +
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;

   hb_arrayGet( s_pClasses[ pMethod->uiSprClass ]->pSharedDatas,
                pMethod->uiData, hb_stackReturnItem() );
}
classes.c4251
STATIC HARBOURhb___msgSetShrData( void )
static HARBOUR hb___msgSetShrData( void )
{
   PCLASS pClass   = s_pClasses[
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiClass ];
   PMETHOD pMethod = pClass->pMethods +
                  hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
   PHB_ITEM pReturn = hb_param( 1, HB_IT_ANY );

   if( !pReturn )
      hb_arrayGet( s_pClasses[ pMethod->uiSprClass ]->pSharedDatas,
                   pMethod->uiData, hb_stackReturnItem() );
   else
   {
      if( pMethod->itemType &&
          ! ( pMethod->itemType & HB_ITEM_TYPERAW( pReturn ) ) )
      {
         if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) )
            hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) );
         else
         {
            (s___msgTypeErr.value.pFunPtr)();
            return;
         }
      }

      hb_arraySet( s_pClasses[ pMethod->uiSprClass ]->pSharedDatas,
                   pMethod->uiData, pReturn );
      hb_itemReturnForward( pReturn );
   }
}
classes.c4267
STATIC HARBOURhb___msgGetData( void )
static HARBOUR hb___msgGetData( void )
{
   PHB_ITEM pObject  = hb_stackSelfItem();

   if( HB_IS_ARRAY( pObject ) )
   {
      USHORT uiObjClass = pObject->item.asArray.value->uiClass;
      USHORT uiClass    = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;
      PCLASS pClass     = s_pClasses[ uiClass ];
      PMETHOD pMethod   = pClass->pMethods +
                          hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
      ULONG ulIndex     = pMethod->uiData;

      if( uiClass != uiObjClass )
      {
         ulIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
                              s_pClasses[ pMethod->uiSprClass ]->pClassSym );
      }
      else
      {
         ulIndex += pMethod->uiOffset;
      }

      hb_arrayGet( pObject, ulIndex, hb_stackReturnItem() );
   }
}
classes.c4303
STATIC HARBOURhb___msgSetData( void )
static HARBOUR hb___msgSetData( void )
{
   PHB_ITEM pObject  = hb_stackSelfItem();

   if( HB_IS_ARRAY( pObject ) )
   {
      PHB_ITEM pReturn  = hb_param( 1, HB_IT_ANY );
      USHORT uiObjClass = pObject->item.asArray.value->uiClass;
      USHORT uiClass    = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;
      PCLASS pClass     = s_pClasses[ uiClass ];
      PMETHOD pMethod   = pClass->pMethods +
                          hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
      ULONG ulIndex     = pMethod->uiData;

      if( uiClass != uiObjClass )
      {
         ulIndex += hb_clsParentInstanceOffset( s_pClasses[ uiObjClass ],
                              s_pClasses[ pMethod->uiSprClass ]->pClassSym );
      }
      else
      {
         ulIndex += pMethod->uiOffset;
      }

      if( !pReturn )
         hb_arrayGet( pObject, ulIndex, hb_stackReturnItem() );

      else
      {
         if( pMethod->itemType &&
             ! ( pMethod->itemType & HB_ITEM_TYPERAW( pReturn ) ) )
         {
            if( pMethod->itemType == HB_IT_NUMINT && HB_IS_NUMERIC( pReturn ) )
               hb_itemPutNInt( pReturn, hb_itemGetNInt( pReturn ) );
            else
            {
               (s___msgTypeErr.value.pFunPtr)();
               return;
            }
         }

         /* will arise only if the class has been modified after first instance */
         if( ulIndex > hb_arrayLen( pObject ) ) /* Resize needed ? */
            hb_arraySize( pObject, ulIndex );   /* Make large enough */
         hb_arraySet( pObject, ulIndex, pReturn );
         hb_itemReturnForward( pReturn );
      }
   }
}
classes.c4335
STATIC HARBOURhb___msgVirtual( void )
static HARBOUR hb___msgVirtual( void )
{
   /* hb_ret(); */ /* NOTE: It's safe to comment this out */
   ;
}
classes.c4390
STATIC HARBOURhb___msgNull( void )
static HARBOUR hb___msgNull( void )
{
   ;
}
classes.c4397
VOIDhb_mthAddTime( ULONG ulClockTicks )
void hb_mthAddTime( ULONG ulClockTicks )
{
   PMETHOD pMethod = s_pClasses[ hb_objGetClassH( hb_stackSelfItem() ) ]->
                     pMethods;
   if( pMethod )
   {
      pMethod += hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
      pMethod->ulCalls++;
      pMethod->ulTime += ulClockTicks;
   }
}
classes.c4403
HB_FUNC__GETMSGPRF(void)
HB_FUNC( __GETMSGPRF ) /* profiler: returns a method called and consumed times */
                       /* ( nClass, cMsg ) --> aMethodInfo { nTimes, nTime } */
{
#ifndef HB_NO_PROFILER
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   char * cMsg    = hb_parc( 2 );

   hb_reta( 2 );
   if( uiClass && uiClass <= s_uiClasses && cMsg && *cMsg )
   {
      PHB_DYNS pMsg = hb_dynsymFindName( cMsg );

      if( pMsg )
      {
         PMETHOD pMethod = hb_clsFindMsg( s_pClasses[ uiClass ], pMsg );

         if( pMethod )
         {
            hb_stornl( pMethod->ulCalls, -1, 1 );
            hb_stornl( pMethod->ulTime, -1, 2 );
            return;
         }
      }
   }
#else
   hb_reta( 2 );
#endif
   hb_stornl( 0, -1, 1 );
   hb_stornl( 0, -1, 2 );
}
classes.c4416
HB_FUNC__CLSGETPROPERTIES(void)
HB_FUNC( __CLSGETPROPERTIES )
{
   USHORT uiClass = ( USHORT ) hb_parni( 1 );
   PHB_ITEM pReturn = hb_itemNew( NULL );

   if( uiClass && uiClass <= s_uiClasses )
   {
      PCLASS  pClass  = s_pClasses[ uiClass ];
      PMETHOD pMethod;
      ULONG ulLimit, ulCount;
      USHORT uiScope = HB_OO_CLSTP_PERSIST;

      if( ISLOG( 2 ) && hb_parl( 2 ) )
         uiScope |= HB_OO_CLSTP_EXPORTED;

      ulCount = 0;
      ulLimit = hb_clsMthNum( pClass );
      pMethod = pClass->pMethods;
      do
      {
         if( pMethod->pMessage && ( pMethod->uiScope & uiScope ) != 0 )
         {
            if( ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) != 0 )
               ++ulCount;
            else if( pMethod->pMessage->pSymbol->szName[ 0 ] == '_' )
            {
               PHB_DYNS pMsg = hb_dynsymFind( pMethod->pMessage->pSymbol->szName + 1 );
               if( pMsg && hb_clsFindMsg( pClass, pMsg ) )
                  ++ulCount;
            }
         }
         ++pMethod;
      }
      while( --ulLimit );

      hb_arrayNew( pReturn, ulCount );

      ulCount = 0;
      ulLimit = hb_clsMthNum( pClass );
      pMethod = pClass->pMethods;
      do
      {
         if( pMethod->pMessage && ( pMethod->uiScope & uiScope ) != 0 )
         {
            if( ( pMethod->uiScope & HB_OO_CLSTP_PERSIST ) != 0 )
               hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName );
            else if( pMethod->pMessage->pSymbol->szName[ 0 ] == '_' )
            {
               PHB_DYNS pMsg = hb_dynsymFind( pMethod->pMessage->pSymbol->szName + 1 );
               if( pMsg && hb_clsFindMsg( pClass, pMsg ) )
                  hb_arraySetC( pReturn, ++ulCount, pMethod->pMessage->pSymbol->szName + 1 );
            }
         }
         ++pMethod;
      }
      while( --ulLimit );
   }

   hb_itemReturnRelease( pReturn );
}
classes.c4455
HB_FUNC__CLSPREALLOCATE(void)
HB_FUNC( __CLSPREALLOCATE )
{
   LONG lNewSize = hb_parnl( 1 );

   if( lNewSize > ( LONG ) USHRT_MAX )
      lNewSize = USHRT_MAX;

   HB_CLASS_LOCK

   if( lNewSize > ( LONG ) s_uiClsSize )
   {
      s_uiClsSize = ( USHORT ) lNewSize;
      s_pClasses = ( PCLASS * ) hb_xrealloc( s_pClasses, sizeof( PCLASS ) *
                                             ( ( ULONG ) s_uiClsSize + 1 ) );
   }

   HB_CLASS_UNLOCK

   hb_retnl( s_uiClsSize );
}
classes.c4516
HB_FUNCHB_SETCLSHANDLE(void)
HB_FUNC( HB_SETCLSHANDLE ) /* ( oObject, nClassHandle ) --> nPrevClassHandle */
{
   PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT );
   USHORT uiPrevClassHandle = 0;

   if( pObject )
   {
      USHORT uiClass = ( USHORT ) hb_parni( 2 );

      uiPrevClassHandle = pObject->item.asArray.value->uiClass;
      if( uiClass <= s_uiClasses )
         pObject->item.asArray.value->uiClass = uiClass;
   }

   hb_retnl( uiPrevClassHandle );
}
classes.c4548
USHORThb_clsCreate( USHORT usSize, const char * szClassName )
USHORT hb_clsCreate( USHORT usSize, const char * szClassName )
{
   return hb_clsNew( szClassName, usSize, NULL, NULL, FALSE );
}
classes.c4565
VOIDhb_clsAdd( USHORT usClassH, const char * szMethodName, PHB_FUNC pFuncPtr )
void hb_clsAdd( USHORT usClassH, const char * szMethodName, PHB_FUNC pFuncPtr )
{
   PHB_SYMB pExecSym;
   PHB_ITEM pFuncItem;

   /*
    * We can use empty name "" for this symbol in hb_symbolNew()
    * It's only envelop for function with additional execution
    * information for HVM not registered symbol. [druzus]
    */
   pExecSym = hb_symbolNew( "" );
   pExecSym->value.pFunPtr = pFuncPtr;
   pFuncItem = hb_itemPutSymbol( NULL, pExecSym );

   hb_clsAddMsg( usClassH, szMethodName, HB_OO_MSG_METHOD, 0, pFuncItem, NULL );

   hb_itemRelease( pFuncItem );
}
classes.c4571
VOIDhb_clsAssociate( USHORT usClassH )
void hb_clsAssociate( USHORT usClassH )
{
   PHB_ITEM pSelf = hb_clsInst( usClassH );

   if( pSelf )
      hb_itemReturnRelease( pSelf );
}
classes.c4591
HB_FUNC__CLS_PARAM(void)
HB_FUNC( __CLS_PARAM )
{
   PHB_ITEM array;
   USHORT uiParam = ( USHORT ) hb_pcount();
   USHORT n;

   if( uiParam >= 1 )
   {
      array = hb_itemArrayNew( uiParam );
      for( n = 1; n <= uiParam; n++ )
         hb_arraySet( array, n, hb_param( n, HB_IT_ANY ) );
   }
   else
   {
      array = hb_itemArrayNew( 1 );
      hb_arraySetC( array, 1, "HBObject" );
   }

   hb_itemReturnRelease( array );
}
classes.c4601
HB_FUNC__CLS_PAR00(void)
HB_FUNC( __CLS_PAR00 )
{
   PHB_ITEM array;
   USHORT uiParam = ( USHORT ) hb_pcount();
   USHORT n;

   array = hb_itemArrayNew( uiParam );
   for( n = 1; n <= uiParam; n++ )
      hb_arraySet( array, n, hb_param( n, HB_IT_ANY ) );

   hb_itemReturnRelease( array );
}

/*
 * This function is only for backward binary compatibility
 * It will be removed in the future so please do not use it.
 * Use hb_objHasMessage() instead.
 */
#if defined(__cplusplus)
   extern "C" BOOL hb_objGetpMethod( PHB_ITEM pObject, PHB_SYMB pMessage );
classes.c4627
BOOLhb_objGetpMethod( PHB_ITEM pObject, PHB_SYMB pMessage )
BOOL hb_objGetpMethod( PHB_ITEM pObject, PHB_SYMB pMessage )
{
   return hb_objHasMessage( pObject, pMessage->pDynSym );
}
classes.c4648
CONST CHAR *hb_clsRealMethodName( void )
const char * hb_clsRealMethodName( void )
{
   LONG lOffset = hb_stackBaseProcOffset( 1 );
   const char * szName = NULL;

   if( lOffset > 0 )
   {
      PHB_STACK_STATE pStack = hb_stackItem( lOffset )->item.asSymbol.stackstate;

      if( pStack->uiClass && pStack->uiClass <= s_uiClasses )
      {
         PCLASS pClass = s_pClasses[ pStack->uiClass ];

         if( ( ULONG ) pStack->uiMethod < hb_clsMthNum( pClass ) )
         {
            PMETHOD pMethod = pClass->pMethods + pStack->uiMethod;

            if( pMethod->pMessage )
               szName = pMethod->pMessage->pSymbol->szName;
         }
      }
   }
   return szName;
}
classes.c4656
cmdarg.c
TypeFunctionSourceLine
HB_EXTERN_END HB_EXPORT VOIDhb_winmainArgInit( HANDLE hInstance, HANDLE hPrevInstance, int iCmdShow )
HB_EXPORT void hb_winmainArgInit( HANDLE hInstance, HANDLE hPrevInstance, int iCmdShow )
{
   s_hInstance = hInstance;
   s_hPrevInstance = hPrevInstance;
   s_iCmdShow = iCmdShow;
   s_WinMainParam = TRUE;
}
cmdarg.c89
HB_EXPORT BOOLhb_winmainArgGet( HANDLE * phInstance, HANDLE * phPrevInstance, int * piCmdShow )
HB_EXPORT BOOL hb_winmainArgGet( HANDLE * phInstance, HANDLE * phPrevInstance, int * piCmdShow )
{
   if( phInstance )
      *phInstance = s_hInstance;
   if( phPrevInstance )
      *phPrevInstance = s_hPrevInstance;
   if( piCmdShow )
      *piCmdShow = s_iCmdShow;

   return s_WinMainParam;
}
cmdarg.c97
HB_EXPORT VOIDhb_cmdargInit( int argc, char * argv[] )
HB_EXPORT void hb_cmdargInit( int argc, char * argv[] )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_cmdargInit(%d, %p)", argc, argv));

   s_argc = argc;
   s_argv = argv;
}
cmdarg.c111
INThb_cmdargARGC( void )
int hb_cmdargARGC( void )
{
   return s_argc;
}
cmdarg.c119
CHAR **hb_cmdargARGV( void )
char ** hb_cmdargARGV( void )
{
   return s_argv;
}
cmdarg.c124
BOOLhb_cmdargIsInternal( const char * szArg, int * piLen )
BOOL hb_cmdargIsInternal( const char * szArg, int * piLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_cmdargIsInternal(%s, %p)", szArg, piLen));

   /* NOTE: Not checking for '--' here, as it would filter out 
            valid command line options used by applications. [vszakats] */

   if( hb_strnicmp( szArg, "--hb:", 5 ) == 0 ||
       hb_strnicmp( szArg, "//hb:", 5 ) == 0 )
   {
      if( piLen )
         *piLen = 5;

      return TRUE;
   }
   else if( strlen( szArg ) >= 2 && 
            szArg[ 0 ] == '/' && 
            szArg[ 1 ] == '/' )
   {
      if( piLen )
         *piLen = 2;

      return TRUE;
   }

   return FALSE;
}
cmdarg.c129
STATIC CHAR *hb_cmdargGet( const char * pszName, BOOL bRetValue )
static char * hb_cmdargGet( const char * pszName, BOOL bRetValue )
{
   char * pszRetVal = NULL;
   char * pszEnvVar;
   int i;
   int iPrefixLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_cmdargGet(%s, %d)", pszName, (int) bRetValue));

   /* Check the command line first */

   for( i = 1; i < s_argc; i++ )
   {
      if( hb_cmdargIsInternal( s_argv[ i ], &iPrefixLen ) &&
         hb_strnicmp( s_argv[ i ] + iPrefixLen, pszName, strlen( pszName ) ) == 0 )
      {
         if( bRetValue )
         {
            char * pszPos = s_argv[ i ] + iPrefixLen + strlen( pszName );

            if( *pszPos == ':' )
               pszPos++;

            return hb_strdup( pszPos );
         }
         else
            return ( char * ) "";
      }
   }

   /* Check the environment variable */
   pszEnvVar = hb_getenv( "HARBOUR" );
   if( !pszEnvVar || pszEnvVar[ 0 ] == '\0' )
   {
      if( pszEnvVar )
         hb_xfree( ( void * ) pszEnvVar );

      pszEnvVar = hb_getenv( "CLIPPER" );
   }

   if( pszEnvVar && pszEnvVar[ 0 ] != '\0' )
   {
      char * pszNext = pszEnvVar;

      /* Step through all envvar switches. */

      /* NOTE: CA-Cl*pper doesn't need the switches to be separated by any
               chars at all, Harbour is more strict/standard in this respect,
               it requires the switches to be separated. */

      i = strlen( pszName );
      while( *pszNext )
      {
         static const char * szSeparator = " ;,\t";
         char * pszEnd;

         /* Skip the separators */
         while( *pszNext && strchr( szSeparator, *pszNext ) )
            pszNext++;

         /* The // is optional in the envvar */
         if( hb_cmdargIsInternal( pszNext, &iPrefixLen ) )
            pszNext += iPrefixLen;

         pszEnd = pszNext;
         /* Search for the end of this switch */
         while( *pszEnd && strchr( szSeparator, *pszEnd ) == NULL )
            pszEnd++;

         /* Check the switch */
         if( hb_strnicmp( pszNext, pszName, i ) == 0 )
         {
            if( bRetValue )
            {
               ULONG ulLen;
               pszNext += i;

               /* Skip value separator colon. */
               if( *pszNext == ':' )
                  pszNext++;

               ulLen = pszEnd > pszNext ? pszEnd - pszNext : 0;
               pszRetVal = ( char * ) hb_xgrab( ulLen + 1 );
               hb_strncpy( pszRetVal, pszNext, ulLen );
            }
            else
               pszRetVal = ( char * ) "";
            break;
         }

         /* Step to the next switch */
         pszNext = pszEnd;
      }
   }

   if( pszEnvVar )
      hb_xfree( ( void * ) pszEnvVar );

   return pszRetVal;
}
cmdarg.c157
BOOLhb_cmdargCheck( const char * pszName )
BOOL hb_cmdargCheck( const char * pszName )
{
   return hb_cmdargGet( pszName, FALSE ) != NULL;
}
cmdarg.c258
CHAR *hb_cmdargString( const char * pszName )
char * hb_cmdargString( const char * pszName )
{
   return hb_cmdargGet( pszName, TRUE );
}
cmdarg.c265
INThb_cmdargNum( const char * pszName )
int hb_cmdargNum( const char * pszName )
{
   char * pszValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_cmdargNum(%s)", pszName));

   pszValue = hb_cmdargGet( pszName, TRUE );
   if( pszValue )
   {
      int iValue = atoi( pszValue );

      hb_xfree( pszValue );

      return iValue;
   }
   else
      return -1;
}
cmdarg.c270
HB_FUNCHB_ARGCHECK(void)
HB_FUNC( HB_ARGCHECK )
{
   hb_retl( ISCHAR( 1 ) ? hb_cmdargCheck( hb_parc( 1 ) ) : FALSE );
}
cmdarg.c291
HB_FUNCHB_ARGSTRING(void)
HB_FUNC( HB_ARGSTRING )
{
   if( ISCHAR( 1 ) )
   {
      char * pszValue = hb_cmdargString( hb_parc( 1 ) );

      if( pszValue )
      {
         hb_retc( pszValue );
         hb_xfree( pszValue );
      }
   }
   else
      hb_retc( NULL );
}
cmdarg.c298
HB_FUNCHB_ARGC(void)
HB_FUNC( HB_ARGC )
{
   hb_retni( s_argc - 1 );
}
cmdarg.c317
HB_FUNCHB_ARGV(void)
HB_FUNC( HB_ARGV )
{
   if( ISNUM( 1 ) )
   {
      int argc = hb_parni( 1 );

      hb_retc( ( argc >= 0 && argc < s_argc ) ? s_argv[ argc ] : NULL );
   }
   else
      hb_retc( NULL );
}
cmdarg.c326
ULONGhb_cmdargProcessVM( int *pCancelKey, int *pCancelKeyEx )
ULONG hb_cmdargProcessVM( int *pCancelKey, int *pCancelKeyEx )
{
   char * cFlags;
   ULONG ulFlags = HB_VMFLAG_HARBOUR;

   if( hb_cmdargCheck( "INFO" ) )
   {
      {
         char * pszVersion = hb_verHarbour();
         hb_conOutErr( pszVersion, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
         hb_xfree( pszVersion );
      }

      {
         char * pszVersion = hb_verPlatform();
         hb_conOutErr( pszVersion, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
         hb_xfree( pszVersion );
      }

      {
         char buffer[ 128 ];
#if defined(HB_C52_STRICT)
         snprintf( buffer, sizeof( buffer ), "DS avail=%luKB  OS avail=%luKB  EMM avail=%luKB", hb_xquery( HB_MEM_BLOCK ), hb_xquery( HB_MEM_VM ), hb_xquery( HB_MEM_EMS ) );
#else
         snprintf( buffer, sizeof( buffer ), "DS avail=%luKB  OS avail=%luKB  EMM avail=%luKB  MemStat:%s  MT:%s", hb_xquery( HB_MEM_BLOCK ), hb_xquery( HB_MEM_VM ), hb_xquery( HB_MEM_EMS ), hb_xquery( HB_MEM_USEDMAX ) ? "On" : "Off", hb_vmIsMt() ? "On" : "Off" );
#endif
         hb_conOutErr( buffer, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
      }
   }

   if( hb_cmdargCheck( "BUILD" ) )
      hb_verBuildInfo();

   if( ( cFlags = hb_cmdargString( "FLAGS" ) ) != NULL ) 
   {
      int i = 0;
      while( cFlags[ i ] )
      {
         switch( cFlags[ i++ ] )
         {
            case 'c':
               /* clear all flags - minimal set of features */
               ulFlags = 0;
               break;

            case 'h':
               /* default Harbour mode */
               ulFlags |= HB_VMFLAG_HARBOUR;
               break;
/*
            case 'x':
               ulFlags |= HB_VMFLAG_XBASE;
               break;

            case 'r':
               ulFlags |= HB_VMFLAG_RT_MACRO;
               break;
*/
            case 's':
               ulFlags |= HB_VMFLAG_ARRSTR;
               break;
         }
      }
      hb_xfree( cFlags );
   }

   if( ( cFlags = hb_cmdargString( "CANCEL" ) ) != NULL ) 
   {
      int iVal = atoi( cFlags );
      if( iVal )
         *pCancelKey = iVal;
      hb_xfree( cFlags );
   }

   if( ( cFlags = hb_cmdargString( "CANCELEX" ) ) != NULL ) 
   {
      int iVal = atoi( cFlags );
      if( iVal )
         *pCancelKeyEx = iVal;
      hb_xfree( cFlags );
   }

   return ulFlags;
}
cmdarg.c338
INThb_verSvnID( void )
int hb_verSvnID( void )
{
   return HB_VER_SVNID;
}
cmdarg.c427
CONST CHAR *hb_verSvnChangeLogID( void )
const char * hb_verSvnChangeLogID( void )
{
   return HB_VER_CHLID;
}
cmdarg.c433
CONST CHAR *hb_verSvnLastEntry( void )
const char * hb_verSvnLastEntry( void )
{
   return HB_VER_LENTRY;
}
cmdarg.c439
CONST CHAR *hb_verFlagsC( void )
const char * hb_verFlagsC( void )
{
#ifdef HB_VER_C_USR
   return HB_VER_C_USR;
#else
   return "";
#endif
}
cmdarg.c445
CONST CHAR *hb_verFlagsL( void )
const char * hb_verFlagsL( void )
{
#ifdef HB_VER_L_USR
   return HB_VER_L_USR;
#else
   return "";
#endif
}
cmdarg.c455
CONST CHAR *hb_verFlagsPRG( void )
const char * hb_verFlagsPRG( void )
{
#ifdef HB_VER_PRG_USR
   return HB_VER_PRG_USR;
#else
   return "";
#endif
}
cmdarg.c465
codebloc.c
TypeFunctionSourceLine
STATIC HB_GARBAGE_FUNC(hb_codeblockDeleteGarbage )
static HB_GARBAGE_FUNC( hb_codeblockDeleteGarbage )
{
   HB_CODEBLOCK_PTR pCBlock = ( HB_CODEBLOCK_PTR ) Cargo;

   HB_TRACE(HB_TR_DEBUG, ("hb_codeblockDeleteGarbage(%p)", Cargo));

   /* free space allocated for pcodes - if it was a macro-compiled codeblock
    */
   if( pCBlock->pCode && pCBlock->dynBuffer )
   {
      pCBlock->dynBuffer = FALSE;
      hb_xfree( pCBlock->pCode );
   }
   pCBlock->pCode = ( BYTE * ) s_pCode;

   /* free space allocated for local variables
    */
   if( pCBlock->pLocals )
   {
      PHB_ITEM pLocals = pCBlock->pLocals;
      USHORT uiLocals = pCBlock->uiLocals;

      /* clear pCBlock->pLocals to avoid infinit loop in cross
       * referenced items
       */
      pCBlock->pLocals = NULL;
      pCBlock->uiLocals = 0;

      if( hb_xRefDec( pLocals ) )
      {
         while( uiLocals )
            hb_memvarValueDecRef( pLocals[ uiLocals-- ].item.asMemvar.value );
         hb_xfree( pLocals );
      }
   }
}
codebloc.c68
HB_CODEBLOCK_PTRhb_codeblockNew( const BYTE * pBuffer, USHORT uiLocals, const BYTE * pLocalPosTable, PHB_SYMB pSymbols, ULONG ulLen )
HB_CODEBLOCK_PTR hb_codeblockNew( const BYTE * pBuffer,
                                  USHORT uiLocals,
                                  const BYTE * pLocalPosTable,
                                  PHB_SYMB pSymbols,
                                  ULONG ulLen )
{
   HB_CODEBLOCK_PTR pCBlock;
   PHB_ITEM pLocals;
   BYTE * pCode;

   HB_TRACE(HB_TR_DEBUG, ("hb_codeblockNew(%p, %hu, %p, %p, %lu)", pBuffer, uiLocals, pLocalPosTable, pSymbols, ulLen));

   /*
    * allocate memory for code block body and detach items hb_gcAlloc()
    * to be safe for automatic GC activation in hb_xgrab() without
    * calling hb_gcLock()/hb_gcUnlock(). [druzus]
    */

   if( ulLen )
   {
      /*
       * The codeblock pcode is stored in dynamically allocated memory that
       * can be deallocated after creation of a codeblock. We have to duplicate
       * the passed buffer
       */
      pCode = ( BYTE * ) hb_xgrab( ulLen );
      memcpy( pCode, pBuffer, ulLen );
   }
   else
   {
      /*
       * The codeblock pcode is stored in static segment.
       * The only allowed operation on a codeblock is evaluating it then
       * there is no need to duplicate its pcode - just store the pointer to it
       */
      pCode     = ( BYTE * ) pBuffer;
   }

   if( uiLocals )
   {
      /* NOTE: if a codeblock will be created by macro compiler then
       * uiLocal have to be ZERO
       * uiLocal will be also ZERO if it is a nested codeblock
       */
      USHORT ui = 1;
      PHB_ITEM pLocal;

      /* Create a table that will store the values of local variables
       * accessed in a codeblock
       * The element 0 is unused
       * NOTE: This table can be shared by codeblocks created during
       * evaluation of this codeblock
       */
      pLocals = ( PHB_ITEM ) hb_xgrab( ( uiLocals + 1 ) * sizeof( HB_ITEM ) );
      pLocals[ 0 ].type = HB_IT_NIL;

      do
      {
         /* Swap the current value of local variable with the reference to this
          * value.
          * TODO: If Harbour will support threads in the future then we need
          * to implement some kind of semaphores here.
          */
         int iLocal = HB_PCODE_MKUSHORT( pLocalPosTable );
         pLocal = hb_stackLocalVariable( &iLocal );
         pLocalPosTable += 2;

         pLocal = hb_memvarDetachLocal( pLocal );
         memcpy( pLocals + ui, pLocal, sizeof( HB_ITEM ) );
         /* Increment the reference counter so this value will not be
          * released if other codeblock will be deleted
          */
         hb_memvarValueIncRef( pLocal->item.asMemvar.value );
      }
      while( ++ui <= uiLocals );
   }
   else
   {
      /* Check if this codeblock is created during evaluation of another
       * codeblock - all inner codeblocks use the local variables table
       * created during creation of the outermost codeblock
       */
      PHB_ITEM pLocal;

      pLocal = hb_stackSelfItem();
      if( HB_IS_BLOCK( pLocal ) )
      {
         HB_CODEBLOCK_PTR pOwner = pLocal->item.asBlock.value;

         uiLocals = pOwner->uiLocals;
         pLocals  = pOwner->pLocals;
         if( pLocals )
            hb_xRefInc( pLocals );
      }
      else
         pLocals = NULL;
   }

   pCBlock = ( HB_CODEBLOCK_PTR ) hb_gcAlloc( sizeof( HB_CODEBLOCK ), hb_codeblockDeleteGarbage );

   pCBlock->pCode     = pCode;
   pCBlock->dynBuffer = ulLen != 0;
   pCBlock->pDefSymb  = hb_stackBaseItem()->item.asSymbol.value;
   pCBlock->pSymbols  = pSymbols;
   pCBlock->lStatics  = hb_stackGetStaticsBase();
   pCBlock->uiLocals  = uiLocals;
   pCBlock->pLocals   = pLocals;

   HB_TRACE(HB_TR_INFO, ("codeblock created %p", pCBlock));

   return pCBlock;
}
codebloc.c107
HB_CODEBLOCK_PTRhb_codeblockMacroNew( const BYTE * pBuffer, ULONG ulLen )
HB_CODEBLOCK_PTR hb_codeblockMacroNew( const BYTE * pBuffer, ULONG ulLen )
{
   HB_CODEBLOCK_PTR pCBlock;
   BYTE * pCode;

   HB_TRACE(HB_TR_DEBUG, ("hb_codeblockMacroNew(%p, %lu)", pBuffer, ulLen));

   /*
    * The codeblock pcode is stored in dynamically allocated memory that
    * can be deallocated after creation of a codeblock. We have to duplicate
    * the passed buffer
    */
   /*
    * allocate memory for code block body and detach items hb_gcAlloc()
    * to be safe for automatic GC activation in hb_xgrab() without
    * calling hb_gcLock()/hb_gcUnlock(). [druzus]
    */
   pCode = ( BYTE * ) hb_xgrab( ulLen );
   memcpy( pCode, pBuffer, ulLen );

   pCBlock = ( HB_CODEBLOCK_PTR ) hb_gcAlloc( sizeof( HB_CODEBLOCK ), hb_codeblockDeleteGarbage );
   /* Store the number of referenced local variables */
   pCBlock->pCode     = pCode;
   pCBlock->dynBuffer = TRUE;
   pCBlock->pDefSymb  = hb_stackBaseItem()->item.asSymbol.value;
   pCBlock->pSymbols  = NULL; /* macro-compiled codeblock cannot acces a local symbol table */
   pCBlock->lStatics  = hb_stackGetStaticsBase();
   pCBlock->uiLocals  = 0;
   pCBlock->pLocals   = NULL;

   HB_TRACE(HB_TR_INFO, ("codeblock created %p", pCBlock));

   return pCBlock;
}
codebloc.c230
VOIDhb_codeblockEvaluate( HB_ITEM_PTR pItem )
void hb_codeblockEvaluate( HB_ITEM_PTR pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_codeblockEvaluate(%p)", pItem));

   hb_stackSetStaticsBase( pItem->item.asBlock.value->lStatics );
   hb_vmExecute( pItem->item.asBlock.value->pCode, pItem->item.asBlock.value->pSymbols );
}
codebloc.c265
PHB_ITEMhb_codeblockGetVar( PHB_ITEM pItem, LONG iItemPos )
PHB_ITEM  hb_codeblockGetVar( PHB_ITEM pItem, LONG iItemPos )
{
   HB_CODEBLOCK_PTR pCBlock = pItem->item.asBlock.value;

   HB_TRACE(HB_TR_DEBUG, ("hb_codeblockGetVar(%p, %ld)", pItem, iItemPos));

   /* local variables accessed in a codeblock are always stored as reference */
   return hb_itemUnRef( pCBlock->pLocals - iItemPos );
}
codebloc.c279
PHB_ITEMhb_codeblockGetRef( HB_CODEBLOCK_PTR pCBlock, LONG iItemPos )
PHB_ITEM  hb_codeblockGetRef( HB_CODEBLOCK_PTR pCBlock, LONG iItemPos )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_codeblockGetRef(%p, %ld)", pCBlock, iItemPos));

   return pCBlock->pLocals - iItemPos;
}
codebloc.c291
HB_EXPORT VOID *hb_codeblockId( PHB_ITEM pItem )
HB_EXPORT void * hb_codeblockId( PHB_ITEM pItem )
{
   if( HB_IS_BLOCK( pItem ) )
      return ( void * ) pItem->item.asBlock.value;
   else
      return NULL;
}
codebloc.c300
debug.c
TypeFunctionSourceLine
STATIC VOIDAddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, ULONG ulPos )
static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, ULONG ulPos )
{
   HB_TRACE(HB_TR_DEBUG, ("AddToArray(%p, %p, %lu)", pItem, pReturn, ulPos));

   if( HB_IS_SYMBOL( pItem ) )
   {                                            /* Symbol is pushed as text */
      PHB_ITEM pArrayItem = hb_arrayGetItemPtr( pReturn, ulPos );

      if( pArrayItem )
      {
         ULONG ulLen = strlen( pItem->item.asSymbol.value->szName ) + 2;
         char * szBuff = ( char * ) hb_xgrab( ulLen + 1 );

         snprintf( szBuff, ulLen + 1, "[%s]", pItem->item.asSymbol.value->szName );
         hb_itemPutCLPtr( pArrayItem, szBuff, ulLen );
      }
   }
   else                                         /* Normal types             */
      hb_itemArrayPut( pReturn, ulPos, pItem );
}
debug.c60
HB_FUNC__DBGVMSTKGCOUNT(void)
HB_FUNC( __DBGVMSTKGCOUNT )
{
   hb_retnl( hb_stackTopOffset() );
}
debug.c85
HB_FUNC__DBGVMSTKGLIST(void)
HB_FUNC( __DBGVMSTKGLIST )
{
   PHB_ITEM pReturn;
   ULONG ulLen = hb_stackTopOffset();
   ULONG ulPos;

   pReturn = hb_itemArrayNew( ulLen );           /* Create a transfer array  */

   for( ulPos = 0; ulPos < ulLen; ++ulPos )
   {
      AddToArray( hb_stackItem( ulPos ), pReturn, ulPos + 1 );
   }
   hb_itemReturnRelease( pReturn );
}
debug.c94
STATIC LONGhb_stackLen( int iLevel )
static LONG hb_stackLen( int iLevel )
{
   LONG lBaseOffset, lPrevOffset, lLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_stackLen()"));

   lBaseOffset = hb_stackBaseOffset();
   while( --iLevel > 0 && lBaseOffset > 1 )
      lBaseOffset = hb_stackItem( lBaseOffset - 1 )->item.asSymbol.stackstate->lBaseItem + 1;

   if( lBaseOffset > 1 )
   {
      lPrevOffset = hb_stackItem( lBaseOffset - 1 )->item.asSymbol.stackstate->lBaseItem;
      lLen = lBaseOffset - lPrevOffset - 3;
   }
   else
      lLen = 0;

   return lLen;
}
debug.c113
HB_FUNC__DBGVMSTKLCOUNT(void)
HB_FUNC( __DBGVMSTKLCOUNT )
{
   hb_retnl( hb_stackLen( hb_parni( 1 ) + 1 ) );
}
debug.c138
HB_FUNC__DBGVMSTKLLIST(void)
HB_FUNC( __DBGVMSTKLLIST )
{
   PHB_ITEM pReturn;
   ULONG ulLen, ul;
   LONG lBaseOffset, lPrevOffset;

   lBaseOffset = hb_stackBaseOffset();
   lPrevOffset = hb_stackItem( lBaseOffset - 1 )->item.asSymbol.stackstate->lBaseItem;

   ulLen = lBaseOffset - lPrevOffset - 3;
   pReturn = hb_itemArrayNew( ulLen );           /* Create a transfer array  */
   for( ul = 0; ul < ulLen; ++ul )
      AddToArray( hb_stackItem( lPrevOffset + ul ), pReturn, ul + 1 );

   hb_itemReturnRelease( pReturn );
}
debug.c147
HB_FUNC__DBGVMPARLLIST(void)
               /* somewhere for declared parameters */
               /* and locals                        */
HB_FUNC( __DBGVMPARLLIST )
{
   hb_itemReturnRelease( hb_arrayFromParams( hb_parni( 1 ) + 1 ) );
}
debug.c175
HB_EXPORT PHB_ITEMhb_dbg_vmVarLGet( int iLevel, int iLocal )
HB_EXPORT PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal )
{
   PHB_ITEM pLocal = NULL;
   LONG lBaseOffset;

   lBaseOffset = hb_stackBaseOffset();
   while( iLevel-- > 0 && lBaseOffset > 1 )
      lBaseOffset = hb_stackItem( lBaseOffset - 1 )->item.asSymbol.stackstate->lBaseItem + 1;

   if( iLevel < 0 )
   {
      if( iLocal > SHRT_MAX )
      {
         iLocal -= USHRT_MAX;
         iLocal--;
      }

      if( iLocal >= 0 )
      {
         PHB_ITEM pBase = hb_stackItem( lBaseOffset - 1 );

         if( pBase->item.asSymbol.paramcnt > pBase->item.asSymbol.paramdeclcnt &&
             iLocal > pBase->item.asSymbol.paramdeclcnt )
            iLocal += pBase->item.asSymbol.paramcnt - pBase->item.asSymbol.paramdeclcnt;

         pLocal = hb_stackItem( lBaseOffset + iLocal );
      }
      else
         pLocal = hb_codeblockGetRef( hb_stackItem( lBaseOffset )->item.asBlock.value, iLocal );

      if( HB_IS_BYREF( pLocal ) )
         pLocal = hb_itemUnRef( pLocal );
   }

   return pLocal;
}
debug.c187
HB_FUNC__DBGVMVARLGET(void)
HB_FUNC( __DBGVMVARLGET )
{
   int iLevel = hb_parni( 1 ) + 1;
   int iLocal = hb_parni( 2 );
   PHB_ITEM pLocal = hb_dbg_vmVarLGet( iLevel, iLocal );

   if( pLocal )
      hb_itemReturn( pLocal );
   else
      hb_errRT_BASE( EG_ARG, 6005, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
debug.c224
HB_FUNC__DBGVMVARLSET(void)
HB_FUNC( __DBGVMVARLSET )
{
   int iLevel = hb_parni( 1 ) + 1;
   int iLocal = hb_parni( 2 );
   LONG lBaseOffset;
   PHB_ITEM pLocal;

   lBaseOffset = hb_stackBaseOffset();
   while( iLevel-- > 0 && lBaseOffset > 1 )
      lBaseOffset = hb_stackItem( lBaseOffset - 1 )->item.asSymbol.stackstate->lBaseItem + 1;

   if( iLevel < 0 )
   {
      if( iLocal > SHRT_MAX )
      {
         iLocal -= USHRT_MAX;
         iLocal--;
      }

      if( iLocal >= 0 )
      {
         PHB_ITEM pBase = hb_stackItem( lBaseOffset - 1 );

         if( pBase->item.asSymbol.paramcnt > pBase->item.asSymbol.paramdeclcnt &&
             iLocal > pBase->item.asSymbol.paramdeclcnt )
            iLocal += pBase->item.asSymbol.paramcnt - pBase->item.asSymbol.paramdeclcnt;

         pLocal = hb_stackItem( lBaseOffset + iLocal );
      }
      else
         pLocal = hb_codeblockGetRef( hb_stackItem( lBaseOffset )->item.asBlock.value, iLocal );

      hb_itemCopyToRef( pLocal, hb_stackItemFromBase( 3 ) );
   }
}
debug.c236
debugold.c
TypeFunctionSourceLine
HB_FUNCHB_DBG_VMSTKLCOUNT(void)
HB_FUNC( HB_DBG_VMSTKLCOUNT )
{
   HB_FUNC_EXEC( __DBGVMSTKLCOUNT );
}

HB_FUNC_EXTERN( __DBGVMPARLLIST );
debugold.c59
HB_FUNCHB_DBG_VMPARLLIST(void)
HB_FUNC( HB_DBG_VMPARLLIST )
{
   HB_FUNC_EXEC( __DBGVMPARLLIST );
}

HB_FUNC_EXTERN( __DBGVMVARLGET );
debugold.c66
HB_FUNCHB_DBG_VMVARLGET(void)
HB_FUNC( HB_DBG_VMVARLGET )
{
   HB_FUNC_EXEC( __DBGVMVARLGET );
}

HB_FUNC_EXTERN( __DBGVMVARSLEN );
debugold.c73
HB_FUNCHB_DBG_VMVARSLEN(void)
HB_FUNC( HB_DBG_VMVARSLEN )
{
   HB_FUNC_EXEC( __DBGVMVARSLEN );
}

#if 0

HB_FUNC_EXTERN( __DBGVMSTKLLIST );
debugold.c80
HB_FUNCHB_DBG_VMSTKLLIST(void)
HB_FUNC( HB_DBG_VMSTKLLIST )
{
   HB_FUNC_EXEC( __DBGVMSTKLLIST );
}

HB_FUNC_EXTERN( __DBGVMVARLSET );
debugold.c89
HB_FUNCHB_DBG_VMVARLSET(void)
HB_FUNC( HB_DBG_VMVARLSET )
{
   HB_FUNC_EXEC( __DBGVMVARLSET );
}

HB_FUNC_EXTERN( __DBGVMSTKGLIST );
debugold.c96
HB_FUNCHB_DBG_VMSTKGLIST(void)
HB_FUNC( HB_DBG_VMSTKGLIST )
{
   HB_FUNC_EXEC( __DBGVMSTKGLIST );
}

HB_FUNC_EXTERN( __DBGVMSTKGCOUNT );
debugold.c103
HB_FUNCHB_DBG_VMSTKGCOUNT(void)
HB_FUNC( HB_DBG_VMSTKGCOUNT )
{
   HB_FUNC_EXEC( __DBGVMSTKGCOUNT );
}

HB_FUNC_EXTERN( __DBGVMVARGLIST );
debugold.c110
HB_FUNCHB_DBG_VMVARGLIST(void)
HB_FUNC( HB_DBG_VMVARGLIST )
{
   HB_FUNC_EXEC( __DBGVMVARGLIST );
}

HB_FUNC_EXTERN( __DBGVMVARSLIST );
debugold.c117
HB_FUNCHB_DBG_VMVARSLIST(void)
HB_FUNC( HB_DBG_VMVARSLIST )
{
   HB_FUNC_EXEC( __DBGVMVARSLIST );
}

HB_FUNC_EXTERN( __DBGVMVARSGET );
debugold.c124
HB_FUNCHB_DBG_VMVARSGET(void)
HB_FUNC( HB_DBG_VMVARSGET )
{
   HB_FUNC_EXEC( __DBGVMVARSGET );
}

HB_FUNC_EXTERN( __DBGVMVARSSET );
debugold.c131
HB_FUNCHB_DBG_VMVARSSET(void)
HB_FUNC( HB_DBG_VMVARSSET )
{
   HB_FUNC_EXEC( __DBGVMVARSSET );
}
debugold.c138
dlmalloc.c
TypeFunctionSourceLine
STATIC VOID*win32mmap(size_t size)
static void* win32mmap(size_t size) {
  void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
  return (ptr != 0)? ptr: MFAIL;
}
dlmalloc.c1316
STATIC VOID*win32direct_mmap(size_t size)
static void* win32direct_mmap(size_t size) {
  void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN,
                           PAGE_READWRITE);
  return (ptr != 0)? ptr: MFAIL;
}
dlmalloc.c1322
STATIC INTwin32munmap(void* ptr, size_t size)
static int win32munmap(void* ptr, size_t size) {
  MEMORY_BASIC_INFORMATION minfo;
  char* cptr = ptr;
  while (size) {
    if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0)
      return -1;
    if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr ||
        minfo.State != MEM_COMMIT || minfo.RegionSize > size)
      return -1;
    if (VirtualFree(cptr, 0, MEM_RELEASE) == 0)
      return -1;
    cptr += minfo.RegionSize;
    size -= minfo.RegionSize;
  }
  return 0;
}

#define CALL_MMAP(s)         win32mmap(s)
#define CALL_MUNMAP(a, s)    win32munmap((a), (s))
#define DIRECT_MMAP(s)       win32direct_mmap(s)
#endif /* WIN32 */
#endif /* HAVE_MMAP */

#if HAVE_MMAP && HAVE_MREMAP
#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
#else  /* HAVE_MMAP && HAVE_MREMAP */
#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL
#endif /* HAVE_MMAP && HAVE_MREMAP */

#if HAVE_MORECORE
#define CALL_MORECORE(S)     MORECORE(S)
#else  /* HAVE_MORECORE */
#define CALL_MORECORE(S)     MFAIL
#endif /* HAVE_MORECORE */

/* mstate bit set if continguous morecore disabled or failed */
#define USE_NONCONTIGUOUS_BIT (4U)

/* segment bit set in create_mspace_with_base */
#define EXTERN_BIT            (8U)


/* --------------------------- Lock preliminaries ------------------------ */

#if USE_LOCKS

/*
  When locks are defined, there are up to two global locks:

  * If HAVE_MORECORE, morecore_mutex protects sequences of calls to
    MORECORE.  In many cases sys_alloc requires two calls, that should
    not be interleaved with calls by other threads.  This does not
    protect against direct calls to MORECORE by other threads not
    using this lock, so there is still code to cope the best we can on
    interference.

  * magic_init_mutex ensures that mparams.magic and other
    unique mparams values are initialized only once.
*/

#ifndef WIN32
/* By default use posix locks */
#include 
#define MLOCK_T pthread_mutex_t
#define INITIAL_LOCK(l)      pthread_mutex_init(l, NULL)
#define ACQUIRE_LOCK(l)      pthread_mutex_lock(l)
#define RELEASE_LOCK(l)      pthread_mutex_unlock(l)

#if HAVE_MORECORE
static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif /* HAVE_MORECORE */

static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
dlmalloc.c1329
STATIC INTwin32_acquire_lock (MLOCK_T *sl)
static int win32_acquire_lock (MLOCK_T *sl) {
  for (;;) {
#ifdef InterlockedCompareExchangePointer
    if (!InterlockedCompareExchange(sl, 1, 0))
      return 0;
#else  /* Use older void* version */
    if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0))
      return 0;
#endif /* InterlockedCompareExchangePointer */
    Sleep (0);
  }
}
dlmalloc.c1411
STATIC VOIDwin32_release_lock (MLOCK_T *sl)
static void win32_release_lock (MLOCK_T *sl) {
  InterlockedExchange (sl, 0);
}

#define INITIAL_LOCK(l)      *(l)=0
#define ACQUIRE_LOCK(l)      win32_acquire_lock(l)
#define RELEASE_LOCK(l)      win32_release_lock(l)
#if HAVE_MORECORE
static MLOCK_T morecore_mutex;
#endif /* HAVE_MORECORE */
static MLOCK_T magic_init_mutex;
#endif /* WIN32 */

#define USE_LOCK_BIT               (2U)
#else  /* USE_LOCKS */
#define USE_LOCK_BIT               (0U)
#define INITIAL_LOCK(l)
#endif /* USE_LOCKS */

#if USE_LOCKS && HAVE_MORECORE
#define ACQUIRE_MORECORE_LOCK()    ACQUIRE_LOCK(&morecore_mutex);
#define RELEASE_MORECORE_LOCK()    RELEASE_LOCK(&morecore_mutex);
#else /* USE_LOCKS && HAVE_MORECORE */
#define ACQUIRE_MORECORE_LOCK()
#define RELEASE_MORECORE_LOCK()
#endif /* USE_LOCKS && HAVE_MORECORE */

#if USE_LOCKS
#define ACQUIRE_MAGIC_INIT_LOCK()  ACQUIRE_LOCK(&magic_init_mutex);
#define RELEASE_MAGIC_INIT_LOCK()  RELEASE_LOCK(&magic_init_mutex);
#else  /* USE_LOCKS */
#define ACQUIRE_MAGIC_INIT_LOCK()
#define RELEASE_MAGIC_INIT_LOCK()
#endif /* USE_LOCKS */


/* -----------------------  Chunk representations ------------------------ */

/*
  (The following includes lightly edited explanations by Colin Plumb.)

  The malloc_chunk declaration below is misleading (but accurate and
  necessary).  It declares a "view" into memory allowing access to
  necessary fields at known offsets from a given base.

  Chunks of memory are maintained using a `boundary tag' method as
  originally described by Knuth.  (See the paper by Paul Wilson
  ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such
  techniques.)  Sizes of free chunks are stored both in the front of
  each chunk and at the end.  This makes consolidating fragmented
  chunks into bigger chunks fast.  The head fields also hold bits
  representing whether chunks are free or in use.

  Here are some pictures to make it clearer.  They are "exploded" to
  show that the state of a chunk can be thought of as extending from
  the high 31 bits of the head field of its header through the
  prev_foot and PINUSE_BIT bit of the following chunk header.

  A chunk that's in use looks like:

   chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
           | Size of previous chunk (if P = 1)                             |
           +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|
         | Size of this chunk                                         1| +-+
   mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                                                               |
         +-                                                             -+
         |                                                               |
         +-                                                             -+
         |                                                               :
         +-      size - sizeof(size_t) available payload bytes          -+
         :                                                               |
 chunk-> +-                                                             -+
         |                                                               |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1|
       | Size of next chunk (may or may not be in use)               | +-+
 mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

    And if it's free, it looks like this:

   chunk-> +-                                                             -+
           | User payload (must be in use, or we would have merged!)       |
           +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|
         | Size of this chunk                                         0| +-+
   mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         | Next pointer                                                  |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         | Prev pointer                                                  |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                                                               :
         +-      size - sizeof(struct chunk) unused bytes               -+
         :                                                               |
 chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         | Size of this chunk                                            |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0|
       | Size of next chunk (must be in use, or we would have merged)| +-+
 mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                                                               :
       +- User payload                                                -+
       :                                                               |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                                                     |0|
                                                                     +-+
  Note that since we always merge adjacent free chunks, the chunks
  adjacent to a free chunk must be in use.

  Given a pointer to a chunk (which can be derived trivially from the
  payload pointer) we can, in O(1) time, find out whether the adjacent
  chunks are free, and if so, unlink them from the lists that they
  are on and merge them with the current chunk.

  Chunks always begin on even word boundaries, so the mem portion
  (which is returned to the user) is also on an even word boundary, and
  thus at least double-word aligned.

  The P (PINUSE_BIT) bit, stored in the unused low-order bit of the
  chunk size (which is always a multiple of two words), is an in-use
  bit for the *previous* chunk.  If that bit is *clear*, then the
  word before the current chunk size contains the previous chunk
  size, and can be used to find the front of the previous chunk.
  The very first chunk allocated always has this bit set, preventing
  access to non-existent (or non-owned) memory. If pinuse is set for
  any given chunk, then you CANNOT determine the size of the
  previous chunk, and might even get a memory addressing fault when
  trying to do so.

  The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of
  the chunk size redundantly records whether the current chunk is
  inuse. This redundancy enables usage checks within free and realloc,
  and reduces indirection when freeing and consolidating chunks.

  Each freshly allocated chunk must have both cinuse and pinuse set.
  That is, each allocated chunk borders either a previously allocated
  and still in-use chunk, or the base of its memory arena. This is
  ensured by making all allocations from the the `lowest' part of any
  found chunk.  Further, no free chunk physically borders another one,
  so each free chunk is known to be preceded and followed by either
  inuse chunks or the ends of memory.

  Note that the `foot' of the current chunk is actually represented
  as the prev_foot of the NEXT chunk. This makes it easier to
  deal with alignments etc but can be very confusing when trying
  to extend or adapt this code.

  The exceptions to all this are

     1. The special chunk `top' is the top-most available chunk (i.e.,
        the one bordering the end of available memory). It is treated
        specially.  Top is never included in any bin, is used only if
        no other chunk is available, and is released back to the
        system if it is very large (see M_TRIM_THRESHOLD).  In effect,
        the top chunk is treated as larger (and thus less well
        fitting) than any other available chunk.  The top chunk
        doesn't update its trailing size field since there is no next
        contiguous chunk that would have to index off it. However,
        space is still allocated for it (TOP_FOOT_SIZE) to enable
        separation or merging when space is extended.

     3. Chunks allocated via mmap, which have the lowest-order bit
        (IS_MMAPPED_BIT) set in their prev_foot fields, and do not set
        PINUSE_BIT in their head fields.  Because they are allocated
        one-by-one, each must carry its own prev_foot field, which is
        also used to hold the offset this chunk has within its mmapped
        region, which is needed to preserve alignment. Each mmapped
        chunk is trailed by the first two fields of a fake next-chunk
        for sake of usage checks.

*/

struct malloc_chunk {
  size_t               prev_foot;  /* Size of previous chunk (if free).  */
  size_t               head;       /* Size and inuse bits. */
  struct malloc_chunk* fd;         /* double links -- used only if free. */
  struct malloc_chunk* bk;
};

typedef struct malloc_chunk  mchunk;
typedef struct malloc_chunk* mchunkptr;
typedef struct malloc_chunk* sbinptr;  /* The type of bins of chunks */
typedef unsigned int bindex_t;         /* Described below */
typedef unsigned int binmap_t;         /* Described below */
typedef unsigned int flag_t;           /* The type of various bit flag sets */

/* ------------------- Chunks sizes and alignments ----------------------- */

#define MCHUNK_SIZE         (sizeof(mchunk))

#if FOOTERS
#define CHUNK_OVERHEAD      (TWO_SIZE_T_SIZES)
#else /* FOOTERS */
#define CHUNK_OVERHEAD      (SIZE_T_SIZE)
#endif /* FOOTERS */

/* MMapped chunks need a second word of overhead ... */
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
/* ... and additional padding for fake next-chunk at foot */
#define MMAP_FOOT_PAD       (FOUR_SIZE_T_SIZES)

/* The smallest size we can malloc is an aligned minimal chunk */
#define MIN_CHUNK_SIZE\
  ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)

/* conversion from malloc headers to user pointers, and back */
#define chunk2mem(p)        ((void*)((char*)(p)       + TWO_SIZE_T_SIZES))
#define mem2chunk(mem)      ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))
/* chunk associated with aligned address A */
#define align_as_chunk(A)   (mchunkptr)((A) + align_offset(chunk2mem(A)))

/* Bounds on request (not chunk) sizes. */
#define MAX_REQUEST         ((-MIN_CHUNK_SIZE) << 2)
#define MIN_REQUEST         (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)

/* pad request bytes into a usable size */
#define pad_request(req) \
   (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)

/* pad request, checking for minimum (but not maximum) */
#define request2size(req) \
  (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))


/* ------------------ Operations on head and foot fields ----------------- */

/*
  The head field of a chunk is or'ed with PINUSE_BIT when previous
  adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in
  use. If the chunk was obtained with mmap, the prev_foot field has
  IS_MMAPPED_BIT set, otherwise holding the offset of the base of the
  mmapped region to the base of the chunk.
*/

#define PINUSE_BIT          (SIZE_T_ONE)
#define CINUSE_BIT          (SIZE_T_TWO)
#define INUSE_BITS          (PINUSE_BIT|CINUSE_BIT)

/* Head value for fenceposts */
#define FENCEPOST_HEAD      (INUSE_BITS|SIZE_T_SIZE)

/* extraction of fields from head words */
#define cinuse(p)           ((p)->head & CINUSE_BIT)
#define pinuse(p)           ((p)->head & PINUSE_BIT)
#define chunksize(p)        ((p)->head & ~(INUSE_BITS))

#define clear_pinuse(p)     ((p)->head &= ~PINUSE_BIT)
#define clear_cinuse(p)     ((p)->head &= ~CINUSE_BIT)

/* Treat space at ptr +/- offset as a chunk */
#define chunk_plus_offset(p, s)  ((mchunkptr)(((char*)(p)) + (s)))
#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s)))

/* Ptr to next or previous physical malloc_chunk. */
#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS)))
#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))

/* extract next chunk's pinuse bit */
#define next_pinuse(p)  ((next_chunk(p)->head) & PINUSE_BIT)

/* Get/set size at footer */
#define get_foot(p, s)  (((mchunkptr)((char*)(p) + (s)))->prev_foot)
#define set_foot(p, s)  (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))

/* Set size, pinuse bit, and foot */
#define set_size_and_pinuse_of_free_chunk(p, s)\
  ((p)->head = (s|PINUSE_BIT), set_foot(p, s))

/* Set size, pinuse bit, foot, and clear next pinuse */
#define set_free_with_pinuse(p, s, n)\
  (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))

#define is_mmapped(p)\
  (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))

/* Get the internal overhead associated with chunk p */
#define overhead_for(p)\
 (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)

/* Return true if malloced space is not necessarily cleared */
#if MMAP_CLEARS
#define calloc_must_clear(p) (!is_mmapped(p))
#else /* MMAP_CLEARS */
#define calloc_must_clear(p) (1)
#endif /* MMAP_CLEARS */

/* ---------------------- Overlaid data structures ----------------------- */

/*
  When chunks are not in use, they are treated as nodes of either
  lists or trees.

  "Small"  chunks are stored in circular doubly-linked lists, and look
  like this:

    chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of previous chunk                            |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    `head:' |             Size of chunk, in bytes                         |P|
      mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Forward pointer to next chunk in list             |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Back pointer to previous chunk in list            |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Unused space (may be 0 bytes long)                .
            .                                                               .
            .                                                               |
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    `foot:' |             Size of chunk, in bytes                           |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

  Larger chunks are kept in a form of bitwise digital trees (aka
  tries) keyed on chunksizes.  Because malloc_tree_chunks are only for
  free chunks greater than 256 bytes, their size doesn't impose any
  constraints on user chunk sizes.  Each node looks like:

    chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of previous chunk                            |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    `head:' |             Size of chunk, in bytes                         |P|
      mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Forward pointer to next chunk of same size        |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Back pointer to previous chunk of same size       |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Pointer to left child (child[0])                  |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Pointer to right child (child[1])                 |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Pointer to parent                                 |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             bin index of this chunk                           |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Unused space                                      .
            .                                                               |
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    `foot:' |             Size of chunk, in bytes                           |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

  Each tree holding treenodes is a tree of unique chunk sizes.  Chunks
  of the same size are arranged in a circularly-linked list, with only
  the oldest chunk (the next to be used, in our FIFO ordering)
  actually in the tree.  (Tree members are distinguished by a non-null
  parent pointer.)  If a chunk with the same size an an existing node
  is inserted, it is linked off the existing node using pointers that
  work in the same way as fd/bk pointers of small chunks.

  Each tree contains a power of 2 sized range of chunk sizes (the
  smallest is 0x100 <= x < 0x180), which is is divided in half at each
  tree level, with the chunks in the smaller half of the range (0x100
  <= x < 0x140 for the top nose) in the left subtree and the larger
  half (0x140 <= x < 0x180) in the right subtree.  This is, of course,
  done by inspecting individual bits.

  Using these rules, each node's left subtree contains all smaller
  sizes than its right subtree.  However, the node at the root of each
  subtree has no particular ordering relationship to either.  (The
  dividing line between the subtree sizes is based on trie relation.)
  If we remove the last chunk of a given size from the interior of the
  tree, we need to replace it with a leaf node.  The tree ordering
  rules permit a node to be replaced by any leaf below it.

  The smallest chunk in a tree (a common operation in a best-fit
  allocator) can be found by walking a path to the leftmost leaf in
  the tree.  Unlike a usual binary tree, where we follow left child
  pointers until we reach a null, here we follow the right child
  pointer any time the left one is null, until we reach a leaf with
  both child pointers null. The smallest chunk in the tree will be
  somewhere along that path.

  The worst case number of steps to add, find, or remove a node is
  bounded by the number of bits differentiating chunks within
  bins. Under current bin calculations, this ranges from 6 up to 21
  (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case
  is of course much better.
*/

struct malloc_tree_chunk {
  /* The first four fields must be compatible with malloc_chunk */
  size_t                    prev_foot;
  size_t                    head;
  struct malloc_tree_chunk* fd;
  struct malloc_tree_chunk* bk;

  struct malloc_tree_chunk* child[2];
  struct malloc_tree_chunk* parent;
  bindex_t                  index;
};

typedef struct malloc_tree_chunk  tchunk;
typedef struct malloc_tree_chunk* tchunkptr;
typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */

/* A little helper macro for trees */
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])

/* ----------------------------- Segments -------------------------------- */

/*
  Each malloc space may include non-contiguous segments, held in a
  list headed by an embedded malloc_segment record representing the
  top-most space. Segments also include flags holding properties of
  the space. Large chunks that are directly allocated by mmap are not
  included in this list. They are instead independently created and
  destroyed without otherwise keeping track of them.

  Segment management mainly comes into play for spaces allocated by
  MMAP.  Any call to MMAP might or might not return memory that is
  adjacent to an existing segment.  MORECORE normally contiguously
  extends the current space, so this space is almost always adjacent,
  which is simpler and faster to deal with. (This is why MORECORE is
  used preferentially to MMAP when both are available -- see
  sys_alloc.)  When allocating using MMAP, we don't use any of the
  hinting mechanisms (inconsistently) supported in various
  implementations of unix mmap, or distinguish reserving from
  committing memory. Instead, we just ask for space, and exploit
  contiguity when we get it.  It is probably possible to do
  better than this on some systems, but no general scheme seems
  to be significantly better.

  Management entails a simpler variant of the consolidation scheme
  used for chunks to reduce fragmentation -- new adjacent memory is
  normally prepended or appended to an existing segment. However,
  there are limitations compared to chunk consolidation that mostly
  reflect the fact that segment processing is relatively infrequent
  (occurring only when getting memory from system) and that we
  don't expect to have huge numbers of segments:

  * Segments are not indexed, so traversal requires linear scans.  (It
    would be possible to index these, but is not worth the extra
    overhead and complexity for most programs on most platforms.)
  * New segments are only appended to old ones when holding top-most
    memory; if they cannot be prepended to others, they are held in
    different segments.

  Except for the top-most segment of an mstate, each segment record
  is kept at the tail of its segment. Segments are added by pushing
  segment records onto the list headed by &mstate.seg for the
  containing mstate.

  Segment flags control allocation/merge/deallocation policies:
  * If EXTERN_BIT set, then we did not allocate this segment,
    and so should not try to deallocate or merge with others.
    (This currently holds only for the initial segment passed
    into create_mspace_with_base.)
  * If IS_MMAPPED_BIT set, the segment may be merged with
    other surrounding mmapped segments and trimmed/de-allocated
    using munmap.
  * If neither bit is set, then the segment was obtained using
    MORECORE so can be merged with surrounding MORECORE'd segments
    and deallocated/trimmed using MORECORE with negative arguments.
*/

struct malloc_segment {
  char*        base;             /* base address */
  size_t       size;             /* allocated size */
  struct malloc_segment* next;   /* ptr to next segment */
  flag_t       sflags;           /* mmap and extern flag */
};

#define is_mmapped_segment(S)  ((S)->sflags & IS_MMAPPED_BIT)
#define is_extern_segment(S)   ((S)->sflags & EXTERN_BIT)

typedef struct malloc_segment  msegment;
typedef struct malloc_segment* msegmentptr;

/* ---------------------------- malloc_state ----------------------------- */

/*
   A malloc_state holds all of the bookkeeping for a space.
   The main fields are:

  Top
    The topmost chunk of the currently active segment. Its size is
    cached in topsize.  The actual size of topmost space is
    topsize+TOP_FOOT_SIZE, which includes space reserved for adding
    fenceposts and segment records if necessary when getting more
    space from the system.  The size at which to autotrim top is
    cached from mparams in trim_check, except that it is disabled if
    an autotrim fails.

  Designated victim (dv)
    This is the preferred chunk for servicing small requests that
    don't have exact fits.  It is normally the chunk split off most
    recently to service another small request.  Its size is cached in
    dvsize. The link fields of this chunk are not maintained since it
    is not kept in a bin.

  SmallBins
    An array of bin headers for free chunks.  These bins hold chunks
    with sizes less than MIN_LARGE_SIZE bytes. Each bin contains
    chunks of all the same size, spaced 8 bytes apart.  To simplify
    use in double-linked lists, each bin header acts as a malloc_chunk
    pointing to the real first node, if it exists (else pointing to
    itself).  This avoids special-casing for headers.  But to avoid
    waste, we allocate only the fd/bk pointers of bins, and then use
    repositioning tricks to treat these as the fields of a chunk.

  TreeBins
    Treebins are pointers to the roots of trees holding a range of
    sizes. There are 2 equally spaced treebins for each power of two
    from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything
    larger.

  Bin maps
    There is one bit map for small bins ("smallmap") and one for
    treebins ("treemap).  Each bin sets its bit when non-empty, and
    clears the bit when empty.  Bit operations are then used to avoid
    bin-by-bin searching -- nearly all "search" is done without ever
    looking at bins that won't be selected.  The bit maps
    conservatively use 32 bits per map word, even if on 64bit system.
    For a good description of some of the bit-based techniques used
    here, see Henry S. Warren Jr's book "Hacker's Delight" (and
    supplement at http://hackersdelight.org/). Many of these are
    intended to reduce the branchiness of paths through malloc etc, as
    well as to reduce the number of memory locations read or written.

  Segments
    A list of segments headed by an embedded malloc_segment record
    representing the initial space.

  Address check support
    The least_addr field is the least address ever obtained from
    MORECORE or MMAP. Attempted frees and reallocs of any address less
    than this are trapped (unless INSECURE is defined).

  Magic tag
    A cross-check field that should always hold same value as mparams.magic.

  Flags
    Bits recording whether to use MMAP, locks, or contiguous MORECORE

  Statistics
    Each space keeps track of current and maximum system memory
    obtained via MORECORE or MMAP.

  Locking
    If USE_LOCKS is defined, the "mutex" lock is acquired and released
    around every public call using this mspace.
*/

/* Bin types, widths and sizes */
#define NSMALLBINS        (32U)
#define NTREEBINS         (32U)
#define SMALLBIN_SHIFT    (3U)
#define SMALLBIN_WIDTH    (SIZE_T_ONE << SMALLBIN_SHIFT)
#define TREEBIN_SHIFT     (8U)
#define MIN_LARGE_SIZE    (SIZE_T_ONE << TREEBIN_SHIFT)
#define MAX_SMALL_SIZE    (MIN_LARGE_SIZE - SIZE_T_ONE)
#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)

struct malloc_state {
  binmap_t   smallmap;
  binmap_t   treemap;
  size_t     dvsize;
  size_t     topsize;
  char*      least_addr;
  mchunkptr  dv;
  mchunkptr  top;
  size_t     trim_check;
  size_t     magic;
  mchunkptr  smallbins[(NSMALLBINS+1)*2];
  tbinptr    treebins[NTREEBINS];
  size_t     footprint;
  size_t     max_footprint;
  flag_t     mflags;
#if USE_LOCKS
  MLOCK_T    mutex;     /* locate lock among fields that rarely change */
#endif /* USE_LOCKS */
  msegment   seg;
};

typedef struct malloc_state*    mstate;

/* ------------- Global malloc_state and malloc_params ------------------- */

/*
  malloc_params holds global properties, including those that can be
  dynamically set using mallopt. There is a single instance, mparams,
  initialized in init_mparams.
*/

struct malloc_params {
  size_t magic;
  size_t page_size;
  size_t granularity;
  size_t mmap_threshold;
  size_t trim_threshold;
  flag_t default_mflags;
};

static struct malloc_params mparams;

/* The global malloc_state used for all non-"mspace" calls */
static struct malloc_state _gm_;
#define gm                 (&_gm_)
#define is_global(M)       ((M) == &_gm_)
#define is_initialized(M)  ((M)->top != 0)

/* -------------------------- system alloc setup ------------------------- */

/* Operations on mflags */

#define use_lock(M)           ((M)->mflags &   USE_LOCK_BIT)
#define enable_lock(M)        ((M)->mflags |=  USE_LOCK_BIT)
#define disable_lock(M)       ((M)->mflags &= ~USE_LOCK_BIT)

#define use_mmap(M)           ((M)->mflags &   USE_MMAP_BIT)
#define enable_mmap(M)        ((M)->mflags |=  USE_MMAP_BIT)
#define disable_mmap(M)       ((M)->mflags &= ~USE_MMAP_BIT)

#define use_noncontiguous(M)  ((M)->mflags &   USE_NONCONTIGUOUS_BIT)
#define disable_contiguous(M) ((M)->mflags |=  USE_NONCONTIGUOUS_BIT)

#define set_lock(M,L)\
 ((M)->mflags = (L)?\
  ((M)->mflags | USE_LOCK_BIT) :\
  ((M)->mflags & ~USE_LOCK_BIT))

/* page-align a size */
#define page_align(S)\
 (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE))

/* granularity-align a size */
#define granularity_align(S)\
  (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE))

#define is_page_aligned(S)\
   (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)
#define is_granularity_aligned(S)\
   (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)

/*  True if segment S holds address A */
#define segment_holds(S, A)\
  ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
dlmalloc.c1424
((CHAR*)(A) >= S->BASE && (CHAR*)(A) < S->BASE + S->SIZE) STATIC MSEGMENTPTRsegment_holding(mstate m, char* addr)
static msegmentptr segment_holding(mstate m, char* addr) {
  msegmentptr sp = &m->seg;
  for (;;) {
    if (addr >= sp->base && addr < sp->base + sp->size)
      return sp;
    if ((sp = sp->next) == 0)
      return 0;
  }
}
dlmalloc.c2061
STATIC INThas_segment_link(mstate m, msegmentptr ss)
static int has_segment_link(mstate m, msegmentptr ss) {
  msegmentptr sp = &m->seg;
  for (;;) {
    if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size)
      return 1;
    if ((sp = sp->next) == 0)
      return 0;
  }
}

#ifndef MORECORE_CANNOT_TRIM
#define should_trim(M,s)  ((s) > (M)->trim_check)
#else  /* MORECORE_CANNOT_TRIM */
#define should_trim(M,s)  (0)
#endif /* MORECORE_CANNOT_TRIM */

/*
  TOP_FOOT_SIZE is padding at the end of a segment, including space
  that may be needed to place segment records and fenceposts when new
  noncontiguous segments are added.
*/
#define TOP_FOOT_SIZE\
  (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)


/* -------------------------------  Hooks -------------------------------- */

/*
  PREACTION should be defined to return 0 on success, and nonzero on
  failure. If you are not using locking, you can redefine these to do
  anything you like.
*/

#if USE_LOCKS

/* Ensure locks are initialized */
#define GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams())

#define PREACTION(M)  ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)
#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }
#else /* USE_LOCKS */

#ifndef PREACTION
#define PREACTION(M) (0)
#endif  /* PREACTION */

#ifndef POSTACTION
#define POSTACTION(M)
#endif  /* POSTACTION */

#endif /* USE_LOCKS */

/*
  CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.
  USAGE_ERROR_ACTION is triggered on detected bad frees and
  reallocs. The argument p is an address that might have triggered the
  fault. It is ignored by the two predefined actions, but might be
  useful in custom actions that try to help diagnose errors.
*/

#if PROCEED_ON_ERROR

/* A count of the number of corruption errors causing resets */
int malloc_corruption_error_count;

/* default corruption action */
static void reset_on_error(mstate m);

#define CORRUPTION_ERROR_ACTION(m)  reset_on_error(m)
#define USAGE_ERROR_ACTION(m, p)

#else /* PROCEED_ON_ERROR */

#ifndef CORRUPTION_ERROR_ACTION
#define CORRUPTION_ERROR_ACTION(m) ABORT
#endif /* CORRUPTION_ERROR_ACTION */

#ifndef USAGE_ERROR_ACTION
#define USAGE_ERROR_ACTION(m,p) ABORT
#endif /* USAGE_ERROR_ACTION */

#endif /* PROCEED_ON_ERROR */

/* -------------------------- Debugging setup ---------------------------- */

#if ! DEBUG

#define check_free_chunk(M,P)
#define check_inuse_chunk(M,P)
#define check_malloced_chunk(M,P,N)
#define check_mmapped_chunk(M,P)
#define check_malloc_state(M)
#define check_top_chunk(M,P)

#else /* DEBUG */
#define check_free_chunk(M,P)       do_check_free_chunk(M,P)
#define check_inuse_chunk(M,P)      do_check_inuse_chunk(M,P)
#define check_top_chunk(M,P)        do_check_top_chunk(M,P)
#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N)
#define check_mmapped_chunk(M,P)    do_check_mmapped_chunk(M,P)
#define check_malloc_state(M)       do_check_malloc_state(M)

static void   do_check_any_chunk(mstate m, mchunkptr p);
static void   do_check_top_chunk(mstate m, mchunkptr p);
static void   do_check_mmapped_chunk(mstate m, mchunkptr p);
static void   do_check_inuse_chunk(mstate m, mchunkptr p);
static void   do_check_free_chunk(mstate m, mchunkptr p);
static void   do_check_malloced_chunk(mstate m, void* mem, size_t s);
static void   do_check_tree(mstate m, tchunkptr t);
static void   do_check_treebin(mstate m, bindex_t i);
static void   do_check_smallbin(mstate m, bindex_t i);
static void   do_check_malloc_state(mstate m);
static int    bin_find(mstate m, mchunkptr x);
static size_t traverse_and_check(mstate m);
#endif /* DEBUG */

/* ---------------------------- Indexing Bins ---------------------------- */

#define is_small(s)         (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)
#define small_index(s)      ((s)  >> SMALLBIN_SHIFT)
#define small_index2size(i) ((i)  << SMALLBIN_SHIFT)
#define MIN_SMALL_INDEX     (small_index(MIN_CHUNK_SIZE))

/* addressing by index. See above about smallbin repositioning */
#define smallbin_at(M, i)   ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))
#define treebin_at(M,i)     (&((M)->treebins[i]))

/* assign tree index for size S to variable I */
#if defined(__GNUC__) && defined(i386)
#define compute_tree_index(S, I)\
{\
  size_t X = S >> TREEBIN_SHIFT;\
  if (X == 0)\
    I = 0;\
  else if (X > 0xFFFF)\
    I = NTREEBINS-1;\
  else {\
    unsigned int K;\
    __asm__("bsrl %1,%0\n\t" : "=r" (K) : "rm"  (X));\
    I =  (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\
  }\
}
#else /* GNUC */
#define compute_tree_index(S, I)\
{\
  size_t X = S >> TREEBIN_SHIFT;\
  if (X == 0)\
    I = 0;\
  else if (X > 0xFFFF)\
    I = NTREEBINS-1;\
  else {\
    unsigned int Y = (unsigned int)X;\
    unsigned int N = ((Y - 0x100) >> 16) & 8;\
    unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\
    N += K;\
    N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\
    K = 14 - N + ((Y <<= K) >> 15);\
    I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\
  }\
}
#endif /* GNUC */

/* Bit representing maximum resolved size in a treebin at i */
#define bit_for_tree_index(i) \
   (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)

/* Shift placing maximum resolved bit in a treebin at i as sign bit */
#define leftshift_for_tree_index(i) \
   ((i == NTREEBINS-1)? 0 : \
    ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))

/* The size of the smallest chunk held in bin with index i */
#define minsize_for_tree_index(i) \
   ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) |  \
   (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))


/* ------------------------ Operations on bin maps ----------------------- */

/* bit corresponding to given index */
#define idx2bit(i)              ((binmap_t)(1) << (i))

/* Mark/Clear bits with given index */
#define mark_smallmap(M,i)      ((M)->smallmap |=  idx2bit(i))
#define clear_smallmap(M,i)     ((M)->smallmap &= ~idx2bit(i))
#define smallmap_is_marked(M,i) ((M)->smallmap &   idx2bit(i))

#define mark_treemap(M,i)       ((M)->treemap  |=  idx2bit(i))
#define clear_treemap(M,i)      ((M)->treemap  &= ~idx2bit(i))
#define treemap_is_marked(M,i)  ((M)->treemap  &   idx2bit(i))

/* index corresponding to given bit */

#if defined(__GNUC__) && defined(i386)
#define compute_bit2idx(X, I)\
{\
  unsigned int J;\
  __asm__("bsfl %1,%0\n\t" : "=r" (J) : "rm" (X));\
  I = (bindex_t)J;\
}

#else /* GNUC */
#if  USE_BUILTIN_FFS
#define compute_bit2idx(X, I) I = ffs(X)-1

#else /* USE_BUILTIN_FFS */
#define compute_bit2idx(X, I)\
{\
  unsigned int Y = X - 1;\
  unsigned int K = Y >> (16-4) & 16;\
  unsigned int N = K;        Y >>= K;\
  N += K = Y >> (8-3) &  8;  Y >>= K;\
  N += K = Y >> (4-2) &  4;  Y >>= K;\
  N += K = Y >> (2-1) &  2;  Y >>= K;\
  N += K = Y >> (1-0) &  1;  Y >>= K;\
  I = (bindex_t)(N + Y);\
}
#endif /* USE_BUILTIN_FFS */
#endif /* GNUC */

/* isolate the least set bit of a bitmap */
#define least_bit(x)         ((x) & -(x))

/* mask with all bits to left of least bit of x on */
#define left_bits(x)         ((x<<1) | -(x<<1))

/* mask with all bits to left of or equal to least bit of x on */
#define same_or_left_bits(x) ((x) | -(x))


/* ----------------------- Runtime Check Support ------------------------- */

/*
  For security, the main invariant is that malloc/free/etc never
  writes to a static address other than malloc_state, unless static
  malloc_state itself has been corrupted, which cannot occur via
  malloc (because of these checks). In essence this means that we
  believe all pointers, sizes, maps etc held in malloc_state, but
  check all of those linked or offsetted from other embedded data
  structures.  These checks are interspersed with main code in a way
  that tends to minimize their run-time cost.

  When FOOTERS is defined, in addition to range checking, we also
  verify footer fields of inuse chunks, which can be used guarantee
  that the mstate controlling malloc/free is intact.  This is a
  streamlined version of the approach described by William Robertson
  et al in "Run-time Detection of Heap-based Overflows" LISA'03
  http://www.usenix.org/events/lisa03/tech/robertson.html The footer
  of an inuse chunk holds the xor of its mstate and a random seed,
  that is checked upon calls to free() and realloc().  This is
  (probablistically) unguessable from outside the program, but can be
  computed by any code successfully malloc'ing any chunk, so does not
  itself provide protection against code that has already broken
  security through some other means.  Unlike Robertson et al, we
  always dynamically check addresses of all offset chunks (previous,
  next, etc). This turns out to be cheaper than relying on hashes.
*/

#if !INSECURE
/* Check if address a is at least as high as any from MORECORE or MMAP */
#define ok_address(M, a) ((char*)(a) >= (M)->least_addr)
/* Check if address of next chunk n is higher than base chunk p */
#define ok_next(p, n)    ((char*)(p) < (char*)(n))
/* Check if p has its cinuse bit on */
#define ok_cinuse(p)     cinuse(p)
/* Check if p has its pinuse bit on */
#define ok_pinuse(p)     pinuse(p)

#else /* !INSECURE */
#define ok_address(M, a) (1)
#define ok_next(b, n)    (1)
#define ok_cinuse(p)     (1)
#define ok_pinuse(p)     (1)
#endif /* !INSECURE */

#if (FOOTERS && !INSECURE)
/* Check if (alleged) mstate m has expected magic field */
#define ok_magic(M)      ((M)->magic == mparams.magic)
#else  /* (FOOTERS && !INSECURE) */
#define ok_magic(M)      (1)
#endif /* (FOOTERS && !INSECURE) */


/* In gcc, use __builtin_expect to minimize impact of checks */
#if !INSECURE
#if defined(__GNUC__) && __GNUC__ >= 3
#define RTCHECK(e)  __builtin_expect(e, 1)
#else /* GNUC */
#define RTCHECK(e)  (e)
#endif /* GNUC */
#else /* !INSECURE */
#define RTCHECK(e)  (1)
#endif /* !INSECURE */

/* macros to set up inuse chunks with or without footers */

#if !FOOTERS

#define mark_inuse_foot(M,p,s)

/* Set cinuse bit and pinuse bit of next chunk */
#define set_inuse(M,p,s)\
  ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
  ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)

/* Set cinuse and pinuse of this chunk and pinuse of next chunk */
#define set_inuse_and_pinuse(M,p,s)\
  ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
  ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)

/* Set size, cinuse and pinuse bit of this chunk */
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\
  ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))

#else /* FOOTERS */

/* Set foot of inuse chunk to be xor of mstate and seed */
#define mark_inuse_foot(M,p,s)\
  (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic))

#define get_mstate_for(p)\
  ((mstate)(((mchunkptr)((char*)(p) +\
    (chunksize(p))))->prev_foot ^ mparams.magic))

#define set_inuse(M,p,s)\
  ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
  (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \
  mark_inuse_foot(M,p,s))

#define set_inuse_and_pinuse(M,p,s)\
  ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
  (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\
 mark_inuse_foot(M,p,s))

#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\
  ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
  mark_inuse_foot(M, p, s))
dlmalloc.c2072
STATIC INTinit_mparams(void)
static int init_mparams(void) {
  if (mparams.page_size == 0) {
    size_t s;

    mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD;
    mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD;
#if MORECORE_CONTIGUOUS
    mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT;
#else  /* MORECORE_CONTIGUOUS */
    mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT;
#endif /* MORECORE_CONTIGUOUS */

#if (FOOTERS && !INSECURE)
    {
#if USE_DEV_RANDOM
      int fd;
      unsigned char buf[sizeof(size_t)];
      /* Try to use /dev/urandom, else fall back on using time */
      if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 &&
          read(fd, buf, sizeof(buf)) == sizeof(buf)) {
        s = *((size_t *) buf);
        close(fd);
      }
      else
#endif /* USE_DEV_RANDOM */
        s = (size_t)(time(0) ^ (size_t)0x55555555U);

      s |= (size_t)8U;    /* ensure nonzero */
      s &= ~(size_t)7U;   /* improve chances of fault for bad values */

    }
#else /* (FOOTERS && !INSECURE) */
    s = (size_t)0x58585858U;
#endif /* (FOOTERS && !INSECURE) */
    ACQUIRE_MAGIC_INIT_LOCK();
    if (mparams.magic == 0) {
      mparams.magic = s;
      /* Set up lock for main malloc area */
      INITIAL_LOCK(&gm->mutex);
      gm->mflags = mparams.default_mflags;
    }
    RELEASE_MAGIC_INIT_LOCK();

#ifndef WIN32
    mparams.page_size = malloc_getpagesize;
    mparams.granularity = ((DEFAULT_GRANULARITY != 0)?
                           DEFAULT_GRANULARITY : mparams.page_size);
#else /* WIN32 */
    {
      SYSTEM_INFO system_info;
      GetSystemInfo(&system_info);
      mparams.page_size = system_info.dwPageSize;
      mparams.granularity = system_info.dwAllocationGranularity;
    }
#endif /* WIN32 */

    /* Sanity-check configuration:
       size_t must be unsigned and as wide as pointer type.
       ints must be at least 4 bytes.
       alignment must be at least 8.
       Alignment, min chunk size, and page size must all be powers of 2.
    */
    if ((sizeof(size_t) != sizeof(char*)) ||
        (MAX_SIZE_T < MIN_CHUNK_SIZE)  ||
        (sizeof(int) < 4)  ||
        (MALLOC_ALIGNMENT < (size_t)8U) ||
        ((MALLOC_ALIGNMENT    & (MALLOC_ALIGNMENT-SIZE_T_ONE))    != 0) ||
        ((MCHUNK_SIZE         & (MCHUNK_SIZE-SIZE_T_ONE))         != 0) ||
        ((mparams.granularity & (mparams.granularity-SIZE_T_ONE)) != 0) ||
        ((mparams.page_size   & (mparams.page_size-SIZE_T_ONE))   != 0))
      ABORT;
  }
  return 0;
}
dlmalloc.c2415
STATIC INTchange_mparam(int param_number, int value)
static int change_mparam(int param_number, int value) {
  size_t val = (size_t)value;
  init_mparams();
  switch(param_number) {
  case M_TRIM_THRESHOLD:
    mparams.trim_threshold = val;
    return 1;
  case M_GRANULARITY:
    if (val >= mparams.page_size && ((val & (val-1)) == 0)) {
      mparams.granularity = val;
      return 1;
    }
    else
      return 0;
  case M_MMAP_THRESHOLD:
    mparams.mmap_threshold = val;
    return 1;
  default:
    return 0;
  }
}
dlmalloc.c2491
STATIC VOIDdo_check_any_chunk(mstate m, mchunkptr p)
static void do_check_any_chunk(mstate m, mchunkptr p) {
  assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
  assert(ok_address(m, p));
}
dlmalloc.c2517
STATIC VOIDdo_check_top_chunk(mstate m, mchunkptr p)
static void do_check_top_chunk(mstate m, mchunkptr p) {
  msegmentptr sp = segment_holding(m, (char*)p);
  size_t  sz = chunksize(p);
  assert(sp != 0);
  assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
  assert(ok_address(m, p));
  assert(sz == m->topsize);
  assert(sz > 0);
  assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE);
  assert(pinuse(p));
  assert(!next_pinuse(p));
}
dlmalloc.c2523
STATIC VOIDdo_check_mmapped_chunk(mstate m, mchunkptr p)
static void do_check_mmapped_chunk(mstate m, mchunkptr p) {
  size_t  sz = chunksize(p);
  size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD);
  assert(is_mmapped(p));
  assert(use_mmap(m));
  assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
  assert(ok_address(m, p));
  assert(!is_small(sz));
  assert((len & (mparams.page_size-SIZE_T_ONE)) == 0);
  assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD);
  assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0);
}
dlmalloc.c2537
STATIC VOIDdo_check_inuse_chunk(mstate m, mchunkptr p)
static void do_check_inuse_chunk(mstate m, mchunkptr p) {
  do_check_any_chunk(m, p);
  assert(cinuse(p));
  assert(next_pinuse(p));
  /* If not pinuse and not mmapped, previous chunk has OK offset */
  assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p);
  if (is_mmapped(p))
    do_check_mmapped_chunk(m, p);
}
dlmalloc.c2551
STATIC VOIDdo_check_free_chunk(mstate m, mchunkptr p)
static void do_check_free_chunk(mstate m, mchunkptr p) {
  size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT);
  mchunkptr next = chunk_plus_offset(p, sz);
  do_check_any_chunk(m, p);
  assert(!cinuse(p));
  assert(!next_pinuse(p));
  assert (!is_mmapped(p));
  if (p != m->dv && p != m->top) {
    if (sz >= MIN_CHUNK_SIZE) {
      assert((sz & CHUNK_ALIGN_MASK) == 0);
      assert(is_aligned(chunk2mem(p)));
      assert(next->prev_foot == sz);
      assert(pinuse(p));
      assert (next == m->top || cinuse(next));
      assert(p->fd->bk == p);
      assert(p->bk->fd == p);
    }
    else  /* markers are always of size SIZE_T_SIZE */
      assert(sz == SIZE_T_SIZE);
  }
}
dlmalloc.c2562
STATIC VOIDdo_check_malloced_chunk(mstate m, void* mem, size_t s)
static void do_check_malloced_chunk(mstate m, void* mem, size_t s) {
  if (mem != 0) {
    mchunkptr p = mem2chunk(mem);
    size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT);
    do_check_inuse_chunk(m, p);
    assert((sz & CHUNK_ALIGN_MASK) == 0);
    assert(sz >= MIN_CHUNK_SIZE);
    assert(sz >= s);
    /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */
    assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE));
  }
}
dlmalloc.c2585
STATIC VOIDdo_check_tree(mstate m, tchunkptr t)
static void do_check_tree(mstate m, tchunkptr t) {
  tchunkptr head = 0;
  tchunkptr u = t;
  bindex_t tindex = t->index;
  size_t tsize = chunksize(t);
  bindex_t idx;
  compute_tree_index(tsize, idx);
  assert(tindex == idx);
  assert(tsize >= MIN_LARGE_SIZE);
  assert(tsize >= minsize_for_tree_index(idx));
  assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1))));

  do { /* traverse through chain of same-sized nodes */
    do_check_any_chunk(m, ((mchunkptr)u));
    assert(u->index == tindex);
    assert(chunksize(u) == tsize);
    assert(!cinuse(u));
    assert(!next_pinuse(u));
    assert(u->fd->bk == u);
    assert(u->bk->fd == u);
    if (u->parent == 0) {
      assert(u->child[0] == 0);
      assert(u->child[1] == 0);
    }
    else {
      assert(head == 0); /* only one node on chain has parent */
      head = u;
      assert(u->parent != u);
      assert (u->parent->child[0] == u ||
              u->parent->child[1] == u ||
              *((tbinptr*)(u->parent)) == u);
      if (u->child[0] != 0) {
        assert(u->child[0]->parent == u);
        assert(u->child[0] != u);
        do_check_tree(m, u->child[0]);
      }
      if (u->child[1] != 0) {
        assert(u->child[1]->parent == u);
        assert(u->child[1] != u);
        do_check_tree(m, u->child[1]);
      }
      if (u->child[0] != 0 && u->child[1] != 0) {
        assert(chunksize(u->child[0]) < chunksize(u->child[1]));
      }
    }
    u = u->fd;
  } while (u != t);
  assert(head != 0);
}
dlmalloc.c2599
STATIC VOIDdo_check_treebin(mstate m, bindex_t i)
static void do_check_treebin(mstate m, bindex_t i) {
  tbinptr* tb = treebin_at(m, i);
  tchunkptr t = *tb;
  int empty = (m->treemap & (1U << i)) == 0;
  if (t == 0)
    assert(empty);
  if (!empty)
    do_check_tree(m, t);
}
dlmalloc.c2650
STATIC VOIDdo_check_smallbin(mstate m, bindex_t i)
static void do_check_smallbin(mstate m, bindex_t i) {
  sbinptr b = smallbin_at(m, i);
  mchunkptr p = b->bk;
  unsigned int empty = (m->smallmap & (1U << i)) == 0;
  if (p == b)
    assert(empty);
  if (!empty) {
    for (; p != b; p = p->bk) {
      size_t size = chunksize(p);
      mchunkptr q;
      /* each chunk claims to be free */
      do_check_free_chunk(m, p);
      /* chunk belongs in bin */
      assert(small_index(size) == i);
      assert(p->bk == b || chunksize(p->bk) == chunksize(p));
      /* chunk is followed by an inuse chunk */
      q = next_chunk(p);
      if (q->head != FENCEPOST_HEAD)
        do_check_inuse_chunk(m, q);
    }
  }
}
dlmalloc.c2661
STATIC INTbin_find(mstate m, mchunkptr x)
static int bin_find(mstate m, mchunkptr x) {
  size_t size = chunksize(x);
  if (is_small(size)) {
    bindex_t sidx = small_index(size);
    sbinptr b = smallbin_at(m, sidx);
    if (smallmap_is_marked(m, sidx)) {
      mchunkptr p = b;
      do {
        if (p == x)
          return 1;
      } while ((p = p->fd) != b);
    }
  }
  else {
    bindex_t tidx;
    compute_tree_index(size, tidx);
    if (treemap_is_marked(m, tidx)) {
      tchunkptr t = *treebin_at(m, tidx);
      size_t sizebits = size << leftshift_for_tree_index(tidx);
      while (t != 0 && chunksize(t) != size) {
        t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
        sizebits <<= 1;
      }
      if (t != 0) {
        tchunkptr u = t;
        do {
          if (u == (tchunkptr)x)
            return 1;
        } while ((u = u->fd) != t);
      }
    }
  }
  return 0;
}
dlmalloc.c2685
STATIC SIZE_Ttraverse_and_check(mstate m)
static size_t traverse_and_check(mstate m) {
  size_t sum = 0;
  if (is_initialized(m)) {
    msegmentptr s = &m->seg;
    sum += m->topsize + TOP_FOOT_SIZE;
    while (s != 0) {
      mchunkptr q = align_as_chunk(s->base);
      mchunkptr lastq = 0;
      assert(pinuse(q));
      while (segment_holds(s, q) &&
             q != m->top && q->head != FENCEPOST_HEAD) {
        sum += chunksize(q);
        if (cinuse(q)) {
          assert(!bin_find(m, q));
          do_check_inuse_chunk(m, q);
        }
        else {
          assert(q == m->dv || bin_find(m, q));
          assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */
          do_check_free_chunk(m, q);
        }
        lastq = q;
        q = next_chunk(q);
      }
      s = s->next;
    }
  }
  return sum;
}
dlmalloc.c2721
STATIC VOIDdo_check_malloc_state(mstate m)
static void do_check_malloc_state(mstate m) {
  bindex_t i;
  size_t total;
  /* check bins */
  for (i = 0; i < NSMALLBINS; ++i)
    do_check_smallbin(m, i);
  for (i = 0; i < NTREEBINS; ++i)
    do_check_treebin(m, i);

  if (m->dvsize != 0) { /* check dv chunk */
    do_check_any_chunk(m, m->dv);
    assert(m->dvsize == chunksize(m->dv));
    assert(m->dvsize >= MIN_CHUNK_SIZE);
    assert(bin_find(m, m->dv) == 0);
  }

  if (m->top != 0) {   /* check top chunk */
    do_check_top_chunk(m, m->top);
    assert(m->topsize == chunksize(m->top));
    assert(m->topsize > 0);
    assert(bin_find(m, m->top) == 0);
  }

  total = traverse_and_check(m);
  assert(total <= m->footprint);
  assert(m->footprint <= m->max_footprint);
}
dlmalloc.c2752
STATIC STRUCT MALLINFOinternal_mallinfo(mstate m)
static struct mallinfo internal_mallinfo(mstate m) {
  struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  if (!PREACTION(m)) {
    check_malloc_state(m);
    if (is_initialized(m)) {
      size_t nfree = SIZE_T_ONE; /* top always free */
      size_t mfree = m->topsize + TOP_FOOT_SIZE;
      size_t sum = mfree;
      msegmentptr s = &m->seg;
      while (s != 0) {
        mchunkptr q = align_as_chunk(s->base);
        while (segment_holds(s, q) &&
               q != m->top && q->head != FENCEPOST_HEAD) {
          size_t sz = chunksize(q);
          sum += sz;
          if (!cinuse(q)) {
            mfree += sz;
            ++nfree;
          }
          q = next_chunk(q);
        }
        s = s->next;
      }

      nm.arena    = sum;
      nm.ordblks  = nfree;
      nm.hblkhd   = m->footprint - sum;
      nm.usmblks  = m->max_footprint;
      nm.uordblks = m->footprint - mfree;
      nm.fordblks = mfree;
      nm.keepcost = m->topsize;
    }

    POSTACTION(m);
  }
  return nm;
}
dlmalloc.c2785
STATIC VOIDinternal_malloc_stats(mstate m)
static void internal_malloc_stats(mstate m) {
  if (!PREACTION(m)) {
    size_t maxfp = 0;
    size_t fp = 0;
    size_t used = 0;
    check_malloc_state(m);
    if (is_initialized(m)) {
      msegmentptr s = &m->seg;
      maxfp = m->max_footprint;
      fp = m->footprint;
      used = fp - (m->topsize + TOP_FOOT_SIZE);

      while (s != 0) {
        mchunkptr q = align_as_chunk(s->base);
        while (segment_holds(s, q) &&
               q != m->top && q->head != FENCEPOST_HEAD) {
          if (!cinuse(q))
            used -= chunksize(q);
          q = next_chunk(q);
        }
        s = s->next;
      }
    }

    fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp));
    fprintf(stderr, "system bytes     = %10lu\n", (unsigned long)(fp));
    fprintf(stderr, "in use bytes     = %10lu\n", (unsigned long)(used));

    POSTACTION(m);
  }
}

/* ----------------------- Operations on smallbins ----------------------- */

/*
  Various forms of linking and unlinking are defined as macros.  Even
  the ones for trees, which are very long but have very short typical
  paths.  This is ugly but reduces reliance on inlining support of
  compilers.
*/

/* Link a free chunk into a smallbin  */
#define insert_small_chunk(M, P, S) {\
  bindex_t I  = small_index(S);\
  mchunkptr B = smallbin_at(M, I);\
  mchunkptr F = B;\
  assert(S >= MIN_CHUNK_SIZE);\
  if (!smallmap_is_marked(M, I))\
    mark_smallmap(M, I);\
  else if (RTCHECK(ok_address(M, B->fd)))\
    F = B->fd;\
  else {\
    CORRUPTION_ERROR_ACTION(M);\
  }\
  B->fd = P;\
  F->bk = P;\
  P->fd = F;\
  P->bk = B;\
}

/* Unlink a chunk from a smallbin  */
#define unlink_small_chunk(M, P, S) {\
  mchunkptr F = P->fd;\
  mchunkptr B = P->bk;\
  bindex_t I = small_index(S);\
  assert(P != B);\
  assert(P != F);\
  assert(chunksize(P) == small_index2size(I));\
  if (F == B)\
    clear_smallmap(M, I);\
dlmalloc.c2824
\ ELSE IF (RTCHECK((F == SMALLBIN_AT(M,I) || OK_ADDRESS(M, F)) &&\ (B == SMALLBIN_AT(M,I) ||ok_address(M, B))))
  else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\
                   (B == smallbin_at(M,I) || ok_address(M, B)))) {\
    F->bk = B;\
    B->fd = F;\
  }\
  else {\
    CORRUPTION_ERROR_ACTION(M);\
  }\
}

/* Unlink the first chunk from a smallbin */
#define unlink_first_small_chunk(M, B, P, I) {\
  mchunkptr F = P->fd;\
  assert(P != B);\
  assert(P != F);\
  assert(chunksize(P) == small_index2size(I));\
  if (B == F)\
    clear_smallmap(M, I);\
dlmalloc.c2894
\ ELSE IF (RTCHECKok_address(M, F)))
  else if (RTCHECK(ok_address(M, F))) {\
    B->fd = F;\
    F->bk = B;\
  }\
  else {\
    CORRUPTION_ERROR_ACTION(M);\
  }\
}

/* Replace dv node, binning the old one */
/* Used only when dvsize known to be small */
#define replace_dv(M, P, S) {\
  size_t DVS = M->dvsize;\
dlmalloc.c2912
\if (DVS != 0)
  if (DVS != 0) {\
    mchunkptr DV = M->dv;\
    assert(is_small(DVS));\
    insert_small_chunk(M, DV, DVS);\
  }\
  M->dvsize = S;\
  M->dv = P;\
}

/* ------------------------- Operations on trees ------------------------- */

/* Insert chunk into tree */
#define insert_large_chunk(M, X, S) {\
  tbinptr* H;\
  bindex_t I;\
  compute_tree_index(S, I);\
  H = treebin_at(M, I);\
  X->index = I;\
  X->child[0] = X->child[1] = 0;\
dlmalloc.c2925
\ IF (treemap_is_marked(M, I))
  if (!treemap_is_marked(M, I)) {\
    mark_treemap(M, I);\
    *H = X;\
    X->parent = (tchunkptr)H;\
    X->fd = X->bk = X;\
  }\
  else {\
    tchunkptr T = *H;\
    size_t K = S << leftshift_for_tree_index(I);\
    for (;;) {\
      if (chunksize(T) != S) {\
        tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\
        K <<= 1;\
        if (*C != 0)\
          T = *C;\
        else if (RTCHECK(ok_address(M, C))) {\
          *C = X;\
          X->parent = T;\
          X->fd = X->bk = X;\
          break;\
        }\
        else {\
          CORRUPTION_ERROR_ACTION(M);\
          break;\
        }\
      }\
      else {\
        tchunkptr F = T->fd;\
        if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\
          T->fd = F->bk = X;\
          X->fd = F;\
          X->bk = T;\
          X->parent = 0;\
          break;\
        }\
        else {\
          CORRUPTION_ERROR_ACTION(M);\
          break;\
        }\
      }\
    }\
  }\
}

/*
  Unlink steps:

  1. If x is a chained node, unlink it from its same-sized fd/bk links
     and choose its bk node as its replacement.
  2. If x was the last node of its size, but not a leaf node, it must
     be replaced with a leaf node (not merely one with an open left or
     right), to make sure that lefts and rights of descendents
     correspond properly to bit masks.  We use the rightmost descendent
     of x.  We could use any other leaf, but this is easy to locate and
     tends to counteract removal of leftmosts elsewhere, and so keeps
     paths shorter than minimally guaranteed.  This doesn't loop much
     because on average a node in a tree is near the bottom.
  3. If x is the base of a chain (i.e., has parent links) relink
     x's parent and children to x's replacement (or null if none).
*/

#define unlink_large_chunk(M, X) {\
  tchunkptr XP = X->parent;\
  tchunkptr R;\
dlmalloc.c2944
\if (X->bk != X)
  if (X->bk != X) {\
    tchunkptr F = X->fd;\
    R = X->bk;\
    if (RTCHECK(ok_address(M, F))) {\
      F->bk = R;\
      R->fd = F;\
    }\
    else {\
      CORRUPTION_ERROR_ACTION(M);\
    }\
  }\
  else {\
    tchunkptr* RP;\
    if (((R = *(RP = &(X->child[1]))) != 0) ||\
        ((R = *(RP = &(X->child[0]))) != 0)) {\
      tchunkptr* CP;\
      while ((*(CP = &(R->child[1])) != 0) ||\
             (*(CP = &(R->child[0])) != 0)) {\
        R = *(RP = CP);\
      }\
      if (RTCHECK(ok_address(M, RP)))\
        *RP = 0;\
      else {\
        CORRUPTION_ERROR_ACTION(M);\
      }\
    }\
  }\
dlmalloc.c3008
IF(XP != 0)
  if (XP != 0) {\
    tbinptr* H = treebin_at(M, X->index);\
    if (X == *H) {\
      if ((*H = R) == 0) \
        clear_treemap(M, X->index);\
    }\
    else if (RTCHECK(ok_address(M, XP))) {\
      if (XP->child[0] == X) \
        XP->child[0] = R;\
      else \
        XP->child[1] = R;\
    }\
    else\
      CORRUPTION_ERROR_ACTION(M);\
    if (R != 0) {\
      if (RTCHECK(ok_address(M, R))) {\
        tchunkptr C0, C1;\
        R->parent = XP;\
        if ((C0 = X->child[0]) != 0) {\
          if (RTCHECK(ok_address(M, C0))) {\
            R->child[0] = C0;\
            C0->parent = R;\
          }\
          else\
            CORRUPTION_ERROR_ACTION(M);\
        }\
        if ((C1 = X->child[1]) != 0) {\
          if (RTCHECK(ok_address(M, C1))) {\
            R->child[1] = C1;\
            C1->parent = R;\
          }\
          else\
            CORRUPTION_ERROR_ACTION(M);\
        }\
      }\
      else\
        CORRUPTION_ERROR_ACTION(M);\
    }\
  }\
}

/* Relays to large vs small bin operations */

#define insert_chunk(M, P, S)\
  if (is_small(S)) insert_small_chunk(M, P, S)\
  else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }

#define unlink_chunk(M, P, S)\
  if (is_small(S)) unlink_small_chunk(M, P, S)\
  else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }


/* Relays to internal calls to malloc/free from realloc, memalign etc */

#if ONLY_MSPACES
#define internal_malloc(m, b) mspace_malloc(m, b)
#define internal_free(m, mem) mspace_free(m,mem);
#else /* ONLY_MSPACES */
#if MSPACES
#define internal_malloc(m, b)\
   (m == gm)? dlmalloc(b) : mspace_malloc(m, b)
#define internal_free(m, mem)\
   if (m == gm) dlfree(mem); else mspace_free(m,mem);
#else /* MSPACES */
#define internal_malloc(m, b) dlmalloc(b)
#define internal_free(m, mem) dlfree(mem)
#endif /* MSPACES */
#endif /* ONLY_MSPACES */

dlmalloc.c3035
STATIC VOID*mmap_alloc(mstate m, size_t nb)
static void* mmap_alloc(mstate m, size_t nb) {
  size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
  if (mmsize > nb) {     /* Check for wrap around 0 */
    char* mm = (char*)(DIRECT_MMAP(mmsize));
    if (mm != CMFAIL) {
      size_t offset = align_offset(chunk2mem(mm));
      size_t psize = mmsize - offset - MMAP_FOOT_PAD;
      mchunkptr p = (mchunkptr)(mm + offset);
      p->prev_foot = offset | IS_MMAPPED_BIT;
      (p)->head = (psize|CINUSE_BIT);
      mark_inuse_foot(m, p, psize);
      chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD;
      chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0;

      if (mm < m->least_addr)
        m->least_addr = mm;
      if ((m->footprint += mmsize) > m->max_footprint)
        m->max_footprint = m->footprint;
      assert(is_aligned(chunk2mem(p)));
      check_mmapped_chunk(m, p);
      return chunk2mem(p);
    }
  }
  return 0;
}
dlmalloc.c3116
STATIC MCHUNKPTRmmap_resize(mstate m, mchunkptr oldp, size_t nb)
static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) {
  size_t oldsize = chunksize(oldp);
  if (is_small(nb)) /* Can't shrink mmap regions below small size */
    return 0;
  /* Keep old chunk if big enough but not too big */
  if (oldsize >= nb + SIZE_T_SIZE &&
      (oldsize - nb) <= (mparams.granularity << 1))
    return oldp;
  else {
    size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT;
    size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD;
    size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES +
                                         CHUNK_ALIGN_MASK);
    char* cp = (char*)CALL_MREMAP((char*)oldp - offset,
                                  oldmmsize, newmmsize, 1);
    if (cp != CMFAIL) {
      mchunkptr newp = (mchunkptr)(cp + offset);
      size_t psize = newmmsize - offset - MMAP_FOOT_PAD;
      newp->head = (psize|CINUSE_BIT);
      mark_inuse_foot(m, newp, psize);
      chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD;
      chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0;

      if (cp < m->least_addr)
        m->least_addr = cp;
      if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint)
        m->max_footprint = m->footprint;
      check_mmapped_chunk(m, newp);
      return newp;
    }
  }
  return 0;
}
dlmalloc.c3143
STATIC VOIDinit_top(mstate m, mchunkptr p, size_t psize)
static void init_top(mstate m, mchunkptr p, size_t psize) {
  /* Ensure alignment */
  size_t offset = align_offset(chunk2mem(p));
  p = (mchunkptr)((char*)p + offset);
  psize -= offset;

  m->top = p;
  m->topsize = psize;
  p->head = psize | PINUSE_BIT;
  /* set size of fake trailing chunk holding overhead space only once */
  chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE;
  m->trim_check = mparams.trim_threshold; /* reset on each update */
}
dlmalloc.c3180
STATIC VOIDinit_bins(mstate m)
static void init_bins(mstate m) {
  /* Establish circular links for smallbins */
  bindex_t i;
  for (i = 0; i < NSMALLBINS; ++i) {
    sbinptr bin = smallbin_at(m,i);
    bin->fd = bin->bk = bin;
  }
}
dlmalloc.c3195
STATIC VOIDreset_on_error(mstate m)
static void reset_on_error(mstate m) {
  int i;
  ++malloc_corruption_error_count;
  /* Reinitialize fields to forget about all memory */
  m->smallbins = m->treebins = 0;
  m->dvsize = m->topsize = 0;
  m->seg.base = 0;
  m->seg.size = 0;
  m->seg.next = 0;
  m->top = m->dv = 0;
  for (i = 0; i < NTREEBINS; ++i)
    *treebin_at(m, i) = 0;
  init_bins(m);
}
dlmalloc.c3207
STATIC VOID*prepend_alloc(mstate m, char* newbase, char* oldbase, size_t nb)
static void* prepend_alloc(mstate m, char* newbase, char* oldbase,
                           size_t nb) {
  mchunkptr p = align_as_chunk(newbase);
  mchunkptr oldfirst = align_as_chunk(oldbase);
  size_t psize = (char*)oldfirst - (char*)p;
  mchunkptr q = chunk_plus_offset(p, nb);
  size_t qsize = psize - nb;
  set_size_and_pinuse_of_inuse_chunk(m, p, nb);

  assert((char*)oldfirst > (char*)q);
  assert(pinuse(oldfirst));
  assert(qsize >= MIN_CHUNK_SIZE);

  /* consolidate remainder with first chunk of old base */
  if (oldfirst == m->top) {
    size_t tsize = m->topsize += qsize;
    m->top = q;
    q->head = tsize | PINUSE_BIT;
    check_top_chunk(m, q);
  }
  else if (oldfirst == m->dv) {
    size_t dsize = m->dvsize += qsize;
    m->dv = q;
    set_size_and_pinuse_of_free_chunk(q, dsize);
  }
  else {
    if (!cinuse(oldfirst)) {
      size_t nsize = chunksize(oldfirst);
      unlink_chunk(m, oldfirst, nsize);
      oldfirst = chunk_plus_offset(oldfirst, nsize);
      qsize += nsize;
    }
    set_free_with_pinuse(q, qsize, oldfirst);
    insert_chunk(m, q, qsize);
    check_free_chunk(m, q);
  }

  check_malloced_chunk(m, chunk2mem(p), nb);
  return chunk2mem(p);
}
dlmalloc.c3224
STATIC VOIDadd_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped)
static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
  /* Determine locations and sizes of segment, fenceposts, old top */
  char* old_top = (char*)m->top;
  msegmentptr oldsp = segment_holding(m, old_top);
  char* old_end = oldsp->base + oldsp->size;
  size_t ssize = pad_request(sizeof(struct malloc_segment));
  char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
  size_t offset = align_offset(chunk2mem(rawsp));
  char* asp = rawsp + offset;
  char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp;
  mchunkptr sp = (mchunkptr)csp;
  msegmentptr ss = (msegmentptr)(chunk2mem(sp));
  mchunkptr tnext = chunk_plus_offset(sp, ssize);
  mchunkptr p = tnext;
  int nfences = 0;

  /* reset top to new space */
  init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);

  /* Set up segment record */
  assert(is_aligned(ss));
  set_size_and_pinuse_of_inuse_chunk(m, sp, ssize);
  *ss = m->seg; /* Push current record */
  m->seg.base = tbase;
  m->seg.size = tsize;
  m->seg.sflags = mmapped;
  m->seg.next = ss;

  /* Insert trailing fenceposts */
  for (;;) {
    mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE);
    p->head = FENCEPOST_HEAD;
    ++nfences;
    if ((char*)(&(nextp->head)) < old_end)
      p = nextp;
    else
      break;
  }
  assert(nfences >= 2);

  /* Insert the rest of old top into a bin as an ordinary free chunk */
  if (csp != old_top) {
    mchunkptr q = (mchunkptr)old_top;
    size_t psize = csp - old_top;
    mchunkptr tn = chunk_plus_offset(q, psize);
    set_free_with_pinuse(q, psize, tn);
    insert_chunk(m, q, psize);
  }

  check_top_chunk(m, m->top);
}
dlmalloc.c3267
STATIC VOID*sys_alloc(mstate m, size_t nb)
static void* sys_alloc(mstate m, size_t nb) {
  char* tbase = CMFAIL;
  size_t tsize = 0;
  flag_t mmap_flag = 0;

  init_mparams();

  /* Directly map large chunks */
  if (use_mmap(m) && nb >= mparams.mmap_threshold) {
    void* mem = mmap_alloc(m, nb);
    if (mem != 0)
      return mem;
  }

  /*
    Try getting memory in any of three ways (in most-preferred to
    least-preferred order):
    1. A call to MORECORE that can normally contiguously extend memory.
       (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or
       or main space is mmapped or a previous contiguous call failed)
    2. A call to MMAP new space (disabled if not HAVE_MMAP).
       Note that under the default settings, if MORECORE is unable to
       fulfill a request, and HAVE_MMAP is true, then mmap is
       used as a noncontiguous system allocator. This is a useful backup
       strategy for systems with holes in address spaces -- in this case
       sbrk cannot contiguously expand the heap, but mmap may be able to
       find space.
    3. A call to MORECORE that cannot usually contiguously extend memory.
       (disabled if not HAVE_MORECORE)
  */

  if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) {
    char* br = CMFAIL;
    msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top);
    size_t asize = 0;
    ACQUIRE_MORECORE_LOCK();

    if (ss == 0) {  /* First time through or recovery */
      char* base = (char*)CALL_MORECORE(0);
      if (base != CMFAIL) {
        asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE);
        /* Adjust to end on a page boundary */
        if (!is_page_aligned(base))
          asize += (page_align((size_t)base) - (size_t)base);
        /* Can't call MORECORE if size is negative when treated as signed */
        if (asize < HALF_MAX_SIZE_T &&
            (br = (char*)(CALL_MORECORE(asize))) == base) {
          tbase = base;
          tsize = asize;
        }
      }
    }
    else {
      /* Subtract out existing available top space from MORECORE request. */
      asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE);
      /* Use mem here only if it did continuously extend old space */
      if (asize < HALF_MAX_SIZE_T &&
          (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) {
        tbase = br;
        tsize = asize;
      }
    }

    if (tbase == CMFAIL) {    /* Cope with partial failure */
      if (br != CMFAIL) {    /* Try to use/extend the space we did get */
        if (asize < HALF_MAX_SIZE_T &&
            asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) {
          size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize);
          if (esize < HALF_MAX_SIZE_T) {
            char* end = (char*)CALL_MORECORE(esize);
            if (end != CMFAIL)
              asize += esize;
            else {            /* Can't use; try to release */
              CALL_MORECORE(-asize);
              br = CMFAIL;
            }
          }
        }
      }
      if (br != CMFAIL) {    /* Use the space we did get */
        tbase = br;
        tsize = asize;
      }
      else
        disable_contiguous(m); /* Don't try contiguous path in the future */
    }

    RELEASE_MORECORE_LOCK();
  }

  if (HAVE_MMAP && tbase == CMFAIL) {  /* Try MMAP */
    size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE;
    size_t rsize = granularity_align(req);
    if (rsize > nb) { /* Fail if wraps around zero */
      char* mp = (char*)(CALL_MMAP(rsize));
      if (mp != CMFAIL) {
        tbase = mp;
        tsize = rsize;
        mmap_flag = IS_MMAPPED_BIT;
      }
    }
  }

  if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */
    size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE);
    if (asize < HALF_MAX_SIZE_T) {
      char* br = CMFAIL;
      char* end = CMFAIL;
      ACQUIRE_MORECORE_LOCK();
      br = (char*)(CALL_MORECORE(asize));
      end = (char*)(CALL_MORECORE(0));
      RELEASE_MORECORE_LOCK();
      if (br != CMFAIL && end != CMFAIL && br < end) {
        size_t ssize = end - br;
        if (ssize > nb + TOP_FOOT_SIZE) {
          tbase = br;
          tsize = ssize;
        }
      }
    }
  }

  if (tbase != CMFAIL) {

    if ((m->footprint += tsize) > m->max_footprint)
      m->max_footprint = m->footprint;

    if (!is_initialized(m)) { /* first-time initialization */
      m->seg.base = m->least_addr = tbase;
      m->seg.size = tsize;
      m->seg.sflags = mmap_flag;
      m->magic = mparams.magic;
      init_bins(m);
      if (is_global(m)) 
        init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
      else {
        /* Offset top by embedded malloc_state */
        mchunkptr mn = next_chunk(mem2chunk(m));
        init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE);
      }
    }

    else {
      /* Try to merge with an existing segment */
      msegmentptr sp = &m->seg;
      while (sp != 0 && tbase != sp->base + sp->size)
        sp = sp->next;
      if (sp != 0 &&
          !is_extern_segment(sp) &&
          (sp->sflags & IS_MMAPPED_BIT) == mmap_flag &&
          segment_holds(sp, m->top)) { /* append */
        sp->size += tsize;
        init_top(m, m->top, m->topsize + tsize);
      }
      else {
        if (tbase < m->least_addr)
          m->least_addr = tbase;
        sp = &m->seg;
        while (sp != 0 && sp->base != tbase + tsize)
          sp = sp->next;
        if (sp != 0 &&
            !is_extern_segment(sp) &&
            (sp->sflags & IS_MMAPPED_BIT) == mmap_flag) {
          char* oldbase = sp->base;
          sp->base = tbase;
          sp->size += tsize;
          return prepend_alloc(m, tbase, oldbase, nb);
        }
        else
          add_segment(m, tbase, tsize, mmap_flag);
      }
    }

    if (nb < m->topsize) { /* Allocate from new or extended top space */
      size_t rsize = m->topsize -= nb;
      mchunkptr p = m->top;
      mchunkptr r = m->top = chunk_plus_offset(p, nb);
      r->head = rsize | PINUSE_BIT;
      set_size_and_pinuse_of_inuse_chunk(m, p, nb);
      check_top_chunk(m, m->top);
      check_malloced_chunk(m, chunk2mem(p), nb);
      return chunk2mem(p);
    }
  }

  MALLOC_FAILURE_ACTION;
  return 0;
}
dlmalloc.c3322
STATIC SIZE_Trelease_unused_segments(mstate m)
static size_t release_unused_segments(mstate m) {
  size_t released = 0;
  msegmentptr pred = &m->seg;
  msegmentptr sp = pred->next;
  while (sp != 0) {
    char* base = sp->base;
    size_t size = sp->size;
    msegmentptr next = sp->next;
    if (is_mmapped_segment(sp) && !is_extern_segment(sp)) {
      mchunkptr p = align_as_chunk(base);
      size_t psize = chunksize(p);
      /* Can unmap if first chunk holds entire segment and not pinned */
      if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) {
        tchunkptr tp = (tchunkptr)p;
        assert(segment_holds(sp, (char*)sp));
        if (p == m->dv) {
          m->dv = 0;
          m->dvsize = 0;
        }
        else {
          unlink_large_chunk(m, tp);
        }
        if (CALL_MUNMAP(base, size) == 0) {
          released += size;
          m->footprint -= size;
          /* unlink obsoleted record */
          sp = pred;
          sp->next = next;
        }
        else { /* back out if cannot unmap */
          insert_large_chunk(m, tp, psize);
        }
      }
    }
    pred = sp;
    sp = next;
  }
  return released;
}
dlmalloc.c3514
STATIC INTsys_trim(mstate m, size_t pad)
static int sys_trim(mstate m, size_t pad) {
  size_t released = 0;
  if (pad < MAX_REQUEST && is_initialized(m)) {
    pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */

    if (m->topsize > pad) {
      /* Shrink top space in granularity-size units, keeping at least one */
      size_t unit = mparams.granularity;
      size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit -
                      SIZE_T_ONE) * unit;
      msegmentptr sp = segment_holding(m, (char*)m->top);

      if (!is_extern_segment(sp)) {
        if (is_mmapped_segment(sp)) {
          if (HAVE_MMAP &&
              sp->size >= extra &&
              !has_segment_link(m, sp)) { /* can't shrink if pinned */
            size_t newsize = sp->size - extra;
            /* Prefer mremap, fall back to munmap */
            if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||
                (CALL_MUNMAP(sp->base + newsize, extra) == 0)) {
              released = extra;
            }
          }
        }
        else if (HAVE_MORECORE) {
          if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */
            extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit;
          ACQUIRE_MORECORE_LOCK();
          {
            /* Make sure end of memory is where we last set it. */
            char* old_br = (char*)(CALL_MORECORE(0));
            if (old_br == sp->base + sp->size) {
              char* rel_br = (char*)(CALL_MORECORE(-extra));
              char* new_br = (char*)(CALL_MORECORE(0));
              if (rel_br != CMFAIL && new_br < old_br)
                released = old_br - new_br;
            }
          }
          RELEASE_MORECORE_LOCK();
        }
      }

      if (released != 0) {
        sp->size -= released;
        m->footprint -= released;
        init_top(m, m->top, m->topsize - released);
        check_top_chunk(m, m->top);
      }
    }

    /* Unmap any unused mmapped segments */
    if (HAVE_MMAP) 
      released += release_unused_segments(m);

    /* On failure, disable autotrim to avoid repeated failed future calls */
    if (released == 0)
      m->trim_check = MAX_SIZE_T;
  }

  return (released != 0)? 1 : 0;
}
dlmalloc.c3555
STATIC VOID*tmalloc_large(mstate m, size_t nb)
static void* tmalloc_large(mstate m, size_t nb) {
  tchunkptr v = 0;
  size_t rsize = -nb; /* Unsigned negation */
  tchunkptr t;
  bindex_t idx;
  compute_tree_index(nb, idx);

  if ((t = *treebin_at(m, idx)) != 0) {
    /* Traverse tree for this bin looking for node with size == nb */
    size_t sizebits = nb << leftshift_for_tree_index(idx);
    tchunkptr rst = 0;  /* The deepest untaken right subtree */
    for (;;) {
      tchunkptr rt;
      size_t trem = chunksize(t) - nb;
      if (trem < rsize) {
        v = t;
        if ((rsize = trem) == 0)
          break;
      }
      rt = t->child[1];
      t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
      if (rt != 0 && rt != t)
        rst = rt;
      if (t == 0) {
        t = rst; /* set t to least subtree holding sizes > nb */
        break;
      }
      sizebits <<= 1;
    }
  }

  if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */
    binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap;
    if (leftbits != 0) {
      bindex_t i;
      binmap_t leastbit = least_bit(leftbits);
      compute_bit2idx(leastbit, i);
      t = *treebin_at(m, i);
    }
  }

  while (t != 0) { /* find smallest of tree or subtree */
    size_t trem = chunksize(t) - nb;
    if (trem < rsize) {
      rsize = trem;
      v = t;
    }
    t = leftmost_child(t);
  }

  /*  If dv is a better fit, return 0 so malloc will use it */
  if (v != 0 && rsize < (size_t)(m->dvsize - nb)) {
    if (RTCHECK(ok_address(m, v))) { /* split */
      mchunkptr r = chunk_plus_offset(v, nb);
      assert(chunksize(v) == rsize + nb);
      if (RTCHECK(ok_next(v, r))) {
        unlink_large_chunk(m, v);
        if (rsize < MIN_CHUNK_SIZE)
          set_inuse_and_pinuse(m, v, (rsize + nb));
        else {
          set_size_and_pinuse_of_inuse_chunk(m, v, nb);
          set_size_and_pinuse_of_free_chunk(r, rsize);
          insert_chunk(m, r, rsize);
        }
        return chunk2mem(v);
      }
    }
    CORRUPTION_ERROR_ACTION(m);
  }
  return 0;
}
dlmalloc.c3620
STATIC VOID*tmalloc_small(mstate m, size_t nb)
static void* tmalloc_small(mstate m, size_t nb) {
  tchunkptr t, v;
  size_t rsize;
  bindex_t i;
  binmap_t leastbit = least_bit(m->treemap);
  compute_bit2idx(leastbit, i);

  v = t = *treebin_at(m, i);
  rsize = chunksize(t) - nb;

  while ((t = leftmost_child(t)) != 0) {
    size_t trem = chunksize(t) - nb;
    if (trem < rsize) {
      rsize = trem;
      v = t;
    }
  }

  if (RTCHECK(ok_address(m, v))) {
    mchunkptr r = chunk_plus_offset(v, nb);
    assert(chunksize(v) == rsize + nb);
    if (RTCHECK(ok_next(v, r))) {
      unlink_large_chunk(m, v);
      if (rsize < MIN_CHUNK_SIZE)
        set_inuse_and_pinuse(m, v, (rsize + nb));
      else {
        set_size_and_pinuse_of_inuse_chunk(m, v, nb);
        set_size_and_pinuse_of_free_chunk(r, rsize);
        replace_dv(m, r, rsize);
      }
      return chunk2mem(v);
    }
  }

  CORRUPTION_ERROR_ACTION(m);
  return 0;
}
dlmalloc.c3693
STATIC VOID*internal_realloc(mstate m, void* oldmem, size_t bytes)
static void* internal_realloc(mstate m, void* oldmem, size_t bytes) {
  if (bytes >= MAX_REQUEST) {
    MALLOC_FAILURE_ACTION;
    return 0;
  }
  if (!PREACTION(m)) {
    mchunkptr oldp = mem2chunk(oldmem);
    size_t oldsize = chunksize(oldp);
    mchunkptr next = chunk_plus_offset(oldp, oldsize);
    mchunkptr newp = 0;
    void* extra = 0;

    /* Try to either shrink or extend into top. Else malloc-copy-free */

    if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) &&
                ok_next(oldp, next) && ok_pinuse(next))) {
      size_t nb = request2size(bytes);
      if (is_mmapped(oldp))
        newp = mmap_resize(m, oldp, nb);
      else if (oldsize >= nb) { /* already big enough */
        size_t rsize = oldsize - nb;
        newp = oldp;
        if (rsize >= MIN_CHUNK_SIZE) {
          mchunkptr remainder = chunk_plus_offset(newp, nb);
          set_inuse(m, newp, nb);
          set_inuse(m, remainder, rsize);
          extra = chunk2mem(remainder);
        }
      }
      else if (next == m->top && oldsize + m->topsize > nb) {
        /* Expand into top */
        size_t newsize = oldsize + m->topsize;
        size_t newtopsize = newsize - nb;
        mchunkptr newtop = chunk_plus_offset(oldp, nb);
        set_inuse(m, oldp, nb);
        newtop->head = newtopsize |PINUSE_BIT;
        m->top = newtop;
        m->topsize = newtopsize;
        newp = oldp;
      }
    }
    else {
      USAGE_ERROR_ACTION(m, oldmem);
      POSTACTION(m);
      return 0;
    }

    POSTACTION(m);

    if (newp != 0) {
      if (extra != 0) {
        internal_free(m, extra);
      }
      check_inuse_chunk(m, newp);
      return chunk2mem(newp);
    }
    else {
      void* newmem = internal_malloc(m, bytes);
      if (newmem != 0) {
        size_t oc = oldsize - overhead_for(oldp);
        memcpy(newmem, oldmem, (oc < bytes)? oc : bytes);
        internal_free(m, oldmem);
      }
      return newmem;
    }
  }
  return 0;
}
dlmalloc.c3734
STATIC VOID*internal_memalign(mstate m, size_t alignment, size_t bytes)
static void* internal_memalign(mstate m, size_t alignment, size_t bytes) {
  if (alignment <= MALLOC_ALIGNMENT)    /* Can just use malloc */
    return internal_malloc(m, bytes);
  if (alignment <  MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */
    alignment = MIN_CHUNK_SIZE;
  if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */
    size_t a = MALLOC_ALIGNMENT << 1;
    while (a < alignment) a <<= 1;
    alignment = a;
  }
  
  if (bytes >= MAX_REQUEST - alignment) {
    if (m != 0)  { /* Test isn't needed but avoids compiler warning */
      MALLOC_FAILURE_ACTION;
    }
  }
  else {
    size_t nb = request2size(bytes);
    size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD;
    char* mem = (char*)internal_malloc(m, req);
    if (mem != 0) {
      void* leader = 0;
      void* trailer = 0;
      mchunkptr p = mem2chunk(mem);

      if (PREACTION(m)) return 0;
      if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */
        /*
          Find an aligned spot inside chunk.  Since we need to give
          back leading space in a chunk of at least MIN_CHUNK_SIZE, if
          the first calculation places us at a spot with less than
          MIN_CHUNK_SIZE leader, we can move to the next aligned spot.
          We've allocated enough total room so that this is always
          possible.
        */
        char* br = (char*)mem2chunk((size_t)(((size_t)(mem +
                                                       alignment -
                                                       SIZE_T_ONE)) &
                                             -alignment));
        char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)?
          br : br+alignment;
        mchunkptr newp = (mchunkptr)pos;
        size_t leadsize = pos - (char*)(p);
        size_t newsize = chunksize(p) - leadsize;

        if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */
          newp->prev_foot = p->prev_foot + leadsize;
          newp->head = (newsize|CINUSE_BIT);
        }
        else { /* Otherwise, give back leader, use the rest */
          set_inuse(m, newp, newsize);
          set_inuse(m, p, leadsize);
          leader = chunk2mem(p);
        }
        p = newp;
      }

      /* Give back spare room at the end */
      if (!is_mmapped(p)) {
        size_t size = chunksize(p);
        if (size > nb + MIN_CHUNK_SIZE) {
          size_t remainder_size = size - nb;
          mchunkptr remainder = chunk_plus_offset(p, nb);
          set_inuse(m, p, nb);
          set_inuse(m, remainder, remainder_size);
          trailer = chunk2mem(remainder);
        }
      }

      assert (chunksize(p) >= nb);
      assert((((size_t)(chunk2mem(p))) % alignment) == 0);
      check_inuse_chunk(m, p);
      POSTACTION(m);
      if (leader != 0) {
        internal_free(m, leader);
      }
      if (trailer != 0) {
        internal_free(m, trailer);
      }
      return chunk2mem(p);
    }
  }
  return 0;
}
dlmalloc.c3805
STATIC VOID**ialloc(mstate m, size_t n_elements, size_t* sizes, int opts, void* chunks[])
static void** ialloc(mstate m,
                     size_t n_elements,
                     size_t* sizes,
                     int opts,
                     void* chunks[]) {
  /*
    This provides common support for independent_X routines, handling
    all of the combinations that can result.

    The opts arg has:
    bit 0 set if all elements are same size (using sizes[0])
    bit 1 set if elements should be zeroed
  */

  size_t    element_size;   /* chunksize of each element, if all same */
  size_t    contents_size;  /* total size of elements */
  size_t    array_size;     /* request size of pointer array */
  void*     mem;            /* malloced aggregate space */
  mchunkptr p;              /* corresponding chunk */
  size_t    remainder_size; /* remaining bytes while splitting */
  void**    marray;         /* either "chunks" or malloced ptr array */
  mchunkptr array_chunk;    /* chunk for malloced ptr array */
  flag_t    was_enabled;    /* to disable mmap */
  size_t    size;
  size_t    i;

  /* compute array length, if needed */
  if (chunks != 0) {
    if (n_elements == 0)
      return chunks; /* nothing to do */
    marray = chunks;
    array_size = 0;
  }
  else {
    /* if empty req, must still return chunk representing empty array */
    if (n_elements == 0)
      return (void**)internal_malloc(m, 0);
    marray = 0;
    array_size = request2size(n_elements * (sizeof(void*)));
  }

  /* compute total element size */
  if (opts & 0x1) { /* all-same-size */
    element_size = request2size(*sizes);
    contents_size = n_elements * element_size;
  }
  else { /* add up all the sizes */
    element_size = 0;
    contents_size = 0;
    for (i = 0; i != n_elements; ++i)
      contents_size += request2size(sizes[i]);
  }

  size = contents_size + array_size;

  /*
     Allocate the aggregate chunk.  First disable direct-mmapping so
     malloc won't use it, since we would not be able to later
     free/realloc space internal to a segregated mmap region.
  */
  was_enabled = use_mmap(m);
  disable_mmap(m);
  mem = internal_malloc(m, size - CHUNK_OVERHEAD);
  if (was_enabled)
    enable_mmap(m);
  if (mem == 0)
    return 0;

  if (PREACTION(m)) return 0;
  p = mem2chunk(mem);
  remainder_size = chunksize(p);

  assert(!is_mmapped(p));

  if (opts & 0x2) {       /* optionally clear the elements */
    memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size);
  }

  /* If not provided, allocate the pointer array as final part of chunk */
  if (marray == 0) {
    size_t  array_chunk_size;
    array_chunk = chunk_plus_offset(p, contents_size);
    array_chunk_size = remainder_size - contents_size;
    marray = (void**) (chunk2mem(array_chunk));
    set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size);
    remainder_size = contents_size;
  }

  /* split out elements */
  for (i = 0; ; ++i) {
    marray[i] = chunk2mem(p);
    if (i != n_elements-1) {
      if (element_size != 0)
        size = element_size;
      else
        size = request2size(sizes[i]);
      remainder_size -= size;
      set_size_and_pinuse_of_inuse_chunk(m, p, size);
      p = chunk_plus_offset(p, size);
    }
    else { /* the final element absorbs any overallocation slop */
      set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size);
      break;
    }
  }

#if DEBUG
  if (marray != chunks) {
    /* final element must have exactly exhausted chunk */
    if (element_size != 0) {
      assert(remainder_size == element_size);
    }
    else {
      assert(remainder_size == request2size(sizes[i]));
    }
    check_inuse_chunk(m, mem2chunk(marray));
  }
  for (i = 0; i != n_elements; ++i)
    check_inuse_chunk(m, mem2chunk(marray[i]));

#endif /* DEBUG */

  POSTACTION(m);
  return marray;
}
dlmalloc.c3892
VOID*dlmalloc(size_t bytes)
void* dlmalloc(size_t bytes) {
  /*
     Basic algorithm:
     If a small request (< 256 bytes minus per-chunk overhead):
       1. If one exists, use a remainderless chunk in associated smallbin.
          (Remainderless means that there are too few excess bytes to
          represent as a chunk.)
       2. If it is big enough, use the dv chunk, which is normally the
          chunk adjacent to the one used for the most recent small request.
       3. If one exists, split the smallest available chunk in a bin,
          saving remainder in dv.
       4. If it is big enough, use the top chunk.
       5. If available, get memory from system and use it
     Otherwise, for a large request:
       1. Find the smallest available binned chunk that fits, and use it
          if it is better fitting than dv chunk, splitting if necessary.
       2. If better fitting than any binned chunk, use the dv chunk.
       3. If it is big enough, use the top chunk.
       4. If request size >= mmap threshold, try to directly mmap this chunk.
       5. If available, get memory from system and use it

     The ugly goto's here ensure that postaction occurs along all paths.
  */

  if (!PREACTION(gm)) {
    void* mem;
    size_t nb;
    if (bytes <= MAX_SMALL_REQUEST) {
      bindex_t idx;
      binmap_t smallbits;
      nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
      idx = small_index(nb);
      smallbits = gm->smallmap >> idx;

      if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */
        mchunkptr b, p;
        idx += ~smallbits & 1;       /* Uses next bin if idx empty */
        b = smallbin_at(gm, idx);
        p = b->fd;
        assert(chunksize(p) == small_index2size(idx));
        unlink_first_small_chunk(gm, b, p, idx);
        set_inuse_and_pinuse(gm, p, small_index2size(idx));
        mem = chunk2mem(p);
        check_malloced_chunk(gm, mem, nb);
        goto postaction;
      }

      else if (nb > gm->dvsize) {
        if (smallbits != 0) { /* Use chunk in next nonempty smallbin */
          mchunkptr b, p, r;
          size_t rsize;
          bindex_t i;
          binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));
          binmap_t leastbit = least_bit(leftbits);
          compute_bit2idx(leastbit, i);
          b = smallbin_at(gm, i);
          p = b->fd;
          assert(chunksize(p) == small_index2size(i));
          unlink_first_small_chunk(gm, b, p, i);
          rsize = small_index2size(i) - nb;
          /* Fit here cannot be remainderless if 4byte sizes */
          if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)
            set_inuse_and_pinuse(gm, p, small_index2size(i));
          else {
            set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
            r = chunk_plus_offset(p, nb);
            set_size_and_pinuse_of_free_chunk(r, rsize);
            replace_dv(gm, r, rsize);
          }
          mem = chunk2mem(p);
          check_malloced_chunk(gm, mem, nb);
          goto postaction;
        }

        else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) {
          check_malloced_chunk(gm, mem, nb);
          goto postaction;
        }
      }
    }
    else if (bytes >= MAX_REQUEST)
      nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */
    else {
      nb = pad_request(bytes);
      if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) {
        check_malloced_chunk(gm, mem, nb);
        goto postaction;
      }
    }

    if (nb <= gm->dvsize) {
      size_t rsize = gm->dvsize - nb;
      mchunkptr p = gm->dv;
      if (rsize >= MIN_CHUNK_SIZE) { /* split dv */
        mchunkptr r = gm->dv = chunk_plus_offset(p, nb);
        gm->dvsize = rsize;
        set_size_and_pinuse_of_free_chunk(r, rsize);
        set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
      }
      else { /* exhaust dv */
        size_t dvs = gm->dvsize;
        gm->dvsize = 0;
        gm->dv = 0;
        set_inuse_and_pinuse(gm, p, dvs);
      }
      mem = chunk2mem(p);
      check_malloced_chunk(gm, mem, nb);
      goto postaction;
    }

    else if (nb < gm->topsize) { /* Split top */
      size_t rsize = gm->topsize -= nb;
      mchunkptr p = gm->top;
      mchunkptr r = gm->top = chunk_plus_offset(p, nb);
      r->head = rsize | PINUSE_BIT;
      set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
      mem = chunk2mem(p);
      check_top_chunk(gm, gm->top);
      check_malloced_chunk(gm, mem, nb);
      goto postaction;
    }

    mem = sys_alloc(gm, nb);

  postaction:
    POSTACTION(gm);
    return mem;
  }

  return 0;
}
dlmalloc.c4023
VOIDdlfree(void* mem)
void dlfree(void* mem) {
  /*
     Consolidate freed chunks with preceeding or succeeding bordering
     free chunks, if they exist, and then place in a bin.  Intermixed
     with special cases for top, dv, mmapped chunks, and usage errors.
  */

  if (mem != 0) {
    mchunkptr p  = mem2chunk(mem);
#if FOOTERS
    mstate fm = get_mstate_for(p);
    if (!ok_magic(fm)) {
      USAGE_ERROR_ACTION(fm, p);
      return;
    }
#else /* FOOTERS */
#define fm gm
#endif /* FOOTERS */
    if (!PREACTION(fm)) {
      check_inuse_chunk(fm, p);
      if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) {
        size_t psize = chunksize(p);
        mchunkptr next = chunk_plus_offset(p, psize);
        if (!pinuse(p)) {
          size_t prevsize = p->prev_foot;
          if ((prevsize & IS_MMAPPED_BIT) != 0) {
            prevsize &= ~IS_MMAPPED_BIT;
            psize += prevsize + MMAP_FOOT_PAD;
            if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
              fm->footprint -= psize;
            goto postaction;
          }
          else {
            mchunkptr prev = chunk_minus_offset(p, prevsize);
            psize += prevsize;
            p = prev;
            if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */
              if (p != fm->dv) {
                unlink_chunk(fm, p, prevsize);
              }
              else if ((next->head & INUSE_BITS) == INUSE_BITS) {
                fm->dvsize = psize;
                set_free_with_pinuse(p, psize, next);
                goto postaction;
              }
            }
            else
              goto erroraction;
          }
        }

        if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {
          if (!cinuse(next)) {  /* consolidate forward */
            if (next == fm->top) {
              size_t tsize = fm->topsize += psize;
              fm->top = p;
              p->head = tsize | PINUSE_BIT;
              if (p == fm->dv) {
                fm->dv = 0;
                fm->dvsize = 0;
              }
              if (should_trim(fm, tsize))
                sys_trim(fm, 0);
              goto postaction;
            }
            else if (next == fm->dv) {
              size_t dsize = fm->dvsize += psize;
              fm->dv = p;
              set_size_and_pinuse_of_free_chunk(p, dsize);
              goto postaction;
            }
            else {
              size_t nsize = chunksize(next);
              psize += nsize;
              unlink_chunk(fm, next, nsize);
              set_size_and_pinuse_of_free_chunk(p, psize);
              if (p == fm->dv) {
                fm->dvsize = psize;
                goto postaction;
              }
            }
          }
          else
            set_free_with_pinuse(p, psize, next);
          insert_chunk(fm, p, psize);
          check_free_chunk(fm, p);
          goto postaction;
        }
      }
    erroraction:
      USAGE_ERROR_ACTION(fm, p);
    postaction:
      POSTACTION(fm);
    }
  }
#if !FOOTERS
#undef fm
#endif /* FOOTERS */
}
dlmalloc.c4155
VOID*dlcalloc(size_t n_elements, size_t elem_size)
void* dlcalloc(size_t n_elements, size_t elem_size) {
  void* mem;
  size_t req = 0;
  if (n_elements != 0) {
    req = n_elements * elem_size;
    if (((n_elements | elem_size) & ~(size_t)0xffff) &&
        (req / n_elements != elem_size))
      req = MAX_SIZE_T; /* force downstream failure on overflow */
  }
  mem = dlmalloc(req);
  if (mem != 0 && calloc_must_clear(mem2chunk(mem)))
    memset(mem, 0, req);
  return mem;
}
dlmalloc.c4255
VOID*dlrealloc(void* oldmem, size_t bytes)
void* dlrealloc(void* oldmem, size_t bytes) {
  if (oldmem == 0)
    return dlmalloc(bytes);
#ifdef REALLOC_ZERO_BYTES_FREES
  if (bytes == 0) {
    dlfree(oldmem);
    return 0;
  }
#endif /* REALLOC_ZERO_BYTES_FREES */
  else {
#if ! FOOTERS
    mstate m = gm;
#else /* FOOTERS */
    mstate m = get_mstate_for(mem2chunk(oldmem));
    if (!ok_magic(m)) {
      USAGE_ERROR_ACTION(m, oldmem);
      return 0;
    }
#endif /* FOOTERS */
    return internal_realloc(m, oldmem, bytes);
  }
}
dlmalloc.c4270
VOID*dlmemalign(size_t alignment, size_t bytes)
void* dlmemalign(size_t alignment, size_t bytes) {
  return internal_memalign(gm, alignment, bytes);
}
dlmalloc.c4293
VOID**dlindependent_calloc(size_t n_elements, size_t elem_size, void* chunks[])
void** dlindependent_calloc(size_t n_elements, size_t elem_size,
                                 void* chunks[]) {
  size_t sz = elem_size; /* serves as 1-element array */
  return ialloc(gm, n_elements, &sz, 3, chunks);
}
dlmalloc.c4297
VOID**dlindependent_comalloc(size_t n_elements, size_t sizes[], void* chunks[])
void** dlindependent_comalloc(size_t n_elements, size_t sizes[],
                                   void* chunks[]) {
  return ialloc(gm, n_elements, sizes, 0, chunks);
}
dlmalloc.c4303
VOID*dlvalloc(size_t bytes)
void* dlvalloc(size_t bytes) {
  size_t pagesz;
  init_mparams();
  pagesz = mparams.page_size;
  return dlmemalign(pagesz, bytes);
}
dlmalloc.c4308
VOID*dlpvalloc(size_t bytes)
void* dlpvalloc(size_t bytes) {
  size_t pagesz;
  init_mparams();
  pagesz = mparams.page_size;
  return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE));
}
dlmalloc.c4315
INTdlmalloc_trim(size_t pad)
int dlmalloc_trim(size_t pad) {
  int result = 0;
  if (!PREACTION(gm)) {
    result = sys_trim(gm, pad);
    POSTACTION(gm);
  }
  return result;
}
dlmalloc.c4322
SIZE_Tdlmalloc_footprint(void)
size_t dlmalloc_footprint(void) {
  return gm->footprint;
}
dlmalloc.c4331
SIZE_Tdlmalloc_max_footprint(void)
size_t dlmalloc_max_footprint(void) {
  return gm->max_footprint;
}
dlmalloc.c4335
STRUCT MALLINFOdlmallinfo(void)
struct mallinfo dlmallinfo(void) {
  return internal_mallinfo(gm);
}
dlmalloc.c4340
VOIDdlmalloc_stats()
void dlmalloc_stats() {
  internal_malloc_stats(gm);
}
dlmalloc.c4345
SIZE_Tdlmalloc_usable_size(void* mem)
size_t dlmalloc_usable_size(void* mem) {
  if (mem != 0) {
    mchunkptr p = mem2chunk(mem);
    if (cinuse(p))
      return chunksize(p) - overhead_for(p);
  }
  return 0;
}
dlmalloc.c4349
INTdlmallopt(int param_number, int value)
int dlmallopt(int param_number, int value) {
  return change_mparam(param_number, value);
}
dlmalloc.c4358
STATIC MSTATEinit_user_mstate(char* tbase, size_t tsize)
static mstate init_user_mstate(char* tbase, size_t tsize) {
  size_t msize = pad_request(sizeof(struct malloc_state));
  mchunkptr mn;
  mchunkptr msp = align_as_chunk(tbase);
  mstate m = (mstate)(chunk2mem(msp));
  memset(m, 0, msize);
  INITIAL_LOCK(&m->mutex);
  msp->head = (msize|PINUSE_BIT|CINUSE_BIT);
  m->seg.base = m->least_addr = tbase;
  m->seg.size = m->footprint = m->max_footprint = tsize;
  m->magic = mparams.magic;
  m->mflags = mparams.default_mflags;
  disable_contiguous(m);
  init_bins(m);
  mn = next_chunk(mem2chunk(m));
  init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE);
  check_top_chunk(m, m->top);
  return m;
}
dlmalloc.c4368
MSPACEcreate_mspace(size_t capacity, int locked)
mspace create_mspace(size_t capacity, int locked) {
  mstate m = 0;
  size_t msize = pad_request(sizeof(struct malloc_state));
  init_mparams(); /* Ensure pagesize etc initialized */

  if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
    size_t rs = ((capacity == 0)? mparams.granularity :
                 (capacity + TOP_FOOT_SIZE + msize));
    size_t tsize = granularity_align(rs);
    char* tbase = (char*)(CALL_MMAP(tsize));
    if (tbase != CMFAIL) {
      m = init_user_mstate(tbase, tsize);
      m->seg.sflags = IS_MMAPPED_BIT;
      set_lock(m, locked);
    }
  }
  return (mspace)m;
}
dlmalloc.c4388
MSPACEcreate_mspace_with_base(void* base, size_t capacity, int locked)
mspace create_mspace_with_base(void* base, size_t capacity, int locked) {
  mstate m = 0;
  size_t msize = pad_request(sizeof(struct malloc_state));
  init_mparams(); /* Ensure pagesize etc initialized */

  if (capacity > msize + TOP_FOOT_SIZE &&
      capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
    m = init_user_mstate((char*)base, capacity);
    m->seg.sflags = EXTERN_BIT;
    set_lock(m, locked);
  }
  return (mspace)m;
}
dlmalloc.c4407
SIZE_Tdestroy_mspace(mspace msp)
size_t destroy_mspace(mspace msp) {
  size_t freed = 0;
  mstate ms = (mstate)msp;
  if (ok_magic(ms)) {
    msegmentptr sp = &ms->seg;
    while (sp != 0) {
      char* base = sp->base;
      size_t size = sp->size;
      flag_t flag = sp->sflags;
      sp = sp->next;
      if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) &&
          CALL_MUNMAP(base, size) == 0)
        freed += size;
    }
  }
  else {
    USAGE_ERROR_ACTION(ms,ms);
  }
  return freed;
}
dlmalloc.c4421
VOID*mspace_malloc(mspace msp, size_t bytes)
void* mspace_malloc(mspace msp, size_t bytes) {
  mstate ms = (mstate)msp;
  if (!ok_magic(ms)) {
    USAGE_ERROR_ACTION(ms,ms);
    return 0;
  }
  if (!PREACTION(ms)) {
    void* mem;
    size_t nb;
    if (bytes <= MAX_SMALL_REQUEST) {
      bindex_t idx;
      binmap_t smallbits;
      nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
      idx = small_index(nb);
      smallbits = ms->smallmap >> idx;

      if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */
        mchunkptr b, p;
        idx += ~smallbits & 1;       /* Uses next bin if idx empty */
        b = smallbin_at(ms, idx);
        p = b->fd;
        assert(chunksize(p) == small_index2size(idx));
        unlink_first_small_chunk(ms, b, p, idx);
        set_inuse_and_pinuse(ms, p, small_index2size(idx));
        mem = chunk2mem(p);
        check_malloced_chunk(ms, mem, nb);
        goto postaction;
      }

      else if (nb > ms->dvsize) {
        if (smallbits != 0) { /* Use chunk in next nonempty smallbin */
          mchunkptr b, p, r;
          size_t rsize;
          bindex_t i;
          binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));
          binmap_t leastbit = least_bit(leftbits);
          compute_bit2idx(leastbit, i);
          b = smallbin_at(ms, i);
          p = b->fd;
          assert(chunksize(p) == small_index2size(i));
          unlink_first_small_chunk(ms, b, p, i);
          rsize = small_index2size(i) - nb;
          /* Fit here cannot be remainderless if 4byte sizes */
          if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)
            set_inuse_and_pinuse(ms, p, small_index2size(i));
          else {
            set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
            r = chunk_plus_offset(p, nb);
            set_size_and_pinuse_of_free_chunk(r, rsize);
            replace_dv(ms, r, rsize);
          }
          mem = chunk2mem(p);
          check_malloced_chunk(ms, mem, nb);
          goto postaction;
        }

        else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) {
          check_malloced_chunk(ms, mem, nb);
          goto postaction;
        }
      }
    }
    else if (bytes >= MAX_REQUEST)
      nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */
    else {
      nb = pad_request(bytes);
      if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) {
        check_malloced_chunk(ms, mem, nb);
        goto postaction;
      }
    }

    if (nb <= ms->dvsize) {
      size_t rsize = ms->dvsize - nb;
      mchunkptr p = ms->dv;
      if (rsize >= MIN_CHUNK_SIZE) { /* split dv */
        mchunkptr r = ms->dv = chunk_plus_offset(p, nb);
        ms->dvsize = rsize;
        set_size_and_pinuse_of_free_chunk(r, rsize);
        set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
      }
      else { /* exhaust dv */
        size_t dvs = ms->dvsize;
        ms->dvsize = 0;
        ms->dv = 0;
        set_inuse_and_pinuse(ms, p, dvs);
      }
      mem = chunk2mem(p);
      check_malloced_chunk(ms, mem, nb);
      goto postaction;
    }

    else if (nb < ms->topsize) { /* Split top */
      size_t rsize = ms->topsize -= nb;
      mchunkptr p = ms->top;
      mchunkptr r = ms->top = chunk_plus_offset(p, nb);
      r->head = rsize | PINUSE_BIT;
      set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
      mem = chunk2mem(p);
      check_top_chunk(ms, ms->top);
      check_malloced_chunk(ms, mem, nb);
      goto postaction;
    }

    mem = sys_alloc(ms, nb);

  postaction:
    POSTACTION(ms);
    return mem;
  }

  return 0;
}
dlmalloc.c4448
VOIDmspace_free(mspace msp, void* mem)
void mspace_free(mspace msp, void* mem) {
  if (mem != 0) {
    mchunkptr p  = mem2chunk(mem);
#if FOOTERS
    mstate fm = get_mstate_for(p);
#else /* FOOTERS */
    mstate fm = (mstate)msp;
#endif /* FOOTERS */
    if (!ok_magic(fm)) {
      USAGE_ERROR_ACTION(fm, p);
      return;
    }
    if (!PREACTION(fm)) {
      check_inuse_chunk(fm, p);
      if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) {
        size_t psize = chunksize(p);
        mchunkptr next = chunk_plus_offset(p, psize);
        if (!pinuse(p)) {
          size_t prevsize = p->prev_foot;
          if ((prevsize & IS_MMAPPED_BIT) != 0) {
            prevsize &= ~IS_MMAPPED_BIT;
            psize += prevsize + MMAP_FOOT_PAD;
            if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
              fm->footprint -= psize;
            goto postaction;
          }
          else {
            mchunkptr prev = chunk_minus_offset(p, prevsize);
            psize += prevsize;
            p = prev;
            if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */
              if (p != fm->dv) {
                unlink_chunk(fm, p, prevsize);
              }
              else if ((next->head & INUSE_BITS) == INUSE_BITS) {
                fm->dvsize = psize;
                set_free_with_pinuse(p, psize, next);
                goto postaction;
              }
            }
            else
              goto erroraction;
          }
        }

        if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {
          if (!cinuse(next)) {  /* consolidate forward */
            if (next == fm->top) {
              size_t tsize = fm->topsize += psize;
              fm->top = p;
              p->head = tsize | PINUSE_BIT;
              if (p == fm->dv) {
                fm->dv = 0;
                fm->dvsize = 0;
              }
              if (should_trim(fm, tsize))
                sys_trim(fm, 0);
              goto postaction;
            }
            else if (next == fm->dv) {
              size_t dsize = fm->dvsize += psize;
              fm->dv = p;
              set_size_and_pinuse_of_free_chunk(p, dsize);
              goto postaction;
            }
            else {
              size_t nsize = chunksize(next);
              psize += nsize;
              unlink_chunk(fm, next, nsize);
              set_size_and_pinuse_of_free_chunk(p, psize);
              if (p == fm->dv) {
                fm->dvsize = psize;
                goto postaction;
              }
            }
          }
          else
            set_free_with_pinuse(p, psize, next);
          insert_chunk(fm, p, psize);
          check_free_chunk(fm, p);
          goto postaction;
        }
      }
    erroraction:
      USAGE_ERROR_ACTION(fm, p);
    postaction:
      POSTACTION(fm);
    }
  }
}
dlmalloc.c4562
VOID*mspace_calloc(mspace msp, size_t n_elements, size_t elem_size)
void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) {
  void* mem;
  size_t req = 0;
  mstate ms = (mstate)msp;
  if (!ok_magic(ms)) {
    USAGE_ERROR_ACTION(ms,ms);
    return 0;
  }
  if (n_elements != 0) {
    req = n_elements * elem_size;
    if (((n_elements | elem_size) & ~(size_t)0xffff) &&
        (req / n_elements != elem_size))
      req = MAX_SIZE_T; /* force downstream failure on overflow */
  }
  mem = internal_malloc(ms, req);
  if (mem != 0 && calloc_must_clear(mem2chunk(mem)))
    memset(mem, 0, req);
  return mem;
}
dlmalloc.c4653
VOID*mspace_realloc(mspace msp, void* oldmem, size_t bytes)
void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) {
  if (oldmem == 0)
    return mspace_malloc(msp, bytes);
#ifdef REALLOC_ZERO_BYTES_FREES
  if (bytes == 0) {
    mspace_free(msp, oldmem);
    return 0;
  }
#endif /* REALLOC_ZERO_BYTES_FREES */
  else {
#if FOOTERS
    mchunkptr p  = mem2chunk(oldmem);
    mstate ms = get_mstate_for(p);
#else /* FOOTERS */
    mstate ms = (mstate)msp;
#endif /* FOOTERS */
    if (!ok_magic(ms)) {
      USAGE_ERROR_ACTION(ms,ms);
      return 0;
    }
    return internal_realloc(ms, oldmem, bytes);
  }
}
dlmalloc.c4673
VOID*mspace_memalign(mspace msp, size_t alignment, size_t bytes)
void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) {
  mstate ms = (mstate)msp;
  if (!ok_magic(ms)) {
    USAGE_ERROR_ACTION(ms,ms);
    return 0;
  }
  return internal_memalign(ms, alignment, bytes);
}
dlmalloc.c4697
VOID**mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[])
void** mspace_independent_calloc(mspace msp, size_t n_elements,
                                 size_t elem_size, void* chunks[]) {
  size_t sz = elem_size; /* serves as 1-element array */
  mstate ms = (mstate)msp;
  if (!ok_magic(ms)) {
    USAGE_ERROR_ACTION(ms,ms);
    return 0;
  }
  return ialloc(ms, n_elements, &sz, 3, chunks);
}
dlmalloc.c4706
VOID**mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[])
void** mspace_independent_comalloc(mspace msp, size_t n_elements,
                                   size_t sizes[], void* chunks[]) {
  mstate ms = (mstate)msp;
  if (!ok_magic(ms)) {
    USAGE_ERROR_ACTION(ms,ms);
    return 0;
  }
  return ialloc(ms, n_elements, sizes, 0, chunks);
}
dlmalloc.c4717
INTmspace_trim(mspace msp, size_t pad)
int mspace_trim(mspace msp, size_t pad) {
  int result = 0;
  mstate ms = (mstate)msp;
  if (ok_magic(ms)) {
    if (!PREACTION(ms)) {
      result = sys_trim(ms, pad);
      POSTACTION(ms);
    }
  }
  else {
    USAGE_ERROR_ACTION(ms,ms);
  }
  return result;
}
dlmalloc.c4727
VOIDmspace_malloc_stats(mspace msp)
void mspace_malloc_stats(mspace msp) {
  mstate ms = (mstate)msp;
  if (ok_magic(ms)) {
    internal_malloc_stats(ms);
  }
  else {
    USAGE_ERROR_ACTION(ms,ms);
  }
}
dlmalloc.c4742
SIZE_Tmspace_footprint(mspace msp)
size_t mspace_footprint(mspace msp) {
  size_t result;
  mstate ms = (mstate)msp;
  if (ok_magic(ms)) {
    result = ms->footprint;
  }
  USAGE_ERROR_ACTION(ms,ms);
  return result;
}
dlmalloc.c4752
SIZE_Tmspace_max_footprint(mspace msp)
size_t mspace_max_footprint(mspace msp) {
  size_t result;
  mstate ms = (mstate)msp;
  if (ok_magic(ms)) {
    result = ms->max_footprint;
  }
  USAGE_ERROR_ACTION(ms,ms);
  return result;
}
dlmalloc.c4763
STRUCT MALLINFOmspace_mallinfo(mspace msp)
struct mallinfo mspace_mallinfo(mspace msp) {
  mstate ms = (mstate)msp;
  if (!ok_magic(ms)) {
    USAGE_ERROR_ACTION(ms,ms);
  }
  return internal_mallinfo(ms);
}
dlmalloc.c4775
INTmspace_mallopt(int param_number, int value)
int mspace_mallopt(int param_number, int value) {
  return change_mparam(param_number, value);
}

#endif /* MSPACES */

/* -------------------- Alternative MORECORE functions ------------------- */

dlmalloc.c4784
dynlibhb.c
TypeFunctionSourceLine
STATIC HB_GARBAGE_FUNC(hb_libRelease )
static HB_GARBAGE_FUNC( hb_libRelease )
{
   /* do nothing */
   HB_SYMBOL_UNUSED( Cargo );
}
dynlibhb.c70
STATIC VOID *hb_parlib( int iParam )
static void * hb_parlib( int iParam )
{
   void ** pDynLibPtr = ( void ** ) hb_parptrGC( hb_libRelease, iParam );

   return pDynLibPtr ? * pDynLibPtr : NULL;
}
dynlibhb.c78
HB_FUNCHB_LIBLOAD(void)
HB_FUNC( HB_LIBLOAD )
{
   void * hDynLib = NULL;

#if defined(HB_OS_WIN_32)
   if( hb_parclen( 1 ) > 0 )
   {
      int argc = hb_pcount() - 1, i;
      char **argv = NULL;

      if( argc > 0 )
      {
         argv = ( char** ) hb_xgrab( sizeof( char* ) * argc );
         for( i = 0; i < argc; ++i )
         {
            argv[i] = hb_parcx( i + 2 );
         }
      }

      /* use stack address as first level marker */
      hb_vmBeginSymbolGroup( ( void * ) hb_stackId(), TRUE );
      hDynLib = ( void * ) LoadLibraryA( hb_parc( 1 ) );
      /* set real marker */
      hb_vmInitSymbolGroup( hDynLib, argc, argv );
      if( argv )
      {
         hb_xfree( argv );
      }
   }
#elif defined(HB_OS_LINUX) && !defined(__WATCOMC__)
   if( hb_parclen( 1 ) > 0 )
   {
      int argc = hb_pcount() - 1, i;
      char **argv = NULL;

      if( argc > 0 )
      {
         argv = ( char** ) hb_xgrab( sizeof( char* ) * argc );
         for( i = 0; i < argc; ++i )
         {
            argv[i] = hb_parcx( i + 2 );
         }
      }

      /* use stack address as first level marker */
      hb_vmBeginSymbolGroup( ( void * ) hb_stackId(), TRUE );
      hDynLib = ( void * ) dlopen( hb_parc( 1 ), RTLD_LAZY | RTLD_GLOBAL );
      /* set real marker */
      hb_vmInitSymbolGroup( hDynLib, argc, argv );
      if( argv )
      {
         hb_xfree( argv );
      }
   }
#endif

   if( hDynLib )
   {
      void ** pLibPtr = ( void ** ) hb_gcAlloc( sizeof( void * ), hb_libRelease );
      * pLibPtr = hDynLib;
      hb_retptrGC( pLibPtr );
   }
   else
      hb_ret();
}
dynlibhb.c86
HB_FUNCHB_LIBFREE(void)
HB_FUNC( HB_LIBFREE )
{
#if defined(HB_OS_WIN_32)
   void * hDynLib = hb_parlib( 1 );

   if( hDynLib )
   {
      hb_vmExitSymbolGroup( hDynLib );
      hb_retl( FreeLibrary( ( HMODULE ) hDynLib ) );
   }
   else
#elif defined(HB_OS_LINUX) && !defined(__WATCOMC__)
   void * hDynLib = hb_parlib( 1 );

   if( hDynLib )
   {
      hb_vmExitSymbolGroup( hDynLib );
      hb_retl( dlclose( hDynLib ) == 0 );
   }
   else
#endif
   {
      hb_retl( FALSE );
   }
}
dynlibhb.c152
HB_FUNCHB_LIBERROR(void)
HB_FUNC( HB_LIBERROR )
{
#if defined(HB_OS_LINUX) && !defined(__WATCOMC__)
   hb_retc( dlerror() );
#else
   hb_retc( NULL );
#endif
}
dynlibhb.c178
HB_FUNCHB_LIBDO(void)
HB_FUNC( HB_LIBDO )
{
   if( hb_parclen( 1 ) > 0 )
   {
      PHB_DYNS pDynSym = hb_dynsymFindName( hb_parc( 1 ) );

      if( pDynSym )
      {
         USHORT uiPCount = hb_pcount();
         USHORT uiParam;

         hb_vmPushSymbol( pDynSym->pSymbol );
         hb_vmPushNil();

         /* same logic here as from HB_FUNC( EVAL ) */
         for( uiParam = 2; uiParam <= uiPCount; uiParam++ )
         {
            hb_vmPush( hb_stackItemFromBase( uiParam ) );
         }

         hb_vmDo( ( USHORT ) ( uiPCount - 1 ) );
      }
   }
}
dynlibhb.c191
dynsym.c
TypeFunctionSourceLine
STATIC PHB_DYNShb_dynsymInsert( PHB_SYMB pSymbol, UINT uiPos )
static PHB_DYNS hb_dynsymInsert( PHB_SYMB pSymbol, UINT uiPos )
{
   PHB_DYNS pDynSym;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymInsert(%p,%u)", pSymbol, uiPos));

   if( ++s_uiDynSymbols == 0 )
   {
      --s_uiDynSymbols;
      hb_errInternal( 6004, "Internal error: size of dynamic symbol table exceed", NULL, NULL );
   }
   else if( s_uiDynSymbols == 1 )
   {
      s_pDynItems = ( PDYNHB_ITEM ) hb_xgrab( sizeof( DYNHB_ITEM ) );
   }
   else
   {
      s_pDynItems = ( PDYNHB_ITEM ) hb_xrealloc( s_pDynItems, s_uiDynSymbols * sizeof( DYNHB_ITEM ) );
      memmove( &s_pDynItems[ uiPos + 1 ], &s_pDynItems[ uiPos ],
               sizeof( DYNHB_ITEM ) * ( s_uiDynSymbols - uiPos - 1 ) );
   }

   pDynSym = ( PHB_DYNS ) hb_xgrab( sizeof( HB_DYNS ) );
   memset( pDynSym, 0, sizeof( HB_DYNS ) );
   pDynSym->pSymbol  = pSymbol;
   pDynSym->uiSymNum = s_uiDynSymbols;

   pSymbol->pDynSym = s_pDynItems[ uiPos ].pDynSym = pDynSym;

   return pDynSym;
}
dynsym.c97
STATIC PHB_DYNShb_dynsymPos( const char * szName, UINT * puiPos )
static PHB_DYNS hb_dynsymPos( const char * szName, UINT * puiPos )
{
   UINT uiFirst, uiLast, uiMiddle;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymPos(%s,%p)", szName, puiPos));

   uiFirst = 0;
   uiLast = s_uiDynSymbols;
   uiMiddle = uiLast >> 1;

   while( uiFirst < uiLast )
   {
      int iCmp = strcmp( s_pDynItems[ uiMiddle ].pDynSym->pSymbol->szName, szName );

      if( iCmp == 0 )
      {
         *puiPos = uiMiddle;
         return s_pDynItems[ uiMiddle ].pDynSym;
      }
      else if( iCmp < 0 )
         uiLast = uiMiddle;
      else /* if( iCmp > 0 ) */
         uiFirst = uiMiddle + 1;
      uiMiddle = ( uiFirst + uiLast ) >> 1;
   }

   *puiPos = uiMiddle;

   return NULL;
}
dynsym.c132
STATIC PHB_SYMBhb_symbolAlloc( const char * szName )
static PHB_SYMB hb_symbolAlloc( const char * szName )
{
   PHB_SYM_HOLDER pHolder;
   int iLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_symbolAlloc(%s)", szName));

   iLen = strlen( szName );
   pHolder = ( PHB_SYM_HOLDER ) hb_xgrab( sizeof( HB_SYM_HOLDER ) + iLen );
   memcpy( pHolder->szName, szName, iLen + 1 );
   pHolder->pNext = s_pAllocSyms;
   s_pAllocSyms = pHolder;

   pHolder->symbol.szName        = pHolder->szName;
   pHolder->symbol.scope.value   = 0;
   pHolder->symbol.value.pFunPtr = NULL;
   pHolder->symbol.pDynSym       = NULL;

   return &pHolder->symbol;
}
dynsym.c167
HB_EXPORT PHB_DYNShb_dynsymFind( const char * szName )
HB_EXPORT PHB_DYNS hb_dynsymFind( const char * szName )
{
   UINT uiFirst, uiLast;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymFind(%s)", szName));

   HB_DYNSYM_LOCK

   uiFirst = 0;
   uiLast = s_uiDynSymbols;

   while( uiFirst < uiLast )
   {
      UINT uiMiddle = ( uiFirst + uiLast ) >> 1;
      int iCmp = strcmp( s_pDynItems[ uiMiddle ].pDynSym->pSymbol->szName, szName );

      if( iCmp == 0 )
      {
         HB_DYNSYM_UNLOCK
         return s_pDynItems[ uiMiddle ].pDynSym;
      }
      else if( iCmp < 0 )
         uiLast = uiMiddle;
      else /* if( iCmp > 0 ) */
         uiFirst = uiMiddle + 1;
   }

   HB_DYNSYM_UNLOCK

   return NULL;
}
dynsym.c191
HB_EXPORT PHB_SYMBhb_symbolNew( const char * szName )
HB_EXPORT PHB_SYMB hb_symbolNew( const char * szName )
{
   PHB_SYMB pSymbol;

   HB_TRACE(HB_TR_DEBUG, ("hb_symbolNew(%s)", szName));

   HB_DYNSYM_LOCK

   pSymbol = hb_symbolAlloc( szName );

   HB_DYNSYM_UNLOCK

   return pSymbol;
}
dynsym.c224
HB_EXPORT PHB_DYNShb_dynsymNew( PHB_SYMB pSymbol )
HB_EXPORT PHB_DYNS hb_dynsymNew( PHB_SYMB pSymbol )
{
   PHB_DYNS pDynSym;
   UINT uiPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymNew(%p)", pSymbol));

   HB_DYNSYM_LOCK

   pDynSym = hb_dynsymPos( pSymbol->szName, &uiPos ); /* Find position */
   if( ! pDynSym )
      pDynSym = hb_dynsymInsert( pSymbol, uiPos );
   else
   {
      pSymbol->pDynSym = pDynSym;

      if( ( pDynSym->pSymbol->scope.value &
            pSymbol->scope.value & HB_FS_LOCAL ) != 0 &&
            pDynSym->pSymbol != pSymbol )
      {
         /* Someone is using linker which allows to create binaries
          * with multiple function definitions. It's a big chance that
          * wrong binaries are created in such case, f.e both functions
          * linked and not all references updated. Anyhow now we will
          * have to guess which symbol is the real local one [druzus]
          */
         /* Let's check if linker updated function address so both symbols
          * refer to the same function
          */
         if( pDynSym->pSymbol->value.pFunPtr == pSymbol->value.pFunPtr )
         {
            /* The addresses have been updated, f.e. in such way works GCC
             * in Linux (but not MinGW and DJGPP) if user will allow to create
             * binaries with multiple symbols by
             *    -Wl,--allow-multiple-definition
             * when whole module cannot be cleanly replaced.
             * OpenWatcom for Linux, DOS and Windows (I haven't tested OS2
             * version), POCC and XCC (with /FORCE:MULTIPLE) also update
             * addresses in such case.
             *
             * We are guessing that symbols are registered in reverted order
             * so we remove the HB_FS_LOCAL flag from previously registered
             * symbol but some linkers may use different order so it does
             * not have to be true in all cases
             */
            pDynSym->pSymbol->scope.value &= ~HB_FS_LOCAL;
         }
         else
         {
            /* We have multiple symbol with the same name which refer
             * to different public functions inside this single binary
             * Let's check if this symbol is loaded from dynamic library
             * (.so, .dll, .dyn, ...) or .hrb file
             */
            if( pSymbol->scope.value & HB_FS_PCODEFUNC )
            {
               /* It's dynamic module so we are guessing that HVM
                * intentionally not updated function address allowing
                * multiple functions, f.e. programmer asked about keeping
                * local references using HB_LIBLOAD()/HB_HBRLOAD() parameter.
                * In such case update pDynSym address in the new symbol but
                * do not register it as the main one
                */
               HB_DYNSYM_UNLOCK
               return pDynSym;                /* Return pointer to DynSym */
            }
            /* The multiple symbols comes from single binaries - we have to
             * decide what to do with them. We can leave it as is or we can
             * try to overload one symbol so both will point to the same
             * function. For .prg code such overloading will work but not
             * for C code which makes sth like: HB_FUNC_EXEC( funcname )
             * In such case we cannot do anything - we cannot even detect
             * such situation. In some cases even linker cannot detect it
             * because C compiler can make autoinlining or some bindings
             * which are not visible for linker
             */
            /* Let's try to overload one of the functions. Simple:
             *    pDynSym->pSymbol->value.pFunPtr = pSymbol->value.pFunPtr;
             * is not good idea because it's possible that this symbol will
             * be overloaded yet another time after preprocessing rest of
             * symbols so we will use HB_FS_DEFERRED flag which is updated
             * dynamically in hb_vmSend()/hb_vmDo() functions
             */
#define HB_OVERLOAD_MULTIPLE_FUNC

#if defined( HB_OVERLOAD_MULTIPLE_FUNC )
            /* In such way works MinGW, DJGPP, BCC */
#if defined( __GNUC__ ) && !defined( __DJGPP__ )
            /* MinGW (like most of other GCC ports) uses reverted order for
             * initialization functions
             */
            pDynSym->pSymbol->scope.value &= ~HB_FS_LOCAL;
            pDynSym->pSymbol->scope.value |= HB_FS_DEFERRED;
#else
            /* BCC, DJGPP, ... */
            pSymbol->scope.value &= ~HB_FS_LOCAL;
            pSymbol->scope.value |= HB_FS_DEFERRED;
#endif
#endif
         }
      }

      if( ( !pDynSym->pSymbol->value.pFunPtr && pSymbol->value.pFunPtr ) ||
          ( pSymbol->scope.value & HB_FS_LOCAL ) != 0 )
      {
         pDynSym->pSymbol = pSymbol;
#ifndef HB_NO_PROFILER
         pDynSym->ulCalls = 0;
         pDynSym->ulTime  = 0;
         pDynSym->ulRecurse = 0;
#endif
      }
   }

   HB_DYNSYM_UNLOCK

   return pDynSym;
}
dynsym.c240
HB_EXPORT PHB_DYNShb_dynsymGetCase( const char * szName )
HB_EXPORT PHB_DYNS hb_dynsymGetCase( const char * szName )
{
   PHB_DYNS pDynSym;
   UINT uiPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymGetCase(%s)", szName));

   HB_DYNSYM_LOCK

   pDynSym = hb_dynsymPos( szName, &uiPos );
   if( ! pDynSym )
      pDynSym = hb_dynsymInsert( hb_symbolAlloc( szName ), uiPos );

   HB_DYNSYM_UNLOCK

   return pDynSym;
}
dynsym.c360
HB_EXPORT PHB_DYNShb_dynsymGet( const char * szName )
HB_EXPORT PHB_DYNS hb_dynsymGet( const char * szName )  /* finds and creates a symbol if not found */
{
   char szUprName[ HB_SYMBOL_NAME_LEN + 1 ];

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymGet(%s)", szName));

   /* make a copy as we may get a const string, then turn it to uppercase */
   /* NOTE: This block is optimized for speed [vszakats] */
   {
      int iLen = HB_SYMBOL_NAME_LEN;
      char * pDest = szUprName;

      do
      {
         char cChar = *szName++;
         if( cChar == 0 || cChar == ' ' || cChar == '\t' )
            break;
         else if( cChar >= 'a' && cChar <= 'z' )
            *pDest++ = cChar - ( 'a' - 'A' );
         else
            *pDest++ = cChar;
      }
      while( --iLen );
      *pDest = '\0';
   }

   return hb_dynsymGetCase( szUprName );
}
dynsym.c379
HB_EXPORT PHB_DYNShb_dynsymFindName( const char * szName )
HB_EXPORT PHB_DYNS hb_dynsymFindName( const char * szName )  /* finds a symbol */
{
   char szUprName[ HB_SYMBOL_NAME_LEN + 1 ];

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymFindName(%s)", szName));

   /* make a copy as we may get a const string, then turn it to uppercase */
   /* NOTE: This block is optimized for speed [vszakats] */
   {
      int iLen = HB_SYMBOL_NAME_LEN;
      char * pDest = szUprName;

      do
      {
         char cChar = *szName++;
         if( cChar == 0 || cChar == ' ' || cChar == '\t' )
            break;
         else if( cChar >= 'a' && cChar <= 'z' )
            *pDest++ = cChar - ( 'a' - 'A' );
         else
            *pDest++ = cChar;
      }
      while( --iLen );
      *pDest = '\0';
   }

   return hb_dynsymFind( szUprName );
}
dynsym.c408
HB_EXPORT PHB_SYMBhb_dynsymGetSymbol( const char * szName )
HB_EXPORT PHB_SYMB hb_dynsymGetSymbol( const char * szName )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymGetSymbol(%s)", szName));

   return hb_dynsymGet( szName )->pSymbol;
}
dynsym.c437
HB_EXPORT PHB_SYMBhb_dynsymFindSymbol( const char * szName )
HB_EXPORT PHB_SYMB hb_dynsymFindSymbol( const char * szName )
{
   PHB_DYNS pDynSym;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymFindSymbol(%s)", szName));

   pDynSym = hb_dynsymFind( szName );
   return pDynSym ? pDynSym->pSymbol : NULL;
}
dynsym.c444
HB_EXPORT PHB_SYMBhb_dynsymSymbol( PHB_DYNS pDynSym )
HB_EXPORT PHB_SYMB hb_dynsymSymbol( PHB_DYNS pDynSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymSymbol(%p)", pDynSym));

   return pDynSym->pSymbol;
}
dynsym.c454
HB_EXPORT CONST CHAR *hb_dynsymName( PHB_DYNS pDynSym )
HB_EXPORT const char * hb_dynsymName( PHB_DYNS pDynSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymName(%p)", pDynSym));

   return pDynSym->pSymbol->szName;
}
dynsym.c461
HB_EXPORT BOOLhb_dynsymIsFunction( PHB_DYNS pDynSym )
HB_EXPORT BOOL hb_dynsymIsFunction( PHB_DYNS pDynSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymIsFunction(%p)", pDynSym));

   return pDynSym->pSymbol->value.pFunPtr != NULL;
}
dynsym.c468
PHB_ITEMhb_dynsymGetMemvar( PHB_DYNS pDynSym )
PHB_ITEM hb_dynsymGetMemvar( PHB_DYNS pDynSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymGetMemvar(%p)", pDynSym));

   return ( PHB_ITEM ) hb_dynsymHandles( pDynSym )->pMemvar;
}
dynsym.c475
VOIDhb_dynsymSetMemvar( PHB_DYNS pDynSym, PHB_ITEM pMemvar )
void hb_dynsymSetMemvar( PHB_DYNS pDynSym, PHB_ITEM pMemvar )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymSetMemvar(%p,%p)", pDynSym, pMemvar));

   hb_dynsymHandles( pDynSym )->pMemvar = ( void * ) pMemvar;
}
dynsym.c482
HB_EXPORT INThb_dynsymAreaHandle( PHB_DYNS pDynSym )
HB_EXPORT int hb_dynsymAreaHandle( PHB_DYNS pDynSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymAreaHandle(%p)", pDynSym));

   return hb_dynsymHandles( pDynSym )->uiArea;
}
dynsym.c489
HB_EXPORT VOIDhb_dynsymSetAreaHandle( PHB_DYNS pDynSym, int iArea )
HB_EXPORT void hb_dynsymSetAreaHandle( PHB_DYNS pDynSym, int iArea )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymSetAreaHandle(%p,%d)", pDynSym, iArea));

   hb_dynsymHandles( pDynSym )->uiArea = ( USHORT ) iArea;
}
dynsym.c496
STATIC PHB_DYNShb_dynsymGetByIndex( long lIndex )
static PHB_DYNS hb_dynsymGetByIndex( long lIndex )
{
   PHB_DYNS pDynSym = NULL;

   HB_DYNSYM_LOCK

   if( lIndex >= 1 && lIndex <= s_uiDynSymbols )
      pDynSym = s_pDynItems[ lIndex - 1 ].pDynSym;

   HB_DYNSYM_UNLOCK

   return pDynSym;
}
dynsym.c503
VOIDhb_dynsymEval( PHB_DYNS_FUNC pFunction, void * Cargo )
void hb_dynsymEval( PHB_DYNS_FUNC pFunction, void * Cargo )
{
   PHB_DYNS pDynSym = NULL;
   USHORT uiPos = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymEval(%p, %p)", pFunction, Cargo));

   while( TRUE )
   {

      HB_DYNSYM_LOCK

      if( pDynSym )
      {
         /* protection against resizing dynamic symbol by
          * user function or other thread in MT mode
          */
         while( s_pDynItems[ uiPos ].pDynSym != pDynSym )
         {
            if( ++uiPos >= s_uiDynSymbols )
               break;
         }
      }
      if( ++uiPos < s_uiDynSymbols )
         pDynSym = s_pDynItems[ uiPos ].pDynSym;
      else
         pDynSym = NULL;

      HB_DYNSYM_UNLOCK

      if( !pDynSym || !( pFunction )( pDynSym, Cargo ) )
         break;
   }
}
dynsym.c517
VOIDhb_dynsymProtectEval( PHB_DYNS_FUNC pFunction, void * Cargo )
void hb_dynsymProtectEval( PHB_DYNS_FUNC pFunction, void * Cargo )
{
   USHORT uiPos = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymProtectEval(%p, %p)", pFunction, Cargo));

   HB_DYNSYM_LOCK

   while( uiPos < s_uiDynSymbols )
   {
      if( !( pFunction )( s_pDynItems[ uiPos++ ].pDynSym, Cargo ) )
         break;
   }

   HB_DYNSYM_UNLOCK
}
dynsym.c552
VOIDhb_dynsymRelease( void )
void hb_dynsymRelease( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dynsymRelease()"));

   HB_DYNSYM_LOCK

   if( s_uiDynSymbols )
   {
      do
         hb_xfree( ( s_pDynItems + --s_uiDynSymbols )->pDynSym );
      while( s_uiDynSymbols );
      hb_xfree( s_pDynItems );
      s_pDynItems = NULL;
   }

   while( s_pAllocSyms )
   {
      PHB_SYM_HOLDER pHolder = s_pAllocSyms;
      s_pAllocSyms = s_pAllocSyms->pNext;
      hb_xfree( pHolder );
   }

   HB_DYNSYM_UNLOCK
}
dynsym.c569
HB_FUNC__DYNSCOUNT(void)
HB_FUNC( __DYNSCOUNT ) /* How much symbols do we have: dsCount = __dynsymCount() */
{
   hb_retnint( s_uiDynSymbols );
}
dynsym.c594
HB_FUNC__DYNSGETNAME(void)
HB_FUNC( __DYNSGETNAME ) /* Get name of symbol: cSymbol = __dynsymGetName( dsIndex ) */
{
   PHB_DYNS pDynSym = hb_dynsymGetByIndex( hb_parnl( 1 ) );

   hb_retc( pDynSym ? pDynSym->pSymbol->szName : NULL );
}
dynsym.c599
HB_FUNC__DYNSGETINDEX(void)
HB_FUNC( __DYNSGETINDEX ) /* Gimme index number of symbol: dsIndex = __dynsymGetIndex( cSymbol ) */
{
   PHB_DYNS pDynSym;
   UINT uiPos = 0;
   char * szName = hb_parc( 1 );

   if( szName )
   {
      pDynSym = hb_dynsymFindName( szName );
      if( pDynSym )
      {
         HB_DYNSYM_LOCK
         if( !hb_dynsymPos( pDynSym->pSymbol->szName, &uiPos ) )
            uiPos = 0;
         HB_DYNSYM_UNLOCK
      }
   }

   hb_retnint( uiPos );
}

HB_FUNC( __DYNSISFUN ) /* returns .t. if a symbol has a function/procedure pointer,
                          given its symbol index */
{
   PHB_DYNS pDynSym = hb_dynsymGetByIndex( hb_parnl( 1 ) );

   hb_retl( pDynSym && hb_dynsymIsFunction( pDynSym ) );
}

HB_FUNC( __DYNSGETPRF ) /* profiler: It returns an array with a function or procedure
                                     called and consumed times { nTimes, nTime }
                                     , given the dynamic symbol index */
{
#ifndef HB_NO_PROFILER
   PHB_DYNS pDynSym = hb_dynsymGetByIndex( hb_parnl( 1 ) );
#endif

   hb_reta( 2 );
   hb_stornl( 0, -1, 1 );
   hb_stornl( 0, -1, 2 );

#ifndef HB_NO_PROFILER
   if( pDynSym )
   {
      if( hb_dynsymIsFunction( pDynSym ) ) /* it is a function or procedure */
      {
         hb_stornl( pDynSym->ulCalls, -1, 1 );
         hb_stornl( pDynSym->ulTime,  -1, 2 );
      }
   }
#endif
}
dynsym.c606
HB_FUNC__DYNSN2PTR(void)
HB_FUNC( __DYNSN2PTR )
{
   char * szName = hb_parc( 1 );

   hb_retptr( szName ? hb_dynsymGet( szName ) : NULL );
}
dynsym.c659
HB_FUNC__DYNSN2SYM(void)
HB_FUNC( __DYNSN2SYM )
{
   char * szName = hb_parc( 1 );

   if( szName )
      hb_itemPutSymbol( hb_stackReturnItem(), hb_dynsymGet( szName )->pSymbol );
}
dynsym.c666
HB_FUNC__DYNSP2NAME(void)
HB_FUNC( __DYNSP2NAME )
{
   PHB_DYNS pDynSym = ( PHB_DYNS ) hb_parptr( 1 );

   hb_retc( pDynSym != NULL ? pDynSym->pSymbol->szName : NULL );
}
dynsym.c674
estack.c
TypeFunctionSourceLine
STATIC VOIDhb_stack_init( PHB_STACK pStack )
static void hb_stack_init( PHB_STACK pStack )
{
   LONG i;

   HB_TRACE(HB_TR_DEBUG, ("hb_stack_init(%p)", pStack));

   memset( pStack, 0, sizeof( HB_STACK ) );

   pStack->pItems = ( PHB_ITEM * ) hb_xgrab( sizeof( PHB_ITEM ) * STACK_INITHB_ITEMS );
   pStack->pBase  = pStack->pItems;
   pStack->pPos   = pStack->pItems;       /* points to the first stack item */
   pStack->wItems = STACK_INITHB_ITEMS;
   pStack->pEnd   = pStack->pItems + pStack->wItems;

   for( i = 0; i < pStack->wItems; ++i )
   {
      pStack->pItems[ i ] = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) );
      pStack->pItems[ i ]->type = HB_IT_NIL;
   }

   pStack->pPos++;
   hb_itemPutSymbol( * pStack->pItems, &s_initSymbol );
   ( * pStack->pItems )->item.asSymbol.stackstate = &pStack->state;

   pStack->rdd.uiCurrArea = 1;
}
estack.c159
STATIC VOIDhb_stack_destroy_TSD( PHB_STACK pStack )
static void hb_stack_destroy_TSD( PHB_STACK pStack )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stack_destroy_TSD(%p)", pStack));

   while( pStack->iTSD )
   {
      if( pStack->pTSD[pStack->iTSD].pTSD )
      {
         if( pStack->pTSD[pStack->iTSD].pTSD->pCleanFunc )
            pStack->pTSD[pStack->iTSD].pTSD->pCleanFunc(
                                          pStack->pTSD[pStack->iTSD].value );
         hb_xfree( pStack->pTSD[pStack->iTSD].value );
#if !defined( HB_MT_VM )
         pStack->pTSD[pStack->iTSD].pTSD->iHandle = 0;
#endif
      }
      if( --pStack->iTSD == 0 )
      {
         hb_xfree( pStack->pTSD );
         pStack->pTSD = NULL;
      }
   }
}
estack.c186
STATIC VOIDhb_stack_free( PHB_STACK pStack )
static void hb_stack_free( PHB_STACK pStack )
{
   LONG i;

   HB_TRACE(HB_TR_DEBUG, ("hb_stack_free(%p)", pStack));

   hb_stack_destroy_TSD( pStack );

   if( pStack->privates.stack )
   {
      hb_xfree( pStack->privates.stack );
      pStack->privates.stack = NULL;
      pStack->privates.size = pStack->privates.count =
      pStack->privates.base = 0;
   }
   i = pStack->wItems - 1;
   while( i >= 0 )
      hb_xfree( pStack->pItems[ i-- ] );
   hb_xfree( pStack->pItems );
   pStack->pItems = pStack->pPos = pStack->pBase = NULL;
#if defined( HB_MT_VM )
   if( pStack->byDirBuffer )
   {
      hb_xfree( pStack->byDirBuffer );
      pStack->byDirBuffer = NULL;
   }
   if( pStack->iDynH )
   {
      hb_xfree( pStack->pDynH );
      pStack->pDynH = NULL;
      pStack->iDynH = 0;
   }
#endif
}
estack.c210
VOIDhb_stackDestroyTSD( void )
void hb_stackDestroyTSD( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackDestroyTSD()"));

   hb_stack_destroy_TSD( &hb_stack );
}
estack.c245
VOID *hb_stackGetTSD( PHB_TSD pTSD )
void * hb_stackGetTSD( PHB_TSD pTSD )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackGetTSD(%p)", pTSD));

#if defined( HB_MT_VM )
   if( pTSD->iHandle == 0 || pTSD->iHandle > hb_stack.iTSD ||
       hb_stack.pTSD[pTSD->iHandle].pTSD == NULL )
   {
      if( pTSD->iHandle == 0 )
      {
         hb_threadEnterCriticalSection( &TSD_counter );
         /* repeated test protected by mutex to avoid race condition */
         if( pTSD->iHandle == 0 )
            pTSD->iHandle = ++s_iTSDCounter;
         hb_threadLeaveCriticalSection( &TSD_counter );
      }

      if( pTSD->iHandle > hb_stack.iTSD )
      {
         hb_stack.pTSD = ( PHB_TSD_HOLDER )
                        hb_xrealloc( hb_stack.pTSD, ( pTSD->iHandle + 1 ) *
                                                    sizeof( HB_TSD_HOLDER ) );
         memset( &hb_stack.pTSD[hb_stack.iTSD + 1], 0,
                 ( pTSD->iHandle - hb_stack.iTSD ) * sizeof( HB_TSD_HOLDER ) );
         hb_stack.iTSD = pTSD->iHandle;
      }
#else
   if( pTSD->iHandle == 0 )
   {
      ULONG ulSize = ( hb_stack.iTSD + 2 ) * sizeof( HB_TSD_HOLDER );
      if( hb_stack.iTSD == 0 )
      {
         hb_stack.pTSD = ( PHB_TSD_HOLDER ) hb_xgrab( ulSize );
         memset( hb_stack.pTSD, 0, ulSize );
      }
      else
      {
         hb_stack.pTSD = ( PHB_TSD_HOLDER ) hb_xrealloc( hb_stack.pTSD, ulSize );
      }
      pTSD->iHandle = ++hb_stack.iTSD;
#endif

      hb_stack.pTSD[pTSD->iHandle].pTSD  = pTSD;
      hb_stack.pTSD[pTSD->iHandle].value = hb_xgrab( pTSD->iSize );
      memset( hb_stack.pTSD[pTSD->iHandle].value, 0, pTSD->iSize );
      if( pTSD->pInitFunc )
         pTSD->pInitFunc( hb_stack.pTSD[pTSD->iHandle].value );
   }
   return hb_stack.pTSD[pTSD->iHandle].value;
}

void * hb_stackTestTSD( PHB_TSD pTSD )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackTestTSD(%p)", pTSD));

#if defined( HB_MT_VM )
   return ( pTSD->iHandle && pTSD->iHandle <= hb_stack.iTSD ) ?
                          hb_stack.pTSD[pTSD->iHandle].value : NULL;
#else
   return pTSD->iHandle ? hb_stack.pTSD[pTSD->iHandle].value : NULL;
#endif
}

void hb_stackInit( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stackInit()"));

#if defined( HB_MT_VM )
   hb_stack_alloc();
#endif
   {
      HB_STACK_TLS_PRELOAD
      hb_stack_init( &hb_stack );
   }
}

void hb_stackFree( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackFree()"));

   hb_stack_free( &hb_stack );

#if defined( HB_MT_VM )
   hb_stack_dealloc();
#endif
}

#if defined( HB_MT_VM )

#undef hb_stackList
void * hb_stackList( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackList()"));

   return hb_stack.pStackLst;
}

#undef hb_stackListSet
void hb_stackListSet( void * pStackLst )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackListSet(%p)", pStackLst));

   hb_stack.pStackLst = pStackLst;
}

#undef hb_stackIdSetActionRequest
void hb_stackIdSetActionRequest( void * pStackId, USHORT uiAction )
{
   ( ( PHB_STACK ) pStackId )->uiActionRequest = uiAction;
}

PHB_DYN_HANDLES hb_stackGetDynHandle( PHB_DYNS pDynSym )
{
   HB_STACK_TLS_PRELOAD
   int iDynSym;

   HB_TRACE(HB_TR_DEBUG, ("hb_stackGetDynHandle()"));

   iDynSym = pDynSym->uiSymNum;
   if( iDynSym > hb_stack.iDynH )
   {
      hb_stack.pDynH = ( PHB_DYN_HANDLES ) hb_xrealloc( hb_stack.pDynH,
                                          iDynSym * sizeof( HB_DYN_HANDLES ) );
      memset( &hb_stack.pDynH[ hb_stack.iDynH ], 0,
              ( iDynSym - hb_stack.iDynH ) * sizeof( HB_DYN_HANDLES ) );
      hb_stack.iDynH = iDynSym;
   }

   return &hb_stack.pDynH[ iDynSym - 1 ];
}

#undef hb_stackQuitState
BOOL hb_stackQuitState( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.uiQuitState != 0;
}

#undef hb_stackSetQuitState
void hb_stackSetQuitState( USHORT uiState )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.uiQuitState = uiState;
}

#undef hb_stackUnlock
int hb_stackUnlock( void )
{
   HB_STACK_TLS_PRELOAD
   return ++hb_stack.iUnlocked;
}

#undef hb_stackLock
int hb_stackLock( void )
{
   HB_STACK_TLS_PRELOAD
   return --hb_stack.iUnlocked;
}
#endif

#undef hb_stackGetPrivateStack
PHB_PRIVATE_STACK hb_stackGetPrivateStack( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackGetPrivateStack()"));

   return &hb_stack.privates;
}

#undef hb_stackSetStruct
PHB_SET_STRUCT hb_stackSetStruct( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackSetStruct()"));

   return &hb_stack.set;
}

#undef hb_stackId
void * hb_stackId( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackId()"));

   return ( void * ) &hb_stack;
}

#undef hb_stackPop
void hb_stackPop( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackPop()"));

   if( --hb_stack.pPos <= hb_stack.pBase )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );

   if( HB_IS_COMPLEX( * hb_stack.pPos ) )
      hb_itemClear( * hb_stack.pPos );
}

#undef hb_stackPopReturn
void hb_stackPopReturn( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackPopReturn()"));

   if( HB_IS_COMPLEX( &hb_stack.Return ) )
      hb_itemClear( &hb_stack.Return );

   if( --hb_stack.pPos <= hb_stack.pBase )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );

   hb_itemRawMove( &hb_stack.Return, * hb_stack.pPos );
}

#undef hb_stackDec
void hb_stackDec( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackDec()"));

   if( --hb_stack.pPos <= hb_stack.pBase )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );
}

#undef hb_stackDecrease
void hb_stackDecrease( ULONG ulItems )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackDecrease()"));

   if( ( hb_stack.pPos -= ulItems ) <= hb_stack.pBase )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );
}

#undef hb_stackPush
void hb_stackPush( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackPush()"));

   /* enough room for another item ? */
   if( ++hb_stack.pPos == hb_stack.pEnd )
      hb_stackIncrease();
}

#undef hb_stackAllocItem
HB_ITEM_PTR hb_stackAllocItem( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackAllocItem()"));

   if( ++hb_stack.pPos == hb_stack.pEnd )
      hb_stackIncrease();

   return * ( hb_stack.pPos - 1 );
}

#undef hb_stackPushReturn
void hb_stackPushReturn( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackPushReturn()"));

   hb_itemRawMove( * hb_stack.pPos, &hb_stack.Return );

   /* enough room for another item ? */
   if( ++hb_stack.pPos == hb_stack.pEnd )
      hb_stackIncrease();
}

void hb_stackIncrease( void )
{
   HB_STACK_TLS_PRELOAD
   LONG BaseIndex;   /* index of stack base */
   LONG CurrIndex;   /* index of current top item */
   LONG EndIndex;    /* index of current top item */

   HB_TRACE(HB_TR_DEBUG, ("hb_stackIncrease()"));

   BaseIndex = hb_stack.pBase - hb_stack.pItems;
   CurrIndex = hb_stack.pPos - hb_stack.pItems;
   EndIndex  = hb_stack.pEnd - hb_stack.pItems;

   /* no, make more headroom: */
   hb_stack.pItems = ( PHB_ITEM * ) hb_xrealloc( ( void * ) hb_stack.pItems,
            sizeof( PHB_ITEM ) * ( hb_stack.wItems + STACK_EXPANDHB_ITEMS ) );

   /* fix possibly modified by realloc pointers: */
   hb_stack.pPos   = hb_stack.pItems + CurrIndex;
   hb_stack.pBase  = hb_stack.pItems + BaseIndex;
   hb_stack.wItems += STACK_EXPANDHB_ITEMS;
   hb_stack.pEnd   = hb_stack.pItems + hb_stack.wItems;

   do
   {
      hb_stack.pItems[ EndIndex ] = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) );
      hb_stack.pItems[ EndIndex ]->type = HB_IT_NIL;
   }
   while( ++EndIndex < hb_stack.wItems );
}

void hb_stackRemove( LONG lUntilPos )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR * pEnd = hb_stack.pItems + lUntilPos;

   while( hb_stack.pPos > pEnd )
   {
      --hb_stack.pPos;
      if( HB_IS_COMPLEX( * hb_stack.pPos ) )
         hb_itemClear( * hb_stack.pPos );
   }
}

HB_ITEM_PTR hb_stackNewFrame( PHB_STACK_STATE pFrame, USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR * pBase, pItem;

   pBase = hb_stack.pPos - uiParams - 2;
   pItem = * pBase;  /* procedure symbol */

   if( ! HB_IS_SYMBOL( pItem ) )
   {
      hb_stackDispLocal();
      hb_errInternal( HB_EI_VMNOTSYMBOL, NULL, "hb_vmDo()", NULL );
   }

   pFrame->lBaseItem = hb_stack.pBase - hb_stack.pItems;
   pFrame->lStatics = hb_stack.lStatics;
   pFrame->ulPrivateBase = hb_memvarGetPrivatesBase();
   pFrame->uiClass = pFrame->uiMethod = pFrame->uiLineNo = 0;

   pItem->item.asSymbol.stackstate = pFrame;
   pItem->item.asSymbol.paramcnt = uiParams;
   /* set default value of 'paramdeclcnt' - it will be updated
    * in hb_vm[V]Frame only
    */
   pItem->item.asSymbol.paramdeclcnt = uiParams;
   hb_stack.pBase = pBase;

   return pItem;
}

void hb_stackOldFrame( PHB_STACK_STATE pFrame )
{
   HB_STACK_TLS_PRELOAD
   if( hb_stack.pPos <= hb_stack.pBase )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );

   do
   {
      --hb_stack.pPos;
      if( HB_IS_COMPLEX( * hb_stack.pPos ) )
         hb_itemClear( * hb_stack.pPos );
   }
   while( hb_stack.pPos > hb_stack.pBase );

   hb_stack.pBase = hb_stack.pItems + pFrame->lBaseItem;
   hb_stack.lStatics = pFrame->lStatics;
   hb_memvarSetPrivatesBase( pFrame->ulPrivateBase );
}

#undef hb_stackItem
HB_ITEM_PTR hb_stackItem( LONG iItemPos )
{
   HB_STACK_TLS_PRELOAD
   if( iItemPos < 0 )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );

   return * ( hb_stack.pItems + iItemPos );
}

#undef hb_stackItemFromTop
HB_ITEM_PTR hb_stackItemFromTop( int iFromTop )
{
   HB_STACK_TLS_PRELOAD
   if( iFromTop >= 0 )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );

   return * ( hb_stack.pPos + iFromTop );
}

#undef hb_stackItemFromBase
HB_ITEM_PTR hb_stackItemFromBase( int iFromBase )
{
   HB_STACK_TLS_PRELOAD
   if( iFromBase < 0 )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );

   return * ( hb_stack.pBase + iFromBase + 1 );
}

#undef hb_stackLocalVariable
HB_ITEM_PTR hb_stackLocalVariable( int *piFromBase )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pBase = *hb_stack.pBase;

/*   
   if( *piFromBase <= 0 )
      hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL );
*/
   if( pBase->item.asSymbol.paramcnt > pBase->item.asSymbol.paramdeclcnt )
   {
      /* function with variable number of parameters:
       * FUNCTION foo( a,b,c,...)
       * LOCAL x,y,z
       * number of passed parameters is bigger then number of declared
       * parameters - skip additional parameters only for local variables
       */
      if( *piFromBase > pBase->item.asSymbol.paramdeclcnt )
         *piFromBase += pBase->item.asSymbol.paramcnt - pBase->item.asSymbol.paramdeclcnt;
   }
   return * ( hb_stack.pBase + *piFromBase + 1 );
}

#undef hb_stackBaseItem
HB_ITEM_PTR hb_stackBaseItem( void )
{
   HB_STACK_TLS_PRELOAD
   return * hb_stack.pBase;
}

/* Returns SELF object, an evaluated codeblock or NIL for normal func/proc
*/
#undef hb_stackSelfItem
HB_ITEM_PTR hb_stackSelfItem( void )
{
   HB_STACK_TLS_PRELOAD
   return * ( hb_stack.pBase + 1 );
}

#undef hb_stackReturnItem
HB_ITEM_PTR hb_stackReturnItem( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_stackReturnItem()"));

   return &hb_stack.Return;
}

#undef hb_stackTopOffset
LONG hb_stackTopOffset( void )
{
   HB_STACK_TLS_PRELOAD

   return hb_stack.pPos - hb_stack.pItems;
}

#undef hb_stackBaseOffset
LONG hb_stackBaseOffset( void )
{
   HB_STACK_TLS_PRELOAD

   return hb_stack.pBase - hb_stack.pItems + 1;
}

#undef hb_stackTotalItems
LONG hb_stackTotalItems( void )
{
   HB_STACK_TLS_PRELOAD

   return hb_stack.wItems;
}

#undef hb_stackDateBuffer
char * hb_stackDateBuffer( void )
{
   HB_STACK_TLS_PRELOAD

   return hb_stack.szDate;
}

BYTE * hb_stackDirBuffer( void )
{
#if defined( HB_MT_VM )
   if( hb_stack_ready() )
   {
      HB_STACK_TLS_PRELOAD
      if( !hb_stack.byDirBuffer )
         hb_stack.byDirBuffer = ( BYTE * ) hb_xgrab( _POSIX_PATH_MAX + 1 );
      return hb_stack.byDirBuffer;
   }
#endif
   return s_byDirBuffer;
}

PHB_IOERRORS hb_stackIOErrors( void )
{
#if defined( HB_MT_VM )
   if( hb_stack_ready() )
   {
      HB_STACK_TLS_PRELOAD
      return &hb_stack.IOErrors;
   }
#endif
   return &s_IOErrors;
}

PHB_STACKRDD hb_stackRDD( void )
{
   HB_STACK_TLS_PRELOAD
   return &hb_stack.rdd;
}


#undef hb_stackGetStaticsBase
LONG hb_stackGetStaticsBase( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.lStatics;
}

#undef hb_stackSetStaticsBase
void hb_stackSetStaticsBase( LONG lBase )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.lStatics = lBase;
}

#undef hb_stackGetRecoverBase
LONG hb_stackGetRecoverBase( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.lRecoverBase;
}

#undef hb_stackSetRecoverBase
void hb_stackSetRecoverBase( LONG lBase )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.lRecoverBase = lBase;
}

#undef hb_stackGetActionRequest
USHORT hb_stackGetActionRequest( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.uiActionRequest;
}

#undef hb_stackSetActionRequest
void hb_stackSetActionRequest( USHORT uiAction )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.uiActionRequest = uiAction;
}

#undef hb_stackWithObjectItem
PHB_ITEM hb_stackWithObjectItem( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.lWithObject ?
                        * ( hb_stack.pItems + hb_stack.lWithObject ) : NULL;
}

#undef hb_stackWithObjectOffset
LONG hb_stackWithObjectOffset( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.lWithObject;
}

#undef hb_stackWithObjectSetOffset
void hb_stackWithObjectSetOffset( LONG lOffset )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.lWithObject = lOffset;
}

#undef hb_stackGetCDP
void * hb_stackGetCDP( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.pCDP;
}

#undef hb_stackSetCDP
void hb_stackSetCDP( void * pCDP )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.pCDP = pCDP;
}

#undef hb_stackGetLang
void * hb_stackGetLang( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stack.pLang;
}

#undef hb_stackSetLang
void hb_stackSetLang( void * pLang )
{
   HB_STACK_TLS_PRELOAD
   hb_stack.pLang = pLang;
}

#undef hb_stackItemBasePtr
PHB_ITEM ** hb_stackItemBasePtr( void )
{
   HB_STACK_TLS_PRELOAD
   return &hb_stack.pItems;
}

void hb_stackClearMevarsBase( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pBase;

   HB_TRACE(HB_TR_DEBUG, ("hb_stackClearMevarsBase()"));

   pBase = * hb_stack.pBase;

   while( pBase->item.asSymbol.stackstate->ulPrivateBase != 0 )
   {
      pBase->item.asSymbol.stackstate->ulPrivateBase = 0;
      pBase = * ( hb_stack.pItems + pBase->item.asSymbol.stackstate->lBaseItem );
   }
}

int hb_stackCallDepth( void )
{
   HB_STACK_TLS_PRELOAD
   LONG lOffset = hb_stack.pBase - hb_stack.pItems;
   int iLevel = 0;

   while( lOffset > 0 )
   {
      lOffset = ( * ( hb_stack.pItems + lOffset ) )->item.asSymbol.stackstate->lBaseItem;
      ++iLevel;
   }

   return iLevel;
}

LONG hb_stackBaseProcOffset( int iLevel )
{
   HB_STACK_TLS_PRELOAD
   LONG lOffset = hb_stack.pBase - hb_stack.pItems;

   while( iLevel-- > 0 && lOffset > 0 )
      lOffset = ( * ( hb_stack.pItems + lOffset ) )->item.asSymbol.stackstate->lBaseItem;

   if( iLevel < 0 && ( lOffset > 0 || HB_IS_SYMBOL( * hb_stack.pItems ) ) )
      return lOffset;
   else
      return -1;
}

void hb_stackBaseProcInfo( char * szProcName, USHORT * puiProcLine )
{
   /*
    * This function is called by FM module and has to be ready for execution
    * before hb_stack initialization, [druzus]
    * szProcName should be at least HB_SYMBOL_NAME_LEN + 1 bytes buffer
    */

#if defined( HB_MT_VM )
   if( !hb_stack_ready() )
   {
      szProcName[ 0 ] = '\0';
      * puiProcLine = 0;
      return;
   }
#endif
   {
      HB_STACK_TLS_PRELOAD
      if( hb_stack.pPos > hb_stack.pBase )
      {
         hb_strncpy( szProcName, ( * hb_stack.pBase )->item.asSymbol.value->szName,
                     HB_SYMBOL_NAME_LEN );
         * puiProcLine = ( * hb_stack.pBase )->item.asSymbol.stackstate->uiLineNo;
      }
      else
      {
         szProcName[ 0 ] = '\0';
         * puiProcLine = 0;
      }
   }
}

/* NOTE: DEBUG function */
void hb_stackDispLocal( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM * pBase;

   HB_TRACE(HB_TR_DEBUG, ("hb_stackDispLocal()"));

   printf( hb_conNewLine() );
   printf( HB_I_("Virtual Machine Stack Dump at %s(%i):"),
           ( *hb_stack.pBase )->item.asSymbol.value->szName,
           ( *hb_stack.pBase )->item.asSymbol.stackstate->uiLineNo );
   printf( hb_conNewLine() );
   printf( "--------------------------" );

   for( pBase = hb_stack.pBase; pBase <= hb_stack.pPos; pBase++ )
   {
      printf( hb_conNewLine() );

      switch( hb_itemType( *pBase ) )
      {
         case HB_IT_NIL:
            printf( HB_I_("NIL ") );
            break;

         case HB_IT_ARRAY:
            if( hb_arrayIsObject( *pBase ) )
               printf( HB_I_("OBJECT = %s "), hb_objGetClsName( *pBase ) );
            else
               printf( HB_I_("ARRAY ") );
            break;

         case HB_IT_BLOCK:
            printf( HB_I_("BLOCK ") );
            break;

         case HB_IT_DATE:
            {
               char szDate[ 9 ];
               printf( HB_I_("DATE = \"%s\" "), hb_itemGetDS( *pBase, szDate ) );
            }
            break;

         case HB_IT_DOUBLE:
            printf( HB_I_("DOUBLE = %f "), hb_itemGetND( *pBase ) );
            break;

         case HB_IT_LOGICAL:
            printf( HB_I_("LOGICAL = %s "), hb_itemGetL( *pBase ) ? ".T." : ".F." );
            break;

         case HB_IT_LONG:
            printf( HB_I_("LONG = %" PFHL "i ") , hb_itemGetNInt( *pBase ) );
            break;

         case HB_IT_INTEGER:
            printf( HB_I_("INTEGER = %i "), hb_itemGetNI( *pBase ) );
            break;

         case HB_IT_STRING:
            printf( HB_I_("STRING = \"%s\" "), hb_itemGetCPtr( *pBase ) );
            break;

         case HB_IT_SYMBOL:
            printf( HB_I_("SYMBOL = %s "), ( *pBase )->item.asSymbol.value->szName );
            break;

         case HB_IT_POINTER:
            printf( HB_I_("POINTER = %p "), ( *pBase )->item.asPointer.value );
            break;

         default:
            printf( HB_I_("UNKNOWN = TYPE %i "), hb_itemType( *pBase ) );
            break;
      }
   }
}

void hb_stackDispCall( void )
{
   char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 + 10 ]; /* additional 10 bytes for line info (%hu) overhead */
   char file[ _POSIX_PATH_MAX + 1 ];
   USHORT uiLine;
   int iLevel;

   HB_TRACE(HB_TR_DEBUG, ("hb_stackDispCall()"));

   iLevel = 0;

   while( hb_procinfo( iLevel++, buffer, &uiLine, file ) )
   {
      int l = strlen( buffer );
      snprintf( buffer + l, sizeof( buffer ) - l, "(%hu)%s%s", uiLine, *file ? HB_I_(" in ") : "", file );

      hb_conOutErr( "Called from ", 0 );
      hb_conOutErr( buffer, 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
   }
}

/* ------------------------------------------------------------------------ */
/* The garbage collector interface */
/* ------------------------------------------------------------------------ */

#if !defined( HB_MT_VM )
/* helper function to scan all visible memvar variables
 */
static HB_DYNS_FUNC( hb_stackMemvarScan )
{
   PHB_ITEM pMemvar;

   HB_SYMBOL_UNUSED( Cargo );

   pMemvar = hb_dynsymGetMemvar( pDynSymbol );
   if( pMemvar && HB_IS_GCITEM( pMemvar ) )
      hb_gcItemRef( pMemvar );

   return TRUE;
}
#endif

/* Mark all memvars (PRIVATEs and PUBLICs) */
static void hb_stackIsMemvarRef( PHB_STACK pStack )
{
   /* 1. Mark all hidden memvars (PRIVATEs and PUBLICs) */
   PHB_PRIVATE_STACK pPrivateStack = &pStack->privates;
   ULONG ulCount = pPrivateStack->count;

   while( ulCount )
   {
      PHB_ITEM pMemvar = pPrivateStack->stack[ --ulCount ].pPrevMemvar;
      if( pMemvar && HB_IS_GCITEM( pMemvar ) )
         hb_gcItemRef( pMemvar );
   }
   /* 2. Mark all visible memvars (PRIVATEs and PUBLICs) */
#if defined( HB_MT_VM )
   {
      int iDynSym = pStack->iDynH;

      while( --iDynSym >= 0 )
      {
         PHB_ITEM pMemvar = ( PHB_ITEM ) pStack->pDynH[ iDynSym ].pMemvar;
         if( pMemvar && HB_IS_GCITEM( pMemvar ) )
            hb_gcItemRef( pMemvar );
      }
   }
#else
   hb_dynsymEval( hb_stackMemvarScan, NULL );
#endif
}

/* Mark all thread static variables */
static void hb_stackIsTsdRef( PHB_STACK pStack, PHB_TSD_FUNC pCleanFunc )
{
   int iTSD = pStack->iTSD;

   while( iTSD )
   {
      if( pStack->pTSD[iTSD].pTSD &&
          pStack->pTSD[iTSD].pTSD->pCleanFunc == pCleanFunc )
      {
         PHB_ITEM pItem = ( PHB_ITEM ) pStack->pTSD[iTSD].value;
         if( HB_IS_GCITEM( pItem ) )
            hb_gcItemRef( pItem );
      }
      --iTSD;
   }
}

/* Mark all locals as used so they will not be released by the
 * garbage collector
 */
void hb_stackIsStackRef( void * pStackId, PHB_TSD_FUNC pCleanFunc )
{
   PHB_STACK pStack;
   long lCount;

   HB_TRACE(HB_TR_DEBUG, ("hb_stackIsStackRef()"));

   pStack = ( PHB_STACK ) pStackId;
   lCount = pStack->pPos - pStack->pItems;
   while( lCount > 0 )
   {
      PHB_ITEM pItem = pStack->pItems[ --lCount ];

      if( HB_IS_GCITEM( pItem ) )
         hb_gcItemRef( pItem );
   }

   hb_gcItemRef( &pStack->Return );

   hb_stackIsMemvarRef( pStack );

   if( pCleanFunc )
      hb_stackIsTsdRef( pStack, pCleanFunc );
}
estack.c254
eval.c
TypeFunctionSourceLine
BOOLhb_evalNew( PHB_EVALINFO pEvalInfo, PHB_ITEM pItem )
BOOL hb_evalNew( PHB_EVALINFO pEvalInfo, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_evalNew(%p, %p)", pEvalInfo, pItem));

   if( pEvalInfo )
   {
      memset( pEvalInfo, 0, sizeof( HB_EVALINFO ) );
      pEvalInfo->pItems[ 0 ] = pItem;
      pEvalInfo->paramCount = 0;

      return TRUE;
   }
   else
      return FALSE;
}

eval.c72
BOOLhb_evalPutParam( PHB_EVALINFO pEvalInfo, PHB_ITEM pItem )
BOOL hb_evalPutParam( PHB_EVALINFO pEvalInfo, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_evalPutParam(%p, %p)", pEvalInfo, pItem));

   if( pEvalInfo && pItem && pEvalInfo->paramCount < HB_EVAL_PARAM_MAX_ )
   {
      pEvalInfo->pItems[ ++pEvalInfo->paramCount ] = pItem;

      return TRUE;
   }
   else
      return FALSE;
}
eval.c101
PHB_ITEMhb_evalLaunch( PHB_EVALINFO pEvalInfo )
PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo )
{
   PHB_ITEM pResult = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_evalLaunch(%p)", pEvalInfo));

   if( pEvalInfo )
   {
      PHB_ITEM pItem = pEvalInfo->pItems[ 0 ];
      PHB_SYMB pSymbol = NULL;
      USHORT uiParam = 0;

      if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value );

         if( pDynSym )
         {
            pSymbol = pDynSym->pSymbol;
            pItem = NULL;
         }
      }
      else if( HB_IS_SYMBOL( pItem ) )
      {
         pSymbol = pItem->item.asSymbol.value;
         pItem = NULL;
      }
      else if( HB_IS_BLOCK( pItem ) )
      {
         pSymbol = &hb_symEval;
      }

      if( pSymbol )
      {
         hb_vmPushSymbol( pSymbol );
         if( pItem )
            hb_vmPush( pItem );
         else
            hb_vmPushNil();
         while( uiParam < pEvalInfo->paramCount )
            hb_vmPush( pEvalInfo->pItems[ ++uiParam ] );
         if( pItem )
            hb_vmSend( uiParam );
         else
            hb_vmDo( uiParam );
         pResult = hb_itemNew( hb_stackReturnItem() );
      }
   }

   return pResult;
}
eval.c115
BOOLhb_evalRelease( PHB_EVALINFO pEvalInfo )
BOOL hb_evalRelease( PHB_EVALINFO pEvalInfo )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_evalRelease(%p)", pEvalInfo));

   if( pEvalInfo )
   {
      USHORT uiParam;

      for( uiParam = 0; uiParam <= pEvalInfo->paramCount; uiParam++ )
      {
         hb_itemRelease( pEvalInfo->pItems[ uiParam ] );
         pEvalInfo->pItems[ uiParam ] = NULL;
      }

      pEvalInfo->paramCount = 0;

      return TRUE;
   }
   else
      return FALSE;
}
eval.c171
PHB_ITEMhb_itemDo( PHB_ITEM pItem, ULONG ulPCount, ... )
PHB_ITEM hb_itemDo( PHB_ITEM pItem, ULONG ulPCount, ... )
{
   PHB_ITEM pResult = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemDo(%p, %hu, ...)", pItem, ulPCount));

   if( pItem )
   {
      PHB_SYMB pSymbol = NULL;

      if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value );

         if( pDynSym )
         {
            pSymbol = pDynSym->pSymbol;
            pItem = NULL;
         }
      }
      else if( HB_IS_SYMBOL( pItem ) )
      {
         pSymbol = pItem->item.asSymbol.value;
         pItem = NULL;
      }
      else if( HB_IS_BLOCK( pItem ) )
      {
         pSymbol = &hb_symEval;
      }

      if( pSymbol )
      {
         if( hb_vmRequestReenter() )
         {
            hb_vmPushSymbol( pSymbol );
            if( pItem )
               hb_vmPush( pItem );
            else
               hb_vmPushNil();

            if( ulPCount )
            {
               ULONG ulParam;
               va_list va;
               va_start( va, ulPCount );
               for( ulParam = 1; ulParam <= ulPCount; ulParam++ )
                  hb_vmPush( va_arg( va, PHB_ITEM ) );
               va_end( va );
            }
            if( pItem )
               hb_vmSend( ( USHORT ) ulPCount );
            else
               hb_vmDo( ( USHORT ) ulPCount );

            pResult = hb_itemNew( hb_stackReturnItem() );
            hb_vmRequestRestore();
         }
      }
   }

   return pResult;
}
eval.c203
PHB_ITEMhb_itemDoC( const char * szFunc, ULONG ulPCount, ... )
PHB_ITEM hb_itemDoC( const char * szFunc, ULONG ulPCount, ... )
{
   PHB_ITEM pResult = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemDoC(%s, %hu, ...)", szFunc, ulPCount));

   if( szFunc )
   {
      PHB_DYNS pDynSym = hb_dynsymFindName( szFunc );

      if( pDynSym )
      {
         if( hb_vmRequestReenter() )
         {
            hb_vmPushSymbol( pDynSym->pSymbol );
            hb_vmPushNil();
            if( ulPCount )
            {
               ULONG ulParam;
               va_list va;
               va_start( va, ulPCount );
               for( ulParam = 1; ulParam <= ulPCount; ulParam++ )
                  hb_vmPush( va_arg( va, PHB_ITEM ) );
               va_end( va );
            }
            hb_vmDo( ( unsigned short ) ulPCount );
            pResult = hb_itemNew( hb_stackReturnItem() );
            hb_vmRequestRestore();
         }
      }
   }

   return pResult;
}
eval.c273
VOIDhb_evalBlock0( PHB_ITEM pCodeBlock )
void hb_evalBlock0( PHB_ITEM pCodeBlock )
{
   hb_vmPushSymbol( &hb_symEval );
   hb_vmPush( pCodeBlock );
   hb_vmFunction( 0 );
}
eval.c313
VOIDhb_evalBlock1( PHB_ITEM pCodeBlock, PHB_ITEM pParam )
void hb_evalBlock1( PHB_ITEM pCodeBlock, PHB_ITEM pParam )
{
   hb_vmPushSymbol( &hb_symEval );
   hb_vmPush( pCodeBlock );
   hb_vmPush( pParam );
   hb_vmFunction( 1 );
}
eval.c321
VOIDhb_evalBlock( PHB_ITEM pCodeBlock, ... )
void hb_evalBlock( PHB_ITEM pCodeBlock, ... )
{
   va_list args;
   USHORT uiParams = 0;
   PHB_ITEM pParam;

   hb_vmPushSymbol( &hb_symEval );
   hb_vmPush( pCodeBlock );

   va_start( args, pCodeBlock );
   while( ( pParam = va_arg( args, PHB_ITEM ) ) != NULL )
   {
      hb_vmPush( pParam );
      uiParams++;
   }
   va_end( args );

   hb_vmFunction( uiParams );
}
eval.c330
HB_FUNCHB_FORNEXT(void)
HB_FUNC( HB_FORNEXT ) /* nStart, nEnd | bEnd, bCode, nStep */
{
   LONG lStart = hb_parnl( 1 ), lEnd;
   PHB_ITEM pEndBlock = hb_param( 2, HB_IT_BLOCK );
   PHB_ITEM pCodeBlock = hb_param( 3, HB_IT_BLOCK );
   LONG lStep = ( hb_pcount() > 3 ) ? hb_parnl( 4 ) : 1;

   if( pCodeBlock )
   {
      if( pEndBlock )
      {
         hb_evalBlock0( pEndBlock );
         lEnd = hb_parnl( -1 );

         while( lStart <= lEnd )
         {
            hb_vmPushSymbol( &hb_symEval );
            hb_vmPush( pCodeBlock );
            hb_vmPushLong( lStart );
            hb_vmFunction( 1 );

            lStart += lStep;

            hb_evalBlock0( pEndBlock );
            lEnd = hb_parnl( -1 );
         }
      }
      else
      {
         lEnd = hb_parnl( 2 );
         while( lStart <= lEnd )
         {
            hb_vmPushSymbol( &hb_symEval );
            hb_vmPush( pCodeBlock );
            hb_vmPushLong( lStart );
            hb_vmFunction( 1 );

            lStart += lStep;
         }
      }
   }
}
eval.c351
HB_FUNCHB_EXECFROMARRAY(void)
HB_FUNC( HB_EXECFROMARRAY )
{
   PHB_SYMB pExecSym = NULL;
   PHB_ITEM pFunc = NULL;
   PHB_ITEM pSelf = NULL;
   PHB_ITEM pArray = NULL;
   PHB_ITEM pItem;
   ULONG ulParamOffset = 0;
   USHORT usPCount = hb_pcount();

   /* decode parameters */
   if( usPCount )
   {
      PHB_ITEM pParam  = hb_param( 1, HB_IT_ANY );

      if( usPCount == 1 )
      {
         if( HB_IS_ARRAY( pParam ) && !HB_IS_OBJECT( pParam ) )
         {
            pArray = pParam;
            pItem = hb_arrayGetItemPtr( pArray, 1 );
            if( HB_IS_OBJECT( pItem ) )
            {
               pSelf = pItem;
               pFunc = hb_arrayGetItemPtr( pArray, 2 );
               ulParamOffset = 2;
            }
            else
            {
               pFunc = pItem;
               ulParamOffset = 1;
            }
         }
         else
            pFunc = pParam;
      }
      else if( HB_IS_OBJECT( pParam ) && usPCount <= 3 )
      {
         pSelf = pParam;
         pFunc = hb_param( 2, HB_IT_ANY );
         pArray = hb_param( 3, HB_IT_ANY );
      }
      else if( usPCount == 2 )
      {
         pFunc = pParam;
         pArray = hb_param( 2, HB_IT_ANY );
      }
   }

   if( pFunc && ( !pArray || HB_IS_ARRAY( pArray ) ) )
   {
      if( HB_IS_SYMBOL( pFunc ) )
         pExecSym = hb_itemGetSymbol( pFunc );
      else if( HB_IS_STRING( pFunc ) )
         pExecSym = hb_dynsymGet( hb_itemGetCPtr( pFunc ) )->pSymbol;
      else if( HB_IS_BLOCK( pFunc ) && !pSelf )
      {
         pSelf = pFunc;
         pExecSym = &hb_symEval;
      }
   }

   if( pExecSym )
   {
      usPCount = 0;
      hb_vmPushSymbol( pExecSym );
      if( pSelf )
         hb_vmPush( pSelf );
      else
         hb_vmPushNil();

      if( pArray )
      {
         pItem = hb_arrayGetItemPtr( pArray, ++ulParamOffset );
         while( pItem && usPCount < 255 )
         {
            hb_vmPush( pItem );
            ++usPCount;
            pItem = hb_arrayGetItemPtr( pArray, ++ulParamOffset );
         }
      }

      if( pSelf )
         hb_vmSend( usPCount );
      else
         hb_vmDo( usPCount );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
eval.c394
BOOLhb_execFromArray( PHB_ITEM pParam )
BOOL hb_execFromArray( PHB_ITEM pParam )
{
   PHB_SYMB pExecSym = NULL;
   PHB_ITEM pArray = NULL;
   PHB_ITEM pSelf = NULL;
   ULONG ulParamOffset = 0;
   USHORT usPCount = 0;

   if( pParam && HB_IS_ARRAY( pParam ) && !HB_IS_OBJECT( pParam ) )
   {
      pArray = pParam;
      pParam = hb_arrayGetItemPtr( pArray, 1 );
      if( HB_IS_OBJECT( pParam ) )
      {
         pSelf = pParam;
         pParam = hb_arrayGetItemPtr( pArray, 2 );
         ulParamOffset = 2;
      }
      else
         ulParamOffset = 1;
   }

   if( pParam )
   {
      if( HB_IS_SYMBOL( pParam ) )
         pExecSym = hb_itemGetSymbol( pParam );
      else if( HB_IS_STRING( pParam ) )
         pExecSym = hb_dynsymGet( hb_itemGetCPtr( pParam ) )->pSymbol;
      else if( HB_IS_BLOCK( pParam ) && !pSelf )
      {
         pSelf = pParam;
         pExecSym = &hb_symEval;
      }

      if( pExecSym )
      {
         hb_vmPushSymbol( pExecSym );
         if( pSelf )
            hb_vmPush( pSelf );
         else
            hb_vmPushNil();

         if( pArray )
         {
            pParam = hb_arrayGetItemPtr( pArray, ++ulParamOffset );
            while( pParam && usPCount < 255 )
            {
               hb_vmPush( pParam );
               ++usPCount;
               pParam = hb_arrayGetItemPtr( pArray, ++ulParamOffset );
            }
         }

         if( pSelf )
            hb_vmSend( usPCount );
         else
            hb_vmDo( usPCount );

         return TRUE;
      }
   }

   hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );

   return FALSE;
}
eval.c505
evalhb.c
TypeFunctionSourceLine
HB_FUNCEVAL(void)
HB_FUNC( EVAL )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_BLOCK );

   if( pItem )
   {
      USHORT uiPCount = hb_pcount();
      USHORT uiParam;

      hb_vmPushSymbol( &hb_symEval );
      hb_vmPush( pItem );
      /* NOTE: hb_param() function cannot be used for parameter access
       * because we need to pass the references too.
       * hb_param() is dereferencing the passed parameters
       */
      for( uiParam = 2; uiParam <= uiPCount; uiParam++ )
      {
         hb_vmPush( hb_stackItemFromBase( uiParam ) );
      }

      hb_vmDo( ( USHORT ) ( uiPCount - 1 ) );
   }
   else
   {
      hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}
evalhb.c60
extend.c
TypeFunctionSourceLine
HB_EXPORT PHB_ITEMhb_param( int iParam, long lMask )
HB_EXPORT PHB_ITEM hb_param( int iParam, long lMask )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_param(%d, %ld)", iParam, lMask));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam  );

      if( pItem->type & HB_IT_BYREF )
      {
         pItem = hb_itemUnRef( pItem );
         if( ( HB_TYPE ) lMask == HB_IT_BYREF )
            return pItem;
      }

      if( ( pItem->type & ( HB_TYPE ) lMask ) || ( HB_TYPE ) lMask == HB_IT_ANY )
         return pItem;
   }

   return NULL;
}
extend.c81
HB_EXPORT PHB_ITEMhb_paramError( int iParam )
HB_EXPORT PHB_ITEM  hb_paramError( int iParam )
{
   static HB_ITEM s_NIL;

   PHB_ITEM pParam = hb_param( iParam, HB_IT_ANY );

   if( pParam == NULL )
   {
      hb_itemClear( &s_NIL );
      pParam = &s_NIL;
   }

   return pParam;
}
extend.c103
HB_EXPORT BOOLhb_extIsArray( int iParam )
HB_EXPORT BOOL hb_extIsArray( int iParam )
{
   PHB_ITEM pItem;

   if( iParam == -1 )
      pItem = hb_stackReturnItem();
   else if( iParam >= 0 && iParam <= hb_pcount() )
      pItem = hb_stackItemFromBase( iParam );
   else
      return FALSE;
   
   if( HB_IS_BYREF( pItem ) )
      pItem = hb_itemUnRef( pItem );

   return HB_IS_ARRAY( pItem ) && !HB_ARRAY_OBJ( pItem );
}
extend.c121
HB_EXPORT BOOLhb_extIsObject( int iParam )
HB_EXPORT BOOL hb_extIsObject( int iParam )
{
   PHB_ITEM pItem;

   if( iParam == -1 )
      pItem = hb_stackReturnItem();
   else if( iParam >= 0 && iParam <= hb_pcount() )
      pItem = hb_stackItemFromBase( iParam );
   else
      return FALSE;

   if( HB_IS_BYREF( pItem ) )
      pItem = hb_itemUnRef( pItem );

   return HB_IS_OBJECT( pItem );
}
extend.c141
HB_EXPORT CHAR *hb_parc( int iParam, ... )
HB_EXPORT char * hb_parc( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parc(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_STRING( pItem ) )
         return pItem->item.asString.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetCPtr( pItem, ulArrayIndex );
      }
   }

   return ( char * ) NULL;
}
extend.c161
HB_EXPORT CHAR *hb_parcx( int iParam, ... )
HB_EXPORT char * hb_parcx( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parcx(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_STRING( pItem ) )
         return pItem->item.asString.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetCPtr( pItem, ulArrayIndex );
      }
   }

   return ( char * ) "";
}
extend.c190
HB_EXPORT ULONGhb_parclen( int iParam, ... )
HB_EXPORT ULONG  hb_parclen( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parclen(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_STRING( pItem ) )
         return pItem->item.asString.length;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetCLen( pItem, ulArrayIndex );
      }
   }

   return 0;
}
extend.c219
HB_EXPORT ULONGhb_parcsiz( int iParam, ... )
HB_EXPORT ULONG  hb_parcsiz( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parcsiz(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      /* NOTE: hb_parcsiz() will only work for strings passed by reference.
               CA-Cl*pper works like this. [vszakats] */

      if( HB_IS_BYREF( pItem ) )
      {
         pItem = hb_itemUnRef( pItem );

         if( HB_IS_STRING( pItem ) )
            return pItem->item.asString.length + 1;
         else if( HB_IS_ARRAY( pItem ) )
         {
            va_list va;
            ULONG ulArrayIndex;

            va_start( va, iParam );
            ulArrayIndex = va_arg( va, ULONG );
            va_end( va );

            return hb_arrayGetCLen( pItem, ulArrayIndex ) + 1;
         }
      }
   }

   return 0;
}
extend.c252
HB_EXPORT CHAR *hb_pards( int iParam, ... )
HB_EXPORT char  * hb_pards( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_pards(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_DATE( pItem ) )
         return hb_dateDecStr( hb_stackDateBuffer(), pItem->item.asDate.value );
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetDS( pItem, ulArrayIndex, hb_stackDateBuffer() );
      }
   }

   return hb_dateDecStr( hb_stackDateBuffer(), 0 );
}
extend.c289
HB_EXPORT CHAR *hb_pardsbuff( char * szDate, int iParam, ... )
HB_EXPORT char  * hb_pardsbuff( char * szDate, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_pardsbuff(%p, %d, ...)", szDate, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_DATE( pItem ) )
         return hb_dateDecStr( szDate, pItem->item.asDate.value );
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetDS( pItem, ulArrayIndex, szDate );
      }
   }

   return hb_dateDecStr( szDate, 0 );
}
extend.c320
HB_EXPORT LONGhb_pardl( int iParam, ... )
HB_EXPORT LONG  hb_pardl( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_pardl(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
      {
         pItem = hb_itemUnRef( pItem );
      }

      if( HB_IS_DATE( pItem ) )
      {
         return pItem->item.asDate.value;
      }
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetDL( pItem, ulArrayIndex );
      }
   }

   return hb_itemGetDL( NULL );
}
extend.c351
HB_EXPORT INThb_parl( int iParam, ... )
HB_EXPORT int  hb_parl( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parl(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_LOGICAL( pItem ) )
         return pItem->item.asLogical.value ? 1 : 0;
      else if( HB_IS_INTEGER( pItem ) )
         return pItem->item.asInteger.value != 0 ? 1 : 0;
      else if( HB_IS_LONG( pItem ) )
         return pItem->item.asLong.value != 0 ? 1 : 0;
      else if( HB_IS_DOUBLE( pItem ) )
         return pItem->item.asDouble.value != 0.0 ? 1 : 0;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetL( pItem, ulArrayIndex ) ? 1 : 0;
      }
   }

   return 0;
}
extend.c385
HB_EXPORT DOUBLEhb_parnd( int iParam, ... )
HB_EXPORT double  hb_parnd( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parnd(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_DOUBLE( pItem ) )
         return pItem->item.asDouble.value;
      else if( HB_IS_INTEGER( pItem ) )
         return ( double ) pItem->item.asInteger.value;
      else if( HB_IS_LONG( pItem ) )
         return ( double ) pItem->item.asLong.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetND( pItem, ulArrayIndex );
      }
   }

   return 0;
}
extend.c420
HB_EXPORT INThb_parni( int iParam, ... )
HB_EXPORT int  hb_parni( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parni(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_INTEGER( pItem ) )
         return pItem->item.asInteger.value;
      else if( HB_IS_LONG( pItem ) )
         return ( int ) pItem->item.asLong.value;
      else if( HB_IS_DOUBLE( pItem ) )
         return ( int ) pItem->item.asDouble.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetNI( pItem, ulArrayIndex );
      }
   }

   return 0;
}
extend.c453
HB_EXPORT LONGhb_parnl( int iParam, ... )
HB_EXPORT long  hb_parnl( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parnl(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_LONG( pItem ) )
         return ( long ) pItem->item.asLong.value;
      else if( HB_IS_INTEGER( pItem ) )
         return ( long ) pItem->item.asInteger.value;
      else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
         return ( long ) ( unsigned long ) pItem->item.asDouble.value;
#else
         return ( long ) pItem->item.asDouble.value;
#endif
      else if( HB_IS_DATE( pItem ) )
         return ( long ) pItem->item.asDate.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetNL( pItem, ulArrayIndex );
      }
   }

   return 0;
}
extend.c486
HB_EXPORT LONGLONGhb_parnll( int iParam, ... )
HB_EXPORT LONGLONG  hb_parnll( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parnll(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_LONG( pItem ) )
         return ( LONGLONG ) pItem->item.asLong.value;
      else if( HB_IS_INTEGER( pItem ) )
         return ( LONGLONG ) pItem->item.asInteger.value;
      else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
         return ( LONGLONG ) ( ULONGLONG ) pItem->item.asDouble.value;
#else
         return ( LONGLONG ) pItem->item.asDouble.value;
#endif
      else if( HB_IS_DATE( pItem ) )
         return ( LONGLONG ) pItem->item.asDate.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetNLL( pItem, ulArrayIndex );
      }
   }

   return 0;
}
extend.c526
HB_EXPORT HB_LONGhb_parnint( int iParam, ... )
HB_EXPORT HB_LONG  hb_parnint( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parnint(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_LONG( pItem ) )
         return ( HB_LONG ) pItem->item.asLong.value;
      else if( HB_IS_INTEGER( pItem ) )
         return ( HB_LONG ) pItem->item.asInteger.value;
      else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
         return ( HB_LONG ) ( HB_ULONG ) pItem->item.asDouble.value;
#else
         return ( HB_LONG ) pItem->item.asDouble.value;
#endif
      else if( HB_IS_DATE( pItem ) )
         return ( HB_LONG ) pItem->item.asDate.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetNInt( pItem, ulArrayIndex );
      }
   }

   return 0;
}
extend.c566
HB_EXPORT VOID *hb_parptr( int iParam, ... )
HB_EXPORT void * hb_parptr( int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parptr(%d, ...)", iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_POINTER( pItem ) )
         return pItem->item.asPointer.value;
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return hb_arrayGetPtr( pItem, ulArrayIndex );
      }
   }

   return NULL;
}
extend.c605
HB_EXPORT VOID *hb_parptrGC( HB_GARBAGE_FUNC_PTR pFunc, int iParam, ... )
HB_EXPORT void * hb_parptrGC( HB_GARBAGE_FUNC_PTR pFunc, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parptrGC(%p,%d, ...)", pFunc, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );

      if( HB_IS_BYREF( pItem ) )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_POINTER( pItem ) )
      {
         if( pItem->item.asPointer.collect &&
             hb_gcFunc( pItem->item.asPointer.value ) == pFunc )
            return pItem->item.asPointer.value;
      }
      else if( HB_IS_ARRAY( pItem ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         pItem = hb_arrayGetItemPtr( pItem, ulArrayIndex );
         if( pItem && HB_IS_POINTER( pItem ) &&
             pItem->item.asPointer.collect &&
             hb_gcFunc( pItem->item.asPointer.value ) == pFunc )
            return pItem->item.asPointer.value;
      }
   }

   return NULL;
}
extend.c634
HB_EXPORT ULONGhb_parinfa( int iParamNum, ULONG uiArrayIndex )
HB_EXPORT ULONG  hb_parinfa( int iParamNum, ULONG uiArrayIndex )
{
   PHB_ITEM pArray;

   HB_TRACE(HB_TR_DEBUG, ("hb_parinfa(%d, %lu)", iParamNum, uiArrayIndex));

   pArray = hb_param( iParamNum, HB_IT_ARRAY );

   if( pArray )
   {
      if( uiArrayIndex == 0 )
         return hb_arrayLen( pArray );
      else
         return ( long ) hb_arrayGetType( pArray, uiArrayIndex );
   }
   else
      return 0;
}
extend.c671
HB_EXPORT ULONGhb_parinfo( int iParam )
HB_EXPORT ULONG  hb_parinfo( int iParam )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_parinfo(%d)", iParam));

   if( iParam == 0 )
      return ( ULONG ) hb_pcount();
   else
   {
      if( iParam >= -1 && iParam <= hb_pcount() )
      {
         PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
         HB_TYPE uiType = HB_ITEM_TYPE( pItem );

         if( uiType & HB_IT_BYREF )
            uiType |= HB_ITEM_TYPE( hb_itemUnRef( pItem ) );

         return ( ULONG ) uiType;
      }
      else
         return 0;
   }
}
extend.c690
HB_EXPORT VOIDhb_ret( void )
HB_EXPORT void  hb_ret( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_ret()"));

   hb_itemClear( hb_stackReturnItem() );
}
extend.c714
HB_EXPORT VOIDhb_reta( ULONG ulLen )
HB_EXPORT void  hb_reta( ULONG ulLen )  /* undocumented hb_reta() */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_reta(%lu)", ulLen));

   hb_arrayNew( hb_stackReturnItem(), ulLen );
}
extend.c722
HB_EXPORT VOIDhb_retc( const char * szText )
HB_EXPORT void hb_retc( const char * szText )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retc(%s)", szText));

   hb_itemPutC( hb_stackReturnItem(), szText );
}
extend.c730
HB_EXPORT VOIDhb_retc_null( void )
HB_EXPORT void hb_retc_null( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retc_null()"));

   hb_itemPutC( hb_stackReturnItem(), NULL );
}
extend.c738
HB_EXPORT VOIDhb_retc_buffer( char * szText )
HB_EXPORT void hb_retc_buffer( char * szText )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retc_buffer(%s)", szText));

   hb_itemPutCPtr2( hb_stackReturnItem(), szText );
}
extend.c746
HB_EXPORT VOIDhb_retc_const( const char * szText )
HB_EXPORT void hb_retc_const( const char * szText )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retc_const(%s)", szText));

   hb_itemPutCConst( hb_stackReturnItem(), szText );
}
extend.c754
HB_EXPORT VOIDhb_retclen( const char * szText, ULONG ulLen )
HB_EXPORT void  hb_retclen( const char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retclen(%s, %lu)", szText, ulLen));

   hb_itemPutCL( hb_stackReturnItem(), szText, ulLen );
}
extend.c762
HB_EXPORT VOIDhb_retclen_buffer( char * szText, ULONG ulLen )
HB_EXPORT void  hb_retclen_buffer( char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retclen_buffer(%s, %lu)", szText, ulLen));

   hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen );
}
extend.c770
HB_EXPORT VOIDhb_retds( const char * szDate )
HB_EXPORT void hb_retds( const char * szDate )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retds(%s)", szDate));

   hb_itemPutDS( hb_stackReturnItem(), szDate );
}
extend.c780
HB_EXPORT VOIDhb_retd( int iYear, int iMonth, int iDay )
HB_EXPORT void hb_retd( int iYear, int iMonth, int iDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retd(%04i, %02i, %02i)", iYear, iMonth, iDay));

   hb_itemPutD( hb_stackReturnItem(), iYear, iMonth, iDay );
}
extend.c788
HB_EXPORT VOIDhb_retdl( long lJulian )
HB_EXPORT void hb_retdl( long lJulian )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retdl(%ld)", lJulian));

   hb_itemPutDL( hb_stackReturnItem(), lJulian );
}
extend.c796
HB_EXPORT VOIDhb_retl( int iLogical )
HB_EXPORT void hb_retl( int iLogical )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retl(%d)", iLogical));

   hb_itemPutL( hb_stackReturnItem(), iLogical ? TRUE : FALSE );
}
extend.c804
HB_EXPORT VOIDhb_retnd( double dNumber )
HB_EXPORT void hb_retnd( double dNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnd(%lf)", dNumber));

   hb_itemPutND( hb_stackReturnItem(), dNumber );
}
extend.c812
HB_EXPORT VOIDhb_retni( int iNumber )
HB_EXPORT void hb_retni( int iNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retni(%d)", iNumber));

   hb_itemPutNI( hb_stackReturnItem(), iNumber );
}
extend.c820
HB_EXPORT VOIDhb_retnl( long lNumber )
HB_EXPORT void hb_retnl( long lNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnl(%ld)", lNumber));

   hb_itemPutNL( hb_stackReturnItem(), lNumber );
}
extend.c828
HB_EXPORT VOIDhb_retnll( LONGLONG llNumber )
HB_EXPORT void hb_retnll( LONGLONG llNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnll(%" PFLL "d)", llNumber));

   hb_itemPutNLL( hb_stackReturnItem(), llNumber );
}
extend.c837
HB_EXPORT VOIDhb_retnint( HB_LONG lNumber )
HB_EXPORT void hb_retnint( HB_LONG lNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnl(%ld)", lNumber));

   hb_itemPutNInt( hb_stackReturnItem(), lNumber );
}
extend.c846
HB_EXPORT VOIDhb_retnlen( double dNumber, int iWidth, int iDec )
HB_EXPORT void hb_retnlen( double dNumber, int iWidth, int iDec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnlen(%lf, %d, %d)", dNumber, iWidth, iDec));

   hb_itemPutNLen( hb_stackReturnItem(), dNumber, iWidth, iDec );
}
extend.c854
HB_EXPORT VOIDhb_retndlen( double dNumber, int iWidth, int iDec )
HB_EXPORT void hb_retndlen( double dNumber, int iWidth, int iDec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retndlen(%lf, %d, %d)", dNumber, iWidth, iDec));

   hb_itemPutNDLen( hb_stackReturnItem(), dNumber, iWidth, iDec );
}
extend.c862
HB_EXPORT VOIDhb_retnilen( int iNumber, int iWidth )
HB_EXPORT void hb_retnilen( int iNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnilen(%d, %d)", iNumber, iWidth));

   hb_itemPutNILen( hb_stackReturnItem(), iNumber, iWidth );
}
extend.c870
HB_EXPORT VOIDhb_retnllen( long lNumber, int iWidth )
HB_EXPORT void hb_retnllen( long lNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnllen(%ld, %d)", lNumber, iWidth));

   hb_itemPutNLLen( hb_stackReturnItem(), lNumber, iWidth );
}
extend.c878
HB_EXPORT VOIDhb_retnlllen( LONGLONG llNumber, int iWidth )
HB_EXPORT void hb_retnlllen( LONGLONG llNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnlllen(%" PFLL "d, %d)", llNumber, iWidth));

   hb_itemPutNLLLen( hb_stackReturnItem(), llNumber, iWidth );
}
extend.c887
HB_EXPORT VOIDhb_retnintlen( HB_LONG lNumber, int iWidth )
HB_EXPORT void hb_retnintlen( HB_LONG lNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retnintlen(%" PFHL "d, %d)", lNumber, iWidth));

   hb_itemPutNIntLen( hb_stackReturnItem(), lNumber, iWidth );
}
extend.c896
HB_EXPORT VOIDhb_retptr( void * pointer )
HB_EXPORT void hb_retptr( void * pointer )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retptr(%p)", pointer));

   hb_itemPutPtr( hb_stackReturnItem(), pointer );
}
extend.c904
HB_EXPORT VOIDhb_retptrGC( void * pointer )
HB_EXPORT void hb_retptrGC( void * pointer )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_retptrGC(%p)", pointer));

   hb_itemPutPtrGC( hb_stackReturnItem(), pointer );
}
extend.c912
HB_EXPORT INThb_storc( const char * szText, int iParam, ... )
HB_EXPORT int hb_storc( const char * szText, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storc(%s, %d, ...)", szText, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetC( pItem, va_arg( va, ULONG ), szText ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutC( pItem, szText );
         return 1;
      }
   }

   return 0;
}
extend.c920
HB_EXPORT INThb_storclen( const char * szText, ULONG ulLen, int iParam, ... )
HB_EXPORT int hb_storclen( const char * szText, ULONG ulLen, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storclen(%s, %lu, %d, ...)", szText, ulLen, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetCL( pItem, va_arg( va, ULONG ), szText, ulLen ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutCL( pItem, szText, ulLen );
         return 1;
      }
   }

   return 0;
}
extend.c951
HB_EXPORT INThb_storclen_buffer( char * szText, ULONG ulLen, int iParam, ... )
HB_EXPORT int hb_storclen_buffer( char * szText, ULONG ulLen, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storclen_buffer(%s, %lu, %d, ...)", szText, ulLen, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetCPtr( pItem, va_arg( va, ULONG ), szText, ulLen ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutCLPtr( pItem, szText, ulLen );
         return 1;
      }
   }

   return 0;
}
extend.c982
HB_EXPORT INThb_stords( const char * szDate, int iParam, ... )
HB_EXPORT int hb_stords( const char * szDate, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stords(%s, %d, ...)", szDate, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetDS( pItem, va_arg( va, ULONG ), szDate ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutDS( pItem, szDate );
         return 1;
      }
   }

   return 0;
}
extend.c1015
HB_EXPORT INThb_storl( int iLogical, int iParam, ... )
HB_EXPORT int hb_storl( int iLogical, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storl(%d, %d, ...)", iLogical, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetL( pItem, va_arg( va, ULONG ), iLogical ? TRUE : FALSE ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutL( pItem, iLogical ? TRUE : FALSE );
         return 1;
      }
   }

   return 0;
}
extend.c1046
HB_EXPORT INThb_storni( int iValue, int iParam, ... )
HB_EXPORT int hb_storni( int iValue, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storni(%d, %d, ...)", iValue, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetNI( pItem, va_arg( va, ULONG ), iValue ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutNI( pItem, iValue );
         return 1;
      }
   }

   return 0;
}
extend.c1077
HB_EXPORT INThb_stornl( long lValue, int iParam, ... )
HB_EXPORT int hb_stornl( long lValue, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stornl(%ld, %d, ...)", lValue, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetNL( pItem, va_arg( va, ULONG ), lValue ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutNL( pItem, lValue );
         return 1;
      }
   }

   return 0;
}
extend.c1108
HB_EXPORT INThb_stornll( LONGLONG llValue, int iParam, ... )
HB_EXPORT int hb_stornll( LONGLONG llValue, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stornll(%" PFLL "d, %d, ...)", llValue, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetNLL( pItem, va_arg( va, ULONG ), llValue ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutNLL( pItem, llValue );
         return 1;
      }
   }

   return 0;
}
extend.c1140
HB_EXPORT INThb_stornint( HB_LONG lValue, int iParam, ... )
HB_EXPORT int hb_stornint( HB_LONG lValue, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stornint(%" PFHL "d, %d, ...)", lValue, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetNInt( pItem, va_arg( va, ULONG ), lValue ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutNInt( pItem, lValue );
         return 1;
      }
   }

   return 0;
}
extend.c1172
HB_EXPORT INThb_stornd( double dNumber, int iParam, ... )
HB_EXPORT int hb_stornd( double dNumber, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_stornd(%lf, %d, ...)", dNumber, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetND( pItem, va_arg( va, ULONG ), dNumber ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutND( pItem, dNumber );
         return 1;
      }
   }

   return 0;
}
extend.c1203
HB_EXPORT INThb_storptr( void * pointer, int iParam, ... )
HB_EXPORT int hb_storptr( void * pointer, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storptr(%p, %d, ...)", pointer, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetPtr( pItem, va_arg( va, ULONG ), pointer ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutPtr( pItem, pointer );
         return 1;
      }
   }

   return 0;
}
extend.c1234
HB_EXPORT INThb_storptrGC( void * pointer, int iParam, ... )
HB_EXPORT int hb_storptrGC( void * pointer, int iParam, ... )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_storptrGC(%p, %d, ...)", pointer, iParam));

   if( iParam >= -1 && iParam <= hb_pcount() )
   {
      PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
      BOOL bByRef = HB_IS_BYREF( pItem );

      if( bByRef  )
         pItem = hb_itemUnRef( pItem );

      if( HB_IS_ARRAY( pItem ) )
      {
         int iRetVal;
         va_list va;
         va_start( va, iParam );
         iRetVal = hb_arraySetPtrGC( pItem, va_arg( va, ULONG ), pointer ) ? 1 : 0;
         va_end( va );
         return iRetVal;
      }
      else if( bByRef || iParam == -1 )
      {
         hb_itemPutPtrGC( pItem, pointer );
         return 1;
      }
   }

   return 0;
}
extend.c1265
HB_EXPORT INThb_pcount( void )
HB_EXPORT int  hb_pcount( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_pcount()"));

   return ( int ) ( hb_stackBaseItem() )->item.asSymbol.paramcnt;
}
extend.c1297
extrap.c
TypeFunctionSourceLine
LONG WINAPIhb_win32ExceptionHandler( struct _EXCEPTION_POINTERS * pExceptionInfo )
LONG WINAPI hb_win32ExceptionHandler( struct _EXCEPTION_POINTERS * pExceptionInfo )
{
   char errmsg[ 4096 ];

   errmsg[ 0 ] = '\0';

#if defined(HB_WINCE)
   {
      /* TODO */
   }
#elif defined(HB_OS_WIN_64)
   {
      /* TODO */
   }
#else
   {
      int errmsglen = sizeof( errmsg ) - 1;

      char              buf[ 32 ];
      PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
      PCONTEXT          pCtx = pExceptionInfo->ContextRecord;
      DWORD             dwExceptCode = pExceptionInfo->ExceptionRecord->ExceptionCode;
      unsigned char *   pc;
      unsigned int *    sc;
      unsigned int *    ebp;
      unsigned int      eip;
      unsigned int      j;
      int               i;
      
      snprintf( errmsg, errmsglen,
                "\n\n"
                "    Exception Code:%08X\n"
                "    Exception Address:%08X\n"
                "    EAX:%08X  EBX:%08X  ECX:%08X  EDX:%08X\n"
                "    ESI:%08X  EDI:%08X  EBP:%08X\n"
                "    CS:EIP:%04X:%08X  SS:ESP:%04X:%08X\n"
                "    DS:%04X  ES:%04X  FS:%04X  GS:%04X\n"
                "    Flags:%08X\n",
                ( UINT32 ) dwExceptCode, ( UINT32 ) pExceptionRecord->ExceptionAddress,
                ( UINT32 ) pCtx->Eax, ( UINT32 ) pCtx->Ebx, ( UINT32 ) pCtx->Ecx,
                ( UINT32 ) pCtx->Edx, ( UINT32 ) pCtx->Esi, ( UINT32 ) pCtx->Edi,
                ( UINT32 ) pCtx->Ebp,
                ( UINT32 ) pCtx->SegCs, ( UINT32 ) pCtx->Eip, ( UINT32 ) pCtx->SegSs,
                ( UINT32 ) pCtx->Esp, ( UINT32 ) pCtx->SegDs, ( UINT32 ) pCtx->SegEs,
                ( UINT32 ) pCtx->SegFs, ( UINT32 ) pCtx->SegGs,
                ( UINT32 ) pCtx->EFlags );

      hb_strncat( errmsg, "    CS:EIP:", errmsglen );
      pc = ( unsigned char * ) pCtx->Eip;
      for( i = 0; i < 16; i++ )
      {
         if( IsBadReadPtr( pc, 1 ) )
            break;
         snprintf( buf, sizeof( buf ) - 1, " %02X", ( int ) pc[ i ] );
         hb_strncat( errmsg, buf, errmsglen );
      }
      hb_strncat( errmsg, "\n    SS:ESP:", errmsglen );
      sc = ( unsigned int * ) pCtx->Esp;
      for( i = 0; i < 16; i++ )
      {
         if( IsBadReadPtr( sc, 4 ) )
            break;
         snprintf( buf, sizeof( buf ), " %08X", sc[ i ] );
         hb_strncat( errmsg, buf, errmsglen );
      }
      hb_strncat( errmsg, "\n\n", errmsglen );
      hb_strncat( errmsg, "    C stack:\n", errmsglen );
      hb_strncat( errmsg, "    EIP:     EBP:       Frame: OldEBP, RetAddr, Params...\n", errmsglen );
      eip = pCtx->Eip;
      ebp = ( unsigned int * ) pCtx->Ebp;
      if( ! IsBadWritePtr( ebp, 8 ) )
      {
         for( i = 0; i < 20; i++ )
         {
            if( ( unsigned int ) ebp % 4 != 0 || IsBadWritePtr( ebp, 40 ) || ( unsigned int ) ebp >= ebp[ 0 ] )
               break;
            snprintf( buf, sizeof( buf ), "    %08X %08X  ", ( int ) eip, ( int ) ebp );
            hb_strncat( errmsg, buf, errmsglen );
            for( j = 0; j < 10 && ( unsigned int )( ebp + j ) < ebp[ 0 ]; j++ )
            {
               snprintf( buf, sizeof( buf ), " %08X", ebp[ j ] );
               hb_strncat( errmsg, buf, errmsglen );
            }
            hb_strncat( errmsg, "\n", errmsglen );
            eip = ebp[ 1 ];
            ebp = ( unsigned int * ) ebp[ 0 ];
         }
         hb_strncat( errmsg, "\n", errmsglen );
      }
   }
#endif

   hb_errInternal( 6005, "Exception error: %s", errmsg, NULL );

   return hb_cmdargCheck( "BATCH" ) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
}

#elif defined(HB_OS_OS2)

static EXCEPTIONREGISTRATIONRECORD s_regRec; /* Exception Registration Record */
extrap.c89
ULONG _SYSTEMhb_os2ExceptionHandler( PEXCEPTIONREPORTRECORD p1, PEXCEPTIONREGISTRATIONRECORD p2, PCONTEXTRECORD p3, PVOID pv )
ULONG _System hb_os2ExceptionHandler( PEXCEPTIONREPORTRECORD       p1,
                                      PEXCEPTIONREGISTRATIONRECORD p2,
                                      PCONTEXTRECORD               p3,
                                      PVOID                        pv )
{
   HB_SYMBOL_UNUSED( p1 );
   HB_SYMBOL_UNUSED( p2 );
   HB_SYMBOL_UNUSED( p3 );
   HB_SYMBOL_UNUSED( pv );

   /* Don't print stack trace if inside unwind, normal process termination or process killed or
      during debugging */
   if( p1->ExceptionNum != XCPT_UNWIND && p1->ExceptionNum < XCPT_BREAKPOINT )
   {
      char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ];
      char file[ _POSIX_PATH_MAX + 1 ];
      USHORT uiLine;
      int iLevel = 0;

      fprintf( stderr, HB_I_("\nException %lx at address %p \n"), p1->ExceptionNum, p1->ExceptionAddress );

      while( hb_procinfo( iLevel++, buffer, &uiLine, file ) )
         fprintf( stderr, HB_I_("Called from %s(%hu)%s%s\n"), buffer, uiLine, *file ? HB_I_(" in ") : "", file );
   }

   return hb_cmdargCheck( "BATCH" ) ? XCPT_CONTINUE_STOP : XCPT_CONTINUE_SEARCH /* Exception not resolved... */;
}
extrap.c190
STATIC VOIDhb_signalExceptionHandler( int sig, siginfo_t * si, void * ucp )
static void hb_signalExceptionHandler( int sig, siginfo_t * si, void * ucp )
{
   char buffer[ 32 ];
   const char * signame;
   const char * sigaddr;

   HB_SYMBOL_UNUSED( ucp );

   switch( sig )
   {
   case SIGSEGV:
      signame = "SIGSEGV";
      snprintf( buffer, sizeof( buffer ), "%p", si->si_addr );
      sigaddr = buffer;
      break;
   case SIGILL:
      signame = "SIGILL";
      snprintf( buffer, sizeof( buffer ), "%p", si->si_addr );
      sigaddr = buffer;
      break;
   case SIGFPE:
      signame = "SIGFPE";
      snprintf( buffer, sizeof( buffer ), "%p", si->si_addr );
      sigaddr = buffer;
      break;
   case SIGBUS:
      signame = "SIGBUS";
      snprintf( buffer, sizeof( buffer ), "%p", si->si_addr );
      sigaddr = buffer;
      break;
   default:
      snprintf( buffer, sizeof( buffer ), "sig:%d", sig );
      signame = buffer;
      sigaddr = "UNKNOWN";
      break;
   }

   hb_errInternal( 6005, "Exception %s at address %s", signame, sigaddr );
}
extrap.c220
VOIDhb_vmSetExceptionHandler( void )
void hb_vmSetExceptionHandler( void )
{
#if defined(HB_OS_WIN_32) && !defined(HB_WINCE)
   {
      LPTOP_LEVEL_EXCEPTION_FILTER ef = SetUnhandledExceptionFilter( hb_win32ExceptionHandler );
      HB_SYMBOL_UNUSED( ef );
   }
#elif defined(HB_OS_OS2) /* Add OS2TermHandler to this thread's chain of exception handlers */
   {
      APIRET rc;                             /* Return code                   */

      memset( &s_regRec, 0, sizeof( s_regRec ) );
      s_regRec.ExceptionHandler = ( ERR ) hb_os2ExceptionHandler;
      rc = DosSetExceptionHandler( &s_regRec );
      if( rc != NO_ERROR )
         hb_errInternal( HB_EI_ERRUNRECOV, "Unable to setup exception handler (DosSetExceptionHandler())", NULL, NULL );
   }
#elif defined( HB_SIGNAL_EXCEPTION_HANDLER )
   {
      stack_t ss;
      ss.ss_sp = ( void * ) s_signal_stack;
      ss.ss_size = SIGSTKSZ;
      ss.ss_flags = 0;
      /* set alternative stack for SIGSEGV executed on stack overflow */
      if( sigaltstack( &ss, NULL ) == 0 )
      {
         struct sigaction act;
         int i, sigs[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, 0 };

         /* Ignore SIGPIPEs so they don't kill us. */
         signal( SIGPIPE, SIG_IGN );
         for( i = 0; sigs[ i ]; ++i )
         {
            sigaction( sigs[ i ], 0, &act );
            act.sa_sigaction = hb_signalExceptionHandler;
            act.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESETHAND;
            sigaction( sigs[ i ], &act, 0 );
         }
      }
   }
#endif
}
extrap.c262
VOIDhb_vmUnsetExceptionHandler( void )
void hb_vmUnsetExceptionHandler( void )
{
#if defined(HB_OS_OS2) /* Add OS2TermHandler to this thread's chain of exception handlers */
   {
      APIRET rc;                             /* Return code                   */

      /* I don't do any check on return code since harbour is exiting in any case */
      rc = DosUnsetExceptionHandler( &s_regRec );
      HB_SYMBOL_UNUSED( rc );
   }
#elif defined( HB_SIGNAL_EXCEPTION_HANDLER )
   {
      /* we are using static buffer for alternative stack so we do not
       * have to deallocate it to free the memory on application exit
       */
#if 0
      stack_t ss, oss;
      ss.ss_sp = NULL;
      ss.ss_size = SIGSTKSZ;
      ss.ss_flags = SS_DISABLE;
      /* set alternative stack for SIGSEGV executed on stack overflow */
      if( sigaltstack( &ss, &oss ) == 0 )
      {
         if( oss.ss_sp && SS_DISABLE )
            free( oss.ss_sp );
      }
#endif
   }
#endif
}
extrap.c305
fm.c
TypeFunctionSourceLine
STATIC __INLINE VOIDhb_counterIncrement( volatile HB_COUNTER * p )
   static __inline void hb_counterIncrement( volatile HB_COUNTER * p )
   {
      HB_FM_LOCK
      ++(*p);
      HB_FM_UNLOCK
   }
fm.c257
STATIC __INLINE INThb_counterDecrement( volatile HB_COUNTER * p )
   static __inline int hb_counterDecrement( volatile HB_COUNTER * p )
   {
      int iResult;
      HB_FM_LOCK
      iResult = --(*p) != 0;
      HB_FM_UNLOCK
      return iResult;
   }
fm.c264
HB_EXPORT VOIDhb_xsetfilename( char * szValue )
HB_EXPORT void hb_xsetfilename( char * szValue )
{
#ifdef HB_FM_STATISTICS
   hb_strncpy( s_szFileName, szValue, sizeof( s_szFileName ) - 1 );
#else
   HB_SYMBOL_UNUSED( szValue );
#endif
}
fm.c283
HB_EXPORT VOIDhb_xsetinfo( char * szValue )
HB_EXPORT void hb_xsetinfo( char * szValue )
{
#ifdef HB_FM_STATISTICS
   hb_strncpy( s_szInfo, szValue, sizeof( s_szInfo ) - 1 );
#else
   HB_SYMBOL_UNUSED( szValue );
#endif
}
fm.c292
HB_EXPORT VOID *hb_xalloc( ULONG ulSize )
HB_EXPORT void * hb_xalloc( ULONG ulSize )         /* allocates fixed memory, returns NULL on failure */
{
   PHB_MEMINFO pMem;

   HB_TRACE_FM(HB_TR_DEBUG, ("hb_xalloc(%lu)", ulSize));

   if( ulSize == 0 )
      hb_errInternal( HB_EI_XALLOCNULLSIZE, NULL, NULL, NULL );

   pMem = ( PHB_MEMINFO ) malloc( HB_ALLOC_SIZE( ulSize ) );

   if( ! pMem )
      return pMem;

#ifdef HB_FM_STATISTICS

   HB_FM_LOCK

   if( ! s_pFirstBlock )
   {
      pMem->pPrevBlock = NULL;
      s_pFirstBlock = pMem;
   }
   else
   {
      pMem->pPrevBlock = s_pLastBlock;
      s_pLastBlock->pNextBlock = pMem;
   }
   s_pLastBlock = pMem;

   pMem->pNextBlock = NULL;
   pMem->u32Signature = HB_MEMINFO_SIGNATURE;
   HB_FM_SETSIG( HB_MEM_PTR( pMem ), ulSize );
   pMem->ulSize = ulSize;  /* size of the memory block */

   if( hb_tr_level() >= HB_TR_DEBUG )
   {
      /* NOTE: PRG line number/procname is not very useful during hunting
      * for memory leaks - this is why we are using the previously stored
      * function/line info - this is a location of code that called
      * hb_xalloc/hb_xgrab
      */
      pMem->uiProcLine = hb_tr_line_; /* C line number */
      hb_strncpy( pMem->szProcName, hb_tr_file_, sizeof( pMem->szProcName ) - 1 );
   }
   else
   {
      hb_stackBaseProcInfo( pMem->szProcName, &pMem->uiProcLine );
   }

   s_lMemoryConsumed += ulSize + sizeof( HB_COUNTER );
   if( s_lMemoryMaxConsumed < s_lMemoryConsumed )
      s_lMemoryMaxConsumed = s_lMemoryConsumed;
   s_lMemoryBlocks++;
   if( s_lMemoryMaxBlocks < s_lMemoryBlocks )
      s_lMemoryMaxBlocks = s_lMemoryBlocks;

   HB_FM_UNLOCK

#ifdef HB_PARANOID_MEM_CHECK
   memset( HB_MEM_PTR( pMem ), HB_MEMFILER, ulSize );
#endif

#endif

   HB_ATOM_SET( HB_COUNTER_PTR( HB_MEM_PTR( pMem ) ), 1 );

   return HB_MEM_PTR( pMem );
}
fm.c302
HB_EXPORT VOID *hb_xgrab( ULONG ulSize )
HB_EXPORT void * hb_xgrab( ULONG ulSize )         /* allocates fixed memory, exits on failure */
{
   PHB_MEMINFO pMem;

   HB_TRACE_FM(HB_TR_DEBUG, ("hb_xgrab(%lu)", ulSize));

   if( ulSize == 0 )
      hb_errInternal( HB_EI_XGRABNULLSIZE, NULL, NULL, NULL );

   pMem = ( PHB_MEMINFO ) malloc( HB_ALLOC_SIZE( ulSize ) );

   if( ! pMem )
      hb_errInternal( HB_EI_XGRABALLOC, NULL, NULL, NULL );

#ifdef HB_FM_STATISTICS

   HB_FM_LOCK

   if( ! s_pFirstBlock )
   {
      pMem->pPrevBlock = NULL;
      s_pFirstBlock = pMem;
   }
   else
   {
      pMem->pPrevBlock = s_pLastBlock;
      s_pLastBlock->pNextBlock = pMem;
   }
   s_pLastBlock = pMem;

   pMem->pNextBlock = NULL;
   pMem->u32Signature = HB_MEMINFO_SIGNATURE;
   HB_FM_SETSIG( HB_MEM_PTR( pMem ), ulSize );
   pMem->ulSize = ulSize;  /* size of the memory block */

   if( hb_tr_level() >= HB_TR_DEBUG )
   {
      /* NOTE: PRG line number/procname is not very useful during hunting
      * for memory leaks - this is why we are using the previously stored
      * function/line info - this is a location of code that called
      * hb_xalloc/hb_xgrab
      */
      pMem->uiProcLine = hb_tr_line_; /* C line number */
      hb_strncpy( pMem->szProcName, hb_tr_file_, sizeof( pMem->szProcName ) - 1 );
   }
   else
   {
      hb_stackBaseProcInfo( pMem->szProcName, &pMem->uiProcLine );
   }

   s_lMemoryConsumed += ulSize + sizeof( HB_COUNTER );
   if( s_lMemoryMaxConsumed < s_lMemoryConsumed )
      s_lMemoryMaxConsumed = s_lMemoryConsumed;
   s_lMemoryBlocks++;
   if( s_lMemoryMaxBlocks < s_lMemoryBlocks )
      s_lMemoryMaxBlocks = s_lMemoryBlocks;

   HB_FM_UNLOCK

#ifdef HB_PARANOID_MEM_CHECK
   memset( HB_MEM_PTR( pMem ), HB_MEMFILER, ulSize );
#endif

#endif

   HB_ATOM_SET( HB_COUNTER_PTR( HB_MEM_PTR( pMem ) ), 1 );

   return HB_MEM_PTR( pMem );
}
fm.c372
HB_EXPORT VOID *hb_xrealloc( void * pMem, ULONG ulSize )
HB_EXPORT void * hb_xrealloc( void * pMem, ULONG ulSize )       /* reallocates memory */
{
   HB_TRACE_FM(HB_TR_DEBUG, ("hb_xrealloc(%p, %lu)", pMem, ulSize));

#if 0
   /* disabled to make hb_xrealloc() ANSI-C realloc() compatible */
   if( ! pMem )
      hb_errInternal( HB_EI_XREALLOCNULL, NULL, NULL, NULL );

   if( ulSize == 0 )
      hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
#endif

#ifdef HB_FM_STATISTICS
   if( pMem == NULL )
   {
      if( ulSize == 0 )
         hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
      return hb_xgrab( ulSize );
   }
   else if( ulSize == 0 )
   {
      hb_xfree( pMem );
      return NULL;
   }
   else
   {
      PHB_MEMINFO pMemBlock;
      ULONG ulMemSize;

      pMemBlock = HB_FM_PTR( pMem );

      if( pMemBlock->u32Signature != HB_MEMINFO_SIGNATURE )
         hb_errInternal( HB_EI_XREALLOCINV, NULL, NULL, NULL );

      ulMemSize = pMemBlock->ulSize;

      if( HB_FM_GETSIG( pMem, ulMemSize ) != HB_MEMINFO_SIGNATURE )
         hb_errInternal( HB_EI_XMEMOVERFLOW, NULL, NULL, NULL );

      HB_FM_CLRSIG( pMem, ulMemSize );

      HB_FM_LOCK

#ifdef HB_PARANOID_MEM_CHECK
      pMem = malloc( HB_ALLOC_SIZE( ulSize ) );
      if( pMem )
      {
         if( ulSize > ulMemSize )
         {
            memcpy( pMem, pMemBlock, HB_ALLOC_SIZE( ulMemSize ) );
            memset( ( BYTE * ) pMem + HB_ALLOC_SIZE( ulMemSize ), HB_MEMFILER, ulSize - ulMemSize );
         }
         else
            memcpy( pMem, pMemBlock, HB_ALLOC_SIZE( ulSize ) );
      }
      memset( pMemBlock, HB_MEMFILER, HB_ALLOC_SIZE( ulMemSize ) );
      free( pMemBlock );
#else
      pMem = realloc( pMemBlock, HB_ALLOC_SIZE( ulSize ) );
#endif

      s_lMemoryConsumed += ( ulSize - ulMemSize );
      if( s_lMemoryMaxConsumed < s_lMemoryConsumed )
         s_lMemoryMaxConsumed = s_lMemoryConsumed;

      if( ! pMem )
         hb_errInternal( HB_EI_XREALLOC, NULL, NULL, NULL );

      ( ( PHB_MEMINFO ) pMem )->ulSize = ulSize;  /* size of the memory block */
      HB_FM_SETSIG( HB_MEM_PTR( pMem ), ulSize );
      if( ( ( PHB_MEMINFO ) pMem )->pPrevBlock )
         ( ( PHB_MEMINFO ) pMem )->pPrevBlock->pNextBlock = ( PHB_MEMINFO ) pMem;
      if( ( ( PHB_MEMINFO ) pMem )->pNextBlock )
         ( ( PHB_MEMINFO ) pMem )->pNextBlock->pPrevBlock = ( PHB_MEMINFO ) pMem;

      if( s_pFirstBlock == pMemBlock )
         s_pFirstBlock = ( PHB_MEMINFO ) pMem;
      if( s_pLastBlock == pMemBlock )
         s_pLastBlock = ( PHB_MEMINFO ) pMem;

      HB_FM_UNLOCK
   }
#else

   if( pMem == NULL )
   {
      if( ulSize == 0 )
         hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
      pMem = malloc( HB_ALLOC_SIZE( ulSize ) );
   }
   else if( ulSize == 0 )
   {
      free( HB_FM_PTR( pMem ) );
      return NULL;
   }
   else
   {
      pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( ulSize ) );
   }

   if( !pMem )
      hb_errInternal( HB_EI_XREALLOC, NULL, NULL, NULL );

#endif

   return HB_MEM_PTR( pMem );
}
fm.c442
HB_EXPORT VOIDhb_xfree( void * pMem )
HB_EXPORT void hb_xfree( void * pMem )            /* frees fixed memory */
{
   HB_TRACE_FM(HB_TR_DEBUG, ("hb_xfree(%p)", pMem));

   if( pMem )
   {
#ifdef HB_FM_STATISTICS

      PHB_MEMINFO pMemBlock = HB_FM_PTR( pMem );

      if( pMemBlock->u32Signature != HB_MEMINFO_SIGNATURE )
         hb_errInternal( HB_EI_XFREEINV, NULL, NULL, NULL );

      if( HB_FM_GETSIG( pMem, pMemBlock->ulSize ) != HB_MEMINFO_SIGNATURE )
         hb_errInternal( HB_EI_XMEMOVERFLOW, NULL, NULL, NULL );

      HB_FM_LOCK

      s_lMemoryConsumed -= pMemBlock->ulSize + sizeof( HB_COUNTER );
      s_lMemoryBlocks--;

      if( pMemBlock->pPrevBlock )
         pMemBlock->pPrevBlock->pNextBlock = pMemBlock->pNextBlock;
      else
         s_pFirstBlock = pMemBlock->pNextBlock;

      if( pMemBlock->pNextBlock )
         pMemBlock->pNextBlock->pPrevBlock = pMemBlock->pPrevBlock;
      else
         s_pLastBlock = pMemBlock->pPrevBlock;

      HB_FM_UNLOCK

      pMemBlock->u32Signature = 0;
      HB_FM_CLRSIG( pMem, pMemBlock->ulSize );

#ifdef HB_PARANOID_MEM_CHECK
      memset( pMemBlock, HB_MEMFILER, HB_ALLOC_SIZE( pMemBlock->ulSize ) );
#endif

      free( ( void * ) pMemBlock );

#else

      free( HB_FM_PTR( pMem ) );

#endif
   }
   else
      hb_errInternal( HB_EI_XFREENULL, NULL, NULL, NULL );
}
fm.c551
VOIDhb_xRefInc( void * pMem )
void hb_xRefInc( void * pMem )
{
   HB_ATOM_INC( HB_COUNTER_PTR( pMem ) );
}
fm.c605
BOOLhb_xRefDec( void * pMem )
BOOL hb_xRefDec( void * pMem )
{
   return HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0;
}
fm.c612
VOIDhb_xRefFree( void * pMem )
void hb_xRefFree( void * pMem )
{
#ifdef HB_FM_STATISTICS

   if( HB_FM_PTR( pMem )->u32Signature != HB_MEMINFO_SIGNATURE )
      hb_errInternal( HB_EI_XFREEINV, NULL, NULL, NULL );

   if( HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0 )
      hb_xfree( pMem );

#else

   if( HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0 )
      free( HB_FM_PTR( pMem ) );

#endif
}
fm.c619
HB_COUNTERhb_xRefCount( void * pMem )
HB_COUNTER hb_xRefCount( void * pMem )
{
   return HB_ATOM_GET( HB_COUNTER_PTR( pMem ) );
}
fm.c639
VOID *hb_xRefResize( void * pMem, ULONG ulSave, ULONG ulSize )
void * hb_xRefResize( void * pMem, ULONG ulSave, ULONG ulSize )
{

#ifdef HB_FM_STATISTICS
   if( HB_ATOM_GET( HB_COUNTER_PTR( pMem ) ) > 1 )
   {
      void * pMemNew = memcpy( hb_xgrab( ulSize ), pMem, HB_MIN( ulSave, ulSize ) );

      if( HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0 )
         hb_xfree( pMem );

      return pMemNew;
   }

   return hb_xrealloc( pMem, ulSize );

#else

   if( HB_ATOM_GET( HB_COUNTER_PTR( pMem ) ) > 1 )
   {
      void * pMemNew = malloc( HB_ALLOC_SIZE( ulSize ) );

      if( pMemNew )
      {
         HB_ATOM_SET( HB_COUNTER_PTR( HB_MEM_PTR( pMemNew ) ), 1 );
         memcpy( HB_MEM_PTR( pMemNew ), pMem, HB_MIN( ulSave, ulSize ) );
         if( HB_ATOM_DEC( HB_COUNTER_PTR( pMem ) ) == 0 )
            free( HB_FM_PTR( pMem ) );
         return HB_MEM_PTR( pMemNew );
      }
   }
   else
   {
      pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE ( ulSize ) );
      if( pMem )
         return HB_MEM_PTR( pMem );
   }

   hb_errInternal( HB_EI_XREALLOC, NULL, NULL, NULL );
   return NULL;
#endif
}
fm.c646
HB_EXPORT ULONGhb_xsize( void * pMem )
HB_EXPORT ULONG  hb_xsize( void * pMem ) /* returns the size of an allocated memory block */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xsize(%p)", pMem));

#ifdef HB_FM_STATISTICS
   return HB_FM_PTR( pMem )->ulSize;
#else
   HB_SYMBOL_UNUSED( pMem );

   return 0;
#endif
}
fm.c692
HB_EXPORT VOIDhb_xinit( void )
HB_EXPORT void hb_xinit( void ) /* Initialize fixed memory subsystem */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xinit()"));
}
fm.c705
STATIC CHAR *hb_mem2str( char * membuffer, void * pMem, UINT uiSize )
static char * hb_mem2str( char * membuffer, void * pMem, UINT uiSize )
{
   BYTE *cMem = ( BYTE * ) pMem;
   UINT uiIndex, uiPrintable;

   uiPrintable = 0;
   for( uiIndex = 0; uiIndex < uiSize; uiIndex++ )
      if( ( cMem[ uiIndex ] & 0x60 ) != 0 )
         uiPrintable++;

   if( uiPrintable * 100 / uiSize > 70 ) /* more then 70% printable chars */
   {
      /* format as string of original chars */
      for( uiIndex = 0; uiIndex < uiSize; uiIndex++ )
         if( cMem[ uiIndex ] >= ' ' )
            membuffer[ uiIndex ] = cMem[ uiIndex ];
         else
            membuffer[ uiIndex ] = '.';
      membuffer[ uiIndex ] = '\0';
   }
   else
   {
     /* format as hex */
      for( uiIndex = 0; uiIndex < uiSize; uiIndex++ )
      {
         int lownibble, hinibble;
         hinibble = cMem[ uiIndex ] >> 4;
         lownibble = cMem[ uiIndex ] & 0x0F;
         membuffer[ uiIndex * 2 ]     = hinibble <= 9 ?
                               ( '0' + hinibble ) : ( 'A' + hinibble - 10 );
         membuffer[ uiIndex * 2 + 1 ] = lownibble <= 9 ?
                               ( '0' + lownibble ) : ( 'A' + lownibble - 10 );
      }
      membuffer[ uiIndex * 2 ] = '\0';
   }

   return membuffer;
}
fm.c714
HB_EXPORT VOIDhb_xexit( void )
HB_EXPORT void hb_xexit( void ) /* Deinitialize fixed memory subsystem */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xexit()"));

   if( s_lMemoryBlocks || hb_cmdargCheck( "INFO" ) )
   {
      char membuffer[ HB_MAX_MEM2STR_BLOCK * 2 + 1 ]; /* multiplied by 2 to allow hex format */
      PHB_MEMINFO pMemBlock;
      USHORT ui;
      char buffer[ 100 ];
      FILE * hLog = NULL;

      if( s_lMemoryBlocks && s_szFileName[ 0 ] )
         hLog = hb_fopen( s_szFileName, "a+" );

      hb_conOutErr( hb_conNewLine(), 0 );
      hb_conOutErr( "----------------------------------------", 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
      snprintf( buffer, sizeof( buffer ), HB_I_("Total memory allocated: %li bytes (%li block(s))"), s_lMemoryMaxConsumed, s_lMemoryMaxBlocks );
      hb_conOutErr( buffer, 0 );

      if( s_lMemoryBlocks )
      {
         if( hLog )
         {
            char szTime[ 9 ];
            int iYear, iMonth, iDay;
         
            hb_dateToday( &iYear, &iMonth, &iDay );
            hb_dateTimeStr( szTime );
         
            fprintf( hLog, HB_I_("Application Memory Allocation Report - %s\n"), hb_cmdargARGV()[0] );
            fprintf( hLog, HB_I_("Terminated at: %04d.%02d.%02d %s\n"), iYear, iMonth, iDay, szTime );
            if( s_szInfo[ 0 ] )
               fprintf( hLog, HB_I_("Info: %s\n"), s_szInfo );
            fprintf( hLog, "%s\n", buffer );
         }

         hb_conOutErr( hb_conNewLine(), 0 );
         snprintf( buffer, sizeof( buffer ), HB_I_("Warning, memory allocated but not released: %li bytes (%li block(s))"), s_lMemoryConsumed, s_lMemoryBlocks );
         hb_conOutErr( buffer, 0 );

         if( hLog )
            fprintf( hLog, "%s\n", buffer );
      }

      hb_conOutErr( hb_conNewLine(), 0 );

      for( ui = 1, pMemBlock = s_pFirstBlock; pMemBlock; pMemBlock = pMemBlock->pNextBlock, ++ui )
      {
         HB_TRACE( HB_TR_ERROR, ( "Block %i (size %lu) %s(%i), \"%s\"", ui,
            pMemBlock->ulSize, pMemBlock->szProcName, pMemBlock->uiProcLine,
            hb_mem2str( membuffer, ( char * ) pMemBlock + HB_MEMINFO_SIZE,
                        HB_MIN( pMemBlock->ulSize, HB_MAX_MEM2STR_BLOCK ) ) ) );

         if( hLog )
         {
            fprintf( hLog, HB_I_("Block %i %p (size %lu) %s(%i), \"%s\"\n"), ui,
               ( char * ) pMemBlock + HB_MEMINFO_SIZE,
               pMemBlock->ulSize, pMemBlock->szProcName, pMemBlock->uiProcLine,
               hb_mem2str( membuffer, ( char * ) pMemBlock + HB_MEMINFO_SIZE,
                           HB_MIN( pMemBlock->ulSize, HB_MAX_MEM2STR_BLOCK ) ) );
         }
      }

      if( hLog )
      {
         fprintf( hLog, "------------------------------------------------------------------------\n");
         fclose( hLog );
      }
   }
}
fm.c754
HB_EXPORT VOIDhb_xexit( void )
HB_EXPORT void hb_xexit( void ) /* Deinitialize fixed memory subsystem */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xexit()"));
}

#endif

fm.c829
VOID *hb_xmemcpy( void * pDestArg, void * pSourceArg, ULONG ulLen )
void * hb_xmemcpy( void * pDestArg, void * pSourceArg, ULONG ulLen )
{
   BYTE * pDest;
   BYTE * pSource;
   ULONG  ulRemaining;
   int    iCopySize;

   HB_TRACE(HB_TR_DEBUG, ("hb_xmemcpy(%p, %p, %lu)", pDestArg, pSourceArg, ulLen));

   pDest = ( BYTE * ) pDestArg;
   pSource = ( BYTE * ) pSourceArg;
   ulRemaining = ulLen;

   while( ulRemaining )
   {
      /* Overcome the memcpy() size_t limitation */
      if( ulRemaining > UINT_MAX )
      {
         iCopySize = UINT_MAX;
         ulRemaining -= ( ULONG ) iCopySize;
      }
      else
      {
         iCopySize = ( int ) ulRemaining;
         ulRemaining = 0;
      }
      memcpy( pDest, pSource, iCopySize );
      pDest += iCopySize;
      pSource += iCopySize;
   }

   return pDestArg;
}
fm.c848
VOID *hb_xmemset( void * pDestArg, int iFill, ULONG ulLen )
void * hb_xmemset( void * pDestArg, int iFill, ULONG ulLen )
{
   BYTE * pDest;
   ULONG  ulRemaining;
   int    iSetSize;

   HB_TRACE(HB_TR_DEBUG, ("hb_xmemset(%p, %d, %lu)", pDestArg, iFill, ulLen));

   pDest = ( BYTE * ) pDestArg;
   ulRemaining = ulLen;

   while( ulRemaining )
   {
      /* Overcome the memset() size_t limitation */
      if( ulRemaining > UINT_MAX )
      {
         iSetSize = UINT_MAX;
         ulRemaining -= ( ULONG ) iSetSize;
      }
      else
      {
         iSetSize = ( int ) ulRemaining;
         ulRemaining = 0;
      }
      memset( pDest, iFill, iSetSize );
      pDest += iSetSize;
   }

   return pDestArg;
}
fm.c884
ULONGhb_xquery( USHORT uiMode )
ULONG hb_xquery( USHORT uiMode )
{
   ULONG ulResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xquery(%hu)", uiMode));

   /* TODO: Return the correct values instead of 9999 [vszakats] */

   switch( uiMode )
   {
   case HB_MEM_CHAR:       /*               (Free Variable Space [KB])          */
      #if defined(HB_OS_WIN_32)
      {
         MEMORYSTATUS memorystatus;
         GlobalMemoryStatus( &memorystatus );
         ulResult = memorystatus.dwAvailPhys / 1024;
      }
      #elif defined(HB_OS_OS2)
      {
         ULONG ulSysInfo = 0;

         if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
            ulResult = 0;
         else
            ulResult = ulSysInfo / 1024;
      }
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_BLOCK:      /*               (Largest String [KB])               */
      #if defined(HB_OS_WIN_32)
      {
         MEMORYSTATUS memorystatus;
         GlobalMemoryStatus( &memorystatus );
         ulResult = HB_MIN( memorystatus.dwAvailPhys, ULONG_MAX ) / 1024;
      }
      #elif defined(HB_OS_OS2)
      {
         ULONG ulSysInfo = 0;

         if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
            ulResult = 0;
         else
            ulResult = HB_MIN( ulSysInfo, ULONG_MAX ) / 1024;
      }
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_RUN:        /*               (RUN Memory [KB])                   */
      #if defined(HB_OS_WIN_32)
      {
         MEMORYSTATUS memorystatus;
         GlobalMemoryStatus( &memorystatus );
         ulResult = memorystatus.dwAvailPhys / 1024;
      }
      #elif defined(HB_OS_OS2)
      {
         ULONG ulSysInfo = 0;

         if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
            ulResult = 0;
         else
            ulResult = ulSysInfo / 1024;
      }
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_VM:         /* UNDOCUMENTED! (Virtual Memory [KB])               */
      #if defined(HB_OS_WIN_32)
      {
         MEMORYSTATUS memorystatus;
         GlobalMemoryStatus( &memorystatus );
         ulResult = memorystatus.dwAvailVirtual / 1024;
      }
      #elif defined(HB_OS_OS2)
      {
         ULONG ulSysInfo = 0;

         if( DosQuerySysInfo( QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
            ulResult = 0;
         else
            ulResult = ulSysInfo / 1024;
      }
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_EMS:        /* UNDOCUMENTED! (Free Expanded Memory [KB]) (?)     */
      #if defined(HB_OS_WIN_32) || defined(HB_OS_OS2)
         ulResult = 0;
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_FM:         /* UNDOCUMENTED! (Fixed Memory/Heap [KB]) (?)        */
      #if defined(HB_OS_WIN_32)
      {
         MEMORYSTATUS memorystatus;
         GlobalMemoryStatus( &memorystatus );
         ulResult = memorystatus.dwTotalPhys / 1024;
      }
      #elif defined(HB_OS_OS2)
      {
         ULONG ulSysInfo = 0;

         if( DosQuerySysInfo( QSV_MAXPRMEM, QSV_MAXPRMEM, &ulSysInfo, sizeof( ULONG ) ) != NO_ERROR )
            ulResult = 0;
         else
            ulResult = ulSysInfo / 1024;
      }
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_FMSEGS:     /* UNDOCUMENTED! (Segments in Fixed Memory/Heap) (?) */
      #if defined(HB_OS_WIN_32) || defined(HB_OS_OS2)
         ulResult = 1;
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_SWAP:       /* UNDOCUMENTED! (Free Swap Memory [KB])             */
      #if defined(HB_OS_WIN_32)
      {
         MEMORYSTATUS memorystatus;
         GlobalMemoryStatus( &memorystatus );
         ulResult = memorystatus.dwAvailPageFile / 1024;
      }
      #elif defined(HB_OS_OS2)
      {
         /* NOTE: There is no way to know how much a swap file can grow on an
                  OS/2 system. I think we should return free space on DASD
                  media which contains swap file [maurilio.longo] */
         ulResult = 9999;
      }
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_CONV:       /* UNDOCUMENTED! (Free Conventional [KB])            */
      #if defined(HB_OS_WIN_32) || defined(HB_OS_OS2)
         ulResult = 0;
      #else
         ulResult = 9999;
      #endif
      break;

   case HB_MEM_EMSUSED:    /* UNDOCUMENTED! (Used Expanded Memory [KB]) (?)     */
      ulResult = 0;
      break;

   case HB_MEM_USED:       /* Harbour extension (Memory used [bytes])           */
#ifdef HB_FM_STATISTICS
      ulResult = s_lMemoryConsumed;
#else
      ulResult = 0;
#endif
      break;

   case HB_MEM_BLOCKS:     /* Harbour extension (Memory blocks used)            */
#ifdef HB_FM_STATISTICS
      ulResult = s_lMemoryBlocks;
#else
      ulResult = 0;
#endif
      break;

   case HB_MEM_USEDMAX:    /* Harbour extension (Maximum memory used [bytes])   */
#ifdef HB_FM_STATISTICS
      ulResult = s_lMemoryMaxConsumed;
#else
      ulResult = 0;
#endif
      break;

   case HB_MEM_STACKITEMS: /* Harbour extension (Total items allocated for the stack)      */
      ulResult = hb_stackTotalItems();
      break;

   case HB_MEM_STACK:      /* Harbour extension (Total memory size used by the stack [bytes]) */
      ulResult = hb_stackTotalItems() * sizeof( HB_ITEM );
      break;

   case HB_MEM_STACK_TOP : /* Harbour extension (Total items currently on the stack)      */
      ulResult = hb_stackTopOffset( );
      break;

   default:
      ulResult = 0;
   }

   return ulResult;
}
fm.c916
HB_FUNCMEMORY(void)
HB_FUNC( MEMORY )
{
   hb_retnint( hb_xquery( ( USHORT ) hb_parni( 1 ) ) );
}
fm.c1121
HB_FUNCHB_FM_STAT(void)
HB_FUNC( HB_FM_STAT ) {}
fm.c1127
HB_FUNCHB_FM_NOSTAT(void)
HB_FUNC( HB_FM_NOSTAT ) {}
fm.c1129
garbage.c
TypeFunctionSourceLine
STATIC __INLINE__ INThb_atomic_lock( volatile int * p )
   static __inline__ int hb_atomic_lock( volatile int * p )
   {
      unsigned char c;
      __asm__ __volatile__(
         "lock\n\t"
         "cmpxchgl %3, %1\n\t"
         "sete %0"
         :"=a" (c), "+m" (*p)
         :"a" (0), "d" (1)
      );
      return c;
   }
garbage.c80
STATIC __INLINE__ VOIDhb_atomic_unlock( volatile int * p )
   static __inline__ void hb_atomic_unlock( volatile int * p )
   {
      __asm__ __volatile__(
         "xchgl %0, %1"
         :"+m" (*p)
         :"a" (0), "r" (*p)
      );
   }

   static int s_gcSpinLock = 0;
garbage.c93
STATIC VOIDhb_gc_acquire_lock( void )
   static void hb_gc_acquire_lock( void )
   {
      for( ;; )
      {
         if( hb_atomic_lock( &s_gcSpinLock ) )
            return;
#if defined( HB_OS_WIN_32 )
         Sleep( 0 );
#elif defined( HB_OS_OS2 )
         DosSleep( 0 );
#elif defined( HB_OS_UNIX )
         sched_yield();
#else
         sleep( 0 );
#endif
      }
   }
garbage.c104
STATIC VOIDhb_gc_release_lock( void )
   static void hb_gc_release_lock( void )
   {
      hb_atomic_unlock( &s_gcSpinLock );
   }

#  define HB_GC_LOCK          hb_gc_acquire_lock();
#  define HB_GC_UNLOCK        hb_gc_release_lock();

#else

   static HB_CRITICAL_NEW( s_gcMtx );
#  define HB_GC_LOCK          hb_threadEnterCriticalSection( &s_gcMtx );
#  define HB_GC_UNLOCK        hb_threadLeaveCriticalSection( &s_gcMtx );

#endif

#else

#  define HB_GC_LOCK
#  define HB_GC_UNLOCK

#endif /* HB_MT_VM */

/* holder of memory block information */
/* NOTE: USHORT is used intentionally to fill up the structure to
 * full 16 bytes (on 16/32 bit environment)
 */
typedef struct HB_GARBAGE_
{
   struct HB_GARBAGE_ *pNext;  /* next memory block */
   struct HB_GARBAGE_ *pPrev;  /* previous memory block */
   HB_GARBAGE_FUNC_PTR pFunc;  /* cleanup function called before memory releasing */
   USHORT locked;              /* locking counter */
   BYTE used;                  /* used/unused block */
   BYTE flags;                 /* HB_GC_USERSWEEP */
} HB_GARBAGE, *HB_GARBAGE_PTR;

#ifdef HB_ALLOC_ALIGNMENT
#  define HB_GARBAGE_SIZE     ( ( sizeof( HB_GARBAGE ) + HB_ALLOC_ALIGNMENT - 1 ) - \
                                ( sizeof( HB_GARBAGE ) + HB_ALLOC_ALIGNMENT - 1 ) % HB_ALLOC_ALIGNMENT )
#else
#  define HB_GARBAGE_SIZE     sizeof( HB_GARBAGE )
#endif

#define HB_GC_PTR( p )        ( ( HB_GARBAGE_PTR ) ( ( BYTE * ) ( p ) - HB_GARBAGE_SIZE ) )

#endif /* !defined( HB_GC_PTR ) */

#define HB_MEM_PTR( p )       ( ( void * ) ( ( BYTE * ) ( p ) + HB_GARBAGE_SIZE ) )

/* we may use a cache later */
#define HB_GARBAGE_NEW( ulSize )    ( ( HB_GARBAGE_PTR ) hb_xgrab( HB_GARBAGE_SIZE + ( ulSize ) ) )
#define HB_GARBAGE_FREE( pAlloc )   hb_xfree( ( void * ) ( pAlloc ) )

/* status of memory block */
/* flags stored in 'used' slot */
#define HB_GC_USED_FLAG    1  /* the bit for used/unused flag */
#define HB_GC_DELETE       2  /* item marked to delete */
#define HB_GC_DELETELST    4  /* item will be deleted during finalization */
/* flags stored in 'flags' slot */
#define HB_GC_USERSWEEP    8  /* memory block with user defined sweep function */

/* pointer to memory block that will be checked in next step */
static HB_GARBAGE_PTR s_pCurrBlock = NULL;
/* memory blocks are stored in linked list with a loop */

/* pointer to locked memory blocks */
static HB_GARBAGE_PTR s_pLockedBlock = NULL;

/* pointer to memory blocks that will be deleted */
static HB_GARBAGE_PTR s_pDeletedBlock = NULL;

/* marks if block releasing is requested during garbage collecting */
static BOOL s_bCollecting = FALSE;

/* flag for used/unused blocks - the meaning of the HB_GC_USED_FLAG bit
 * is reversed on every collecting attempt
 */
static BYTE s_uUsedFlag = HB_GC_USED_FLAG;


/* list of functions that sweeps external memory blocks */
typedef struct _HB_GARBAGE_EXTERN {
   HB_GARBAGE_SWEEPER_PTR pFunc;
   void * pBlock;
   struct _HB_GARBAGE_EXTERN *pNext;
} HB_GARBAGE_EXTERN, *HB_GARBAGE_EXTERN_PTR;

static HB_GARBAGE_EXTERN_PTR s_pSweepExtern = NULL;

static void  hb_gcUnregisterSweep( void * Cargo );
garbage.c122
STATIC VOIDhb_gcLink( HB_GARBAGE_PTR *pList, HB_GARBAGE_PTR pAlloc )
static void hb_gcLink( HB_GARBAGE_PTR *pList, HB_GARBAGE_PTR pAlloc )
{
   if( *pList )
   {
      /* add new block at the logical end of list */
      pAlloc->pNext = *pList;
      pAlloc->pPrev = (*pList)->pPrev;
      pAlloc->pPrev->pNext = pAlloc;
      (*pList)->pPrev = pAlloc;
   }
   else
   {
      *pList = pAlloc->pNext = pAlloc->pPrev = pAlloc;
   }
}
garbage.c215
STATIC VOIDhb_gcUnlink( HB_GARBAGE_PTR *pList, HB_GARBAGE_PTR pAlloc )
static void hb_gcUnlink( HB_GARBAGE_PTR *pList, HB_GARBAGE_PTR pAlloc )
{
   pAlloc->pPrev->pNext = pAlloc->pNext;
   pAlloc->pNext->pPrev = pAlloc->pPrev;
   if( *pList == pAlloc )
   {
      *pList = pAlloc->pNext;
      if( *pList == pAlloc )
         *pList = NULL;    /* this was the last block */
   }
}
garbage.c231
VOID *hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc )
void * hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pCleanupFunc )
{
   HB_GARBAGE_PTR pAlloc;

   pAlloc = HB_GARBAGE_NEW( ulSize );
   if( pAlloc )
   {
      pAlloc->pFunc  = pCleanupFunc;
      pAlloc->locked = 0;
      pAlloc->used   = s_uUsedFlag;
      pAlloc->flags  = 0;

      HB_GC_LOCK
      hb_gcLink( &s_pCurrBlock, pAlloc );
      HB_GC_UNLOCK

      return HB_MEM_PTR( pAlloc );        /* hide the internal data */
   }
   else
      return NULL;
}
garbage.c243
VOIDhb_gcFree( void *pBlock )
void hb_gcFree( void *pBlock )
{
   if( pBlock )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pBlock );

      /* Don't release the block that will be deleted during finalization */
      if( !( pAlloc->used & HB_GC_DELETE ) )
      {
         HB_GC_LOCK
         if( pAlloc->locked )
            hb_gcUnlink( &s_pLockedBlock, pAlloc );
         else
            hb_gcUnlink( &s_pCurrBlock, pAlloc );
         HB_GC_UNLOCK

         if( pAlloc->flags & HB_GC_USERSWEEP )
            hb_gcUnregisterSweep( pBlock );

         HB_GARBAGE_FREE( pAlloc );
      }
   }
   else
   {
      hb_errInternal( HB_EI_XFREENULL, NULL, NULL, NULL );
   }
}
garbage.c266
HB_GARBAGE_FUNC_PTRhb_gcFunc( void *pBlock )
HB_GARBAGE_FUNC_PTR hb_gcFunc( void *pBlock )
{
   return HB_GC_PTR( pBlock )->pFunc;
}
garbage.c295
VOIDhb_gcRefInc( void * pBlock )
void hb_gcRefInc( void * pBlock )
{
   hb_xRefInc( HB_GC_PTR( pBlock ) );
}
garbage.c303
BOOLhb_gcRefDec( void * pBlock )
BOOL hb_gcRefDec( void * pBlock )
{
   return hb_xRefDec( HB_GC_PTR( pBlock ) );
}
garbage.c310
VOIDhb_gcRefFree( void * pBlock )
void hb_gcRefFree( void * pBlock )
{
   if( pBlock )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pBlock );

      if( hb_xRefDec( pAlloc ) )
      {
         /* Don't release the block that will be deleted during finalization */
         if( !( pAlloc->used & HB_GC_DELETE ) )
         {
            /* unlink the block first to avoid possible problems
             * if cleanup function activate GC
             */
            HB_GC_LOCK
            if( pAlloc->locked )
               hb_gcUnlink( &s_pLockedBlock, pAlloc );
            else
               hb_gcUnlink( &s_pCurrBlock, pAlloc );
            HB_GC_UNLOCK

            pAlloc->used |= HB_GC_DELETE;

            /* execute clean-up function */
            if( pAlloc->pFunc )
               ( pAlloc->pFunc )( pBlock );

            if( pAlloc->used & HB_GC_DELETE )
               HB_GARBAGE_FREE( pAlloc );
         }
      }
   }
   else
   {
      hb_errInternal( HB_EI_XFREENULL, NULL, NULL, NULL );
   }
}
garbage.c317
HB_COUNTERhb_gcRefCount( void * pBlock )
HB_COUNTER hb_gcRefCount( void * pBlock )
{
   return hb_xRefCount( HB_GC_PTR( pBlock ) );
}
garbage.c358
VOIDhb_gcRefCheck( void * pBlock )
void hb_gcRefCheck( void * pBlock )
{
   HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pBlock );

   if( !( pAlloc->used & HB_GC_DELETELST ) )
   {
      if( hb_xRefCount( pAlloc ) != 0 )
      {
         pAlloc->used = s_uUsedFlag;
         pAlloc->locked = 0;

         HB_GC_LOCK
         hb_gcLink( &s_pCurrBlock, pAlloc );
         HB_GC_UNLOCK

         if( hb_vmRequestQuery() == 0 )
            hb_errRT_BASE( EG_DESTRUCTOR, 1301, NULL, "Reference to freed block", 0 );
      }
   }
}
garbage.c364
STATIC HB_GARBAGE_FUNC(hb_gcGripRelease )
static HB_GARBAGE_FUNC( hb_gcGripRelease )
{
    /* Item was already released in hb_gcGripDrop() - then we have nothing
     * to do here
     */
    HB_SYMBOL_UNUSED( Cargo );
}
garbage.c389
HB_ITEM_PTRhb_gcGripGet( HB_ITEM_PTR pOrigin )
HB_ITEM_PTR hb_gcGripGet( HB_ITEM_PTR pOrigin )
{
   HB_GARBAGE_PTR pAlloc;

   pAlloc = HB_GARBAGE_NEW( sizeof( HB_ITEM ) );
   if( pAlloc )
   {
      HB_ITEM_PTR pItem = ( HB_ITEM_PTR ) HB_MEM_PTR( pAlloc );

      pAlloc->pFunc  = hb_gcGripRelease;
      pAlloc->locked = 1;
      pAlloc->used   = s_uUsedFlag;
      pAlloc->flags  = 0;

      pItem->type = HB_IT_NIL;

      HB_GC_LOCK
      hb_gcLink( &s_pLockedBlock, pAlloc );
      HB_GC_UNLOCK

      if( pOrigin )
         hb_itemCopy( pItem, pOrigin );

      return pItem;
   }
   else
      return NULL;
}
garbage.c397
VOIDhb_gcGripDrop( HB_ITEM_PTR pItem )
void hb_gcGripDrop( HB_ITEM_PTR pItem )
{
   if( pItem )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pItem );

      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );    /* clear value stored in this item */

      HB_GC_LOCK
      hb_gcUnlink( &s_pLockedBlock, pAlloc );
      HB_GC_UNLOCK

      HB_GARBAGE_FREE( pAlloc );
   }
}
garbage.c426
VOID *hb_gcLock( void * pBlock )
void * hb_gcLock( void * pBlock )
{
   if( pBlock )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pBlock );

      HB_GC_LOCK
      if( ! pAlloc->locked )
      {
         hb_gcUnlink( &s_pCurrBlock, pAlloc );
         hb_gcLink( &s_pLockedBlock, pAlloc );
      }
      ++pAlloc->locked;
      HB_GC_UNLOCK
   }

   return pBlock;
}
garbage.c443
VOID *hb_gcUnlock( void * pBlock )
void * hb_gcUnlock( void * pBlock )
{
   if( pBlock )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pBlock );

      HB_GC_LOCK
      if( pAlloc->locked )
      {
         if( --pAlloc->locked == 0 )
         {
            pAlloc->used = s_uUsedFlag;

            hb_gcUnlink( &s_pLockedBlock, pAlloc );
            hb_gcLink( &s_pCurrBlock, pAlloc );
         }
      }
      HB_GC_UNLOCK
   }
   return pBlock;
}
garbage.c465
VOIDhb_gcItemRef( HB_ITEM_PTR pItem )
void hb_gcItemRef( HB_ITEM_PTR pItem )
{
   while( HB_IS_BYREF( pItem ) )
   {
      if( HB_IS_ENUM( pItem ) )
         return;
      else if( HB_IS_EXTREF( pItem ) )
      {
         pItem->item.asExtRef.func->mark( pItem->item.asExtRef.value );
         return;
      }
      else if( ! HB_IS_MEMVAR( pItem ) &&
               pItem->item.asRefer.offset == 0 &&
               pItem->item.asRefer.value >= 0 )
      {
         /* array item reference */
         HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pItem->item.asRefer.BasePtr.array );
         if( pAlloc->used == s_uUsedFlag )
         {
            ULONG ulSize = pItem->item.asRefer.BasePtr.array->ulLen;
            pAlloc->used ^= HB_GC_USED_FLAG;
            pItem = pItem->item.asRefer.BasePtr.array->pItems;
            while( ulSize )
            {
               hb_gcItemRef( pItem++ );
               --ulSize;
            }
         }
         return;
      }
      pItem = hb_itemUnRefOnce( pItem );
   }

   if( HB_IS_ARRAY( pItem ) )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pItem->item.asArray.value );

      /* Check this array only if it was not checked yet */
      if( pAlloc->used == s_uUsedFlag )
      {
         ULONG ulSize = pItem->item.asArray.value->ulLen;
         /* mark this block as used so it will be no re-checked from
          * other references
          */
         pAlloc->used ^= HB_GC_USED_FLAG;

         /* mark also all array elements */
         pItem = pItem->item.asArray.value->pItems;
         while( ulSize )
         {
            hb_gcItemRef( pItem++ );
            --ulSize;
         }
      }
   }
   else if( HB_IS_HASH( pItem ) )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pItem->item.asHash.value );

      /* Check this hash table only if it was not checked yet */
      if( pAlloc->used == s_uUsedFlag )
      {
         /* mark this block as used so it will be no re-checked from
          * other references
          */
         pAlloc->used ^= HB_GC_USED_FLAG;

         /* mark also all hash elements */
         hb_hashRefGrabage( pItem );
      }
   }
   else if( HB_IS_BLOCK( pItem ) )
   {
      HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pItem->item.asBlock.value );

      if( pAlloc->used == s_uUsedFlag )
      {
         HB_CODEBLOCK_PTR pCBlock = pItem->item.asBlock.value;
         USHORT ui = 1;

         pAlloc->used ^= HB_GC_USED_FLAG;  /* mark this codeblock as used */

         /* mark as used all detached variables in a codeblock */
         while( ui <= pCBlock->uiLocals )
         {
            hb_gcItemRef( &pCBlock->pLocals[ ui++ ] );
         }
      }
   }
   else if( HB_IS_POINTER( pItem ) )
   {
      if( pItem->item.asPointer.collect )
      {
         HB_GARBAGE_PTR pAlloc = HB_GC_PTR( pItem->item.asPointer.value );

         if( pAlloc->used == s_uUsedFlag )
         {
            if( ! (pAlloc->flags & HB_GC_USERSWEEP) )
            {
               /* Mark this pointer as used only if it doesn't have
                  registerd his own sweeper function that checks if
                  this pointer is still used.
                  The sweeper function will be called elsewhere.
               */
               pAlloc->used ^= HB_GC_USED_FLAG;  /* mark this codeblock as used */
            }
         }
      }
   }
   /* all other data types don't need the GC */
}
garbage.c490
VOIDhb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo )
void hb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo )
{
   HB_GARBAGE_EXTERN_PTR pExt;

   pExt = ( HB_GARBAGE_EXTERN_PTR ) hb_xgrab( sizeof( HB_GARBAGE_EXTERN ) );
   pExt->pFunc = pSweep;
   pExt->pBlock = Cargo;

   HB_GC_LOCK
   pExt->pNext = s_pSweepExtern;
   s_pSweepExtern = pExt;
   HB_GC_UNLOCK

   /* set user sweep flag */
   HB_GC_PTR( Cargo )->flags ^= HB_GC_USERSWEEP;
}
garbage.c604
STATIC VOIDhb_gcUnregisterSweep( void * Cargo )
static void hb_gcUnregisterSweep( void * Cargo )
{
   HB_GARBAGE_EXTERN_PTR pExt;
   HB_GARBAGE_EXTERN_PTR pPrev;

   HB_GC_LOCK

   pPrev = pExt = s_pSweepExtern;
   while( pExt )
   {
      if( pExt->pBlock == Cargo )
      {
         HB_GARBAGE_PTR pAlloc = HB_GC_PTR( Cargo );

         /* clear user sweep flag */
         pAlloc->flags &= ~ HB_GC_USERSWEEP;

         if( pExt == s_pSweepExtern )
         {
            s_pSweepExtern = pExt->pNext;
         }
         else
         {
            pPrev->pNext = pExt->pNext;
         }

         hb_xfree( (void *) pExt );
         pExt = NULL;
      }
      else
      {
         pPrev = pExt;
         pExt = pExt->pNext;
      }
   }

   HB_GC_UNLOCK
}
garbage.c627
VOIDhb_gcCollect( void )
void hb_gcCollect( void )
{
   /* TODO: decrease the amount of time spend collecting */
   hb_gcCollectAll( FALSE );
}
garbage.c666
VOIDhb_gcCollectAll( BOOL fForce )
void hb_gcCollectAll( BOOL fForce )
{
   /* MTNOTE: it's not necessary to protect s_bCollecting with mutex
    *         because it can be changed at RT only inside this procedure
    *         when all other threads are stoped by hb_vmSuspendThreads(),
    *         [druzus]
    */
   if( !s_bCollecting && hb_vmSuspendThreads( fForce ) )
   {
      HB_GARBAGE_PTR pAlloc, pDelete;

      if( !s_pCurrBlock )
      {
         hb_vmResumeThreads();
         return;
      }

      s_bCollecting = TRUE;

      /* Step 1 - mark */
      /* All blocks are already marked because we are flipping
       * the used/unused flag
       */

      /* Step 2 - sweep */
      /* check all known places for blocks they are referring */
      hb_vmIsStackRef();
      hb_vmIsStaticRef();
      hb_clsIsClassRef();

      if( s_pSweepExtern )
      {
         HB_GARBAGE_EXTERN_PTR *pExtPtr = &s_pSweepExtern;

         do
         {
            pAlloc = HB_GC_PTR( ( *pExtPtr )->pBlock );

            if( ( ( *pExtPtr )->pFunc )( ( *pExtPtr )->pBlock ) )
            {
               /* block is still used */
               pAlloc->used ^= HB_GC_USED_FLAG;
               pExtPtr = &( *pExtPtr )->pNext;
            }
            else
            {
               HB_GARBAGE_EXTERN_PTR pFree = *pExtPtr;

               pAlloc->flags &= ~ HB_GC_USERSWEEP;
               *pExtPtr = ( *pExtPtr )->pNext;
               hb_xfree( pFree );
            }
         }
         while( *pExtPtr );
      }

      /* check list of locked block for blocks referenced from
       * locked block
       */
      if( s_pLockedBlock )
      {
         pAlloc = s_pLockedBlock;
         do
         {  /* it is not very elegant method but it works well */
            if( pAlloc->pFunc == hb_gcGripRelease )
            {
               hb_gcItemRef( ( HB_ITEM_PTR ) HB_MEM_PTR( pAlloc ) );
            }
            pAlloc = pAlloc->pNext;
         } while( s_pLockedBlock != pAlloc );
      }

      /* Step 3 - finalize */
      /* Release all blocks that are still marked as unused */

      /*
       * infinite loop can appear when we are executing clean-up functions
       * scanning s_pCurrBlock. It's possible that one of them will free
       * the GC block which we are using as stop condition. Only blocks
       * for which we set HB_GC_DELETE flag are guarded against releasing.
       * To avoid such situation first we are moving blocks which will be
       * deleted to separate list. It's additional operation but it can
       * even increase the speed when we are deleting only few percent
       * of all allocated blocks because in next passes we will scan only
       * deleted block list. [druzus]
       */

      pAlloc = NULL; /* for stop condition */
      do
      {
         if( s_pCurrBlock->used == s_uUsedFlag )
         {
            pDelete = s_pCurrBlock;
            s_pCurrBlock->used |= HB_GC_DELETE | HB_GC_DELETELST;
            hb_gcUnlink( &s_pCurrBlock, s_pCurrBlock );
            hb_gcLink( &s_pDeletedBlock, pDelete );
         }
         else
         {
            /* at least one block will not be deleted, set new stop condition */
            if( ! pAlloc )
               pAlloc = s_pCurrBlock;
            s_pCurrBlock = s_pCurrBlock->pNext;
         }

      } while( pAlloc != s_pCurrBlock );

      /* do we have any deleted blocks? */
      if( s_pDeletedBlock )
      {
         /* call a cleanup function */
         pAlloc = s_pDeletedBlock;
         do
         {
            if( s_pDeletedBlock->pFunc )
               ( s_pDeletedBlock->pFunc )( HB_MEM_PTR( s_pDeletedBlock ) );

            s_pDeletedBlock = s_pDeletedBlock->pNext;

         } while( pAlloc != s_pDeletedBlock );

         /* release all deleted blocks */
         do
         {
            pDelete = s_pDeletedBlock;
            hb_gcUnlink( &s_pDeletedBlock, s_pDeletedBlock );
            if( hb_xRefCount( pDelete ) != 0 )
            {
               hb_gcLink( &s_pCurrBlock, pAlloc );
               pAlloc->used = s_uUsedFlag;
               pAlloc->locked = 0;

               if( hb_vmRequestQuery() == 0 )
                  hb_errRT_BASE( EG_DESTRUCTOR, 1301, NULL, "Reference to freed block", 0 );
            }
            else
               HB_GARBAGE_FREE( pDelete );

         } while( s_pDeletedBlock );
      }

      /* Step 4 - flip flag */
      /* Reverse used/unused flag so we don't have to mark all blocks
       * during next collecting
       */
      s_uUsedFlag ^= HB_GC_USED_FLAG;

      s_bCollecting = FALSE;
      hb_vmResumeThreads();
   }
}
garbage.c672
VOIDhb_gcReleaseAll( void )
void hb_gcReleaseAll( void )
{
   if( s_pCurrBlock )
   {
      HB_GARBAGE_PTR pAlloc, pDelete;

      s_bCollecting = TRUE;

      pAlloc = s_pCurrBlock;
      do
      {
         /* call a cleanup function */
         if( s_pCurrBlock->pFunc )
         {
            HB_TRACE( HB_TR_INFO, ( "Cleanup, %p", s_pCurrBlock ) );

            s_pCurrBlock->used |= HB_GC_DELETE | HB_GC_DELETELST;
            ( s_pCurrBlock->pFunc )( HB_MEM_PTR( s_pCurrBlock ) );
         }

         s_pCurrBlock = s_pCurrBlock->pNext;

      } while ( s_pCurrBlock && pAlloc != s_pCurrBlock );

      do
      {
         HB_TRACE( HB_TR_INFO, ( "Release %p", s_pCurrBlock ) );
         pDelete = s_pCurrBlock;
         hb_gcUnlink( &s_pCurrBlock, s_pCurrBlock );
         HB_GARBAGE_FREE( pDelete );

      } while ( s_pCurrBlock );
   }

   s_bCollecting = FALSE;
}
garbage.c826
HB_FUNCHB_GCSTEP(void)
HB_FUNC( HB_GCSTEP )
{
   hb_gcCollect();
}
garbage.c867
HB_FUNCHB_GCALL(void)
HB_FUNC( HB_GCALL )
{
   /* call hb_ret() to clear stack return item, HVM does not clean
    * it before calling functions/procedures if caller does not
    * try to retrieve returned value. It's safe and cost nearly
    * nothing in whole GC scan process. It may help when previously
    * called function returned complex item with cross references.
    * It's quite common situation that people executes HB_GCALL()
    * immediately after such function. [druzus]
    */
   hb_ret();

   hb_gcCollectAll( hb_pcount() < 1 || hb_parl( 1 ) );
}
garbage.c875
hashes.c
TypeFunctionSourceLine
VOIDhb_hashRefGrabage( PHB_ITEM pHash )
void hb_hashRefGrabage( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashRefGrabage(%p)", pHash));

   if( HB_IS_HASH( pHash ) && pHash->item.asHash.value->ulLen > 0 )
   {
      PHB_HASHPAIR pPairs = pHash->item.asHash.value->pPairs;
      ULONG ulLen = pHash->item.asHash.value->ulLen;

      while( ulLen-- )
      {
         if( HB_IS_GCITEM( &pPairs[ ulLen ].key ) )
            hb_gcItemRef( &pPairs[ ulLen ].key );
         if( HB_IS_GCITEM( &pPairs[ ulLen ].value ) )
            hb_gcItemRef( &pPairs[ ulLen ].value );
      }
   }
}
hashes.c83
STATIC HB_GARBAGE_FUNC(hb_hashReleaseGarbage )
static HB_GARBAGE_FUNC( hb_hashReleaseGarbage )
{
   PHB_BASEHASH pBaseHash = ( PHB_BASEHASH ) Cargo;

   HB_TRACE(HB_TR_INFO, ("hb_hashReleaseGarbage(%p)", pBaseHash ));

   if( pBaseHash->ulSize > 0 )
   {
      PHB_HASHPAIR pPairs = pBaseHash->pPairs;
      ULONG ulLen = pBaseHash->ulLen;

      /*
       * clear the pBaseHash->pPairs to avoid infinite loop in cross
       * referenced items when pBaseArray is not freed due to buggy
       * object destructor [druzus]
       */
      pBaseHash->pPairs = NULL;
      pBaseHash->ulLen  = 0;

      while( ulLen-- )
      {
         if( HB_IS_COMPLEX( &pPairs[ ulLen ].key ) )
            hb_itemClear( &pPairs[ ulLen ].key );
         if( HB_IS_COMPLEX( &pPairs[ ulLen ].value ) )
            hb_itemClear( &pPairs[ ulLen ].value );
      }
      hb_xfree( pPairs );
   }
   if( pBaseHash->pDefault )
   {
      PHB_ITEM pDefault = pBaseHash->pDefault;
      pBaseHash->pDefault = NULL;
      hb_itemRelease( pDefault );
   }
}
hashes.c102
STATIC INThb_hashItemCmp( PHB_ITEM pKey1, PHB_ITEM pKey2, BOOL fIgnoreCase )
static int hb_hashItemCmp( PHB_ITEM pKey1, PHB_ITEM pKey2, BOOL fIgnoreCase )
{
   if( HB_IS_STRING( pKey1 ) )
   {
      if( HB_IS_STRING( pKey2 ) )
      {
         if( fIgnoreCase )
            return hb_itemStrICmp( pKey1, pKey2, TRUE );
         else
            return hb_itemStrCmp( pKey1, pKey2, TRUE );
      }
      else
         return 1;
   }
   else if( HB_IS_DATE( pKey1 ) )
   {
      if( HB_IS_DATE( pKey2 ) )
         return pKey1->item.asDate.value < pKey2->item.asDate.value ? -1 :
              ( pKey1->item.asDate.value > pKey2->item.asDate.value ? 1 : 0 );
      else if( HB_IS_STRING( pKey2 ) )
         return -1;
      else
         return 1;
   }
   else if( HB_IS_POINTER( pKey1 ) )
   {
      if( HB_IS_POINTER( pKey2 ) )
         return pKey1->item.asPointer.value < pKey2->item.asPointer.value ? -1 :
              ( pKey1->item.asPointer.value > pKey2->item.asPointer.value ? 1 : 0 );
      else if( HB_IS_STRING( pKey2 ) || HB_IS_DATE( pKey2 ) )
         return -1;
      else
         return 1;
   }
   else if( HB_IS_NUMINT( pKey1 ) && HB_IS_NUMINT( pKey2 ) )
   {
      HB_LONG l1 = HB_ITEM_GET_NUMINTRAW( pKey1 ),
              l2 = HB_ITEM_GET_NUMINTRAW( pKey2 );
      return l1 < l2 ? -1 : ( l1 > l2 ? 1 : 0 );
   }
   else if( HB_IS_NUMERIC( pKey2 ) )
   {
      double d1 = hb_itemGetND( pKey1 ), d2 = hb_itemGetND( pKey2 );
      return d1 < d2 ? -1 : ( d1 > d2 ? 1 : 0 );
   }
   return -1;
}
hashes.c139
STATIC BOOLhb_hashFind( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, ULONG * pulPos )
static BOOL hb_hashFind( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, ULONG * pulPos )
{
   ULONG ulLeft = 0, ulRight = pBaseHash->ulLen, ulMiddle;
   BOOL fIgnoreCase = ( pBaseHash->iFlags & HB_HASH_IGNORECASE ) != 0;
   int i;

   while( ulLeft < ulRight )
   {
      ulMiddle = ( ulLeft + ulRight ) >> 1;
      i = hb_hashItemCmp( &pBaseHash->pPairs[ ulMiddle ].key, pKey, fIgnoreCase );
      if( i == 0 )
      {
         if( pulPos )
            *pulPos = ulMiddle;
         return TRUE;
      }
      else if( i < 0 )
         ulLeft = ulMiddle + 1;
      else
         ulRight = ulMiddle;
   }

   if( pulPos )
      *pulPos = ulLeft;
   return FALSE;
}
hashes.c187
STATIC VOIDhb_hashResize( PHB_BASEHASH pBaseHash, ULONG ulNewSize )
static void hb_hashResize( PHB_BASEHASH pBaseHash, ULONG ulNewSize )
{
   if( pBaseHash->ulSize < ulNewSize )
   {
      if( pBaseHash->ulSize )
         pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xrealloc( pBaseHash->pPairs,
                                          ulNewSize * sizeof( HB_HASHPAIR ) );
      else
         pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xgrab( ulNewSize * sizeof( HB_HASHPAIR ) );

      do
      {
         pBaseHash->pPairs[ pBaseHash->ulSize ].key.type = HB_IT_NIL;
         pBaseHash->pPairs[ pBaseHash->ulSize ].value.type = HB_IT_NIL;
      }
      while( ++pBaseHash->ulSize < ulNewSize );
   }
   else if( pBaseHash->ulSize > ulNewSize && pBaseHash->ulLen <= ulNewSize )
   {
      pBaseHash->ulSize = ulNewSize;
      if( ulNewSize )
         pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xrealloc( pBaseHash->pPairs,
                                          ulNewSize * sizeof( HB_HASHPAIR ) );
      else
      {
         hb_xfree( pBaseHash->pPairs );
         pBaseHash->pPairs = NULL;
      }
   }
}
hashes.c214
STATIC PHB_ITEMhb_hashValuePtr( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, BOOL fAdd )
static PHB_ITEM hb_hashValuePtr( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, BOOL fAdd )
{
   ULONG ulPos;

   if( !hb_hashFind( pBaseHash, pKey, &ulPos ) )
   {
      if( !fAdd )
         return NULL;

      if( pBaseHash->ulSize == pBaseHash->ulLen )
         hb_hashResize( pBaseHash, pBaseHash->ulSize + HB_HASH_ITEM_ALLOC );

      if( ulPos < pBaseHash->ulLen )
      {
         memmove( pBaseHash->pPairs + ulPos + 1, pBaseHash->pPairs + ulPos,
                  ( pBaseHash->ulLen - ulPos ) * sizeof( HB_HASHPAIR ) );
         pBaseHash->pPairs[ ulPos ].key.type = HB_IT_NIL;
         pBaseHash->pPairs[ ulPos ].value.type = HB_IT_NIL;
      }
      hb_itemCopy( &pBaseHash->pPairs[ ulPos ].key, pKey );
      pBaseHash->ulLen++;
      if( pBaseHash->pDefault )
      {
         PHB_ITEM pDefault = hb_itemClone( pBaseHash->pDefault );
         hb_itemMove( &pBaseHash->pPairs[ ulPos ].value, pDefault );
         hb_itemRelease( pDefault );
      }
   }

   return &pBaseHash->pPairs[ ulPos ].value;
}
hashes.c245
STATIC BOOLhb_hashNewValue( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, PHB_ITEM pValue )
static BOOL hb_hashNewValue( PHB_BASEHASH pBaseHash, PHB_ITEM pKey, PHB_ITEM pValue )
{
   ULONG ulPos;

   if( !hb_hashFind( pBaseHash, pKey, &ulPos ) )
   {
      if( pBaseHash->ulSize == pBaseHash->ulLen )
         hb_hashResize( pBaseHash, pBaseHash->ulSize + HB_HASH_ITEM_ALLOC );

      if( ulPos < pBaseHash->ulLen )
      {
         memmove( pBaseHash->pPairs + ulPos + 1, pBaseHash->pPairs + ulPos,
                  ( pBaseHash->ulLen - ulPos ) * sizeof( HB_HASHPAIR ) );
         pBaseHash->pPairs[ ulPos ].key.type = HB_IT_NIL;
         pBaseHash->pPairs[ ulPos ].value.type = HB_IT_NIL;
      }

      hb_itemCopy( &pBaseHash->pPairs[ ulPos ].key, pKey );
      hb_itemCopyFromRef( &pBaseHash->pPairs[ ulPos ].value, pValue );
      pBaseHash->ulLen++;

      return TRUE;
   }

   return FALSE;
}
hashes.c277
STATIC VOIDhb_hashDelPair( PHB_BASEHASH pBaseHash, ULONG ulPos )
static void hb_hashDelPair( PHB_BASEHASH pBaseHash, ULONG ulPos )
{
   if( --pBaseHash->ulLen == 0 )
   {
      PHB_HASHPAIR pPairs = pBaseHash->pPairs;
      pBaseHash->pPairs = NULL;
      pBaseHash->ulSize = 0;
      if( HB_IS_COMPLEX( &pPairs->key ) )
         hb_itemClear( &pPairs->key );
      if( HB_IS_COMPLEX( &pPairs->value ) )
         hb_itemClear( &pPairs->value );
      hb_xfree( pPairs );
   }
   else if( ulPos == pBaseHash->ulLen )
   {
      hb_itemSetNil( &pBaseHash->pPairs[ ulPos ].key );
      hb_itemSetNil( &pBaseHash->pPairs[ ulPos ].value );
   }
   else
   {
      HB_HASHPAIR pair;
      memcpy( &pair, pBaseHash->pPairs + ulPos, sizeof( HB_HASHPAIR ) );
      memmove( pBaseHash->pPairs + ulPos, pBaseHash->pPairs + ulPos + 1,
               ( pBaseHash->ulLen - ulPos ) * sizeof( HB_HASHPAIR ) );
      pBaseHash->pPairs[ pBaseHash->ulLen ].key.type = HB_IT_NIL;
      pBaseHash->pPairs[ pBaseHash->ulLen ].value.type = HB_IT_NIL;
      if( HB_IS_COMPLEX( &pair.key ) )
         hb_itemClear( &pair.key );
      if( HB_IS_COMPLEX( &pair.value ) )
         hb_itemClear( &pair.value );
      if( pBaseHash->ulSize - pBaseHash->ulLen > ( HB_HASH_ITEM_ALLOC << 1 ) )
      {
         pBaseHash->ulSize -= HB_HASH_ITEM_ALLOC;
         pBaseHash->pPairs = ( PHB_HASHPAIR ) hb_xrealloc( pBaseHash->pPairs,
                              pBaseHash->ulSize * sizeof( HB_HASHPAIR ) );
      }
   }
}
hashes.c304
HB_EXPORT PHB_ITEMhb_hashNew( PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_hashNew( PHB_ITEM pItem )
{
   PHB_BASEHASH pBaseHash;

   HB_TRACE(HB_TR_DEBUG, ("hb_hashNew(%p)", pItem));

   if( pItem == NULL )
      pItem = hb_itemNew( NULL );
   else if( HB_IS_COMPLEX( pItem ) )
      hb_itemClear( pItem );

   pBaseHash = ( PHB_BASEHASH ) hb_gcAlloc( sizeof( HB_BASEHASH ), hb_hashReleaseGarbage );
   pBaseHash->pPairs   = NULL;
   pBaseHash->ulSize   = 0;
   pBaseHash->ulLen    = 0;
   pBaseHash->iFlags   = HB_HASH_AUTOADD_ASSIGN;
   pBaseHash->pDefault = NULL;

   pItem->type = HB_IT_HASH;
   pItem->item.asHash.value = pBaseHash;

   return pItem;
}
hashes.c343
HB_EXPORT ULONGhb_hashLen( PHB_ITEM pHash )
HB_EXPORT ULONG hb_hashLen( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashLen(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
      return pHash->item.asHash.value->ulLen;
   else
      return 0;
}
hashes.c367
HB_EXPORT VOIDhb_hashPreallocate( PHB_ITEM pHash, ULONG ulNewSize )
HB_EXPORT void hb_hashPreallocate( PHB_ITEM pHash, ULONG ulNewSize )
{
   if( HB_IS_HASH( pHash ) )
      hb_hashResize( pHash->item.asHash.value, ulNewSize );
}
hashes.c377
HB_EXPORT PHB_ITEMhb_hashGetItemPtr( PHB_ITEM pHash, PHB_ITEM pKey, int iFlags )
HB_EXPORT PHB_ITEM hb_hashGetItemPtr( PHB_ITEM pHash, PHB_ITEM pKey, int iFlags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetItemPtr(%p,%p,%d)", pHash, pKey, iFlags));

   if( HB_IS_HASH( pHash ) && HB_IS_HASHKEY( pKey ) )
   {
      PHB_ITEM pDest = hb_hashValuePtr( pHash->item.asHash.value, pKey,
         iFlags && ( pHash->item.asHash.value->iFlags & iFlags ) == iFlags );
      if( pDest )
         return HB_IS_BYREF( pDest ) ? hb_itemUnRef( pDest ) : pDest;
   }

   return NULL;
}
hashes.c383
HB_EXPORT PHB_ITEMhb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey )
HB_EXPORT PHB_ITEM hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetItemRefPtr(%p,%p)", pHash, pKey));

   if( HB_IS_HASH( pHash ) && HB_IS_HASHKEY( pKey ) )
   {
      PHB_ITEM pDest = hb_hashValuePtr( pHash->item.asHash.value, pKey,
            ( pHash->item.asHash.value->iFlags & HB_HASH_AUTOADD_REFERENCE ) ==
            HB_HASH_AUTOADD_REFERENCE );
      if( pDest )
      {
         if( !HB_IS_BYREF( pDest ) )
            pDest = hb_memvarDetachLocal( pDest );
         return pDest;
      }
   }

   return NULL;
}
hashes.c398
HB_EXPORT BOOLhb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, ULONG * pulPos )
HB_EXPORT BOOL hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, ULONG * pulPos )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashScan(%p,%p,%p)", pHash, pKey, pulPos));

   if( HB_IS_HASH( pHash ) )
   {
      ULONG ulPos;
      if( HB_IS_HASHKEY( pKey ) )
      {
         if( hb_hashFind( pHash->item.asHash.value, pKey, &ulPos ) )
         {
            if( pulPos )
               *pulPos = ulPos + 1;
            return TRUE;
         }
      }
      else if( HB_IS_HASH( pKey ) && pKey->item.asHash.value->ulLen == 1 )
      {
         if( hb_hashFind( pHash->item.asHash.value, &pKey->item.asHash.value->pPairs[ 0 ].key, &ulPos ) )
         {
            PHB_ITEM pVal1 = &pHash->item.asHash.value->pPairs[ ulPos ].value;
            PHB_ITEM pVal2 = &pKey->item.asHash.value->pPairs[ 0 ].value;
            BOOL fResult = FALSE;
            if( HB_IS_STRING( pVal1 ) && HB_IS_STRING( pVal2 ) )
               fResult = hb_itemStrCmp( pVal1, pVal2, TRUE ) == 0;
            else if( HB_IS_NUMINT( pVal1 ) && HB_IS_NUMINT( pVal2 ) )
               fResult = HB_ITEM_GET_NUMINTRAW( pVal1 ) == HB_ITEM_GET_NUMINTRAW( pVal2 );
            else if( HB_IS_NUMERIC( pVal1 ) && HB_IS_NUMERIC( pVal2 ) )
               fResult = hb_itemGetND( pVal1 ) == hb_itemGetND( pVal2 );
            else if( HB_IS_NIL( pVal1 ) && HB_IS_NIL( pVal2 ) )
               fResult = TRUE;
            else if( hb_itemType( pVal1 ) & hb_itemType( pVal2 ) )
            {
               hb_vmPush( pVal1 );
               hb_vmPush( pVal2 );
               if( !hb_xvmExactlyEqual() )
               {
                  fResult = hb_itemGetL( hb_stackItemFromTop( -1 ) );
                  hb_stackPop();
               }
            }
            if( fResult )
            {
               if( pulPos )
                  *pulPos = ulPos + 1;
               return TRUE;
            }
         }
      }
   }
   if( pulPos )
      *pulPos = 0;
   return FALSE;
}
hashes.c418
HB_EXPORT BOOLhb_hashClear( PHB_ITEM pHash )
HB_EXPORT BOOL hb_hashClear( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashClear(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
   {
      if( pHash->item.asHash.value->ulSize )
      {
         while( pHash->item.asHash.value->ulLen )
         {
            pHash->item.asHash.value->ulLen--;
            if( HB_IS_COMPLEX( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].key ) )
               hb_itemClear( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].key );
            if( HB_IS_COMPLEX( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].value ) )
               hb_itemClear( &pHash->item.asHash.value->pPairs[ pHash->item.asHash.value->ulLen ].value );
         }
         /*
          * This condition is a protection against recursive call
          * from .prg object destructor [druzus]
          */
         if( pHash->item.asHash.value->ulSize )
         {
            hb_xfree( pHash->item.asHash.value->pPairs );
            pHash->item.asHash.value->pPairs = NULL;
            pHash->item.asHash.value->ulSize = 0;
         }
      }
      return TRUE;
   }

   return FALSE;
}
hashes.c473
HB_EXPORT BOOLhb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey )
HB_EXPORT BOOL hb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashDel(%p,%p)", pHash, pKey));

   if( HB_IS_HASH( pHash ) && HB_IS_HASHKEY( pKey ) )
   {
      PHB_BASEHASH pBaseHash = pHash->item.asHash.value;
      ULONG ulPos;

      if( hb_hashFind( pBaseHash, pKey, &ulPos ) )
      {
         hb_hashDelPair( pBaseHash, ulPos );
         return TRUE;
      }
   }

   return FALSE;
}
hashes.c506
HB_EXPORT BOOLhb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem )
HB_EXPORT BOOL hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashRemove(%p,%p)", pHash, pItem));

   if( HB_IS_HASH( pHash ) )
   {
      if( HB_IS_HASHKEY( pItem ) )
      {
         hb_hashDel( pHash, pItem );
         return TRUE;
      }
      else if( HB_IS_ARRAY( pItem ) )
      {
         ULONG ul = 0;
         PHB_ITEM pKey;
         while( ( pKey = hb_arrayGetItemPtr( pItem, ++ul ) ) != NULL )
            hb_hashDel( pHash, pKey );
         return TRUE;
      }
      else if( HB_IS_HASH( pItem ) )
      {
         if( pHash->item.asHash.value == pItem->item.asHash.value )
            hb_hashClear( pHash );
         else
         {
            ULONG ulLen = 0;
            while( ulLen < pItem->item.asHash.value->ulLen )
               hb_hashDel( pHash, &pItem->item.asHash.value->pPairs[ ulLen++ ].key );
         }
         return TRUE;
      }
   }
   return FALSE;
}
hashes.c525
HB_EXPORT BOOLhb_hashAdd( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue )
HB_EXPORT BOOL hb_hashAdd( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashAdd(%p,%p,%p)", pHash, pKey, pValue));

   if( HB_IS_HASH( pHash ) && HB_IS_HASHKEY( pKey ) )
   {
      PHB_ITEM pDest = hb_hashValuePtr( pHash->item.asHash.value, pKey, TRUE );
      if( pDest )
      {
         if( HB_IS_BYREF( pDest ) )
            pDest = hb_itemUnRef( pDest );
         if( pValue )
            hb_itemCopyFromRef( pDest, pValue );
         else
            hb_itemSetNil( pDest );
         return TRUE;
      }
   }

   return FALSE;
}
hashes.c560
HB_EXPORT BOOLhb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue )
HB_EXPORT BOOL hb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashAddNew(%p,%p,%p)", pHash, pKey, pValue));

   if( HB_IS_HASH( pHash ) && HB_IS_HASHKEY( pKey ) )
      return hb_hashNewValue( pHash->item.asHash.value, pKey, pValue );
   else
      return FALSE;
}
hashes.c582
HB_EXPORT PHB_ITEMhb_hashGetKeyAt( PHB_ITEM pHash, ULONG ulPos )
HB_EXPORT PHB_ITEM hb_hashGetKeyAt( PHB_ITEM pHash, ULONG ulPos )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetKeyAt(%p,%lu)", pHash, ulPos));

   if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen )
      return &pHash->item.asHash.value->pPairs[ ulPos - 1 ].key;
   else
      return NULL;
}
hashes.c592
HB_EXPORT PHB_ITEMhb_hashGetValueAt( PHB_ITEM pHash, ULONG ulPos )
HB_EXPORT PHB_ITEM hb_hashGetValueAt( PHB_ITEM pHash, ULONG ulPos )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetValueAt(%p,%lu)", pHash, ulPos));

   if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen )
      return HB_IS_BYREF( &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value ) ?
             hb_itemUnRef( &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value ) :
             &pHash->item.asHash.value->pPairs[ ulPos - 1 ].value;
   else
      return NULL;
}
hashes.c602
HB_EXPORT BOOLhb_hashDelAt( PHB_ITEM pHash, ULONG ulPos )
HB_EXPORT BOOL hb_hashDelAt( PHB_ITEM pHash, ULONG ulPos )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashDelAt(%p,%lu)", pHash, ulPos));

   if( HB_IS_HASH( pHash ) && ulPos > 0 && ulPos <= pHash->item.asHash.value->ulLen )
   {
      hb_hashDelPair( pHash->item.asHash.value, ulPos - 1 );
      return TRUE;
   }
   else
      return FALSE;
}
hashes.c614
HB_EXPORT VOID *hb_hashId( PHB_ITEM pHash )
HB_EXPORT void * hb_hashId( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashId(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
      return ( void * ) pHash->item.asHash.value;
   else
      return NULL;
}
hashes.c627
VOIDhb_hashCloneBody( PHB_ITEM pHash, PHB_ITEM pDest, PHB_NESTED_CLONED pClonedList )
void hb_hashCloneBody( PHB_ITEM pHash, PHB_ITEM pDest, PHB_NESTED_CLONED pClonedList )
{
   ULONG ulPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_hashCloneBody(%p,%p,%p)", pHash, pDest, pClonedList));

   hb_hashNew( pDest );
   hb_hashResize( pDest->item.asHash.value, pHash->item.asHash.value->ulSize );
   pDest->item.asHash.value->iFlags = pHash->item.asHash.value->iFlags;
   if( pHash->item.asHash.value->pDefault )
      pDest->item.asHash.value->pDefault =
                              hb_itemNew( pHash->item.asHash.value->pDefault );
   for( ulPos = 0; ulPos < pHash->item.asHash.value->ulLen; ++ulPos )
   {
      PHB_ITEM pValue = &pHash->item.asHash.value->pPairs[ ulPos ].value;
      if( HB_IS_BYREF( pValue ) )
         pValue = hb_itemUnRef( pValue );
      hb_itemCopy( &pDest->item.asHash.value->pPairs[ ulPos ].key,
                   &pHash->item.asHash.value->pPairs[ ulPos ].key );
      pDest->item.asHash.value->ulLen++;
      hb_cloneNested( &pDest->item.asHash.value->pPairs[ ulPos ].value, pValue, pClonedList );
   }
}
hashes.c638
HB_EXPORT PHB_ITEMhb_hashClone( PHB_ITEM pHash )
HB_EXPORT PHB_ITEM hb_hashClone( PHB_ITEM pHash )
{
   PHB_ITEM pDest;

   HB_TRACE(HB_TR_DEBUG, ("hb_hashClone(%p)", pHash));

   pDest = hb_itemNew( NULL );
   if( HB_IS_HASH( pHash ) )
   {
      PHB_NESTED_CLONED pClonedList, pCloned;

      pClonedList = ( PHB_NESTED_CLONED ) hb_xgrab( sizeof( HB_NESTED_CLONED ) );
      pClonedList->value = ( void * ) pHash->item.asHash.value;
      pClonedList->pDest = pDest;
      pClonedList->pNext = NULL;

      hb_hashCloneBody( pHash, pDest, pClonedList );

      do
      {
         pCloned = pClonedList;
         pClonedList = pClonedList->pNext;
         hb_xfree( pCloned );
      }
      while( pClonedList );
   }

   return pDest;
}
hashes.c662
HB_EXPORT VOIDhb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType )
HB_EXPORT void hb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashJoin(%p,%p,%d)", pDest, pSource, iType));

   if( HB_IS_HASH( pDest ) && HB_IS_HASH( pSource ) )
   {
      PHB_BASEHASH pBaseHash;
      ULONG ulPos;

      switch( iType )
      {
         case HB_HASH_UNION:        /* OR */
            pBaseHash = pSource->item.asHash.value;
            for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
            {
               PHB_ITEM pVal = &pBaseHash->pPairs[ ulPos ].value;
               if( HB_IS_BYREF( pVal ) )
                  pVal = hb_itemUnRef( pVal );
               hb_hashAdd( pDest, &pBaseHash->pPairs[ ulPos ].key, pVal );
            }
            break;

         case HB_HASH_INTERSECT:    /* AND */
            pBaseHash = pDest->item.asHash.value;
            for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
            {
               if( !hb_hashFind( pSource->item.asHash.value,
                                 &pBaseHash->pPairs[ ulPos ].key, NULL ) )
                  hb_hashDel( pDest, &pBaseHash->pPairs[ ulPos ].key );
            }
            break;

         case HB_HASH_DIFFERENCE:   /* XOR */
            pBaseHash = pSource->item.asHash.value;
            for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
            {
               if( !hb_hashDel( pDest, &pBaseHash->pPairs[ ulPos ].key ) )
               {
                  PHB_ITEM pVal = &pBaseHash->pPairs[ ulPos ].value;
                  if( HB_IS_BYREF( pVal ) )
                     pVal = hb_itemUnRef( pVal );
                  hb_hashAdd( pDest, &pBaseHash->pPairs[ ulPos ].key, pVal );
               }
            }
            break;

         case HB_HASH_REMOVE:       /* NOT -> h1 & ( h1 ^ h2 ) */
            pBaseHash = pSource->item.asHash.value;
            if( pDest->item.asHash.value == pBaseHash )
               hb_hashClear( pDest );
            else
            {
               for( ulPos = 0; ulPos < pBaseHash->ulLen; ++ulPos )
                  hb_hashDel( pDest, &pBaseHash->pPairs[ ulPos ].key );
            }
            break;
      }
   }
}
hashes.c692
HB_EXPORT PHB_ITEMhb_hashGetKeys( PHB_ITEM pHash )
HB_EXPORT PHB_ITEM hb_hashGetKeys( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetKeys(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
   {
      PHB_ITEM pKeys = hb_itemArrayNew( hb_hashLen( pHash ) ), pKey;
      ULONG ulPos = 0;

      while( ( pKey = hb_hashGetKeyAt( pHash, ++ulPos ) ) != NULL )
      {
         PHB_ITEM pDest = hb_arrayGetItemPtr( pKeys, ulPos );
         if( !pDest )
            break;
         hb_itemCopy( pDest, pKey );
      }
      return pKeys;
   }

   return NULL;
}
hashes.c752
HB_EXPORT PHB_ITEMhb_hashGetValues( PHB_ITEM pHash )
HB_EXPORT PHB_ITEM hb_hashGetValues( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetValues(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
   {
      PHB_ITEM pValues = hb_itemArrayNew( hb_hashLen( pHash ) ), pVal;
      ULONG ulPos = 0;

      while( ( pVal = hb_hashGetValueAt( pHash, ++ulPos ) ) != NULL )
      {
         PHB_ITEM pDest = hb_arrayGetItemPtr( pValues, ulPos );
         if( !pDest )
            break;
         hb_itemCopy( pDest, pVal );
      }
      return pValues;
   }

   return NULL;
}
hashes.c774
HB_EXPORT VOIDhb_hashSetDefault( PHB_ITEM pHash, PHB_ITEM pValue )
HB_EXPORT void hb_hashSetDefault( PHB_ITEM pHash, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashSetDefault(%p,%p)", pHash, pValue));

   if( HB_IS_HASH( pHash ) )
   {
      if( pHash->item.asHash.value->pDefault )
      {
         hb_itemRelease( pHash->item.asHash.value->pDefault );
         pHash->item.asHash.value->pDefault = NULL;
      }
      if( pValue && !HB_IS_NIL( pValue ) &&
          ( !HB_IS_HASH( pValue ) || pHash->item.asHash.value !=
                                     pValue->item.asHash.value ) )
         pHash->item.asHash.value->pDefault = hb_itemClone( pValue );
   }
}
hashes.c796
HB_EXPORT PHB_ITEMhb_hashGetDefault( PHB_ITEM pHash )
HB_EXPORT PHB_ITEM hb_hashGetDefault( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetDefault(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
      return pHash->item.asHash.value->pDefault;
   else
      return NULL;
}
hashes.c814
HB_EXPORT VOIDhb_hashSetFlags( PHB_ITEM pHash, int iFlags )
HB_EXPORT void hb_hashSetFlags( PHB_ITEM pHash, int iFlags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashSetFlags(%p,%d)", pHash, iFlags));

   if( HB_IS_HASH( pHash ) )
      pHash->item.asHash.value->iFlags |= iFlags;
}
hashes.c824
HB_EXPORT VOIDhb_hashClearFlags( PHB_ITEM pHash, int iFlags )
HB_EXPORT void hb_hashClearFlags( PHB_ITEM pHash, int iFlags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashClearFlags(%p,%d)", pHash, iFlags));

   if( HB_IS_HASH( pHash ) )
      pHash->item.asHash.value->iFlags &= ~iFlags;
}
hashes.c832
HB_EXPORT INThb_hashGetFlags( PHB_ITEM pHash )
HB_EXPORT int hb_hashGetFlags( PHB_ITEM pHash )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hashGetFlags(%p)", pHash));

   if( HB_IS_HASH( pHash ) )
      return pHash->item.asHash.value->iFlags;
   else
      return 0;
}
hashes.c840
hashfunc.c
TypeFunctionSourceLine
HB_FUNCHB_HASH(void)
HB_FUNC( HB_HASH )
{
   int iPCount = hb_pcount(), iParam;

   if( iPCount & 1 )
      hb_errRT_BASE( EG_BOUND, 1131, NULL, hb_langDGetErrorDesc( EG_ARRDIMENSION ), HB_ERR_ARGS_BASEPARAMS );
   else
   {
      PHB_ITEM pHash = hb_hashNew( NULL );
      for( iParam = 1; iParam <= iPCount; iParam += 2 )
      {
         PHB_ITEM pKey = hb_param( iParam, HB_IT_HASHKEY );
         PHB_ITEM pValue = hb_param( iParam + 1, HB_IT_ANY );
         if( pKey )
            hb_hashAdd( pHash, pKey, pValue );
         else
         {
            hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 3, pHash, hb_param( iParam, HB_IT_ANY ), pValue );
            break;
         }
      }
      hb_itemReturnRelease( pHash );
   }
}
hashfunc.c61
HB_FUNCHB_HHASKEY(void)
HB_FUNC( HB_HHASKEY )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pKey = hb_param( 2, HB_IT_HASHKEY );

   if( pHash && pKey )
      hb_retl( hb_hashScan( pHash, pKey, NULL ) );
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c86
HB_FUNCHB_HPOS(void)
HB_FUNC( HB_HPOS )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pKey = hb_param( 2, HB_IT_HASHKEY );

   if( pHash && pKey )
   {
      ULONG ulPos;
      hb_hashScan( pHash, pKey, &ulPos );
      hb_retnint( ulPos );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c97
HB_FUNCHB_HGET(void)
HB_FUNC( HB_HGET )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pKey = hb_param( 2, HB_IT_HASHKEY );

   if( pHash && pKey )
   {
      PHB_ITEM pDest = hb_hashGetItemPtr( pHash, pKey, HB_HASH_AUTOADD_ACCESS );
      if( pDest )
         hb_itemReturn( HB_IS_BYREF( pDest ) ? hb_itemUnRef( pDest ) : pDest );
      else
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pHash, pKey );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c112
HB_FUNCHB_HSET(void)
HB_FUNC( HB_HSET )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pKey = hb_param( 2, HB_IT_HASHKEY );
   PHB_ITEM pValue = hb_param( 3, HB_IT_ANY );

   if( pHash && pKey && pValue )
   {
      hb_hashAdd( pHash, pKey, pValue );
      hb_itemReturn( pHash );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c129
HB_FUNCHB_HDEL(void)
HB_FUNC( HB_HDEL )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pKey = hb_param( 2, HB_IT_HASHKEY );

   if( pHash && pKey )
   {
      if( hb_hashDel( pHash, pKey ) )
         hb_itemReturn( pHash );
      else
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 2, pHash, pKey );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c144
HB_FUNCHB_HKEYAT(void)
HB_FUNC( HB_HKEYAT )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pPos = hb_param( 2, HB_IT_NUMERIC );

   if( pHash && pPos )
   {
      PHB_ITEM pKey = hb_hashGetKeyAt( pHash, hb_itemGetNL( pPos ) );
      if( pKey )
         hb_itemReturn( pKey );
      else
         hb_errRT_BASE( EG_BOUND, 1187, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c160
HB_FUNCHB_HVALUEAT(void)
HB_FUNC( HB_HVALUEAT )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pPos = hb_param( 2, HB_IT_NUMERIC );
   PHB_ITEM pValue = hb_param( 3, HB_IT_ANY );

   if( pHash && pPos )
   {
      PHB_ITEM pItem = hb_hashGetValueAt( pHash, hb_itemGetNL( pPos ) );
      if( pItem )
      {
         if( pValue )
            hb_itemCopy( pItem, pValue );
         else
            pValue = pItem;
         hb_itemReturn( pValue );
      }
      else
         hb_errRT_BASE( EG_BOUND, 1187, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c177
HB_FUNCHB_HPAIRAT(void)
HB_FUNC( HB_HPAIRAT )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pPos = hb_param( 2, HB_IT_NUMERIC );

   if( pHash && pPos )
   {
      PHB_ITEM pKey = hb_hashGetKeyAt( pHash, hb_itemGetNL( pPos ) );
      PHB_ITEM pValue = hb_hashGetValueAt( pHash, hb_itemGetNL( pPos ) );
      if( pKey && pValue )
      {
         PHB_ITEM pDstKey = hb_param( 3, HB_IT_BYREF );
         PHB_ITEM pDstVal = hb_param( 4, HB_IT_BYREF );
         if( pDstKey && pDstVal )
         {
            hb_itemCopy( pDstKey, pKey );
            hb_itemCopy( pDstVal, pValue );
         }
         else
         {
            PHB_ITEM pResult = hb_itemArrayNew( 2 );
            hb_arraySet( pResult, 1, pKey );
            hb_arraySet( pResult, 2, pValue );
            hb_itemReturnRelease( pResult );
         }
      }
      else
         hb_errRT_BASE( EG_BOUND, 1187, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c201
HB_FUNCHB_HDELAT(void)
HB_FUNC( HB_HDELAT )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pPos = hb_param( 2, HB_IT_NUMERIC );

   if( pHash && pPos )
   {
      if( hb_hashDelAt( pHash, hb_itemGetNL( pPos ) ) )
         hb_itemReturn( pHash );
      else
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 2, pHash, pPos );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c234
HB_FUNCHB_HKEYS(void)
HB_FUNC( HB_HKEYS )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );

   if( pHash )
      hb_itemReturnRelease( hb_hashGetKeys( pHash ) );
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c251
HB_FUNCHB_HVALUES(void)
HB_FUNC( HB_HVALUES )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );

   if( pHash )
      hb_itemReturnRelease( hb_hashGetValues( pHash ) );
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c261
HB_FUNCHB_HFILL(void)
HB_FUNC( HB_HFILL )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

   if( pHash && pValue )
   {
      PHB_ITEM pDest;
      ULONG ulPos = 0;

      while( ( pDest = hb_hashGetValueAt( pHash, ++ulPos ) ) != NULL )
         hb_itemCopy( pDest, pValue );

      hb_itemReturn( pHash );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c271
HB_FUNCHB_HCLONE(void)
HB_FUNC( HB_HCLONE )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );

   if( pHash )
      hb_itemReturnRelease( hb_hashClone( pHash ) );
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c290
HB_FUNCHB_HCOPY(void)
HB_FUNC( HB_HCOPY )
{
   PHB_ITEM pSource = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pDest = hb_param( 2, HB_IT_HASH );

   if( pSource && pDest )
   {
      ULONG ulLen = hb_hashLen( pSource ), ulStart, ulCount;

      ulStart = hb_parnl( 3 );
      if( !ulStart )
         ++ulStart;
      ulCount = ISNUM( 4 ) ? ( ULONG ) hb_parnl( 4 ) : ulLen - ulStart + 1;

      while( ulCount-- )
      {
         PHB_ITEM pKey = hb_hashGetKeyAt( pSource, ulStart );
         PHB_ITEM pValue = hb_hashGetValueAt( pSource, ulStart );
         if( pKey && pValue )
            hb_hashAdd( pDest, pKey, pValue );
         else
            break;
         ++ulStart;
      }

      hb_itemReturn( pDest );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c300
HB_FUNCHB_HMERGE(void)
HB_FUNC( HB_HMERGE )
{
   PHB_ITEM pDest = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pSource = hb_param( 2, HB_IT_HASH );
   PHB_ITEM pAction = hb_param( 3, HB_IT_BLOCK | HB_IT_NUMERIC );

   if( pDest && pSource )
   {
      if( pAction && HB_IS_BLOCK( pAction ) )
      {
         ULONG ulLen = hb_hashLen( pSource ), ulPos = 0;
         while( ++ulPos <= ulLen )
         {
            PHB_ITEM pKey = hb_hashGetKeyAt( pSource, ulPos );
            PHB_ITEM pValue = hb_hashGetValueAt( pSource, ulPos );
            if( pKey && pValue )
            {
               hb_vmPushEvalSym();
               hb_vmPush( pAction );
               hb_vmPush( pKey );
               hb_vmPush( pValue );
               hb_vmPushLong( ulPos );
               hb_vmSend( 3 );
               if( HB_IS_LOGICAL( hb_stackReturnItem() ) &&
                   hb_itemGetL( hb_stackReturnItem() ) )
                  hb_hashAdd( pDest, pKey, pValue );
            }
            else
               break;
         }
      }
      else
         hb_hashJoin( pDest, pSource, pAction ? hb_itemGetNI( pAction ) : HB_HASH_UNION );

      hb_itemReturn( pDest );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c331
HB_FUNCHB_HEVAL(void)
HB_FUNC( HB_HEVAL )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pBlock = hb_param( 2, HB_IT_BLOCK );

   if( pHash && pBlock )
   {
      ULONG ulLen = hb_hashLen( pHash ), ulStart, ulCount;

      ulStart = hb_parnl( 3 );
      if( !ulStart )
         ++ulStart;
      ulCount = ISNUM( 4 ) ? ( ULONG ) hb_parnl( 4 ) : ulLen - ulStart + 1;

      while( ulCount-- )
      {
         PHB_ITEM pKey = hb_hashGetKeyAt( pHash, ulStart );
         PHB_ITEM pValue = hb_hashGetValueAt( pHash, ulStart );
         if( pKey && pValue )
         {
            hb_vmPushEvalSym();
            hb_vmPush( pBlock );
            hb_vmPush( pKey );
            hb_vmPush( pValue );
            hb_vmPushLong( ulStart );
            hb_vmSend( 3 );
         }
         else
            break;
         ++ulStart;
      }

      hb_itemReturn( pHash );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c371
HB_FUNCHB_HSCAN(void)
HB_FUNC( HB_HSCAN )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );

   if( pHash && pValue )
   {
      BOOL fExact = hb_parl( 5 ), fFound = FALSE;
      ULONG ulLen = hb_hashLen( pHash ), ulStart, ulCount;

      ulStart = hb_parnl( 3 );
      if( !ulStart )
         ++ulStart;
      ulCount = ISNUM( 4 ) ? ( ULONG ) hb_parnl( 4 ) : ulLen - ulStart + 1;

      if( HB_IS_BLOCK( pValue ) )
      {
         while( ulCount-- )
         {
            PHB_ITEM pKey = hb_hashGetKeyAt( pHash, ulStart );
            PHB_ITEM pVal = hb_hashGetValueAt( pHash, ulStart );
            if( pKey && pValue )
            {
               hb_vmPushEvalSym();
               hb_vmPush( pValue );
               hb_vmPush( pKey );
               hb_vmPush( pVal );
               hb_vmPushLong( ulStart );
               hb_vmSend( 3 );
               if( HB_IS_LOGICAL( hb_stackReturnItem() ) &&
                   hb_itemGetL( hb_stackReturnItem() ) )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( HB_IS_STRING( pValue ) )
      {
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_STRING( pItem ) && hb_itemStrCmp( pItem, pValue, fExact ) == 0 )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( HB_IS_NUMERIC( pValue ) )
      {
         double dValue = hb_itemGetND( pValue );
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_NUMERIC( pItem ) && hb_itemGetND( pItem ) == dValue )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( HB_IS_DATE( pValue ) )
      {
         long lValue = hb_itemGetDL( pValue );
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_DATE( pItem ) && hb_itemGetDL( pItem ) == lValue )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( HB_IS_LOGICAL( pValue ) )
      {
         BOOL fValue = hb_itemGetDL( pValue );
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_LOGICAL( pItem ) && hb_itemGetL( pItem ) == fValue )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( HB_IS_NIL( pValue ) )
      {
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_NIL( pItem ) )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( HB_IS_POINTER( pValue ) )
      {
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_POINTER( pItem ) &&
                   pItem->item.asPointer.value == pValue->item.asPointer.value )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( fExact && HB_IS_ARRAY( pValue ) )
      {
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_ARRAY( pItem ) &&
                   pItem->item.asArray.value == pValue->item.asArray.value )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }
      else if( fExact && HB_IS_HASH( pValue ) )
      {
         while( ulCount-- )
         {
            PHB_ITEM pItem = hb_hashGetValueAt( pHash, ulStart );
            if( pItem )
            {
               if( HB_IS_HASH( pItem ) &&
                   pItem->item.asHash.value == pValue->item.asHash.value )
               {
                  fFound = TRUE;
                  break;
               }
            }
            else
               break;
            ++ulStart;
         }
      }

      hb_retnint( fFound ? ulStart : 0 );
   }
   else
      hb_errRT_BASE( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c409
HB_FUNCHB_HCASEMATCH(void)
HB_FUNC( HB_HCASEMATCH )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pValue = hb_param( 2, HB_IT_LOGICAL );

   if( pHash )
   {
      hb_retl( ( hb_hashGetFlags( pHash ) & HB_HASH_IGNORECASE ) == 0 );
      if( pValue )
      {
         if( hb_itemGetL( pValue ) )
            hb_hashClearFlags( pHash, HB_HASH_IGNORECASE );
         else
            hb_hashSetFlags( pHash, HB_HASH_IGNORECASE );
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 2017, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c607
HB_FUNCHB_HAUTOADD(void)
HB_FUNC( HB_HAUTOADD )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pValue = hb_param( 2, HB_IT_LOGICAL | HB_IT_NUMERIC );

   if( pHash )
   {
      int iOldFlags = hb_hashGetFlags( pHash ) & HB_HASH_AUTOADD_MASK;
      hb_retni( iOldFlags );
      if( pValue )
      {
         if( HB_IS_LOGICAL( pValue ) )
         {
            if( hb_itemGetL( pValue ) )
               hb_hashSetFlags( pHash, hb_hashGetDefault( pHash ) ?
                           HB_HASH_AUTOADD_ALWAYS : HB_HASH_AUTOADD_ASSIGN );
            else if( iOldFlags )
               hb_hashClearFlags( pHash, iOldFlags );
         }
         else
         {
            int iNewFlags = hb_itemGetNI( pValue );
            if( ( iNewFlags | iOldFlags ) != iNewFlags )
               hb_hashClearFlags( pHash, iOldFlags );
            if( iNewFlags )
               hb_hashSetFlags( pHash, iNewFlags );
         }
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 2017, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c627
HB_FUNCHB_HALLOCATE(void)
HB_FUNC( HB_HALLOCATE )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );
   PHB_ITEM pValue = hb_param( 2, HB_IT_NUMERIC );

   if( pHash && pValue )
   {
      LONG lMem = hb_itemGetNL( pValue );
      if( lMem >= 0 )
         hb_hashPreallocate( pHash, lMem );
   }
   else
      hb_errRT_BASE( EG_ARG, 2017, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hashfunc.c660
HB_FUNCHB_HDEFAULT(void)
HB_FUNC( HB_HDEFAULT )
{
   PHB_ITEM pHash = hb_param( 1, HB_IT_HASH );

   if( pHash )
   {
      hb_itemReturn( hb_hashGetDefault( pHash ) );
      if( hb_pcount() > 1 )
         hb_hashSetDefault( pHash, hb_param( 2, HB_IT_ANY ) );
   }
   else
      hb_errRT_BASE( EG_ARG, 2017, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}

HB_FUNC( HB_HSETAUTOADD )     { HB_FUNC_EXEC( HB_HAUTOADD ); hb_itemReturn( hb_param( 1, HB_IT_HASH ) ); }
HB_FUNC( HB_HSETCASEMATCH )   { HB_FUNC_EXEC( HB_HCASEMATCH ); hb_itemReturn( hb_param( 1, HB_IT_HASH ) ); }
hashfunc.c675
hvm.c
TypeFunctionSourceLine
HB_EXPORT VOIDhb_vmAtInit( HB_INIT_FUNC pFunc, void * cargo )
HB_EXPORT void hb_vmAtInit( HB_INIT_FUNC pFunc, void * cargo )
{
   PHB_FUNC_LIST pLst = ( PHB_FUNC_LIST ) hb_xgrab( sizeof( HB_FUNC_LIST ) );

   pLst->pFunc = pFunc;
   pLst->cargo = cargo;
   HB_ATINIT_LOCK
   pLst->pNext = s_InitFunctions;
   s_InitFunctions = pLst;
   HB_ATINIT_UNLOCK
}
hvm.c296
HB_EXPORT VOIDhb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo )
HB_EXPORT void hb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo )
{
   PHB_FUNC_LIST pLst = ( PHB_FUNC_LIST ) hb_xgrab( sizeof( HB_FUNC_LIST ) );

   pLst->pFunc = pFunc;
   pLst->cargo = cargo;
   HB_ATINIT_LOCK
   pLst->pNext = s_ExitFunctions;
   s_ExitFunctions = pLst;
   HB_ATINIT_UNLOCK
}
hvm.c308
STATIC VOIDhb_vmCleanModuleFunctions( void )
static void hb_vmCleanModuleFunctions( void )
{
   PHB_FUNC_LIST pLst;

   while( s_InitFunctions )
   {
      pLst = s_InitFunctions;
      s_InitFunctions = pLst->pNext;
      hb_xfree( pLst );
   }
   while( s_ExitFunctions )
   {
      pLst = s_ExitFunctions;
      s_ExitFunctions = pLst->pNext;
      hb_xfree( pLst );
   }
}
hvm.c320
STATIC VOIDhb_vmDoModuleInitFunctions( void )
static void hb_vmDoModuleInitFunctions( void )
{
   PHB_FUNC_LIST pLst = s_InitFunctions;

   while( pLst )
   {
      pLst->pFunc( pLst->cargo );
      pLst = pLst->pNext;
   }
}
hvm.c338
STATIC VOIDhb_vmDoModuleExitFunctions( void )
static void hb_vmDoModuleExitFunctions( void )
{
   PHB_FUNC_LIST pLst = s_ExitFunctions;

   while( pLst )
   {
      pLst->pFunc( pLst->cargo );
      pLst = pLst->pNext;
   }
}
hvm.c349
STATIC VOIDhb_vmDoInitClip( void )
static void hb_vmDoInitClip( void )
{
   PHB_DYNS pDynSym = hb_dynsymFind( "CLIPINIT" );

   if( pDynSym && pDynSym->pSymbol->value.pFunPtr )
   {
      hb_vmPushSymbol( pDynSym->pSymbol );
      hb_vmPushNil();
      hb_vmDo( 0 );
   }
}

#if !defined( HB_MT_VM )

BOOL hb_vmIsMt( void ) { return FALSE; }
hvm.c361
} VOIDhb_vmLock( void )

hvm.c377
VOIDhb_vmUnlock( void )
void hb_vmLock( void ) {}
void hb_vmUnlock( void ) {}
BOOL hb_vmSuspendThreads( BOOL fWait ) { HB_SYMBOL_UNUSED( fWait ); return TRUE; }
hvm.c377
} VOIDhb_vmResumeThreads( void )
void hb_vmResumeThreads( void ) {}

#else

static HB_CRITICAL_NEW( s_vmMtx );
static HB_COND_NEW( s_vmCond );

/* number of allocated HVM stacks */
static int volatile s_iStackCount = 0;
/* number of running HVM threads */
static int volatile s_iRunningCount = 0;
/* active HVM stacks list */
static PHB_THREADSTATE s_vmStackLst = NULL;

#  define HB_THREQUEST_STOP   1
#  define HB_THREQUEST_QUIT   2

#  define HB_VM_LOCK      hb_threadEnterCriticalSection( &s_vmMtx );
#  define HB_VM_UNLOCK    hb_threadLeaveCriticalSection( &s_vmMtx );

BOOL hb_vmIsMt( void ) { return TRUE; }
hvm.c380
} STATIC VOIDhb_vmRequestTest( void )
static void hb_vmRequestTest( void )
{
   HB_VM_LOCK

   s_iRunningCount--;
   while( TRUE )
   {
      if( hb_vmThreadRequest & HB_THREQUEST_QUIT )
      {
         HB_STACK_TLS_PRELOAD
         if( !hb_stackQuitState() )
         {
            hb_stackSetQuitState( TRUE );
            hb_stackSetActionRequest( HB_QUIT_REQUESTED );
         }
      }
      if( hb_vmThreadRequest & HB_THREQUEST_STOP )
      {
         hb_threadCondBroadcast( &s_vmCond );
         hb_threadCondWait( &s_vmCond, &s_vmMtx );
      }
      else
         break;
   }
   s_iRunningCount++;

   HB_VM_UNLOCK
}
hvm.c402
VOIDhb_vmUnlock( void )
void hb_vmUnlock( void )
{
   HB_STACK_TLS_PRELOAD

   if( hb_stackId() )   /* check if thread has associated HVM stack */
   {
      if( hb_stackUnlock() == 1 )
      {
         HB_VM_LOCK
         s_iRunningCount--;
         if( hb_vmThreadRequest )
         {
            if( hb_vmThreadRequest & HB_THREQUEST_QUIT )
            {
               if( !hb_stackQuitState() )
               {
                  hb_stackSetQuitState( TRUE );
                  hb_stackSetActionRequest( HB_QUIT_REQUESTED );
               }
            }
            hb_threadCondBroadcast( &s_vmCond );
         }
         HB_VM_UNLOCK
      }
   }
}
hvm.c431
VOIDhb_vmLock( void )
void hb_vmLock( void )
{
   HB_STACK_TLS_PRELOAD

   if( hb_stackId() )   /* check if thread has associated HVM stack */
   {
      if( hb_stackLock() == 0 )
      {
         HB_VM_LOCK
         while( TRUE )
         {
            if( hb_vmThreadRequest & HB_THREQUEST_QUIT )
            {
               if( !hb_stackQuitState() )
               {
                  hb_stackSetQuitState( TRUE );
                  hb_stackSetActionRequest( HB_QUIT_REQUESTED );
               }
            }
            if( hb_vmThreadRequest & HB_THREQUEST_STOP )
               hb_threadCondWait( &s_vmCond, &s_vmMtx );
            else
               break;
         }
         s_iRunningCount++;
         HB_VM_UNLOCK
      }
   }
}
hvm.c459
BOOLhb_vmSuspendThreads( BOOL fWait )
BOOL hb_vmSuspendThreads( BOOL fWait )
{
   HB_VM_LOCK

   if( ( hb_vmThreadRequest & ( HB_THREQUEST_STOP | HB_THREQUEST_QUIT ) ) == 0 )
   {
      hb_vmThreadRequest |= HB_THREQUEST_STOP;
      --s_iRunningCount;
      while( TRUE )
      {
         if( s_iRunningCount <= 0 )
         {
            hb_vmThreadRequest &= ~HB_THREQUEST_STOP;
            ++s_iRunningCount;
            return TRUE;
         }
         if( !fWait )
            break;
         hb_threadCondWait( &s_vmCond, &s_vmMtx );
         if( hb_vmThreadRequest & HB_THREQUEST_QUIT )
            break;
      }
      hb_vmThreadRequest &= ~HB_THREQUEST_STOP;
      ++s_iRunningCount;
      hb_threadCondBroadcast( &s_vmCond );
   }

   HB_VM_UNLOCK

   return FALSE;
}
hvm.c490
VOIDhb_vmResumeThreads( void )
void hb_vmResumeThreads( void )
{
   hb_vmThreadRequest &= ~HB_THREQUEST_STOP;
   hb_threadCondBroadcast( &s_vmCond );
   HB_VM_UNLOCK
}
hvm.c523
VOIDhb_vmTerminateThreads( void )
void hb_vmTerminateThreads( void )
{
   HB_STACK_TLS_PRELOAD

   if( s_main_thread == hb_stackId() )
   {
      HB_VM_LOCK

      hb_vmThreadRequest |= HB_THREQUEST_QUIT;
      --s_iRunningCount;

      hb_threadCondBroadcast( &s_vmCond );

      while( s_iStackCount > 1 )
         hb_threadCondWait( &s_vmCond, &s_vmMtx );

      ++s_iRunningCount;
      /* hb_vmThreadRequest &= ~HB_THREQUEST_QUIT; */
      hb_vmThreadRequest = 0;

      HB_VM_UNLOCK
   }
}
hvm.c531
VOIDhb_vmWaitForThreads( void )
void hb_vmWaitForThreads( void )
{
   HB_STACK_TLS_PRELOAD

   if( s_main_thread == hb_stackId() )
   {
      HB_VM_LOCK

      --s_iRunningCount;
      if( hb_vmThreadRequest )
         hb_threadCondBroadcast( &s_vmCond );

      while( s_iStackCount > 1 )
         hb_threadCondWait( &s_vmCond, &s_vmMtx );

      ++s_iRunningCount;

      HB_VM_UNLOCK
   }
}
hvm.c559
VOID *hb_vmThreadState( void )
void * hb_vmThreadState( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadState()"));

   return hb_stackList();
}
hvm.c583
STATIC VOIDhb_vmStackAdd( PHB_THREADSTATE pState )
static void hb_vmStackAdd( PHB_THREADSTATE pState )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmStackAdd(%p)", pState));

   if( !pState->pPrev )
   {
      if( s_vmStackLst )
      {
         pState->pNext = s_vmStackLst;
         pState->pPrev = s_vmStackLst->pPrev;
         pState->pPrev->pNext = pState;
         s_vmStackLst->pPrev = pState;
      }
      else
      {
         s_vmStackLst = pState->pNext = pState->pPrev = pState;
      }
      s_iStackCount++;
   }
}
hvm.c592
STATIC VOIDhb_vmStackDel( PHB_THREADSTATE pState )
static void hb_vmStackDel( PHB_THREADSTATE pState )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmStackDel(%p)", pState));

   pState->fActive = FALSE;
   pState->pStackId = NULL;

   if( pState->pPrev )
   {
      pState->pPrev->pNext = pState->pNext;
      pState->pNext->pPrev = pState->pPrev;
      if( s_vmStackLst == pState )
      {
         s_vmStackLst = pState->pNext;
         if( s_vmStackLst == pState )
            s_vmStackLst = NULL;
      }
      pState->pPrev = pState->pNext = NULL;
      s_iStackCount--;
   }

   if( pState->pThItm )
   {
      PHB_ITEM pThItm = pState->pThItm;
      pState->pThItm = NULL;
      /* NOTE: releasing pThItm may force pState freeing if parent
       *       thread does not keep thread pointer item. So it's
       *       important to not access it later. [druzus]
       */
      hb_itemRelease( pThItm );
   }
}
hvm.c613
STATIC VOIDhb_vmStackInit( PHB_THREADSTATE pState )
static void hb_vmStackInit( PHB_THREADSTATE pState )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmStackInit(%p)", pState));

   HB_VM_LOCK

   hb_stackInit();      /* initialize HVM thread stack */
   {
      HB_STACK_TLS_PRELOAD

      hb_stackUnlock();
      pState->pStackId = hb_stackId();
      hb_stackListSet( ( void * ) ( pState ) );
      pState->fActive = TRUE;
      hb_vmStackAdd( pState );
   }
   HB_VM_UNLOCK

   hb_vmLock();
}
hvm.c646
STATIC VOIDhb_vmStackRelease( void )
static void hb_vmStackRelease( void )
{
   HB_STACK_TLS_PRELOAD
   BOOL fLocked;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmStackRelease()"));

   HB_VM_LOCK

   fLocked = hb_stackUnlock() == 1;

   hb_vmStackDel( ( PHB_THREADSTATE ) hb_stackList() );

   hb_setRelease( hb_stackSetStruct() );
   hb_stackFree();

   hb_threadMutexUnlockAll();

   if( fLocked )
   {
      s_iRunningCount--;
      hb_threadCondBroadcast( &s_vmCond );
   }

   HB_VM_UNLOCK
}
hvm.c667
HB_EXPORT BOOLhb_vmThreadRegister( void * Cargo )
HB_EXPORT BOOL hb_vmThreadRegister( void * Cargo )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadRegister(%p)", Cargo));

   HB_VM_LOCK

   hb_vmStackAdd( ( PHB_THREADSTATE ) Cargo );

   HB_VM_UNLOCK

   return TRUE;
}
hvm.c694
HB_EXPORT VOIDhb_vmThreadRelease( void * Cargo )
HB_EXPORT void hb_vmThreadRelease( void * Cargo )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadRelease(%p)", Cargo));

   HB_VM_LOCK

   hb_vmStackDel( ( PHB_THREADSTATE ) Cargo );

   HB_VM_UNLOCK
}
hvm.c707
HB_EXPORT VOIDhb_vmThreadInit( void * Cargo )
HB_EXPORT void hb_vmThreadInit( void * Cargo )
{
   PHB_THREADSTATE pState;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadInit(%p)", Cargo));

   pState = ( PHB_THREADSTATE ) Cargo;
   if( !pState )
      pState = hb_threadStateNew();

   hb_vmStackInit( pState );  /* initialize HVM thread stack */
   {
      HB_STACK_TLS_PRELOAD

      hb_cdpSelectID( pState->pszCDP );
      hb_langSelectID( pState->pszLang );

      if( pState && pState->pSet )
      {
         /* TODO: add set sharing */
         memcpy( hb_stackSetStruct(), pState->pSet, sizeof( HB_SET_STRUCT ) );
         hb_xfree( pState->pSet );
         pState->pSet = NULL;
      }
      else
         hb_setInitialize( hb_stackSetStruct() );

      if( pState->pszDefRDD )
         hb_stackRDD()->szDefaultRDD = pState->pszDefRDD;

      if( s_fHVMActive )
      {
         /* call CLIPINIT function to initialize GetList PUBLIC variables
          * ErrorBlock() and __SetHelpK()
          */
         hb_vmDoInitClip();
      }

      if( pState->pMemvars )
      {
         hb_memvarRestoreFromArray( pState->pMemvars );
         hb_itemRelease( pState->pMemvars );
         pState->pMemvars = NULL;
      }
   }
}
hvm.c718
HB_EXPORT VOIDhb_vmThreadQuit( void )
HB_EXPORT void hb_vmThreadQuit( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_THREADSTATE pState;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadQuit()"));

   hb_stackSetQuitState( TRUE );
   hb_stackSetActionRequest( 0 );

   pState = ( PHB_THREADSTATE ) hb_stackList();
   {
      PHB_ITEM pReturn = hb_stackReturnItem();

      if( HB_IS_BYREF( pReturn ) )
         pReturn = hb_itemUnRef( pReturn );

      if( !pState->pResult )
         pState->pResult = hb_itemNew( pReturn );
      else
         hb_itemCopy( pState->pResult, pReturn );
   }
   hb_itemClear( hb_stackReturnItem() );

   hb_rddCloseAll();             /* close all workareas */
   hb_stackRemove( 1 );          /* clear stack items, leave only initial symbol item */
   hb_memvarsClear();            /* clear all PUBLIC (and PRIVATE if any) variables */
   hb_vmStackRelease();          /* release HVM stack and remove it from linked HVM stacks list */
}
hvm.c766
HB_EXPORT VOIDhb_vmThreadQuitRequest( void * Cargo )
HB_EXPORT void hb_vmThreadQuitRequest( void * Cargo )
{
   PHB_THREADSTATE pState;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadQuitRequest(%p)", Cargo));

   pState = ( PHB_THREADSTATE ) Cargo;

   HB_VM_LOCK

   if( pState->pStackId && pState->fActive )
      hb_stackIdSetActionRequest( pState->pStackId, HB_QUIT_REQUESTED );

   HB_VM_UNLOCK
}
hvm.c797
HB_EXPORT VOIDhb_vmInit( BOOL bStartMainProc )
HB_EXPORT void hb_vmInit( BOOL bStartMainProc )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmInit()"));

   /* initialize internal data structures */
   s_aStatics.type = HB_IT_NIL;

   s_bDebugging = FALSE;

   hb_vmSymbolInit_RT();      /* initialize symbol table with runtime support functions */

   s_pDynsDbgEntry = hb_dynsymFind( "__DBGENTRY" );

   hb_xinit();

#if defined( HB_MT_VM )
   hb_vmStackInit( hb_threadStateNew() ); /* initialize HVM thread stack */
#else
   hb_stackInit();                        /* initialize HVM stack */
#endif
   /* Set the language and codepage to the default */
   /* This trick is needed to stringify the macro value */
   hb_langSelectID( HB_MACRO2STRING( HB_LANG_DEFAULT ) );
   hb_cdpSelectID( HB_MACRO2STRING( HB_CODEPAGE_DEFAULT ) );
   {
      HB_STACK_TLS_PRELOAD
      s_main_thread = hb_stackId();
      /* _SET_* initialization */
      hb_setInitialize( hb_stackSetStruct() );
   }

   hb_clsInit();              /* initialize Classy/OO system */
   hb_errInit();

   /* initialize dynamic symbol for evaluating codeblocks */
   hb_symEval.pDynSym = hb_dynsymGetCase( hb_symEval.szName );

   hb_conInit();

   /* Check for some internal switches */
   s_VMFlags = hb_cmdargProcessVM( &s_VMCancelKey, &s_VMCancelKeyEx );
   hb_inkeySetCancelKeys( s_VMCancelKey, s_VMCancelKeyEx );

#ifndef HB_NO_PROFILER
   /* Initialize opcodes profiler support arrays */
   {
      ULONG ul;

      for( ul = 0; ul < HB_P_LAST_PCODE; ul++ )
      {
         hb_ulOpcodesCalls[ ul ] = 0;
         hb_ulOpcodesTime[ ul ] = 0;
      }
   }
#endif

   if( s_pDynsDbgEntry )
   {
      /* Try to get C dbgEntry() function pointer */
      if( !s_pFunDbgEntry )
         hb_vmDebugEntry( HB_DBG_GETENTRY, 0, NULL, 0, 0 );
      if( !s_pFunDbgEntry )
         s_pFunDbgEntry = hb_vmDebugEntry;
   }

   /* enable executing PCODE (HVM reenter request) */
   s_fHVMActive = TRUE;

   /* Call functions that initializes static variables
    * Static variables have to be initialized before any INIT functions
    * because INIT function can use static variables
    */
   hb_vmDoInitStatics();
   /* call CLIPINIT function to initialize GetList PUBLIC variables
    * ErrorBlock() and __SetHelpK()
    * Because on some platform the execution order of init functions
    * is out of Harbour control then this function has to be called
    * explicitly in VM initialization process before hb_vmDoInitFunctions()
    * and not depends on INIT clause.
    */
   hb_vmDoInitClip();
   hb_clsDoInit();                  /* initialize Classy .prg functions */

   hb_vmDoModuleInitFunctions();    /* process AtInit registered functions */
   hb_vmDoInitFunctions();          /* process defined INIT functions */

   /* This is undocumented CA-Cl*pper, if there's a function called _APPMAIN
      it will be executed first. [vszakats] */
   {
      PHB_DYNS pDynSym = hb_dynsymFind( "_APPMAIN" );

      if( pDynSym && pDynSym->pSymbol->value.pFunPtr )
         s_pSymStart = pDynSym->pSymbol;
#ifdef HB_START_PROCEDURE
      else
      {
         /* if first char is '@' then start procedure were set by
            programmer explicitly and should have the highest priority
            in other case it's the name of first public function in
            first linked moudule which is used if there is no
            HB_START_PROCEDURE in code */
         if( hb_vm_pszLinkedMain && *hb_vm_pszLinkedMain == '@' )
            pDynSym = hb_dynsymFind( hb_vm_pszLinkedMain + 1 );
         else
         {
            pDynSym = hb_dynsymFind( HB_START_PROCEDURE );

            if( ! ( pDynSym && pDynSym->pSymbol->value.pFunPtr ) && hb_vm_pszLinkedMain )
               pDynSym = hb_dynsymFind( hb_vm_pszLinkedMain );
         }

         if( pDynSym && pDynSym->pSymbol->value.pFunPtr )
            s_pSymStart = pDynSym->pSymbol;
         else
            hb_errInternal( HB_EI_VMBADSTARTUP, NULL, HB_START_PROCEDURE, NULL );
      }
#else
      else if( hb_vm_pszLinkedMain )
      {
         pDynSym = hb_dynsymFind( hb_vm_pszLinkedMain + ( *hb_vm_pszLinkedMain == '@' ? 1 : 0 ) );
         if( pDynSym && pDynSym->pSymbol->value.pFunPtr )
            s_pSymStart = pDynSym->pSymbol;
      }
#ifndef HB_C52_STRICT
      if( bStartMainProc && ! s_pSymStart )
         hb_errInternal( HB_EI_VMNOSTARTUP, NULL, NULL, NULL );
#endif
#endif
   }

   if( bStartMainProc && s_pSymStart )
   {
      int i;
      int iArgCount;

      hb_vmSetExceptionHandler();

      hb_vmPushSymbol( s_pSymStart ); /* pushes first HB_FS_PUBLIC defined symbol to the stack */
      hb_vmPushNil();                 /* places NIL at self */

      iArgCount = 0;
      for( i = 1; i < hb_cmdargARGC(); i++ )     /* places application parameters on the stack */
      {
         char ** argv = hb_cmdargARGV();

         /* Filter out any parameters beginning with //, like //INFO */
         if( ! hb_cmdargIsInternal( argv[ i ], NULL ) )
         {
            hb_vmPushString( argv[ i ], strlen( argv[ i ] ) );
            iArgCount++;
         }
      }

      hb_vmDo( ( USHORT ) iArgCount ); /* invoke it with number of supplied parameters */

      hb_vmUnsetExceptionHandler();
   }
}
hvm.c818
HB_EXPORT INThb_vmQuit( void )
HB_EXPORT int hb_vmQuit( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmQuit()"));

#if defined( HB_MT_VM )
   hb_vmTerminateThreads();
#endif

   hb_vmDoExitFunctions(); /* process defined EXIT functions */

   /* process AtExit registered functions */
   hb_vmDoModuleExitFunctions();
   hb_vmCleanModuleFunctions();

   /* deactivate debugger */
   hb_vmDebuggerExit();

   /* release all known items stored in subsystems */
   hb_itemClear( hb_stackReturnItem() );
   hb_stackRemove( 1 );          /* clear stack items, leave only initial symbol item */

   hb_memvarsClear();            /* clear all PUBLIC (and PRIVATE if any) variables */

   /* intentionally here to allow executing object destructors for all
    * cross referenced items before we release classy subsystem
    */
   hb_gcCollectAll( TRUE );

   /* Clear any pending actions so RDD shutdown process
    * can be cleanly executed
    */
   hb_stackSetActionRequest( 0 );
   hb_rddCloseAll();             /* close all workareas */
   hb_rddShutDown();             /* remove all registered RDD drivers */

   /* release thread specific data */
   hb_stackDestroyTSD();

   /* stop executing PCODE (HVM reenter request) */
   s_fHVMActive = FALSE;

   hb_errExit();
   hb_clsReleaseAll();

   hb_itemClear( &s_aStatics );

   /* release all remaining items */

   hb_conRelease();                       /* releases Console */
   hb_vmReleaseLocalSymbols();            /* releases the local modules linked list */
   hb_dynsymRelease();                    /* releases the dynamic symbol table */
#ifndef HB_CDP_SUPPORT_OFF
   hb_cdpReleaseAll();                    /* releases codepages */
#endif
   hb_itemClear( hb_stackReturnItem() );

   hb_gcCollectAll( TRUE );

#if defined( HB_MT_VM )
   hb_vmStackRelease();       /* release HVM stack and remove it from linked HVM stacks list */
#else
   hb_setRelease( hb_stackSetStruct() );  /* releases Sets */
   hb_stackFree();
#endif

   /* release all known garbage */
   if( hb_xquery( HB_MEM_USEDMAX ) == 0 ) /* check if fmstat is ON */
      hb_gcReleaseAll();
   hb_xexit();

   return s_nErrorLevel;
}
hvm.c977
HB_EXPORT VOIDhb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
{
   HB_STACK_TLS_PRELOAD
   LONG w = 0;
   BOOL bCanRecover = FALSE;
   BOOL bDynCode = pSymbols == NULL || ( pSymbols->scope.value & HB_FS_DYNCODE ) != 0;
#ifndef HB_NO_PROFILER
   ULONG ulLastOpcode = 0; /* opcodes profiler support */
   ULONG ulPastClock = 0;  /* opcodes profiler support */
#endif
#if !defined( HB_GUI )
   static unsigned short uiPolls = 1;
#endif

   HB_TRACE(HB_TR_DEBUG, ("hb_vmExecute(%p, %p)", pCode, pSymbols));

#ifndef HB_NO_PROFILER
   if( hb_bProfiler )
      ulPastClock = ( ULONG ) clock();
#endif

   for( ;; )
   {
#ifndef HB_NO_PROFILER
      if( hb_bProfiler )
      {
         ULONG ulActualClock = ( ULONG ) clock();

         hb_ulOpcodesTime[ ulLastOpcode ] += ( ulActualClock - ulPastClock );
         ulPastClock = ulActualClock;
         ulLastOpcode = pCode[ w ];
         hb_ulOpcodesCalls[ ulLastOpcode ]++;
      }
#endif

#if !defined( HB_GUI )
      if( ! --uiPolls )
      {
         hb_inkeyPoll();
         /* uiPolls = 255; */

         /* IMHO we should have a _SET_ controlled by user
          * sth like:

         if( hb_stackSetStruct()->HB_SET_KEYPOLL )
         {
            hb_inkeyPoll();
            uiPolls = hb_stackSetStruct()->HB_SET_KEYPOLL;
         }

         for some GTs which can work in assynchrous mode user may
         set it to 0 (or if he doesn't need any inkey poll) and
         when ALT+C/ALT+D is pressed (or any other platform dependent
         key combination) they should set proper flags in
         ActionRequest so we can serve it in main VM loop without
         performance decrease or ignore depending on
         hb_stackSetStruct()->HB_SET_CANCEL,
         hb_stackSetStruct()->HB_SET_DEBUG flags
         */
      }
#endif
#if defined( HB_MT_VM )
      if( hb_vmThreadRequest )
         hb_vmRequestTest();
#endif

      switch( pCode[ w ] )
      {
         /* Operators ( mathematical / character / misc ) */

         case HB_P_NEGATE:
            hb_vmNegate();
            w++;
            break;

         case HB_P_PLUS:
            hb_vmPlus( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_PLUSEQ:
            {
               HB_ITEM_PTR pResult, pValue;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               pValue = hb_stackItemFromTop( -1 );
               hb_vmPlus( pResult, pResult, pValue );
               hb_itemCopy( pValue, pResult );
               hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
               hb_stackDec();
            }
            w++;
            break;

         case HB_P_PLUSEQPOP:
            {
               HB_ITEM_PTR pResult;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               hb_vmPlus( pResult, pResult, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               hb_stackPop();
            }
            w++;
            break;

         case HB_P_MINUS:
            hb_vmMinus( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_MINUSEQ:
            {
               HB_ITEM_PTR pResult, pValue;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               pValue = hb_stackItemFromTop( -1 );
               hb_vmMinus( pResult, pResult, pValue );
               hb_itemCopy( pValue, pResult );
               hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
               hb_stackDec();
            }
            w++;
            break;

         case HB_P_MINUSEQPOP:
            {
               HB_ITEM_PTR pResult;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               hb_vmMinus( pResult, pResult, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               hb_stackPop();
            }
            w++;
            break;

         case HB_P_MULT:
            hb_vmMult( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_MULTEQ:
            {
               HB_ITEM_PTR pResult, pValue;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               pValue = hb_stackItemFromTop( -1 );
               hb_vmMult( pResult, pResult, pValue );
               hb_itemCopy( pValue, pResult );
               hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
               hb_stackDec();
            }
            w++;
            break;

         case HB_P_MULTEQPOP:
            {
               HB_ITEM_PTR pResult;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               hb_vmMult( pResult, pResult, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               hb_stackPop();
            }
            w++;
            break;

         case HB_P_DIVIDE:
            hb_vmDivide( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_DIVEQ:
            {
               HB_ITEM_PTR pResult, pValue;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               pValue = hb_stackItemFromTop( -1 );
               hb_vmDivide( pResult, pResult, pValue );
               hb_itemCopy( pValue, pResult );
               hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
               hb_stackDec();
            }
            w++;
            break;

         case HB_P_DIVEQPOP:
            {
               HB_ITEM_PTR pResult;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               hb_vmDivide( pResult, pResult, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               hb_stackPop();
            }
            w++;
            break;

         case HB_P_MODULUS:
            hb_vmModulus( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_MODEQ:
            {
               HB_ITEM_PTR pResult, pValue;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               pValue = hb_stackItemFromTop( -1 );
               hb_vmModulus( pResult, pResult, pValue );
               hb_itemCopy( pValue, pResult );
               hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
               hb_stackDec();
            }
            w++;
            break;

         case HB_P_MODEQPOP:
            {
               HB_ITEM_PTR pResult;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               hb_vmModulus( pResult, pResult, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               hb_stackPop();
            }
            w++;
            break;

         case HB_P_POWER:
            hb_vmPower( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_EXPEQ:
            {
               HB_ITEM_PTR pResult, pValue;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               pValue = hb_stackItemFromTop( -1 );
               hb_vmPower( pResult, pResult, pValue );
               hb_itemCopy( pValue, pResult );
               hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
               hb_stackDec();
            }
            w++;
            break;

         case HB_P_EXPEQPOP:
            {
               HB_ITEM_PTR pResult;
               pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
               hb_vmPower( pResult, pResult, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               hb_stackPop();
            }
            w++;
            break;

         case HB_P_INC:
            hb_vmInc( hb_stackItemFromTop( -1 ) );
            w++;
            break;

         case HB_P_INCEQ:
            {
               HB_ITEM_PTR pResult, pValue, pTemp;
               pResult = hb_stackItemFromTop( -1 );
               pValue = hb_itemUnRef( pResult );
               hb_vmInc( pValue );
               pTemp = hb_stackAllocItem();
               hb_itemCopy( pTemp, pValue );
               hb_itemMove( pResult, pTemp );
               hb_stackDec();
               w++;
            }
            break;

         case HB_P_INCEQPOP:
            hb_vmInc( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_DEC:
            hb_vmDec( hb_stackItemFromTop( -1 ) );
            w++;
            break;

         case HB_P_DECEQ:
            {
               HB_ITEM_PTR pResult, pValue, pTemp;
               pResult = hb_stackItemFromTop( -1 );
               pValue = hb_itemUnRef( pResult );
               hb_vmDec( pValue );
               pTemp = hb_stackAllocItem();
               hb_itemCopy( pTemp, pValue );
               hb_itemMove( pResult, pTemp );
               hb_stackDec();
               w++;
            }
            break;

         case HB_P_DECEQPOP:
            hb_vmDec( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) );
            hb_stackPop();
            w++;
            break;

         case HB_P_FUNCPTR:
            hb_vmFuncPtr();
            w++;
            break;

         /* Operators (relational) */

         case HB_P_EQUAL:
            hb_vmEqual();
            w++;
            break;

         case HB_P_EXACTLYEQUAL:
            hb_vmExactlyEqual();
            w++;
            break;

         case HB_P_NOTEQUAL:
            hb_vmNotEqual();
            w++;
            break;

         case HB_P_LESS:
            hb_vmLess();
            w++;
            break;

         case HB_P_LESSEQUAL:
            hb_vmLessEqual();
            w++;
            break;

         case HB_P_GREATER:
            hb_vmGreater();
            w++;
            break;

         case HB_P_GREATEREQUAL:
            hb_vmGreaterEqual();
            w++;
            break;

         case HB_P_INSTRING:
            hb_vmInstring();
            w++;
            break;

         case HB_P_FORTEST:
            hb_vmForTest();
            w++;
            break;

         case HB_P_ENUMSTART:
            hb_vmEnumStart( pCode[ w + 1 ], pCode[ w + 2 ] );
            w += 3;
            break;

         case HB_P_ENUMNEXT:
            hb_vmEnumNext();
            w++;
            break;

         case HB_P_ENUMPREV:
            hb_vmEnumPrev();
            w++;
            break;

         case HB_P_ENUMEND:
            hb_vmEnumEnd();
            w++;
            break;

         case HB_P_SWITCH:
            w = hb_vmSwitch( pCode, w+3, HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            break;

         /* Operators (logical) */

         case HB_P_NOT:
            hb_vmNot();
            w++;
            break;

         case HB_P_AND:
            hb_vmAnd();
            w++;
            break;

         case HB_P_OR:
            hb_vmOr();
            w++;
            break;

         /* Array */

         case HB_P_ARRAYPUSH:
            hb_vmArrayPush();
            w++;
            break;

         case HB_P_ARRAYPUSHREF:
            hb_vmArrayPushRef();
            w++;
            break;

         case HB_P_ARRAYPOP:
            hb_vmArrayPop();
            w++;
            break;

         case HB_P_ARRAYDIM:
            hb_vmArrayDim( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_ARRAYGEN:
            hb_vmArrayGen( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_HASHGEN:
            hb_vmHashGen( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         /* Object */

         case HB_P_MESSAGE:
            hb_vmPushSymbol( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         /* Database */

         case HB_P_SWAPALIAS:
            hb_vmSwapAlias();
            w++;
            break;

         /* Execution */

         case HB_P_DO:
            hb_vmDo( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_DOSHORT:
            hb_vmDo( pCode[ w + 1 ] );
            w += 2;
            break;

         case HB_P_FUNCTION:
            hb_itemSetNil( hb_stackReturnItem() );
            hb_vmDo( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            hb_stackPushReturn();
            w += 3;
            break;

         case HB_P_FUNCTIONSHORT:
            hb_itemSetNil( hb_stackReturnItem() );
            hb_vmDo( pCode[ w + 1 ] );
            hb_stackPushReturn();
            w += 2;
            break;

         case HB_P_SEND:
            hb_itemSetNil( hb_stackReturnItem() );
            hb_vmSend( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;

            /* Is This OK??? */
            if( pCode[ w ] == HB_P_POP )
               w++;
            else
               hb_stackPushReturn();
            break;

         case HB_P_SENDSHORT:
            hb_itemSetNil( hb_stackReturnItem() );
            hb_vmSend( pCode[ w + 1 ] );
            w += 2;

            if( pCode[ w ] == HB_P_POP )
               w++;
            else
               hb_stackPushReturn();
            break;

         case HB_P_PUSHOVARREF:
            hb_vmPushObjectVarRef();
            w++;
            break;

         case HB_P_LINE:
            HB_TRACE(HB_TR_INFO, ("Opcode: HB_P_LINE: %s (%i)",
                     hb_stackBaseItem()->item.asSymbol.value->szName,
                     hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo));

            hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
#ifndef HB_NO_DEBUG
            if( s_bDebugging )
               hb_vmDebuggerShowLine( hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo );
#endif
            w += 3;
            break;

         case HB_P_PARAMETER:
            hb_memvarNewParameter( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ), hb_stackItemFromBase( pCode[ w + 3 ] ) );
            HB_TRACE(HB_TR_INFO, ("(hb_vmPopParameter)"));
            w += 4;
            break;

         case HB_P_FRAME:
            hb_vmFrame( pCode[ w + 1 ], pCode[ w + 2 ] );
            w += 3;
            break;

         case HB_P_VFRAME:
            hb_vmVFrame( pCode[ w + 1 ], pCode[ w + 2 ] );
            w += 3;
            break;

         case HB_P_LARGEFRAME:
            hb_vmFrame( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ), pCode[ w + 3 ] );
            w += 4;
            break;

         case HB_P_LARGEVFRAME:
            hb_vmVFrame( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ), pCode[ w + 3 ] );
            w += 4;
            break;

         case HB_P_SFRAME:
            hb_vmSFrame( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_STATICS:
            hb_vmStatics( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ), HB_PCODE_MKUSHORT( &pCode[ w + 3 ] ) );
            w += 5;
            break;

         case HB_P_THREADSTATICS:
         {
            USHORT uiCount = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            hb_vmInitThreadStatics( uiCount, &pCode[ w + 3 ] );
            w += 3 + ( ( ULONG ) uiCount << 1 );
            break;
         }

         case HB_P_RETVALUE:
            hb_vmRetValue();
            w++;
            break;

         case HB_P_LOCALNAME:
            hb_vmLocalName( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ),
                            ( char * ) pCode + w + 3 );
            w += 3;
            while( pCode[ w++ ] ) {};
            break;

         case HB_P_STATICNAME:
            hb_vmStaticName( pCode[ w + 1 ], HB_PCODE_MKUSHORT( &pCode[ w + 2 ] ),
                             ( char * ) pCode + w + 4 );
            w += 4;
            while( pCode[ w++ ] ) {};
            break;

         case HB_P_MODULENAME:
            hb_vmModuleName( ( char * ) pCode + w + 1 );
            while( pCode[ w++ ] ) {};
            break;

         case HB_P_ENDBLOCK:
            HB_TRACE(HB_TR_INFO, ("HB_P_ENDBLOCK"));
            hb_vmEndBlock();
            /* manually inlined hb_vmRequestEndProc() for some C compilers
             * which does not make such optimisation
             */
            hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
            break;

         case HB_P_ENDPROC:
            HB_TRACE(HB_TR_INFO, ("HB_P_ENDPROC"));
            /* manually inlined hb_vmRequestEndProc() for some C compilers
             * which does not make such optimisation
             */
            hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
            break;

         /* BEGIN SEQUENCE/RECOVER/ALWAYS/END SEQUENCE */

         case HB_P_SEQBLOCK:
            hb_vmSeqBlock();
            w++;
            break;

         case HB_P_SEQALWAYS:
         {
            /*
             * Create the SEQUENCE envelope
             * [ break return value ]  -2
             * [ recover envelope   ]  -1
             * [                    ] <- new recover base
             */

            PHB_ITEM pItem;

            /*
             * 1) clear the storage for value returned by BREAK statement
             */
            hb_stackAllocItem()->type = HB_IT_NIL;

            /*
             * 2) recover data
             */
            pItem = hb_stackAllocItem();
            /* mark type as NIL - it's not real item */
            pItem->type = HB_IT_NIL;
            /* store the address of RECOVER or END opcode */
            pItem->item.asRecover.recover = w + HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            /* store current RECOVER base */
            pItem->item.asRecover.base = hb_stackGetRecoverBase();
            /* store current bCanRecover flag - in a case of nested sequences */
            pItem->item.asRecover.flags = HB_SEQ_DOALWAYS | ( bCanRecover ? HB_SEQ_CANRECOVER : 0 );
            /* clear new recovery state */
            pItem->item.asRecover.request = 0;

            /*
             * set new recover base
             */
            hb_stackSetRecoverBase( hb_stackTopOffset() );
            /*
             * we are now inside a valid SEQUENCE envelope
             */
            bCanRecover = TRUE;
            w += 4;
            break;
         }

         case HB_P_ALWAYSBEGIN:
            /* change the recover address to ALWAYSEND opcode */
            hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.recover =
               w + HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            /* store and reset action */
            hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags |=
               hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request;
            hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request = 0;
            /* store RETURN value */
            if( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_ENDPROC_REQUESTED )
               hb_itemMove( hb_stackItemFromTop( HB_RECOVER_VALUE ), hb_stackReturnItem() );
            w += 4;
            break;

         case HB_P_ALWAYSEND:
         {
            USHORT uiPrevAction, uiCurrAction;

            uiPrevAction = hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags;
            uiCurrAction = hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request;

            /* restore previous recovery base */
            bCanRecover = ( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_CANRECOVER ) != 0;
            hb_stackSetRecoverBase( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.base );

            /* restore requested action */
            if( ( uiCurrAction | uiPrevAction ) & HB_QUIT_REQUESTED )
               hb_stackSetActionRequest( HB_QUIT_REQUESTED );
            else if( ( uiCurrAction | uiPrevAction ) & HB_BREAK_REQUESTED )
               hb_stackSetActionRequest( HB_BREAK_REQUESTED );
            else if( ( uiCurrAction | uiPrevAction ) & HB_ENDPROC_REQUESTED )
               hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
            else
               hb_stackSetActionRequest( 0 );

            /* Remove the ALWAYS envelope */
            hb_stackDec();

            /* restore RETURN value if not overloaded inside ALWAYS code */
            if( !( uiCurrAction & HB_ENDPROC_REQUESTED ) &&
                 ( uiPrevAction & HB_ENDPROC_REQUESTED ) )
               hb_stackPopReturn();
            else
               hb_stackPop();
            w++;
            break;
         }

         case HB_P_SEQBEGIN:
         {
            /*
             * Create the SEQUENCE envelope
             * [ break return value ]  -2
             * [ recover envelope   ]  -1
             * [                    ] <- new recover base
             */

            PHB_ITEM pItem;

            /*
             * 1) clear the storage for value returned by BREAK statement
             */
            hb_stackAllocItem()->type = HB_IT_NIL;

            /*
             * 2) recover data
             */
            pItem = hb_stackAllocItem();
            /* mark type as NIL - it's not real item */
            pItem->type = HB_IT_NIL;
            /* store the address of RECOVER or END opcode */
            pItem->item.asRecover.recover = w + HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            /* store current RECOVER base */
            pItem->item.asRecover.base = hb_stackGetRecoverBase();
            /* store current bCanRecover flag - in a case of nested sequences */
            pItem->item.asRecover.flags = bCanRecover ? HB_SEQ_CANRECOVER : 0;
            /* clear new recovery state */
            pItem->item.asRecover.request = 0;

            /*
             * set new recover base
             */
            hb_stackSetRecoverBase( hb_stackTopOffset() );
            /*
             * we are now inside a valid SEQUENCE envelope
             */
            bCanRecover = TRUE;
            w += 4;
            break;
         }

         case HB_P_SEQEND:
            /*
             * Remove the SEQUENCE envelope
             * This is executed either at the end of sequence or as the
             * response to the break statement if there is no RECOVER clause
             */

            /*
             * 2) Restore previous recovery state
             */
            bCanRecover = ( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_CANRECOVER ) != 0;
            hb_stackSetRecoverBase( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.base );
            hb_stackDec();

            /*
             * 1) Discard the value returned by BREAK statement - there
             * was no RECOVER clause or there was no BREAK statement
             */
            hb_stackPop();
            /*
             * skip outside of SEQUENCE structure
             */
            w += HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            break;

         case HB_P_SEQRECOVER:
            /*
             * Execute the RECOVER code
             */

            /*
             * 2) Restore previous recovery state
             */
            bCanRecover = ( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_CANRECOVER ) != 0;
            hb_stackSetRecoverBase( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.base );
            hb_stackDec();
            /*
             * 1) Leave the value returned from BREAK  - it will be popped
             * in next executed opcode
             */
            w++;
            break;

         /* Jumps */

         case HB_P_JUMPNEAR:
            w += (signed char) pCode[ w + 1 ];
            break;

         case HB_P_JUMP:
            w += HB_PCODE_MKSHORT( &pCode[ w + 1 ] );
            break;

         case HB_P_JUMPFAR:
            w += HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            break;

         case HB_P_JUMPFALSENEAR:
            if( ! hb_vmPopLogical() )
               w += (signed char) pCode[ w + 1 ];
            else
               w += 2;
            break;

         case HB_P_JUMPFALSE:
            if( ! hb_vmPopLogical() )
               w += HB_PCODE_MKSHORT( &pCode[ w + 1 ] );
            else
               w += 3;
            break;

         case HB_P_JUMPFALSEFAR:
            if( ! hb_vmPopLogical() )
               w += HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            else
               w += 4;
            break;

         case HB_P_JUMPTRUENEAR:
            if( hb_vmPopLogical() )
               w += (signed char) pCode[ w + 1 ];
            else
               w += 2;
            break;

         case HB_P_JUMPTRUE:
            if( hb_vmPopLogical() )
               w += HB_PCODE_MKSHORT( &pCode[ w + 1 ] );
            else
               w += 3;
            break;

         case HB_P_JUMPTRUEFAR:
            if( hb_vmPopLogical() )
               w += HB_PCODE_MKINT24( &pCode[ w + 1 ] );
            else
               w += 4;
            break;

         /* Push */

         case HB_P_TRUE:
            {
               PHB_ITEM pItem = hb_stackAllocItem();

               pItem->type = HB_IT_LOGICAL;
               pItem->item.asLogical.value = TRUE;
               w++;
            }
            break;

         case HB_P_FALSE:
            {
               PHB_ITEM pItem = hb_stackAllocItem();

               pItem->type = HB_IT_LOGICAL;
               pItem->item.asLogical.value = FALSE;
               w++;
            }
            break;

         case HB_P_ONE:
            {
               PHB_ITEM pItem = hb_stackAllocItem();

               pItem->type = HB_IT_INTEGER;
               pItem->item.asInteger.value = 1;
               pItem->item.asInteger.length = 10;
               HB_TRACE(HB_TR_INFO, ("(HB_P_ONE)"));
               w++;
            }
            break;

         case HB_P_ZERO:
            {
               PHB_ITEM pItem = hb_stackAllocItem();

               pItem->type = HB_IT_INTEGER;
               pItem->item.asInteger.value = 0;
               pItem->item.asInteger.length = 10;
               HB_TRACE(HB_TR_INFO, ("(HB_P_ZERO)"));
               w++;
            }
            break;

         case HB_P_PUSHNIL:
            hb_stackAllocItem()->type = HB_IT_NIL;
            HB_TRACE(HB_TR_INFO, ("(HB_P_PUSHNIL)"));
            w++;
            break;

         case HB_P_PUSHBYTE:
            {
               PHB_ITEM pItem = hb_stackAllocItem();

               pItem->type = HB_IT_INTEGER;
               pItem->item.asInteger.value = ( signed char ) pCode[ w + 1 ];
               pItem->item.asInteger.length = 10;
               HB_TRACE(HB_TR_INFO, ("(HB_P_PUSHBYTE)"));
               w += 2;
            }
            break;

         case HB_P_PUSHINT:
            HB_TRACE(HB_TR_INFO, ("(HB_P_PUSHINT)"));
            hb_vmPushInteger( HB_PCODE_MKSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHLONG:
            HB_TRACE( HB_TR_DEBUG, ("(HB_P_PUSHLONG)") );
#if HB_INT_MAX >= INT32_MAX
            hb_vmPushIntegerConst( ( int ) HB_PCODE_MKLONG( &pCode[ w + 1 ] ) );
#else
            hb_vmPushLongConst( ( long ) HB_PCODE_MKLONG( &pCode[ w + 1 ] ) );
#endif
            w += 5;
            break;

         case HB_P_PUSHLONGLONG:
            HB_TRACE( HB_TR_DEBUG, ("(HB_P_PUSHLONGLONG)") );
#if !defined( HB_LONG_LONG_OFF )
            hb_vmPushLongLongConst( HB_PCODE_MKLONGLONG( &pCode[ w + 1 ] ) );
#else
            hb_vmPushDoubleConst( HB_PCODE_MKLONGLONG( &pCode[ w + 1 ] ),
                                  HB_DEFAULT_WIDTH, HB_DEFAULT_DECIMALS );
#endif
            w += 9;

            break;

         case HB_P_PUSHDOUBLE:
            hb_vmPushDoubleConst( HB_PCODE_MKDOUBLE( &pCode[ w + 1 ] ),
                                  ( int ) * ( BYTE * ) &pCode[ w + 1 + sizeof( double ) ],
                                  ( int ) * ( BYTE * ) &pCode[ w + 1 + sizeof( double ) + sizeof( BYTE ) ] );
            w += 1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE );
            break;

         case HB_P_PUSHSTRSHORT:
            if( bDynCode )
               hb_vmPushString( ( char * ) pCode + w + 2, ( ULONG ) pCode[ w + 1 ] - 1 );
            else
               hb_vmPushStringPcode( ( char * ) pCode + w + 2, ( ULONG ) pCode[ w + 1 ] - 1 );
            w += 2 + pCode[ w + 1 ];
            break;

         case HB_P_PUSHSTR:
         {
            USHORT uiSize = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            if( bDynCode )
               hb_vmPushString( ( char * ) pCode + w + 3, uiSize - 1 );
            else
               hb_vmPushStringPcode( ( char * ) pCode + w + 3, uiSize - 1 );
            w += 3 + uiSize;
            break;
         }

         case HB_P_PUSHSTRLARGE:
         {
            ULONG ulSize = HB_PCODE_MKUINT24( &pCode[ w + 1 ] );
            if( bDynCode )
               hb_vmPushString( ( char * ) pCode + w + 4, ulSize - 1 );
            else
               hb_vmPushStringPcode( ( char * ) pCode + w + 4, ulSize - 1 );
            w += 4 + ulSize;
            break;
         }

         case HB_P_PUSHSTRHIDDEN:
         {
            ULONG ulSize = ( ULONG ) HB_PCODE_MKUSHORT( &pCode[ w + 2 ] );
            char * szText = hb_compDecodeString( pCode[ w + 1 ], ( char * ) pCode + w + 4, &ulSize );
            hb_itemPutCLPtr( hb_stackAllocItem(), szText, ulSize );
            w += ( 4 + ulSize );
            break;
         }

         case HB_P_PUSHDATE:
            HB_TRACE( HB_TR_DEBUG, ("(HB_P_PUSHDATE)") );
            hb_vmPushDate( ( long ) HB_PCODE_MKLONG( &pCode[ w + 1 ] ) );
            w += 5;
            break;

         case HB_P_PUSHBLOCK:
         {
            /* +0    -> _pushblock
             * +1 +2 -> size of codeblock
             * +3 +4 -> number of expected parameters
             * +5 +6 -> number of referenced local variables
             * +7    -> start of table with referenced local variables
             */
            ULONG ulSize = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            hb_vmPushBlock( ( const BYTE * ) ( pCode + w + 3 ), pSymbols, bDynCode ? ulSize - 7 : 0 );
            w += ulSize;
            break;
         }
         case HB_P_PUSHBLOCKLARGE:
         {
            /* +0       -> _pushblock
             * +1 +2 +3 -> size of codeblock
             * +4 +5    -> number of expected parameters
             * +6 +7    -> number of referenced local variables
             * +8       -> start of table with referenced local variables
             */
            ULONG ulSize = HB_PCODE_MKUINT24( &pCode[ w + 1 ] );
            hb_vmPushBlock( ( const BYTE * ) ( pCode + w + 4 ), pSymbols, bDynCode ? ulSize - 8 : 0 );
            w += ulSize;
            break;
         }
         case HB_P_PUSHBLOCKSHORT:
         {
            /* +0    -> _pushblock
             * +1    -> size of codeblock
             */
            ULONG ulSize = pCode[ w + 1 ];
            hb_vmPushBlockShort( ( const BYTE * ) ( pCode + w + 2 ), pSymbols, bDynCode ? ulSize - 2 : 0 );
            w += ulSize;
            break;
         }

         case HB_P_PUSHSELF:
            hb_vmPush( hb_stackSelfItem() );
            w++;
            break;

         case HB_P_PUSHSYM:
            hb_vmPushSymbol( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHSYMNEAR:
            hb_vmPushSymbol( pSymbols + pCode[ w + 1 ] );
            w += 2;
            break;

         case HB_P_PUSHFUNCSYM:
            hb_vmPushSymbol( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            hb_stackAllocItem()->type = HB_IT_NIL;
            w += 3;
            break;

         case HB_P_PUSHALIAS:
            hb_vmPushAlias();
            w++;
            break;

         case HB_P_PUSHALIASEDFIELD:
            hb_vmPushAliasedField( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHALIASEDFIELDNEAR:
            hb_vmPushAliasedField( pSymbols + pCode[ w + 1 ] );
            w += 2;
            break;

         case HB_P_PUSHALIASEDVAR:
            hb_vmPushAliasedVar( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHFIELD:
            /* It pushes the current value of the given field onto the eval stack
             */
            hb_rddGetFieldValue( hb_stackAllocItem(), pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            HB_TRACE(HB_TR_INFO, ("(hb_vmPushField)"));
            w += 3;
            break;

         case HB_P_PUSHLOCAL:
            hb_vmPushLocal( HB_PCODE_MKSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHLOCALNEAR:
            hb_vmPushLocal( ( signed char ) pCode[ w + 1 ] );
            w += 2;  /* only first two bytes are used */
            break;

         case HB_P_PUSHLOCALREF:
            hb_vmPushLocalByRef( HB_PCODE_MKSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHSTATIC:
            hb_vmPushStatic( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHSTATICREF:
            hb_vmPushStaticByRef( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_PUSHMEMVAR:
            hb_memvarGetValue( hb_stackAllocItem(), pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            HB_TRACE(HB_TR_INFO, ("(hb_vmPushMemvar)"));
            w += 3;
            break;

         case HB_P_PUSHMEMVARREF:
            hb_memvarGetRefer( hb_stackAllocItem(), pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            HB_TRACE(HB_TR_INFO, ("(hb_vmPushMemvarRef)"));
            w += 3;
            break;

         case HB_P_PUSHVARIABLE:
            /* Push a value of variable of unknown type onto the eval stack
             */
            hb_vmPushVariable( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_DUPLICATE:
            hb_vmDuplicate();
            w++;
            break;

         case HB_P_DUPLTWO:
            hb_vmDuplTwo();
            w++;
            break;

         case HB_P_DUPLUNREF:
            hb_vmDuplUnRef();
            w++;
            break;

         case HB_P_PUSHUNREF:
            hb_vmPushUnRef();
            w++;
            break;

         case HB_P_PUSHVPARAMS:
            hb_vmPushVParams();
            w++;
            break;

         case HB_P_SWAP:
            hb_vmSwap( pCode[ w + 1 ] );
            w+=2;
            break;

         /* Pop */

         case HB_P_POP:
            hb_stackPop();
            w++;
            break;

         case HB_P_POPALIAS:
            hb_vmPopAlias();
            w++;
            break;

         case HB_P_POPALIASEDFIELD:
            hb_vmPopAliasedField( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_POPALIASEDFIELDNEAR:
            hb_vmPopAliasedField( pSymbols + pCode[ w + 1 ] );
            w += 2;
            break;

         case HB_P_POPALIASEDVAR:
            hb_vmPopAliasedVar( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_POPFIELD:
            /* Pops a value from the eval stack and uses it to set
             * a new value of the given field
             */
            hb_rddPutFieldValue( hb_stackItemFromTop(-1), pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            hb_stackPop();
            HB_TRACE(HB_TR_INFO, ("(hb_vmPopField)"));
            w += 3;
            break;

         case HB_P_POPLOCAL:
            hb_vmPopLocal( HB_PCODE_MKSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_POPLOCALNEAR:
            hb_vmPopLocal( ( signed char ) pCode[ w + 1 ] );
            w += 2;  /* only first two bytes are used */
            break;

         case HB_P_POPSTATIC:
            hb_vmPopStatic( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_POPMEMVAR:
            hb_memvarSetValue( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ),
                               hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            HB_TRACE(HB_TR_INFO, ("(hb_vmPopMemvar)"));
            w += 3;
            break;

         case HB_P_POPVARIABLE:
         {
            /*
               2004-03-19 Ron Pinkas
               Test with Clipper shows that for assignment, MEMVAR context
               is always used even if MEMVAR does NOT exists, and a FIELD
               with this name exists!!!
               Here is the Test Ueed - Clipper produced NO R/T Error -
               indicating MEMVAR was created.
                 PROCEDURE Main()
                    USE Test
                    First := First
                    CLOSE
                    ? First
                 RETURN
            */
#if 0
            /* Pops a value from the eval stack and uses it to set
             * a new value of a variable of unknown type.
             */
            PHB_SYMB pSymbol = pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );

            if( pSymbol->pDynSym && hb_dynsymGetMemvar( pSymbol->pDynSym ) )
               /* If exist a memory symbol with this name use it */
               hb_memvarSetValue( pSymbol, hb_stackItemFromTop(-1) );
            else if( hb_rddFieldPut( hb_stackItemFromTop(-1), pSymbol ) == FAILURE )
               /* Try with a field and after create a memvar */
               hb_memvarSetValue( pSymbol, hb_stackItemFromTop(-1) );
#else
            hb_memvarSetValue( pSymbols + HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ),
                               hb_stackItemFromTop( -1 ) );
#endif
            hb_stackPop();
            HB_TRACE(HB_TR_INFO, ("(hb_vmPopVariable)"));
            w += 3;
            break;
         }

         /* macro creation */

         case HB_P_MACROPOP:
            /* compile and run - pop a value from the stack */
            hb_macroSetValue( hb_stackItemFromTop( -1 ), pCode[ ++w ] );
            w++;
            break;

         case HB_P_MACROPOPALIASED:
            /* compile and run - pop an aliased variable from the stack */
            hb_macroPopAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), pCode[ ++w ] );
            w++;
            break;

         case HB_P_MACROPUSH:
            /* compile and run - leave the result on the stack */
            /* the topmost element on the stack contains a macro
             * string for compilation
             */
            hb_macroGetValue( hb_stackItemFromTop( -1 ), 0, pCode[ ++w ] );
            w++;
            break;

         case HB_P_MACROPUSHLIST:
            /* compile and run - leave the result on the stack */
            /* the topmost element on the stack contains a macro
             * string for compilation
             */
            hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHLIST, pCode[ ++w ] );
            w++;
            break;

         case HB_P_MACROPUSHINDEX:
            hb_vmMacroPushIndex();
            w++;
            break;

         case HB_P_MACROARRAYGEN:
            hb_vmMacroArrayGen( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_MACRODO:
            hb_vmMacroDo( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_MACROFUNC:
            hb_vmMacroFunc( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_MACROSEND:
            hb_vmMacroSend( HB_PCODE_MKUSHORT( &pCode[ w + 1 ] ) );
            w += 3;
            break;

         case HB_P_MACROPUSHPARE:
            /* compile and run - leave the result on the stack */
            /* the topmost element on the stack contains a macro
             * string for compilation
             */
            hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHPARE, pCode[ ++w ] );
            w++;
            break;

         case HB_P_MACROPUSHALIASED:
            /* compile and run - leave an aliased variable on the stack */
            hb_macroPushAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), pCode[ ++w ] );
            w++;
            break;

         case HB_P_MACROPUSHREF:
            {
               PHB_ITEM pMacro = hb_stackItemFromTop( -1 );
               PHB_SYMB pSym;
               /* compile into a symbol name (used in function calls) */
               hb_macroPushSymbol( pMacro );
               /* NOTE: pMacro string is replaced with a symbol.
                * Symbol is created if it doesn't exist.
                */
               if( hb_stackGetActionRequest() == 0 )
               {
                  pSym = pMacro->item.asSymbol.value;
                  /* NOTE: pMacro item of symbol type is replaced with
                   *  the reference
                   */
                  hb_memvarGetRefer( pMacro, pSym );
               }
               w++;
            }
            break;

         case HB_P_MACROSYMBOL:
            /* compile into a symbol name (used in function calls) */
            hb_macroPushSymbol( hb_stackItemFromTop( -1 ) );
            w++;
            break;

         case HB_P_MACROTEXT:
            /* macro text substitution
             * "text ¯o.other text"
             */
            hb_macroTextValue( hb_stackItemFromTop( -1 ) );
            w++;
            break;

         /* macro compiled opcodes - we are using symbol address here */

         case HB_P_MMESSAGE:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPushSymbol( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPOPALIASEDFIELD:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPopAliasedField( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPOPALIASEDVAR:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPopAliasedVar( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPOPFIELD:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            /* Pops a value from the eval stack and uses it to set
            * a new value of the given field
            */
            hb_rddPutFieldValue( ( hb_stackItemFromTop(-1) ), pDynSym->pSymbol );
            hb_stackPop();
            HB_TRACE(HB_TR_INFO, ("(hb_vmMPopField)"));
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPOPMEMVAR:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_memvarSetValue( pDynSym->pSymbol, hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            HB_TRACE(HB_TR_INFO, ("(hb_vmMPopMemvar)"));
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHALIASEDFIELD:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPushAliasedField( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHALIASEDVAR:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPushAliasedVar( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHBLOCK:
         {
            /*NOTE: the pcode is stored in dynamically allocated memory
            * We need to handle it with more care than compile-time
            * codeblocks
            */
            /* +0    -> _pushblock
             * +1 +2 -> size of codeblock
             * +3 +4 -> number of expected parameters
             * +5    -> pcode bytes
             */
            ULONG ulSize = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            hb_vmPushMacroBlock( ( BYTE * ) ( pCode + w + 5 ), ulSize - 5,
                                 HB_PCODE_MKUSHORT( &pCode[ w + 3 ] ) );
            w += ulSize;
            break;
         }

         case HB_P_MPUSHBLOCKLARGE:
         {
            /*NOTE: the pcode is stored in dynamically allocated memory
            * We need to handle it with more care than compile-time
            * codeblocks
            */
            /* +0       -> _pushblock
             * +1 +2 +3 -> size of codeblock
             * +4 +5    -> number of expected parameters
             * +6       -> pcode bytes
             */
            ULONG ulSize = HB_PCODE_MKUINT24( &pCode[ w + 1 ] );
            hb_vmPushMacroBlock( ( BYTE * ) ( pCode + w + 6 ), ulSize - 6,
                                 HB_PCODE_MKUSHORT( &pCode[ w + 4 ] ) );
            w += ulSize;
            break;
         }

         case HB_P_MPUSHFIELD:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            /* It pushes the current value of the given field onto the eval stack
            */
            hb_rddGetFieldValue( hb_stackAllocItem(), pDynSym->pSymbol );
            HB_TRACE(HB_TR_INFO, ("(hb_vmMPushField)"));
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHMEMVAR:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_memvarGetValue( hb_stackAllocItem(), pDynSym->pSymbol );
            HB_TRACE(HB_TR_INFO, ("(hb_vmMPushMemvar)"));
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHMEMVARREF:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_memvarGetRefer( hb_stackAllocItem(), pDynSym->pSymbol );
            HB_TRACE(HB_TR_INFO, ("(hb_vmMPushMemvarRef)"));
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHSYM:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPushSymbol( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHVARIABLE:
         {
            HB_DYNS_PTR pDynSym = ( HB_DYNS_PTR ) HB_GET_PTR( pCode + w + 1 );
            hb_vmPushVariable( pDynSym->pSymbol );
            w += sizeof( HB_DYNS_PTR ) + 1;
            break;
         }

         case HB_P_MPUSHSTR:
         {
            USHORT uiSize = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );

            hb_vmPushString( ( char * ) ( pCode + w + 3 ), uiSize - 1 );
            w += 3 + uiSize;
            break;
         }

         case HB_P_MPUSHSTRLARGE:
         {
            ULONG ulSize = HB_PCODE_MKUINT24( &pCode[ w + 1 ] );

            hb_vmPushString( ( char * ) ( pCode + w + 3 ), ulSize - 1 );
            w += 4 + ulSize;
            break;
         }

         case HB_P_LOCALNEARADDINT:
         {
            int iLocal = pCode[ w + 1 ];
            HB_TRACE( HB_TR_DEBUG, ("HB_P_LOCALNEARADDINT") );

            hb_vmAddInt( hb_stackLocalVariable( &iLocal ),
                         HB_PCODE_MKSHORT( &pCode[ w + 2 ] ) );
            w += 4;
            break;
         }

         case HB_P_LOCALADDINT:
         {
            int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            HB_TRACE( HB_TR_DEBUG, ("HB_P_LOCALADDINT") );

            hb_vmAddInt( hb_stackLocalVariable( &iLocal ),
                         HB_PCODE_MKSHORT( &pCode[ w + 3 ] ) );
            w += 5;
            break;
         }

         case HB_P_LOCALINC:
         {
            int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal );
            hb_vmInc( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal );
            w += 3;
            break;
         }

         case HB_P_LOCALDEC:
         {
            int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal );
            hb_vmDec( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal );
            w += 3;
            break;
         }

         case HB_P_LOCALINCPUSH:
         {
            int iLocal = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal );
            if( HB_IS_BYREF( pLocal ) )
               pLocal = hb_itemUnRef( pLocal );
            hb_vmInc( pLocal );
            hb_itemCopy( hb_stackAllocItem(), pLocal );
            w += 3;
            break;
         }

         /* WITH OBJECT */

         case HB_P_WITHOBJECTMESSAGE:
         {
            USHORT wSymPos = HB_PCODE_MKUSHORT( &pCode[ w + 1 ] );
            if( wSymPos != 0xFFFF )
            {
               /* NOTE: 0xFFFF is passed when ':&varmacro' syntax is used.
                * In this case symbol is already pushed on the stack
                * using HB_P_MACROSYMBOL.
               */
               hb_vmPushSymbol( pSymbols + wSymPos );
            }
            hb_vmPush( hb_stackWithObjectItem() );
            w += 3;
            break;
         }

         case HB_P_WITHOBJECTSTART:
            hb_vmWithObjectStart();
            w++;
            break;

         case HB_P_WITHOBJECTEND:
            hb_stackPop();    /* remove with object envelope */
            hb_stackPop();    /* remove implicit object */
            w += 1;
            break;

         /* misc */

         case HB_P_NOOP:
            /* Intentionally do nothing */
            w++;
            break;

         default:
            /* TODO: Include to failing pcode in the error message */
            hb_errInternal( HB_EI_VMBADOPCODE, NULL, NULL, NULL );
            break;
      }

      if( hb_stackGetActionRequest() )
      {
         if( hb_stackGetActionRequest() & HB_ENDPROC_REQUESTED )
         {
            /* request to stop current procedure was issued
             * (from macro evaluation)
             */

            /* This code allow to use RETURN inside BEGIN/END sequence
             * or in RECOVER code when ALWAYS clause is used
             */
            if( bCanRecover )
            {
               do
               {
                  hb_stackRemove( hb_stackGetRecoverBase() );
                  if( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_DOALWAYS )
                     break;
                  /* Restore previous recovery state */
                  bCanRecover = ( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_CANRECOVER ) != 0;
                  hb_stackSetRecoverBase( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.base );
               }
               while( bCanRecover );

               /* ALWAYS found? */
               if( bCanRecover )
               {
                  /* reload the address of ALWAYS code */
                  w = hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.recover;
                  /* store and reset action */
                  hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request = hb_stackGetActionRequest();
                  hb_stackSetActionRequest( 0 );
                  continue;
               }
            }
            hb_stackSetActionRequest( 0 );
            break;
         }
         else if( hb_stackGetActionRequest() & HB_BREAK_REQUESTED )
         {
            if( bCanRecover )
            {
               /*
                * There is the BEGIN/END sequence defined in current
                * procedure/function - use it to continue opcodes execution
                */
               /*
                * remove all items placed on the stack after BEGIN code
                */
               hb_stackRemove( hb_stackGetRecoverBase() );
               /*
                * reload the address of recovery code
                */
               w = hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.recover;
               /*
                * leave the SEQUENCE envelope on the stack - it will
                * be popped either in RECOVER or END opcode
                */

               /* store and reset action */
               hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request = hb_stackGetActionRequest();
               hb_stackSetActionRequest( 0 );
            }
            else
               break;
         }
         else if( hb_stackGetActionRequest() & HB_QUIT_REQUESTED )
         {
            if( bCanRecover )
            {
               do
               {
                  hb_stackRemove( hb_stackGetRecoverBase() );
                  if( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_DOALWAYS )
                     break;
                  /* Restore previous recovery state */
                  bCanRecover = ( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_CANRECOVER ) != 0;
                  hb_stackSetRecoverBase( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.base );
                  /* skip other steps */
               }
               while( bCanRecover );

               /* ALWAYS found? */
               if( bCanRecover )
               {
                  /* reload the address of ALWAYS code */
                  w = hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.recover;
                  /* store and reset action */
                  hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request = hb_stackGetActionRequest();
                  hb_stackSetActionRequest( 0 );
                  continue;
               }
            }
            break;
         }
      }
   }
}

/* ------------------------------- */
/* Operators ( mathematical        */
hvm.c1052
STATIC VOIDhb_vmAddInt( HB_ITEM_PTR pResult, LONG lAdd )
static void hb_vmAddInt( HB_ITEM_PTR pResult, LONG lAdd )
{
   double dNewVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmAddInt(%p,%ld)", pResult, lAdd));

   if( HB_IS_BYREF( pResult ) )
   {
      pResult = hb_itemUnRef( pResult );
   }

   if( HB_IS_NUMINT( pResult ) )
   {
      HB_LONG lVal = HB_ITEM_GET_NUMINTRAW( pResult ), lResult;

      lResult = lVal + lAdd;

      if( lAdd >= 0 ? lResult >= lVal : lResult <  lVal )
      {
         HB_ITEM_PUT_NUMINTRAW( pResult, lResult );
         return;
      }
      else
      {
         dNewVal = ( double ) lVal + lAdd;
      }
   }
   else if( HB_IS_DATE( pResult ) )
   {
      pResult->item.asDate.value += lAdd;
      return;
   }
   else if( HB_IS_DOUBLE( pResult ) )
   {
      dNewVal = pResult->item.asDouble.value + lAdd;
   }
   else if( hb_objHasOperator( pResult, HB_OO_OP_PLUS ) )
   {
      HB_STACK_TLS_PRELOAD
      hb_vmPushLong( lAdd );
      hb_objOperatorCall( HB_OO_OP_PLUS, pResult, pResult, hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return;
   }
   else
   {
      HB_STACK_TLS_PRELOAD
      PHB_ITEM pSubst;

      hb_vmPushLong( lAdd );
      pSubst = hb_errRT_BASE_Subst( EG_ARG, 1081, NULL, "+", 2, pResult, hb_stackItemFromTop( -1 ) );
      if( pSubst )
      {
         hb_stackPop();
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
      return;
   }

   if( !HB_IS_DOUBLE( pResult ) )
   {
      pResult->type = HB_IT_DOUBLE;
      pResult->item.asDouble.decimal = 0;
   }

   pResult->item.asDouble.value = dNewVal;
   pResult->item.asDouble.length = HB_DBL_LENGTH( dNewVal );
}
hvm.c2759
STATIC VOIDhb_vmNegate( void )
static void hb_vmNegate( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmNegate()"));

   pItem = hb_stackItemFromTop( -1 );

   if( HB_IS_INTEGER( pItem ) )
   {
#if -HB_INT_MAX > HB_INT_MIN
      if( pItem->item.asInteger.value < -HB_INT_MAX )
      {
#if HB_LONG_MAX > HB_INT_MAX
         HB_LONG lValue = ( HB_LONG ) pItem->item.asInteger.value;
         pItem->type = HB_IT_LONG;
         pItem->item.asLong.value = -lValue;
         pItem->item.asLong.length = HB_LONG_EXPLENGTH( -lValue );
#else
         double dValue = ( double ) pItem->item.asInteger.value;
         pItem->type = HB_IT_DOUBLE;
         pItem->item.asDouble.value = -dValue;
         pItem->item.asDouble.length = HB_DBL_LENGTH( -dValue );
#endif
      }
      else
#endif
      {
         pItem->type = HB_IT_INTEGER;
         pItem->item.asInteger.value = -pItem->item.asInteger.value;
         pItem->item.asInteger.length = HB_INT_EXPLENGTH( pItem->item.asInteger.value );
      }
   }
   else if( HB_IS_LONG( pItem ) )
   {
#if -HB_LONG_MAX > HB_LONG_MIN
      if( pItem->item.asLong.value < -HB_LONG_MAX )
      {
         double dValue = ( double ) pItem->item.asLong.value;
         pItem->type = HB_IT_DOUBLE;
         pItem->item.asDouble.value = -dValue;
         pItem->item.asDouble.length = HB_DBL_LENGTH( -dValue );
      }
      else
#endif
      {
         pItem->type = HB_IT_LONG;
         pItem->item.asLong.value = -pItem->item.asLong.value;
         pItem->item.asLong.length = HB_LONG_EXPLENGTH( pItem->item.asLong.value );
      }
   }
   else if( HB_IS_DOUBLE( pItem ) )
   {
      pItem->type = HB_IT_DOUBLE;
      pItem->item.asDouble.value = -pItem->item.asDouble.value;
      pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1080, NULL, "-", 1, pItem );

      if( pResult )
      {
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c2831
STATIC VOIDhb_vmPlus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
static void hb_vmPlus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmPlus(%p,%p,%p)", pResult, pItem1, pItem2));

   if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      HB_LONG lNumber1 = HB_ITEM_GET_NUMINTRAW( pItem1 );
      HB_LONG lNumber2 = HB_ITEM_GET_NUMINTRAW( pItem2 );
      HB_LONG lResult = lNumber1 + lNumber2;

      if( lNumber2 >= 0 ? lResult >= lNumber1 : lResult < lNumber1 )
      {
         HB_ITEM_PUT_NUMINTRAW( pResult, lResult );
      }
      else
      {
         hb_itemPutND( pResult, ( double ) lNumber1 + ( double ) lNumber2 );
      }
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      int iDec1, iDec2;
      double dNumber1 = hb_itemGetNDDec( pItem1, &iDec1 );
      double dNumber2 = hb_itemGetNDDec( pItem2, &iDec2 );

      hb_itemPutNumType( pResult, dNumber1 + dNumber2, HB_MAX( iDec1, iDec2 ),
                         HB_ITEM_TYPERAW( pItem1 ), HB_ITEM_TYPERAW( pItem2 ) );
   }
   else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      ULONG ulLen1 = pItem1->item.asString.length;
      ULONG ulLen2 = pItem2->item.asString.length;

      if( ulLen2 )
      {
         if( ulLen1 )
         {
            if( ulLen1 < ULONG_MAX - ulLen2 )
            {
               if( pResult != pItem1 )
               {
                  hb_itemMove( pResult, pItem1 );
                  pItem1 = pResult;
               }
               hb_itemReSizeString( pItem1, ulLen1 + ulLen2 );
               hb_xmemcpy( pItem1->item.asString.value + ulLen1,
                           pItem2->item.asString.value, ulLen2 );
            }
            else
               hb_errRT_BASE( EG_STROVERFLOW, 1209, NULL, "+", 2, pItem1, pItem2 );
         }
         else
            hb_itemCopy( pResult, pItem2 );
      }
      else if( pResult != pItem1 )
         hb_itemCopy( pResult, pItem1 );
      pResult->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      /* NOTE: This is not a bug. CA-Cl*pper does exactly that. */
      hb_itemPutDL( pResult, hb_itemGetNL( pItem1 ) + hb_itemGetNL( pItem2 ) );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      hb_itemPutDL( pResult, hb_itemGetDL( pItem1 ) + hb_itemGetNL( pItem2 ) );
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      hb_itemPutDL( pResult, hb_itemGetNL( pItem1 ) + hb_itemGetDL( pItem2 ) );
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_PLUS, pResult, pItem1, pItem2, NULL ) )
   {
      PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ARG, 1081, NULL, "+", 2, pItem1, pItem2 );

      if( pSubst )
      {
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
   }
}
hvm.c2901
STATIC VOIDhb_vmMinus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
static void hb_vmMinus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmMinus(%p,%p,%p)", pResult, pItem1, pItem2));

   if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      HB_LONG lNumber1 = HB_ITEM_GET_NUMINTRAW( pItem1 );
      HB_LONG lNumber2 = HB_ITEM_GET_NUMINTRAW( pItem2 );
      HB_LONG lResult = lNumber1 - lNumber2;

      if( lNumber2 <= 0 ? lResult >= lNumber1 : lResult < lNumber1 )
      {
         HB_ITEM_PUT_NUMINTRAW( pResult, lResult );
      }
      else
      {
         hb_itemPutND( pResult, ( double ) lNumber1 - ( double ) lNumber2 );
      }
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      int iDec1, iDec2;
      double dNumber1 = hb_itemGetNDDec( pItem1, &iDec1 );
      double dNumber2 = hb_itemGetNDDec( pItem2, &iDec2 );

      hb_itemPutNumType( pResult, dNumber1 - dNumber2, HB_MAX( iDec1, iDec2 ),
                         HB_ITEM_TYPERAW( pItem1 ), HB_ITEM_TYPERAW( pItem2 ) );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      HB_LONG lResult = hb_itemGetDL( pItem1 ) - hb_itemGetDL( pItem2 );

      HB_ITEM_PUT_NUMINTRAW( pResult, lResult );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      hb_itemPutDL( pResult, hb_itemGetDL( pItem1 ) - hb_itemGetNL( pItem2 ) );
   }
   else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      ULONG ulLen1 = pItem1->item.asString.length;
      ULONG ulLen2 = pItem2->item.asString.length;

      if( ulLen1 == 0 )
      {
         hb_itemCopy( pResult, pItem2 );
         pResult->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
      }
      else if( ulLen2 == 0 )
      {
         if( pResult != pItem1 )
            hb_itemCopy( pResult, pItem1 );
         pResult->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
      }
      else if( ulLen1 < ULONG_MAX - ulLen2 )
      {
         if( pResult != pItem1 )
         {
            hb_itemMove( pResult, pItem1 );
            pItem1 = pResult;
         }
         hb_itemReSizeString( pItem1, ulLen1 + ulLen2 );
         while( ulLen1 && pItem1->item.asString.value[ ulLen1 - 1 ] == ' ' )
            ulLen1--;
         hb_xmemcpy( pItem1->item.asString.value + ulLen1,
                     pItem2->item.asString.value, ulLen2 );
         hb_xmemset( pItem1->item.asString.value + ulLen1 + ulLen2, ' ',
                     pItem1->item.asString.length - ulLen1 - ulLen2 );
      }
      else
         hb_errRT_BASE( EG_STROVERFLOW, 1210, NULL, "-", 2, pItem1, pItem2 );
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_MINUS, pResult, pItem1, pItem2, NULL ) )
   {
      PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ARG, 1082, NULL, "-", 2, pItem1, pItem2 );

      if( pSubst )
      {
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
   }
}
hvm.c2984
STATIC VOIDhb_vmMult( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
static void hb_vmMult( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmMult(%p,%p,%p)", pResult, pItem1, pItem2));

   /* if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      HB_LONG lNumber1 = HB_ITEM_GET_NUMINTRAW( pItem1 )
      HB_LONG lNumber2 = HB_ITEM_GET_NUMINTRAW( pItem2 );
      HB_LONG lResult = lNumber1 * lNumber2;
      if( lNumber2 == 0 || lResult / lNumber2 == lNumber1 )
         HB_ITEM_PUT_NUMINTRAW( pResult, lResult );
      else
         hb_itemPutNLen( pResult, ( double ) lNumber1 * lNumber2, 0, 0 );
   }
   else */ if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      int iDec1, iDec2;
      double dNumber1 = hb_itemGetNDDec( pItem1, &iDec1 );
      double dNumber2 = hb_itemGetNDDec( pItem2, &iDec2 );

      hb_itemPutNumType( pResult, dNumber1 * dNumber2, iDec1 + iDec2,
                         HB_ITEM_TYPERAW( pItem1 ), HB_ITEM_TYPERAW( pItem2 ) );
   }

   else if( ! hb_objOperatorCall( HB_OO_OP_MULT, pResult, pItem1, pItem2, NULL ) )
   {
      PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ARG, 1083, NULL, "*", 2, pItem1, pItem2 );

      if( pSubst )
      {
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
   }
}
hvm.c3068
STATIC VOIDhb_vmDivide( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
static void hb_vmDivide( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmDivide(%p,%p,%p)", pResult, pItem1, pItem2));

   if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      HB_LONG lDivisor = HB_ITEM_GET_NUMINTRAW( pItem2 );

      if( lDivisor == 0 )
      {
         PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ZERODIV, 1340, NULL, "/", 2, pItem1, pItem2 );

         if( pSubst )
         {
            hb_itemMove( pResult, pSubst );
            hb_itemRelease( pSubst );
         }
      }
      else
      {
         HB_LONG lNumber1 = HB_ITEM_GET_NUMINTRAW( pItem1 );
         hb_itemPutND( pResult, ( double ) lNumber1 / ( double ) lDivisor );
      }
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      double dDivisor = hb_itemGetND( pItem2 );

      if( dDivisor == 0.0 )
      {
         PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ZERODIV, 1340, NULL, "/", 2, pItem1, pItem2 );

         if( pSubst )
         {
            hb_itemMove( pResult, pSubst );
            hb_itemRelease( pSubst );
         }
      }
      else
      {
         /* If all both operand was integer and the result is an integer, too,
            push the number without decimals. Clipper compatible. Actually,
            this is not Clipper compatible. The only time Clipper returns 0
            decimal places is for compiler optimized integer division with an
            integer result. Therefore this code is not needed and has been
            removed - David G. Holm 
         */
         hb_itemPutND( pResult, hb_itemGetND( pItem1 ) / dDivisor );
      }
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_DIVIDE, pResult, pItem1, pItem2, NULL ) )
   {
      PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ARG, 1084, NULL, "/", 2, pItem1, pItem2 );

      if( pSubst )
      {
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
   }
}
hvm.c3104
STATIC VOIDhb_vmModulus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
static void hb_vmModulus( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmModulus(%p,%p,%p)", pResult, pItem1, pItem2));

   if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      HB_LONG lDivisor = HB_ITEM_GET_NUMINTRAW( pItem2 );

      if( lDivisor == 0 )
      {
         PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", 2, pItem1, pItem2 );

         if( pSubst )
         {
            hb_itemMove( pResult, pSubst );
            hb_itemRelease( pSubst );
         }
      }
      else
      {
         /* NOTE: Clipper always returns the result of modulus
                  with the SET number of decimal places. */
         hb_itemPutND( pResult, ( double ) ( HB_ITEM_GET_NUMINTRAW( pItem1 ) % lDivisor ) );
      }
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      double dDivisor = hb_itemGetND( pItem2 );

      if( dDivisor == 0.0 )
      {
         PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", 2, pItem1, pItem2 );

         if( pSubst )
         {
            hb_itemMove( pResult, pSubst );
            hb_itemRelease( pSubst );
         }
      }
      else
      {
         /* NOTE: Clipper always returns the result of modulus
                  with the SET number of decimal places. */
         hb_itemPutND( pResult, fmod( hb_itemGetND( pItem1 ), dDivisor ) );
      }
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_MOD, pResult, pItem1, pItem2, NULL ) )
   {
      PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ARG, 1085, NULL, "%", 2, pItem1, pItem2 );

      if( pSubst )
      {
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
   }
}
hvm.c3166
STATIC VOIDhb_vmPower( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
static void hb_vmPower( HB_ITEM_PTR pResult, HB_ITEM_PTR pItem1, HB_ITEM_PTR pItem2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmPower(%p,%p,%p)", pResult, pItem1, pItem2));

   if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      /* NOTE: Clipper always returns the result of power
               with the SET number of decimal places. */
      hb_itemPutND( pResult, pow( hb_itemGetND( pItem1 ), hb_itemGetND( pItem2 ) ) );
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_POWER, pResult, pItem1, pItem2, NULL ) )
   {
      PHB_ITEM pSubst = hb_errRT_BASE_Subst( EG_ARG, 1088, NULL, "^", 2, pItem1, pItem2 );

      if( pSubst )
      {
         hb_itemMove( pResult, pSubst );
         hb_itemRelease( pSubst );
      }
   }
}
hvm.c3224
STATIC VOIDhb_vmInc( PHB_ITEM pItem )
static void hb_vmInc( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmInc(%p)", pItem));

   if( HB_IS_NUMINT( pItem ) )
   {
      if( HB_IS_INTEGER( pItem ) )
      {
         if( pItem->item.asInteger.value < HB_INT_MAX )
         {
            pItem->type = HB_IT_INTEGER;
            pItem->item.asInteger.value++;
            pItem->item.asInteger.length = HB_INT_EXPLENGTH( pItem->item.asInteger.value );
         }
         else
         {
#if HB_INT_MAX < HB_LONG_MAX
            pItem->type = HB_IT_LONG;
            pItem->item.asLong.value = ( HB_LONG ) pItem->item.asInteger.value + 1;
            pItem->item.asLong.length = HB_LONG_EXPLENGTH( pItem->item.asLong.value );
#else
            pItem->type = HB_IT_DOUBLE;
            pItem->item.asDouble.value = ( double ) pItem->item.asInteger.value + 1;
            pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
            pItem->item.asDouble.decimal = 0;
#endif
         }
      }
      else if( pItem->item.asLong.value < HB_LONG_MAX )
      {
         pItem->type = HB_IT_LONG;
         pItem->item.asLong.value++;
         pItem->item.asLong.length = HB_LONG_EXPLENGTH( pItem->item.asLong.value );
      }
      else
      {
         pItem->type = HB_IT_DOUBLE;
         pItem->item.asDouble.value = ( double ) pItem->item.asLong.value + 1;
         pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
         pItem->item.asDouble.decimal = 0;
      }
   }
   else if( HB_IS_DOUBLE( pItem ) )
   {
      pItem->type = HB_IT_DOUBLE;
      pItem->item.asDouble.value++;
      pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
   }
   else if( HB_IS_DATE( pItem ) )
   {
      pItem->type = HB_IT_DATE;
      pItem->item.asDate.value++;
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_INC, pItem, pItem, NULL, NULL ) )
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1086, NULL, "++", 1, pItem );

      if( pResult )
      {
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3246
STATIC VOIDhb_vmDec( PHB_ITEM pItem )
static void hb_vmDec( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmDec(%p)", pItem));

   if( HB_IS_NUMINT( pItem ) )
   {
      if( HB_IS_INTEGER( pItem ) )
      {
         if( pItem->item.asInteger.value > HB_INT_MIN )
         {
            pItem->type = HB_IT_INTEGER;
            pItem->item.asInteger.value--;
            pItem->item.asInteger.length = HB_INT_EXPLENGTH( pItem->item.asInteger.value );
         }
         else
         {
#if HB_INT_MIN > HB_LONG_MIN
            pItem->type = HB_IT_LONG;
            pItem->item.asLong.value = ( HB_LONG ) pItem->item.asInteger.value - 1;
            pItem->item.asLong.length = HB_LONG_EXPLENGTH( pItem->item.asLong.value );
#else
            pItem->type = HB_IT_DOUBLE;
            pItem->item.asDouble.value = ( double ) pItem->item.asInteger.value - 1;
            pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
            pItem->item.asDouble.decimal = 0;
#endif
         }
      }
      else if( pItem->item.asLong.value > HB_LONG_MIN )
      {
         pItem->type = HB_IT_LONG;
         pItem->item.asLong.value--;
         pItem->item.asLong.length = HB_LONG_EXPLENGTH( pItem->item.asLong.value );
      }
      else
      {
         pItem->type = HB_IT_DOUBLE;
         pItem->item.asDouble.value = ( double ) pItem->item.asLong.value - 1;
         pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
         pItem->item.asDouble.decimal = 0;
      }
   }
   else if( HB_IS_DOUBLE( pItem ) )
   {
      pItem->type = HB_IT_DOUBLE;
      pItem->item.asDouble.value--;
      pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
   }
   else if( HB_IS_DATE( pItem ) )
   {
      pItem->type = HB_IT_DATE;
      pItem->item.asDate.value--;
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_DEC, pItem, pItem, NULL, NULL ) )
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1087, NULL, "--", 1, pItem );

      if( pResult )
      {
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3311
STATIC VOIDhb_vmFuncPtr( void )
static void hb_vmFuncPtr( void )  /* pushes a function address pointer. Removes the symbol from the satck */
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmFuncPtr()"));

   pItem = hb_stackItemFromTop( -1 );

   if( HB_IS_SYMBOL( pItem ) )
   {
      /* do nothing - now we are using HB_IT_SYMBOL */
#if 0
      hb_stackPop();
      hb_vmPushPointer( ( void* ) pItem->item.asSymbol.value->value.pFunPtr );
#endif
   }
   else
      hb_errInternal( HB_EI_VMNOTSYMBOL, NULL, "hb_vmFuncPtr()", NULL );
}

/* ------------------------------- */
hvm.c3376
STATIC VOIDhb_vmExactlyEqual( void )
static void hb_vmExactlyEqual( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmExactlyEqual()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_NIL( pItem1 ) )
   {
      /* pItem1 is NIL so this is safe */
      pItem1->type = HB_IT_LOGICAL;
      pItem1->item.asLogical.value = HB_IS_NIL( pItem2 );
      hb_stackPop();    /* clear the pItem2 */
   }
   else if( HB_IS_NIL( pItem2 ) )
   {
      hb_stackDec();    /* pItem2 is already NIL */
      hb_stackPop();    /* clear the pItem1 */
      hb_vmPushLogical( FALSE );
   }
   else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      BOOL fResult = pItem1->item.asString.length == pItem2->item.asString.length &&
                     memcmp( pItem1->item.asString.value,
                             pItem2->item.asString.value,
                             pItem1->item.asString.length ) == 0;
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) ==
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
      hb_vmPushLogical( hb_vmPopNumber() == hb_vmPopNumber() );
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value ==
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
      hb_vmPushLogical( hb_vmPopLogical() == hb_vmPopLogical() );
   else if( HB_IS_POINTER( pItem1 ) && HB_IS_POINTER( pItem2 ) )
   {
      BOOL fResult = pItem1->item.asPointer.value == pItem2->item.asPointer.value;

      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( HB_IS_HASH( pItem1 ) && HB_IS_HASH( pItem2 ) )
   {
      BOOL fResult = pItem1->item.asHash.value == pItem2->item.asHash.value;

      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( HB_IS_ARRAY( pItem1 ) && HB_IS_ARRAY( pItem2 ) &&
            ! hb_objHasOperator( pItem1, HB_OO_OP_EXACTEQUAL ) )
   {
      BOOL fResult = pItem1->item.asArray.value == pItem2->item.asArray.value;

      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( hb_objOperatorCall( HB_OO_OP_EXACTEQUAL, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1070, NULL, "==", 2, pItem1, pItem2 );
      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3401
STATIC VOIDhb_vmEqual( void )
static void hb_vmEqual( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEqual()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_NIL( pItem1 ) )
   {
      /* pItem1 is NIL so this is safe */
      pItem1->type = HB_IT_LOGICAL;
      pItem1->item.asLogical.value = HB_IS_NIL( pItem2 );
      hb_stackPop();    /* clear the pItem2 */
   }
   else if( HB_IS_NIL( pItem2 ) )
   {
      hb_stackDec();    /* pItem2 is already NIL */
      hb_stackPop();    /* clear the pItem1 */
      hb_vmPushLogical( FALSE );
   }
   else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      BOOL fResult = hb_itemStrCmp( pItem1, pItem2, FALSE ) == 0;
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) ==
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
      hb_vmPushLogical( hb_vmPopNumber() == hb_vmPopNumber() );
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value ==
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
      hb_vmPushLogical( hb_vmPopLogical() == hb_vmPopLogical() );
   else if( HB_IS_POINTER( pItem1 ) && HB_IS_POINTER( pItem2 ) )
   {
      BOOL fResult = pItem1->item.asPointer.value == pItem2->item.asPointer.value;
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( HB_IS_HASH( pItem1 ) && HB_IS_HASH( pItem2 ) )
   {
      BOOL fResult = pItem1->item.asHash.value == pItem2->item.asHash.value;
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( hb_objOperatorCall( HB_OO_OP_EQUAL, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1071, NULL, "=", 2, pItem1, pItem2 );
      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3492
STATIC VOIDhb_vmNotEqual( void )
static void hb_vmNotEqual( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmNotEqual()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_NIL( pItem1 ) )
   {
      /* pItem1 is NIL so this is safe */
      pItem1->type = HB_IT_LOGICAL;
      pItem1->item.asLogical.value = ! HB_IS_NIL( pItem2 );
      hb_stackPop();    /* clear the pItem2 */
   }
   else if( HB_IS_NIL( pItem2 ) )
   {
      hb_stackDec();    /* pItem2 is already NIL */
      hb_stackPop();    /* clear the pItem1 */
      hb_vmPushLogical( TRUE );
   }
   else if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      int i = hb_itemStrCmp( pItem1, pItem2, FALSE );
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( i != 0 );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) !=
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
      hb_vmPushLogical( hb_vmPopNumber() != hb_vmPopNumber() );
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value !=
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
      hb_vmPushLogical( hb_vmPopLogical() != hb_vmPopLogical() );
   else if( HB_IS_POINTER( pItem1 ) && HB_IS_POINTER( pItem2 ) )
   {
      BOOL fValue = pItem1->item.asPointer.value !=
                    pItem2->item.asPointer.value;
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fValue );
   }
   else if( HB_IS_HASH( pItem1 ) && HB_IS_HASH( pItem2 ) )
   {
      BOOL fResult = pItem1->item.asHash.value != pItem2->item.asHash.value;
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( hb_objOperatorCall( HB_OO_OP_NOTEQUAL, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1072, NULL, "<>", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3569
STATIC VOIDhb_vmLess( void )
static void hb_vmLess( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmLess()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      int i = hb_itemStrCmp( pItem1, pItem2, FALSE );
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( i < 0 );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) <
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      double dNumber2 = hb_vmPopNumber();
      double dNumber1 = hb_vmPopNumber();
      hb_vmPushLogical( dNumber1 < dNumber2 );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value <
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
   {
      BOOL bLogical2 = hb_vmPopLogical();
      BOOL bLogical1 = hb_vmPopLogical();
      hb_vmPushLogical( bLogical1 < bLogical2 );
   }
   else if( hb_objOperatorCall( HB_OO_OP_LESS, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1073, NULL, "<", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3648
STATIC VOIDhb_vmLessEqual( void )
static void hb_vmLessEqual( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmLessEqual()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      int i = hb_itemStrCmp( pItem1, pItem2, FALSE );
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( i <= 0 );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) <=
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      double dNumber2 = hb_vmPopNumber();
      double dNumber1 = hb_vmPopNumber();
      hb_vmPushLogical( dNumber1 <= dNumber2 );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value <=
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
   {
      BOOL bLogical2 = hb_vmPopLogical();
      BOOL bLogical1 = hb_vmPopLogical();
      hb_vmPushLogical( bLogical1 <= bLogical2 );
   }
   else if( hb_objOperatorCall( HB_OO_OP_LESSEQUAL, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1074, NULL, "<=", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3708
STATIC VOIDhb_vmGreater( void )
static void hb_vmGreater( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmGreater()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      int i = hb_itemStrCmp( pItem1, pItem2, FALSE );
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( i > 0 );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) >
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      double dNumber2 = hb_vmPopNumber();
      double dNumber1 = hb_vmPopNumber();
      hb_vmPushLogical( dNumber1 > dNumber2 );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value >
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
   {
      BOOL bLogical2 = hb_vmPopLogical();
      BOOL bLogical1 = hb_vmPopLogical();
      hb_vmPushLogical( bLogical1 > bLogical2 );
   }
   else if( hb_objOperatorCall( HB_OO_OP_GREATER, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1075, NULL, ">", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3768
STATIC VOIDhb_vmGreaterEqual( void )
static void hb_vmGreaterEqual( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmGreaterEqual()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      int i = hb_itemStrCmp( pItem1, pItem2, FALSE );
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( i >= 0 );
   }
   else if( HB_IS_NUMINT( pItem1 ) && HB_IS_NUMINT( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( HB_ITEM_GET_NUMINTRAW( pItem1 ) >=
                                       HB_ITEM_GET_NUMINTRAW( pItem2 ) );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem1 ) && HB_IS_NUMERIC( pItem2 ) )
   {
      double dNumber2 = hb_vmPopNumber();
      double dNumber1 = hb_vmPopNumber();
      hb_vmPushLogical( dNumber1 >= dNumber2 );
   }
   else if( HB_IS_DATE( pItem1 ) && HB_IS_DATE( pItem2 ) )
   {
      pItem1->item.asLogical.value = ( pItem1->item.asDate.value >=
                                       pItem2->item.asDate.value );
      pItem1->type = HB_IT_LOGICAL;
      hb_stackDec();
   }
   else if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
   {
      BOOL bLogical2 = hb_vmPopLogical();
      BOOL bLogical1 = hb_vmPopLogical();
      hb_vmPushLogical( bLogical1 >= bLogical2 );
   }
   else if( hb_objOperatorCall( HB_OO_OP_GREATEREQUAL, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1076, NULL, ">=", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3828
STATIC VOIDhb_vmInstring( void )
static void hb_vmInstring( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem1;
   PHB_ITEM pItem2;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmInstring()"));

   pItem1 = hb_stackItemFromTop( -2 );
   pItem2 = hb_stackItemFromTop( -1 );

   if( HB_IS_STRING( pItem1 ) && HB_IS_STRING( pItem2 ) )
   {
      BOOL fResult = ( hb_strAt( pItem1->item.asString.value, pItem1->item.asString.length,
                                 pItem2->item.asString.value, pItem2->item.asString.length ) != 0 );
      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( HB_IS_HASH( pItem2 ) &&
            ( HB_IS_HASHKEY( pItem1 ) || hb_hashLen( pItem1 ) == 1 ) )
   {
      BOOL fResult = hb_hashScan( pItem2, pItem1, NULL );

      hb_stackPop();
      hb_stackPop();
      hb_vmPushLogical( fResult );
   }
   else if( hb_objOperatorCall( HB_OO_OP_INCLUDE, pItem1, pItem2, pItem1, NULL ) )
      hb_stackPop();

   else if( hb_objOperatorCall( HB_OO_OP_INSTRING, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1109, NULL, "$", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c3888
STATIC VOIDhb_vmForTest( void )
static void hb_vmForTest( void )        /* Test to check the end point of the FOR */
{
   HB_STACK_TLS_PRELOAD
   BOOL fBack;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmForTest()"));

   if( HB_IS_NUMERIC( hb_stackItemFromTop( -1 ) ) )
   {
      fBack = hb_vmPopNumber() < 0.0;
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushInteger( 0 );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1073, NULL, "<", 2, hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         if( HB_IS_LOGICAL( pResult ) )
         {
            fBack = pResult->item.asLogical.value;
            hb_itemRelease( pResult );
            hb_stackPop();
            hb_stackPop();
         }
         else
         {
            hb_itemMove( hb_stackItemFromTop( -1 ), pResult );
            hb_itemRelease( pResult );
            hb_errRT_BASE( EG_ARG, 1066, NULL, hb_langDGetErrorDesc( EG_CONDITION ), 1, hb_stackItemFromTop( -1 ) );
            return;
         }
      }
      else
         return;
   }

   if( fBack )
      hb_vmLess();
   else
      hb_vmGreater();
}
hvm.c3935
STATIC HB_GARBAGE_FUNC(hb_SeqBlockDestructor )
static HB_GARBAGE_FUNC( hb_SeqBlockDestructor )
{
   PHB_ITEM * pBlockPtr = ( PHB_ITEM * ) Cargo;

   hb_itemMove( hb_errorBlock(), * pBlockPtr );
   hb_itemRelease( * pBlockPtr );
}
hvm.c3985
STATIC VOIDhb_vmSeqBlock( void )
static void hb_vmSeqBlock( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmSeqBlock()"));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_BLOCK( pItem ) )
   {
      PHB_ITEM * pBlockPtr, pBlock, pHolder;

      pBlock = hb_errorBlock();
      pHolder = hb_itemNew( pBlock );
      hb_itemMove( pBlock, pItem );
      pBlockPtr = ( PHB_ITEM * ) hb_gcAlloc( sizeof( PHB_ITEM ),
                                             hb_SeqBlockDestructor );
      * pBlockPtr = pHolder;
      pItem->type = HB_IT_POINTER;
      pItem->item.asPointer.value = pBlockPtr;
      pItem->item.asPointer.collect = pItem->item.asPointer.single = TRUE;
   }
}
hvm.c3994
STATIC HB_GARBAGE_FUNC(hb_withObjectDestructor )
static HB_GARBAGE_FUNC( hb_withObjectDestructor )
{
   HB_STACK_TLS_PRELOAD
   LONG * plWithObjectBase = ( LONG * ) Cargo;
   hb_stackWithObjectSetOffset( * plWithObjectBase );
}
hvm.c4018
STATIC VOIDhb_vmWithObjectStart( void )
static void hb_vmWithObjectStart( void )
{
   HB_STACK_TLS_PRELOAD
   LONG * plWithObjectBase;
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmWithObjectStart()"));

   pItem = hb_stackAllocItem();
   plWithObjectBase = ( LONG * ) hb_gcAlloc( sizeof( LONG ),
                                             hb_withObjectDestructor );
   * plWithObjectBase = hb_stackWithObjectOffset();
   pItem->type = HB_IT_POINTER;
   pItem->item.asPointer.value = plWithObjectBase;
   pItem->item.asPointer.collect = pItem->item.asPointer.single = TRUE;
   /* The object is pushed directly before this pcode */
   /* store position of current WITH OBJECT frame */
   hb_stackWithObjectSetOffset( hb_stackTopOffset() - 2 );
}
hvm.c4026
VOIDhb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue )
void hb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEnumRelease(%p,%p)", pBase, pValue));

   if( pValue )
      hb_itemRelease( pValue );

   if( HB_IS_OBJECT( pBase ) && hb_vmRequestQuery() == 0 &&
       hb_objHasOperator( pBase, HB_OO_OP_ENUMSTOP ) )
   {
      hb_stackPushReturn();
      hb_vmPushNil();
      hb_objOperatorCall( HB_OO_OP_ENUMSTOP, hb_stackItemFromTop( -1 ),
                          pBase, NULL, NULL );
      hb_stackPop();
      hb_stackPopReturn();
   }
}

/*
 * extended reference used as enumerator destructor
 */
typedef struct
{
   HB_ITEM  basevalue;
   HB_ITEM  oldvalue;
   HB_ITEM  enumref;
} HB_ENUMREF, * PHB_ENUMREF;
hvm.c4046
STATIC PHB_ITEMhb_vmEnumRefRead( PHB_ITEM pRefer )
static PHB_ITEM hb_vmEnumRefRead( PHB_ITEM pRefer )
{
   return &( ( PHB_ENUMREF ) pRefer->item.asExtRef.value )->oldvalue;
}
hvm.c4080
STATIC PHB_ITEMhb_vmEnumRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
static PHB_ITEM hb_vmEnumRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
{
   HB_SYMBOL_UNUSED( pRefer );
   HB_SYMBOL_UNUSED( pSource );
   return NULL;
}
hvm.c4085
STATIC VOIDhb_vmEnumRefCopy( PHB_ITEM pDest )
static void hb_vmEnumRefCopy( PHB_ITEM pDest )
{
   pDest->type = HB_IT_NIL;
}
hvm.c4092
STATIC VOIDhb_vmEnumRefClear( void * value )
static void hb_vmEnumRefClear( void * value )
{
   hb_itemMove( hb_itemUnRefOnce( &( ( PHB_ENUMREF ) value )->enumref ),
                &( ( PHB_ENUMREF ) value )->oldvalue );
   if( HB_IS_COMPLEX( &( ( PHB_ENUMREF ) value )->basevalue ) )
      hb_itemClear( &( ( PHB_ENUMREF ) value )->basevalue );
   if( HB_IS_COMPLEX( &( ( PHB_ENUMREF ) value )->enumref ) )
      hb_itemClear( &( ( PHB_ENUMREF ) value )->enumref );

   hb_xfree( value );
}
hvm.c4097
STATIC VOIDhb_vmEnumRefMark( void * value )
static void hb_vmEnumRefMark( void * value )
{
   if( HB_IS_GCITEM( &( ( PHB_ENUMREF ) value )->basevalue ) )
      hb_gcItemRef( &( ( PHB_ENUMREF ) value )->basevalue );
   if( HB_IS_GCITEM( &( ( PHB_ENUMREF ) value )->oldvalue ) )
      hb_gcItemRef( &( ( PHB_ENUMREF ) value )->oldvalue );
   if( HB_IS_GCITEM( &( ( PHB_ENUMREF ) value )->enumref ) )
      hb_gcItemRef( &( ( PHB_ENUMREF ) value )->enumref );
}
hvm.c4109
STATIC VOIDhb_vmEnumReference( PHB_ITEM pBase )
static void hb_vmEnumReference( PHB_ITEM pBase )
{
   static const HB_EXTREF s_EnumExtRef = {
             hb_vmEnumRefRead,
             hb_vmEnumRefWrite,
             hb_vmEnumRefCopy,
             hb_vmEnumRefClear,
             hb_vmEnumRefMark };

   PHB_ENUMREF pEnumExtRef;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEnumReference(%p)", pBase));

   pEnumExtRef = ( PHB_ENUMREF ) hb_xgrab( sizeof( HB_ENUMREF ) );
   pEnumExtRef->basevalue.type = HB_IT_NIL;
   pEnumExtRef->oldvalue.type = HB_IT_NIL;
   pEnumExtRef->enumref.type = HB_IT_NIL;
   hb_itemMove( &pEnumExtRef->basevalue, pBase );
   pBase->type = HB_IT_BYREF | HB_IT_EXTREF;
   pBase->item.asExtRef.value = ( void * ) pEnumExtRef;
   pBase->item.asExtRef.func = &s_EnumExtRef;
}
hvm.c4119
STATIC VOIDhb_vmEnumStart( BYTE nVars, BYTE nDescend )
static void hb_vmEnumStart( BYTE nVars, BYTE nDescend )
{
   HB_STACK_TLS_PRELOAD
   BOOL fStart = TRUE;
   int i;

/*
   pItem = hb_itemUnRef( hb_stackItemFromTop( -( ( int ) nVars << 1 ) ) );
   if( ( pItem->type & ( HB_IT_ARRAY | HB_IT_HASH | HB_IT_STRING ) ) == 0 )
   {
      hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 1, pItem );
      return;
   }
*/

   for( i = ( int ) nVars << 1; i > 0 && fStart; i -= 2 )
   {
      HB_ITEM_PTR pBase, pValue, pEnumRef, pEnum;

      pValue = hb_stackItemFromTop( -i );
      /* create extended reference for enumerator destructor */
      hb_vmEnumReference( pValue );
      pBase = &( ( PHB_ENUMREF ) pValue->item.asExtRef.value )->basevalue;
      /* store the reference to control variable */
      pEnumRef = hb_stackItemFromTop( -i + 1 );
      hb_itemCopy( &( ( PHB_ENUMREF ) pValue->item.asExtRef.value )->enumref,
                   pEnumRef );
      /* the control variable */
      pEnum = hb_itemUnRefOnce( pEnumRef );
      /* store the old value of control variable and clear it */
      hb_itemMove( &( ( PHB_ENUMREF ) pValue->item.asExtRef.value )->oldvalue,
                   pEnum );
      /* set the iterator value */
      pEnum->type = HB_IT_BYREF | HB_IT_ENUM;
      pEnum->item.asEnum.basePtr = pBase;
      pEnum->item.asEnum.valuePtr = NULL;

      if( HB_IS_BYREF( pBase ) )
         pBase = hb_itemUnRef( pBase );

      if( HB_IS_OBJECT( pBase ) && hb_objHasOperator( pBase, HB_OO_OP_ENUMSTART ) )
      {
         pEnum->item.asEnum.offset = 0;
         pEnum->item.asEnum.valuePtr = hb_itemNew( NULL );
         hb_vmPushNil();
         hb_vmPushLogical( nDescend == 0 );
         hb_objOperatorCall( HB_OO_OP_ENUMSTART, hb_stackItemFromTop( -2 ),
                             pBase, pEnumRef, hb_stackItemFromTop( -1 ) );
         hb_stackPop();
         if( hb_vmRequestQuery() != 0 || ! hb_vmPopLogical() )
         {
            fStart = FALSE;
            break;
         }
         else if( hb_objHasOperator( pBase, HB_OO_OP_ENUMSKIP ) )
            continue;
         hb_itemRelease( pEnum->item.asEnum.valuePtr );
         pEnum->item.asEnum.valuePtr = NULL;
      }

      if( HB_IS_ARRAY( pBase ) )
      {
         /* the index into an array */
         pEnum->item.asEnum.offset = ( nDescend > 0 ) ? 1 :
                                       pBase->item.asArray.value->ulLen;
         if( pBase->item.asArray.value->ulLen == 0 )
            fStart = FALSE;
      }
      else if( HB_IS_HASH( pBase ) )
      {
         ULONG ulLen = hb_hashLen( pBase );
         /* the index into a hash */
         pEnum->item.asEnum.offset = ( nDescend > 0 ) ? 1 : ulLen;
         if( ulLen == 0 )
            fStart = FALSE;
      }
      else if( HB_IS_STRING( pBase ) )
      {
         /* storage item for single characters */
         pEnum->item.asEnum.offset = ( nDescend > 0 ) ? 1 :
                                       pBase->item.asString.length;
         if( pBase->item.asString.length )
            pEnum->item.asEnum.valuePtr =
                        hb_itemPutCL( NULL, pBase->item.asString.value +
                                            pEnum->item.asEnum.offset - 1, 1 );
         else
            fStart = FALSE;
      }
      else
      {
         hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 1, pBase );
         return;
      }
   }

   hb_vmPushInteger( nVars );    /* number of iterators */
   /* empty array/string - do not start enumerations loop */
   hb_vmPushLogical( fStart );
}
hvm.c4145
STATIC VOIDhb_vmEnumNext( void )
static void hb_vmEnumNext( void )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pEnumRef, pEnum, pBase;
   int i;

   for( i = ( int ) hb_stackItemFromTop( -1 )->item.asInteger.value; i > 0; --i )
   {
      pEnumRef = hb_stackItemFromTop( -( i << 1 ) );
      pEnum = hb_itemUnRefOnce( pEnumRef );
      pBase = pEnum->item.asEnum.basePtr;
      if( HB_IS_BYREF( pBase ) )
         pBase = hb_itemUnRef( pBase );
      if( HB_IS_ARRAY( pBase ) )
      {
         if( HB_IS_OBJECT( pBase ) &&
             hb_objHasOperator( pBase, HB_OO_OP_ENUMSKIP ) )
         {
            ++pEnum->item.asEnum.offset;
            hb_vmPushNil();
            hb_vmPushLogical( FALSE );
            hb_objOperatorCall( HB_OO_OP_ENUMSKIP, hb_stackItemFromTop( -2 ),
                                pBase, pEnumRef, hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            if( hb_vmRequestQuery() != 0 || ! hb_vmPopLogical() )
               break;
         }
         else
         {
            /* Clear the item value which can be set with RT error
               when enumerator was out of array size during unreferencing
             */
            if( pEnum->item.asEnum.valuePtr )
            {
               hb_itemRelease( pEnum->item.asEnum.valuePtr );
               pEnum->item.asEnum.valuePtr = NULL;
            }
            if( ( ULONG ) ++pEnum->item.asEnum.offset >
                pBase->item.asArray.value->ulLen )
               break;
         }
      }
      else if( HB_IS_HASH( pBase ) )
      {
         /* Clear the item value which can be set with RT error
            when enumerator was out of array size during unreferencing
          */
         if( pEnum->item.asEnum.valuePtr )
         {
            hb_itemRelease( pEnum->item.asEnum.valuePtr );
            pEnum->item.asEnum.valuePtr = NULL;
         }
         if( ( ULONG ) ++pEnum->item.asEnum.offset > hb_hashLen( pBase ) )
            break;
      }
      else if( HB_IS_STRING( pBase ) )
      {
         if( ( ULONG ) ++pEnum->item.asEnum.offset >
             pBase->item.asString.length )
            break;
         hb_itemPutCL( pEnum->item.asEnum.valuePtr,
                       pBase->item.asString.value +
                       pEnum->item.asEnum.offset - 1, 1 );
      }
      else
      {
         hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 1, pBase );
         return;
      }
   }
   hb_vmPushLogical( i == 0 );
}
hvm.c4251
STATIC VOIDhb_vmEnumPrev( void )
static void hb_vmEnumPrev( void )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pEnumRef, pEnum, pBase;
   int i;

   for( i = hb_stackItemFromTop( -1 )->item.asInteger.value; i > 0; --i )
   {
      pEnumRef = hb_stackItemFromTop( -( i << 1 ) );
      pEnum = hb_itemUnRefOnce( pEnumRef );
      pBase = pEnum->item.asEnum.basePtr;
      if( HB_IS_BYREF( pBase ) )
         pBase = hb_itemUnRef( pBase );
      if( HB_IS_ARRAY( pBase ) )
      {
         if( HB_IS_OBJECT( pBase ) &&
             hb_objHasOperator( pBase, HB_OO_OP_ENUMSKIP ) )
         {
            --pEnum->item.asEnum.offset;
            hb_vmPushNil();
            hb_vmPushLogical( TRUE );
            hb_objOperatorCall( HB_OO_OP_ENUMSKIP, hb_stackItemFromTop( -2 ),
                                pBase, pEnumRef, hb_stackItemFromTop( -1 ) );
            hb_stackPop();
            if( hb_vmRequestQuery() != 0 || ! hb_vmPopLogical() )
               break;
         }
         else
         {
            /* Clear the item value which can be set with RT error
               when enumerator was out of array size during unreferencing
             */
            if( pEnum->item.asEnum.valuePtr )
            {
               hb_itemRelease( pEnum->item.asEnum.valuePtr );
               pEnum->item.asEnum.valuePtr = NULL;
            }
            if( --pEnum->item.asEnum.offset == 0 )
               break;
         }
      }
      else if( HB_IS_HASH( pBase ) )
      {
         /* Clear the item value which can be set with RT error
            when enumerator was out of array size during unreferencing
          */
         if( pEnum->item.asEnum.valuePtr )
         {
            hb_itemRelease( pEnum->item.asEnum.valuePtr );
            pEnum->item.asEnum.valuePtr = NULL;
         }
         if( --pEnum->item.asEnum.offset == 0 )
            break;
      }
      else if( HB_IS_STRING( pBase ) )
      {
         if( --pEnum->item.asEnum.offset == 0 )
            break;
         hb_itemPutCL( pEnum->item.asEnum.valuePtr,
                       pBase->item.asString.value +
                       pEnum->item.asEnum.offset - 1, 1 );
      }
      else
      {
         hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 1, pBase );
         return;
      }
   }
   hb_vmPushLogical( i == 0 );
}
hvm.c4330
STATIC VOIDhb_vmEnumEnd( void )
static void hb_vmEnumEnd( void )
{
   HB_STACK_TLS_PRELOAD
   int iVars;

   /* remove number of iterators */
   iVars = hb_stackItemFromTop( -1 )->item.asInteger.value;
   hb_stackDec();

   while( --iVars >= 0 )
   {
      hb_stackPop();
      hb_stackPop();
   }
}
hvm.c4407
STATIC LONGhb_vmSwitch( const BYTE * pCode, LONG offset, USHORT casesCnt )
static LONG hb_vmSwitch( const BYTE * pCode, LONG offset, USHORT casesCnt )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pSwitch = hb_stackItemFromTop( -1 );
   BOOL fFound = FALSE;

   if( !( HB_IS_NUMINT( pSwitch ) || HB_IS_STRING( pSwitch ) ) )
   {
      HB_ITEM_PTR pResult = hb_errRT_BASE_Subst( EG_ARG, 3104, NULL, "SWITCH", 1, pSwitch );

      if( !pResult )
         return offset;

      hb_itemMove( pSwitch, pResult );
      hb_itemRelease( pResult );
   }

   while( !fFound && casesCnt-- )
   {
      switch( pCode[ offset ] )
      {
         case HB_P_PUSHLONG:
            if( HB_IS_NUMINT( pSwitch ) )
            {
               fFound = HB_ITEM_GET_NUMINTRAW( pSwitch ) == HB_PCODE_MKLONG( &pCode[ offset + 1 ] );
            }
            offset += 5;
            break;

         case HB_P_PUSHSTRSHORT:
            if( HB_IS_STRING( pSwitch ) )
            {
               /*fFound = hb_itemStrCmp( pItem1, pItem2, bExact );*/
               fFound = ( ULONG ) pCode[ offset + 1 ] - 1 == pSwitch->item.asString.length &&
                        memcmp( pSwitch->item.asString.value,
                                ( char * ) &pCode[ offset + 2 ],
                                pSwitch->item.asString.length ) == 0;
            }
            offset += 2 + pCode[ offset + 1 ];
            break;

         case HB_P_PUSHNIL:
            /* default clause */
            fFound = TRUE;
            ++offset;
            break;
      }

      switch( pCode[ offset ] )
      {
         case HB_P_JUMPNEAR:
            if( fFound )
               offset += ( signed char ) pCode[ offset + 1 ];
            else
               offset += 2;
            break;
         case HB_P_JUMP:
            if( fFound )
               offset += HB_PCODE_MKSHORT( &pCode[ offset + 1 ] );
            else
               offset += 3;
            break;
         case HB_P_JUMPFAR:
            if( fFound )
               offset += HB_PCODE_MKINT24( &pCode[ offset + 1 ] );
            else
               offset += 4;
            break;
      }
   }
   hb_stackPop();
   return offset;
}

/* ------------------------------- */
hvm.c4429
STATIC VOIDhb_vmNot( void )
static void hb_vmNot( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmNot()"));

   pItem = hb_stackItemFromTop( -1 );

   if( HB_IS_LOGICAL( pItem ) )
   {
      pItem->type = HB_IT_LOGICAL;
      pItem->item.asLogical.value = ! pItem->item.asLogical.value;
   }
   else if( ! hb_objOperatorCall( HB_OO_OP_NOT, pItem, pItem, NULL, NULL ) )
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1077, NULL, ".NOT.", 1, pItem );

      if( pResult )
      {
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c4507
STATIC VOIDhb_vmAnd( void )
static void hb_vmAnd( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmAnd()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
   {
      pItem1->type = HB_IT_LOGICAL;
      pItem1->item.asLogical.value = pItem1->item.asLogical.value && pItem2->item.asLogical.value;
      hb_stackDec();
   }
   else if( hb_objOperatorCall( HB_OO_OP_AND, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1078, NULL, ".AND.", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}
hvm.c4533
STATIC VOIDhb_vmOr( void )
static void hb_vmOr( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem2;
   PHB_ITEM pItem1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmOr()"));

   pItem2 = hb_stackItemFromTop( -1 );
   pItem1 = hb_stackItemFromTop( -2 );

   if( HB_IS_LOGICAL( pItem1 ) && HB_IS_LOGICAL( pItem2 ) )
   {
      pItem1->type = HB_IT_LOGICAL;
      pItem1->item.asLogical.value = pItem1->item.asLogical.value || pItem2->item.asLogical.value;
      hb_stackDec();
   }
   else if( hb_objOperatorCall( HB_OO_OP_OR, pItem1, pItem1, pItem2, NULL ) )
      hb_stackPop();

   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1079, NULL, ".OR.", 2, pItem1, pItem2 );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem1, pResult );
         hb_itemRelease( pResult );
      }
   }
}

/* ------------------------------- */
hvm.c4566
STATIC VOIDhb_vmArrayPush( void )
static void hb_vmArrayPush( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pIndex;
   PHB_ITEM pArray;
   ULONG ulIndex;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPush()"));

   pIndex = hb_stackItemFromTop( -1 );
   pArray = hb_stackItemFromTop( -2 );

   if( HB_IS_HASH( pArray ) && HB_IS_HASHKEY( pIndex ) )
   {
      PHB_ITEM pValue = hb_hashGetItemPtr( pArray, pIndex, HB_HASH_AUTOADD_ACCESS );
      if( pValue )
      {
         hb_itemCopy( pIndex, pValue );
         hb_itemMove( pArray, pIndex );
         hb_stackDec();
      }
      else if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, NULL ) )
         hb_stackPop();
      else
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
      return;
   }
   else if( HB_IS_INTEGER( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asInteger.value;
   else if( HB_IS_LONG( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asLong.value;
   else if( HB_IS_DOUBLE( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asDouble.value;
   else
   {
      if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, NULL ) )
         hb_stackPop();
      else
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
         if( pResult )
         {
            hb_stackPop();
            hb_itemMove( pArray, pResult );
            hb_itemRelease( pResult );
         }
      }
      return;
   }

   if( HB_IS_ARRAY( pArray ) )
   {
      if( HB_IS_OBJECT( pArray ) &&
          hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, NULL ) )
      {
         hb_stackPop();
         return;
      }

      if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->ulLen ) )
      {
         hb_itemCopy( pIndex, pArray->item.asArray.value->pItems + ulIndex - 1 );
         hb_itemMove( pArray, pIndex );
         hb_stackDec();
      }
      else if( !HB_IS_OBJECT( pArray ) &&
               hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, NULL ) )
         hb_stackPop();
      else
#ifdef HB_C52_STRICT
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 0 );
#else
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
#endif
   }
   else if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, NULL ) )
      hb_stackPop();

   else
      hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
}
hvm.c4603
STATIC VOIDhb_vmArrayPushRef( void )
static void hb_vmArrayPushRef( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pIndex;
   PHB_ITEM pArray;
   PHB_ITEM pRefer;
   ULONG ulIndex;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPushRef()"));

   pIndex = hb_stackItemFromTop( -1 );
   pRefer = hb_stackItemFromTop( -2 );
   pArray = HB_IS_BYREF( pRefer ) ? hb_itemUnRef( pRefer ) : pRefer;

   if( HB_IS_HASH( pArray ) && HB_IS_HASHKEY( pIndex ) )
   {
      PHB_ITEM pValue = hb_hashGetItemRefPtr( pArray, pIndex );
      if( pValue )
      {
         hb_itemCopy( pIndex, pValue );
         hb_itemMove( pRefer, pIndex );
         hb_stackDec();
      }
      else if( hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
      {
         /* create extended object index reference */
         hb_vmMsgIndexReference( pRefer, pArray, pIndex );
         hb_stackPop();
         return;
      }
      else
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
      return;
   }
   else if( HB_IS_INTEGER( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asInteger.value;
   else if( HB_IS_LONG( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asLong.value;
   else if( HB_IS_DOUBLE( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asDouble.value;
   else if( hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
   {
      /* create extended object index reference */
      hb_vmMsgIndexReference( pRefer, pArray, pIndex );
      hb_stackPop();
      return;
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pRefer, pResult );
         hb_itemRelease( pResult );
      }
      return;
   }

   if( HB_IS_ARRAY( pArray ) )
   {
      if( HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
      {
         /* create extended object index reference */
         hb_vmMsgIndexReference( pRefer, pArray, pIndex );
         hb_stackPop();
         return;
      }
      else if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->ulLen ) )
      {
         /* This function is safe for overwriting passed array, [druzus] */
         hb_arrayGetItemRef( pArray, ulIndex, pRefer );
         hb_stackDec();
      }
      else if( !HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
      {
         /* create extended object index reference */
         hb_vmMsgIndexReference( pRefer, pArray, pIndex );
         hb_stackPop();
         return;
      }
      else
#ifdef HB_C52_STRICT
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 0 );
#else
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
#endif
   }
   else if( hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
   {
      /* create extended object index reference */
      hb_vmMsgIndexReference( pRefer, pArray, pIndex );
      hb_stackPop();
      return;
   }
   else
      hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, pIndex );
}
hvm.c4685
STATIC VOIDhb_vmArrayPop( void )
static void hb_vmArrayPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pValue;
   PHB_ITEM pIndex;
   PHB_ITEM pArray;
   ULONG ulIndex;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayPop()"));

   pValue = hb_stackItemFromTop( -3 );
   pArray = hb_stackItemFromTop( -2 );
   pIndex = hb_stackItemFromTop( -1 );

   if( HB_IS_BYREF( pArray ) )
      pArray = hb_itemUnRef( pArray );

   if( HB_IS_HASH( pArray ) && HB_IS_HASHKEY( pIndex ) )
   {
      PHB_ITEM pDest = hb_hashGetItemPtr( pArray, pIndex, HB_HASH_AUTOADD_ASSIGN );
      if( pDest )
      {
         pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
         hb_itemMoveFromRef( pDest, pValue );
         hb_stackPop();
         hb_stackPop();
         hb_stackDec();    /* value was moved above hb_stackDec() is enough */
      }
      else if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, pValue ) )
      {
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
      }
      else
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 3, pArray, pIndex, pValue );
      return;
   }
   else if( HB_IS_INTEGER( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asInteger.value;
   else if( HB_IS_LONG( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asLong.value;
   else if( HB_IS_DOUBLE( pIndex ) )
      ulIndex = ( ULONG ) pIndex->item.asDouble.value;
   else
   {
      if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, pValue ) )
      {
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
      }
      else
         hb_errRT_BASE( EG_ARG, 1069, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
      return;
   }

   if( HB_IS_ARRAY( pArray ) )
   {
      if( HB_IS_OBJECT( pArray ) &&
          hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, pValue ) )
      {
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
         return;
      }

      if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->ulLen ) )
      {
         pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
         hb_itemMoveRef( pArray->item.asArray.value->pItems + ulIndex - 1, pValue );
         hb_stackPop();
         hb_stackPop();
         hb_stackDec();    /* value was moved above hb_stackDec() is enough */
      }
      else if( !HB_IS_OBJECT( pArray ) &&
               hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, pValue ) )
      {
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
      }
      else
#ifdef HB_C52_STRICT
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 0 );
#else
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
#endif
   }
   else if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray, pIndex, pValue ) )
   {
      hb_stackPop();
      hb_stackPop();
      hb_stackPop();
      return;
   }
   else
      hb_errRT_BASE( EG_ARG, 1069, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 1, pIndex );
}
hvm.c4785
STATIC VOIDhb_vmArrayGen( ULONG ulElements )
static void hb_vmArrayGen( ULONG ulElements ) /* generates an ulElements Array and fills it from the stack values */
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pArray;
   ULONG ulPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayGen(%lu)", ulElements));

   /* create new array on HVM stack */
   pArray = hb_stackAllocItem();
   hb_arrayNew( pArray, ulElements );

   if( ulElements )
   {
      /* move items from HVM stack to created array */
      for( ulPos = 0; ulPos < ulElements; ulPos++ )
      {
         PHB_ITEM pValue = hb_stackItemFromTop( ( int ) ( ulPos - ulElements - 1 ) );
         pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
         hb_itemMove( pArray->item.asArray.value->pItems + ulPos, pValue );
      }
      /* move the new array to position of first parameter */
      hb_itemMove( hb_stackItemFromTop( ( int ) ( -1 - ulElements ) ), pArray );

      /* decrease the stack counter - all items are NIL */
      hb_stackDecrease( ulElements );
   }
}
hvm.c4886
STATIC VOIDhb_vmArrayNew( HB_ITEM_PTR pArray, USHORT uiDimension )
static void hb_vmArrayNew( HB_ITEM_PTR pArray, USHORT uiDimension )
{
   HB_STACK_TLS_PRELOAD
   ULONG ulElements;
   HB_ITEM_PTR pDim;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayNew(%p, %hu)", pArray, uiDimension));

   pDim = hb_stackItemFromTop( ( int ) ( -1 - uiDimension ) );

   /* use the proper type of number of elements */
   if( HB_IS_INTEGER( pDim ) )
      ulElements = ( ULONG ) pDim->item.asInteger.value;
   else if( HB_IS_LONG( pDim ) )
      ulElements = ( ULONG ) pDim->item.asLong.value;
   else if( HB_IS_DOUBLE( pDim ) )
      ulElements = ( ULONG ) pDim->item.asDouble.value;
   else
      /* NOTE: Clipper creates empty array if non-numeric value is
       * specified as dimension and stops further processing.
       * There is no runtime error generated.
       */
      ulElements = 0;

   /* create an array */
   hb_arrayNew( pArray, ulElements );

   if( --uiDimension )
   {
      /* call self recursively to create next dimensions
       */
      while( ulElements-- )
         hb_vmArrayNew( pArray->item.asArray.value->pItems + ulElements, uiDimension );
   }
}
hvm.c4915
STATIC VOIDhb_vmArrayDim( USHORT uiDimensions )
static void hb_vmArrayDim( USHORT uiDimensions ) /* generates an uiDimensions Array and initialize those dimensions from the stack values */
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayDim(%hu)", uiDimensions));

   hb_vmArrayNew( hb_stackAllocItem(), uiDimensions );

   hb_itemMove( hb_stackItemFromTop( ( int ) ( -1 - uiDimensions ) ),
                hb_stackItemFromTop( -1 ) );
   do
   {
      hb_stackPop();
   }
   while( --uiDimensions );
}
hvm.c4954
STATIC VOIDhb_vmHashGen( ULONG ulElements )
static void hb_vmHashGen( ULONG ulElements ) /* generates an ulElements Hash and fills it from the stack values */
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pHash, pKey, pVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmHashGen(%lu)", ulElements));

   /* create new hash item */
   pHash = hb_hashNew( NULL );
   hb_hashPreallocate( pHash, ulElements );
   while( ulElements-- )
   {
      pKey = hb_stackItemFromTop( -2 );
      pVal = hb_stackItemFromTop( -1 );
      if( HB_IS_HASHKEY( pKey ) )
      {
         hb_hashAddNew( pHash, pKey, pVal );
         hb_stackPop();
         hb_stackPop();
      }
      else
      {
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 3, pHash, pKey, pVal );
         break;
      }
   }
   hb_itemMove( hb_stackAllocItem(), pHash );
   hb_itemRelease( pHash );
}


/* ------------------------------- */
hvm.c4971
STATIC VOIDhb_vmMacroPushIndex( void )
static void hb_vmMacroPushIndex( void )
{
   HB_STACK_TLS_PRELOAD
   ULONG ulIndexes;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroPushIndex()"));

   /*
    * Now the top most element on the stack points to number of
    * additional indexes to generated array
    */
   ulIndexes = hb_itemGetNL( hb_stackItemFromTop( -1 ) );
   hb_stackDec();

   if( ulIndexes > 1 )
   {
      PHB_ITEM pIndexArray;
      ULONG ul = 1;

      hb_vmArrayGen( ulIndexes - 1 );
      pIndexArray = hb_itemNew( hb_stackItemFromTop( -1 ) );
      hb_stackPop();

      /* First index is still on stack.*/
      do
      {
         hb_vmArrayPush();
         /* RT error? */
         if( hb_stackGetActionRequest() != 0 )
            break;
         hb_vmPush( hb_arrayGetItemPtr( pIndexArray, ul ) );
      }
      while( ++ul < ulIndexes );

      hb_itemRelease( pIndexArray );
   }
   else if( ulIndexes == 0 )
      hb_vmPushNil();   /* It will force RT error later in array push or pop */
}
hvm.c5006
STATIC LONGhb_vmArgsJoin( LONG lLevel, USHORT uiArgSets )
static LONG hb_vmArgsJoin( LONG lLevel, USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD
   LONG lArgs, lRestArgs, lOffset;
   PHB_ITEM pArgs = hb_stackItemFromTop( lLevel ) ;


   lArgs = hb_itemGetNL( pArgs );
   if( HB_IS_COMPLEX( pArgs ) )
      hb_itemClear( pArgs );

   if( --uiArgSets )
   {
      lRestArgs = lArgs;
      lArgs += hb_vmArgsJoin( lLevel - lArgs - 1, uiArgSets );
      lOffset = lLevel - lRestArgs - uiArgSets;
      while( lRestArgs-- )
      {
         hb_itemMove( hb_stackItemFromTop( lOffset ),
                      hb_stackItemFromTop( lOffset + uiArgSets ) );
         ++lOffset;
      }
   }

   return lArgs;
}
hvm.c5046
STATIC VOIDhb_vmMacroDo( USHORT uiArgSets )
static void hb_vmMacroDo( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD
   LONG lArgs;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroDo(%hu)", uiArgSets));

   lArgs = hb_vmArgsJoin( -1, uiArgSets );
   hb_stackDecrease( uiArgSets );
   hb_vmDo( ( USHORT ) lArgs );
}
hvm.c5087
STATIC VOIDhb_vmMacroFunc( USHORT uiArgSets )
static void hb_vmMacroFunc( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD
   LONG lArgs;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroFunc(%hu)", uiArgSets));

   lArgs = hb_vmArgsJoin( -1, uiArgSets );
   hb_stackDecrease( uiArgSets );
   hb_vmDo( ( USHORT ) lArgs );
   hb_stackPushReturn();
}
hvm.c5099
STATIC VOIDhb_vmMacroSend( USHORT uiArgSets )
static void hb_vmMacroSend( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD
   LONG lArgs;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroSend(%hu)", uiArgSets));

   lArgs = hb_vmArgsJoin( -1, uiArgSets );
   hb_stackDecrease( uiArgSets );
   hb_vmSend( ( USHORT ) lArgs );
   hb_stackPushReturn();
}
hvm.c5112
STATIC VOIDhb_vmMacroArrayGen( USHORT uiArgSets )
static void hb_vmMacroArrayGen( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD
   LONG lArgs;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMacroArrayGen(%hu)", uiArgSets));

   lArgs = hb_vmArgsJoin( -1, uiArgSets );
   hb_stackDecrease( uiArgSets );
   hb_vmArrayGen( lArgs );
}
hvm.c5125
STATIC VOIDhb_vmPushVParams( void )
static void hb_vmPushVParams( void )
{
   HB_STACK_TLS_PRELOAD
   int iPCount, iFirst, i = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushVParams()"));

   iFirst = hb_stackBaseItem()->item.asSymbol.paramdeclcnt;
   iPCount = hb_pcount();
   while( ++iFirst <= iPCount )
   {
      hb_vmPush( hb_stackItemFromBase( iFirst ) );
      i++;
   }
   hb_vmPushInteger( i );
}

/* ------------------------------- */
hvm.c5137
STATIC ERRCODEhb_vmSelectWorkarea( PHB_ITEM pAlias, PHB_SYMB pField )
static ERRCODE hb_vmSelectWorkarea( PHB_ITEM pAlias, PHB_SYMB pField )
{
   HB_STACK_TLS_PRELOAD
   ERRCODE errCode;
   BOOL fRepeat;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmSelectWorkArea(%p,%p)", pAlias, pField));

   /* NOTE: Clipper doesn't generate an error if an workarea specified
    * as numeric value cannot be selected
    */
   do
   {
      fRepeat = FALSE;
      errCode = SUCCESS;

      switch( HB_ITEM_TYPE( pAlias ) )
      {
         case HB_IT_INTEGER:
            /* Alias was used as integer value, for example: 4->field
             * or it was saved on the stack using hb_vmPushAlias()
             * or was evaluated from an expression, (nWorkArea)->field
             */
            hb_rddSelectWorkAreaNumber( pAlias->item.asInteger.value );
            pAlias->type = HB_IT_NIL;
            break;

         case HB_IT_LONG:
            /* Alias was evaluated from an expression, (nWorkArea)->field
             */
            hb_rddSelectWorkAreaNumber( ( int ) pAlias->item.asLong.value );
            pAlias->type = HB_IT_NIL;
            break;

         case HB_IT_DOUBLE:
            /* Alias was evaluated from an expression, (nWorkArea)->field
             */
            hb_rddSelectWorkAreaNumber( ( int ) pAlias->item.asDouble.value );
            pAlias->type = HB_IT_NIL;
            break;

         case HB_IT_SYMBOL:
            /* Alias was specified using alias identifier, for example: al->field
             */
            errCode = hb_rddSelectWorkAreaSymbol( pAlias->item.asSymbol.value );
            pAlias->type = HB_IT_NIL;
            break;

         case HB_IT_STRING:
         {
            /* Alias was evaluated from an expression, for example: (cVar)->field
             */
            /* expand '&' operator if exists */
            char * szAlias;
            BOOL bNewString;

            szAlias = hb_macroExpandString( pAlias->item.asString.value, pAlias->item.asString.length, &bNewString );
            if( pField )
            {
               errCode = hb_rddSelectWorkAreaAlias( szAlias );
            }
            else
            {
               int iArea;
               hb_rddGetAliasNumber( szAlias, &iArea );
               hb_rddSelectWorkAreaNumber( iArea );
            }

            if( bNewString )
               hb_xfree( szAlias );
            hb_itemClear( pAlias );
            break;
         }

         default:
            if( pField )
            {
               PHB_ITEM pSubstVal;

               hb_vmPushString( pField->szName, strlen( pField->szName ) );
               pSubstVal = hb_errRT_BASE_Subst( EG_ARG, 1065, NULL, "&",
                                       2, pAlias, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
               if( pSubstVal )
               {
                  hb_itemMove( pAlias, pSubstVal );
                  hb_itemRelease( pSubstVal );
                  fRepeat = TRUE;
               }
               else
               {
                  hb_itemSetNil( pAlias );
                  errCode = FAILURE;
               }
            }
            else
            {
               hb_rddSelectWorkAreaNumber( -1 );
               hb_itemSetNil( pAlias );
            }
            break;
      }
   }
   while( fRepeat );

   return errCode;
}
hvm.c5158
STATIC VOIDhb_vmSwapAlias( void )
static void hb_vmSwapAlias( void )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pItem;
   HB_ITEM_PTR pWorkArea;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmSwapAlias()"));

   pItem = hb_stackItemFromTop( -1 );
   pWorkArea = hb_stackItemFromTop( -2 );

   hb_vmSelectWorkarea( pWorkArea, NULL );

   hb_itemMove( pWorkArea, pItem );
   hb_stackDec();
}

/* ------------------------------- */
hvm.c5266
HB_EXPORT VOIDhb_vmDo( USHORT uiParams )
HB_EXPORT void hb_vmDo( USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD
   HB_STACK_STATE sStackState;
   PHB_SYMB pSym;
   PHB_ITEM pSelf;
#ifndef HB_NO_DEBUG
   BOOL bDebugPrevState;
#endif
#ifndef HB_NO_PROFILER
   ULONG ulClock = 0;
   BOOL bProfiler = hb_bProfiler; /* because profiler state may change */
#endif

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDo(%hu)", uiParams));

#ifndef HB_NO_PROFILER
   if( bProfiler )
      ulClock = ( ULONG ) clock();
#endif

   /* Poll the console keyboard
   #if !defined( HB_GUI )
      hb_inkeyPoll();
   #endif
   */

   pSym = hb_stackNewFrame( &sStackState, uiParams )->item.asSymbol.value;
   pSelf = hb_stackSelfItem();   /* NIL, OBJECT or BLOCK */
#ifndef HB_NO_DEBUG
   bDebugPrevState = s_bDebugging;
   s_bDebugging = FALSE;
#endif

   if( ! HB_IS_NIL( pSelf ) ) /* are we sending a message ? */
   {
      PHB_SYMB pExecSym;

      pExecSym = hb_objGetMethod( pSelf, pSym, &sStackState );
      if( pExecSym && ( pExecSym->scope.value & HB_FS_DEFERRED ) && pExecSym->pDynSym )
         pExecSym = pExecSym->pDynSym->pSymbol;
      if( pExecSym && pExecSym->value.pFunPtr )
      {
         HB_TRACE_PRG(("Calling: %s:%s", hb_objGetClsName( pSelf ), pSym->szName));
         if( pExecSym->scope.value & HB_FS_PCODEFUNC )
            /* Running pCode dynamic function from .hrb */
            hb_vmExecute( pExecSym->value.pCodeFunc->pCode,
                          pExecSym->value.pCodeFunc->pSymbols );
         else
            pExecSym->value.pFunPtr();

#ifndef HB_NO_PROFILER
         if( bProfiler )
            hb_mthAddTime( clock() - ulClock );
#endif
      }
      else if( pSym->szName[ 0 ] == '_' )
         hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + 1, HB_ERR_ARGS_SELFPARAMS );
      else
         hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, pSym->szName, HB_ERR_ARGS_SELFPARAMS );
   }
   else /* it is a function */
   {
      if( ( pSym->scope.value & HB_FS_DEFERRED ) && pSym->pDynSym )
         pSym = pSym->pDynSym->pSymbol;
      if( pSym->value.pFunPtr )
      {
         HB_TRACE_PRG(("Calling: %s", pSym->szName));
#ifndef HB_NO_PROFILER
         if( bProfiler && pSym->pDynSym )
            pSym->pDynSym->ulRecurse++;
#endif
         /* Running pCode dynamic function from .hrb? */
         if( pSym->scope.value & HB_FS_PCODEFUNC )
            hb_vmExecute( pSym->value.pCodeFunc->pCode,
                          pSym->value.pCodeFunc->pSymbols );
         else
            pSym->value.pFunPtr();

#ifndef HB_NO_PROFILER
         if( bProfiler && pSym->pDynSym )
         {
            pSym->pDynSym->ulCalls++;                   /* profiler support */
            /* Time spent has to be added only inside topmost call of a recursive function */
            if( --pSym->pDynSym->ulRecurse == 0 )
               pSym->pDynSym->ulTime += clock() - ulClock; /* profiler support */
         }
#endif
      }
      else
         hb_errRT_BASE_SubstR( EG_NOFUNC, 1001, NULL, pSym->szName, HB_ERR_ARGS_BASEPARAMS );
   }

#ifndef HB_NO_DEBUG
   if( s_bDebugging )
      hb_vmDebuggerEndProc();
   s_bDebugging = bDebugPrevState;
#endif

   hb_stackOldFrame( &sStackState );
}
hvm.c5290
HB_EXPORT VOIDhb_vmSend( USHORT uiParams )
HB_EXPORT void hb_vmSend( USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD
   HB_STACK_STATE sStackState;
   PHB_SYMB pSym;
   PHB_SYMB pExecSym;
   PHB_ITEM pSelf;
#ifndef HB_NO_DEBUG
   BOOL bDebugPrevState;
#endif
#ifndef HB_NO_PROFILER
   ULONG ulClock = 0;
   BOOL bProfiler = hb_bProfiler; /* because profiler state may change */
#endif

   HB_TRACE(HB_TR_DEBUG, ("hb_vmSend(%hu)", uiParams));

#ifndef HB_NO_PROFILER
   if( bProfiler )
      ulClock = ( ULONG ) clock();
#endif

   /* Poll the console keyboard
   #if !defined( HB_GUI )
      hb_inkeyPoll();
   #endif
   */

   pSym = hb_stackNewFrame( &sStackState, uiParams )->item.asSymbol.value;
   pSelf = hb_stackSelfItem();   /* NIL, OBJECT or BLOCK */
#ifndef HB_NO_DEBUG
   bDebugPrevState = s_bDebugging;
   s_bDebugging = FALSE;
#endif

   pExecSym = hb_objGetMethod( pSelf, pSym, &sStackState );
   if( pExecSym && ( pExecSym->scope.value & HB_FS_DEFERRED ) && pExecSym->pDynSym )
      pExecSym = pExecSym->pDynSym->pSymbol;
   if( pExecSym && pExecSym->value.pFunPtr )
   {
      HB_TRACE_PRG(("Calling: %s:%s", hb_objGetClsName( pSelf ), pSym->szName));

      if( pExecSym->scope.value & HB_FS_PCODEFUNC )
         /* Running pCode dynamic function from .hrb */
         hb_vmExecute( pExecSym->value.pCodeFunc->pCode,
                    pExecSym->value.pCodeFunc->pSymbols );
      else
         pExecSym->value.pFunPtr();

#ifndef HB_NO_PROFILER
      if( bProfiler )
         hb_mthAddTime( clock() - ulClock );
#endif
   }
   else if( pSym->szName[ 0 ] == '_' )
      hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + 1, HB_ERR_ARGS_SELFPARAMS );
   else
      hb_errRT_BASE_SubstR( EG_NOMETHOD, 1004, NULL, pSym->szName, HB_ERR_ARGS_SELFPARAMS );

#ifndef HB_NO_DEBUG
   if( s_bDebugging )
      hb_vmDebuggerEndProc();
   s_bDebugging = bDebugPrevState;
#endif

   hb_stackOldFrame( &sStackState );
}
hvm.c5392
STATIC VOIDhb_vmPushObjectVarRef( void )
static void hb_vmPushObjectVarRef( void )
{
   HB_STACK_TLS_PRELOAD
   HB_STACK_STATE sStackState;
   PHB_ITEM pItem;
   PHB_SYMB pSym;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushObjectVarRef()"));

   pItem = hb_stackNewFrame( &sStackState, 0 );   /* procedure name */
   pSym = pItem->item.asSymbol.value;

   if( !hb_objGetVarRef( hb_stackSelfItem(), pSym, &sStackState ) &&
       hb_vmRequestQuery() == 0 )
      hb_errRT_BASE_SubstR( EG_NOVARMETHOD, 1005, NULL, pSym->szName + ( pSym->szName[ 0 ] == '_' ? 1 : 0 ), 1, hb_stackSelfItem() );

   hb_stackOldFrame( &sStackState );

   hb_stackPushReturn();
}
hvm.c5460
STATIC HARBOURhb_vmDoBlock( void )
static HARBOUR hb_vmDoBlock( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pBlock;
   int iParam;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDoBlock()"));

   pBlock = hb_stackSelfItem();

   if( ! HB_IS_BLOCK( pBlock ) )
      hb_errInternal( HB_EI_VMNOTCBLOCK, NULL, "hb_vmDoBlock()", NULL );

   /* Check for valid count of parameters */
   iParam = pBlock->item.asBlock.paramcnt - hb_pcount();
   hb_stackBaseItem()->item.asSymbol.paramdeclcnt =
               pBlock->item.asBlock.paramcnt;

   /* add missing parameters */
   while( --iParam >= 0 )
      hb_vmPushNil();

   /* set the current line number to a line where the codeblock was defined
    */
   hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo = pBlock->item.asBlock.lineno;
   hb_stackBaseItem()->item.asSymbol.stackstate->uiClass  = pBlock->item.asBlock.hclass;
   hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod = pBlock->item.asBlock.method;

   hb_codeblockEvaluate( pBlock );
}
hvm.c5481
HB_ITEM_PTRhb_vmEvalBlock( HB_ITEM_PTR pBlock )
HB_ITEM_PTR hb_vmEvalBlock( HB_ITEM_PTR pBlock )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEvalBlock(%p)", pBlock));

   hb_vmPushSymbol( &hb_symEval );
   hb_vmPush( pBlock );
   hb_vmSend( 0 );
   return hb_stackReturnItem();
}
hvm.c5512
HB_ITEM_PTRhb_vmEvalBlockV( HB_ITEM_PTR pBlock, ULONG ulArgCount, ... )
HB_ITEM_PTR hb_vmEvalBlockV( HB_ITEM_PTR pBlock, ULONG ulArgCount, ... )
{
   HB_STACK_TLS_PRELOAD
   va_list va;
   ULONG i;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEvalBlockV(%p, %hu, ...)", pBlock, ulArgCount));

   hb_vmPushSymbol( &hb_symEval );
   hb_vmPush( pBlock );

   va_start( va, ulArgCount );
   for( i = 1; i <= ulArgCount; i++ )
      hb_vmPush( va_arg( va, PHB_ITEM ) );
   va_end( va );

   /* take care here, possible loss of data long to short ... */
   /* added an explicit casting here for VC++ JFL */
   hb_vmSend( ( USHORT ) ulArgCount );

   return hb_stackReturnItem();
}
hvm.c5526
HB_EXPORT PHB_ITEMhb_vmEvalBlockOrMacro( PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_vmEvalBlockOrMacro( PHB_ITEM pItem )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEvalBlockOrMacro(%p)", pItem));

   if( HB_IS_BLOCK( pItem ) )
   {
      hb_vmPushSymbol( &hb_symEval );
      hb_vmPush( pItem );
      hb_vmSend( 0 );
   }
   else
   {
      HB_MACRO_PTR pMacro = ( HB_MACRO_PTR ) hb_itemGetPtr( pItem );
      if( pMacro )
      {
         hb_macroRun( pMacro );
         hb_stackPopReturn();
      }
      else
      {
         hb_itemSetNil( hb_stackReturnItem() );
      }
   }
   return hb_stackReturnItem();
}
hvm.c5557
HB_EXPORT VOIDhb_vmDestroyBlockOrMacro( PHB_ITEM pItem )
HB_EXPORT void hb_vmDestroyBlockOrMacro( PHB_ITEM pItem )
{
   if( HB_IS_POINTER( pItem ) )
   {
      HB_MACRO_PTR pMacro = ( HB_MACRO_PTR ) hb_itemGetPtr( pItem );
      if( pMacro )
      {
         hb_macroDelete( pMacro );
      }
   }
   hb_itemRelease( pItem );
}
hvm.c5587
VOIDhb_vmFunction( USHORT uiParams )
void hb_vmFunction( USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmFunction(%hu)", uiParams));

   hb_itemSetNil( hb_stackReturnItem() );
   hb_vmDo( uiParams );
}
hvm.c5605
STATIC VOIDhb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDebugEntry"));

   HB_SYMBOL_UNUSED( nFrame );

   switch( nMode )
   {
      case HB_DBG_MODULENAME:
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_MODULENAME );
         hb_vmPushString( szName, strlen( szName ) );
         hb_vmDo( 2 );
         break;

      case HB_DBG_LOCALNAME:
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_LOCALNAME );
         hb_vmPushInteger( nIndex );
         hb_vmPushString( szName, strlen( szName ) );
         hb_vmDo( 3 );
         break;

      case HB_DBG_STATICNAME:
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_STATICNAME );
         hb_vmPushLong( hb_stackGetStaticsBase() );   /* current static frame */
         hb_vmPushInteger( nIndex );                  /* variable index */
         hb_vmPushString( szName, strlen( szName ) );
         hb_vmDo( 4 );
         break;

      case HB_DBG_ENDPROC:
         hb_stackPushReturn();      /* saves the previous returned value */
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_ENDPROC );
         hb_vmDo( 1 );
         hb_stackPopReturn();       /* restores the previous returned value */
         break;

      case HB_DBG_SHOWLINE:
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_SHOWLINE );
         hb_vmPushInteger( nLine );
         hb_vmDo( 2 );
         break;

      case HB_DBG_GETENTRY:
         /* Try to get C dbgEntry() function pointer */
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_GETENTRY );
         hb_vmDo( 1 );
         break;

      case HB_DBG_VMQUIT:
         hb_vmPushDynSym( s_pDynsDbgEntry );
         hb_vmPushNil();
         hb_vmPushInteger( HB_DBG_VMQUIT );
         hb_vmDo( 1 );
         break;
   }
}
hvm.c5616
STATIC VOIDhb_vmDummyDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
static void hb_vmDummyDebugEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmDummyDebugEntry"));

   HB_SYMBOL_UNUSED( nMode );
   HB_SYMBOL_UNUSED( nLine );
   HB_SYMBOL_UNUSED( szName );
   HB_SYMBOL_UNUSED( nIndex );
   HB_SYMBOL_UNUSED( nFrame );
}
hvm.c5687
STATIC VOIDhb_vmDebuggerExit( void )
static void hb_vmDebuggerExit( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerExit"));

   /* is debugger linked ? */
   if( s_pFunDbgEntry )
   {
      s_bDebugging = FALSE;
      /* inform debugger that we are quitting now */
      s_pFunDbgEntry( HB_DBG_VMQUIT, 0, NULL, 0, 0 );
      /* set dummy debugger function to avoid debugger activation in .prg
       *       destructors if any */
      s_pFunDbgEntry = hb_vmDummyDebugEntry;
   }
}
hvm.c5698
STATIC VOIDhb_vmLocalName( USHORT uiLocal, char * szLocalName )
static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ) /* locals and parameters index and name information for the debugger */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmLocalName(%hu, %s)", uiLocal, szLocalName));

   if( s_bDebugging )
   {
      s_bDebugging = FALSE;
      s_pFunDbgEntry( HB_DBG_LOCALNAME, 0, szLocalName, uiLocal, 0 );
      s_bDebugging = TRUE;
   }
}
hvm.c5714
STATIC VOIDhb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName )
static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ) /* statics vars information for the debugger */
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmStaticName(%hu, %s)", uiStatic, szStaticName));

   HB_SYMBOL_UNUSED( bIsGlobal );

   if( s_bDebugging )
   {
      s_bDebugging = FALSE;
      s_pFunDbgEntry( HB_DBG_STATICNAME, 0, szStaticName, uiStatic, hb_stackGetStaticsBase() );
      s_bDebugging = TRUE;
   }
}
hvm.c5726
STATIC VOIDhb_vmModuleName( char * szModuleName )
static void hb_vmModuleName( char * szModuleName ) /* PRG and function name information for the debugger */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmModuleName(%s)", szModuleName));

#ifdef HB_NO_DEBUG
   HB_SYMBOL_UNUSED( szModuleName );
#else
   if( s_pFunDbgEntry )
   {
      s_bDebugging = FALSE;
      s_pFunDbgEntry( HB_DBG_MODULENAME, 0, szModuleName, 0, 0 );
      s_bDebugging = TRUE;
   }
#endif
}
hvm.c5742
STATIC VOIDhb_vmDebuggerEndProc( void )
static void hb_vmDebuggerEndProc( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerEndProc()"));

   s_bDebugging = FALSE;
   s_pFunDbgEntry( HB_DBG_ENDPROC, 0, NULL, 0, 0 );
}
hvm.c5759
STATIC VOIDhb_vmDebuggerShowLine( USHORT uiLine )
static void hb_vmDebuggerShowLine( USHORT uiLine ) /* makes the debugger shows a specific source code line */
{
   BOOL bDebugging = s_bDebugging;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDebuggerShowLine(%hu)", uiLine));

   s_bDebugging = FALSE;
   s_pFunDbgEntry( HB_DBG_SHOWLINE, uiLine, NULL, 0, 0 );
   s_bDebugging = bDebugging;
}
hvm.c5767
STATIC VOIDhb_vmFrame( USHORT usLocals, BYTE bParams )
static void hb_vmFrame( USHORT usLocals, BYTE bParams )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pBase;
   int iTotal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmFrame(%d, %d)", (int) usLocals, (int) bParams));

   pBase = hb_stackBaseItem();

#if 0
   /* This old code which clears additional parameters to make space for
    * local variables without updating pBase->item.asSymbol.paramdeclcnt
    */
   iTotal = pBase->item.asSymbol.paramcnt - bParams;
   if( iTotal > 0 )
   {
      pBase->item.asSymbol.paramcnt = bParams;
      do
         hb_itemClear( hb_stackItemFromTop( -iTotal ) );
      while( --iTotal > 0 );
   }

   iTotal = usLocals + bParams;
   if( iTotal )
   {
      iTotal -= pBase->item.asSymbol.paramcnt;
      while( --iTotal >= 0 )
         hb_vmPushNil();
   }
#else
   pBase->item.asSymbol.paramdeclcnt = bParams;

   iTotal = bParams - pBase->item.asSymbol.paramcnt;
   if( iTotal < 0 )
      iTotal = 0;
   iTotal += usLocals;

   if( iTotal )
   {
      do
         hb_vmPushNil();
      while( --iTotal > 0 );
   }
#endif
}
hvm.c5779
STATIC VOIDhb_vmVFrame( USHORT usLocals, BYTE bParams )
static void hb_vmVFrame( USHORT usLocals, BYTE bParams )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pBase;
   int iTotal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmVFrame(%d, %d)", (int) usLocals, (int) bParams));

   pBase = hb_stackBaseItem();

   pBase->item.asSymbol.paramdeclcnt = bParams;

   iTotal = bParams - pBase->item.asSymbol.paramcnt;
   if( iTotal < 0 )
      iTotal = 0;
   iTotal += usLocals;

   if( iTotal )
   {
      do
         hb_vmPushNil();
      while( --iTotal > 0 );
   }
}
hvm.c5826
STATIC VOIDhb_vmSFrame( PHB_SYMB pSym )
static void hb_vmSFrame( PHB_SYMB pSym )      /* sets the statics frame for a function */
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmSFrame(%p)", pSym));

   /* _INITSTATICS is now the statics frame. Statics() changed it! */
   hb_stackSetStaticsBase( pSym->value.lStaticsBase );
}
hvm.c5851
STATIC VOIDhb_vmStatics( PHB_SYMB pSym, USHORT uiStatics )
static void hb_vmStatics( PHB_SYMB pSym, USHORT uiStatics ) /* initializes the global aStatics array or redimensionates it */
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmStatics(%p, %hu)", pSym, uiStatics));

   if( HB_IS_NIL( &s_aStatics ) )
   {
      pSym->value.lStaticsBase = 0;         /* statics frame for this PRG */
      hb_arrayNew( &s_aStatics, uiStatics );
   }
   else
   {
      pSym->value.lStaticsBase = hb_arrayLen( &s_aStatics );
      hb_arraySize( &s_aStatics, ( ULONG ) pSym->value.lStaticsBase + uiStatics );
   }
}

#if defined( HB_MT_VM )
/*
 * extended thread static variable reference structure
 */
typedef struct
{
   HB_ITEM  source;
   HB_TSD   threadData;
} HB_TSVREF, * PHB_TSVREF;
hvm.c5861
STATIC PHB_ITEMhb_vmTSVRefRead( PHB_ITEM pRefer )
static PHB_ITEM hb_vmTSVRefRead( PHB_ITEM pRefer )
{
   PHB_TSVREF pTSVRef = ( PHB_TSVREF ) pRefer->item.asExtRef.value;
   PHB_ITEM pItem = ( PHB_ITEM ) hb_stackTestTSD( &pTSVRef->threadData );
   if( !pItem )
   {
      pItem = ( PHB_ITEM ) hb_stackGetTSD( &pTSVRef->threadData );
      hb_itemCopy( pItem, &pTSVRef->source );
   }
   return pItem;
}
hvm.c5887
STATIC PHB_ITEMhb_vmTSVRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
static PHB_ITEM hb_vmTSVRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
{
   PHB_TSVREF pTSVRef = ( PHB_TSVREF ) pRefer->item.asExtRef.value;
   HB_SYMBOL_UNUSED( pSource );
   return ( PHB_ITEM ) hb_stackGetTSD( &pTSVRef->threadData );
}
hvm.c5902
STATIC VOIDhb_vmTSVRefCopy( PHB_ITEM pDest )
static void hb_vmTSVRefCopy( PHB_ITEM pDest )
{
   hb_xRefInc( pDest->item.asExtRef.value );
}
hvm.c5909
STATIC VOIDhb_vmTSVRefClear( void * value )
static void hb_vmTSVRefClear( void * value )
{
   if( hb_xRefDec( value ) )
   {
      PHB_ITEM pItem;

      if( HB_IS_COMPLEX( &( ( PHB_TSVREF ) value )->source ) )
         hb_itemClear( &( ( PHB_TSVREF ) value )->source );

      pItem = ( PHB_ITEM ) hb_stackTestTSD( &( ( PHB_TSVREF ) value )->threadData );
      if( pItem && HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );

      hb_xfree( value );
   }
}
hvm.c5914
STATIC VOIDhb_vmTSVRefMark( void * value )
static void hb_vmTSVRefMark( void * value )
{
   PHB_ITEM pItem;

   if( HB_IS_GCITEM( &( ( PHB_TSVREF ) value )->source ) )
      hb_gcItemRef( &( ( PHB_TSVREF ) value )->source );

   pItem = ( PHB_ITEM ) hb_stackTestTSD( &( ( PHB_TSVREF ) value )->threadData );
   if( pItem && HB_IS_GCITEM( pItem ) )
      hb_gcItemRef( pItem );
}
hvm.c5931
VOIDhb_vmTSVarClean( void * pThreadItem )
void hb_vmTSVarClean( void * pThreadItem )
{
   if( HB_IS_COMPLEX( ( PHB_ITEM ) pThreadItem ) )
      hb_itemClear( ( PHB_ITEM ) pThreadItem );
}
hvm.c5943
STATIC VOIDhb_vmTSVReference( PHB_ITEM pStatic )
static void hb_vmTSVReference( PHB_ITEM pStatic )
{
   static const HB_EXTREF s_TSVExtRef = {
             hb_vmTSVRefRead,
             hb_vmTSVRefWrite,
             hb_vmTSVRefCopy,
             hb_vmTSVRefClear,
             hb_vmTSVRefMark };

   HB_STACK_TLS_PRELOAD
   PHB_TSVREF pTSVRef;
   PHB_ITEM pRefer;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmTSVReference(%p)", pStatic));

   pTSVRef = ( PHB_TSVREF ) hb_xgrab( sizeof( HB_TSVREF ) );

   pTSVRef->source.type = HB_IT_NIL;
   HB_TSD_INIT( &pTSVRef->threadData, sizeof( HB_ITEM ), NULL, hb_vmTSVarClean );

   /* Use hb_stackReturnItem() as temporary item holder */
   pRefer = hb_stackReturnItem();
   pRefer->type = HB_IT_BYREF | HB_IT_EXTREF;
   pRefer->item.asExtRef.value = ( void * ) pTSVRef;
   pRefer->item.asExtRef.func = &s_TSVExtRef;

   hb_itemMove( &pTSVRef->source, pStatic );
   hb_itemMove( pStatic, pRefer );
}
hvm.c5950
STATIC VOIDhb_vmInitThreadStatics( USHORT uiCount, const BYTE * pCode )
static void hb_vmInitThreadStatics( USHORT uiCount, const BYTE * pCode )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmInitThreadStatics(%p,%hu,%p)", uiCount, pCode));

   while( uiCount-- )
   {
      USHORT uiStatic = HB_PCODE_MKUSHORT( pCode );
      PHB_ITEM pStatic = s_aStatics.item.asArray.value->pItems + hb_stackGetStaticsBase() + uiStatic - 1;
      hb_vmTSVReference( pStatic );
      pCode += 2;
   }
}
hvm.c5983
STATIC VOIDhb_vmInitThreadStatics( USHORT uiCount, const BYTE * pCode )
static void hb_vmInitThreadStatics( USHORT uiCount, const BYTE * pCode )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmInitThreadStatics(%p,%hu,%p)", uiCount, pCode));

   /* single thread VM - do nothing, use normal static variables */

   HB_SYMBOL_UNUSED( uiCount );
   HB_SYMBOL_UNUSED( pCode );
}
hvm.c5998
STATIC VOIDhb_vmEndBlock( void )
static void hb_vmEndBlock( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmEndBlock()"));

   hb_stackPopReturn();
}
hvm.c6011
STATIC VOIDhb_vmRetValue( void )
static void hb_vmRetValue( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRetValue()"));

   hb_stackPopReturn();
   hb_stackReturnItem()->type &= ~HB_IT_MEMOFLAG;
}

/* ------------------------------- */
hvm.c6020
HB_EXPORT VOIDhb_vmPush( PHB_ITEM pItem )
HB_EXPORT void hb_vmPush( PHB_ITEM pItem )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPush(%p)", pItem));

   hb_itemCopy( hb_stackAllocItem(), pItem );
}
hvm.c6034
HB_EXPORT VOIDhb_vmPushState( void )
HB_EXPORT void hb_vmPushState( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushState()"));

   hb_stackPushReturn();
}
hvm.c6043
HB_EXPORT VOIDhb_vmPushNil( void )
HB_EXPORT void hb_vmPushNil( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushNil()"));

   hb_stackAllocItem()->type = HB_IT_NIL;
}
hvm.c6052
HB_EXPORT VOIDhb_vmPushLogical( BOOL bValue )
HB_EXPORT void hb_vmPushLogical( BOOL bValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLogical(%d)", (int) bValue));

   pItem->type = HB_IT_LOGICAL;
   pItem->item.asLogical.value = bValue;
}
hvm.c6061
HB_EXPORT VOIDhb_vmPushNumber( double dNumber, int iDec )
HB_EXPORT void hb_vmPushNumber( double dNumber, int iDec )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushNumber(%lf, %d)", dNumber, iDec));

   if( iDec )
      hb_vmPushDouble( dNumber, iDec );

   else if( HB_DBL_LIM_INT( dNumber ) )
      hb_vmPushInteger( ( int ) dNumber );

   else if( HB_DBL_LIM_LONG( dNumber ) )
      hb_vmPushHBLong( ( HB_LONG ) dNumber );

   else
      hb_vmPushDouble( dNumber, hb_stackSetStruct()->HB_SET_DECIMALS );
}
hvm.c6072
STATIC INThb_vmCalcIntWidth( HB_LONG lNumber )
static int hb_vmCalcIntWidth( HB_LONG lNumber )
{
   int iWidth;

   if( lNumber <= -1000000000L )
   {
      iWidth = 20;
   }
   else
   {
      iWidth = 10;
      while( lNumber >= 1000000000L )
      {
         iWidth++;
         lNumber /= 10;
      }
   }
   return iWidth;
}
hvm.c6092
HB_EXPORT VOIDhb_vmPushInteger( int iNumber )
HB_EXPORT void hb_vmPushInteger( int iNumber )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushInteger(%d)", iNumber));

   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = iNumber;
   pItem->item.asInteger.length = HB_INT_LENGTH( iNumber );
}
hvm.c6112
STATIC VOIDhb_vmPushIntegerConst( int iNumber )
static void hb_vmPushIntegerConst( int iNumber )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushIntegerConst(%d)", iNumber));

   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = iNumber;
   pItem->item.asInteger.length = hb_vmCalcIntWidth( iNumber );
}
hvm.c6125
STATIC VOIDhb_vmPushLongConst( long lNumber )
static void hb_vmPushLongConst( long lNumber )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLongConst(%ld)", lNumber));

   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = ( HB_LONG ) lNumber;
   pItem->item.asLong.length = hb_vmCalcIntWidth( lNumber );
}
hvm.c6137
HB_EXPORT VOIDhb_vmPushLong( long lNumber )
HB_EXPORT void hb_vmPushLong( long lNumber )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLong(%ld)", lNumber));

#if HB_INT_MAX >= LONG_MAX
   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = ( int ) lNumber;
   pItem->item.asInteger.length = HB_INT_LENGTH( lNumber );
#else
   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = ( HB_LONG ) lNumber;
   pItem->item.asLong.length = HB_LONG_LENGTH( lNumber );
#endif
}
hvm.c6151
STATIC VOIDhb_vmPushHBLong( HB_LONG lNumber )
static void hb_vmPushHBLong( HB_LONG lNumber )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushHBLong(%" PFHL "d)", lNumber));

   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = lNumber;
   pItem->item.asLong.length = HB_LONG_LENGTH( lNumber );
}
hvm.c6169
STATIC VOIDhb_vmPushLongLongConst( LONGLONG llNumber )
static void hb_vmPushLongLongConst( LONGLONG llNumber )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLongLongConst(%" PFLL "d)", llNumber));

   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = ( HB_LONG ) llNumber;
   pItem->item.asLong.length = hb_vmCalcIntWidth( llNumber );
}
hvm.c6182
HB_EXPORT VOIDhb_vmPushNumInt( HB_LONG lNumber )
HB_EXPORT void hb_vmPushNumInt( HB_LONG lNumber )
{
   if( HB_LIM_INT( lNumber ) )
      hb_vmPushInteger( ( int ) lNumber );
   else
      hb_vmPushHBLong( lNumber );
}
hvm.c6195
HB_EXPORT VOIDhb_vmPushDouble( double dNumber, int iDec )
HB_EXPORT void hb_vmPushDouble( double dNumber, int iDec )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushDouble(%lf, %d)", dNumber, iDec));

   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.value = dNumber;
   pItem->item.asDouble.length = HB_DBL_LENGTH( dNumber );
   if( iDec == HB_DEFAULT_DECIMALS )
      pItem->item.asDouble.decimal = hb_stackSetStruct()->HB_SET_DECIMALS;
   else
      pItem->item.asDouble.decimal = iDec;
}
hvm.c6203
STATIC VOIDhb_vmPushDoubleConst( double dNumber, int iWidth, int iDec )
static void hb_vmPushDoubleConst( double dNumber, int iWidth, int iDec )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushDoubleConst(%lf, %d, %d)", dNumber, iWidth, iDec));

   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.value = dNumber;

   if( iDec == HB_DEFAULT_DECIMALS )
      pItem->item.asDouble.decimal = hb_stackSetStruct()->HB_SET_DECIMALS;
   else
      pItem->item.asDouble.decimal = iDec;

   if( iWidth == HB_DEFAULT_WIDTH )
      pItem->item.asDouble.length = HB_DBL_LENGTH( dNumber );
   else
      pItem->item.asDouble.length = iWidth;
}
hvm.c6219
HB_EXPORT VOIDhb_vmPushDate( long lDate )
HB_EXPORT void hb_vmPushDate( long lDate )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushDate(%ld)", lDate));

   pItem->type = HB_IT_DATE;
   pItem->item.asDate.value = lDate;
}
hvm.c6240
HB_EXPORT VOIDhb_vmPushPointer( void * pPointer )
HB_EXPORT void hb_vmPushPointer( void * pPointer )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushPointer(%ld)", pPointer));

   pItem->type = HB_IT_POINTER;
   pItem->item.asPointer.value = pPointer;
   pItem->item.asPointer.collect =
   pItem->item.asPointer.single = FALSE;
}
hvm.c6251
HB_EXPORT VOIDhb_vmPushString( const char * szText, ULONG length )
HB_EXPORT void hb_vmPushString( const char * szText, ULONG length )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushString(%s, %lu)", szText, length));

   hb_itemPutCL( hb_stackAllocItem(), szText, length );
}
hvm.c6264
HB_EXPORT VOIDhb_vmPushStringPcode( const char * szText, ULONG length )
HB_EXPORT void hb_vmPushStringPcode( const char * szText, ULONG length )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushStringPcode(%s, %lu)", szText, length));

   pItem->type = HB_IT_STRING;
   pItem->item.asString.length    = length;
   pItem->item.asString.allocated = 0;
   pItem->item.asString.value     = ( char * ) szText;
}
hvm.c6273
HB_EXPORT VOIDhb_vmPushSymbol( PHB_SYMB pSym )
HB_EXPORT void hb_vmPushSymbol( PHB_SYMB pSym )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushSymbol(%p)", pSym));

   pItem->type = HB_IT_SYMBOL;
   pItem->item.asSymbol.value = pSym;
   pItem->item.asSymbol.stackstate = NULL;
}
hvm.c6286
HB_EXPORT VOIDhb_vmPushDynSym( PHB_DYNS pDynSym )
HB_EXPORT void hb_vmPushDynSym( PHB_DYNS pDynSym )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushDynSym(%p)", pDynSym));

   pItem->type = HB_IT_SYMBOL;
   pItem->item.asSymbol.value = pDynSym->pSymbol;
   pItem->item.asSymbol.stackstate = NULL;
}
hvm.c6298
HB_EXPORT VOIDhb_vmPushEvalSym( void )
HB_EXPORT void hb_vmPushEvalSym( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushEvalSym()"));

   pItem->type = HB_IT_SYMBOL;
   pItem->item.asSymbol.value = &hb_symEval;
   pItem->item.asSymbol.stackstate = NULL;
}
hvm.c6310
STATIC VOIDhb_vmPushBlock( const BYTE * pCode, PHB_SYMB pSymbols, ULONG ulLen )
static void hb_vmPushBlock( const BYTE * pCode, PHB_SYMB pSymbols, ULONG ulLen )
{
   HB_STACK_TLS_PRELOAD
   USHORT uiLocals;
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushBlock(%p,%p,%lu)", pCode, pSymbols, ulLen));

   uiLocals = HB_PCODE_MKUSHORT( &pCode[ 2 ] );

   if( ulLen )
      ulLen -= uiLocals << 1;

   pItem->item.asBlock.value =
         hb_codeblockNew( pCode + 4 + ( uiLocals << 1 ),/* pcode buffer         */
         uiLocals,                                      /* number of referenced local variables */
         pCode + 4,                                     /* table with referenced local variables */
         pSymbols,
         ulLen );

   pItem->type = HB_IT_BLOCK;
   /* store the number of expected parameters
    */
   pItem->item.asBlock.paramcnt = HB_PCODE_MKUSHORT( pCode );
   /* store the line number where the codeblock was defined
    */
   pItem->item.asBlock.lineno = hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo;
   pItem->item.asBlock.hclass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;
   pItem->item.asBlock.method = hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
}
hvm.c6322
STATIC VOIDhb_vmPushBlockShort( const BYTE * pCode, PHB_SYMB pSymbols, ULONG ulLen )
static void hb_vmPushBlockShort( const BYTE * pCode, PHB_SYMB pSymbols, ULONG ulLen )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushBlockShort(%p,%p,%hu)", pCode, pSymbols, ulLen));

   pItem->item.asBlock.value =
         hb_codeblockNew( pCode,                    /* pcode buffer         */
         0,                                         /* number of referenced local variables */
         NULL,                                      /* table with referenced local variables */
         pSymbols,
         ulLen );

   pItem->type = HB_IT_BLOCK;

   /* store the number of expected parameters
    */
   pItem->item.asBlock.paramcnt = 0;
   /* store the line number where the codeblock was defined
    */
   pItem->item.asBlock.lineno = hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo;
   pItem->item.asBlock.hclass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;
   pItem->item.asBlock.method = hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
}
hvm.c6361
STATIC VOIDhb_vmPushMacroBlock( const BYTE * pCode, ULONG ulSize, USHORT usParams )
static void hb_vmPushMacroBlock( const BYTE * pCode, ULONG ulSize, USHORT usParams )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushMacroBlock(%p,%lu,%hu)", pCode, ulSize, usParams));

   pItem->item.asBlock.value = hb_codeblockMacroNew( pCode, ulSize );
   pItem->type = HB_IT_BLOCK;

   /* store the number of expected parameters
    */
   pItem->item.asBlock.paramcnt = usParams;
   /* store the line number where the codeblock was defined
    */
   pItem->item.asBlock.lineno = hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo;
   pItem->item.asBlock.hclass = hb_stackBaseItem()->item.asSymbol.stackstate->uiClass;
   pItem->item.asBlock.method = hb_stackBaseItem()->item.asSymbol.stackstate->uiMethod;
}
hvm.c6393
STATIC VOIDhb_vmPushAlias( void )
static void hb_vmPushAlias( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushAlias()"));

   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = hb_rddGetCurrentWorkAreaNumber();
   pItem->item.asInteger.length = 10;
}
hvm.c6420
STATIC VOIDhb_vmPushAliasedField( PHB_SYMB pSym )
static void hb_vmPushAliasedField( PHB_SYMB pSym )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pAlias;
   int iCurrArea;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushAliasedField(%p)", pSym));

   iCurrArea = hb_rddGetCurrentWorkAreaNumber();
   pAlias = hb_stackItemFromTop( -1 );

   /*
    * NOTE: hb_vmSelecWorkarea clears passed item
    */
   if( hb_vmSelectWorkarea( pAlias, pSym ) == SUCCESS )
      hb_rddGetFieldValue( pAlias, pSym );

   hb_rddSelectWorkAreaNumber( iCurrArea );
}
hvm.c6434
STATIC VOIDhb_vmPushAliasedVar( PHB_SYMB pSym )
static void hb_vmPushAliasedVar( PHB_SYMB pSym )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pAlias = hb_stackItemFromTop( -1 );

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushAliasedVar(%p)", pSym));

   if( HB_IS_STRING( pAlias ) )
   {
      char * szAlias = pAlias->item.asString.value;

      if( szAlias[ 0 ] == 'M' || szAlias[ 0 ] == 'm' )
      {
         if( pAlias->item.asString.length == 1 || /* M->variable */
             ( pAlias->item.asString.length >= 4 &&
               hb_strnicmp( szAlias, "MEMVAR", /* MEMVAR-> or MEMVA-> or MEMV-> */
                                     pAlias->item.asString.length ) == 0 ) )
         {
            hb_memvarGetValue( pAlias, pSym );
            return;
         }
      }
      else if( pAlias->item.asString.length >= 4 &&
               ( hb_strnicmp( szAlias, "FIELD", /* FIELD-> or FIEL-> */
                                       pAlias->item.asString.length ) == 0 ||
                 hb_strnicmp( szAlias, "_FIELD", /* _FIELD-> or _FIE-> */
                                       pAlias->item.asString.length ) == 0 ) )
      {
         hb_rddGetFieldValue( pAlias, pSym );
         return;
      }
   }
   hb_vmPushAliasedField( pSym );
}
hvm.c6458
STATIC VOIDhb_vmPushLocal( int iLocal )
static void hb_vmPushLocal( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLocal(%d)", iLocal));

   if( iLocal >= 0 )
   {
      /* local variable or local parameter */
      pLocal = hb_stackLocalVariable( &iLocal );
   }
   else
   {
      /* local variable referenced in a codeblock
       * hb_stackSelfItem() points to a codeblock that is currently evaluated
       */
      pLocal = hb_codeblockGetRef( hb_stackSelfItem()->item.asBlock.value, ( LONG ) iLocal );
   }

   hb_itemCopy( hb_stackAllocItem(),
                HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal );
}
hvm.c6499
STATIC VOIDhb_vmPushLocalByRef( int iLocal )
static void hb_vmPushLocalByRef( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pTop = hb_stackAllocItem();

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushLocalByRef(%d)", iLocal));

   /* we store its stack offset instead of a pointer to support a dynamic stack */
   if( iLocal >= 0 )
   {
      PHB_ITEM pLocal = hb_stackLocalVariable( &iLocal );
      if( HB_IS_BYREF( pLocal ) && !HB_IS_ENUM( pLocal ) )
      {
         hb_itemCopy( pTop, pLocal );
         return;
      }
      pTop->item.asRefer.BasePtr.itemsbasePtr = hb_stackItemBasePtr();
   }
   else
   {
      /* store direct codeblock address because an item where a codeblock
       * is stored can be no longer placed on the eval stack at the time
       * of a codeblock evaluation or variable access
       */
      pTop->item.asRefer.BasePtr.block = hb_stackSelfItem()->item.asBlock.value;
   }
   pTop->type = HB_IT_BYREF;
   pTop->item.asRefer.value = iLocal;
   pTop->item.asRefer.offset = hb_stackBaseOffset();
}
hvm.c6523
STATIC VOIDhb_vmPushStatic( USHORT uiStatic )
static void hb_vmPushStatic( USHORT uiStatic )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pStatic;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushStatic(%hu)", uiStatic));

   pStatic = s_aStatics.item.asArray.value->pItems + hb_stackGetStaticsBase() + uiStatic - 1;
   hb_itemCopy( hb_stackAllocItem(),
                HB_IS_BYREF( pStatic ) ? hb_itemUnRef( pStatic ) : pStatic );
}
hvm.c6554
STATIC VOIDhb_vmPushStaticByRef( USHORT uiStatic )
static void hb_vmPushStaticByRef( USHORT uiStatic )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pTop = hb_stackAllocItem();
   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushStaticByRef(%hu)", uiStatic));

   pTop->type = HB_IT_BYREF;
   /* we store the offset instead of a pointer to support a dynamic stack */
   pTop->item.asRefer.value = hb_stackGetStaticsBase() + uiStatic - 1;
   pTop->item.asRefer.offset = 0;    /* 0 for static variables */
   pTop->item.asRefer.BasePtr.array = s_aStatics.item.asArray.value;
   hb_gcRefInc( s_aStatics.item.asArray.value );
}
hvm.c6566
STATIC VOIDhb_vmPushVariable( PHB_SYMB pVarSymb )
static void hb_vmPushVariable( PHB_SYMB pVarSymb )
{
   HB_STACK_TLS_PRELOAD
   USHORT uiAction = E_DEFAULT;
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_INFO, ("(hb_vmPushVariable)"));

   pItem = hb_stackAllocItem();

   do
   {
      /* First try if passed symbol is a name of field
         * in a current workarea - if it is not a field (FAILURE)
         * then try the memvar variable
         */
      if( hb_rddFieldGet( pItem, pVarSymb ) != SUCCESS )
      {
         if( hb_memvarGet( pItem, pVarSymb ) != SUCCESS )
         {
            HB_ITEM_PTR pError;

            pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, 1003,
                                    NULL, pVarSymb->szName,
                                    0, EF_CANRETRY );

            uiAction = hb_errLaunch( pError );
            hb_errRelease( pError );
         }
      }
   }
   while( uiAction == E_RETRY );
}
hvm.c6580
STATIC VOIDhb_vmDuplicate( void )
static void hb_vmDuplicate( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDuplicate()"));

   pItem = hb_stackItemFromTop( -1 );
   hb_itemCopy( hb_stackAllocItem(), pItem );
}
hvm.c6615
STATIC VOIDhb_vmDuplUnRef( void )
static void hb_vmDuplUnRef( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDuplUnRef()"));

   pItem = hb_stackItemFromTop( -1 );
   hb_itemCopy( hb_stackAllocItem(), pItem );
   if( HB_IS_BYREF( pItem ) )
      hb_itemCopy( pItem, hb_itemUnRef( pItem ) );
}
hvm.c6626
STATIC VOIDhb_vmDuplTwo( void )
static void hb_vmDuplTwo( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDuplTwo()"));

   pItem = hb_stackItemFromTop( -2 );
   hb_itemCopy( hb_stackAllocItem(), pItem );
   pItem = hb_stackItemFromTop( -2 );
   hb_itemCopy( hb_stackAllocItem(), pItem );
}
hvm.c6639
STATIC VOIDhb_vmPushUnRef( void )
static void hb_vmPushUnRef( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushUnRef()"));

   pItem = hb_stackItemFromTop( -1 );
   hb_itemCopy( hb_stackAllocItem(),
                HB_IS_BYREF( pItem ) ? hb_itemUnRef( pItem ) : pItem );
}
hvm.c6652
STATIC VOIDhb_vmSwap( BYTE bCount )
static void hb_vmSwap( BYTE bCount )
{
   HB_STACK_TLS_PRELOAD
   int i = -1;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmSwap(%d)", bCount));

   do
   {
      hb_itemSwap( hb_stackItemFromTop( i ), hb_stackItemFromTop( i - 1 ) );
      --i;
   }
   while( bCount-- );
}

/* ------------------------------- */
hvm.c6664
HB_EXPORT VOIDhb_vmPopState( void )
HB_EXPORT void hb_vmPopState( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE_STEALTH( HB_TR_DEBUG, ( "hb_vmPopState()" ) );

   hb_stackPopReturn();
}
hvm.c6683
STATIC BOOLhb_vmPopLogical( void )
static BOOL hb_vmPopLogical( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopLogical()"));

   if( HB_IS_LOGICAL( hb_stackItemFromTop( -1 ) ) )
   {
      BOOL fValue = hb_stackItemFromTop( -1 )->item.asLogical.value;

      hb_stackDec();
      return fValue;
   }
   else
   {
      hb_errRT_BASE( EG_ARG, 1066, NULL, hb_langDGetErrorDesc( EG_CONDITION ), 1, hb_stackItemFromTop( -1 ) );
      return FALSE;
   }
}
hvm.c6692
STATIC DOUBLEhb_vmPopNumber( void )
static double hb_vmPopNumber( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;
   double dNumber;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopNumber()"));

   pItem = hb_stackItemFromTop( -1 );

   if( HB_IS_INTEGER( pItem ) )
      dNumber = ( double ) pItem->item.asInteger.value;

   else if( HB_IS_LONG( pItem ) )
      dNumber = ( double ) pItem->item.asLong.value;

   else if( HB_IS_DOUBLE( pItem ) )
      dNumber = pItem->item.asDouble.value;

   else
   {
      hb_errInternal( HB_EI_VMPOPINVITEM, NULL, "hb_vmPopNumber()", NULL );
      dNumber = 0.0; /* To avoid GCC -O2 warning */
   }

   hb_stackDec();

   return dNumber;
}
hvm.c6714
STATIC VOIDhb_vmPopAlias( void )
static void hb_vmPopAlias( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopAlias()"));

   hb_vmSelectWorkarea( hb_stackItemFromTop( -1 ), NULL ); /* it clears the passed item */
   hb_stackDec();
}
hvm.c6744
STATIC VOIDhb_vmPopAliasedField( PHB_SYMB pSym )
static void hb_vmPopAliasedField( PHB_SYMB pSym )
{
   HB_STACK_TLS_PRELOAD
   int iCurrArea;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopAliasedField(%p)", pSym));

   iCurrArea = hb_rddGetCurrentWorkAreaNumber();
   if( hb_vmSelectWorkarea( hb_stackItemFromTop( -1 ), pSym ) == SUCCESS )
      hb_rddPutFieldValue( hb_stackItemFromTop( -2 ), pSym );

   hb_rddSelectWorkAreaNumber( iCurrArea );
   hb_stackDec();    /* alias - it was cleared in hb_vmSelectWorkarea */
   hb_stackPop();    /* field value */
}
hvm.c6757
STATIC VOIDhb_vmPopAliasedVar( PHB_SYMB pSym )
static void hb_vmPopAliasedVar( PHB_SYMB pSym )
{
   HB_STACK_TLS_PRELOAD
   HB_ITEM_PTR pAlias = hb_stackItemFromTop( -1 );

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopAliasedVar(%p)", pSym));

   /*
    * "M", "MEMV" - "MEMVAR" and "FIEL" - "FIELD" are reserved aliases
    */
   if( HB_IS_STRING( pAlias ) )
   {
      char * szAlias = pAlias->item.asString.value;

      if( szAlias[ 0 ] == 'M' || szAlias[ 0 ] == 'm' )
      {
         if( pAlias->item.asString.length == 1 || /* M->variable */
             ( pAlias->item.asString.length >= 4 &&
               hb_strnicmp( szAlias, "MEMVAR", /* MEMVAR-> or MEMVA-> or MEMV-> */
                                     pAlias->item.asString.length ) == 0 ) )
         {
            hb_memvarSetValue( pSym, hb_stackItemFromTop( -2 ) );
            hb_stackPop();    /* alias */
            hb_stackPop();    /* value */
            return;
         }
      }
      else if( pAlias->item.asString.length >= 4 &&
               ( hb_strnicmp( szAlias, "FIELD", /* FIELD-> or FIEL-> */
                                     pAlias->item.asString.length ) == 0 ||
                 hb_strnicmp( szAlias, "_FIELD", /* _FIELD-> or _FIE-> */
                                       pAlias->item.asString.length ) == 0 ) )
      {
         hb_rddPutFieldValue( hb_stackItemFromTop( -2 ), pSym );
         hb_stackPop();    /* alias */
         hb_stackPop();    /* value */
         return;
      }
   }
   hb_vmPopAliasedField( pSym );
}
hvm.c6776
STATIC VOIDhb_vmPopLocal( int iLocal )
static void hb_vmPopLocal( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal, pVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopLocal(%d)", iLocal));

   pVal = hb_stackItemFromTop( -1 );

   /* Remove MEMOFLAG if exists (assignment from field). */
   pVal->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );

   if( iLocal >= 0 )
   {
      /* local variable or local parameter */
      pLocal = hb_stackLocalVariable( &iLocal );
   }
   else
   {
      /* local variable referenced in a codeblock
       * hb_stackSelfItem() points to a codeblock that is currently evaluated
       */
      pLocal = hb_codeblockGetRef( hb_stackSelfItem()->item.asBlock.value, iLocal );
   }

   hb_itemMoveToRef( pLocal, pVal );

   hb_stackDec();
}
hvm.c6823
STATIC VOIDhb_vmPopStatic( USHORT uiStatic )
static void hb_vmPopStatic( USHORT uiStatic )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pStatic, pVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPopStatic(%hu)", uiStatic));

   pVal = hb_stackItemFromTop( -1 );

   /* Remove MEMOFLAG if exists (assignment from field). */
   pVal->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
   pStatic = s_aStatics.item.asArray.value->pItems + hb_stackGetStaticsBase() + uiStatic - 1;

   hb_itemMoveToRef( pStatic, pVal );
   hb_stackDec();
}

hvm.c6853
PHB_SYMBhb_vmGetRealFuncSym( PHB_SYMB pSym )
PHB_SYMB hb_vmGetRealFuncSym( PHB_SYMB pSym )
{
   if( pSym && !( pSym->scope.value & HB_FS_LOCAL ) )
   {
      pSym = pSym->pDynSym &&
           ( pSym->pDynSym->pSymbol->scope.value & HB_FS_LOCAL ) ?
             pSym->pDynSym->pSymbol : NULL;
   }

   return pSym;
}
hvm.c6875
CHAR *hb_vmFindModuleSymbolName( PHB_SYMB pSym )
char * hb_vmFindModuleSymbolName( PHB_SYMB pSym )
{
   if( pSym )
   {
      PHB_SYMBOLS pLastSymbols = s_pSymbols;

      while( pLastSymbols )
      {
         if( pLastSymbols->fActive &&
             pSym >= pLastSymbols->pModuleSymbols &&
             pSym < pLastSymbols->pModuleSymbols + pLastSymbols->uiModuleSymbols )
         {
            return pLastSymbols->szModuleName;
         }
         pLastSymbols = pLastSymbols->pNext;
      }
   }
   return NULL;
}
hvm.c6887
BOOLhb_vmFindModuleSymbols( PHB_SYMB pSym, PHB_SYMB * pSymbols, USHORT * puiSymbols )
BOOL hb_vmFindModuleSymbols( PHB_SYMB pSym, PHB_SYMB * pSymbols,
                             USHORT * puiSymbols )
{
   if( pSym )
   {
      PHB_SYMBOLS pLastSymbols = s_pSymbols;

/*
      if( pSym->scope.value & HB_FS_PCODEFUNC )
         * pSymbols = pSym->value.pCodeFunc->pSymbols;
*/

      while( pLastSymbols )
      {
         if( pLastSymbols->fActive &&
             pSym >= pLastSymbols->pModuleSymbols &&
             pSym < pLastSymbols->pModuleSymbols + pLastSymbols->uiModuleSymbols )
         {
            * pSymbols = pLastSymbols->pModuleSymbols;
            * puiSymbols = pLastSymbols->uiModuleSymbols;
            return TRUE;
         }
         pLastSymbols = pLastSymbols->pNext;
      }
   }

   * pSymbols = NULL;
   * puiSymbols = 0;
   return FALSE;
}
hvm.c6907
STATIC PHB_SYMBOLShb_vmFindFreeModule( PHB_SYMB pSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID )
static PHB_SYMBOLS hb_vmFindFreeModule( PHB_SYMB pSymbols, USHORT uiSymbols,
                                        const char * szModuleName, ULONG ulID )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmFindFreeModule(%p,%hu,%s,%lu)", pSymbols, uiSymbols, szModuleName, ulID));

   if( s_ulFreeSymbols )
   {
      PHB_SYMBOLS pLastSymbols = s_pSymbols;

      while( pLastSymbols )
      {
         if( !pLastSymbols->fActive &&
             pLastSymbols->ulID == ulID &&
             pLastSymbols->uiModuleSymbols == uiSymbols &&
             pLastSymbols->szModuleName != NULL &&
             strcmp( pLastSymbols->szModuleName, szModuleName ) == 0 )
         {
            PHB_SYMB pModuleSymbols = pLastSymbols->pModuleSymbols;
            USHORT ui;

            for( ui = 0; ui < uiSymbols; ++ui )
            {
               if( ( pSymbols[ ui ].scope.value & ~( HB_FS_PCODEFUNC | HB_FS_DYNCODE ) ) !=
                   ( pModuleSymbols[ ui ].scope.value & ~HB_FS_DEFERRED ) ||
                   strcmp( pSymbols[ ui ].szName, pModuleSymbols[ ui ].szName ) != 0 )
               {
                  break;
               }
            }
            if( ui == uiSymbols )
            {
               --s_ulFreeSymbols;
               return pLastSymbols;
            }
         }
         pLastSymbols = pLastSymbols->pNext;
      }
   }

   return NULL;
}
hvm.c6938
VOIDhb_vmFreeSymbols( PHB_SYMBOLS pSymbols )
void hb_vmFreeSymbols( PHB_SYMBOLS pSymbols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmFreeSymbols(%p)", pSymbols));

   if( pSymbols->fActive )
   {
      USHORT ui;

      for( ui = 0; ui < pSymbols->uiModuleSymbols; ++ui )
      {
         HB_SYMBOLSCOPE scope = pSymbols->pModuleSymbols[ ui ].scope.value & HB_FS_INITEXIT;

         /* do not overwrite already initialized statics' frame */
         if( scope != HB_FS_INITEXIT )
         {
            PHB_SYMB pSymbol = &pSymbols->pModuleSymbols[ ui ];
            pSymbol->value.pFunPtr = NULL;
            if( pSymbol->pDynSym && pSymbol->pDynSym->pSymbol != pSymbol &&
                ( pSymbol->scope.value & HB_FS_LOCAL ) == 0 )
               pSymbol->scope.value |= HB_FS_DEFERRED;
         }
         pSymbols->pModuleSymbols[ ui ].scope.value &= ~( HB_FS_PCODEFUNC | HB_FS_DYNCODE );
      }
      pSymbols->hDynLib = NULL;
      pSymbols->fActive = FALSE;
      ++s_ulFreeSymbols;
   }
}
hvm.c6980
VOIDhb_vmBeginSymbolGroup( void * hDynLib, BOOL fClone )
void hb_vmBeginSymbolGroup( void * hDynLib, BOOL fClone )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmBeginSymbolGroup(%p,%d)", hDynLib, (int)fClone));

   s_hDynLibID = hDynLib;
   s_fCloneSym = fClone;
}
hvm.c7009
VOIDhb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] )
void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmInitSymbolGroup(%p,%d,%p)", hNewDynLib, argc, argv));

   s_fCloneSym = FALSE;

   if( s_hDynLibID )
   {
      PHB_SYMBOLS pLastSymbols = s_pSymbols;
      void * hDynLib = s_hDynLibID;
      BOOL fFound = FALSE;
      USHORT ui;

      s_hDynLibID = NULL;

      while( pLastSymbols )
      {
         if( pLastSymbols->hDynLib == hDynLib )
         {
            fFound = TRUE;

            if( pLastSymbols->fInitStatics && pLastSymbols->fActive )
            {
               for( ui = 0; ui < pLastSymbols->uiModuleSymbols; ui++ )
               {
                  HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & HB_FS_INITEXIT;

                  if( scope == HB_FS_INITEXIT )
                  {
                     hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
                     hb_vmPushNil();
                     hb_vmDo( 0 );
                  }
               }
               pLastSymbols->fInitStatics = FALSE;
            }

            pLastSymbols->hDynLib = hNewDynLib;
         }
         pLastSymbols = pLastSymbols->pNext;
      }

      if( fFound )
      {
         pLastSymbols = s_pSymbols;
         while( pLastSymbols )
         {
            if( pLastSymbols->hDynLib == hNewDynLib )
            {
               if( pLastSymbols->fActive && ( pLastSymbols->hScope & HB_FS_INIT ) != 0 )
               {
                  for( ui = 0; ui < pLastSymbols->uiModuleSymbols; ui++ )
                  {
                     HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & HB_FS_INITEXIT;

                     if( scope == HB_FS_INIT )
                     {
                        int i;
                        hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
                        hb_vmPushNil();
                        for( i = 0; i < argc; ++i )
                        {
                           hb_vmPushString( argv[i], strlen( argv[i] ) );
                        }
                        hb_vmDo( ( USHORT ) argc );
                     }
                  }
               }
            }
            pLastSymbols = pLastSymbols->pNext;
         }
      }
   }
}
hvm.c7017
VOIDhb_vmExitSymbolGroup( void * hDynLib )
void hb_vmExitSymbolGroup( void * hDynLib )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmExitSymbolGroup(%p)", hDynLib));

   if( hDynLib )
   {
      PHB_SYMBOLS pLastSymbols = s_pSymbols;
      BOOL fFound = FALSE;

      while( pLastSymbols )
      {
         if( pLastSymbols->hDynLib == hDynLib )
         {
            fFound = TRUE;
            if( pLastSymbols->fActive && ( pLastSymbols->hScope & HB_FS_EXIT ) != 0 )
            {
               USHORT ui;
               for( ui = 0; ui < pLastSymbols->uiModuleSymbols; ui++ )
               {
                  HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & HB_FS_INITEXIT;

                  if( scope == HB_FS_EXIT )
                  {
                     hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
                     hb_vmPushNil();
                     hb_vmDo( 0 );
                  }
               }
            }
         }
         pLastSymbols = pLastSymbols->pNext;
      }

      if( fFound )
      {
         pLastSymbols = s_pSymbols;
         while( pLastSymbols )
         {
            if( pLastSymbols->hDynLib == hDynLib )
            {
               hb_vmFreeSymbols( pLastSymbols );
            }
            pLastSymbols = pLastSymbols->pNext;
         }
      }
   }
}
hvm.c7092
PHB_SYMBOLShb_vmRegisterSymbols( PHB_SYMB pModuleSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID, BOOL fDynLib, BOOL fClone )
PHB_SYMBOLS hb_vmRegisterSymbols( PHB_SYMB pModuleSymbols, USHORT uiSymbols,
                                  const char * szModuleName, ULONG ulID,
                                  BOOL fDynLib, BOOL fClone )
{
   PHB_SYMBOLS pNewSymbols;
   BOOL fRecycled, fInitStatics = FALSE;
   USHORT ui;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRegisterSymbols(%p,%hu,%s,%lu,%d,%d)", pModuleSymbols, uiSymbols, szModuleName, ulID, (int)fDynLib, (int)fClone));

   pNewSymbols = s_ulFreeSymbols == 0 ? NULL :
               hb_vmFindFreeModule( pModuleSymbols, uiSymbols, szModuleName, ulID );

   if( pNewSymbols )
   {
      pNewSymbols->fActive = fRecycled = TRUE;
      pNewSymbols->hDynLib = s_hDynLibID;
      pNewSymbols->hScope = 0;
   }
   else
   {
      fRecycled = FALSE;

      if( fClone )
      {
         PHB_SYMB pSymbols = ( PHB_SYMB ) hb_xgrab( uiSymbols * sizeof( HB_SYMB ) );
         memcpy( pSymbols, pModuleSymbols, uiSymbols * sizeof( HB_SYMB ) );
         for( ui = 0; ui < uiSymbols; ui++ )
         {
            pSymbols[ ui ].szName = hb_strdup( pSymbols[ ui ].szName );
         }
         pModuleSymbols = pSymbols;
      }

      pNewSymbols = ( PHB_SYMBOLS ) hb_xgrab( sizeof( HB_SYMBOLS ) );
      pNewSymbols->pModuleSymbols = pModuleSymbols;
      pNewSymbols->uiModuleSymbols = uiSymbols;
      pNewSymbols->szModuleName = hb_strdup( szModuleName );
      pNewSymbols->ulID = ulID;
      pNewSymbols->fAllocated = fClone;
      pNewSymbols->fActive = TRUE;
      pNewSymbols->fInitStatics = FALSE;
      pNewSymbols->hDynLib = s_hDynLibID;
      pNewSymbols->hScope = 0;
      pNewSymbols->pNext = NULL;

      if( s_pSymbols == NULL )
      {
         s_pSymbols = pNewSymbols;
      }
      else
      {
         PHB_SYMBOLS pLastSymbols = s_pSymbols;

         while( pLastSymbols->pNext ) /* locates the latest processed group of symbols */
            pLastSymbols = pLastSymbols->pNext;
         pLastSymbols->pNext = pNewSymbols;
      }
   }

   for( ui = 0; ui < uiSymbols; ui++ ) /* register each public symbol on the dynamic symbol table */
   {
      PHB_SYMB pSymbol = pNewSymbols->pModuleSymbols + ui;
      HB_SYMBOLSCOPE hSymScope;
      BOOL fPublic, fStatics;

      fStatics = ( pSymbol->scope.value & HB_FS_INITEXIT ) == HB_FS_INITEXIT;

      if( fRecycled && !fStatics )
      {
         pSymbol->value.pFunPtr = ( pModuleSymbols + ui )->value.pFunPtr;
         pSymbol->scope.value = ( pModuleSymbols + ui )->scope.value;
      }
      if( fDynLib )
      {
         pSymbol->scope.value |= HB_FS_DYNCODE;
      }

      hSymScope = pSymbol->scope.value;
      pNewSymbols->hScope |= hSymScope;
      /* fPublic = ( hSymScope & ( HB_FS_PUBLIC | HB_FS_MESSAGE | HB_FS_MEMVAR ) ) != 0; */
      fPublic = ( hSymScope & ( HB_FS_INITEXIT | HB_FS_STATIC ) ) == 0;
      if( fStatics )
      {
         fInitStatics = TRUE;
      }

      if( ( hSymScope & HB_FS_PCODEFUNC ) && ( hSymScope & HB_FS_LOCAL ) &&
          ( fRecycled || fClone ) )
      {
         pSymbol->value.pCodeFunc->pSymbols = pNewSymbols->pModuleSymbols;
      }

      if( !s_pSymStart && !fDynLib &&
          ( hSymScope & HB_FS_FIRST ) != 0 &&
          ( hSymScope & HB_FS_INITEXIT ) == 0 )
      {
         /* first public defined symbol to start execution */
         s_pSymStart = pSymbol;
      }

      /* Enable this code to see static functions which are registered in global dynsym table */
#if 0
      if( fPublic && ( hSymScope & ( HB_FS_INITEXIT | HB_FS_STATIC ) ) != 0 )
      {
         printf("Registring: %s:%s scope %04x\r\n", szModuleName, pSymbol->szName, hSymScope ); fflush(stdout);
      }
#endif

      if( fPublic )
      {
         if( fDynLib && pSymbol->value.pFunPtr )
         {
            PHB_DYNS pDynSym;

            pDynSym = hb_dynsymFind( pSymbol->szName );

            if( pDynSym )
            {
               pSymbol->pDynSym = pDynSym;
               if( pDynSym->pSymbol->value.pFunPtr )
               {
                  pSymbol->scope.value =
                     ( pSymbol->scope.value & ~( HB_FS_PCODEFUNC | HB_FS_LOCAL ) ) |
                     ( pDynSym->pSymbol->scope.value & HB_FS_PCODEFUNC );
                  pSymbol->value.pFunPtr = pDynSym->pSymbol->value.pFunPtr;
               }
               else
               {
                  pDynSym->pSymbol = pSymbol;
               }
               continue;
            }
         }

         hb_dynsymNew( pSymbol );
      }
   }

   if( !fRecycled )
   {
      pNewSymbols->fInitStatics = fInitStatics;
   }

   return pNewSymbols;
}
hvm.c7140
HB_EXPORT PHB_SYMBhb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiModuleSymbols, const char * szModuleName, ULONG ulID, USHORT uiPCodeVer )
HB_EXPORT PHB_SYMB hb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiModuleSymbols,
                                          const char * szModuleName, ULONG ulID,
                                          USHORT uiPCodeVer )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmProcessSymbolsEx(%p,%hu,%s,%lu,%hu)", pSymbols, uiModuleSymbols, szModuleName, ulID, uiPCodeVer));

   if( uiPCodeVer != 0 )
   {
      if( uiPCodeVer > HB_PCODE_VER || /* the module is compiled with newer compiler version then HVM */
          uiPCodeVer < HB_PCODE_VER_MIN )  /* the module is compiled with old not longer supported by HVM compiler version */
      {
         char szPCode[ 10 ];
         snprintf( szPCode, sizeof( szPCode ), "%i.%i", uiPCodeVer>>8, uiPCodeVer &0xff );

         hb_errInternal( HB_EI_ERRUNRECOV, "Module '%s'\n"
                         "was compiled with unsupported PCODE version %s.\n"
                         "Please recompile.", szModuleName, szPCode );
      }
   }

   return hb_vmRegisterSymbols( pSymbols, uiModuleSymbols, szModuleName, ulID,
                                s_fCloneSym, s_fCloneSym )->pModuleSymbols;
}
hvm.c7287
HB_EXPORT PHB_SYMBhb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols )
HB_EXPORT PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmProcessSymbols(%p,%hu)", pSymbols, uiSymbols));

   return hb_vmRegisterSymbols( pSymbols, uiSymbols, "", 0L,
                                s_fCloneSym, s_fCloneSym )->pModuleSymbols;
}
hvm.c7314
HB_EXPORT PHB_SYMBhb_vmProcessDllSymbols( PHB_SYMB pSymbols, USHORT uiModuleSymbols )
HB_EXPORT PHB_SYMB hb_vmProcessDllSymbols( PHB_SYMB pSymbols, USHORT uiModuleSymbols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmProcessDllSymbols(%p,%hu)", pSymbols, uiModuleSymbols));

   return hb_vmRegisterSymbols( pSymbols, uiModuleSymbols, "", 0,
                                TRUE, s_fCloneSym )->pModuleSymbols;
}
hvm.c7325
STATIC VOIDhb_vmReleaseLocalSymbols( void )
static void hb_vmReleaseLocalSymbols( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmReleaseLocalSymbols()"));

   while( s_pSymbols )
   {
      PHB_SYMBOLS pDestroy;

      pDestroy = s_pSymbols;
      s_pSymbols = s_pSymbols->pNext;

      if( pDestroy->szModuleName )
      {
         hb_xfree( pDestroy->szModuleName );
      }
      if( pDestroy->fAllocated )
      {
         USHORT ui;
         for( ui = 0; ui < pDestroy->uiModuleSymbols; ++ui )
         {
            PHB_SYMB pSymbol = pDestroy->pModuleSymbols + ui;
            if( pSymbol->pDynSym && pSymbol->pDynSym->pSymbol == pSymbol )
            {
               pSymbol->pDynSym->pSymbol = NULL;
            }
            hb_xfree( ( void * ) pSymbol->szName );
         }
         hb_xfree( pDestroy->pModuleSymbols );
      }
      hb_xfree( pDestroy );
   }
}
hvm.c7336
STATIC VOIDhb_vmDoInitStatics( void )
static void hb_vmDoInitStatics( void )
{
   PHB_SYMBOLS pLastSymbols = s_pSymbols;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDoInitStatics()"));

   while( pLastSymbols )
   {
      if( pLastSymbols->fInitStatics )
      {
         USHORT ui;

         for( ui = 0; ui < pLastSymbols->uiModuleSymbols; ui++ )
         {
            HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & ( HB_FS_EXIT | HB_FS_INIT );

            if( scope == HB_FS_INITEXIT )
            {
               hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
               hb_vmPushNil();
               hb_vmDo( 0 );
            }
         }
         pLastSymbols->fInitStatics = FALSE;
      }
      pLastSymbols = pLastSymbols->pNext;
   }
}
hvm.c7369
STATIC VOIDhb_vmDoInitFunctions( void )
static void hb_vmDoInitFunctions( void )
{
   PHB_SYMBOLS pLastSymbols = s_pSymbols;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDoInitFunctions()"));

   while( pLastSymbols )
   {
      /* only if module contains some INIT functions */
      if( pLastSymbols->fActive && pLastSymbols->hScope & HB_FS_INIT )
      {
         USHORT ui;

         for( ui = 0; ui < pLastSymbols->uiModuleSymbols; ui++ )
         {
            HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & ( HB_FS_EXIT | HB_FS_INIT );

            if( scope == HB_FS_INIT )
            {
               int argc = hb_cmdargARGC();
               char ** argv = hb_cmdargARGV();

               int i;
               int iArgCount;

               hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
               hb_vmPushNil();

               iArgCount = 0;
               for( i = 1; i < argc; i++ ) /* places application parameters on the stack */
               {
                  /* Filter out any parameters beginning with //, like //INFO */
                  if( ! hb_cmdargIsInternal( argv[ i ], NULL ) )
                  {
                     hb_vmPushString( argv[ i ], strlen( argv[ i ] ) );
                     iArgCount++;
                  }
               }

               hb_vmDo( ( USHORT ) iArgCount );
            }
         }
      }
      pLastSymbols = pLastSymbols->pNext;
   }
}
hvm.c7403
STATIC VOIDhb_vmDoExitFunctions( void )
static void hb_vmDoExitFunctions( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_SYMBOLS pLastSymbols = s_pSymbols;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmDoExitFunctions()"));

   /* EXIT procedures should be processed? */
   if( s_fDoExitProc )
   {
      s_fDoExitProc = FALSE;
      hb_stackSetActionRequest( 0 );

      while( pLastSymbols )
      {
         /* only if module contains some EXIT functions */
         if( pLastSymbols->fActive && pLastSymbols->hScope & HB_FS_EXIT )
         {
            USHORT ui;

            for( ui = 0; ui < pLastSymbols->uiModuleSymbols; ui++ )
            {
               HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & ( HB_FS_EXIT | HB_FS_INIT );

               if( scope == HB_FS_EXIT )
               {
                  hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
                  hb_vmPushNil();
                  hb_vmDo( 0 );
                  if( hb_stackGetActionRequest() )
                     /* QUIT or BREAK was issued - stop processing
                     */
                     return;
               }
            }
         }
         pLastSymbols = pLastSymbols->pNext;
      }
   }
}

/* ------------------------------- */
hvm.c7450
STATIC PHB_ITEMhb_vmItemRefRead( PHB_ITEM pRefer )
static PHB_ITEM hb_vmItemRefRead( PHB_ITEM pRefer )
{
   return ( PHB_ITEM ) pRefer->item.asExtRef.value;
}
hvm.c7495
STATIC PHB_ITEMhb_vmItemRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
static PHB_ITEM hb_vmItemRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
{
   HB_SYMBOL_UNUSED( pSource );
   return ( PHB_ITEM ) pRefer->item.asExtRef.value;
}
hvm.c7503
STATIC VOIDhb_vmItemRefCopy( PHB_ITEM pDest )
static void hb_vmItemRefCopy( PHB_ITEM pDest )
{
   pDest->type = HB_IT_NIL;
   hb_itemCopy( pDest, ( PHB_ITEM ) pDest->item.asExtRef.value );
}
hvm.c7509
STATIC VOIDhb_vmItemRefDummy( void * value )
static void hb_vmItemRefDummy( void * value )
{
   HB_SYMBOL_UNUSED( value );
}
hvm.c7515
HB_EXPORT VOIDhb_vmPushItemRef( PHB_ITEM pItem )
HB_EXPORT void hb_vmPushItemRef( PHB_ITEM pItem )
{
   static const HB_EXTREF s_ItmExtRef = {
             hb_vmItemRefRead,
             hb_vmItemRefWrite,
             hb_vmItemRefCopy,
             hb_vmItemRefDummy,
             hb_vmItemRefDummy };

   HB_STACK_TLS_PRELOAD
   PHB_ITEM pRefer;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmPushItemRef(%p)", pItem));

   pRefer = hb_stackAllocItem();
   pRefer->type = HB_IT_BYREF | HB_IT_EXTREF;
   pRefer->item.asExtRef.value = ( void * ) pItem;
   pRefer->item.asExtRef.func = &s_ItmExtRef;
}

/* ------------------------------- */

/*
 * extended message reference structure
 */
typedef struct
{
   PHB_DYNS access;
   PHB_DYNS assign;
   HB_ITEM  object;
   HB_ITEM  value;
} HB_MSGREF, * PHB_MSGREF;
hvm.c7520
STATIC PHB_ITEMhb_vmMsgRefRead( PHB_ITEM pRefer )
static PHB_ITEM hb_vmMsgRefRead( PHB_ITEM pRefer )
{
   PHB_MSGREF pMsgRef = ( PHB_MSGREF ) pRefer->item.asExtRef.value;

   if( hb_vmRequestQuery() == 0 )
   {
      HB_STACK_TLS_PRELOAD

      hb_stackPushReturn();
      if( !pMsgRef->access )
         pMsgRef->access = hb_dynsymGetCase( pMsgRef->assign->pSymbol->szName + 1 );
      hb_vmPushDynSym( pMsgRef->access );
      hb_vmPush( &pMsgRef->object );
      hb_vmSend( 0 );
      hb_itemMove( &pMsgRef->value, hb_stackReturnItem() );
      pMsgRef->value.type |= HB_IT_DEFAULT;
      hb_stackPopReturn();
   }
   return &pMsgRef->value;
}
hvm.c7556
STATIC PHB_ITEMhb_vmMsgRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
static PHB_ITEM hb_vmMsgRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
{
   PHB_MSGREF pMsgRef = ( PHB_MSGREF ) pRefer->item.asExtRef.value;

   if( hb_vmRequestQuery() == 0 )
   {
      HB_STACK_TLS_PRELOAD

      hb_stackPushReturn();
      hb_vmPushDynSym( pMsgRef->assign );
      hb_vmPush( &pMsgRef->object );
      hb_vmPush( pSource );
      hb_vmSend( 1 );
      hb_itemCopy( &pMsgRef->value, pSource );
      pMsgRef->value.type |= HB_IT_DEFAULT;
      hb_stackPopReturn();
   }
   return NULL; /*&pMsgIdxRef->value;*/
}
hvm.c7580
STATIC VOIDhb_vmMsgRefCopy( PHB_ITEM pDest )
static void hb_vmMsgRefCopy( PHB_ITEM pDest )
{
   hb_xRefInc( pDest->item.asExtRef.value );
}
hvm.c7600
STATIC VOIDhb_vmMsgRefClear( void * value )
static void hb_vmMsgRefClear( void * value )
{
   if( hb_xRefDec( value ) )
   {
      PHB_MSGREF pMsgRef = ( PHB_MSGREF ) value;
      /* value were change by C code without calling RefWrite(),
       *  f.e. hb_stor*() function
       */
      if( ( pMsgRef->value.type & HB_IT_DEFAULT ) == 0 )
      {
         if( hb_vmRequestReenter() )
         {
            hb_vmPushDynSym( pMsgRef->assign );
            hb_vmPush( &pMsgRef->object );
            hb_vmPush( &pMsgRef->value );
            hb_vmSend( 1 );
            hb_vmRequestRestore();
         }
      }
      if( HB_IS_COMPLEX( &pMsgRef->value ) )
         hb_itemClear( &pMsgRef->value );
      if( HB_IS_COMPLEX( &pMsgRef->object ) )
         hb_itemClear( &pMsgRef->object );
      hb_xfree( value );
   }
}
hvm.c7605
STATIC VOIDhb_vmMsgRefMark( void * value )
static void hb_vmMsgRefMark( void * value )
{
   if( HB_IS_GCITEM( &( ( PHB_MSGREF ) value )->object ) )
      hb_gcItemRef( &( ( PHB_MSGREF ) value )->object );
   if( HB_IS_GCITEM( &( ( PHB_MSGREF ) value )->value ) )
      hb_gcItemRef( &( ( PHB_MSGREF ) value )->value );
}
hvm.c7632
BOOLhb_vmMsgReference( PHB_ITEM pObject, PHB_DYNS pMessage, PHB_DYNS pAccMsg )
BOOL hb_vmMsgReference( PHB_ITEM pObject, PHB_DYNS pMessage, PHB_DYNS pAccMsg )
{
   static const HB_EXTREF s_MsgExtRef = {
             hb_vmMsgRefRead,
             hb_vmMsgRefWrite,
             hb_vmMsgRefCopy,
             hb_vmMsgRefClear,
             hb_vmMsgRefMark };

   HB_STACK_TLS_PRELOAD
   PHB_MSGREF pMsgRef;
   PHB_ITEM pRefer;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMsgReference(%p,%p,%p)", pObject, pMessage, pAccMsg));

   pMsgRef = ( PHB_MSGREF ) hb_xgrab( sizeof( HB_MSGREF ) );
   pMsgRef->access = pAccMsg;
   pMsgRef->assign = pMessage;
   pMsgRef->value.type = HB_IT_NIL | HB_IT_DEFAULT;
   pMsgRef->object.type = HB_IT_NIL;
   hb_itemMove( &pMsgRef->object, pObject );

   pRefer = hb_stackReturnItem();
   pRefer->type = HB_IT_BYREF | HB_IT_EXTREF;
   pRefer->item.asExtRef.value = ( void * ) pMsgRef;
   pRefer->item.asExtRef.func = &s_MsgExtRef;

   return TRUE;
}

/* ------------------------------- */

/*
 * extended object index reference structure
 */
typedef struct
{
   HB_ITEM  object;
   HB_ITEM  value;
   HB_ITEM  index;
} HB_MSGIDXREF, * PHB_MSGIDXREF;
hvm.c7640
STATIC PHB_ITEMhb_vmMsgIdxRefRead( PHB_ITEM pRefer )
static PHB_ITEM hb_vmMsgIdxRefRead( PHB_ITEM pRefer )
{
   PHB_MSGIDXREF pMsgIdxRef = ( PHB_MSGIDXREF ) pRefer->item.asExtRef.value;

   if( hb_vmRequestQuery() == 0 )
   {
      HB_STACK_TLS_PRELOAD

      hb_stackPushReturn();
      hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, &pMsgIdxRef->value,
                          HB_IS_BYREF( &pMsgIdxRef->object ) ?
                          hb_itemUnRef( &pMsgIdxRef->object ) :
                          &pMsgIdxRef->object, &pMsgIdxRef->index, NULL );
      hb_stackPopReturn();
      pMsgIdxRef->value.type |= HB_IT_DEFAULT;
   }
   return &pMsgIdxRef->value;
}
hvm.c7685
STATIC PHB_ITEMhb_vmMsgIdxRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
static PHB_ITEM hb_vmMsgIdxRefWrite( PHB_ITEM pRefer, PHB_ITEM pSource )
{
   PHB_MSGIDXREF pMsgIdxRef = ( PHB_MSGIDXREF ) pRefer->item.asExtRef.value;

   if( hb_vmRequestQuery() == 0 )
   {
      HB_STACK_TLS_PRELOAD
      PHB_ITEM pObject = HB_IS_BYREF( &pMsgIdxRef->object ) ?
                         hb_itemUnRef( &pMsgIdxRef->object ) :
                         &pMsgIdxRef->object;
      hb_stackPushReturn();
      hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pObject, pObject,
                          &pMsgIdxRef->index, pSource );
      hb_stackPopReturn();
      pMsgIdxRef->value.type |= HB_IT_DEFAULT;
   }

   return NULL; /*&pMsgIdxRef->value;*/
}
hvm.c7707
STATIC VOIDhb_vmMsgIdxRefCopy( PHB_ITEM pDest )
static void hb_vmMsgIdxRefCopy( PHB_ITEM pDest )
{
   hb_xRefInc( pDest->item.asExtRef.value );
}
hvm.c7727
STATIC VOIDhb_vmMsgIdxRefClear( void * value )
static void hb_vmMsgIdxRefClear( void * value )
{
   if( hb_xRefDec( value ) )
   {
      PHB_MSGIDXREF pMsgIdxRef = ( PHB_MSGIDXREF ) value;
      /* value were change by C code without calling RefWrite(),
       *  f.e. hb_stor*() function
       */
      if( ( pMsgIdxRef->value.type & HB_IT_DEFAULT ) == 0 )
      {
         if( hb_vmRequestReenter() )
         {
            PHB_ITEM pObject = HB_IS_BYREF( &pMsgIdxRef->object ) ?
                               hb_itemUnRef( &pMsgIdxRef->object ) :
                               &pMsgIdxRef->object;
            hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pObject, pObject,
                                &pMsgIdxRef->index, &pMsgIdxRef->value );
            hb_vmRequestRestore();
         }
      }
      if( HB_IS_COMPLEX( &pMsgIdxRef->value ) )
         hb_itemClear( &pMsgIdxRef->value );
      if( HB_IS_COMPLEX( &pMsgIdxRef->object ) )
         hb_itemClear( &pMsgIdxRef->object );
      if( HB_IS_COMPLEX( &pMsgIdxRef->index ) )
         hb_itemClear( &pMsgIdxRef->index );
      hb_xfree( value );
   }
}
hvm.c7732
STATIC VOIDhb_vmMsgIdxRefMark( void * value )
static void hb_vmMsgIdxRefMark( void * value )
{
   if( HB_IS_GCITEM( &( ( PHB_MSGIDXREF ) value )->object ) )
      hb_gcItemRef( &( ( PHB_MSGIDXREF ) value )->object );
   if( HB_IS_GCITEM( &( ( PHB_MSGIDXREF ) value )->index ) )
      hb_gcItemRef( &( ( PHB_MSGIDXREF ) value )->index );
   if( HB_IS_GCITEM( &( ( PHB_MSGIDXREF ) value )->value ) )
      hb_gcItemRef( &( ( PHB_MSGIDXREF ) value )->value );
}
hvm.c7762
STATIC VOIDhb_vmMsgIndexReference( PHB_ITEM pRefer, PHB_ITEM pObject, PHB_ITEM pIndex )
static void hb_vmMsgIndexReference( PHB_ITEM pRefer, PHB_ITEM pObject, PHB_ITEM pIndex )
{
   static const HB_EXTREF s_MsgIdxExtRef = {
             hb_vmMsgIdxRefRead,
             hb_vmMsgIdxRefWrite,
             hb_vmMsgIdxRefCopy,
             hb_vmMsgIdxRefClear,
             hb_vmMsgIdxRefMark };

   PHB_MSGIDXREF pMsgIdxRef;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmMsgIndexReference(%p,%p,%p)", pRefer, pObject, pIndex));

   pMsgIdxRef = ( PHB_MSGIDXREF ) hb_xgrab( sizeof( HB_MSGIDXREF ) );
   pMsgIdxRef->value.type = HB_IT_NIL | HB_IT_DEFAULT;
   pMsgIdxRef->object.type = HB_IT_NIL;
   pMsgIdxRef->index.type = HB_IT_NIL;
   hb_itemCopy( &pMsgIdxRef->object, HB_IS_STRING( pObject ) ? pRefer : pObject );
   hb_itemCopy( &pMsgIdxRef->index, pIndex );

   pIndex->type = HB_IT_BYREF | HB_IT_EXTREF;
   pIndex->item.asExtRef.value = ( void * ) pMsgIdxRef;
   pIndex->item.asExtRef.func = &s_MsgIdxExtRef;
   hb_itemMove( pRefer, pIndex );
}

/* ------------------------------- */
hvm.c7772
VOIDhb_vmRequestQuit( void )
void hb_vmRequestQuit( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestQuit()"));

   /* In MT mode EXIT functions are executed only from hb_vmQuit()
    * when all other threads have terminated
    */
#if !defined( HB_MT_VM )
   hb_vmDoExitFunctions(); /* process defined EXIT functions */
#endif
   hb_stackSetActionRequest( HB_QUIT_REQUESTED );
}
hvm.c7805
VOIDhb_vmRequestEndProc( void )
void hb_vmRequestEndProc( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestEndProc()"));

   hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
}
hvm.c7820
VOIDhb_vmRequestBreak( PHB_ITEM pItem )
void hb_vmRequestBreak( PHB_ITEM pItem )
{
   HB_STACK_TLS_PRELOAD
   ULONG ulRecoverBase;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestBreak(%p)", pItem));

   ulRecoverBase = hb_stackGetRecoverBase();
   while( ulRecoverBase && ( hb_stackItem( ulRecoverBase +
               HB_RECOVER_STATE )->item.asRecover.flags & HB_SEQ_DOALWAYS ) )
   {
      ulRecoverBase = hb_stackItem( ulRecoverBase +
                                    HB_RECOVER_STATE )->item.asRecover.base;
   }

   if( ulRecoverBase )
   {
      if( pItem )
         hb_itemCopy( hb_stackItem( ulRecoverBase + HB_RECOVER_VALUE ), pItem );

      hb_stackSetActionRequest( HB_BREAK_REQUESTED );
   }
   else
   {
#ifdef HB_C52_STRICT
      /*
       * do not execute EXIT procedures to be as close as possible
       * buggy Clipper behavior. [druzus]
       */
      s_fDoExitProc = FALSE;
      hb_stackSetActionRequest( HB_QUIT_REQUESTED );
#else
      /*
       * Clipper has a bug here. Tests shows that it set exception flag
       * and then tries to execute EXIT procedures so the first one is
       * immediately interrupted. Because Clipper does not check the
       * exception flag often enough then it's possible to execute one
       * function from first EXIT PROC. Using small trick with
       * QOUT( TYPE( cPrivateVar ) ) in the EXIT procedure (TYPE() is
       * not normal function) we can also check that it tries to execute
       * EXIT procedures exactly here before leave current function.
       * So to be as close as possible the Clipper intentional behavior
       * we execute hb_vmRequestQuit() here. [druzus]
       */
      hb_vmRequestQuit();
#endif
   }
}
hvm.c7829
VOIDhb_vmRequestCancel( void )
void hb_vmRequestCancel( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestCancel()"));

   if( hb_stackSetStruct()->HB_SET_CANCEL )
   {
      char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 + 10 ]; /* additional 10 bytes for line info (%hu) overhead */
      char file[ _POSIX_PATH_MAX + 1 ];
      USHORT uiLine;
      int iLevel = 0, l;

      hb_conOutErr( hb_conNewLine(), 0 );
      hb_conOutErr( "Cancelled at: ", 0 );

      while( hb_procinfo( iLevel++, buffer, &uiLine, file ) )
      {
         l = strlen( buffer );
         snprintf( buffer + l, sizeof( buffer ) - l, " (%hu)%s%s", uiLine, *file ? HB_I_(" in ") : "", file );

         hb_conOutErr( buffer, 0 );
         hb_conOutErr( hb_conNewLine(), 0 );
      }

      /*
       * Clipper does not execute EXIT procedures when quiting using break key
       */
      s_fDoExitProc = FALSE;
      hb_stackSetActionRequest( HB_QUIT_REQUESTED );
   }
}
hvm.c7878
USHORThb_vmRequestQuery( void )
USHORT hb_vmRequestQuery( void )
{
   HB_STACK_TLS_PRELOAD
   return hb_stackGetActionRequest();
}
hvm.c7911
BOOLhb_vmRequestReenter( void )
BOOL hb_vmRequestReenter( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestReenter()"));

   if( !s_fHVMActive )
      return FALSE;

   hb_stackPushReturn();

   hb_vmPushInteger( hb_stackGetActionRequest() );
   hb_stackSetActionRequest( 0 );

   return TRUE;
}
hvm.c7917
VOIDhb_vmRequestRestore( void )
void hb_vmRequestRestore( void )
{
   HB_STACK_TLS_PRELOAD
   USHORT uiAction;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestRestore()"));

   uiAction = ( USHORT ) hb_stackItemFromTop( -1 )->item.asInteger.value |
              hb_stackGetActionRequest();
   if( uiAction & HB_QUIT_REQUESTED )
      hb_stackSetActionRequest( HB_QUIT_REQUESTED );
   else if( uiAction & HB_BREAK_REQUESTED )
      hb_stackSetActionRequest( HB_BREAK_REQUESTED );
   else if( uiAction & HB_ENDPROC_REQUESTED )
      hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
   else
      hb_stackSetActionRequest( 0 );

   hb_stackDec();
   hb_stackPopReturn();
}
hvm.c7934
PHB_CODEPAGEhb_vmCDP( void )
PHB_CODEPAGE hb_vmCDP( void )
{
   HB_STACK_TLS_PRELOAD

   return ( PHB_CODEPAGE ) hb_stackGetCDP();
}
hvm.c7956
VOIDhb_vmSetCDP( PHB_CODEPAGE pCDP )
void hb_vmSetCDP( PHB_CODEPAGE pCDP )
{
   HB_STACK_TLS_PRELOAD

   hb_stackSetCDP( ( void * ) pCDP );
}
hvm.c7963
PHB_LANGhb_vmLang( void )
PHB_LANG hb_vmLang( void )
{
   HB_STACK_TLS_PRELOAD

   return ( PHB_LANG ) hb_stackGetLang();
}
hvm.c7970
VOIDhb_vmSetLang( PHB_LANG pLang )
void hb_vmSetLang( PHB_LANG pLang )
{
   HB_STACK_TLS_PRELOAD

   hb_stackSetLang( ( void * ) pLang );
}

#if defined( HB_MT_VM )
#  define HB_XVM_RETURN \
      if( hb_vmThreadRequest ) \
         hb_vmRequestTest(); \
      return ( hb_stackGetActionRequest() & \
               ( HB_ENDPROC_REQUESTED | HB_BREAK_REQUESTED | HB_QUIT_REQUESTED ) ) != 0;
#else
#  define HB_XVM_RETURN \
      return ( hb_stackGetActionRequest() & \
               ( HB_ENDPROC_REQUESTED | HB_BREAK_REQUESTED | HB_QUIT_REQUESTED ) ) != 0;
hvm.c7977
HB_EXPORT VOIDhb_xvmExitProc( void )
HB_EXPORT void hb_xvmExitProc( void )
{
   HB_STACK_TLS_PRELOAD

   if( hb_stackGetActionRequest() & HB_ENDPROC_REQUESTED )
      hb_stackSetActionRequest( 0 );
}
hvm.c7996
HB_EXPORT VOIDhb_xvmEndProc( void )
HB_EXPORT void hb_xvmEndProc( void )
{
   HB_STACK_TLS_PRELOAD

   if( !( hb_stackGetActionRequest() & ( HB_QUIT_REQUESTED | HB_BREAK_REQUESTED ) ) )
      hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
}
hvm.c8004
HB_EXPORT VOIDhb_xvmSeqBegin( void )
HB_EXPORT void hb_xvmSeqBegin( void )
{
   HB_STACK_TLS_PRELOAD

   PHB_ITEM pItem;
   /*
    * Create the SEQUENCE envelope
    * To keep compatibility with pure PCODE evaluation we have
    * use exactly the same SEQUENCE envelope or hb_vmRequestBreak()
    * will not work as expected.
    *
    * [ break return value ]  -2
    * [ recover envelope   ]  -1
    * [                    ] <- new recover base
    */

   /* 1) clear the storage for value returned by BREAK statement */
   hb_stackAllocItem()->type = HB_IT_NIL;
   /* 2) recovery state */
   pItem = hb_stackAllocItem();
   /* mark type as NIL - it's not real item */
   pItem->type = HB_IT_NIL;
   /* address of RECOVER or END opcode - not used in C code */
   pItem->item.asRecover.recover = 0;
   /* store current RECOVER base */
   pItem->item.asRecover.base = hb_stackGetRecoverBase();
   /* store current bCanRecover flag - not used in C code */
   pItem->item.asRecover.flags = 0;
   /* clear new recovery state */
   pItem->item.asRecover.request = 0;

   /* set new recover base */
   hb_stackSetRecoverBase( hb_stackTopOffset() );
}
hvm.c8012
HB_EXPORT BOOLhb_xvmSeqEnd( void )
HB_EXPORT BOOL hb_xvmSeqEnd( void )
{
   HB_STACK_TLS_PRELOAD

   /*
    * remove all items placed on the stack after BEGIN code
    */
   hb_stackRemove( hb_stackGetRecoverBase() );

   /*
    * Remove the SEQUENCE envelope
    * This is executed either at the end of sequence or as the
    * response to the break statement if there is no RECOVER clause
    */

   /* 2) Restore previous recovery base address */
   hb_stackSetRecoverBase( hb_stackItemFromTop( -1 )->item.asRecover.base );
   hb_stackDec();
   /* 1) Discard the value returned by BREAK statement */
   hb_stackPop();

#if defined( HB_MT_VM )
   if( hb_vmThreadRequest )
      hb_vmRequestTest();
#endif
   if( hb_stackGetActionRequest() & ( HB_ENDPROC_REQUESTED | HB_QUIT_REQUESTED ) )
      return TRUE;
   else if( hb_stackGetActionRequest() & HB_BREAK_REQUESTED )
      hb_stackSetActionRequest( 0 );
   return FALSE;
}
hvm.c8047
HB_EXPORT BOOLhb_xvmSeqEndTest( void )
HB_EXPORT BOOL hb_xvmSeqEndTest( void )
{
   HB_STACK_TLS_PRELOAD

#if defined( HB_MT_VM )
   if( hb_vmThreadRequest )
      hb_vmRequestTest();
#endif
   if( ( hb_stackGetActionRequest() &
       ( HB_ENDPROC_REQUESTED | HB_BREAK_REQUESTED | HB_QUIT_REQUESTED ) ) != 0 )
      return TRUE;

   /*
    * remove all items placed on the stack after BEGIN code
    */
   hb_stackRemove( hb_stackGetRecoverBase() );

   /*
    * Remove the SEQUENCE envelope
    * This is executed either at the end of sequence or as the
    * response to the break statement if there is no RECOVER clause
    */

   /* 2) Restore previous recovery base address */
   hb_stackSetRecoverBase( hb_stackItemFromTop( -1 )->item.asRecover.base );
   hb_stackDec();
   /* 1) Discard the value returned by BREAK statement */
   hb_stackPop();
   return FALSE;
}
hvm.c8079
HB_EXPORT BOOLhb_xvmSeqRecover( void )
HB_EXPORT BOOL hb_xvmSeqRecover( void )
{
   HB_STACK_TLS_PRELOAD

   /*
    * Execute the RECOVER code
    */

   /*
    * remove all items placed on the stack after BEGIN code
    */
   hb_stackRemove( hb_stackGetRecoverBase() );

   /* 2) Restore previous recovery base address */
   hb_stackSetRecoverBase( hb_stackItemFromTop( -1 )->item.asRecover.base );
   hb_stackDec();
   /* 1) Leave the value returned from BREAK */

#if defined( HB_MT_VM )
   if( hb_vmThreadRequest )
      hb_vmRequestTest();
#endif
   if( hb_stackGetActionRequest() & ( HB_ENDPROC_REQUESTED | HB_QUIT_REQUESTED ) )
      return TRUE;
   else if( hb_stackGetActionRequest() & HB_BREAK_REQUESTED )
      hb_stackSetActionRequest( 0 );
   return FALSE;
}
hvm.c8110
HB_EXPORT VOIDhb_xvmSeqAlways( void )
HB_EXPORT void hb_xvmSeqAlways( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSeqAlways()"));

   /* Create the SEQUENCE ALWAYS envelope */
   /* 1) clear the storage for RETURN value */
   hb_stackAllocItem()->type = HB_IT_NIL;
   /* 2) recovery state */
   pItem = hb_stackAllocItem();
   /* mark type as NIL - it's not real item */
   pItem->type = HB_IT_NIL;
   /* address of RECOVER or END opcode - not used in C code */
   pItem->item.asRecover.recover = 0;
   /* store current RECOVER base */
   pItem->item.asRecover.base = hb_stackGetRecoverBase();
   /* store current bCanRecover flag - not used in C code */
   pItem->item.asRecover.flags = 0;
   /* clear new recovery state */
   pItem->item.asRecover.request = 0;
   /* set sequence type */
   pItem->item.asRecover.flags = HB_SEQ_DOALWAYS;
   /* set new recover base */
   hb_stackSetRecoverBase( hb_stackTopOffset() );
}
hvm.c8139
HB_EXPORT BOOLhb_xvmAlwaysBegin( void )
HB_EXPORT BOOL hb_xvmAlwaysBegin( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmAlwaysBegin()"));

   /* remove all items placed on the stack after BEGIN code */
   hb_stackRemove( hb_stackGetRecoverBase() );
   /* store and reset action */
   hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request = hb_stackGetActionRequest();
   hb_stackSetActionRequest( 0 );
   /* store RETURN value */
   if( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request & HB_ENDPROC_REQUESTED )
      hb_itemMove( hb_stackItemFromTop( HB_RECOVER_VALUE ), hb_stackReturnItem() );

   HB_XVM_RETURN
}
hvm.c8167
HB_EXPORT BOOLhb_xvmAlwaysEnd( void )
HB_EXPORT BOOL hb_xvmAlwaysEnd( void )
{
   HB_STACK_TLS_PRELOAD
   USHORT uiPrevAction, uiCurrAction;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmAlwaysEnd()"));

   /* remove all items placed on the stack after ALWAYSBEGIN code */
   hb_stackRemove( hb_stackGetRecoverBase() );
   /* restore previous recovery base address */
   hb_stackSetRecoverBase( hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.base );
   uiCurrAction = hb_stackGetActionRequest();
   uiPrevAction = hb_stackItemFromTop( HB_RECOVER_STATE )->item.asRecover.request;
   /* restore requested action */
   if( ( uiCurrAction | uiPrevAction ) & HB_QUIT_REQUESTED )
      hb_stackSetActionRequest( HB_QUIT_REQUESTED );
   else if( ( uiCurrAction | uiPrevAction ) & HB_BREAK_REQUESTED )
      hb_stackSetActionRequest( HB_BREAK_REQUESTED );
   else if( ( uiCurrAction | uiPrevAction ) & HB_ENDPROC_REQUESTED )
      hb_stackSetActionRequest( HB_ENDPROC_REQUESTED );
   else
      hb_stackSetActionRequest( 0 );
   /* remove the ALWAYS envelope */
   hb_stackDec();
   /* restore RETURN value if not overloaded inside ALWAYS code */
   if( !( uiCurrAction & HB_ENDPROC_REQUESTED ) &&
        ( uiPrevAction & HB_ENDPROC_REQUESTED ) )
      hb_stackPopReturn();
   else
      hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8185
HB_EXPORT BOOLhb_xvmSeqBlock( void )
HB_EXPORT BOOL hb_xvmSeqBlock( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSeqBlock()"));

   hb_vmSeqBlock();

   HB_XVM_RETURN
}
hvm.c8219
HB_EXPORT BOOLhb_xvmEnumStart( BYTE nVars, BYTE nDescend )
HB_EXPORT BOOL hb_xvmEnumStart( BYTE nVars, BYTE nDescend )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEnumStart(%d,%d)", nVars, nDescend));

   hb_vmEnumStart( nVars, nDescend );

   HB_XVM_RETURN
}
hvm.c8230
HB_EXPORT BOOLhb_xvmEnumNext( void )
HB_EXPORT BOOL hb_xvmEnumNext( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEnumNext()"));

   hb_vmEnumNext();

   HB_XVM_RETURN
}
hvm.c8241
HB_EXPORT BOOLhb_xvmEnumPrev( void )
HB_EXPORT BOOL hb_xvmEnumPrev( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEnumPrev()"));

   hb_vmEnumPrev();

   HB_XVM_RETURN
}
hvm.c8252
HB_EXPORT VOIDhb_xvmEnumEnd( void )
HB_EXPORT void hb_xvmEnumEnd( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEnumEnd()"));

   hb_vmEnumEnd();
}
hvm.c8263
HB_EXPORT VOIDhb_xvmSetLine( USHORT uiLine )
HB_EXPORT void hb_xvmSetLine( USHORT uiLine )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSetLine(%hu)", uiLine));

   hb_stackBaseItem()->item.asSymbol.stackstate->uiLineNo = uiLine;
#ifndef HB_NO_DEBUG
   if( s_bDebugging )
      hb_vmDebuggerShowLine( uiLine );
#endif
}
hvm.c8270
HB_EXPORT VOIDhb_xvmFrame( int iLocals, int iParams )
HB_EXPORT void hb_xvmFrame( int iLocals, int iParams )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmFrame(%d, %d)", iLocals, iParams));

   hb_vmFrame( ( USHORT ) iLocals, ( BYTE ) iParams );
}
hvm.c8283
HB_EXPORT VOIDhb_xvmVFrame( int iLocals, int iParams )
HB_EXPORT void hb_xvmVFrame( int iLocals, int iParams )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmVFrame(%d, %d)", iLocals, iParams));

   hb_vmVFrame( ( USHORT ) iLocals, ( BYTE ) iParams );
}
hvm.c8290
HB_EXPORT VOIDhb_xvmSFrame( PHB_SYMB pSymbol )
HB_EXPORT void hb_xvmSFrame( PHB_SYMB pSymbol )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSFrame(%p)", pSymbol));

   hb_vmSFrame( pSymbol );
}
hvm.c8297
HB_EXPORT BOOLhb_xvmDo( USHORT uiParams )
HB_EXPORT BOOL hb_xvmDo( USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDo(%hu)", uiParams));

   hb_vmDo( uiParams );

   HB_XVM_RETURN
}
hvm.c8304
HB_EXPORT BOOLhb_xvmFunction( USHORT uiParams )
HB_EXPORT BOOL hb_xvmFunction( USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmFunction(%hu)", uiParams));

   hb_itemSetNil( hb_stackReturnItem() );
   hb_vmDo( uiParams );
   hb_stackPushReturn();

   HB_XVM_RETURN
}
hvm.c8315
HB_EXPORT BOOLhb_xvmSend( USHORT uiParams )
HB_EXPORT BOOL hb_xvmSend( USHORT uiParams )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSend(%hu)", uiParams));

   hb_itemSetNil( hb_stackReturnItem() );
   hb_vmSend( uiParams );
   hb_stackPushReturn();

   HB_XVM_RETURN
}
hvm.c8328
HB_EXPORT BOOLhb_xvmPushObjectVarRef( void )
HB_EXPORT BOOL hb_xvmPushObjectVarRef( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushObjectVarRef()"));

   hb_vmPushObjectVarRef();

   HB_XVM_RETURN
}
hvm.c8341
HB_EXPORT VOIDhb_xvmRetValue( void )
HB_EXPORT void hb_xvmRetValue( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmRetValue()"));

   hb_stackPopReturn();
   hb_stackReturnItem()->type &= ~HB_IT_MEMOFLAG;
}
hvm.c8352
HB_EXPORT VOIDhb_xvmStatics( PHB_SYMB pSymbol, USHORT uiStatics )
HB_EXPORT void hb_xvmStatics( PHB_SYMB pSymbol, USHORT uiStatics )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmStatics(%p,%hu)", pSymbol, uiStatics));

   hb_vmStatics( pSymbol, uiStatics );
}
hvm.c8362
HB_EXPORT VOIDhb_xvmThreadStatics( USHORT uiStatics, const BYTE * statics )
HB_EXPORT void hb_xvmThreadStatics( USHORT uiStatics, const BYTE * statics )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmThreadStatics(%hu,%p)", uiStatics, statics));

   hb_vmInitThreadStatics( uiStatics, statics );
}
hvm.c8369
HB_EXPORT VOIDhb_xvmParameter( PHB_SYMB pSymbol, int iParams )
HB_EXPORT void hb_xvmParameter( PHB_SYMB pSymbol, int iParams )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmParameter(%p,%d)", pSymbol, iParams));

   hb_memvarNewParameter( pSymbol, hb_stackItemFromBase( iParams ) );
}
hvm.c8376
HB_EXPORT VOIDhb_xvmPushLocal( SHORT iLocal )
HB_EXPORT void hb_xvmPushLocal( SHORT iLocal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushLocal(%hd)", iLocal));

   hb_vmPushLocal( iLocal );
}
hvm.c8385
HB_EXPORT VOIDhb_xvmPushLocalByRef( SHORT iLocal )
HB_EXPORT void hb_xvmPushLocalByRef( SHORT iLocal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushLocalByRef(%hd)", iLocal));

   hb_vmPushLocalByRef( iLocal );
}
hvm.c8392
HB_EXPORT VOIDhb_xvmPopLocal( SHORT iLocal )
HB_EXPORT void hb_xvmPopLocal( SHORT iLocal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPopLocal(%hd)", iLocal));

   hb_vmPopLocal( iLocal );
}
hvm.c8399
HB_EXPORT PHB_ITEMhb_xvmLocalPtr( int iLocal )
HB_EXPORT PHB_ITEM hb_xvmLocalPtr( int iLocal )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalPtr(%d)", iLocal));

   if( iLocal >= 0 )
   {
      /* local variable or local parameter */
      return hb_stackLocalVariable( &iLocal );
   }
   else
   {
      /* local variable referenced in a codeblock
       * hb_stackSelfItem() points to a codeblock that is currently evaluated
       */
      return hb_codeblockGetRef( hb_stackSelfItem()->item.asBlock.value, ( LONG ) iLocal );
   }
}
hvm.c8406
HB_EXPORT PHB_ITEMhb_xvmStaticPtr( int iStatic )
HB_EXPORT PHB_ITEM hb_xvmStaticPtr( int iStatic )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmStaticPtr(%d)", iStatic));

   return s_aStatics.item.asArray.value->pItems + hb_stackGetStaticsBase() + iStatic - 1;
}
hvm.c8426
HB_EXPORT VOIDhb_xvmCopyLocals( int iDest, int iSource )
HB_EXPORT void hb_xvmCopyLocals( int iDest, int iSource )
{
   PHB_ITEM pDest;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmCopyLocals(%d,%d)", iDest, iSource));

   pDest = hb_xvmLocalPtr( iDest );
   hb_itemCopyToRef( hb_xvmLocalPtr( iSource ),
                     HB_IS_BYREF( pDest ) ? hb_itemUnRef( pDest ) : pDest );
}
hvm.c8435
HB_EXPORT VOIDhb_xvmPushStatic( USHORT uiStatic )
HB_EXPORT void hb_xvmPushStatic( USHORT uiStatic )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushStatic(%hu)", uiStatic));

   hb_vmPushStatic( uiStatic );
}
hvm.c8446
HB_EXPORT VOIDhb_xvmPushStaticByRef( USHORT uiStatic )
HB_EXPORT void hb_xvmPushStaticByRef( USHORT uiStatic )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushStaticByRef(%hu)", uiStatic));

   hb_vmPushStaticByRef( uiStatic );
}
hvm.c8453
HB_EXPORT VOIDhb_xvmPopStatic( USHORT uiStatic )
HB_EXPORT void hb_xvmPopStatic( USHORT uiStatic )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPopStatic(%hu)", uiStatic));

   hb_vmPopStatic( uiStatic );
}
hvm.c8460
HB_EXPORT BOOLhb_xvmPushVariable( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPushVariable( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPushVariable(%p)", pSymbol));

   hb_vmPushVariable( pSymbol );

   HB_XVM_RETURN
}
hvm.c8467
HB_EXPORT BOOLhb_xvmPopVariable( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPopVariable( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPopVariable(%p)", pSymbol));

   /* See the note above in HB_P_POPVARIABLE */
#if 0
   if( pSymbol->pDynSym && hb_dynsymGetMemvar( pSymbol->pDynSym ) )
      hb_memvarSetValue( pSymbol, hb_stackItemFromTop(-1) );
   else if( hb_rddFieldPut( hb_stackItemFromTop(-1), pSymbol ) == FAILURE )
#endif
      hb_memvarSetValue( pSymbol, hb_stackItemFromTop(-1) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8478
HB_EXPORT VOIDhb_xvmPushBlockShort( const BYTE * pCode, PHB_SYMB pSymbols )
HB_EXPORT void hb_xvmPushBlockShort( const BYTE * pCode, PHB_SYMB pSymbols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushBlockShort(%p, %p)", pCode, pSymbols));

   hb_vmPushBlockShort( pCode, pSymbols, FALSE );
}
hvm.c8496
HB_EXPORT VOIDhb_xvmPushBlock( const BYTE * pCode, PHB_SYMB pSymbols )
HB_EXPORT void hb_xvmPushBlock( const BYTE * pCode, PHB_SYMB pSymbols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushBlock(%p, %p)", pCode, pSymbols));

   hb_vmPushBlock( pCode, pSymbols, FALSE );
}
hvm.c8503
HB_EXPORT VOIDhb_xvmPushSelf( void )
HB_EXPORT void hb_xvmPushSelf( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushSelf()"));

   hb_vmPush( hb_stackSelfItem() );
}
hvm.c8510
HB_EXPORT VOIDhb_xvmPushFuncSymbol( PHB_SYMB pSym )
HB_EXPORT void hb_xvmPushFuncSymbol( PHB_SYMB pSym )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushFuncSymbol(%p)", pSym));

   pItem = hb_stackAllocItem();
   pItem->type = HB_IT_SYMBOL;
   pItem->item.asSymbol.value = pSym;
   pItem->item.asSymbol.stackstate = NULL;
   hb_stackAllocItem()->type = HB_IT_NIL;
}
hvm.c8519
HB_EXPORT BOOLhb_xvmPopLogical( BOOL * pfValue )
HB_EXPORT BOOL hb_xvmPopLogical( BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPopLogical(%p)", pfValue));

   *pfValue = hb_vmPopLogical();

   HB_XVM_RETURN
}
hvm.c8533
HB_EXPORT BOOLhb_xvmPopAlias( void )
HB_EXPORT BOOL hb_xvmPopAlias( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPopAlias()"));

   hb_vmSelectWorkarea( hb_stackItemFromTop( -1 ), NULL ); /* it clears the passed item */
   hb_stackDec();

   HB_XVM_RETURN
}
hvm.c8544
HB_EXPORT BOOLhb_xvmSwapAlias( void )
HB_EXPORT BOOL hb_xvmSwapAlias( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSwapAlias()"));

   hb_vmSwapAlias();

   HB_XVM_RETURN
}
hvm.c8556
HB_EXPORT BOOLhb_xvmPushField( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPushField( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPushField(%p)", pSymbol));

   hb_rddGetFieldValue( hb_stackAllocItem(), pSymbol );

   HB_XVM_RETURN
}
hvm.c8567
HB_EXPORT BOOLhb_xvmPushAlias( void )
HB_EXPORT BOOL hb_xvmPushAlias( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushAlias()"));

   hb_vmPushAlias();

   HB_XVM_RETURN
}
hvm.c8578
HB_EXPORT BOOLhb_xvmPushAliasedField( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPushAliasedField( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPushAliasedField(%p)", pSymbol));

   hb_vmPushAliasedField( pSymbol );

   HB_XVM_RETURN
}
hvm.c8589
HB_EXPORT BOOLhb_xvmPushAliasedVar( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPushAliasedVar( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPushAliasedVar(%p)", pSymbol));

   hb_vmPushAliasedVar( pSymbol );

   HB_XVM_RETURN
}
hvm.c8600
HB_EXPORT BOOLhb_xvmPopField( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPopField( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPopField(%p)", pSymbol));

   hb_rddPutFieldValue( hb_stackItemFromTop(-1), pSymbol );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8611
HB_EXPORT BOOLhb_xvmPushMemvar( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPushMemvar( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPushMemvar(%p)", pSymbol));

   hb_memvarGetValue( hb_stackAllocItem(), pSymbol );

   HB_XVM_RETURN
}
hvm.c8623
HB_EXPORT BOOLhb_xvmPushMemvarByRef( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPushMemvarByRef( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPushMemvarByRef(%p)", pSymbol));

   hb_memvarGetRefer( hb_stackAllocItem(), pSymbol );

   HB_XVM_RETURN
}
hvm.c8634
HB_EXPORT BOOLhb_xvmPopMemvar( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPopMemvar( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPopMemvar(%p)", pSymbol));

   hb_memvarSetValue( pSymbol, hb_stackItemFromTop(-1) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8645
HB_EXPORT BOOLhb_xvmPopAliasedField( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPopAliasedField( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPopAliasedField(%p)", pSymbol));

   hb_vmPopAliasedField( pSymbol );

   HB_XVM_RETURN
}
hvm.c8657
HB_EXPORT BOOLhb_xvmPopAliasedVar( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmPopAliasedVar( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_INFO, ("hb_xvmPopAliasedVar(%p)", pSymbol));

   hb_vmPopAliasedVar( pSymbol );

   HB_XVM_RETURN
}
hvm.c8668
HB_EXPORT VOIDhb_xvmLocalSetInt( int iLocal, LONG lValue )
HB_EXPORT void hb_xvmLocalSetInt( int iLocal, LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalSetInt(%d, %d)", iLocal, lValue));

   if( iLocal >= 0 )
   {
      /* local variable or local parameter */
      pLocal = hb_stackLocalVariable( &iLocal );
      if( HB_IS_BYREF( pLocal ) )
         pLocal = hb_itemUnRef( pLocal );
   }
   else
   {
      /* local variable referenced in a codeblock
       * hb_stackSelfItem() points to a codeblock that is currently evaluated
       */
      pLocal = hb_codeblockGetVar( hb_stackSelfItem(), iLocal );
   }

   if( HB_IS_OBJECT( pLocal ) && hb_objHasOperator( pLocal, HB_OO_OP_ASSIGN ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_ASSIGN, pLocal, pLocal,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      hb_itemPutNL( pLocal, lValue );
   }
}
hvm.c8679
HB_EXPORT BOOLhb_xvmLocalAddInt( int iLocal, LONG lAdd )
HB_EXPORT BOOL hb_xvmLocalAddInt( int iLocal, LONG lAdd )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalAddInt(%d,%ld)", iLocal, lAdd));

   hb_vmAddInt( hb_stackLocalVariable( &iLocal ), lAdd );

   HB_XVM_RETURN
}
hvm.c8714
HB_EXPORT BOOLhb_xvmLocalInc( int iLocal )
HB_EXPORT BOOL hb_xvmLocalInc( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalInc(%d)", iLocal));

   pLocal = hb_stackLocalVariable( &iLocal );
   hb_vmInc( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal );

   HB_XVM_RETURN
}
hvm.c8725
HB_EXPORT BOOLhb_xvmLocalDec( int iLocal )
HB_EXPORT BOOL hb_xvmLocalDec( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalDec(%d)", iLocal));

   pLocal = hb_stackLocalVariable( &iLocal );
   hb_vmDec( HB_IS_BYREF( pLocal ) ? hb_itemUnRef( pLocal ) : pLocal );

   HB_XVM_RETURN
}
hvm.c8738
HB_EXPORT BOOLhb_xvmLocalIncPush( int iLocal )
HB_EXPORT BOOL hb_xvmLocalIncPush( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalInc(%d)", iLocal));

   pLocal = hb_stackLocalVariable( &iLocal );
   if( HB_IS_BYREF( pLocal ) )
      pLocal = hb_itemUnRef( pLocal );
   hb_vmInc( pLocal );
   hb_itemCopy( hb_stackAllocItem(), pLocal );

   HB_XVM_RETURN
}
hvm.c8751
HB_EXPORT BOOLhb_xvmLocalAdd( int iLocal )
HB_EXPORT BOOL hb_xvmLocalAdd( int iLocal )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pLocal;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalAdd(%d)", iLocal));

   pLocal = hb_stackLocalVariable( &iLocal );
   if( HB_IS_BYREF( pLocal ) )
      pLocal = hb_itemUnRef( pLocal );
   hb_vmPlus( pLocal, hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8767
HB_EXPORT BOOLhb_xvmStaticAdd( USHORT uiStatic )
HB_EXPORT BOOL hb_xvmStaticAdd( USHORT uiStatic )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pStatic;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmStaticAdd(%hu)", uiStatic));

   pStatic = s_aStatics.item.asArray.value->pItems + hb_stackGetStaticsBase() + uiStatic - 1;
   if( HB_IS_BYREF( pStatic ) )
      pStatic = hb_itemUnRef( pStatic );
   hb_vmPlus( pStatic, hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8784
HB_EXPORT BOOLhb_xvmMemvarAdd( PHB_SYMB pSymbol )
HB_EXPORT BOOL hb_xvmMemvarAdd( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pMemVar, pVal1, pVal2;

   HB_TRACE(HB_TR_INFO, ("hb_xvmMemvarAdd(%p)", pSymbol));

   pVal1 = hb_stackItemFromTop( -2 );
   pVal2 = hb_stackItemFromTop( -1 );
   if( HB_IS_STRING( pVal1 ) && HB_IS_STRING( pVal2 ) )
   {
      pMemVar = hb_memvarGetItem( pSymbol );
      if( pMemVar )
      {
         hb_vmPlus( pMemVar, pVal1, pVal2 );
         hb_stackPop();
         hb_stackPop();
         HB_XVM_RETURN
      }
   }

   hb_vmPlus( pVal1, pVal1, pVal2 );
   hb_memvarSetValue( pSymbol, pVal1 );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c8801
HB_EXPORT BOOLhb_xvmAnd( void )
HB_EXPORT BOOL hb_xvmAnd( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmAnd()"));

   hb_vmAnd();

   HB_XVM_RETURN
}
hvm.c8830
HB_EXPORT BOOLhb_xvmOr( void )
HB_EXPORT BOOL hb_xvmOr( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmOr()"));

   hb_vmOr();

   HB_XVM_RETURN
}
hvm.c8841
HB_EXPORT BOOLhb_xvmNot( void )
HB_EXPORT BOOL hb_xvmNot( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmNot()"));

   hb_vmNot();

   HB_XVM_RETURN
}
hvm.c8852
HB_EXPORT BOOLhb_xvmNegate( void )
HB_EXPORT BOOL hb_xvmNegate( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmNegate()"));

   hb_vmNegate();

   HB_XVM_RETURN
}
hvm.c8863
HB_EXPORT VOIDhb_xvmDuplicate( void )
HB_EXPORT void hb_xvmDuplicate( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDuplicate()"));

   hb_vmDuplicate();
}
hvm.c8874
HB_EXPORT VOIDhb_xvmDuplUnRef( void )
HB_EXPORT void hb_xvmDuplUnRef( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDuplUnRef()"));

   hb_vmDuplUnRef();
}
hvm.c8881
HB_EXPORT VOIDhb_xvmDuplTwo( void )
HB_EXPORT void hb_xvmDuplTwo( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDuplTwo()"));

   hb_vmDuplTwo();
}
hvm.c8888
HB_EXPORT VOIDhb_xvmPushUnRef( void )
HB_EXPORT void hb_xvmPushUnRef( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushUnRef()"));

   hb_vmPushUnRef();
}
hvm.c8895
HB_EXPORT VOIDhb_xvmSwap( int iCount )
HB_EXPORT void hb_xvmSwap( int iCount )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmSwap(%d)", iCount));

   hb_vmSwap( ( BYTE ) iCount );
}
hvm.c8902
HB_EXPORT BOOLhb_xvmForTest( void )
HB_EXPORT BOOL hb_xvmForTest( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmForTest()"));

   hb_vmForTest();

   HB_XVM_RETURN
}
hvm.c8909
HB_EXPORT VOIDhb_xvmFuncPtr( void )
HB_EXPORT void hb_xvmFuncPtr( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmFuncPtr()"));

   hb_vmFuncPtr();
}
hvm.c8920
HB_EXPORT BOOLhb_xvmEqual( void )
HB_EXPORT BOOL hb_xvmEqual( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEqual()"));

   hb_vmEqual();

   HB_XVM_RETURN
}
hvm.c8927
HB_EXPORT BOOLhb_xvmExactlyEqual( void )
HB_EXPORT BOOL hb_xvmExactlyEqual( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmExactlyEqual()"));

   hb_vmExactlyEqual();

   HB_XVM_RETURN
}
hvm.c8938
HB_EXPORT BOOLhb_xvmEqualInt( LONG lValue )
HB_EXPORT BOOL hb_xvmEqualInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEqualInt(%ld)", lValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NIL( pItem ) )
   {
      pItem->type = HB_IT_LOGICAL;
      pItem->item.asLogical.value = FALSE;
   }
   else if( HB_IS_NUMINT( pItem ) )
   {
      pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) == ( HB_LONG ) lValue;
      pItem->type = HB_IT_LOGICAL;
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      double dNumber = hb_vmPopNumber();
      hb_vmPushLogical( dNumber == ( double ) lValue );
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_EQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_EQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1071, NULL, "=", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }

   HB_XVM_RETURN
}
hvm.c8949
HB_EXPORT BOOLhb_xvmEqualIntIs( LONG lValue, BOOL * pfValue )
HB_EXPORT BOOL hb_xvmEqualIntIs( LONG lValue, BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmEqualIntIs(%ld,%p)", lValue, pfValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NIL( pItem ) )
   {
      * pfValue = FALSE;
      hb_stackDec();
   }
   else if( HB_IS_NUMINT( pItem ) )
   {
      * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) == ( HB_LONG ) lValue;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      * pfValue = hb_vmPopNumber() == ( double ) lValue;
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_EQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_EQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return hb_xvmPopLogical( pfValue );
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1071, NULL, "=", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
         return hb_xvmPopLogical( pfValue );
      }
   }

   HB_XVM_RETURN
}
hvm.c8997
HB_EXPORT BOOLhb_xvmNotEqual( void )
HB_EXPORT BOOL hb_xvmNotEqual( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmNotEqual()"));

   hb_vmNotEqual();

   HB_XVM_RETURN
}
hvm.c9046
HB_EXPORT BOOLhb_xvmNotEqualInt( LONG lValue )
HB_EXPORT BOOL hb_xvmNotEqualInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmNotEqualInt(%ld)", lValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NIL( pItem ) )
   {
      pItem->type = HB_IT_LOGICAL;
      pItem->item.asLogical.value = TRUE;
   }
   else if( HB_IS_NUMINT( pItem ) )
   {
      pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) != ( HB_LONG ) lValue;
      pItem->type = HB_IT_LOGICAL;
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      double dNumber = hb_vmPopNumber();
      hb_vmPushLogical( dNumber != ( double ) lValue );
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_NOTEQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_NOTEQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1072, NULL, "<>", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }

   HB_XVM_RETURN
}
hvm.c9057
HB_EXPORT BOOLhb_xvmNotEqualIntIs( LONG lValue, BOOL * pfValue )
HB_EXPORT BOOL hb_xvmNotEqualIntIs( LONG lValue, BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmNotEqualIntIs(%ld,%p)", lValue, pfValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NIL( pItem ) )
   {
      * pfValue = TRUE;
      hb_stackDec();
   }
   else if( HB_IS_NUMINT( pItem ) )
   {
      * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) != ( HB_LONG ) lValue;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      * pfValue = hb_vmPopNumber() != ( double ) lValue;
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_NOTEQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_NOTEQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return hb_xvmPopLogical( pfValue );
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1072, NULL, "<>", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
         return hb_xvmPopLogical( pfValue );
      }
   }

   HB_XVM_RETURN
}
hvm.c9105
HB_EXPORT BOOLhb_xvmLess( void )
HB_EXPORT BOOL hb_xvmLess( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLess()"));

   hb_vmLess();

   HB_XVM_RETURN
}
hvm.c9154
HB_EXPORT BOOLhb_xvmLessThenInt( LONG lValue )
HB_EXPORT BOOL hb_xvmLessThenInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLessThenInt(%ld)", lValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) < ( HB_LONG ) lValue;
      pItem->type = HB_IT_LOGICAL;
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      hb_vmPushLogical( hb_vmPopNumber() < ( double ) lValue );
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_LESS ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_LESS, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1073, NULL, "<", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }

   HB_XVM_RETURN
}
hvm.c9165
HB_EXPORT BOOLhb_xvmLessThenIntIs( LONG lValue, BOOL * pfValue )
HB_EXPORT BOOL hb_xvmLessThenIntIs( LONG lValue, BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLessThenIntIs(%ld,%p)", lValue, pfValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) < ( HB_LONG ) lValue;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      * pfValue = hb_vmPopNumber() < ( double ) lValue;
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_LESS ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_LESS, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return hb_xvmPopLogical( pfValue );
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1073, NULL, "<", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
         return hb_xvmPopLogical( pfValue );
      }
   }

   HB_XVM_RETURN
}
hvm.c9207
HB_EXPORT BOOLhb_xvmLessEqual( void )
HB_EXPORT BOOL hb_xvmLessEqual( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLessEqual()"));

   hb_vmLessEqual();

   HB_XVM_RETURN
}
hvm.c9251
HB_EXPORT BOOLhb_xvmLessEqualThenInt( LONG lValue )
HB_EXPORT BOOL hb_xvmLessEqualThenInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLessEqualThenInt(%ld)", lValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) <= ( HB_LONG ) lValue;
      pItem->type = HB_IT_LOGICAL;
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      hb_vmPushLogical( hb_vmPopNumber() <= ( double ) lValue );
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_LESSEQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_LESSEQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1074, NULL, "<=", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }

   HB_XVM_RETURN
}
hvm.c9262
HB_EXPORT BOOLhb_xvmLessEqualThenIntIs( LONG lValue, BOOL * pfValue )
HB_EXPORT BOOL hb_xvmLessEqualThenIntIs( LONG lValue, BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLessEqualThenIntIs(%ld,%p)", lValue, pfValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) <= ( HB_LONG ) lValue;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      * pfValue = hb_vmPopNumber() <= ( double ) lValue;
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_LESSEQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_LESSEQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return hb_xvmPopLogical( pfValue );
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1074, NULL, "<=", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
         return hb_xvmPopLogical( pfValue );
      }
   }

   HB_XVM_RETURN
}
hvm.c9304
HB_EXPORT BOOLhb_xvmGreater( void )
HB_EXPORT BOOL hb_xvmGreater( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmGreater()"));

   hb_vmGreater();

   HB_XVM_RETURN
}
hvm.c9348
HB_EXPORT BOOLhb_xvmGreaterThenInt( LONG lValue )
HB_EXPORT BOOL hb_xvmGreaterThenInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmGreaterThenInt(%ld)", lValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) > ( HB_LONG ) lValue;
      pItem->type = HB_IT_LOGICAL;
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      hb_vmPushLogical( hb_vmPopNumber() > ( double ) lValue );
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_GREATER ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_GREATER, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1075, NULL, ">", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }

   HB_XVM_RETURN
}
hvm.c9359
HB_EXPORT BOOLhb_xvmGreaterThenIntIs( LONG lValue, BOOL * pfValue )
HB_EXPORT BOOL hb_xvmGreaterThenIntIs( LONG lValue, BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmGreaterThenIntIs(%ld,%p)", lValue, pfValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) > ( HB_LONG ) lValue;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      * pfValue = hb_vmPopNumber() > ( double ) lValue;
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_GREATER ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_GREATER, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return hb_xvmPopLogical( pfValue );
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1075, NULL, ">", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
         return hb_xvmPopLogical( pfValue );
      }
   }

   HB_XVM_RETURN
}
hvm.c9401
HB_EXPORT BOOLhb_xvmGreaterEqual( void )
HB_EXPORT BOOL hb_xvmGreaterEqual( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmGreaterEqual()"));

   hb_vmGreaterEqual();

   HB_XVM_RETURN
}
hvm.c9445
HB_EXPORT BOOLhb_xvmGreaterEqualThenInt( LONG lValue )
HB_EXPORT BOOL hb_xvmGreaterEqualThenInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmGreaterEqualThenInt(%ld)", lValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      pItem->item.asLogical.value = HB_ITEM_GET_NUMINTRAW( pItem ) >= ( HB_LONG ) lValue;
      pItem->type = HB_IT_LOGICAL;
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      hb_vmPushLogical( hb_vmPopNumber() >= ( double ) lValue );
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_GREATEREQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_GREATEREQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1076, NULL, ">=", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
      }
   }

   HB_XVM_RETURN
}
hvm.c9456
HB_EXPORT BOOLhb_xvmGreaterEqualThenIntIs( LONG lValue, BOOL * pfValue )
HB_EXPORT BOOL hb_xvmGreaterEqualThenIntIs( LONG lValue, BOOL * pfValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmGreaterEqualThenIntIs(%ld,%p)", lValue, pfValue));

   pItem = hb_stackItemFromTop( -1 );
   if( HB_IS_NUMINT( pItem ) )
   {
      * pfValue = HB_ITEM_GET_NUMINTRAW( pItem ) >= ( HB_LONG ) lValue;
      hb_stackDec();
   }
   else if( HB_IS_NUMERIC( pItem ) )
   {
      * pfValue = hb_vmPopNumber() >= ( double ) lValue;
   }
   else if( hb_objHasOperator( pItem, HB_OO_OP_GREATEREQUAL ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_GREATEREQUAL, pItem, pItem,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
      return hb_xvmPopLogical( pfValue );
   }
   else
   {
      PHB_ITEM pResult;

      hb_vmPushLong( lValue );
      pResult = hb_errRT_BASE_Subst( EG_ARG, 1074, NULL, "<=", 2, pItem, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();
         hb_itemMove( pItem, pResult );
         hb_itemRelease( pResult );
         return hb_xvmPopLogical( pfValue );
      }
   }

   HB_XVM_RETURN
}
hvm.c9498
HB_EXPORT BOOLhb_xvmInstring( void )
HB_EXPORT BOOL hb_xvmInstring( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmInstring()"));

   hb_vmInstring();

   HB_XVM_RETURN
}
hvm.c9542
HB_EXPORT BOOLhb_xvmAddInt( LONG lAdd )
HB_EXPORT BOOL hb_xvmAddInt( LONG lAdd )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmAddInt(%ld)", lAdd));

   hb_vmAddInt( hb_stackItemFromTop( -1 ), lAdd );

   HB_XVM_RETURN
}
hvm.c9553
HB_EXPORT BOOLhb_xvmPlus( void )
HB_EXPORT BOOL hb_xvmPlus( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPlus()"));

   hb_vmPlus( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ),
              hb_stackItemFromTop( -1 ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9564
HB_EXPORT BOOLhb_xvmPlusEq( void )
HB_EXPORT BOOL hb_xvmPlusEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPlusEq()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   pValue = hb_stackItemFromTop( -1 );
   hb_vmPlus( pResult, pResult, pValue );
   hb_itemCopy( pValue, pResult );
   hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9577
HB_EXPORT BOOLhb_xvmPlusEqPop( void )
HB_EXPORT BOOL hb_xvmPlusEqPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPlusEqPop()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   hb_vmPlus( pResult, pResult, hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9594
HB_EXPORT BOOLhb_xvmMinus( void )
HB_EXPORT BOOL hb_xvmMinus( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMinus()"));

   hb_vmMinus( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ),
               hb_stackItemFromTop( -1 ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9609
HB_EXPORT BOOLhb_xvmMinusEq( void )
HB_EXPORT BOOL hb_xvmMinusEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMinusEq()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   pValue = hb_stackItemFromTop( -1 );
   hb_vmMinus( pResult, pResult, pValue );
   hb_itemCopy( pValue, pResult );
   hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9622
HB_EXPORT BOOLhb_xvmMinusEqPop( void )
HB_EXPORT BOOL hb_xvmMinusEqPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMinusEqPop()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   hb_vmMinus( pResult, pResult, hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9639
HB_EXPORT BOOLhb_xvmMultByInt( LONG lValue )
HB_EXPORT BOOL hb_xvmMultByInt( LONG lValue )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMultByInt(%ld)", lValue));

   pValue = hb_stackItemFromTop( -1 );

   if( HB_IS_NUMERIC( pValue ) )
   {
      int iDec;
      double dValue = hb_itemGetNDDec( pValue, &iDec );

      hb_itemPutNumType( pValue, dValue * lValue, iDec,
                         HB_ITEM_TYPERAW( pValue ), HB_IT_INTEGER );
   }
   else if( hb_objHasOperator( pValue, HB_OO_OP_MULT ) )
   {
      hb_vmPushLong( lValue );
      hb_objOperatorCall( HB_OO_OP_MULT, pValue, pValue,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pSubst;

      hb_vmPushLong( lValue );
      pSubst = hb_errRT_BASE_Subst( EG_ARG, 1083, NULL, "*", 2, pValue, hb_stackItemFromTop( -1 ) );

      if( pSubst )
      {
         hb_stackPop();
         hb_itemMove( pValue, pSubst );
         hb_itemRelease( pSubst );
      }
   }

   HB_XVM_RETURN
}
hvm.c9654
HB_EXPORT BOOLhb_xvmMult( void )
HB_EXPORT BOOL hb_xvmMult( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMult()"));

   hb_vmMult( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9696
HB_EXPORT BOOLhb_xvmMultEq( void )
HB_EXPORT BOOL hb_xvmMultEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMultEq()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   pValue = hb_stackItemFromTop( -1 );
   hb_vmMult( pResult, pResult, pValue );
   hb_itemCopy( pValue, pResult );
   hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9708
HB_EXPORT BOOLhb_xvmMultEqPop( void )
HB_EXPORT BOOL hb_xvmMultEqPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMultEqPop()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   hb_vmMult( pResult, pResult, hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9725
HB_EXPORT BOOLhb_xvmDivideByInt( LONG lDivisor )
HB_EXPORT BOOL hb_xvmDivideByInt( LONG lDivisor )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDivideByInt(%ld)", lDivisor));

   pValue = hb_stackItemFromTop( -1 );

   if( HB_IS_NUMERIC( pValue ) )
   {
      if( lDivisor == 0 )
      {
         PHB_ITEM pSubst;

         hb_vmPushLong( lDivisor );
         pSubst = hb_errRT_BASE_Subst( EG_ZERODIV, 1340, NULL, "/", 2, pValue, hb_stackItemFromTop( -1 ) );

         if( pSubst )
         {
            hb_stackPop();
            hb_itemMove( pValue, pSubst );
            hb_itemRelease( pSubst );
         }
      }
      else
      {
         hb_itemPutND( pValue, hb_itemGetND( pValue ) / lDivisor );
      }
   }
   else if( hb_objHasOperator( pValue, HB_OO_OP_DIVIDE ) )
   {
      hb_vmPushLong( lDivisor );
      hb_objOperatorCall( HB_OO_OP_DIVIDE, pValue, pValue,
                          hb_stackItemFromTop( -1 ), NULL );
      hb_stackPop();
   }
   else
   {
      PHB_ITEM pSubst;

      hb_vmPushLong( lDivisor );
      pSubst = hb_errRT_BASE_Subst( EG_ARG, 1084, NULL, "/", 2, pValue, hb_stackItemFromTop( -1 ) );

      if( pSubst )
      {
         hb_stackPop();
         hb_itemMove( pValue, pSubst );
         hb_itemRelease( pSubst );
      }
   }

   HB_XVM_RETURN
}
hvm.c9740
HB_EXPORT BOOLhb_xvmDivide( void )
HB_EXPORT BOOL hb_xvmDivide( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDivide()"));

   hb_vmDivide( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9795
HB_EXPORT BOOLhb_xvmDivEq( void )
HB_EXPORT BOOL hb_xvmDivEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDivEq()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   pValue = hb_stackItemFromTop( -1 );
   hb_vmDivide( pResult, pResult, pValue );
   hb_itemCopy( pValue, pResult );
   hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9807
HB_EXPORT BOOLhb_xvmDivEqPop( void )
HB_EXPORT BOOL hb_xvmDivEqPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDivEqPop()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   hb_vmDivide( pResult, pResult, hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9824
HB_EXPORT BOOLhb_xvmModulus( void )
HB_EXPORT BOOL hb_xvmModulus( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmModulus()"));

   hb_vmModulus( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9839
HB_EXPORT BOOLhb_xvmModEq( void )
HB_EXPORT BOOL hb_xvmModEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmModEq()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   pValue = hb_stackItemFromTop( -1 );
   hb_vmModulus( pResult, pResult, pValue );
   hb_itemCopy( pValue, pResult );
   hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9851
HB_EXPORT BOOLhb_xvmModEqPop( void )
HB_EXPORT BOOL hb_xvmModEqPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmModEqPop()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   hb_vmModulus( pResult, pResult, hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9868
HB_EXPORT BOOLhb_xvmPower( void )
HB_EXPORT BOOL hb_xvmPower( void )
{
   HB_STACK_TLS_PRELOAD
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPower()"));

   hb_vmPower( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9883
HB_EXPORT BOOLhb_xvmExpEq( void )
HB_EXPORT BOOL hb_xvmExpEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmExpEq()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   pValue = hb_stackItemFromTop( -1 );
   hb_vmPower( pResult, pResult, pValue );
   hb_itemCopy( pValue, pResult );
   hb_itemMove( hb_stackItemFromTop( -2 ), pValue );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9894
HB_EXPORT BOOLhb_xvmExpEqPop( void )
HB_EXPORT BOOL hb_xvmExpEqPop( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmExpEqPop()"));

   pResult = hb_itemUnRef( hb_stackItemFromTop( -2 ) );
   hb_vmPower( pResult, pResult, hb_stackItemFromTop( -1 ) );
   hb_stackPop();
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9911
HB_EXPORT BOOLhb_xvmInc( void )
HB_EXPORT BOOL hb_xvmInc( void )
{
   HB_STACK_TLS_PRELOAD
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmInc()"));

   hb_vmInc( hb_stackItemFromTop( -1 ) );

   HB_XVM_RETURN
}
hvm.c9926
HB_EXPORT BOOLhb_xvmIncEq( void )
HB_EXPORT BOOL hb_xvmIncEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue, pTemp;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmIncEq()"));

   pResult = hb_stackItemFromTop( -1 );
   pValue = hb_itemUnRef( pResult );
   hb_vmInc( pValue );
   pTemp = hb_stackAllocItem();
   hb_itemCopy( pTemp, pValue );
   hb_itemMove( pResult, pTemp );
   hb_stackDec();

   HB_XVM_RETURN
}
hvm.c9936
HB_EXPORT BOOLhb_xvmIncEqPop( void )
HB_EXPORT BOOL hb_xvmIncEqPop( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmIncEqPop()"));

   hb_vmInc( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9954
HB_EXPORT BOOLhb_xvmDec( void )
HB_EXPORT BOOL hb_xvmDec( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDec()"));

   hb_vmDec( hb_stackItemFromTop( -1 ) );

   HB_XVM_RETURN
}
hvm.c9966
HB_EXPORT BOOLhb_xvmDecEq( void )
HB_EXPORT BOOL hb_xvmDecEq( void )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pResult, pValue, pTemp;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDecEq()"));

   pResult = hb_stackItemFromTop( -1 );
   pValue = hb_itemUnRef( pResult );
   hb_vmDec( pValue );
   pTemp = hb_stackAllocItem();
   hb_itemCopy( pTemp, pValue );
   hb_itemMove( pResult, pTemp );
   hb_stackDec();

   HB_XVM_RETURN
}
hvm.c9977
HB_EXPORT BOOLhb_xvmDecEqPop( void )
HB_EXPORT BOOL hb_xvmDecEqPop( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmDecEqPop()"));

   hb_vmDec( hb_itemUnRef( hb_stackItemFromTop( -1 ) ) );
   hb_stackPop();

   HB_XVM_RETURN
}
hvm.c9995
HB_EXPORT VOIDhb_xvmArrayDim( USHORT uiDimensions )
HB_EXPORT void hb_xvmArrayDim( USHORT uiDimensions )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayDim(%hu)", uiDimensions));

   hb_vmArrayDim( uiDimensions );
}
hvm.c10007
HB_EXPORT VOIDhb_xvmArrayGen( ULONG ulElements )
HB_EXPORT void hb_xvmArrayGen( ULONG ulElements )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayGen(%lu)", ulElements));

   hb_vmArrayGen( ulElements );
}
hvm.c10014
HB_EXPORT VOIDhb_xvmHashGen( ULONG ulElements )
HB_EXPORT void hb_xvmHashGen( ULONG ulElements )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmHashGen(%lu)", ulElements));

   hb_vmHashGen( ulElements );
}
hvm.c10021
STATIC VOIDhb_vmArrayItemPush( ULONG ulIndex )
static void hb_vmArrayItemPush( ULONG ulIndex )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pArray;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayItemPush(%lu)", ulIndex));

   pArray = hb_stackItemFromTop( -1 );

   if( HB_IS_ARRAY( pArray ) )
   {
      if( HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
      {
         hb_vmPushNumInt( ulIndex );
         hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                             hb_stackItemFromTop( -1 ), NULL );
         hb_stackPop();
         return;
      }

      if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->ulLen ) )
      {
         PHB_ITEM pItem = hb_stackAllocItem();

         hb_itemCopy( pItem, pArray->item.asArray.value->pItems + ulIndex - 1 );
         hb_itemMove( pArray, pItem );
         hb_stackDec();
      }
      else
      {
         hb_vmPushNumInt( ulIndex );
         if( !HB_IS_OBJECT( pArray ) &&
             hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                                 hb_stackItemFromTop( -1 ), NULL ) )
            hb_stackPop();
         else
#ifdef HB_C52_STRICT
            hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 0 );
#else
            hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ),
                           2, pArray, hb_stackItemFromTop( -1 ) );
#endif
      }
   }
   else if( HB_IS_HASH( pArray ) )
   {
      PHB_ITEM pValue;

      hb_vmPushNumInt( ulIndex );
      pValue = hb_hashGetItemPtr( pArray, hb_stackItemFromTop( -1 ), HB_HASH_AUTOADD_ACCESS );

      if( pValue )
      {
         hb_itemCopy( hb_stackItemFromTop( -1 ), pValue );
         hb_itemMove( pArray, hb_stackItemFromTop( -1 ) );
         hb_stackDec();
      }
      else if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                                   hb_stackItemFromTop( -1 ), NULL ) )
         hb_stackPop();
      else
         hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, hb_stackItemFromTop( -1 ) );
   }
   else
   {
      hb_vmPushNumInt( ulIndex );
      if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                              hb_stackItemFromTop( -1 ), NULL ) )
         hb_stackPop();
      else
         hb_errRT_BASE( EG_ARG, 1068, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ), 2, pArray, hb_stackItemFromTop( -1 ) );
   }
}
hvm.c10028
STATIC VOIDhb_vmArrayItemPop( ULONG ulIndex )
static void hb_vmArrayItemPop( ULONG ulIndex )
{
   HB_STACK_TLS_PRELOAD
   PHB_ITEM pValue;
   PHB_ITEM pArray;

   HB_TRACE(HB_TR_DEBUG, ("hb_vmArrayItemPop(%lu", ulIndex));

   pValue = hb_stackItemFromTop( -2 );
   pArray = hb_stackItemFromTop( -1 );

   if( HB_IS_BYREF( pArray ) )
      pArray = hb_itemUnRef( pArray );

   if( HB_IS_ARRAY( pArray ) )
   {
      if( HB_IS_OBJECT( pArray ) && hb_objHasOperator( pArray, HB_OO_OP_ARRAYINDEX ) )
      {
         hb_vmPushNumInt( ulIndex );
         hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                             hb_stackItemFromTop( -1 ), pValue );
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
         return;
      }

      if( HB_IS_VALID_INDEX( ulIndex, pArray->item.asArray.value->ulLen ) )
      {
         pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
         hb_itemMoveRef( pArray->item.asArray.value->pItems + ulIndex - 1, pValue );
         hb_stackPop();
         hb_stackDec();    /* value was moved above hb_stackDec() is enough */
      }
      else
      {
         hb_vmPushNumInt( ulIndex );
         if( !HB_IS_OBJECT( pArray ) &&
             hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                                 hb_stackItemFromTop( -1 ), pValue ) )
         {
            hb_stackPop();
            hb_stackPop();
            hb_stackPop();
         }
         else
#ifdef HB_C52_STRICT
            hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 0 );
#else
            hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ),
                           1, hb_stackItemFromTop( -1 ) );
#endif
      }
   }
   else if( HB_IS_HASH( pArray ) )
   {
      PHB_ITEM pDest;

      hb_vmPushNumInt( ulIndex );
      pDest = hb_hashGetItemPtr( pArray, hb_stackItemFromTop( -1 ), HB_HASH_AUTOADD_ASSIGN );

      if( pDest )
      {
         pValue->type &= ~( HB_IT_MEMOFLAG | HB_IT_DEFAULT );
         hb_itemMoveRef( pDest, pValue );
         hb_stackPop();
         hb_stackPop();
         hb_stackDec();    /* value was moved above hb_stackDec() is enough */
      }
      else if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                                   hb_stackItemFromTop( -1 ), pValue ) )
      {
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
      }
      else
         hb_errRT_BASE( EG_BOUND, 1133, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ), 3, pArray, hb_stackItemFromTop( -1 ), pValue );
   }
   else
   {
      hb_vmPushNumInt( ulIndex );
      if( hb_objOperatorCall( HB_OO_OP_ARRAYINDEX, pArray, pArray,
                              hb_stackItemFromTop( -1 ), pValue ) )
      {
         hb_stackPop();
         hb_stackPop();
         hb_stackPop();
      }
      else
         hb_errRT_BASE( EG_ARG, 1069, NULL, hb_langDGetErrorDesc( EG_ARRASSIGN ),
                        1, hb_stackItemFromTop( -1 ) );
   }
}
hvm.c10102
HB_EXPORT BOOLhb_xvmArrayPush( void )
HB_EXPORT BOOL hb_xvmArrayPush( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayPush()"));

   hb_vmArrayPush();

   HB_XVM_RETURN
}
hvm.c10198
HB_EXPORT BOOLhb_xvmArrayPushRef( void )
HB_EXPORT BOOL hb_xvmArrayPushRef( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayPushRef()"));

   hb_vmArrayPushRef();

   HB_XVM_RETURN
}
hvm.c10209
HB_EXPORT BOOLhb_xvmArrayItemPush( ULONG ulIndex )
HB_EXPORT BOOL hb_xvmArrayItemPush( ULONG ulIndex )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayItemPush(%lu)", ulIndex));

   hb_vmArrayItemPush( ulIndex );

   HB_XVM_RETURN
}
hvm.c10220
HB_EXPORT BOOLhb_xvmArrayPop( void )
HB_EXPORT BOOL hb_xvmArrayPop( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayPop()"));

   hb_vmArrayPop();

   HB_XVM_RETURN
}
hvm.c10231
HB_EXPORT BOOLhb_xvmArrayItemPop( ULONG ulIndex )
HB_EXPORT BOOL hb_xvmArrayItemPop( ULONG ulIndex )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmArrayItemPop(%lu)", ulIndex));

   hb_vmArrayItemPop( ulIndex );

   HB_XVM_RETURN
}
hvm.c10242
HB_EXPORT VOIDhb_xvmPushDouble( double dNumber, int iWidth, int iDec )
HB_EXPORT void hb_xvmPushDouble( double dNumber, int iWidth, int iDec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushDouble(%lf, %d, %d)", dNumber, iWidth, iDec));

   hb_vmPushDoubleConst( dNumber, iWidth, iDec );
}
hvm.c10253
HB_EXPORT VOIDhb_xvmPushLongLong( double dNumber )
HB_EXPORT void hb_xvmPushLongLong( double dNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushLongLong(%l.0f)", dNumber));

   hb_vmPushDoubleConst( dNumber, HB_DEFAULT_WIDTH, 0 );
}
hvm.c10261
HB_EXPORT VOIDhb_xvmPushLongLong( LONGLONG llNumber )
HB_EXPORT void hb_xvmPushLongLong( LONGLONG llNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushLongLong(%" PFLL "i)", llNumber));

   hb_vmPushLongLongConst( llNumber );
}
hvm.c10268
HB_EXPORT VOIDhb_xvmLocalName( USHORT uiLocal, char * szLocalName )
HB_EXPORT void hb_xvmLocalName( USHORT uiLocal, char * szLocalName )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmLocalName(%hu, %s)", uiLocal, szLocalName));

   hb_vmLocalName( uiLocal, szLocalName );
}
hvm.c10276
HB_EXPORT VOIDhb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName )
HB_EXPORT void hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmStaticName(%d, %hu, %s)", (int)bIsGlobal, uiStatic, szStaticName));

   hb_vmStaticName( bIsGlobal, uiStatic, szStaticName );
}
hvm.c10283
HB_EXPORT VOIDhb_xvmModuleName( char * szModuleName )
HB_EXPORT void hb_xvmModuleName( char * szModuleName )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmModuleName(%s)", szModuleName));

   hb_vmModuleName( szModuleName );
}
hvm.c10290
HB_EXPORT BOOLhb_xvmMacroArrayGen( USHORT uiArgSets )
HB_EXPORT BOOL hb_xvmMacroArrayGen( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroArrayGen(%hu)", uiArgSets));

   hb_vmMacroArrayGen( uiArgSets );

   HB_XVM_RETURN
}
hvm.c10297
HB_EXPORT BOOLhb_xvmMacroDo( USHORT uiArgSets )
HB_EXPORT BOOL hb_xvmMacroDo( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroDo(%hu)", uiArgSets));

   hb_vmMacroDo( uiArgSets );

   HB_XVM_RETURN
}
hvm.c10308
HB_EXPORT BOOLhb_xvmMacroFunc( USHORT uiArgSets )
HB_EXPORT BOOL hb_xvmMacroFunc( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroFunc(%hu)", uiArgSets));

   hb_vmMacroFunc( uiArgSets );

   HB_XVM_RETURN
}
hvm.c10319
HB_EXPORT BOOLhb_xvmMacroSend( USHORT uiArgSets )
HB_EXPORT BOOL hb_xvmMacroSend( USHORT uiArgSets )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroSend(%hu)", uiArgSets));

   hb_vmMacroSend( uiArgSets );

   HB_XVM_RETURN
}
hvm.c10330
HB_EXPORT BOOLhb_xvmMacroPush( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPush( BYTE bFlags )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPush(%d)", bFlags));

   hb_macroGetValue( hb_stackItemFromTop( -1 ), 0, bFlags );

   HB_XVM_RETURN
}
hvm.c10341
HB_EXPORT BOOLhb_xvmMacroPushRef( void )
HB_EXPORT BOOL hb_xvmMacroPushRef( void )
{
   HB_STACK_TLS_PRELOAD

   PHB_ITEM pMacro;

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushRef()"));

   pMacro = hb_stackItemFromTop( -1 );
   hb_macroPushSymbol( pMacro );
   if( hb_stackGetActionRequest() == 0 )
      hb_memvarGetRefer( pMacro, pMacro->item.asSymbol.value );

   HB_XVM_RETURN
}
hvm.c10352
HB_EXPORT BOOLhb_xvmMacroPushIndex( void )
HB_EXPORT BOOL hb_xvmMacroPushIndex( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushIndex()"));

   hb_vmMacroPushIndex();

   HB_XVM_RETURN
}
hvm.c10368
HB_EXPORT BOOLhb_xvmMacroPushList( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPushList( BYTE bFlags )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushList(%d)", bFlags));

   hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHLIST, bFlags );

   HB_XVM_RETURN
}
hvm.c10379
HB_EXPORT BOOLhb_xvmMacroPushPare( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPushPare( BYTE bFlags )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushPare(%d)", bFlags));

   hb_macroGetValue( hb_stackItemFromTop( -1 ), HB_P_MACROPUSHPARE, bFlags );

   HB_XVM_RETURN
}
hvm.c10390
HB_EXPORT BOOLhb_xvmMacroPushAliased( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPushAliased( BYTE bFlags )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPushAliased(%d)", bFlags));

   hb_macroPushAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), bFlags );

   HB_XVM_RETURN
}
hvm.c10401
HB_EXPORT BOOLhb_xvmMacroPop( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPop( BYTE bFlags )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPop(%d)", bFlags));

   hb_macroSetValue( hb_stackItemFromTop( -1 ), bFlags );

   HB_XVM_RETURN
}
hvm.c10412
HB_EXPORT BOOLhb_xvmMacroPopAliased( BYTE bFlags )
HB_EXPORT BOOL hb_xvmMacroPopAliased( BYTE bFlags )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroPopAliased(%d)", bFlags));

   hb_macroPopAliasedValue( hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ), bFlags );

   HB_XVM_RETURN
}
hvm.c10423
HB_EXPORT BOOLhb_xvmMacroSymbol( void )
HB_EXPORT BOOL hb_xvmMacroSymbol( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroSymbol()"));

   hb_macroPushSymbol( hb_stackItemFromTop( -1 ) );

   HB_XVM_RETURN
}
hvm.c10434
HB_EXPORT BOOLhb_xvmMacroText( void )
HB_EXPORT BOOL hb_xvmMacroText( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmMacroText()"));

   hb_macroTextValue( hb_stackItemFromTop( -1 ) );

   HB_XVM_RETURN
}
hvm.c10445
HB_EXPORT VOIDhb_xvmPushVParams( void )
HB_EXPORT void hb_xvmPushVParams( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmPushVParams()"));

   hb_vmPushVParams();
}
hvm.c10456
HB_EXPORT VOIDhb_xvmWithObjectStart( void )
HB_EXPORT void hb_xvmWithObjectStart( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_xvmWithObjectStart()"));

   hb_vmWithObjectStart();
}
hvm.c10462
HB_EXPORT VOIDhb_xvmWithObjectEnd( void )
HB_EXPORT void hb_xvmWithObjectEnd( void )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmWithObjectEnd()"));

   hb_stackPop();  /* remove with object envelope */
   hb_stackPop();  /* remove implicit object */
}
hvm.c10469
HB_EXPORT VOIDhb_xvmWithObjectMessage( PHB_SYMB pSymbol )
HB_EXPORT void hb_xvmWithObjectMessage( PHB_SYMB pSymbol )
{
   HB_STACK_TLS_PRELOAD

   HB_TRACE(HB_TR_DEBUG, ("hb_xvmWithObjectMessage(%p)", pSymbol));

   if( pSymbol )
      hb_vmPushSymbol( pSymbol );
   hb_vmPush( hb_stackWithObjectItem() );
}
hvm.c10479
HB_EXPORT ULONGhb_vmFlagEnabled( ULONG flags )
HB_EXPORT ULONG hb_vmFlagEnabled( ULONG flags )
{
   return s_VMFlags & flags;
}
hvm.c10493
HB_EXPORT VOIDhb_vmFlagSet( ULONG flags )
HB_EXPORT void hb_vmFlagSet( ULONG flags )
{
   s_VMFlags |= flags;
}
hvm.c10498
HB_EXPORT VOIDhb_vmFlagClear( ULONG flags )
HB_EXPORT void hb_vmFlagClear( ULONG flags )
{
   s_VMFlags &= ~flags;
}

/* ------------------------------------------------------------------------ */
hvm.c10503
VOIDhb_vmRequestDebug( void )
void hb_vmRequestDebug( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmRequestDebug()"));
   s_bDebugRequest = TRUE;
}
hvm.c10512
HB_EXPORT BOOLhb_dbg_InvokeDebug( BOOL bInvoke )
HB_EXPORT BOOL hb_dbg_InvokeDebug( BOOL bInvoke )
{
   BOOL bRequest = s_bDebugRequest;

   s_bDebugRequest = bInvoke;
   return bRequest;
}
hvm.c10518
HB_EXPORT HB_DBGENTRY_FUNChb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry )
HB_EXPORT HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry )
{
   HB_DBGENTRY_FUNC pPrevFunc = s_pFunDbgEntry;

   HB_TRACE(HB_TR_DEBUG, ("hb_dbg_SetEntry(%p)", pFunDbgEntry));

   s_pFunDbgEntry = pFunDbgEntry;
   return pPrevFunc;
}
hvm.c10526
HB_EXPORT PHB_ITEMhb_dbg_vmVarSGet( int nStatic, int nOffset )
HB_EXPORT PHB_ITEM hb_dbg_vmVarSGet( int nStatic, int nOffset )
{
   return hb_arrayGetItemPtr( &s_aStatics, nStatic + nOffset );
}
hvm.c10536
HB_EXPORT ULONGhb_dbg_ProcLevel( void )
HB_EXPORT ULONG hb_dbg_ProcLevel( void )
{
   return hb_stackCallDepth();
}
hvm.c10541
HB_FUNC__DBGINVOKEDEBUG(void)
HB_FUNC( __DBGINVOKEDEBUG )
{
   HB_STACK_TLS_PRELOAD
   BOOL bRequest = s_bDebugRequest;
   if( hb_pcount() > 0 )
      s_bDebugRequest = hb_parl( 1 );
   else
      s_bDebugRequest = FALSE;
   hb_retl( bRequest );
}
hvm.c10546
HB_FUNC__DBGVMVARSLIST(void)
HB_FUNC( __DBGVMVARSLIST )
{
   PHB_ITEM pStatics = hb_itemClone( &s_aStatics );

   hb_itemReturnRelease( pStatics );
}
hvm.c10561
HB_FUNC__DBGVMVARSLEN(void)
HB_FUNC( __DBGVMVARSLEN )
{
   HB_STACK_TLS_PRELOAD
   hb_retnl( hb_arrayLen( &s_aStatics ) );
}
hvm.c10572
HB_FUNC__DBGVMVARSGET(void)
HB_FUNC( __DBGVMVARSGET )
{
   hb_itemReturn( hb_dbg_vmVarSGet( hb_parni( 1 ), hb_parni( 2 ) ) );
}
hvm.c10582
HB_FUNC__DBGVMVARSSET(void)
HB_FUNC( __DBGVMVARSSET )
{
   PHB_ITEM pItem = hb_param( 3, HB_IT_ANY );
   if( pItem )
      hb_arraySet( &s_aStatics, hb_parni( 1 ) + hb_parni( 2 ), pItem );
}
hvm.c10591
HB_FUNC__DBGPROCLEVEL(void)
HB_FUNC( __DBGPROCLEVEL )
{
   HB_STACK_TLS_PRELOAD
   hb_retnl( hb_dbg_ProcLevel() - 1 );   /* Don't count self */
}
hvm.c10602
HB_EXPORT ULONGhb_dbg_vmVarGCount( void )
HB_EXPORT ULONG hb_dbg_vmVarGCount( void )
{
#if 0
   return hb_arrayLen( &s_aGlobals );
#else
   return 0;
#endif
}
hvm.c10608
HB_EXPORT PHB_ITEMhb_dbg_vmVarGGet( int nGlobal, int nOffset )
HB_EXPORT PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset )
{
#if 0
   return hb_arrayGetItemPtr( &s_aGlobals, nGlobal + nOffset );
#else
   HB_SYMBOL_UNUSED( nGlobal );
   HB_SYMBOL_UNUSED( nOffset );
   return NULL;
#endif
}
hvm.c10622
HB_FUNC__DBGVMVARGLIST(void)
HB_FUNC( __DBGVMVARGLIST )
{
#if 0
   PHB_ITEM pGlobals = hb_itemClone( &s_aGlobals );
#else
   PHB_ITEM pGlobals = hb_itemArrayNew( 0 );
#endif

   hb_itemReturnRelease( pGlobals );
}
hvm.c10633
HB_FUNC__DBGVMVARGGET(void)
HB_FUNC( __DBGVMVARGGET )
{
   hb_itemReturn( hb_dbg_vmVarGGet( hb_parni( 1 ), hb_parni( 2 ) ) );
}
hvm.c10648
HB_FUNC__DBGVMVARGSET(void)
HB_FUNC( __DBGVMVARGSET )
{
#if 0
   PHB_ITEM pItem = hb_param( 3, HB_IT_ANY );
   if( pItem )
      hb_arraySet( &s_aGlobals, hb_parni( 1 ) + hb_parni( 2 ), pItem );
#endif
}


/* ------------------------------------------------------------------------ */
hvm.c10653
VOIDhb_vmIsStaticRef( void )
void hb_vmIsStaticRef( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmIsStaticRef()"));

   /* statics are stored as an item of array type */
   hb_gcItemRef( &s_aStatics );
}
hvm.c10667
VOIDhb_vmIsStackRef( void )
void hb_vmIsStackRef( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmIsStackRef()"));

#if defined( HB_MT_VM )
   if( s_vmStackLst )
   {
      PHB_THREADSTATE pStack = s_vmStackLst;
      do
      {
         if( pStack->fActive && pStack->pStackId )
            hb_stackIsStackRef( pStack->pStackId, hb_vmTSVarClean );
         pStack = pStack->pNext;
      }
      while( pStack != s_vmStackLst );
   }
#else
   hb_stackIsStackRef( hb_stackId(), NULL );
#endif
}
hvm.c10678
HB_FUNC__SETPROFILER(void)
HB_FUNC( __SETPROFILER )
{
   HB_STACK_TLS_PRELOAD
#ifdef HB_NO_PROFILER
   hb_retl( FALSE );
#else
   hb_retl( hb_bProfiler );
   if( ISLOG( 1 ) )
      hb_bProfiler = hb_parl( 1 );
#endif
}
hvm.c10701
HB_FUNC__TRACEPRGCALLS(void)
HB_FUNC( __TRACEPRGCALLS )
{
   HB_STACK_TLS_PRELOAD
#if defined( HB_PRG_TRACE )
   hb_retl( hb_bTracePrgCalls );
   if( ISLOG( 1 ) )
      hb_bTracePrgCalls = hb_parl( 1 );
#else
   hb_retl( FALSE );
#endif
}
hvm.c10717
HB_FUNC__OPCOUNT(void)
HB_FUNC( __OPCOUNT ) /* it returns the total amount of opcodes */
{
   HB_STACK_TLS_PRELOAD
   hb_retnl( HB_P_LAST_PCODE - 1 );
}

HB_FUNC( __OPGETPRF ) /* profiler: It returns an array with an opcode called and
                         consumed times { nTimes, nTime },
                         given the opcode index */
{
   HB_STACK_TLS_PRELOAD
#ifndef HB_NO_PROFILER
   ULONG ulOpcode = hb_parnl( 1 );

   hb_reta( 2 );
   if( ulOpcode < HB_P_LAST_PCODE )
   {
      hb_stornl( hb_ulOpcodesCalls[ ulOpcode ], -1, 1 );
      hb_stornl( hb_ulOpcodesTime[ ulOpcode ],  -1, 2 );
   }
   else
#else
   hb_reta( 2 );
#endif
   {
      hb_stornl( 0, -1, 1 );
      hb_stornl( 0, -1, 2 );
   }
}
hvm.c10733
HB_FUNCERRORLEVEL(void)
HB_FUNC( ERRORLEVEL )
{
   HB_STACK_TLS_PRELOAD

   hb_retni( s_nErrorLevel );

   /* NOTE: This should be ISNUM( 1 ), but it's sort of a Clipper bug that it
            accepts other types also and considers them zero. [vszakats] */

   if( hb_pcount() >= 1 )
      /* Only replace the error level if a parameter was passed */
      s_nErrorLevel = hb_parni( 1 );
}
hvm.c10763
VOIDhb_vmForceLink( void )
void hb_vmForceLink( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmForceLink()"));

   HB_FUNC_EXEC( SYSINIT );
}

/* Force linking default language and codepage modules */
HB_CODEPAGE_REQUEST( HB_CODEPAGE_DEFAULT )
HB_LANG_REQUEST( HB_LANG_DEFAULT )

#undef HB_FORCE_LINK_MAIN

#if !defined(HB_DYNLIB) && defined(HB_OS_WIN_32) && \
    ( defined(__DMC__) || defined(__WATCOMC__) || defined(__MINGW32__) )

#  define HB_FORCE_LINK_MAIN  hb_forceLinkMainWin

#elif defined(HB_OS_LINUX) && defined(__WATCOMC__)

#  define HB_FORCE_LINK_MAIN  hb_forceLinkMainStd

#endif

#ifdef HB_FORCE_LINK_MAIN
HB_EXTERN_BEGIN
extern HB_EXPORT void HB_FORCE_LINK_MAIN( void );
hvm.c10782
HB_EXTERN_END VOID_hb_forceLinkMain()
HB_EXTERN_END
void _hb_forceLinkMain()
{
   HB_FORCE_LINK_MAIN();
}
hvm.c10809
initexit.c
TypeFunctionSourceLine
HB_FUNC__QUIT(void)
HB_FUNC( __QUIT )
{
   hb_vmRequestQuit();
}
initexit.c61
initsymb.c
TypeFunctionSourceLine
VOIDhb_vmSymbolInit_RT( void )
void hb_vmSymbolInit_RT( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_vmSymbolInit_RT()"));

   hb_vmProcessSymbols( symbols, sizeof( symbols ) / sizeof( HB_SYMB ) );
}
initsymb.c190
itemapi.c
TypeFunctionSourceLine
HB_EXPORT PHB_ITEMhb_itemNew( PHB_ITEM pNull )
HB_EXPORT PHB_ITEM hb_itemNew( PHB_ITEM pNull )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemNew(%p)", pNull));

   return hb_gcGripGet( pNull );
}
itemapi.c111
HB_EXPORT PHB_ITEMhb_itemParam( USHORT uiParam )
HB_EXPORT PHB_ITEM hb_itemParam( USHORT uiParam )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemParam(%hu)", uiParam));

   return hb_itemNew( hb_param( uiParam, HB_IT_ANY ) );
}
itemapi.c118
HB_EXPORT PHB_ITEMhb_itemParamPtr( USHORT uiParam, long lMask )
HB_EXPORT PHB_ITEM hb_itemParamPtr( USHORT uiParam, long lMask )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemParamPtr(%hu, %ld)", uiParam, lMask));

   return hb_param( ( int ) uiParam, lMask );
}
itemapi.c127
HB_EXPORT BOOLhb_itemParamStore( USHORT uiParam, PHB_ITEM pItem )
HB_EXPORT BOOL hb_itemParamStore( USHORT uiParam, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemParamStore(%hu, %p)", uiParam, pItem));

   if( hb_param( uiParam, HB_IT_BYREF ) )
   {
      hb_itemCopyToRef( hb_stackItemFromBase( uiParam ), pItem );
      return TRUE;
   }

   return FALSE;
}
itemapi.c134
HB_EXPORT BOOLhb_itemParamStoreForward( USHORT uiParam, PHB_ITEM pItem )
HB_EXPORT BOOL hb_itemParamStoreForward( USHORT uiParam, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemParamStoreForward(%hu, %p)", uiParam, pItem));

   if( hb_param( uiParam, HB_IT_BYREF ) )
   {
      hb_itemMoveToRef( hb_stackItemFromBase( uiParam ), pItem );
      return TRUE;
   }

   return FALSE;
}
itemapi.c147
HB_EXPORT USHORThb_itemPCount( void )
HB_EXPORT USHORT hb_itemPCount( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPCount()"));

   return ( USHORT ) hb_pcount();
}
itemapi.c160
HB_EXPORT BOOLhb_itemRelease( PHB_ITEM pItem )
HB_EXPORT BOOL hb_itemRelease( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemRelease(%p)", pItem));

   if( pItem )
   {
      hb_gcGripDrop( pItem );
      return TRUE;
   }
   else
      return FALSE;
}
itemapi.c167
HB_EXPORT PHB_ITEMhb_itemArrayNew( ULONG ulLen )
HB_EXPORT PHB_ITEM hb_itemArrayNew( ULONG ulLen )
{
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemArrayNew(%lu)", ulLen));

   pItem = hb_itemNew( NULL );

   hb_arrayNew( pItem, ulLen );

   return pItem;
}
itemapi.c180
HB_EXPORT PHB_ITEMhb_itemArrayGet( PHB_ITEM pArray, ULONG ulIndex )
HB_EXPORT PHB_ITEM hb_itemArrayGet( PHB_ITEM pArray, ULONG ulIndex )
{
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemArrayGet(%p, %lu)", pArray, ulIndex));

   pItem = hb_itemNew( NULL );

   if( pArray )
      hb_arrayGet( pArray, ulIndex, pItem );

   return pItem;
}
itemapi.c193
HB_EXPORT PHB_ITEMhb_itemArrayPut( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_itemArrayPut( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemArrayPut(%p, %lu, %p)", pArray, ulIndex, pItem));

   if( pArray )
      hb_arraySet( pArray, ulIndex, pItem );

   return pArray;
}
itemapi.c207
HB_EXPORT PHB_ITEMhb_itemPutC( PHB_ITEM pItem, const char * szText )
HB_EXPORT PHB_ITEM hb_itemPutC( PHB_ITEM pItem, const char * szText )
{
   ULONG ulLen, ulAlloc;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutC(%p, %s)", pItem, szText));

   ulLen = szText ? strlen( szText ) : 0;
   if( ulLen > 1 )
   {
      ulAlloc = ulLen + 1;
      szText = ( char * ) hb_xmemcpy( hb_xgrab( ulAlloc ), szText, ulAlloc );
   }
   else
   {
      ulAlloc = 0;
      szText = ( char * ) ( ulLen ? hb_szAscii[ ( unsigned char ) ( szText[0] ) ] : "" );
   }

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_STRING;
   pItem->item.asString.value     = ( char * ) szText;
   pItem->item.asString.length    = ulLen;
   pItem->item.asString.allocated = ulAlloc;

   return pItem;
}
itemapi.c217
HB_EXPORT PHB_ITEMhb_itemPutCL( PHB_ITEM pItem, const char * szText, ULONG ulLen )
HB_EXPORT PHB_ITEM hb_itemPutCL( PHB_ITEM pItem, const char * szText, ULONG ulLen )
{
   ULONG ulAlloc;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCL(%p, %s, %lu)", pItem, szText, ulLen));

   if( ulLen > 1 )
   {
      ulAlloc = ulLen + 1;
      szText = ( char * ) hb_xmemcpy( hb_xgrab( ulAlloc ), szText, ulLen );
      ( ( char * ) szText )[ ulLen ] = '\0';
   }
   else
   {
      ulAlloc = 0;
      szText = ( char * ) ( ulLen ? hb_szAscii[ ( unsigned char ) ( szText[0] ) ] : "" );
   }

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   /* NOTE: CA-Cl*pper seems to be buggy here, it will return ulLen bytes of
            trash if the szText buffer is NULL, at least with hb_retclen().
            [vszakats] */

   pItem->type = HB_IT_STRING;
   pItem->item.asString.value     = ( char * ) szText;
   pItem->item.asString.length    = ulLen;
   pItem->item.asString.allocated = ulAlloc;

   return pItem;
}
itemapi.c251
HB_EXPORT PHB_ITEMhb_itemPutCConst( PHB_ITEM pItem, const char * szText )
HB_EXPORT PHB_ITEM hb_itemPutCConst( PHB_ITEM pItem, const char * szText )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCConst(%p, %s)", pItem, szText));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_STRING;
   pItem->item.asString.allocated = 0;

   if( szText == NULL )
   {
      pItem->item.asString.value  = ( char * ) "";
      pItem->item.asString.length = 0;
   }
   else
   {
      pItem->item.asString.value  = ( char * ) szText;
      pItem->item.asString.length = strlen( szText );
   }

   return pItem;
}
itemapi.c289
HB_EXPORT PHB_ITEMhb_itemPutCLConst( PHB_ITEM pItem, const char * szText, ULONG ulLen )
HB_EXPORT PHB_ITEM hb_itemPutCLConst( PHB_ITEM pItem, const char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCConst(%p, %s, %lu)", pItem, szText, ulLen));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   if( szText == NULL )
   {
      pItem->item.asString.value  = ( char * ) "";
      pItem->item.asString.length = 0;
   }
   else
   {
      if( szText[ ulLen ] != '\0' )
         hb_errInternal( 6003, "Internal error: hb_itemPutCLConst() missing termination character", NULL, NULL );

      pItem->item.asString.value  = ( char * ) szText;
      pItem->item.asString.length = ulLen;
   }

   pItem->type = HB_IT_STRING;
   pItem->item.asString.allocated = 0;

   return pItem;
}
itemapi.c318
HB_EXPORT PHB_ITEMhb_itemPutCPtr2( PHB_ITEM pItem, char * szText )
HB_EXPORT PHB_ITEM hb_itemPutCPtr2( PHB_ITEM pItem, char * szText )
{
   ULONG ulLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCPtr2(%p, %s)", pItem, szText));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   ulLen = szText ? strlen( szText ) : 0;

   pItem->type = HB_IT_STRING;
   pItem->item.asString.length = ulLen;
   if( ulLen == 0 )
   {
      pItem->item.asString.allocated = 0;
      pItem->item.asString.value     = ( char * ) "";
      hb_xfree( szText );
   }
   else if( ulLen == 1 )
   {
      pItem->item.asString.allocated = 0;
      pItem->item.asString.value     = ( char * ) hb_szAscii[ (unsigned char) ( szText[0] ) ];
      hb_xfree( szText );
   }
   else
   {
      szText[ ulLen ] = '\0';
      pItem->item.asString.allocated = ulLen + 1;
      pItem->item.asString.value     = szText;
   }

   return pItem;
}
itemapi.c350
HB_EXPORT PHB_ITEMhb_itemPutCPtr( PHB_ITEM pItem, char * szText, ULONG ulLen )
HB_EXPORT PHB_ITEM hb_itemPutCPtr( PHB_ITEM pItem, char * szText, ULONG ulLen )
{
   return hb_itemPutCLPtr( pItem, szText, ulLen );
}
itemapi.c390
HB_EXPORT PHB_ITEMhb_itemPutCLPtr( PHB_ITEM pItem, char * szText, ULONG ulLen )
HB_EXPORT PHB_ITEM hb_itemPutCLPtr( PHB_ITEM pItem, char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutCLPtr(%p, %s, %lu)", pItem, szText, ulLen));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_STRING;
   pItem->item.asString.length = ulLen;
   if( ulLen == 0 )
   {
      pItem->item.asString.allocated = 0;
      pItem->item.asString.value     = ( char * ) "";
      hb_xfree( szText );
   }
   else if( ulLen == 1 )
   {
      pItem->item.asString.allocated = 0;
      pItem->item.asString.value     = ( char * ) hb_szAscii[ (unsigned char) ( szText[0] ) ];
      hb_xfree( szText );
   }
   else
   {
      szText[ ulLen ] = '\0';
      pItem->item.asString.allocated = ulLen + 1;
      pItem->item.asString.value     = szText;
   }

   return pItem;
}
itemapi.c395
HB_EXPORT VOIDhb_itemSetCMemo( PHB_ITEM pItem )
HB_EXPORT void hb_itemSetCMemo( PHB_ITEM pItem )
{
   if( pItem && HB_IS_STRING( pItem ) )
      pItem->type |= HB_IT_MEMOFLAG;
}
itemapi.c431
HB_EXPORT CHAR *hb_itemGetC( PHB_ITEM pItem )
HB_EXPORT char * hb_itemGetC( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetC(%p)", pItem));

   if( pItem && HB_IS_STRING( pItem ) )
   {
      char * szResult = ( char * ) hb_xgrab( pItem->item.asString.length + 1 );
      hb_xmemcpy( szResult, pItem->item.asString.value, pItem->item.asString.length );
      szResult[ pItem->item.asString.length ] = '\0';

      return szResult;
   }
   else
      return NULL;
}
itemapi.c439
HB_EXPORT CHAR *hb_itemGetCPtr( PHB_ITEM pItem )
HB_EXPORT char * hb_itemGetCPtr( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetCPtr(%p)", pItem));

   if( pItem && HB_IS_STRING( pItem ) )
      return pItem->item.asString.value;
   else
      return ( char * ) "";
}
itemapi.c458
HB_EXPORT ULONGhb_itemGetCLen( PHB_ITEM pItem )
HB_EXPORT ULONG hb_itemGetCLen( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetCLen(%p)", pItem));

   if( pItem && HB_IS_STRING( pItem ) )
      return pItem->item.asString.length;
   else
      return 0;
}
itemapi.c468
HB_EXPORT ULONGhb_itemCopyC( PHB_ITEM pItem, char * szBuffer, ULONG ulLen )
HB_EXPORT ULONG hb_itemCopyC( PHB_ITEM pItem, char * szBuffer, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemCopyC(%p, %s, %lu)", pItem, szBuffer, ulLen));

   if( pItem && HB_IS_STRING( pItem ) )
   {
      if( ulLen == 0 || ulLen > pItem->item.asString.length )
         ulLen = pItem->item.asString.length;

      hb_xmemcpy( szBuffer, pItem->item.asString.value, ulLen );

      return ulLen;
   }
   else
      return 0;
}
itemapi.c478
HB_EXPORT BOOLhb_itemFreeC( char * szText )
HB_EXPORT BOOL hb_itemFreeC( char * szText )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemFreeC(%s)", szText));

   if( szText )
   {
      hb_xfree( szText );

      return TRUE;
   }
   else
      return FALSE;
}
itemapi.c495
HB_EXPORT CHAR *hb_itemGetDS( PHB_ITEM pItem, char * szDate )
HB_EXPORT char * hb_itemGetDS( PHB_ITEM pItem, char * szDate )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetDS(%p, %s)", szDate));

   if( pItem && HB_IS_DATE( pItem ) )
      return hb_dateDecStr( szDate, pItem->item.asDate.value );
   else
      return hb_dateDecStr( szDate, 0 );
}
itemapi.c515
HB_EXPORT LONGhb_itemGetDL( PHB_ITEM pItem )
HB_EXPORT long hb_itemGetDL( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetDL(%p)", pItem));

   if( pItem && HB_IS_DATE( pItem ) )
      return pItem->item.asDate.value;
   else
      return 0;
}
itemapi.c525
HB_EXPORT BOOLhb_itemGetL( PHB_ITEM pItem )
HB_EXPORT BOOL hb_itemGetL( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetL(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_LOGICAL( pItem ) )
         return pItem->item.asLogical.value;

      else if( HB_IS_INTEGER( pItem ) )
         return pItem->item.asInteger.value != 0;

      else if( HB_IS_LONG( pItem ) )
         return pItem->item.asLong.value != 0;

      else if( HB_IS_DOUBLE( pItem ) )
         return pItem->item.asDouble.value != 0.0;
   }

   return FALSE;
}
itemapi.c535
HB_EXPORT DOUBLEhb_itemGetND( PHB_ITEM pItem )
HB_EXPORT double hb_itemGetND( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetND(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_DOUBLE( pItem ) )
         return pItem->item.asDouble.value;

      else if( HB_IS_INTEGER( pItem ) )
         return ( double ) pItem->item.asInteger.value;

      else if( HB_IS_LONG( pItem ) )
         return ( double ) pItem->item.asLong.value;
   }

   return 0;
}
itemapi.c557
HB_EXPORT INThb_itemGetNI( PHB_ITEM pItem )
HB_EXPORT int hb_itemGetNI( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNI(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_INTEGER( pItem ) )
         return pItem->item.asInteger.value;

      else if( HB_IS_LONG( pItem ) )
         return ( int ) pItem->item.asLong.value;

      else if( HB_IS_DOUBLE( pItem ) )
         return ( int ) pItem->item.asDouble.value;
   }

   return 0;
}
itemapi.c576
HB_EXPORT LONGhb_itemGetNL( PHB_ITEM pItem )
HB_EXPORT LONG hb_itemGetNL( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNL(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_LONG( pItem ) )
         return ( LONG ) pItem->item.asLong.value;

      else if( HB_IS_INTEGER( pItem ) )
         return ( LONG ) pItem->item.asInteger.value;

      else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
         return ( LONG ) ( ULONG ) pItem->item.asDouble.value;
#else
         return ( LONG ) pItem->item.asDouble.value;
#endif

      else if( HB_IS_DATE( pItem ) )
         return ( LONG ) pItem->item.asDate.value;
   }

   return 0;
}
itemapi.c595
HB_EXPORT HB_LONGhb_itemGetNInt( PHB_ITEM pItem )
HB_EXPORT HB_LONG hb_itemGetNInt( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNL(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_LONG( pItem ) )
         return ( HB_LONG ) pItem->item.asLong.value;

      else if( HB_IS_INTEGER( pItem ) )
         return ( HB_LONG ) pItem->item.asInteger.value;

      else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
         return ( HB_LONG ) ( HB_ULONG ) pItem->item.asDouble.value;
#else
         return ( HB_LONG ) pItem->item.asDouble.value;
#endif

      else if( HB_IS_DATE( pItem ) )
         return ( LONG ) pItem->item.asDate.value;
   }

   return 0;
}
itemapi.c621
HB_EXPORT LONGLONGhb_itemGetNLL( PHB_ITEM pItem )
HB_EXPORT LONGLONG hb_itemGetNLL( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNL(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_LONG( pItem ) )
         return ( LONGLONG ) pItem->item.asLong.value;

      else if( HB_IS_INTEGER( pItem ) )
         return ( LONGLONG ) pItem->item.asInteger.value;

      else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
         return ( LONGLONG ) ( ULONGLONG ) pItem->item.asDouble.value;
#else
         return ( LONGLONG ) pItem->item.asDouble.value;
#endif

      else if( HB_IS_DATE( pItem ) )
         return ( LONGLONG ) pItem->item.asDate.value;
   }

   return 0;
}
itemapi.c648
HB_EXPORT VOID *hb_itemGetPtr( PHB_ITEM pItem )
HB_EXPORT void * hb_itemGetPtr( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetPtr(%p)", pItem));

   if( pItem && HB_IS_POINTER( pItem ) )
      return pItem->item.asPointer.value;
   else
      return NULL;
}
itemapi.c675
HB_EXPORT VOID *hb_itemGetPtrGC( PHB_ITEM pItem, HB_GARBAGE_FUNC_PTR pFunc )
HB_EXPORT void * hb_itemGetPtrGC( PHB_ITEM pItem, HB_GARBAGE_FUNC_PTR pFunc )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetPtrGC(%p,%p)", pItem, pFunc));

   if( pItem && HB_IS_POINTER( pItem ) &&
       pItem->item.asPointer.collect &&
       hb_gcFunc( pItem->item.asPointer.value ) == pFunc )
      return pItem->item.asPointer.value;
   else
      return NULL;
}
itemapi.c685
HB_EXPORT PHB_SYMBhb_itemGetSymbol( PHB_ITEM pItem )
HB_EXPORT PHB_SYMB hb_itemGetSymbol( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetSymbol(%p)", pItem));

   if( pItem && HB_IS_SYMBOL( pItem ) )
      return pItem->item.asSymbol.value;
   else
      return NULL;
}
itemapi.c697
HB_EXPORT PHB_ITEMhb_itemReturn( PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_itemReturn( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemReturn(%p)", pItem));

   if( pItem )
      hb_itemCopy( hb_stackReturnItem(), pItem );

   return pItem;
}
itemapi.c707
HB_EXPORT PHB_ITEMhb_itemReturnForward( PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_itemReturnForward( PHB_ITEM pItem )
{
   HB_TRACE_STEALTH( HB_TR_DEBUG, ("hb_itemReturnForward(%p)", pItem ) );

   if( pItem )
      hb_itemMove( hb_stackReturnItem(), pItem );

   return pItem;
}
itemapi.c717
HB_EXPORT VOIDhb_itemReturnRelease( PHB_ITEM pItem )
HB_EXPORT void hb_itemReturnRelease( PHB_ITEM pItem )
{
   HB_TRACE_STEALTH( HB_TR_DEBUG, ("hb_itemReturnRelease(%p)", pItem ) );

   if( pItem )
   {
      hb_itemMove( hb_stackReturnItem(), pItem );
      hb_itemRelease( pItem );
   }
}
itemapi.c727
HB_EXPORT PHB_ITEMhb_itemPutDS( PHB_ITEM pItem, const char * szDate )
HB_EXPORT PHB_ITEM hb_itemPutDS( PHB_ITEM pItem, const char * szDate )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutDS(%p, %s)", pItem, szDate));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_DATE;
   pItem->item.asDate.value = hb_dateEncStr( szDate );

   return pItem;
}
itemapi.c739
HB_EXPORT PHB_ITEMhb_itemPutD( PHB_ITEM pItem, int iYear, int iMonth, int iDay )
HB_EXPORT PHB_ITEM hb_itemPutD( PHB_ITEM pItem, int iYear, int iMonth, int iDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutD(%p, %04i, %02i, %02i)", pItem, iYear, iMonth, iDay));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_DATE;
   pItem->item.asDate.value = hb_dateEncode( iYear, iMonth, iDay );

   return pItem;
}
itemapi.c757
HB_EXPORT PHB_ITEMhb_itemPutDL( PHB_ITEM pItem, long lJulian )
HB_EXPORT PHB_ITEM hb_itemPutDL( PHB_ITEM pItem, long lJulian )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutDL(%p, %ld)", pItem, lJulian));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_DATE;
   pItem->item.asDate.value = lJulian;

   return pItem;
}
itemapi.c775
HB_EXPORT PHB_ITEMhb_itemPutL( PHB_ITEM pItem, BOOL bValue )
HB_EXPORT PHB_ITEM hb_itemPutL( PHB_ITEM pItem, BOOL bValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutL(%p, %d)", pItem, (int) bValue));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_LOGICAL;
   pItem->item.asLogical.value = bValue;

   return pItem;
}
itemapi.c793
HB_EXPORT PHB_ITEMhb_itemPutND( PHB_ITEM pItem, double dNumber )
HB_EXPORT PHB_ITEM hb_itemPutND( PHB_ITEM pItem, double dNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutND(%p, %lf)", pItem, dNumber));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.length = HB_DBL_LENGTH( dNumber );
   pItem->item.asDouble.decimal = hb_stackSetStruct()->HB_SET_DECIMALS;
   pItem->item.asDouble.value = dNumber;

   return pItem;
}
itemapi.c811
HB_EXPORT PHB_ITEMhb_itemPutNI( PHB_ITEM pItem, int iNumber )
HB_EXPORT PHB_ITEM hb_itemPutNI( PHB_ITEM pItem, int iNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNI(%p, %d)", pItem, iNumber));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = iNumber;
   pItem->item.asInteger.length = HB_INT_LENGTH( iNumber );

   return pItem;
}
itemapi.c831
HB_EXPORT PHB_ITEMhb_itemPutNL( PHB_ITEM pItem, LONG lNumber )
HB_EXPORT PHB_ITEM hb_itemPutNL( PHB_ITEM pItem, LONG lNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNL(%p, %ld)", pItem, lNumber));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

#if HB_INT_MAX >= LONG_MAX
   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = (int) lNumber;
   pItem->item.asInteger.length = HB_INT_LENGTH( lNumber );
#else
   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = (HB_LONG) lNumber;
   pItem->item.asLong.length = HB_LONG_LENGTH( lNumber );
#endif

   return pItem;
}
itemapi.c850
HB_EXPORT PHB_ITEMhb_itemPutNLL( PHB_ITEM pItem, LONGLONG llNumber )
HB_EXPORT PHB_ITEM hb_itemPutNLL( PHB_ITEM pItem, LONGLONG llNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNL(%p, %" PFLL "d)", pItem, llNumber));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

#if HB_LONG_MAX >= LONGLONG_MAX
   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = (HB_LONG) llNumber;
   pItem->item.asLong.length = HB_LONG_LENGTH( llNumber );
#else
   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.value = ( double ) llNumber;
   pItem->item.asDouble.length = HB_DBL_LENGTH( pItem->item.asDouble.value );
   pItem->item.asDouble.decimal = 0;
#endif
   return pItem;
}
itemapi.c876
HB_EXPORT PHB_ITEMhb_itemPutNInt( PHB_ITEM pItem, HB_LONG lNumber )
HB_EXPORT PHB_ITEM hb_itemPutNInt( PHB_ITEM pItem, HB_LONG lNumber )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNInt(%p, %" PFHL "d)", pItem, lNumber));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   if( HB_LIM_INT( lNumber ) )
   {
      pItem->type = HB_IT_INTEGER;
      pItem->item.asInteger.value = ( int ) lNumber;
      /* EXP limit used intentionally */
      pItem->item.asInteger.length = HB_INT_EXPLENGTH( lNumber );
   }
   else
   {
      pItem->type = HB_IT_LONG;
      pItem->item.asLong.value = lNumber;
      pItem->item.asLong.length = HB_LONG_LENGTH( lNumber );
   }

   return pItem;
}
itemapi.c902
HB_EXPORT PHB_ITEMhb_itemPutNIntLen( PHB_ITEM pItem, HB_LONG lNumber, int iWidth )
HB_EXPORT PHB_ITEM hb_itemPutNIntLen( PHB_ITEM pItem, HB_LONG lNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNIntLen(%p, %" PFHL "d, %d)", pItem, lNumber, iWidth));

   if( HB_LIM_INT( lNumber ) )
   {
      return hb_itemPutNILen( pItem, ( int ) lNumber, iWidth );
   }
   else
   {
#ifdef HB_LONG_LONG_OFF
      return hb_itemPutNLLen( pItem, ( long ) lNumber, iWidth );
#else
      return hb_itemPutNLLLen( pItem, ( LONGLONG ) lNumber, iWidth );
#endif
   }
}
itemapi.c931
HB_EXPORT PHB_ITEMhb_itemPutNLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec )
HB_EXPORT PHB_ITEM hb_itemPutNLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNLen(%p, %lf, %d, %d)", pItem, dNumber, iWidth, iDec));

   if( iWidth <= 0 || iWidth > 99 )
      iWidth = HB_DBL_LENGTH( dNumber );

   if( iDec < 0 )
      iDec = hb_stackSetStruct()->HB_SET_DECIMALS;

   if( iDec > 0 )
      return hb_itemPutNDLen( pItem, dNumber, iWidth, iDec );
   else if( HB_DBL_LIM_INT( dNumber ) )
      return hb_itemPutNILen( pItem, ( int ) dNumber, iWidth );
   else if( HB_DBL_LIM_LONG( dNumber ) )
#ifdef HB_LONG_LONG_OFF
      return hb_itemPutNLLen( pItem, ( long ) dNumber, iWidth );
#else
      return hb_itemPutNLLLen( pItem, ( LONGLONG ) dNumber, iWidth );
#endif
   else
      return hb_itemPutNDLen( pItem, dNumber, iWidth, 0 );
}
itemapi.c949
HB_EXPORT PHB_ITEMhb_itemPutNDLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec )
HB_EXPORT PHB_ITEM hb_itemPutNDLen( PHB_ITEM pItem, double dNumber, int iWidth, int iDec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNDLen(%p, %lf, %d, %d)", pItem, dNumber, iWidth, iDec));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   if( iWidth <= 0 || iWidth > 99 )
   {
#if (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
      /* Borland C compiled app crashes if a "NaN" double is compared with another double [martin vogel] */
      if( _isnan( dNumber ) )
      {
         iWidth = 20;
      }
      else
#endif
      iWidth = HB_DBL_LENGTH( dNumber );
   }

   if( iDec < 0 )
      iDec = hb_stackSetStruct()->HB_SET_DECIMALS;

   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.length = iWidth;
   pItem->item.asDouble.decimal = iDec;
   pItem->item.asDouble.value = dNumber;

   return pItem;
}
itemapi.c973
HB_EXPORT PHB_ITEMhb_itemPutNDDec( PHB_ITEM pItem, double dNumber, int iDec )
HB_EXPORT PHB_ITEM hb_itemPutNDDec( PHB_ITEM pItem, double dNumber, int iDec )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemPutNDDec(%p, %lf, %i)", pItem, dNumber, iDec));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.length = HB_DBL_LENGTH( dNumber );

   if( iDec == HB_DEFAULT_DECIMALS )
   {
      pItem->item.asDouble.decimal = hb_stackSetStruct()->HB_SET_DECIMALS;
   }
   else
   {
      pItem->item.asDouble.decimal = iDec;
   }

   pItem->item.asDouble.value = dNumber;

   return pItem;
}
itemapi.c1009
HB_EXPORT DOUBLEhb_itemGetNDDec( PHB_ITEM pItem, int * piDec )
HB_EXPORT double hb_itemGetNDDec( PHB_ITEM pItem, int * piDec )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNDDec(%p,%p)", pItem, piDec));

   if( HB_IS_INTEGER( pItem ) )
   {
      *piDec = 0;
      return ( double ) pItem->item.asInteger.value;
   }
   else if( HB_IS_LONG( pItem ) )
   {
      *piDec = 0;
      return ( double ) pItem->item.asLong.value;
   }
   else if( HB_IS_DOUBLE( pItem ) )
   {
      *piDec = pItem->item.asDouble.decimal;
      return pItem->item.asDouble.value;
   }

   *piDec = 0;
   return 0.0;
}
itemapi.c1038
HB_EXPORT PHB_ITEMhb_itemPutNILen( PHB_ITEM pItem, int iNumber, int iWidth )
HB_EXPORT PHB_ITEM hb_itemPutNILen( PHB_ITEM pItem, int iNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNILen(%p, %d, %d)", pItem, iNumber, iWidth));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   if( iWidth <= 0 || iWidth > 99 )
      iWidth = HB_INT_LENGTH( iNumber );

   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.length = iWidth;
   pItem->item.asInteger.value = iNumber;

   return pItem;
}
itemapi.c1063
HB_EXPORT PHB_ITEMhb_itemPutNLLen( PHB_ITEM pItem, LONG lNumber, int iWidth )
HB_EXPORT PHB_ITEM hb_itemPutNLLen( PHB_ITEM pItem, LONG lNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNLLen(%p, %ld, %d)", pItem, lNumber, iWidth));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

#if HB_INT_MAX == LONG_MAX
   if( iWidth <= 0 || iWidth > 99 )
      iWidth = HB_INT_LENGTH( lNumber );

   pItem->type = HB_IT_INTEGER;
   pItem->item.asInteger.value = (int) lNumber;
   pItem->item.asInteger.length = iWidth;
#else
   if( iWidth <= 0 || iWidth > 99 )
      iWidth = HB_LONG_LENGTH( lNumber );

   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = (HB_LONG) lNumber;
   pItem->item.asLong.length = iWidth;
#endif

   return pItem;
}
itemapi.c1085
HB_EXPORT PHB_ITEMhb_itemPutNLLLen( PHB_ITEM pItem, LONGLONG llNumber, int iWidth )
HB_EXPORT PHB_ITEM hb_itemPutNLLLen( PHB_ITEM pItem, LONGLONG llNumber, int iWidth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNLLLen(%p, %" PFLL "d, %d)", pItem, llNumber, iWidth));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

#if HB_LONG_MAX >= LONGLONG_MAX
   if( iWidth <= 0 || iWidth > 99 )
      iWidth = HB_LONG_LENGTH( llNumber );

   pItem->type = HB_IT_LONG;
   pItem->item.asLong.value = ( HB_LONG ) llNumber;
   pItem->item.asLong.length = iWidth;
#else
   pItem->type = HB_IT_DOUBLE;
   pItem->item.asDouble.value = ( double ) llNumber;
   if( iWidth <= 0 || iWidth > 99 )
      iWidth = HB_LONG_LENGTH( pItem->item.asDouble.value );
   pItem->item.asDouble.length = iWidth;
   pItem->item.asDouble.decimal = 0;
#endif

   return pItem;
}
itemapi.c1117
HB_EXPORT PHB_ITEMhb_itemPutNumType( PHB_ITEM pItem, double dNumber, int iDec, int iType1, int iType2 )
HB_EXPORT PHB_ITEM hb_itemPutNumType( PHB_ITEM pItem, double dNumber, int iDec, int iType1, int iType2 )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutNumType( %p, %lf, %d, %i, %i)", pItem, dNumber, iDec, iType1, iType2));

   if( iDec || iType1 & HB_IT_DOUBLE || iType2 & HB_IT_DOUBLE )
   {
      return hb_itemPutNDDec( pItem, dNumber, iDec );
   }
   else if( HB_DBL_LIM_INT( dNumber ) )
   {
      return hb_itemPutNI( pItem, ( int ) dNumber );
   }
   else if( HB_DBL_LIM_LONG( dNumber ) )
   {
#ifdef HB_LONG_LONG_OFF
      return hb_itemPutNL( pItem, ( long ) dNumber );
#else
      return hb_itemPutNLL( pItem, ( LONGLONG ) dNumber );
#endif
   }
   else
   {
      return hb_itemPutND( pItem, dNumber );
   }
}
itemapi.c1149
HB_EXPORT PHB_ITEMhb_itemPutPtr( PHB_ITEM pItem, void * pValue )
HB_EXPORT PHB_ITEM hb_itemPutPtr( PHB_ITEM pItem, void * pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutPtr(%p, %p)", pItem, pValue));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_POINTER;
   pItem->item.asPointer.value = pValue;
   pItem->item.asPointer.collect =
   pItem->item.asPointer.single = FALSE;

   return pItem;
}
itemapi.c1175
HB_EXPORT PHB_ITEMhb_itemPutPtrGC( PHB_ITEM pItem, void * pValue )
HB_EXPORT PHB_ITEM hb_itemPutPtrGC( PHB_ITEM pItem, void * pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutPtrGC(%p, %p)", pItem, pValue));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_POINTER;
   pItem->item.asPointer.value = pValue;
   pItem->item.asPointer.collect = TRUE;
   pItem->item.asPointer.single = FALSE;

   return pItem;
}
itemapi.c1195
HB_EXPORT PHB_ITEMhb_itemPutSymbol( PHB_ITEM pItem, PHB_SYMB pSym )
HB_EXPORT PHB_ITEM hb_itemPutSymbol( PHB_ITEM pItem, PHB_SYMB pSym )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemPutSymbol(%p,%p)", pItem, pSym));

   if( pItem )
   {
      if( HB_IS_COMPLEX( pItem ) )
         hb_itemClear( pItem );
   }
   else
      pItem = hb_itemNew( NULL );

   pItem->type = HB_IT_SYMBOL;
   pItem->item.asSymbol.value        = pSym;
   pItem->item.asSymbol.stackstate   = NULL;
   pItem->item.asSymbol.paramcnt     =
   pItem->item.asSymbol.paramdeclcnt = 0;

   return pItem;
}
itemapi.c1215
HB_EXPORT VOIDhb_itemGetNLen( PHB_ITEM pItem, int * piWidth, int * piDecimal )
HB_EXPORT void hb_itemGetNLen( PHB_ITEM pItem, int * piWidth, int * piDecimal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemGetNLen(%p, %p, %p)", pItem, piWidth, piDecimal));

   if( pItem )
   {
      if( HB_IS_DOUBLE( pItem ) )
      {
         if( piWidth ) *piWidth = ( int ) pItem->item.asDouble.length;
         if( piDecimal ) *piDecimal = ( int ) pItem->item.asDouble.decimal;
      }
      else if( HB_IS_INTEGER( pItem ) )
      {
         if( piWidth ) *piWidth = ( int ) pItem->item.asInteger.length;
         if( piDecimal ) *piDecimal = 0;
      }
      else if( HB_IS_LONG( pItem ) )
      {
         if( piWidth ) *piWidth = ( int ) pItem->item.asLong.length;
         if( piDecimal ) *piDecimal = 0;
      }
      else
      {
         if( piWidth ) *piWidth = 0;
         if( piDecimal ) *piDecimal = 0;
      }
   }
}
itemapi.c1236
HB_EXPORT ULONGhb_itemSize( PHB_ITEM pItem )
HB_EXPORT ULONG hb_itemSize( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemSize(%p)", pItem));

   if( pItem )
   {
      if( HB_IS_STRING( pItem ) )
         return pItem->item.asString.length;
      else if( HB_IS_ARRAY( pItem ) )
         return hb_arrayLen( pItem );
      else if( HB_IS_HASH( pItem ) )
         return hb_hashLen( pItem );
   }

   return 0;
}
itemapi.c1265
HB_EXPORT HB_TYPEhb_itemType( PHB_ITEM pItem )
HB_EXPORT HB_TYPE hb_itemType( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemType(%p)", pItem));

   if( pItem )
      return ( HB_TYPE ) HB_ITEM_TYPE( pItem );
   else
      return HB_IT_NIL;
}
itemapi.c1282
HB_EXPORT CHAR *hb_itemTypeStr( PHB_ITEM pItem )
HB_EXPORT char * hb_itemTypeStr( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemTypeStr(%p)", pItem));

   switch( HB_ITEM_TYPE( pItem ) )
   {
      case HB_IT_ARRAY:
         return ( char * ) ( hb_arrayIsObject( pItem ) ? "O" : "A" );

      case HB_IT_BLOCK:
         return ( char * ) "B";

      case HB_IT_DATE:
         return ( char * ) "D";

      case HB_IT_LOGICAL:
         return ( char * ) "L";

      case HB_IT_INTEGER:
      case HB_IT_LONG:
      case HB_IT_DOUBLE:
         return ( char * ) "N";

      case HB_IT_STRING:
         return ( char * ) "C";

      case HB_IT_MEMO:
         return ( char * ) "M";

      case HB_IT_HASH:
         return ( char * ) "H";

      case HB_IT_POINTER:
         return ( char * ) "P";

      case HB_IT_SYMBOL:
         return ( char * ) "S";
   }

   return ( char * ) "U";
}
itemapi.c1292
HB_EXPORT VOIDhb_itemInit( PHB_ITEM pItem )
HB_EXPORT void hb_itemInit( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemInit(%p)", pItem));

   if( pItem )
      pItem->type = HB_IT_NIL;
}
itemapi.c1336
HB_EXPORT VOIDhb_itemClear( PHB_ITEM pItem )
HB_EXPORT void hb_itemClear( PHB_ITEM pItem )
{
   HB_TYPE type;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemClear(%p)", pItem));

   type = HB_ITEM_TYPERAW( pItem );
   pItem->type = HB_IT_NIL;

   /* GCLOCK enter */
   if( type & HB_IT_STRING )
   {
      if( pItem->item.asString.allocated )
         hb_xRefFree( pItem->item.asString.value );
   }
   else if( type & HB_IT_ARRAY )
      hb_gcRefFree( pItem->item.asArray.value );

   else if( type & HB_IT_BLOCK )
      hb_gcRefFree( pItem->item.asBlock.value );

   else if( type & HB_IT_HASH )
      hb_gcRefFree( pItem->item.asHash.value );

   else if( type & HB_IT_BYREF )
   {
      if( type & HB_IT_MEMVAR )
         hb_memvarValueDecRef( pItem->item.asMemvar.value );

      else if( type & HB_IT_ENUM )     /* FOR EACH control variable */
         hb_vmEnumRelease( pItem->item.asEnum.basePtr,
                           pItem->item.asEnum.valuePtr );

      else if( type & HB_IT_EXTREF )
         pItem->item.asExtRef.func->clear( pItem->item.asExtRef.value );

      else if( pItem->item.asRefer.offset == 0 && pItem->item.asRefer.value >= 0 )
         hb_gcRefFree( pItem->item.asRefer.BasePtr.array );
   }
   else if( type & HB_IT_POINTER )
   {
      if( pItem->item.asPointer.collect )
         hb_gcRefFree( pItem->item.asPointer.value );
   }
   /* GCLOCK leave */
}
itemapi.c1344
HB_EXPORT VOIDhb_itemCopy( PHB_ITEM pDest, PHB_ITEM pSource )
HB_EXPORT void hb_itemCopy( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemCopy(%p, %p)", pDest, pSource));

   if( pDest == pSource )
      hb_errInternal( HB_EI_ITEMBADCOPY, NULL, "hb_itemCopy()", NULL );

   if( HB_IS_COMPLEX( pDest ) )
      hb_itemClear( pDest );

   memcpy( pDest, pSource, sizeof( HB_ITEM ) );
   pDest->type &= ~HB_IT_DEFAULT;

   if( HB_IS_COMPLEX( pSource ) )
   {
      /* GCLOCK enter */
      if( HB_IS_STRING( pSource ) )
      {
         if( pSource->item.asString.allocated )
            hb_xRefInc( pSource->item.asString.value );
      }
      else if( HB_IS_ARRAY( pSource ) )
         hb_gcRefInc( pSource->item.asArray.value );

      else if( HB_IS_BLOCK( pSource ) )
         hb_gcRefInc( pSource->item.asBlock.value );

      else if( HB_IS_HASH( pSource ) )
         hb_gcRefInc( pSource->item.asHash.value );

      else if( HB_IS_BYREF( pSource ) )
      {
         if( HB_IS_MEMVAR( pSource ) )
            hb_memvarValueIncRef( pSource->item.asMemvar.value );

         else if( HB_IS_ENUM( pSource ) )    /* enumerators cannnot be copied */
            pDest->type = HB_IT_NIL;

         else if( HB_IS_EXTREF( pSource ) )
            pSource->item.asExtRef.func->copy( pDest );

         else if( pSource->item.asRefer.offset == 0 && pSource->item.asRefer.value >= 0 )
            hb_gcRefInc( pSource->item.asRefer.BasePtr.array );
      }
      else if( HB_IS_POINTER( pSource ) )
      {
         if( pSource->item.asPointer.collect )
         {
            if( pSource->item.asPointer.single )
               pDest->item.asPointer.collect = FALSE;
            else
               hb_gcRefInc( pSource->item.asPointer.value );
         }
      }
      /* GCLOCK leave */
   }
}
itemapi.c1393
VOIDhb_itemCopyToRef( PHB_ITEM pDest, PHB_ITEM pSource )
void hb_itemCopyToRef( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemCopyToRef(%p, %p)", pDest, pSource));

   if( HB_IS_BYREF( pDest ) )
   {
      pDest = hb_itemUnRefWrite( pDest, pSource );
      if( !pDest || pDest == pSource )
         /* extended reference or pDest is a reference to pSource
            - do not copy */
         return;
   }

   if( HB_IS_BYREF( pSource ) )
   {
      if( hb_itemUnRef( pSource ) == pDest )
         /*
          * assign will create cyclic reference
          * pSource and pDest reference to the same item
          * we can simply drop coping
          */
         return;
   }

   if( HB_IS_OBJECT( pDest ) &&
       hb_objOperatorCall( HB_OO_OP_ASSIGN, pDest, pDest, pSource, NULL ) )
      return;

   hb_itemCopy( pDest, pSource );
}
itemapi.c1453
VOIDhb_itemCopyFromRef( PHB_ITEM pDest, PHB_ITEM pSource )
void hb_itemCopyFromRef( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemCopyFromRef(%p, %p)", pDest, pSource));

   if( HB_IS_BYREF( pSource ) )
   {
      pSource = hb_itemUnRef( pSource );
      if( pDest == pSource )
         /* pSource is a reference to pDest - do not copy */
         return;
   }

   hb_itemCopy( pDest, pSource );
}
itemapi.c1486
HB_EXPORT VOIDhb_itemMove( PHB_ITEM pDest, PHB_ITEM pSource )
HB_EXPORT void hb_itemMove( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemMove(%p, %p)", pDest, pSource));

   if( pDest == pSource )
      hb_errInternal( HB_EI_ITEMBADCOPY, NULL, "hb_itemMove()", NULL );

   if( HB_IS_COMPLEX( pDest ) )
      hb_itemClear( pDest );

   /* GCLOCK enter */
   memcpy( pDest, pSource, sizeof( HB_ITEM ) );
   pDest->type &= ~HB_IT_DEFAULT;
   pSource->type = HB_IT_NIL;
   /* GCLOCK leave */
}
itemapi.c1501
VOIDhb_itemMoveRef( PHB_ITEM pDest, PHB_ITEM pSource )
void hb_itemMoveRef( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemMoveRef(%p, %p)", pDest, pSource));

   if( HB_IS_BYREF( pSource ) )
   {
      if( hb_itemUnRef( pSource ) == ( HB_IS_BYREF( pDest ) ?
                                             hb_itemUnRef( pDest ) : pDest ) )
      {
         /*
          * assign will create cyclic reference
          * pSource is a reference to pDest
          * we can simply drop coping
          */
         hb_itemSetNil( pSource );
         return;
      }
   }

   if( HB_IS_COMPLEX( pDest ) )
      hb_itemClear( pDest );

   /* GCLOCK enter */
   memcpy( pDest, pSource, sizeof( HB_ITEM ) );
   pDest->type &= ~HB_IT_DEFAULT;
   pSource->type = HB_IT_NIL;
   /* GCLOCK leave */
}
itemapi.c1524
VOIDhb_itemMoveToRef( PHB_ITEM pDest, PHB_ITEM pSource )
void hb_itemMoveToRef( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemMoveToRef(%p, %p)", pDest, pSource));

   if( HB_IS_BYREF( pDest ) )
   {
      pDest = hb_itemUnRefWrite( pDest, pSource );
      if( !pDest || pDest == pSource )
      {
         /* extended reference or pDest is a reference to pSource
            - do not copy */
         hb_itemSetNil( pSource );
         return;
      }
   }

   if( HB_IS_BYREF( pSource ) )
   {
      if( hb_itemUnRef( pSource ) == pDest )
      {
         /*
          * assign will create cyclic reference
          * pSource and pDest reference to the same item
          * we can simply drop coping
          */
         hb_itemSetNil( pSource );
         return;
      }
   }

   if( HB_IS_OBJECT( pDest ) &&
       hb_objOperatorCall( HB_OO_OP_ASSIGN, pDest, pDest, pSource, NULL ) )
   {
      hb_itemSetNil( pSource );
      return;
   }

   if( HB_IS_COMPLEX( pDest ) )
      hb_itemClear( pDest );

   /* GCLOCK enter */
   memcpy( pDest, pSource, sizeof( HB_ITEM ) );
   pDest->type &= ~HB_IT_DEFAULT;
   pSource->type = HB_IT_NIL;
   /* GCLOCK leave */
}
itemapi.c1555
VOIDhb_itemMoveFromRef( PHB_ITEM pDest, PHB_ITEM pSource )
void hb_itemMoveFromRef( PHB_ITEM pDest, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemCopyFromRef(%p, %p)", pDest, pSource));

   if( HB_IS_BYREF( pSource ) )
   {
      PHB_ITEM pUnRef = hb_itemUnRef( pSource );
      if( pDest != pUnRef )
         /* pSource is not a reference to pDest - make copy */
         hb_itemCopy( pDest, pUnRef );
      hb_itemClear( pSource );
   }
   else
      hb_itemMove( pDest, pSource );
}
itemapi.c1602
HB_EXPORT VOIDhb_itemSwap( PHB_ITEM pItem1, PHB_ITEM pItem2 )
HB_EXPORT void hb_itemSwap( PHB_ITEM pItem1, PHB_ITEM pItem2 )
{
   HB_ITEM temp;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemSwap(%p, %p)", pItem1, pItem2));

   /*
    * It's safe to use this version because our GC cannot be
    * activated inside memcpy()
    */
   /* GCLOCK enter */
   memcpy( &temp, pItem2, sizeof( HB_ITEM ) );
   memcpy( pItem2, pItem1, sizeof( HB_ITEM ) );
   memcpy( pItem1, &temp, sizeof( HB_ITEM ) );
   pItem1->type &= ~HB_IT_DEFAULT;
   pItem2->type &= ~HB_IT_DEFAULT;
   /* GCLOCK leave */
}

itemapi.c1620
PHB_ITEMhb_itemUnRefOnce( PHB_ITEM pItem )
PHB_ITEM hb_itemUnRefOnce( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemUnRefOnce(%p)", pItem));

   if( HB_IS_BYREF( pItem ) )
   {
      if( HB_IS_MEMVAR( pItem ) )
      {
         pItem = pItem->item.asMemvar.value;
      }
      else if( HB_IS_ENUM( pItem ) ) /* FOR EACH control variable */
      {
         /* enumerator variable */
         if( pItem->item.asEnum.valuePtr )
            return pItem->item.asEnum.valuePtr;
         else
         {
            PHB_ITEM pBase = HB_IS_BYREF( pItem->item.asEnum.basePtr ) ?
                            hb_itemUnRef( pItem->item.asEnum.basePtr ) :
                                          pItem->item.asEnum.basePtr;
            if( HB_IS_ARRAY( pBase ) )
            {
               pBase = hb_arrayGetItemPtr( pBase, pItem->item.asEnum.offset );
               if( pBase )
                  return pBase;
            }
            else if( HB_IS_HASH( pBase ) )
            {
               pBase = hb_hashGetValueAt( pBase, pItem->item.asEnum.offset );
               if( pBase )
                  return pBase;
            }
            else if( HB_IS_STRING( pBase ) )
            {
               if( pItem->item.asEnum.offset > 0 &&
                   ( ULONG ) pItem->item.asEnum.offset <= pBase->item.asString.length )
               {
                  pItem->item.asEnum.valuePtr = hb_itemPutCL( NULL,
                     pBase->item.asString.value + pItem->item.asEnum.offset - 1, 1 );
                  return pItem->item.asEnum.valuePtr;
               }
            }

            /* put it here to avoid recursive RT error generation */
            pItem->item.asEnum.valuePtr = hb_itemNew( NULL );

            if( hb_vmRequestQuery() == 0 )
            {
               hb_itemPutNInt( hb_stackAllocItem(), pItem->item.asEnum.offset );
               hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ),
                              2, pItem->item.asEnum.basePtr, hb_stackItemFromTop( -1 ) );
               hb_stackPop();
            }
            return pItem->item.asEnum.valuePtr;
         }
      }
      else if( HB_IS_EXTREF( pItem ) )
      {
         pItem = pItem->item.asExtRef.func->read( pItem );
      }
      else
      {
         if( pItem->item.asRefer.value >= 0 )
         {
            if( pItem->item.asRefer.offset == 0 )
            {
               /* a reference to a static variable or array item */
               if( ( ULONG ) pItem->item.asRefer.value <
                   pItem->item.asRefer.BasePtr.array->ulLen )
               {
                  pItem = pItem->item.asRefer.BasePtr.array->pItems +
                          pItem->item.asRefer.value;
               }
               else if( hb_vmRequestQuery() == 0 )
               {
                  hb_arrayPushBase( pItem->item.asRefer.BasePtr.array );
                  hb_itemPutNInt( hb_stackAllocItem(), pItem->item.asRefer.value + 1 );
                  hb_errRT_BASE( EG_BOUND, 1132, NULL, hb_langDGetErrorDesc( EG_ARRACCESS ),
                                 2, hb_stackItemFromTop( -2 ), hb_stackItemFromTop( -1 ) );
                  hb_stackPop();
                  hb_stackPop();

                  /* check it again - user error handler can resize the array */
                  if( ( ULONG ) pItem->item.asRefer.value <
                      pItem->item.asRefer.BasePtr.array->ulLen )
                  {
                     pItem = pItem->item.asRefer.BasePtr.array->pItems +
                             pItem->item.asRefer.value;
                  }
                  else
                     /* It's safe to clear the item - if we are here then
                        the reference chain to this item does not start in
                        one of the pItem->item.asRefer.BasePtr.array items
                        or more then one reference to this array exists
                        so it will not be freed [druzus] */
                     hb_itemClear( pItem );
               }
            }
            else
            {
               /* a reference to a local variable */
               HB_ITEM_PTR *pLocal;

               pLocal = *( pItem->item.asRefer.BasePtr.itemsbasePtr ) +
                        pItem->item.asRefer.offset + pItem->item.asRefer.value;
               pItem = *pLocal;
            }
         }
         else
         {
            /* local variable referenced in a codeblock */
            pItem = hb_codeblockGetRef( pItem->item.asRefer.BasePtr.block,
                                        pItem->item.asRefer.value );
         }
      }
   }

   return pItem;
}

itemapi.c1642
PHB_ITEMhb_itemUnRef( PHB_ITEM pItem )
PHB_ITEM hb_itemUnRef( PHB_ITEM pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemUnRef(%p)", pItem));

   do
   {
      pItem = hb_itemUnRefOnce( pItem );
   }
   while( HB_IS_BYREF( pItem ) );

   return pItem;
}
itemapi.c1765
PHB_ITEMhb_itemUnRefWrite( PHB_ITEM pItem, PHB_ITEM pSource )
PHB_ITEM hb_itemUnRefWrite( PHB_ITEM pItem, PHB_ITEM pSource )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_itemUnRefWrite(%p,%p)", pItem, pSource));

   if( HB_IS_EXTREF( pItem ) )
   {
      pItem = pItem->item.asExtRef.func->write( pItem, pSource );
   }
   else if( HB_IS_STRING( pSource ) &&
       pSource->item.asString.length == 1 )
   {
      do
      {
         if( HB_IS_ENUM( pItem ) && HB_IS_BYREF( pItem->item.asEnum.basePtr ) &&
             pItem->item.asEnum.offset >= 1 )
         {
            PHB_ITEM pBase = hb_itemUnRef( pItem->item.asEnum.basePtr );
            if( HB_IS_STRING( pBase ) &&
                ( ULONG ) pItem->item.asEnum.offset <= pBase->item.asString.length )
            {
               hb_itemUnShareString( pBase );
               pBase->item.asString.value[ pItem->item.asEnum.offset - 1 ] =
                                             pSource->item.asString.value[ 0 ];
               return pItem->item.asEnum.valuePtr;
            }
         }
         pItem = hb_itemUnRefOnce( pItem );
      }
      while( HB_IS_BYREF( pItem ) );
   }
   else
      pItem = hb_itemUnRef( pItem );

   return pItem;
}
itemapi.c1778
PHB_ITEMhb_itemUnRefRefer( PHB_ITEM pItem )
PHB_ITEM hb_itemUnRefRefer( PHB_ITEM pItem )
{
   PHB_ITEM pLast;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemUnRefRefer(%p)", pItem));

   do
   {
      pLast = pItem;
      pItem = hb_itemUnRefOnce( pItem );
   }
   while( HB_IS_BYREF( pItem ) );

   return pLast;
}

itemapi.c1817
PHB_ITEMhb_itemReSizeString( PHB_ITEM pItem, ULONG ulSize )
PHB_ITEM hb_itemReSizeString( PHB_ITEM pItem, ULONG ulSize )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemReSizeString(%p,%lu)", pItem, ulSize));

   if( pItem->item.asString.allocated == 0 )
   {
      char *szText = ( char* ) hb_xgrab( ulSize + 1 );
      hb_xmemcpy( szText, pItem->item.asString.value,
                  pItem->item.asString.length );
      szText[ ulSize ] = '\0';
      pItem->item.asString.value     = szText;
      pItem->item.asString.length    = ulSize;
      pItem->item.asString.allocated = ulSize + 1;
   }
   else
   {
      ULONG ulAlloc = ulSize + 1 +
                ( pItem->item.asString.allocated < ulSize ? ulSize : 0 );
      pItem->item.asString.value = ( char* )
                     hb_xRefResize( pItem->item.asString.value,
                                    pItem->item.asString.length,
                                    ulAlloc );
      pItem->item.asString.length = ulSize;
      pItem->item.asString.allocated = ulAlloc;
      pItem->item.asString.value[ ulSize ] = '\0';
   }
   pItem->type &= ~HB_IT_DEFAULT;

   return pItem;
}

itemapi.c1839
PHB_ITEMhb_itemUnShareString( PHB_ITEM pItem )
PHB_ITEM hb_itemUnShareString( PHB_ITEM pItem )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemUnShareString(%p)", pItem));

   if( pItem->item.asString.allocated == 0 ||
       hb_xRefCount( pItem->item.asString.value ) > 1 )
   {
      ULONG ulLen = pItem->item.asString.length + 1;
      char *szText = ( char* ) hb_xmemcpy( hb_xgrab( ulLen ),
                                           pItem->item.asString.value, ulLen );
      if( pItem->item.asString.allocated )
      {
         /* GCLOCK enter */
         hb_xRefFree( pItem->item.asString.value );
         /* GCLOCK leave */
      }
      pItem->item.asString.value = szText;
      pItem->item.asString.allocated = ulLen;
   }
   pItem->type &= ~HB_IT_DEFAULT;

   return pItem;
}
itemapi.c1873
PHB_ITEMhb_itemUnShare( PHB_ITEM pItem )
PHB_ITEM hb_itemUnShare( PHB_ITEM pItem )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemUnShare(%p)", pItem));

   if( HB_IS_BYREF( pItem ) )
      pItem = hb_itemUnRef( pItem );

   if( HB_IS_STRING( pItem ) )
      return hb_itemUnShareString( pItem );
   else
      return pItem;
}
itemapi.c1897
HB_EXPORT PHB_ITEMhb_itemClone( PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_itemClone( PHB_ITEM pItem )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemClone(%p)", pItem));

   if( HB_IS_ARRAY( pItem ) )
   {
      return hb_arrayClone( pItem );
   }
   else if( HB_IS_HASH( pItem ) )
   {
      return hb_hashClone( pItem );
   }
   else
   {
      return hb_itemNew( pItem );
   }
}
itemapi.c1910
HB_EXPORT INThb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact )
HB_EXPORT int hb_itemStrCmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact )
{
   char * szFirst;
   char * szSecond;
   ULONG ulLenFirst;
   ULONG ulLenSecond;
   ULONG ulMinLen;
   int iRet = 0; /* Current status */

   HB_TRACE(HB_TR_DEBUG, ("hb_itemStrCmp(%p, %p, %d)", pFirst, pSecond, (int) bForceExact));

   szFirst = pFirst->item.asString.value;
   szSecond = pSecond->item.asString.value;
   ulLenFirst = pFirst->item.asString.length;
   ulLenSecond = pSecond->item.asString.length;

   if( hb_stackSetStruct()->HB_SET_EXACT && !bForceExact )
   {
      /* SET EXACT ON and not using == */
      /* Don't include trailing spaces */
      while( ulLenFirst > ulLenSecond && szFirst[ ulLenFirst - 1 ] == ' ' )
         ulLenFirst--;
      while( ulLenSecond > ulLenFirst && szSecond[ ulLenSecond - 1 ] == ' ' )
         ulLenSecond--;
   }

   ulMinLen = ulLenFirst < ulLenSecond ? ulLenFirst : ulLenSecond;

   /* Both strings not empty */
   if( ulMinLen )
   {
#ifndef HB_CDP_SUPPORT_OFF
      PHB_CODEPAGE cdp = hb_vmCDP();
      if( cdp && cdp->lSort )
         iRet = hb_cdpcmp( szFirst, ulLenFirst, szSecond, ulLenSecond,
                           cdp, bForceExact || hb_stackSetStruct()->HB_SET_EXACT );
      else
#endif
      {
         do
         {
            if( *szFirst != *szSecond )
            {
               iRet = ( ( UCHAR ) *szFirst < ( UCHAR ) *szSecond ) ? -1 : 1;
               break;
            }
            szFirst++;
            szSecond++;
         }
         while( --ulMinLen );

         /* If equal and length is different ! */
         if( !iRet && ulLenFirst != ulLenSecond )
         {
            /* Force an exact comparison? */
            if( bForceExact || ulLenSecond > ulLenFirst ||
                hb_stackSetStruct()->HB_SET_EXACT )
               iRet = ( ulLenFirst < ulLenSecond ) ? -1 : 1;
         }
      }
   }
   else
   {
      /* Both empty ? */
      if( ulLenFirst != ulLenSecond )
      {
         if( bForceExact || hb_stackSetStruct()->HB_SET_EXACT )
            iRet = ( ulLenFirst < ulLenSecond ) ? -1 : 1;
         else
            iRet = ( ulLenSecond == 0 ) ? 0 : -1;
      }
      else
         /* Both empty => Equal ! */
         iRet = 0;
   }

   return iRet;
}
itemapi.c1933
HB_EXPORT INThb_itemStrICmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact )
HB_EXPORT int hb_itemStrICmp( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact )
{
   char * szFirst;
   char * szSecond;
   ULONG ulLenFirst;
   ULONG ulLenSecond;
   ULONG ulMinLen;
   int iRet = 0; /* Current status */

   HB_TRACE(HB_TR_DEBUG, ("hb_itemStrICmp(%p, %p, %d)", pFirst, pSecond, (int) bForceExact));

   szFirst = pFirst->item.asString.value;
   szSecond = pSecond->item.asString.value;
   ulLenFirst = pFirst->item.asString.length;
   ulLenSecond = pSecond->item.asString.length;

   if( !bForceExact || hb_stackSetStruct()->HB_SET_EXACT )
   {
      /* SET EXACT ON and not using == */
      /* Don't include trailing spaces */
      while( ulLenFirst > ulLenSecond && szFirst[ ulLenFirst - 1 ] == ' ' )
         ulLenFirst--;
      while( ulLenSecond > ulLenFirst && szSecond[ ulLenSecond - 1 ] == ' ' )
         ulLenSecond--;
   }

   ulMinLen = ulLenFirst < ulLenSecond ? ulLenFirst : ulLenSecond;

   /* Both strings not empty */
   if( ulMinLen )
   {
#ifndef HB_CDP_SUPPORT_OFF
      PHB_CODEPAGE cdp = hb_vmCDP();
      if( cdp && cdp->lSort )
         iRet = hb_cdpicmp( szFirst, ulLenFirst, szSecond, ulLenSecond,
                            cdp, bForceExact || hb_stackSetStruct()->HB_SET_EXACT );
      else
#endif
      {
         do
         {
            int i1 = toupper( ( UCHAR ) *szFirst );
            int i2 = toupper( ( UCHAR ) *szSecond );
            if( i1 != i2 )
            {
               iRet = ( i1 < i2 ) ? -1 : 1;
               break;
            }
            szFirst++;
            szSecond++;
         }
         while( --ulMinLen );

         /* If equal and length is different ! */
         if( !iRet && ulLenFirst != ulLenSecond )
         {
            /* Force an exact comparison? */
            if( bForceExact || ulLenSecond > ulLenFirst ||
                hb_stackSetStruct()->HB_SET_EXACT )
               iRet = ( ulLenFirst < ulLenSecond ) ? -1 : 1;
         }
      }
   }
   else
   {
      /* Both empty ? */
      if( ulLenFirst != ulLenSecond )
      {
         if( bForceExact || hb_stackSetStruct()->HB_SET_EXACT )
            iRet = ( ulLenFirst < ulLenSecond ) ? -1 : 1;
         else
            iRet = ( ulLenSecond == 0 ) ? 0 : -1;
      }
      else
         /* Both empty => Equal ! */
         iRet = 0;
   }

   return iRet;
}
itemapi.c2013
HB_EXPORT BOOLhb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int iDec )
HB_EXPORT BOOL hb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int iDec )
{
   int iPos, iDot;
   BOOL fNeg;

   if( iDec < 0 )
   {
      iDec = 0;
   }
   if( iDec > 0 )
   {
      iPos = iDot = iSize - iDec - 1;
   }
   else
   {
      iPos = iSize;
      iDot = 0;
   }

   if( HB_IS_DOUBLE( pNumber ) )
   {
      double dNumber = hb_itemGetND( pNumber );

/* TODO: look if finite()/_finite() or isinf()/_isinf and isnan()/_isnan
   does exist for your compiler and add this to the check below */

#if defined(__RSXNT__) || defined(__EMX__) || \
    defined(__XCC__) || defined(__POCC__) || \
    defined(HB_OS_HPUX)
#  define HB_FINITE_DBL(d)    ( isfinite(d)!=0 )
#elif defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER)
#  define HB_FINITE_DBL(d)    ( _finite(d)!=0 )
#elif defined(__GNUC__) || defined(__DJGPP__) || defined(__MINGW32__) || \
      defined(__LCC__)
#  define HB_FINITE_DBL(d)    ( finite(d)!=0 )
#else
      /* added infinity check for Borland C [martin vogel] */
      /* Borland C 5.5 has _finite() function, if it's necessary
         we can reenable this code for older DOS BCC versions
         Now this code is for generic C compilers undefined above
         [druzus] */
      static BOOL s_bInfinityInit = FALSE;
      static double s_dInfinity = 0;

      if( ! s_bInfinityInit )
      {
         /* set math handler to NULL for evaluating log(0),
            to avoid error messages [martin vogel]*/
         HB_MATH_HANDLERPROC fOldMathHandler = hb_mathSetHandler (NULL);
         s_dInfinity = -log( ( double ) 0 );
         hb_mathSetHandler (fOldMathHandler);
         s_bInfinityInit = TRUE;
      }
#  define HB_FINITE_DBL(d)    ( (d) != s_dInfinity && (d) != -s_dInfinity )
#endif
      if( pNumber->item.asDouble.length == 99 || !HB_FINITE_DBL( dNumber ) )
      {
         /* Numeric overflow */
         iPos = -1;
      }
      else
      {
         double dInt, dFract, dDig, doBase = 10.0;
         int iPrec, iFirst = -1;

         /* dNumber = hb_numRound( dNumber, iDec ); */

#ifdef HB_NUM_PRECISION
         iPrec = HB_NUM_PRECISION;
#else
         iPrec = 16;
#endif

         if( dNumber < 0 )
         {
            fNeg = TRUE;
            dFract = modf( -dNumber, &dInt );
         }
         else
         {
            fNeg = FALSE;
            dFract = modf( dNumber, &dInt );
         }

         while( iPos-- > 0 )
         {
            dDig = modf( dInt / doBase + 0.01, &dInt ) * doBase;
            szResult[ iPos ] = '0' + ( char ) ( dDig + 0.01 );
            if( szResult[ iPos ] != '0' )
               iFirst = iPos;
            if( dInt < 1 )
               break;
         }

         if( iPos > 0 )
         {
            memset( szResult, ' ', iPos );
         }

         if( iDec > 0 && iPos >= 0 )
         {
            for( iPos = iDot + 1; iPos < iSize; iPos++ )
            {
               dFract = modf( dFract * doBase, &dDig );
               szResult[ iPos ] = '0' + ( char ) ( dDig + 0.01 );
               if( iFirst < 0 )
               {
                  if( szResult[ iPos ] != '0' )
                  {
                     iFirst = iPos - 1;
                  }
               }
               else if( iPos - iFirst >= iPrec )
               {
                  break;
               }
            }
         }

         /* now try to round the results and set 0 in places over defined
            precision, the same is done by Clipper */
         if( iPos >= 0 )
         {
            int iZer, iLast;

            if( iFirst < 0 )
            {
               iZer = 0;
            }
            else
            {
               iZer = iSize - iFirst - iPrec - ( iDec > 0 ? 1 : 0 );
            }
            dFract = modf( dFract * doBase, &dDig );
            iLast = ( int ) ( dDig + 0.01 );

            /* hack for x.xxxx4999999999, f.e. 8.995 ~FL 8.994999999999999218.. */
            if( iLast == 4 && iZer < 0 )
            {
               for( iPos = -iZer; iPos > 0; --iPos )
               {
                  dFract = modf( dFract * doBase, &dDig );
                  if( dDig + 0.01 < 9 && ( iPos != 1 || dDig < 2 ) )
                     break;
               }
               if( iPos == 0 )
                  iLast = 5;
            }
            iLast = iLast >= 5 ? 1 : 0;

            iPos = iSize;
            while ( iPos-- > 0 )
            {
               if( iDec == 0 || iPos != iDot )
               {
                  if( iZer > 0 )
                  {
                     if( iDec == 0 || iPos <= iDot + 1 )
                     {
                        iLast = szResult[ iPos ] >= '5' ? 1 : 0;
                     }
                     szResult[ iPos ] = '0';
                     --iZer;
                  }
                  else if( iLast > 0 )
                  {
                     if( szResult[ iPos ] == '9' )
                     {
                        szResult[ iPos ] = '0';
                     }
                     else
                     {
                        if( szResult[ iPos ] < '0' ) /* '-' or ' ' */
                        {
                           szResult[ iPos ] = '1';
                           iFirst = iPos;
                        }
                        else
                        {
                           szResult[ iPos ]++;
                           if( iFirst < 0 )
                           {
                              iFirst = iPos;
                           }
                        }
                        break;
                     }
                  }
                  else
                  {
                     break;
                  }
               }
            }
            if( fNeg && iFirst >= 0 && iPos >= 0 )
            {
               iPos = ( iDot > 0 && iFirst >= iDot ) ? iDot - 2 : iFirst - 1;
               if( iPos >= 0 )
               {
                  szResult[ iPos ] = '-';
               }
            }
         }
      }
   }
   else
   {
      HB_LONG lNumber;

      if( HB_IS_INTEGER( pNumber ) )
         lNumber = pNumber->item.asInteger.value;

      else if( HB_IS_LONG( pNumber ) )
         lNumber = pNumber->item.asLong.value;

      else if( HB_IS_DATE( pNumber ) )
         lNumber = pNumber->item.asDate.value;

      else if( HB_IS_STRING( pNumber ) )
         lNumber = pNumber->item.asString.value[0];

      else
      {
         lNumber = 0;
         iPos = -1;
      }

      fNeg = ( lNumber < 0 );
      while ( iPos-- > 0 )
      {
         szResult[ iPos ] = '0' + ( char ) ( fNeg ? -( lNumber % 10 ) : ( lNumber % 10 ) );
         lNumber /= 10;
         if( lNumber == 0 )
            break;
      }
      if( fNeg && iPos-- > 0 )
         szResult[ iPos ] = '-';

      if( iPos > 0 )
         memset( szResult, ' ', iPos );

      if( iDec > 0 && iPos >= 0 )
         memset( &szResult[iSize - iDec], '0', iDec );
   }

   szResult[ iSize ] = '\0';
   /* Set to asterisks in case of overflow */
   if( iPos < 0 )
   {
      memset( szResult, '*', iSize );
      return FALSE;
   }
   else if( iDot > 0 )
   {
      szResult[ iDot ] = '.';
   }
   return TRUE;
}

/* converts a numeric to a string with optional width & precision.
   This function should be used by any function that wants to format numeric
   data for displaying, printing, or putting in a database.
itemapi.c2097
HB_EXPORT CHAR *hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec )
   Note: The caller is responsible for calling hb_xfree to free the results
         buffer, but ONLY if the return value is not a NULL pointer! (If a NULL
         pointer is returned, then there was a conversion error.)
*/
HB_EXPORT char * hb_itemStr( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec )
{
   char * szResult = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemStr(%p, %p, %p)", pNumber, pWidth, pDec));

   if( pNumber )
   {
      /* Default to the width and number of decimals specified by the item,
         with a limit of 90 integer places, plus one space for the sign. */
      int iWidth, iDec, iSize;

      hb_itemGetNLen( pNumber, &iWidth, &iDec );

      if( iWidth > 90 )
         iWidth = 90;

      if( pWidth && HB_IS_NUMERIC( pWidth ) )
      {
         /* If the width parameter is specified, override the default value
            and set the number of decimals to zero */
         iWidth = hb_itemGetNI( pWidth );

         if( iWidth < 1 )
            iWidth = 10;                  /* If 0 or negative, use default */
         iDec = 0;
      }

      /* Clipper ignores decimal places when iWidth is 1 */
      if( iWidth > 1 && pDec && HB_IS_NUMERIC( pDec ) )
      {
         /* This function does not include the decimal places in the width,
            so the width must be adjusted downwards, if the decimal places
            parameter is greater than 0  */
         iDec = hb_itemGetNI( pDec );

         if( iDec <= 0 )
            iDec = 0;
         else if( pWidth )
            iWidth -= ( iDec + 1 );
      }

      iSize = ( iDec > 0 ? iWidth + 1 + iDec : iWidth );

      if( iSize > 0 )
      {
         szResult = ( char * ) hb_xgrab( iSize + 1 );
         hb_itemStrBuf( szResult, pNumber, iSize, iDec );
      }
   }

   return szResult;
}
itemapi.c2360
HB_EXPORT CHAR *hb_itemString( PHB_ITEM pItem, ULONG * ulLen, BOOL * bFreeReq )
HB_EXPORT char * hb_itemString( PHB_ITEM pItem, ULONG * ulLen, BOOL * bFreeReq )
{
   char * buffer;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemString(%p, %p, %p)", pItem, ulLen, bFreeReq));

   switch( HB_ITEM_TYPE( pItem ) )
   {
      case HB_IT_STRING:
      case HB_IT_MEMO:
         buffer = hb_itemGetCPtr( pItem );
         * ulLen = hb_itemGetCLen( pItem );
         * bFreeReq = FALSE;
         break;

      case HB_IT_DATE:
         {
            char szDate[ 9 ];

            hb_dateDecStr( szDate, pItem->item.asDate.value );

            buffer = ( char * ) hb_xgrab( 11 );
            hb_dateFormat( szDate, buffer, hb_stackSetStruct()->HB_SET_DATEFORMAT );
            * ulLen = strlen( buffer );
            * bFreeReq = TRUE;
         }
         break;

      case HB_IT_DOUBLE:
      case HB_IT_INTEGER:
      case HB_IT_LONG:
         if( hb_stackSetStruct()->HB_SET_FIXED )
         {
            /* If fixed mode is enabled, use the default number of decimal places. */
            hb_itemPutNI( hb_stackAllocItem(), hb_stackSetStruct()->HB_SET_DECIMALS );
            buffer = hb_itemStr( pItem, NULL, hb_stackItemFromTop( -1 ) );
            hb_stackPop();
         }
         else
            buffer = hb_itemStr( pItem, NULL, NULL );
         if( buffer )
         {
            * ulLen = strlen( buffer );
            * bFreeReq = TRUE;
         }
         else
         {
            buffer = ( char * ) "";
            * ulLen = 0;
            * bFreeReq = FALSE;
         }
         break;

      case HB_IT_NIL:
         buffer = ( char * ) "NIL";
         * ulLen = 3;
         * bFreeReq = FALSE;
         break;

      case HB_IT_LOGICAL:
         buffer = ( char * ) ( hb_itemGetL( pItem ) ? ".T." : ".F." );
         * ulLen = 3;
         * bFreeReq = FALSE;
         break;

      case HB_IT_POINTER:
      {
         int size = ( sizeof( void * ) << 1 ) + 3; /* n bytes for address + 0x + \0 */
         int n;
         BOOL bFail = TRUE; 

         buffer = ( char * ) hb_xgrab( size );
         do
         {
            n = snprintf( buffer, size, "%p", hb_itemGetPtr( pItem ) );
            if( (n > -1) && (n < size) )
            {
               bFail = FALSE;
            }
            else
            {
               if( n > -1 )
                  size = n + 1;
               else
                  size *= 2;
               buffer = ( char * ) hb_xrealloc( buffer, size );
            }
         }
         while( bFail );
         * ulLen = strlen( buffer );
         * bFreeReq = TRUE;
         break;
      }
      default:
         buffer = ( char * ) "";
         * ulLen = 0;
         * bFreeReq = FALSE;
   }

   return buffer;
}
itemapi.c2424
HB_EXPORT CHAR *hb_itemPadConv( PHB_ITEM pItem, ULONG * pulSize, BOOL * bFreeReq )
HB_EXPORT char * hb_itemPadConv( PHB_ITEM pItem, ULONG * pulSize, BOOL * bFreeReq )
{
   HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemPadConv(%p, %p, %p)", pItem, pulSize, bFreeReq));

   if( pItem )
   {
      switch( HB_ITEM_TYPE( pItem ) )
      {
         case HB_IT_STRING:
         case HB_IT_MEMO:
         case HB_IT_DATE:
            return hb_itemString( pItem, pulSize, bFreeReq );

         case HB_IT_DOUBLE:
         case HB_IT_INTEGER:
         case HB_IT_LONG:
         {
            int i;
            char * buffer = hb_itemString( pItem, pulSize, bFreeReq );

            /* remove leading spaces if any, a little bit redundant but
             * I don't want to complicate the API interface more. Druzus
             */
            for( i = 0; buffer[i] == ' '; i++ ) {};

            if( i > 0 )
            {
               int j = 0;
               * pulSize -= i;
               do
               {
                  buffer[j++] = buffer[i];
               }
               while( buffer[i++] );
            }
            return buffer;
         }
         default:
            break;
      }
   }
   return NULL;
}
itemapi.c2530
HB_EXPORT PHB_ITEMhb_itemValToStr( PHB_ITEM pItem )
HB_EXPORT PHB_ITEM hb_itemValToStr( PHB_ITEM pItem )
{
   PHB_ITEM pResult;
   char * buffer;
   ULONG ulLen;
   BOOL bFreeReq;

   HB_TRACE(HB_TR_DEBUG, ("hb_itemValToStr(%p)", pItem));

   buffer = hb_itemString( pItem, &ulLen, &bFreeReq );
   if( bFreeReq )
      pResult = hb_itemPutCLPtr( NULL, buffer, ulLen );
   else
      pResult = hb_itemPutCL( NULL, buffer, ulLen );

   return pResult;
}
itemapi.c2574
macro.c
TypeFunctionSourceLine
STATIC VOIDhb_macroFlagsInit( void * pFlags )
static void hb_macroFlagsInit( void * pFlags )
{
   * ( ( ULONG * ) pFlags ) = HB_SM_DEFAULT;
}

static HB_TSD_NEW( s_macroFlags, sizeof( ULONG ), hb_macroFlagsInit, NULL );
macro.c73
STATIC ULONGhb_macroFlags( void )
static ULONG hb_macroFlags( void )
{
   return * ( ( ULONG * ) hb_stackGetTSD( &s_macroFlags ) );
}
macro.c80
STATIC VOIDhb_macroFlagsSet( ULONG flag )
static void hb_macroFlagsSet( ULONG flag )
{
   * ( ( ULONG * ) hb_stackGetTSD( &s_macroFlags ) ) = flag;
}

#else

   static ULONG s_macroFlags = HB_SM_DEFAULT;
macro.c85
STATIC INThb_macroParse( HB_MACRO_PTR pMacro )
static int hb_macroParse( HB_MACRO_PTR pMacro )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroParse(%p)", pMacro));

   /* initialize the output (pcode) buffer - it will be filled by yacc */
   pMacro->pCodeInfo = (HB_PCODE_INFO_PTR ) hb_xgrab( sizeof( HB_PCODE_INFO ) );
   pMacro->pCodeInfo->lPCodeSize = HB_PCODE_SIZE;
   pMacro->pCodeInfo->lPCodePos  = 0;
   pMacro->pCodeInfo->fVParams   = FALSE;
   pMacro->pCodeInfo->pLocals    = NULL;
   pMacro->pCodeInfo->pPrev      = NULL;
   pMacro->pCodeInfo->pCode      = ( BYTE * ) hb_xgrab( HB_PCODE_SIZE );

   /* reset the type of compiled expression - this should be filled after
    * successfully compilation
    */
   pMacro->pError = NULL;
   pMacro->uiListElements = 0;
   pMacro->exprType = HB_ET_NONE;

   return hb_macroYYParse( pMacro );
}
macro.c100
VOIDhb_macroDelete( HB_MACRO_PTR pMacro )
void hb_macroDelete( HB_MACRO_PTR pMacro )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroDelete(%p)", pMacro));

   hb_xfree( (void *) pMacro->pCodeInfo->pCode );
   hb_xfree( (void *) pMacro->pCodeInfo );
   if( pMacro->pError )
      hb_errRelease( pMacro->pError );
   if( pMacro->Flags & HB_MACRO_DEALLOCATE )
      hb_xfree( pMacro );
}
macro.c131
STATIC BOOLhb_macroCheckParam( HB_ITEM_PTR pItem )
static BOOL hb_macroCheckParam( HB_ITEM_PTR pItem )
{
   BOOL bValid = TRUE;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroCheckParam(%p)", pItem));

   if( ! HB_IS_STRING( pItem ) )
   {
      HB_ITEM_PTR pResult = hb_errRT_BASE_Subst( EG_ARG, 1065, NULL, "&", 1, pItem );

      bValid = FALSE;
      if( pResult )
      {
         hb_stackPop();
         hb_vmPush( pResult );
         hb_itemRelease( pResult );
      }
   }
   return bValid;
}
macro.c149
STATIC HB_ERROR_HANDLE(hb_macroErrorType )
static HB_ERROR_HANDLE( hb_macroErrorType )
{
   HB_MACRO_PTR pMacro = ( HB_MACRO_PTR ) ErrorInfo->Cargo;

   /* copy error object for later diagnostic usage */
   if( !pMacro->pError )
      pMacro->pError = hb_itemNew( ErrorInfo->Error );

   pMacro->status &= ~HB_MACRO_CONT;

   /* ignore rest of compiled code */
   hb_vmRequestEndProc();

   return NULL;   /* ignore this error */
}
macro.c172
VOIDhb_macroRun( HB_MACRO_PTR pMacro )
void hb_macroRun( HB_MACRO_PTR pMacro )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroRun(%p)", pMacro));

   hb_vmExecute( pMacro->pCodeInfo->pCode, NULL );
}
macro.c191
STATIC VOIDhb_macroSyntaxError( HB_MACRO_PTR pMacro )
static void hb_macroSyntaxError( HB_MACRO_PTR pMacro )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroSyntaxError(%p)", pMacro));

   if( pMacro && pMacro->pError )
   {
      HB_TRACE(HB_TR_DEBUG, ("hb_macroSyntaxError.(%s)", pMacro->string));

      hb_stackPop();    /* remove compiled string */

      hb_errLaunch( pMacro->pError );
      hb_errRelease( pMacro->pError );
      pMacro->pError = NULL;
   }
   else
   {
      PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_SYNTAX, 1449, NULL, "&", 1, hb_stackItemFromTop( -1 ) );

      if( pResult )
      {
         hb_stackPop();    /* remove compiled string */
         hb_vmPush( pResult );
         hb_itemRelease( pResult );
      }
   }
}
macro.c203
STATIC CHAR *hb_macroTextSubst( const char * szString, ULONG *pulStringLen )
static char * hb_macroTextSubst( const char * szString, ULONG *pulStringLen )
{
   char * szResult;
   ULONG ulResStrLen;
   ULONG ulResBufLen;
   ULONG ulCharsLeft;
   char * pHead;
   char * pTail;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroTextSubst(%s, %li)", szString, *pulStringLen));

   pHead = (char *) memchr( (void *) szString, '&', *pulStringLen );
   if( pHead == NULL )
      return ( char * ) szString;  /* no more processing is required */

   /* initial length of the string and the result buffer (it can contain null bytes) */
   ulResBufLen = ulResStrLen = *pulStringLen;
   /* initial buffer for return value */
   szResult = (char *) hb_xgrab( ulResBufLen + 1 );

   /* copy the input string with trailing zero byte
    */
   memcpy( szResult, szString, ulResStrLen + 1 );
   /* switch the pointer so it will point into the result buffer
    */
   pHead = szResult + ( pHead - szString );

   do
   {
      /* store the position where '&' was found so we can restart scanning
       * from this point after macro expansion
       */
      pTail = pHead;
      /* check if the next character can start a valid identifier
      * (only _a-zA-Z are allowed)
      */
      ++pHead;    /* skip '&' character */
      if( *pHead == '_' ||
          ( *pHead >= 'A' && *pHead <= 'Z' ) ||
          ( *pHead >= 'a' && *pHead <= 'z' ) )
      {
         /* extract a variable name */
         /* NOTE: the extracted name can be longer then supported maximal
          * length of identifiers (HB_SYMBOL_NAME_LEN) - only the max allowed
          * are used for name lookup however the whole string is replaced
          */
         ULONG ulNameLen = 1;
         char * pName = pHead;

         while( *++pHead && ( *pHead == '_' ||
                              ( *pHead >= 'A' && *pHead <= 'Z' ) ||
                              ( *pHead >= 'a' && *pHead <= 'z' ) ||
                              ( *pHead >= '0' && *pHead <= '9' ) ) )
         {
            ++ulNameLen;
         }
         /* pHead points now at the character that terminated a variable name */

         /* NOTE: '_' is invalid variable name
          */
         if( ulNameLen > 1 || *pName != '_' )
         {
            /* this is not the "&_" string */
            char * szValPtr;
            ULONG ulValLen;

            /* Get a pointer to the string value stored in this variable
             * or NULL if variable doesn't exist or doesn't contain a string
             * value.
             * NOTE: This doesn't create a copy of the value then it
             * shouldn't be released here.
             */
            ulValLen = ulNameLen;   /* the length of name */
            szValPtr = hb_memvarGetStrValuePtr( pName, &ulValLen );
            if( szValPtr )
            {
               if( *pHead == '.' )
               {
                  /* we have stopped at the macro terminator '.' - skip it */
                  ++pHead;
                  ++ulNameLen;
               }
               ++ulNameLen;   /* count also the '&' character */

               /* number of characters left on the right side of a variable name */
               ulCharsLeft = ulResStrLen - ( pHead - szResult );

               /* NOTE:
                * if a replacement string is shorter then the variable
                * name then we don't have to reallocate the result buffer:
                * 'ulResStrLen' stores the current length of a string in the buffer
                * 'ulResBufLen' stores the length of the buffer
                */
               if( ulValLen > ulNameLen )
               {
                  ulResStrLen += ( ulValLen - ulNameLen );
                  if( ulResStrLen > ulResBufLen )
                  {
                     ULONG ulHead = pHead - szResult;
                     ULONG ulTail = pTail - szResult;
                     ulResBufLen = ulResStrLen;
                     szResult = ( char * ) hb_xrealloc( szResult, ulResBufLen + 1 );
                     pHead = szResult + ulHead;
                     pTail = szResult + ulTail;
                  }
               }
               else
                  ulResStrLen -= ( ulNameLen - ulValLen );

               /* move bytes located on the right side of a variable name */
               memmove( pTail + ulValLen, pHead, ulCharsLeft + 1 );
               /* copy substituted value */
               memcpy( pTail, szValPtr, ulValLen );
               /* restart scanning from the beginning of replaced string */
               /* NOTE: This causes that the following code:
                *    a := '&a'
                *    var := '&a.b'
                * is the same as:
                *    var := '&ab'
                */
               pHead = pTail;
            }
         }
      }
      ulCharsLeft = ulResStrLen - ( pHead - szResult );
   }
   while( ulCharsLeft && ( pHead = (char *) memchr( (void *)pHead, '&', ulCharsLeft ) ) != NULL );

   if( ulResStrLen < ulResBufLen )
   {
      /* result string is shorter then allocated buffer -
       * cut it to a required length
       */
      szResult = ( char * ) hb_xrealloc( szResult, ulResStrLen + 1 );
   }
   szResult[ ulResStrLen ] = 0;  /* place terminating null character */
   /* return a length of result string */
   *pulStringLen = ulResStrLen;

   return szResult;   /* a new memory buffer was allocated */
}
macro.c230
VOIDhb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags )
void hb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroGetValue(%p)", pItem));

   if( hb_macroCheckParam( pItem ) )
   {
      HB_MACRO struMacro;
      int iStatus;
      BOOL fFree;

      struMacro.mode       = HB_MODE_MACRO;
      struMacro.supported  = (flags & HB_SM_RT_MACRO) ? hb_macroFlags() : flags;
      struMacro.Flags      = HB_MACRO_GEN_PUSH;
      struMacro.uiNameLen  = HB_SYMBOL_NAME_LEN;
      struMacro.status     = HB_MACRO_CONT;
      struMacro.length     = pItem->item.asString.length;
      /*
       * Clipper appears to expand nested macros staticly vs. by
       * Macro Parser, f.e.:
       *       PROCEDURE Main()
       *          LOCAL cText
       *          cText := "( v := 'A' ) + &v"
       *          M->v := "'B'"
       *          ? "Macro:", cText
       *          ? "Result:", &cText
       *          ? "Type:", type(cText)
       *       RETURN
       */
      struMacro.string = hb_macroTextSubst( pItem->item.asString.value, &struMacro.length );
      fFree = struMacro.string != pItem->item.asString.value;

      if( iContext != 0 )
      {
         /*
          * If compiled in xbase compatibility mode:
          * macro := "1,2"
          * funCall( ¯o )  ==>  funCall( 1, 2 )
          * { ¯o }  ==>  { 1, 2 }
          * var[ ¯o ]  ==>  var[ 1, 2 ]
          * var := (somevalue, ¯o)  ==> var := 2
          *
          * Always:
          * macro := "1,2"
          * EVAL( {|| ¯o} )
          *
          */
         struMacro.Flags |= HB_MACRO_GEN_LIST;
         if( iContext == HB_P_MACROPUSHPARE )
         {
            struMacro.Flags |= HB_MACRO_GEN_PARE;
         }
      }

      iStatus = hb_macroParse( &struMacro );

      if( iStatus == HB_MACRO_OK && ( struMacro.status & HB_MACRO_CONT ) )
      {
         hb_stackPop();    /* remove compiled string */
         hb_macroRun( &struMacro );

         if( iContext == HB_P_MACROPUSHLIST )
            hb_vmPushLong( struMacro.uiListElements + 1 );
      }
      else
         hb_macroSyntaxError( &struMacro );

      if( fFree )
         hb_xfree( struMacro.string );

      hb_macroDelete( &struMacro );
   }
   else if( iContext == HB_P_MACROPUSHLIST && hb_vmRequestQuery() == 0 )
   {
      hb_vmPushInteger( 1 );
   }
}
macro.c411
VOIDhb_macroSetValue( HB_ITEM_PTR pItem, BYTE flags )
void hb_macroSetValue( HB_ITEM_PTR pItem, BYTE flags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroSetValue(%p)", pItem));

   if( hb_macroCheckParam( pItem ) )
   {
      HB_MACRO struMacro;
      int iStatus;

      struMacro.mode       = HB_MODE_MACRO;
      struMacro.supported  = (flags & HB_SM_RT_MACRO) ? hb_macroFlags() : flags;
      struMacro.Flags      = HB_MACRO_GEN_POP;
      struMacro.uiNameLen  = HB_SYMBOL_NAME_LEN;
      struMacro.status     = HB_MACRO_CONT;
      struMacro.string     = pItem->item.asString.value;
      struMacro.length     = pItem->item.asString.length;

      iStatus = hb_macroParse( &struMacro );

      if( iStatus == HB_MACRO_OK && ( struMacro.status & HB_MACRO_CONT ) )
      {
         hb_stackPop();    /* remove compiled string */
         hb_macroRun( &struMacro );
      }
      else
         hb_macroSyntaxError( &struMacro );

      hb_macroDelete( &struMacro );
   }
   else if( hb_vmRequestQuery() == 0 )
   {
      hb_stackPop();
      hb_stackPop();
   }
}
macro.c488
STATIC VOIDhb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, BYTE bSupported )
static void hb_macroUseAliased( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, int iFlag, BYTE bSupported )
{
   if( HB_IS_STRING( pAlias ) && HB_IS_STRING( pVar ) )
   {
      /* grab memory for "alias->var"
      */
      ULONG ulLen = pAlias->item.asString.length + pVar->item.asString.length + 2;
      char * szString = ( char * ) hb_xgrab( ulLen + 1 );
      HB_MACRO struMacro;
      int iStatus;

      memcpy( szString, pAlias->item.asString.value, pAlias->item.asString.length );
      szString[ pAlias->item.asString.length ]     = '-';
      szString[ pAlias->item.asString.length + 1 ] = '>';
      memcpy( szString + pAlias->item.asString.length + 2, pVar->item.asString.value, pVar->item.asString.length );
      szString[ ulLen ] = '\0';

      struMacro.mode       = HB_MODE_MACRO;
      struMacro.supported  = (bSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : bSupported;
      struMacro.Flags      = iFlag;
      struMacro.uiNameLen  = HB_SYMBOL_NAME_LEN;
      struMacro.status     = HB_MACRO_CONT;
      struMacro.string     = szString;
      struMacro.length     = ulLen;

      iStatus = hb_macroParse( &struMacro );

      hb_stackPop();    /* remove compiled variable name */
      hb_stackPop();    /* remove compiled alias */

      if( iStatus == HB_MACRO_OK && ( struMacro.status & HB_MACRO_CONT ) )
      {
         hb_macroRun( &struMacro );
      }
      else
      {
         hb_vmPushString( szString, ulLen );
         hb_macroSyntaxError( &struMacro );
      }

      hb_xfree( szString );
      hb_macroDelete( &struMacro );
   }
   else if( hb_macroCheckParam( pVar ) )
   {
      /* only right side of alias operator is a string - macro-compile
       * this part only
       */
      HB_MACRO struMacro;
      int iStatus;

      struMacro.mode       = HB_MODE_MACRO;
      struMacro.supported  = (bSupported & HB_SM_RT_MACRO) ? hb_macroFlags() : bSupported;
      struMacro.Flags      = iFlag | HB_MACRO_GEN_ALIASED;
      struMacro.uiNameLen  = HB_SYMBOL_NAME_LEN;
      struMacro.status     = HB_MACRO_CONT;
      struMacro.string     = pVar->item.asString.value;
      struMacro.length     = pVar->item.asString.length;

      iStatus = hb_macroParse( &struMacro );

      if( iStatus == HB_MACRO_OK && ( struMacro.status & HB_MACRO_CONT ) )
      {
         hb_stackPop();    /* remove compiled string */
         hb_macroRun( &struMacro );
      }
      else
         hb_macroSyntaxError( &struMacro );

      hb_macroDelete( &struMacro );
   }
}
macro.c529
VOIDhb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags )
void hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroPopAliasedValue(%p, %p)", pAlias, pVar));

   hb_macroUseAliased( pAlias, pVar, HB_MACRO_GEN_POP, flags );
}
macro.c616
VOIDhb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags )
void hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroPushAliasedValue(%p, %p)", pAlias, pVar));

   hb_macroUseAliased( pAlias, pVar, HB_MACRO_GEN_PUSH, flags );
}
macro.c628
CHAR *hb_macroExpandString( const char *szString, ULONG ulLength, BOOL *pfNewString )
char * hb_macroExpandString( const char *szString, ULONG ulLength, BOOL *pfNewString )
{
   char *szResultString;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroExpandString(%s,%lu,%p)", szString, ulLength, pfNewString));

   if( szString )
      szResultString = hb_macroTextSubst( szString, &ulLength );
   else
      szResultString = ( char * ) szString;
   *pfNewString = ( szString != szResultString );
   return szResultString;
}
macro.c640
CHAR *hb_macroTextSymbol( const char *szString, ULONG ulLength, BOOL *pfNewString )
char * hb_macroTextSymbol( const char *szString, ULONG ulLength, BOOL *pfNewString )
{
   char *szResult = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroTextSymbol(%s,%lu,%p)", szString, ulLength, pfNewString));

   if( szString )
   {
      ULONG ulLen = 0;

      szResult = hb_macroTextSubst( szString, &ulLength );

      while( ulLength && ( szResult[ 0 ] == ' ' || szResult[ 0 ] == '\t' ) )
      {
         ++szResult;
         ++szString;
         --ulLength;
      }

      while( ulLength && ( szResult[ ulLength - 1 ] == ' ' ||
                           szResult[ ulLength - 1 ] == '\t' ) )
         --ulLength;

      /* NOTE: This uses _a-zA-Z0-9 pattern to check for a valid name
       * "_" is not valid macro string
       */
      while( ulLen < ulLength )
      {
         char c = szResult[ ulLen ];
         if( c >= 'a' && c <= 'z' )
         {
            if( szResult == szString )
            {
               szResult = ( char * ) hb_xgrab( ulLength + 1 );
               memcpy( szResult, szString, ulLength );
               szResult[ ulLength ] = '\0';
            }
            szResult[ ulLen ] = c - ( 'a' - 'A' );
         }
         else if( ! ( c == '_' || ( c >= 'A' && c <= 'Z' ) ||
                      ( ulLen && ( c >= '0' && c <= '9' ) ) ) )
         {
            break;
         }
         ++ulLen;
      }
      if( ulLen == ulLength && ulLen > ( ULONG ) ( szResult[ 0 ] == '_' ? 1 : 0 ) )
      {
         if( ulLen > HB_SYMBOL_NAME_LEN )
            ulLen = HB_SYMBOL_NAME_LEN;
         if( szResult[ ulLen ] )
         {
            if( szResult == szString )
            {
               szResult = ( char * ) hb_xgrab( ulLen + 1 );
               memcpy( szResult, szString, ulLen );
            }
            szResult[ ulLen ] = '\0';
         }
      }
      else
      {
         if( szResult != szString )
            hb_xfree( szResult );
         szResult = NULL;
      }
   }
   *pfNewString = szResult && szString != szResult;
   return szResult;
}
macro.c659
HB_MACRO_PTRhb_macroCompile( char * szString )
HB_MACRO_PTR hb_macroCompile( char * szString )
{
   HB_MACRO_PTR pMacro;
   int iStatus;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroCompile(%s)", szString));

   pMacro = ( HB_MACRO_PTR ) hb_xgrab( sizeof( HB_MACRO ) );
   pMacro->mode      = HB_MODE_MACRO;
   pMacro->supported = hb_macroFlags();
   pMacro->Flags     = HB_MACRO_DEALLOCATE | HB_MACRO_GEN_PUSH |
                       HB_MACRO_GEN_LIST | HB_MACRO_GEN_PARE;
   pMacro->uiNameLen = HB_SYMBOL_NAME_LEN;
   pMacro->status    = HB_MACRO_CONT;
   pMacro->string    = szString;
   pMacro->length    = strlen( szString );

   iStatus = hb_macroParse( pMacro );
   if( ! ( iStatus == HB_MACRO_OK && ( pMacro->status & HB_MACRO_CONT ) ) )
   {
      hb_macroDelete( pMacro );
      pMacro = NULL;
   }

   return pMacro;
}
macro.c730
VOIDhb_macroPushSymbol( HB_ITEM_PTR pItem )
void hb_macroPushSymbol( HB_ITEM_PTR pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroPushSymbol(%p)", pItem));

   if( hb_macroCheckParam( pItem ) )
   {
      char * szString;
      BOOL fNewBuffer;

      szString = hb_macroTextSymbol( pItem->item.asString.value,
                                     pItem->item.asString.length,
                                     &fNewBuffer );
      if( szString )
      {
         HB_DYNS_PTR pDynSym = hb_dynsymGetCase( szString );

         if( fNewBuffer )
            hb_xfree( szString );   /* free space allocated in hb_macroTextSymbol */

         hb_stackPop();    /* remove compiled string */
         /* NOTE: checking for valid function name (valid pointer) is done
          * in hb_vmDo()
          */
         hb_vmPushSymbol( pDynSym->pSymbol );  /* push compiled symbol instead of a string */
         return;
      }
      else
         hb_macroSyntaxError( NULL );
   }

   if( !HB_IS_SYMBOL( hb_stackItemFromTop( -1 ) ) && hb_vmRequestQuery() == 0 )
   {
      hb_stackPop();    /* remove compiled string */
      hb_vmPushDynSym( hb_dynsymGetCase( "" ) );  /* push compiled symbol instead of a string */
   }
}
macro.c761
VOIDhb_macroTextValue( HB_ITEM_PTR pItem )
void hb_macroTextValue( HB_ITEM_PTR pItem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroTextValue(%p)", pItem));

   if( hb_macroCheckParam( pItem ) )
   {
      char * szString;
      ULONG ulLength = pItem->item.asString.length;

      szString = hb_macroTextSubst( pItem->item.asString.value, &ulLength );

      if( szString != pItem->item.asString.value )
      {
         /* replace the old value on the eval stack with the new one
         */
         hb_itemPutCLPtr( pItem, szString, ulLength );
      }
      /*
       * else
       *    leave original value on the eval stack - there was no '&' operator
       *    inside a string
       */
   }
}
macro.c805
CHAR *hb_macroGetType( HB_ITEM_PTR pItem )
char * hb_macroGetType( HB_ITEM_PTR pItem )
{
   const char * szType;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroGetType(%p)", pItem));

   if( hb_macroCheckParam( pItem ) )
   {
      HB_MACRO struMacro;
      int iStatus;

      struMacro.mode       = HB_MODE_MACRO;
      struMacro.supported  = hb_macroFlags();
      struMacro.Flags      = HB_MACRO_GEN_PUSH | HB_MACRO_GEN_TYPE;
      struMacro.uiNameLen  = HB_SYMBOL_NAME_LEN;
      struMacro.status     = HB_MACRO_CONT;
      struMacro.string     = pItem->item.asString.value;
      struMacro.length     = pItem->item.asString.length;
      iStatus = hb_macroParse( &struMacro );

      if( iStatus == HB_MACRO_OK )
      {
         /* passed string was successfully compiled
          */
         if( struMacro.exprType == HB_ET_CODEBLOCK )
         {
            /* Clipper ignores any undeclared symbols or UDFs if the
             * compiled expression is a valid codeblock
            */
            szType = "B";
         }
         else if( struMacro.status & HB_MACRO_UNKN_SYM )
         {
            /* request for a symbol that is not in a symbol table or
             * for a variable that is not visible
             */
            szType = "U";
         }
         else if( struMacro.status & HB_MACRO_UDF )
         {
            szType = "UI";  /* UDF function was used - cannot determine a type */
         }
         else if( struMacro.status & HB_MACRO_CONT )
         {
            /* OK - the pcode was generated and it can be evaluated
            */
            HB_ERROR_INFO struErr;
            HB_ERROR_INFO_PTR pOld;

            /* Set our temporary error handler. We do not need any error
             * messages here - we need to know only if evaluation was
             * successfull. If evaluation was successfull then the data type
             * of expression can be determined.
             */
            struErr.Func  = hb_macroErrorType;
            struErr.Cargo = ( void * ) &struMacro;
            pOld = hb_errorHandler( &struErr );
            hb_macroRun( &struMacro );
            hb_errorHandler( pOld );

            if( struMacro.status & HB_MACRO_CONT )
            {
               /* Evaluation was successfull
                * Now the value of expression is placed on the eval stack -
                * check its type and pop it from the stack
                */
               szType = hb_itemTypeStr( hb_stackItemFromTop( -1 ) );
               hb_stackPop();
            }
            else
            {
               /* something unpleasant happened during macro evaluation */
               if( struMacro.pError )
               {
                  ULONG ulGenCode;
                  
                  ulGenCode = hb_errGetGenCode( struMacro.pError );
                  if( ulGenCode == EG_NOVAR || ulGenCode == EG_NOALIAS )
                  {
                     /* Undeclared variable returns 'U' in Clipper */
                     szType = "U";
                  }
                  else
                     szType = "UE";
               }
               else
                  szType = "UE";
            }
         }
         else
         {
            szType = "UE";
         }
      }
      else
         szType = "UE";  /* syntax error during compilation */

      hb_macroDelete( &struMacro );
   }
   else
      szType = "U";

   return ( char * ) szType;
}
macro.c835
ULONGhb_macroSetMacro( BOOL bSet, ULONG flag )
ULONG hb_macroSetMacro( BOOL bSet, ULONG flag )
{
   ULONG ulCurrentFlags = hb_macroFlags();

   if( flag > 0 )
   {
      if( bSet )
         hb_macroFlagsSet( ulCurrentFlags | flag );
      else
         hb_macroFlagsSet( ulCurrentFlags & ~flag );
   }

   return ulCurrentFlags;
}
macro.c940
HB_FUNCHB_SETMACRO(void)
HB_FUNC( HB_SETMACRO )
{
   int iPrmCnt = hb_pcount();

   if( iPrmCnt > 0 )
   {
       ULONG ulFlags = ( ULONG ) hb_parnl( 1 );
       PHB_ITEM pValue;

       switch( ulFlags )
       {
          case HB_SM_HARBOUR:
             /* enable/disable extended Harbour compatibility */
          case HB_SM_XBASE:
             /* enable/disable extended xbase compatibility */
          case HB_SM_ARRSTR:
             /* enable/disable processing of strings as an array of bytes */
          case HB_SM_SHORTCUTS:
             /* enable/disable support for shortcut logical operators */
             hb_retl( hb_macroFlags() & ulFlags );
             pValue = hb_param( 2, HB_IT_LOGICAL );
             if( pValue )
                hb_macroSetMacro( hb_itemGetL( pValue ), ulFlags );
             break;

          default:
              ;/* do nothing */
      }
   }
   else
      hb_ret();    /* return NIL */
}
macro.c959
STATIC INThb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL )
static int hb_macroLocalVarGetPos( const char * szVarName, HB_COMP_DECL )
{
   int iVar = 1;
   HB_CBVAR_PTR pVars = HB_PCODE_DATA->pLocals;

   while( pVars )
   {
      if( pVars->szName && ! strcmp( pVars->szName, szVarName ) )
         return iVar;
      else
      {
         if( pVars->pNext )
         {
            pVars = pVars->pNext;
            iVar++;
         }
         else
            return 0;
      }
   }
   return 0;
}
macro.c994
BOOLhb_macroIsValidMacroText( const char * szText, ULONG ulLen )
BOOL hb_macroIsValidMacroText( const char * szText, ULONG ulLen )
{
   if( ulLen )
   {
      while( --ulLen )
      {
         if( *szText++ == '&' )
         {
            char ch = *szText;
            if( ( ch >= 'A' && ch <= 'Z' ) ||
                ( ch >= 'a' && ch <= 'z' ) || ch == '_' )
               return TRUE;
         }
      }
   }

   return FALSE;
}
macro.c1018
ULONGhb_macroGenJump( LONG lOffset, HB_COMP_DECL )
ULONG hb_macroGenJump( LONG lOffset, HB_COMP_DECL )
{
   if( lOffset == 0 )
      hb_macroGenPCode4( HB_P_JUMPFAR, 0, 0, 0, HB_COMP_PARAM );
   else if( HB_LIM_INT8( lOffset ) )
      hb_macroGenPCode2( HB_P_JUMPNEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM );
   else if( HB_LIM_INT16( lOffset ) )
      hb_macroGenPCode3( HB_P_JUMP, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM );
   else if( HB_LIM_INT24( lOffset ) )
      hb_macroGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM );
   else
      hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );

   return HB_PCODE_DATA->lPCodePos - 3;
}
macro.c1037
ULONGhb_macroGenJumpFalse( LONG lOffset, HB_COMP_DECL )
ULONG hb_macroGenJumpFalse( LONG lOffset, HB_COMP_DECL )
{
   if( lOffset == 0 )
      hb_macroGenPCode4( HB_P_JUMPFALSEFAR, 0, 0, 0, HB_COMP_PARAM );
   else if( HB_LIM_INT8( lOffset ) )
      hb_macroGenPCode2( HB_P_JUMPFALSENEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM );
   else if( HB_LIM_INT16( lOffset ) )
      hb_macroGenPCode3( HB_P_JUMPFALSE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM );
   else if( HB_LIM_INT24( lOffset ) )
      hb_macroGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM );
   else
      hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );

   return HB_PCODE_DATA->lPCodePos - 3;
}
macro.c1053
ULONGhb_macroGenJumpTrue( LONG lOffset, HB_COMP_DECL )
ULONG hb_macroGenJumpTrue( LONG lOffset, HB_COMP_DECL )
{
   if( lOffset == 0 )
      hb_macroGenPCode4( HB_P_JUMPTRUEFAR, 0, 0, 0, HB_COMP_PARAM );
   else if( HB_LIM_INT8( lOffset ) )
      hb_macroGenPCode2( HB_P_JUMPTRUENEAR, HB_LOBYTE( lOffset ), HB_COMP_PARAM );
   else if( HB_LIM_INT16( lOffset ) )
      hb_macroGenPCode3( HB_P_JUMPTRUE, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_COMP_PARAM );
   else if( HB_LIM_INT24( lOffset ) )
      hb_macroGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), HB_ULBYTE( lOffset ), HB_COMP_PARAM );
   else
      hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );

   return HB_PCODE_DATA->lPCodePos - 3;
}
macro.c1069
VOIDhb_macroGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL )
void hb_macroGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL )
{
   BYTE * pCode = HB_PCODE_DATA->pCode;
   LONG lOffset = ulTo - ulFrom + 1;

   if( HB_LIM_INT24( lOffset ) )
      HB_PUT_LE_UINT24( &pCode[ ulFrom ], lOffset );
   else
      hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );
}
macro.c1085
VOIDhb_macroGenJumpHere( ULONG ulOffset, HB_COMP_DECL )
void hb_macroGenJumpHere( ULONG ulOffset, HB_COMP_DECL )
{
   hb_macroGenJumpThere( ulOffset, HB_PCODE_DATA->lPCodePos, HB_COMP_PARAM );
}
macro.c1096
STATIC VOIDhb_macroMemvarGenPCode( BYTE bPCode, const char * szVarName, HB_COMP_DECL )
static void hb_macroMemvarGenPCode( BYTE bPCode, const char * szVarName, HB_COMP_DECL )
{
   BYTE byBuf[ sizeof( HB_DYNS_PTR ) + 1 ];
   HB_DYNS_PTR pSym;

   if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_TYPE )
   {
      /* we are determining the type of expression (called from TYPE() function)
       * then we shouldn't create the requested variable if it doesn't exist
       */
      pSym = hb_dynsymFind( szVarName );
      if( !pSym )
      {
         HB_MACRO_DATA->status |= HB_MACRO_UNKN_VAR;
         pSym = hb_dynsymGetCase( szVarName );
      }
   }
   else
      /* Find the address of passed symbol - create the symbol if doesn't exist
       * (Clipper compatibility). */
      pSym = hb_dynsymGetCase( szVarName );

   byBuf[ 0 ] = bPCode;
   HB_PUT_PTR( &byBuf[ 1 ], pSym );
   hb_macroGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM );
}
macro.c1101
VOIDhb_macroGenPushSymbol( const char * szSymbolName, BOOL bFunction, HB_COMP_DECL )
void hb_macroGenPushSymbol( const char * szSymbolName, BOOL bFunction, HB_COMP_DECL )
{
   BYTE byBuf[ sizeof( HB_DYNS_PTR ) + 1 ];
   HB_DYNS_PTR pSym;

   if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_TYPE )
   {
      /* we are determining the type of expression (called from TYPE() function)
       */
      pSym = hb_dynsymFind( szSymbolName );
      if( ! pSym )
      {
         HB_MACRO_DATA->status |= HB_MACRO_UNKN_SYM;
         HB_MACRO_DATA->status &= ~HB_MACRO_CONT;  /* don't run this pcode */
         /*
          * NOTE: the compiled pcode will be not executed then we can ignore
          * NULL value for pSym
          */
      }
      else if( bFunction )
      {
         if( pSym->pSymbol->value.pFunPtr == NULL )
         {
            /* static functions are not allowed in macro */
            HB_MACRO_DATA->status |= HB_MACRO_UNKN_SYM;
            HB_MACRO_DATA->status &= ~HB_MACRO_CONT;  /* don't run this pcode */
         }
      }
   }
   else
      pSym = hb_dynsymGetCase( szSymbolName );

   byBuf[ 0 ] = HB_P_MPUSHSYM;
   HB_PUT_PTR( &byBuf[ 1 ], pSym );
   hb_macroGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM );
}
macro.c1131
VOIDhb_macroGenPushLong( HB_LONG lNumber, HB_COMP_DECL )
void hb_macroGenPushLong( HB_LONG lNumber, HB_COMP_DECL )
{
   if( lNumber == 0 )
   {
      hb_macroGenPCode1( HB_P_ZERO, HB_COMP_PARAM );
   }
   else if( lNumber == 1 )
   {
      hb_macroGenPCode1( HB_P_ONE, HB_COMP_PARAM );
   }
   else if( HB_LIM_INT8( lNumber ) )
   {
      hb_macroGenPCode2( HB_P_PUSHBYTE, (BYTE) lNumber, HB_COMP_PARAM );
   }
   else if( HB_LIM_INT16( lNumber ) )
   {
      hb_macroGenPCode3( HB_P_PUSHINT, HB_LOBYTE( lNumber ), HB_HIBYTE( lNumber ), HB_COMP_PARAM );
   }
   else if( HB_LIM_INT32( lNumber ) )
   {
      BYTE pBuffer[ 5 ];
      pBuffer[ 0 ] = HB_P_PUSHLONG;
      HB_PUT_LE_UINT32( pBuffer + 1, lNumber );
      hb_macroGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM );
   }
   else
   {
      BYTE pBuffer[ 9 ];
      pBuffer[ 0 ] = HB_P_PUSHLONGLONG;
      HB_PUT_LE_UINT64( pBuffer + 1, lNumber );
      hb_macroGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM );
   }
}
macro.c1169
VOIDhb_macroGenPushDate( HB_LONG lNumber, HB_COMP_DECL )
void hb_macroGenPushDate( HB_LONG lNumber, HB_COMP_DECL )
{
   BYTE pBuffer[ 5 ];
   
   pBuffer[ 0 ] = HB_P_PUSHDATE;
   HB_PUT_LE_UINT32( pBuffer + 1, lNumber );
   hb_macroGenPCodeN( pBuffer, sizeof( pBuffer ), HB_COMP_PARAM );
}
macro.c1204
VOIDhb_macroGenMessage( const char * szMsgName, BOOL bIsObject, HB_COMP_DECL )
void hb_macroGenMessage( const char * szMsgName, BOOL bIsObject, HB_COMP_DECL )
{
   BYTE byBuf[ sizeof( HB_DYNS_PTR ) + 1 ];

   /* Find the address of passed symbol - create the symbol if doesn't exist
    */
   HB_DYNS_PTR pSym = hb_dynsymGetCase( szMsgName );

   byBuf[ 0 ] = HB_P_MMESSAGE;
   HB_PUT_PTR( &byBuf[ 1 ], pSym );
   hb_macroGenPCodeN( byBuf, sizeof( byBuf ), HB_COMP_PARAM );

   HB_SYMBOL_UNUSED( bIsObject );   /* used in full compiler only */
}
macro.c1214
VOIDhb_macroGenMessageData( const char * szMsg, BOOL bIsObject, HB_COMP_DECL )
void hb_macroGenMessageData( const char * szMsg, BOOL bIsObject, HB_COMP_DECL )
{
   char * szResult;
   int iLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroGenMessageData(%s)", szMsg));

   iLen = ( int ) strlen( szMsg );
   if( iLen > HB_SYMBOL_NAME_LEN - 1 )
      iLen = HB_SYMBOL_NAME_LEN - 1;
   szResult = ( char * ) hb_xgrab( iLen + 2 );
   szResult[ 0 ] = '_';
   memcpy( szResult + 1, szMsg, iLen );
   szResult[ iLen + 1 ] = '\0';
   hb_macroGenMessage( szResult, bIsObject, HB_COMP_PARAM );
   hb_xfree( szResult );
}
macro.c1230
VOIDhb_macroGenPopVar( const char * szVarName, HB_COMP_DECL )
void hb_macroGenPopVar( const char * szVarName, HB_COMP_DECL )
{
   int iVar;

   iVar = hb_macroLocalVarGetPos( szVarName, HB_COMP_PARAM );
   if( iVar )
   {
      /* this is a codeblock parameter */
      hb_macroGenPCode3( HB_P_POPLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
   }
   else
   {
      /* TODO: memvars created inside TYPE() function should have PUBLIC scope */
      hb_macroMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM );
   }
}
macro.c1249
VOIDhb_macroGenPopMemvar( const char * szVarName, HB_COMP_DECL )
void hb_macroGenPopMemvar( const char * szVarName, HB_COMP_DECL )
{
   hb_macroMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM );
}
macro.c1267
VOIDhb_macroGenPopAliasedVar( const char * szVarName, BOOL bPushAliasValue, const char * szAlias, HB_LONG lWorkarea, HB_COMP_DECL )
void hb_macroGenPopAliasedVar( const char * szVarName,
                               BOOL bPushAliasValue,
                               const char * szAlias,
                               HB_LONG lWorkarea, HB_COMP_DECL )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroGenPopAliasedVar(%s->%s)",szAlias,szVarName));

   if( bPushAliasValue )
   {
      if( szAlias )
      {
         int iLen = strlen( szAlias );

         if( szAlias[ 0 ] == 'M' && ( iLen == 1 ||
             ( iLen >= 4 && iLen <= 6 && strncmp( szAlias, "MEMVAR", iLen ) == 0 ) ) )
         {  /* M-> or MEMV-> or MEMVA-> or MEMVAR-> variable */
            /* TODO: memvars created inside TYPE() function should have PUBLIC scope */
            hb_macroMemvarGenPCode( HB_P_MPOPMEMVAR, szVarName, HB_COMP_PARAM );
         }
         else if( iLen >= 4 && iLen <= 6 && 
                  ( strncmp( szAlias, "FIELD", iLen ) == 0 ||
                    strncmp( szAlias, "_FIELD", iLen ) == 0 ) )
         {  /* FIELD-> */
            hb_macroMemvarGenPCode( HB_P_MPOPFIELD, szVarName, HB_COMP_PARAM );
         }
         else
         {  /* database alias */
            hb_macroGenPushSymbol( szAlias, FALSE, HB_COMP_PARAM );
            hb_macroMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_COMP_PARAM );
         }
      }
      else
      {
         hb_macroGenPushLong( lWorkarea, HB_COMP_PARAM );
         hb_macroMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_COMP_PARAM );
      }
   }
   else
   {
      /* Alias is already placed on stack
       * NOTE: An alias will be determined at runtime then we cannot decide
       * here if passed name is either a field or a memvar
       */
      /* TODO: memvars created inside TYPE() function should have PUBLIC scope */
      hb_macroMemvarGenPCode( HB_P_MPOPALIASEDVAR, szVarName, HB_COMP_PARAM );
   }
}
macro.c1273
VOIDhb_macroGenPushVar( const char * szVarName, BOOL bMacroVar, HB_COMP_DECL )
void hb_macroGenPushVar( const char * szVarName, BOOL bMacroVar, HB_COMP_DECL )
{
   int iVar;

   HB_SYMBOL_UNUSED( bMacroVar );

   iVar = hb_macroLocalVarGetPos( szVarName, HB_COMP_PARAM );
   if( iVar )
   {
      /* this is a codeblock parameter */
      hb_macroGenPCode3( HB_P_PUSHLOCAL, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
   }
   else
   {
      hb_macroMemvarGenPCode( HB_P_MPUSHVARIABLE, szVarName, HB_COMP_PARAM );
   }
}
macro.c1324
VOIDhb_macroGenPushVarRef( const char * szVarName, HB_COMP_DECL )
void hb_macroGenPushVarRef( const char * szVarName, HB_COMP_DECL )
{
   USHORT iVar;

   iVar = hb_macroLocalVarGetPos( szVarName, HB_COMP_PARAM );
   if( iVar )
      hb_macroGenPCode3( HB_P_PUSHLOCALREF, HB_LOBYTE( iVar ), HB_HIBYTE( iVar ), HB_COMP_PARAM );
   else
   {
      hb_macroMemvarGenPCode( HB_P_MPUSHMEMVARREF, szVarName, HB_COMP_PARAM );
   }
}
macro.c1345
VOIDhb_macroGenPushMemvarRef( const char * szVarName, HB_COMP_DECL )
void hb_macroGenPushMemvarRef( const char * szVarName, HB_COMP_DECL )
{
   hb_macroMemvarGenPCode( HB_P_MPUSHMEMVARREF, szVarName, HB_COMP_PARAM );
}
macro.c1359
VOIDhb_macroGenPushAliasedVar( const char * szVarName, BOOL bPushAliasValue, const char * szAlias, HB_LONG lWorkarea, HB_COMP_DECL )
void hb_macroGenPushAliasedVar( const char * szVarName,
                                BOOL bPushAliasValue,
                                const char * szAlias,
                                HB_LONG lWorkarea, HB_COMP_DECL )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_macroGenPushAliasedVar(%s->%s)",szAlias,szVarName));

   if( bPushAliasValue )
   {
      if( szAlias )
      {
         /* myalias->var
         * FIELD->var
         * MEMVAR->var
         */
         int iLen = strlen( szAlias );

         if( szAlias[ 0 ] == 'M' && ( iLen == 1 ||
             ( iLen >= 4 && iLen <= 6 && strncmp( szAlias, "MEMVAR", iLen ) == 0 ) ) )
         {  /* M-> or MEMV-> or MEMVA-> or MEMVAR-> variable */
            hb_macroMemvarGenPCode( HB_P_MPUSHMEMVAR, szVarName, HB_COMP_PARAM );
         }
         else if( iLen >= 4 && iLen <= 6 && 
                  ( strncmp( szAlias, "FIELD", iLen ) == 0 ||
                    strncmp( szAlias, "_FIELD", iLen ) == 0 ) )
         {  /* FIELD-> */
            hb_macroMemvarGenPCode( HB_P_MPUSHFIELD, szVarName, HB_COMP_PARAM );
         }
         else
         {  /* database alias */
            hb_macroGenPushSymbol( szAlias, FALSE, HB_COMP_PARAM );
            hb_macroMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_COMP_PARAM );
         }
      }
      else
      {
         hb_macroGenPushLong( lWorkarea, HB_COMP_PARAM );
         hb_macroMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_COMP_PARAM );
      }
   }
   else
   {
      /* Alias is already placed on stack
       * NOTE: An alias will be determined at runtime then we cannot decide
       * here if passed name is either a field or a memvar
       */
      hb_macroMemvarGenPCode( HB_P_MPUSHALIASEDVAR, szVarName, HB_COMP_PARAM );
   }
}
macro.c1365
VOIDhb_macroGenPushLogical( int iTrueFalse, HB_COMP_DECL )
void hb_macroGenPushLogical( int iTrueFalse, HB_COMP_DECL )
{
   if( iTrueFalse )
      hb_macroGenPCode1( HB_P_TRUE, HB_COMP_PARAM );
   else
      hb_macroGenPCode1( HB_P_FALSE, HB_COMP_PARAM );
}
macro.c1418
VOIDhb_macroGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL )
void hb_macroGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL )
{
   BYTE pBuffer[ sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ) + 1 ];

   pBuffer[ 0 ] = HB_P_PUSHDOUBLE;
   HB_PUT_LE_DOUBLE( &( pBuffer[ 1 ] ), dNumber );
   pBuffer[ 1 + sizeof( double ) ] = bWidth;
   pBuffer[ 1 + sizeof( double ) + sizeof( BYTE ) ] = bDec;

   hb_macroGenPCodeN( pBuffer, 1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ), HB_COMP_PARAM );
}
macro.c1427
VOIDhb_macroGenPushFunSym( const char * szFunName, HB_COMP_DECL )
void hb_macroGenPushFunSym( const char * szFunName, HB_COMP_DECL )
{
   const char * szFunction;

   szFunction = hb_compReservedName( szFunName );
   if( szFunction )
   {
      /* Abbreviated function name was used - change it for whole name
       */
      hb_macroGenPushSymbol( szFunction, TRUE, HB_COMP_PARAM );
   }
   else
   {
      HB_MACRO_DATA->status |= HB_MACRO_UDF; /* this is used in hb_macroGetType */
      hb_macroGenPushSymbol( szFunName, TRUE, HB_COMP_PARAM );
   }
}
macro.c1440
VOIDhb_macroGenPushFunCall( const char * szFunName, HB_COMP_DECL )
void hb_macroGenPushFunCall( const char * szFunName, HB_COMP_DECL )
{
   hb_macroGenPushFunSym( szFunName, HB_COMP_PARAM );
   hb_macroGenPCode1( HB_P_PUSHNIL, HB_COMP_PARAM );
}
macro.c1458
VOIDhb_macroGenPushFunRef( const char * szFunName, HB_COMP_DECL )
void hb_macroGenPushFunRef( const char * szFunName, HB_COMP_DECL )
{
   const char * szFunction;

   /* if abbreviated function name was used - change it for whole name */
   szFunction = hb_compReservedName( szFunName );
   hb_macroGenPushSymbol( szFunction ? szFunction : szFunName, TRUE, HB_COMP_PARAM );
}
macro.c1464
VOIDhb_macroGenPushString( const char * szText, ULONG ulStrLen, HB_COMP_DECL )
void hb_macroGenPushString( const char * szText, ULONG ulStrLen, HB_COMP_DECL )
{
   if( ulStrLen <= UINT24_MAX )
   {
      if( ulStrLen <= USHRT_MAX )
         hb_macroGenPCode3( HB_P_MPUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_COMP_PARAM );
      else 
         hb_macroGenPCode4( HB_P_MPUSHSTRLARGE, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ), HB_ULBYTE( ulStrLen ), HB_COMP_PARAM );
      hb_macroGenPCodeN( ( BYTE * ) szText, ulStrLen, HB_COMP_PARAM );
   }
   else
      hb_macroError( HB_MACRO_TOO_COMPLEX, HB_COMP_PARAM );
}
macro.c1473
VOIDhb_macroGenPCode1( BYTE byte, HB_COMP_DECL )
void hb_macroGenPCode1( BYTE byte, HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA;

   if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 1 )
      pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_SIZE );

   pFunc->pCode[ pFunc->lPCodePos++ ] = byte;
}
macro.c1488
VOIDhb_macroGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL )
void hb_macroGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA;

   if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 2 )
      pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_SIZE );

   pFunc->pCode[ pFunc->lPCodePos++ ] = byte1;
   pFunc->pCode[ pFunc->lPCodePos++ ] = byte2;
}
macro.c1498
VOIDhb_macroGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL )
void hb_macroGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA;

   if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 3 )
      pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_SIZE );

   pFunc->pCode[ pFunc->lPCodePos++ ] = byte1;
   pFunc->pCode[ pFunc->lPCodePos++ ] = byte2;
   pFunc->pCode[ pFunc->lPCodePos++ ] = byte3;
}
macro.c1509
VOIDhb_macroGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL )
void hb_macroGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA;

   if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 4 )
      pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_SIZE );

   pFunc->pCode[ pFunc->lPCodePos++ ] = byte1;
   pFunc->pCode[ pFunc->lPCodePos++ ] = byte2;
   pFunc->pCode[ pFunc->lPCodePos++ ] = byte3;
   pFunc->pCode[ pFunc->lPCodePos++ ] = byte4;
}
macro.c1521
VOIDhb_macroGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL )
void hb_macroGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pFunc = HB_PCODE_DATA;

   if( pFunc->lPCodePos + ulSize > pFunc->lPCodeSize )
   {
      /* not enough free space in pcode buffer - increase it */
      pFunc->lPCodeSize += ( ( ( ulSize / HB_PCODE_SIZE ) + 1 ) * HB_PCODE_SIZE );
      pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize );
   }

   memcpy( pFunc->pCode + pFunc->lPCodePos, pBuffer, ulSize );
   pFunc->lPCodePos += ulSize;
}
macro.c1534
VOIDhb_macroError( int iError, HB_COMP_DECL )
void hb_macroError( int iError, HB_COMP_DECL )
{
   HB_MACRO_DATA->status |= iError;
   HB_MACRO_DATA->status &= ~HB_MACRO_CONT;  /* clear CONT bit */
}
macro.c1551
VOIDhb_macroCodeBlockStart( HB_COMP_DECL )
void hb_macroCodeBlockStart( HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pCB;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroCodeBlockStart(%p)", HB_COMP_PARAM));

   pCB = ( HB_PCODE_INFO_PTR ) hb_xgrab( sizeof( HB_PCODE_INFO ) );

   /* replace current pcode buffer with the new one
    */
   pCB->pPrev = HB_PCODE_DATA;
   HB_PCODE_DATA = pCB;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroCodeBlockStart.(%p)", HB_COMP_PARAM));
   pCB->pCode = ( BYTE * ) hb_xgrab( HB_PCODE_SIZE );
   pCB->lPCodeSize = HB_PCODE_SIZE;
   pCB->lPCodePos  = 0;
   pCB->fVParams   = FALSE;
   pCB->pLocals    = NULL;
}
macro.c1557
VOIDhb_macroCodeBlockEnd( HB_COMP_DECL )
void hb_macroCodeBlockEnd( HB_COMP_DECL )
{
   HB_PCODE_INFO_PTR pCodeblock;   /* pointer to the current codeblock */
   ULONG ulSize;
   USHORT wParms = 0;   /* number of codeblock parameters */
   HB_CBVAR_PTR pVar;

   HB_TRACE(HB_TR_DEBUG, ("hb_macroCodeBlockEnd(%p)", HB_COMP_PARAM));

   /* a currently processed codeblock */
   pCodeblock = HB_PCODE_DATA;

   /* return to pcode buffer of a codeblock in which the current
    * codeblock was defined
    */
   HB_PCODE_DATA = pCodeblock->pPrev;

   /* generate a proper codeblock frame with a codeblock size and with
    * a number of expected parameters
    */

   /* Count the number of codeblock parameters */
   pVar = pCodeblock->pLocals;
   while( pVar )
   {
      pVar = pVar->pNext;
      ++wParms;
   }

   /*NOTE:  6 = HB_P_MPUSHBLOCK + USHORT( size ) + USHORT( wParams ) + _ENDBLOCK
    * runtime compiled codeblock cannot reference local variables defined in a
    * function
    */
   ulSize = ( ULONG ) pCodeblock->lPCodePos + 6;

   /*NOTE: HB_P_MPUSHBLOCK differs from HB_P_PUSHBLOCK - the pcode
    * is stored in dynamic memory pool instead of static memory
    */
   if( ulSize <= USHRT_MAX )
      hb_macroGenPCode3( HB_P_MPUSHBLOCK, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_COMP_PARAM );
   else
   {
      ++ulSize;
      hb_macroGenPCode4( HB_P_MPUSHBLOCKLARGE, HB_LOBYTE( ulSize ), HB_HIBYTE( ulSize ), HB_ULBYTE( ulSize ), HB_COMP_PARAM );
   }
   hb_macroGenPCode2( HB_LOBYTE( wParms ), HB_HIBYTE( wParms ), HB_COMP_PARAM );

   /* copy a codeblock pcode buffer */
   hb_macroGenPCodeN( pCodeblock->pCode, pCodeblock->lPCodePos, HB_COMP_PARAM );
   hb_macroGenPCode1( HB_P_ENDBLOCK, HB_COMP_PARAM ); /* finish the codeblock */

   /* free memory allocated for a codeblock */
   hb_xfree( ( void * ) pCodeblock->pCode );
   hb_xfree( ( void * ) pCodeblock );
}
macro.c1581
maindll.c
TypeFunctionSourceLine
HB_EXPORT BOOL WINAPIDllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
   HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %p)", hInstance, fdwReason,
             pvReserved ) );

   HB_SYMBOL_UNUSED( hInstance );
   HB_SYMBOL_UNUSED( fdwReason );
   HB_SYMBOL_UNUSED( pvReserved );

   switch( fdwReason )
   {
      case DLL_PROCESS_ATTACH:
           hb_vmInit( FALSE );  /* Don't execute first linked symbol */
           break;

      case DLL_PROCESS_DETACH:
           hb_vmQuit();
           break;
   }

   return TRUE;
}
maindll.c65
HB_EXPORT LONG PASCALHBDLLENTRY( char * cProcName )
HB_EXPORT LONG PASCAL HBDLLENTRY( char * cProcName )
{
   hb_itemDoC( cProcName, 0, 0 );

   return 0;
}
maindll.c88
HB_EXPORT LONG PASCALHBDLLENTRY1( char * cProcName, LONG pItem )
HB_EXPORT LONG PASCAL HBDLLENTRY1( char * cProcName, LONG pItem )
{
   hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );

   return 0;
}
maindll.c95
HB_EXPORT LONG PASCALHBDLLENTRY2( char * cProcName, LONG pItem1, LONG pItem2 )
HB_EXPORT LONG PASCAL HBDLLENTRY2( char * cProcName, LONG pItem1, LONG pItem2 )
{
   hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );

   return 0;
}
maindll.c102
maindllh.c
TypeFunctionSourceLine
HB_EXPORT BOOL WINAPIDllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
   HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason,
             pvReserved ) );

   HB_SYMBOL_UNUSED( hInstance );
   HB_SYMBOL_UNUSED( fdwReason );
   HB_SYMBOL_UNUSED( pvReserved );

   switch( fdwReason )
   {
      case DLL_PROCESS_ATTACH:
           break;

      case DLL_PROCESS_DETACH:
           break;
   }

   return TRUE;
}
maindllh.c65
maindllp.c
TypeFunctionSourceLine
HB_EXTERN_BEGIN STATIC FARPROChb_getProcAddress( LPCSTR szProcName )
static FARPROC hb_getProcAddress( LPCSTR szProcName )
{
   static HMODULE s_hModule = NULL;
   FARPROC pProcAddr = NULL;

   if( s_hModule == NULL )
   {
      s_hModule = GetModuleHandle( HB_DLL_NAME );
#ifdef HB_DLL_NAME2
      if( s_hModule == NULL )
         s_hModule = GetModuleHandle( HB_DLL_NAME2 );
#endif
      if( s_hModule == NULL )
         s_hModule = GetModuleHandle( NULL );
   }
   if( s_hModule )
   {
      pProcAddr = GetProcAddress( s_hModule, szProcName );
      if( pProcAddr == NULL && szProcName[ 0 ] == '_' )
         pProcAddr = GetProcAddress( s_hModule, szProcName + 1 );
   }

   if( pProcAddr == NULL )
      hb_errInternal( 9997, "Cannot find address for function %s", szProcName, NULL );

   return pProcAddr;
}
maindllp.c73
HB_EXPORT BOOL WINAPIDllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
   HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason,
             pvReserved ) );

   HB_SYMBOL_UNUSED( hInstance );
   HB_SYMBOL_UNUSED( fdwReason );
   HB_SYMBOL_UNUSED( pvReserved );

   switch( fdwReason )
   {
      case DLL_PROCESS_ATTACH:
           break;

      case DLL_PROCESS_DETACH:
           break;
   }

   return TRUE;
}
maindllp.c101
PHB_SYMBhb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols )
PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols )
{
   /* notice hb_vmProcessDllSymbols() must be used, and not
    * hb_vmProcessSymbols(), as some special symbols pointers
    * adjustments are required
    */
   static FARPROC s_pProcessSymbols = NULL;

   if( !s_pProcessSymbols )
      s_pProcessSymbols = hb_getProcAddress( "_hb_vmProcessDllSymbols" );

   if( s_pProcessSymbols )
      return ( ( VM_PROCESS_DLL_SYMBOLS ) s_pProcessSymbols ) ( pSymbols,
                                                                uiSymbols );
   /* else
    *    may we issue an error ? */

   return pSymbols;
}
maindllp.c122
PHB_SYMBhb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiSymbols, char * szModuleName, ULONG ulID, USHORT uiPcodeVer )
PHB_SYMB hb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiSymbols, char * szModuleName, ULONG ulID, USHORT uiPcodeVer ) /* module symbols initialization with extended information */
{
   static FARPROC s_pProcessSymbols = NULL;

   if( !s_pProcessSymbols )
      s_pProcessSymbols = hb_getProcAddress( "_hb_vmProcessSymbolsEx" );

   if( s_pProcessSymbols )
      return ( ( VM_PROCESS_SYMBOLS_EX ) s_pProcessSymbols )
                  ( pSymbols, uiSymbols, szModuleName, ulID, uiPcodeVer );
   /* else
    *    may we issue an error ? */

   return pSymbols;
}
maindllp.c143
VOIDhb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
{
   static FARPROC s_pExecute = NULL;

   if( !s_pExecute )
      s_pExecute = hb_getProcAddress( "_hb_vmExecute" );

   if( s_pExecute )
      ( ( VM_DLL_EXECUTE ) s_pExecute ) ( pCode, pSymbols );

   /* else
    *    may we issue an error ? */
}
maindllp.c160
CHAR *hb_parc( int iParam, ... )
char * hb_parc( int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pParC = GetProcAddress( GetModuleHandle( NULL ), "_hb_parc" );

   if( pExtIsArray && pParC )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( EXT_PARC2 ) pParC )( iParam, ulArrayIndex );
      }
      else
         return ( ( EXT_PARC1 ) pParC )( iParam );
   }

   return NULL;
}
maindllp.c177
PHB_ITEMhb_param( int iParam, long lMask )
PHB_ITEM hb_param( int iParam, long lMask ) /* retrieve a generic parameter */
{
   PHB_ITEM pReturn = NULL;
   FARPROC pParam = GetProcAddress( GetModuleHandle( NULL ), "_hb_param" );
   if( pParam )
      pReturn = ( ( HB_PARAM ) pParam )( iParam, lMask );
   return pReturn;
}
maindllp.c202
PHB_ITEMhb_paramError( int iParam )
PHB_ITEM hb_paramError( int iParam ) /* Returns either the generic parameter or a NIL item if param not provided */
{
   PHB_ITEM pReturn = NULL;
   FARPROC pParamError = GetProcAddress( GetModuleHandle( NULL ), "_hb_paramError" );
   if( pParamError )
      pReturn = ((HB_PARAMERROR)pParamError)(iParam);
   return pReturn;
}
maindllp.c211
INThb_pcount( void )
int   hb_pcount( void )          /* returns the number of suplied parameters */
{
   int iReturn = 0;
   FARPROC pCounts = GetProcAddress( GetModuleHandle( NULL ), "_hb_pcount" );
   if( pCounts )
      iReturn = ((HB_PCOUNTS)pCounts)();
   return iReturn;
}
maindllp.c219
VOIDhb_retc( const char * szText )
void hb_retc( const char * szText )   /* returns a string */
{
   FARPROC pRetc=GetProcAddress(GetModuleHandle( NULL ), "_hb_retc" );
   if( pRetc )
      ((HB_RETC)pRetc)(szText);
}
maindllp.c228
VOIDhb_retclen( const char * szText, ULONG ulLen )
void hb_retclen( const char * szText, ULONG ulLen ) /* returns a string with a specific length */
{
   FARPROC pRetclen = GetProcAddress(GetModuleHandle( NULL ), "_hb_retclen" );
   if( pRetclen )
      ((HB_RETCLEN)pRetclen)(szText,ulLen);
}
maindllp.c235
VOIDhb_retds( const char * szDate )
void hb_retds( const char * szDate )  /* returns a date, must use yyyymmdd format */
{
   FARPROC pRetds = GetProcAddress(GetModuleHandle( NULL ), "_hb_retds" );
   if( pRetds )
      ((HB_RETDS)pRetds)(szDate);
}
maindllp.c242
VOIDhb_retd( int iYear, int iMonth, int iDay )
void hb_retd( int iYear, int iMonth, int iDay ) /* returns a date */
{
   FARPROC pRetd = GetProcAddress(GetModuleHandle( NULL ), "_hb_retd" );
   if( pRetd )
      ((HB_RETD)pRetd)( iYear, iMonth, iDay );
}
maindllp.c249
VOIDhb_retdl( long lJulian )
void hb_retdl( long lJulian )   /* returns a long value as a julian date */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retdl" );
   if( pRet )
      ((HB_RETDL)pRet)(lJulian);

}
maindllp.c256
VOIDhb_retl( int iTrueFalse )
void hb_retl( int iTrueFalse ) /*  returns a logical integer */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retl" );
   if( pRet )
      ((HB_RETDL)pRet)(iTrueFalse);
}
maindllp.c264
VOIDhb_retnd( double dNumber )
void hb_retnd( double dNumber ) /* returns a double */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retnd" );
   if( pRet )
      ((HB_RETND)pRet)(dNumber);
}
maindllp.c271
VOIDhb_retni( int iNumber )
void hb_retni( int iNumber )    /* returns a integer number */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retni" );
   if( pRet )
      ((HB_RETNI)pRet)(iNumber);

}
maindllp.c278
VOIDhb_retnl( long lNumber )
void hb_retnl( long lNumber )   /* returns a long number */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retnl" );
   if( pRet )
      ((HB_RETNL)pRet)(lNumber);
}
maindllp.c286
VOIDhb_retnlen( double dNumber, int iWidth, int iDec )
void hb_retnlen( double dNumber, int iWidth, int iDec ) /* returns a double, with specific width and decimals */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retnlen" );
   if( pRet )
      ((HB_RETNLEN)pRet)(dNumber,iWidth,iDec);
}
maindllp.c293
VOIDhb_retndlen( double dNumber, int iWidth, int iDec )
void hb_retndlen( double dNumber, int iWidth, int iDec ) /* returns a double, with specific width and decimals */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retndlen" );
   if( pRet )
      ((HB_RETNDLEN)pRet)(dNumber,iWidth,iDec);
}
maindllp.c300
VOIDhb_retnilen( int iNumber, int iWidth )
void hb_retnilen( int iNumber, int iWidth ) /* returns a integer number, with specific width */
{
    FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retnilen" );
    if( pRet )
      ((HB_RETNILEN)pRet)(iNumber,iWidth);
}
maindllp.c307
VOIDhb_retnllen( long lNumber, int iWidth )
void hb_retnllen( long lNumber, int iWidth ) /* returns a long number, with specific width */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_retnilen" );
   if( pRet )
      ((HB_RETNLLEN)pRet)(lNumber,iWidth);
}
maindllp.c314
VOIDhb_reta( ULONG ulLen )
void hb_reta( ULONG ulLen )  /* returns an array with a specific length */
{
   FARPROC pRet = GetProcAddress(GetModuleHandle( NULL ), "_hb_reta" );
   if( pRet )
      ((HB_RETA)pRet)(ulLen);
}
maindllp.c321
ULONGhb_parinfa( int iParamNum, ULONG uiArrayIndex )
ULONG hb_parinfa( int iParamNum, ULONG uiArrayIndex ) /* retrieve length or element type of an array parameter */
{
   ULONG ulReturn = 0;
   FARPROC pParinfa = GetProcAddress( GetModuleHandle( NULL ), "_hb_parinfa" );
   if( pParinfa )
      ulReturn = ((HB_PARINFA)pParinfa)(iParamNum,uiArrayIndex);
   return ulReturn;
}
maindllp.c328
ULONGhb_parinfo( int iParam )
ULONG hb_parinfo( int iParam ) /* Determine the param count or data type */
{
   ULONG ulReturn = 0;
   FARPROC pParinfo = GetProcAddress( GetModuleHandle( NULL ), "_hb_parinfo" );
   if( pParinfo )
      ulReturn = ((HB_PARINFO)pParinfo)(iParam);
   return ulReturn;
}
maindllp.c337
ULONGhb_parclen( int iParam, ... )
ULONG hb_parclen( int iParam, ... ) /* retrieve a string parameter length */
{
   FARPROC pParC = GetProcAddress( GetModuleHandle( NULL ), "_hb_parclen" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   if( pExtIsArray && pParC )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARCLEN2 ) pParC )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARCLEN ) pParC )( iParam );
   }

   return 0;
}
maindllp.c346
ULONGhb_parcsiz( int iParam, ... )
ULONG hb_parcsiz( int iParam, ... )/* retrieve a by-reference string parameter length, including terminator */
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pParcSiz = GetProcAddress( GetModuleHandle( NULL ), "_hb_parcsiz" );

   if( pExtIsArray && pParcSiz )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARCSIZ2 ) pParcSiz )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARCSIZ ) pParcSiz )( iParam );
   }

   return 0;
}
maindllp.c370
CHAR *hb_pards( int iParam, ... )
char * hb_pards( int iParam, ... ) /* retrieve a date as a string yyyymmdd */
{
   FARPROC pParDs = GetProcAddress( GetModuleHandle( NULL ), "_hb_pards" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );

   if( pExtIsArray && pParDs )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARDS2 ) pParDs )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARDS ) pParDs )( iParam );
   }

   return "";
}
maindllp.c395
CHAR *hb_pardsbuff( char * szDate, int iParam, ... )
char * hb_pardsbuff( char * szDate, int iParam, ... ) /* retrieve a date as a string yyyymmdd */
{
   FARPROC pParDsBuff = GetProcAddress( GetModuleHandle( NULL ), "_hb_pardsbuff" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );

   if( pExtIsArray && pParDsBuff )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARDSBUFF2 ) pParDsBuff )( szDate, iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARDSBUFF ) pParDsBuff )( szDate, iParam );
   }

   return "";
}
maindllp.c420
INThb_parl( int iParam, ... )
int hb_parl( int iParam, ... ) /* retrieve a logical parameter as an int */
{
   /* int iReturn; */
   FARPROC pParL = GetProcAddress( GetModuleHandle( NULL ), "_hb_parl" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );

   if( pExtIsArray && pParL )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARL2 ) pParL )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARL ) pParL )( iParam );
   }

   return 0;
}
maindllp.c445
DOUBLEhb_parnd( int iParam, ... )
double hb_parnd( int iParam, ... ) /* retrieve a numeric parameter as a double */
{

   FARPROC pParNd = GetProcAddress( GetModuleHandle( NULL ), "_hb_parnd" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );

   if( pExtIsArray && pParNd )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARND2 ) pParNd )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARND ) pParNd )( iParam );
   }

   return 0;
}
maindllp.c471
INThb_parni( int iParam, ... )
int hb_parni( int iParam, ... ) /* retrieve a numeric parameter as a integer */
{
   /* int iReturn; */
   FARPROC pParNi = GetProcAddress( GetModuleHandle( NULL ), "_hb_parni" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );

   if( pExtIsArray && pParNi )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARNI2 ) pParNi )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARNI ) pParNi )( iParam );
   }

   return 0;
}
maindllp.c497
LONGhb_parnl( int iParam, ... )
long hb_parnl( int iParam, ... ) /* retrieve a numeric parameter as a long */
{

   FARPROC pParNl = GetProcAddress( GetModuleHandle( NULL ), "_hb_parnl" );
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );

   if( pExtIsArray && pParNl )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         return ( ( HB_PARNL2 ) pParNl )( iParam, ulArrayIndex );
      }
      else
         return ( ( HB_PARNL ) pParNl )( iParam );
   }

   return 0;
}
maindllp.c523
INThb_storc( char * szText, int iParam, ... )
int hb_storc( char * szText, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorC = GetProcAddress( GetModuleHandle( NULL ), "_hb_storc" );

   if( pExtIsArray && pStorC )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORC2) pStorC )( szText, iParam, ulArrayIndex );
         return 1;
      }
      else
      {
         ( ( HB_STORC ) pStorC )( szText, iParam );
         return 1;
      }
   }

   return 0;
}
maindllp.c549
INThb_storclen( char * szText, ULONG ulLen, int iParam, ... )
int hb_storclen( char * szText, ULONG ulLen, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorC = GetProcAddress( GetModuleHandle( NULL ), "_hb_storclen" );

   if( pExtIsArray && pStorC )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORCLEN2) pStorC )( szText, ulLen, iParam, ulArrayIndex );
         return 1;
      }
      else
      {
         ( ( HB_STORCLEN ) pStorC )( szText, ulLen, iParam );
         return 1;
      }

   }

   return 0;
}
maindllp.c578
INThb_stords( char * szDate, int iParam, ... )
int hb_stords( char * szDate, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorDs = GetProcAddress( GetModuleHandle( NULL ), "_hb_stords" );

   if( pExtIsArray && pStorDs )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORDS2) pStorDs )( szDate, iParam, ulArrayIndex );

         return 1;
      }
      else
      {
         ( ( HB_STORDS ) pStorDs )( szDate, iParam );
         return 1;
      }

   }

   return 0;
}
maindllp.c608
INThb_storl( int iLogical, int iParam, ... )
int hb_storl( int iLogical, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorL = GetProcAddress( GetModuleHandle( NULL ), "_hb_storl" );

   if( pExtIsArray && pStorL )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORL2) pStorL )( iLogical, iParam, ulArrayIndex );
         return 1;
      }
      else
      {
         ( ( HB_STORL ) pStorL )(  iLogical, iParam );
         return 1;
      }

   }

   return 0;
}
maindllp.c639
INThb_storni( int iValue, int iParam, ... )
int hb_storni( int iValue, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorNi = GetProcAddress( GetModuleHandle( NULL ), "_hb_storni" );

   if( pExtIsArray && pStorNi )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORNI2) pStorNi )( iValue, iParam, ulArrayIndex );
         return 1;
      }
      else
      {
         ( ( HB_STORNI) pStorNi )(  iValue, iParam );
         return 1;
      }

   }

   return 0;
}
maindllp.c669
INThb_stornl( long lValue, int iParam, ... )
int hb_stornl( long lValue, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorNl = GetProcAddress( GetModuleHandle( NULL ), "_hb_stornl" );

   if( pExtIsArray && pStorNl )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORNL2) pStorNl )( lValue, iParam, ulArrayIndex );
         return 1;
      }
      else
      {
         ( ( HB_STORNL) pStorNl )(  lValue, iParam );
         return 1;
      }

   }

   return 0;
}
maindllp.c699
INThb_stornd( double dNumber, int iParam, ... )
int hb_stornd( double dNumber, int iParam, ... )
{
   FARPROC pExtIsArray = GetProcAddress( GetModuleHandle( NULL ), "_hb_extIsArray" );
   FARPROC pStorNd = GetProcAddress( GetModuleHandle( NULL ), "_hb_stornd" );

   if( pExtIsArray && pStorNd )
   {
      if( ( ( EXT_IS_ARRAY ) pExtIsArray ) ( iParam ) )
      {
         va_list va;
         ULONG ulArrayIndex;

         va_start( va, iParam );
         ulArrayIndex = va_arg( va, ULONG );
         va_end( va );

         ( ( HB_STORND2) pStorNd )( dNumber, iParam, ulArrayIndex );
         return 1;
      }
      else
      {
         ( ( HB_STORND) pStorNd )( dNumber, iParam );
         return 1;
      }

   }

   return 0;
}
maindllp.c729
BOOLhb_arrayNew( PHB_ITEM pItem, ULONG ulLen )
BOOL     hb_arrayNew( PHB_ITEM pItem, ULONG ulLen )  /* creates a new array */
{
   HB_ARRAYNEW  pArrayNew = (HB_ARRAYNEW) GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayNew" );
   if( pArrayNew )
      return pArrayNew( pItem, ulLen );
   else
      return FALSE;
}
maindllp.c759
ULONGhb_arrayLen( PHB_ITEM pArray )
ULONG    hb_arrayLen( PHB_ITEM pArray )  /* retrives the array len */
{
   HB_ARRAYLEN  pArrayLen = (HB_ARRAYLEN)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayLen" );
   if( pArrayLen )
      return pArrayLen( pArray );
   else
      return 0;
}
maindllp.c768
BOOLhb_arrayIsObject( PHB_ITEM pArray )
BOOL     hb_arrayIsObject( PHB_ITEM pArray )  /* retrives if the array is an object */
{
   HB_ARRAYISOBJECT  pArrayIsObject = (HB_ARRAYISOBJECT)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayIsObject" );
   if( pArrayIsObject )
      return pArrayIsObject( pArray );
   else
      return FALSE;
}
maindllp.c777
BOOLhb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue )
BOOL     hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue )  /* add a new item to the end of an array item */
{
   HB_ARRAYADD  pArrayAdd = (HB_ARRAYADD)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayAdd" );
   if( pArrayAdd )
      return pArrayAdd( pArray, pItemValue );
   else
      return FALSE;
}
maindllp.c786
BOOLhb_arrayIns( PHB_ITEM pArray, ULONG ulIndex )
BOOL     hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex )  /* insert a nil item into an array, without changing the length */
{
   HB_ARRAYINS  pArrayIns = (HB_ARRAYINS)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayIns" );
   if( pArrayIns )
      return pArrayIns( pArray, ulIndex );
   else
      return FALSE;
}
maindllp.c795
BOOLhb_arrayDel( PHB_ITEM pArray, ULONG ulIndex )
BOOL     hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex )  /* delete an array item, without changing length */
{
   HB_ARRAYDEL  pArrayDel = (HB_ARRAYDEL)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayDel" );
   if( pArrayDel )
      return pArrayDel( pArray, ulIndex );
   else
      return FALSE;
}
maindllp.c804
BOOLhb_arraySize( PHB_ITEM pArray, ULONG ulLen )
BOOL     hb_arraySize( PHB_ITEM pArray, ULONG ulLen )  /* sets the array total length */
{
   HB_ARRAYSIZE  pArraySize = (HB_ARRAYSIZE)GetProcAddress( GetModuleHandle( NULL ), "_hb_arraySize" );
   if( pArraySize )
      return pArraySize( pArray, ulLen );
   else
      return FALSE;
}
maindllp.c813
BOOLhb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult )
BOOL     hb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult )  /* retrieve last item in an array */
{
   HB_ARRAYLAST  pArrayLast= (HB_ARRAYLAST)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayLast" );
   if( pArrayLast )
      return pArrayLast( pArray, pResult );
   else
      return FALSE;
}
maindllp.c822
BOOLhb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
BOOL     hb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )  /* sets an array element */
{
   HB_ARRAYSET  pArraySet = (HB_ARRAYSET)GetProcAddress( GetModuleHandle( NULL ), "_hb_arraySet" );
   if( pArraySet )
      return pArraySet( pArray, ulIndex, pItem);
   else
      return FALSE;
}
maindllp.c831
BOOLhb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )
BOOL     hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem )  /* retrieves an item */
{
   HB_ARRAYGET  pArrayGet = (HB_ARRAYGET)GetProcAddress( GetModuleHandle( NULL ), "_hb_arrayGet" );
   if( pArrayGet )
      return pArrayGet( pArray, ulIndex, pItem);
   else
      return FALSE;
}
maindllp.c840
VOIDhb_xinit( void )
void     hb_xinit( void )                         /* Initialize fixed memory subsystem */
{
   HB_XINIT pXinit = (HB_XINIT)GetProcAddress( GetModuleHandle( NULL ), "_hb_xinit" );
   if( pXinit )
      pXinit();
}
maindllp.c849
VOIDhb_xexit( void )
void     hb_xexit( void )                         /* Deinitialize fixed memory subsystem */
{
   HB_XEXIT pXexit = (HB_XEXIT)GetProcAddress( GetModuleHandle( NULL ), "_hb_xexit" );
   if( pXexit )
      pXexit();
}
maindllp.c856
VOID *hb_xalloc( ULONG ulSize )
void * hb_xalloc( ULONG ulSize )                /* allocates memory, returns NULL on failure */
{
   void * pRet = NULL;
   HB_XALLOC pXalloc = (HB_XALLOC)GetProcAddress( GetModuleHandle( NULL ), "_hb_xalloc" );
   if( pXalloc )
      pRet=pXalloc( ulSize );
   return pRet;
}
maindllp.c863
VOID *hb_xgrab( ULONG ulSize )
void * hb_xgrab( ULONG ulSize )                 /* allocates memory, exits on failure */
{
   void * pRet = NULL;
   HB_XGRAB pXgrab = (HB_XGRAB)GetProcAddress( GetModuleHandle( NULL ), "_hb_xgrab" );
   if( pXgrab )
      pRet = pXgrab( ulSize );
   return pRet;
}
maindllp.c872
VOIDhb_xfree( void * pMem )
void hb_xfree( void * pMem )                  /* frees memory */
{
   HB_XFREE pXfree = (HB_XFREE)GetProcAddress( GetModuleHandle( NULL ), "_hb_xfree" );
   if( pXfree )
      pXfree( pMem );
}
maindllp.c881
VOID *hb_xrealloc( void * pMem, ULONG ulSize )
void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */
{
   void * pRet = NULL;
   HB_XREALLOC pXrealloc = (HB_XREALLOC)GetProcAddress( GetModuleHandle( NULL ), "_hb_xrealloc" );
   if( pXrealloc )
      pRet = (void*) pXrealloc( pMem, ulSize );
      return pRet;
}
maindllp.c888
ULONGhb_xsize( void * pMem )
ULONG   hb_xsize( void * pMem )                  /* returns the size of an allocated memory block */
{
   HB_XSIZE pXsize = (HB_XSIZE)GetProcAddress( GetModuleHandle( NULL ), "_hb_xsize" );
   ULONG ulReturn = 0;
   if( pXsize )
      ulReturn = pXsize( (void *)pMem );
   return ulReturn;
}

HB_EXTERN_END
maindllp.c897
mainpm.c
TypeFunctionSourceLine
INTmain( int argc, char * argv[] )
int main( int argc, char * argv[] )
{
   int  iErrorCode;
   HAB  hab;         /* Anchor Block handle */
   HMQ  hmq;         /* Message Queue handle */

   hab = WinInitialize( 0 );
   hmq = WinCreateMsgQueue( hab, 0 );

   hb_cmdargInit( argc, argv );
   hb_vmInit( TRUE );
   iErrorCode = hb_vmQuit();

   WinDestroyMsgQueue( hmq );
   WinTerminate( hab );

   return iErrorCode;
}
mainpm.c62
mainstd.c
TypeFunctionSourceLine
INTmain( int argc, char * argv[] )
int main( int argc, char * argv[] )
{
   HB_TRACE(HB_TR_DEBUG, ("main(%d, %p)", argc, argv));

   hb_cmdargInit( argc, argv );
   hb_vmInit( TRUE );
   return hb_vmQuit();
}
mainstd.c61
CHAR **__crt0_glob_function( char * _arg )
char ** __crt0_glob_function( char * _arg )
{
   /* This function disables command line wildcard expansion. */
   HB_SYMBOL_UNUSED( _arg );

   return 0;
}
mainstd.c71
HB_EXPORT VOIDhb_forceLinkMainStd( void )
HB_EXPORT void hb_forceLinkMainStd( void ) {}
#endif

HB_EXTERN_END
mainstd.c81
mainwin.c
TypeFunctionSourceLine
HB_EXTERN_BEGIN HB_EXPORT VOIDhb_forceLinkMainWin( void )
HB_EXTERN_BEGIN
HB_EXPORT void hb_forceLinkMainWin( void ) {}
HB_EXTERN_END
mainwin.c64
memvars.c
TypeFunctionSourceLine
STATIC PHB_ITEMhb_memvarValueNew( void )
static PHB_ITEM hb_memvarValueNew( void )
{
   PHB_ITEM pMemvar;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarValueNew()"));

   pMemvar = ( PHB_ITEM ) hb_xgrab( sizeof( HB_ITEM ) );
   pMemvar->type = HB_IT_NIL;

   return pMemvar;
}
memvars.c108
VOIDhb_memvarValueIncRef( PHB_ITEM pMemvar )
void hb_memvarValueIncRef( PHB_ITEM pMemvar )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarValueIncRef(%p)", pMemvar));

   hb_xRefInc( pMemvar );
}
memvars.c124
VOIDhb_memvarValueDecRef( PHB_ITEM pMemvar )
void hb_memvarValueDecRef( PHB_ITEM pMemvar )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarValueDecRef(%p)", pMemvar));

   if( hb_xRefDec( pMemvar ) )
   {
      if( HB_IS_COMPLEX( pMemvar ) )
         hb_itemClear( pMemvar );
      hb_xfree( pMemvar );
   }
}
memvars.c131
STATIC VOIDhb_memvarDetachDynSym( PHB_DYNS pDynSym, PHB_ITEM pPrevMemvar )
static void hb_memvarDetachDynSym( PHB_DYNS pDynSym, PHB_ITEM pPrevMemvar )
{
   PHB_ITEM pMemvar;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarDetachDynSym(%p,%p)", pDynSym, pPrevMemvar));

   pMemvar = hb_dynsymGetMemvar( pDynSym );
   hb_dynsymSetMemvar( pDynSym, pPrevMemvar );

   hb_memvarValueDecRef( pMemvar );
}
memvars.c147
HB_ITEM_PTRhb_memvarDetachLocal( PHB_ITEM pLocal )
HB_ITEM_PTR hb_memvarDetachLocal( PHB_ITEM pLocal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarDetachLocal(%p)", pLocal));

   if( HB_IS_BYREF( pLocal ) )
   {
      do
      {
         if( HB_IS_MEMVAR( pLocal ) )
            break;
         else if( HB_IS_ENUM( pLocal ) && !pLocal->item.asEnum.valuePtr )
         {
            PHB_ITEM pBase = HB_IS_BYREF( pLocal->item.asEnum.basePtr ) ?
                            hb_itemUnRef( pLocal->item.asEnum.basePtr ) :
                                          pLocal->item.asEnum.basePtr;
            if( HB_IS_ARRAY( pBase ) )
            {
               PHB_ITEM pItem = hb_itemNew( NULL );
               hb_arrayGetItemRef( pBase, pLocal->item.asEnum.offset, pItem );
               pLocal->item.asEnum.valuePtr = pItem;
               pLocal = pItem;
               break;
            }
         }
         else if( pLocal->item.asRefer.value >= 0 &&
                  pLocal->item.asRefer.offset == 0 )
            break;
         pLocal = hb_itemUnRefOnce( pLocal );
      }
      while( HB_IS_BYREF( pLocal ) );
   }

   /* Change the value only if this variable is not referenced
    * by another codeblock yet.
    * In this case we have to copy the current value to a global memory
    * pool so it can be shared by codeblocks
    */
   if( ! HB_IS_MEMVAR( pLocal ) )
   {
      PHB_ITEM pMemvar = hb_memvarValueNew();

      memcpy( pMemvar, pLocal, sizeof( HB_ITEM ) );
      pMemvar->type &= ~HB_IT_DEFAULT;

      pLocal->type = HB_IT_BYREF | HB_IT_MEMVAR;
      pLocal->item.asMemvar.value = pMemvar;
   }

   return pLocal;
}
memvars.c162
STATIC VOIDhb_memvarAddPrivate( PHB_DYNS pDynSym, PHB_ITEM pValue )
static void hb_memvarAddPrivate( PHB_DYNS pDynSym, PHB_ITEM pValue )
{
   PHB_PRIVATE_STACK pPrivateStack;
   PHB_ITEM pMemvar;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarAddPrivate(%p,%p)", pDynSym, pValue));

   pPrivateStack = hb_stackGetPrivateStack();

   /* Allocate the value from the end of table
    */
   if( pPrivateStack->count == pPrivateStack->size )
   {
      /* No more free values in the table - expand the table
       */
      if( pPrivateStack->size == 0 )
      {
         pPrivateStack->stack = ( PHB_PRIVATE_ITEM )
               hb_xgrab( sizeof( HB_PRIVATE_ITEM ) * TABLE_INITHB_VALUE );
         pPrivateStack->size  = TABLE_INITHB_VALUE;
         pPrivateStack->count = pPrivateStack->base = 0;
      }
      else
      {
         pPrivateStack->size += TABLE_EXPANDHB_VALUE;
         pPrivateStack->stack = ( PHB_PRIVATE_ITEM )
               hb_xrealloc( pPrivateStack->stack,
                            sizeof( HB_PRIVATE_ITEM ) * pPrivateStack->size );
      }
   }

   pPrivateStack->stack[ pPrivateStack->count ].pDynSym = pDynSym;
   pPrivateStack->stack[ pPrivateStack->count++ ].pPrevMemvar = hb_dynsymGetMemvar( pDynSym );

   pMemvar = hb_memvarValueNew();
   hb_dynsymSetMemvar( pDynSym, pMemvar );

   if( pValue )
   {
      hb_itemCopy( pMemvar, pValue );
      /* Remove MEMOFLAG if exists (assignment from field). */
      pMemvar->type &= ~HB_IT_MEMOFLAG;
   }
}
memvars.c217
ULONGhb_memvarGetPrivatesBase( void )
ULONG hb_memvarGetPrivatesBase( void )
{
   ULONG ulBase;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarGetPrivatesBase()"));

   ulBase = hb_stackGetPrivateStack()->base;
   hb_stackGetPrivateStack()->base = hb_stackGetPrivateStack()->count;
   return ulBase;
}
memvars.c269
VOIDhb_memvarSetPrivatesBase( ULONG ulBase )
void hb_memvarSetPrivatesBase( ULONG ulBase )
{
   PHB_PRIVATE_STACK pPrivateStack;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarSetPrivatesBase(%lu)", ulBase));

   pPrivateStack = hb_stackGetPrivateStack();

   while( pPrivateStack->count > pPrivateStack->base )
   {
      PHB_DYNS pDynSym = pPrivateStack->stack[ --pPrivateStack->count ].pDynSym;

      if( hb_dynsymGetMemvar( pDynSym ) )
      {
         /* Restore previous value for variables that were overridden
          */
         hb_memvarDetachDynSym( pDynSym, pPrivateStack->stack[ pPrivateStack->count ].pPrevMemvar );
      }
   }
   pPrivateStack->base = ulBase;
}
memvars.c283
VOIDhb_memvarUpdatePrivatesBase( void )
void hb_memvarUpdatePrivatesBase( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarUpdatePrivatesBase()"));

   hb_stackGetPrivateStack()->base = hb_stackGetPrivateStack()->count;
}
memvars.c308
VOIDhb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem )
void hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem )
{
   PHB_DYNS pDyn;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarSetValue(%p, %p)", pMemvarSymb, pItem));

   pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym;
   if( pDyn )
   {
      PHB_ITEM pMemvar;

      HB_TRACE(HB_TR_INFO, ("Memvar item (%i)(%s) assigned", hb_dynsymGetMemvar( pDyn ), pMemvarSymb->szName));

      pMemvar = hb_dynsymGetMemvar( pDyn );
      if( pMemvar )
      {
         /* value is already created */
         hb_itemCopyToRef( pMemvar, pItem );
         /* Remove MEMOFLAG if exists (assignment from field). */
         pMemvar->type &= ~HB_IT_MEMOFLAG;
      }
      else
      {
         /* assignment to undeclared memvar - PRIVATE is assumed */
         hb_memvarCreateFromDynSymbol( pDyn, VS_PRIVATE, pItem );
      }

   }
   else
      hb_errInternal( HB_EI_MVBADSYMBOL, NULL, pMemvarSymb->szName, NULL );
}
memvars.c319
ERRCODEhb_memvarGet( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
ERRCODE hb_memvarGet( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
{
   PHB_DYNS pDyn;
   ERRCODE bSuccess = FAILURE;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarGet(%p, %p)", pItem, pMemvarSymb));

   pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym;
   if( pDyn )
   {
      PHB_ITEM pMemvar;

      HB_TRACE(HB_TR_INFO, ("Memvar item (%i)(%s) queried", hb_dynsymGetMemvar( pDyn ), pMemvarSymb->szName));

      pMemvar = hb_dynsymGetMemvar( pDyn );
      if( pMemvar )
      {
         /* value is already created
          */
         if( HB_IS_BYREF( pMemvar ) )
            hb_itemCopy( pItem, hb_itemUnRef( pMemvar ) );
         else
            hb_itemCopy( pItem, pMemvar );
         bSuccess = SUCCESS;
      }
   }
   else
      hb_errInternal( HB_EI_MVBADSYMBOL, NULL, pMemvarSymb->szName, NULL );

   return bSuccess;
}
memvars.c359
VOIDhb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
void hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarGetValue(%p, %p)", pItem, pMemvarSymb));

   if( hb_memvarGet( pItem, pMemvarSymb ) == FAILURE )
   {
      /* Generate an error with retry possibility
       * (user created error handler can create this variable)
       */
      HB_ITEM_PTR pError;

      pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, 1003,
                             NULL, pMemvarSymb->szName, 0, EF_CANRETRY );

      while( hb_errLaunch( pError ) == E_RETRY )
      {
         if( hb_memvarGet( pItem, pMemvarSymb ) == SUCCESS )
            break;
      }

      hb_errRelease( pError );
   }
}
memvars.c391
VOIDhb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
void hb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb )
{
   PHB_DYNS pDyn;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarGetRefer(%p, %p)", pItem, pMemvarSymb));

   pDyn = ( PHB_DYNS ) pMemvarSymb->pDynSym;
   if( pDyn )
   {
      PHB_ITEM pMemvar;

      HB_TRACE(HB_TR_INFO, ("Memvar item (%i)(%s) referenced", hb_dynsymGetMemvar( pDyn ), pMemvarSymb->szName));

      pMemvar = hb_dynsymGetMemvar( pDyn );
      if( pMemvar )
      {
         if( HB_IS_BYREF( pMemvar ) && !HB_IS_ENUM( pMemvar ) )
            hb_itemCopy( pItem, pMemvar );
         else
         {
            /* value is already created */
            pItem->type = HB_IT_BYREF | HB_IT_MEMVAR;
            pItem->item.asMemvar.value = pMemvar;
            hb_xRefInc( pMemvar );
         }
      }
      else
      {
         /* Generate an error with retry possibility
          * (user created error handler can make this variable accessible)
          */
         HB_ITEM_PTR pError;

         pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, 1003,
                                NULL, pMemvarSymb->szName, 0, EF_CANRETRY );

         while( hb_errLaunch( pError ) == E_RETRY )
         {
            pMemvar = hb_dynsymGetMemvar( pDyn );
            if( pMemvar )
            {
               if( HB_IS_BYREF( pMemvar ) && !HB_IS_ENUM( pMemvar ) )
                  hb_itemCopy( pItem, pMemvar );
               else
               {
                  /* value is already created */
                  pItem->type = HB_IT_BYREF | HB_IT_MEMVAR;
                  pItem->item.asMemvar.value = pMemvar;
                  hb_xRefInc( pMemvar );
               }
               break;
            }
         }
         hb_errRelease( pError );
      }
   }
   else
      hb_errInternal( HB_EI_MVBADSYMBOL, NULL, pMemvarSymb->szName, NULL );
}
memvars.c415
PHB_ITEMhb_memvarGetItem( PHB_SYMB pMemvarSymb )
PHB_ITEM hb_memvarGetItem( PHB_SYMB pMemvarSymb )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarGetItem(%p)", pMemvarSymb));

   if( pMemvarSymb->pDynSym )
   {
      PHB_ITEM pMemvar = hb_dynsymGetMemvar( pMemvarSymb->pDynSym );

      if( pMemvar )
      {
         if( HB_IS_BYREF( pMemvar ) )
            return hb_itemUnRef( pMemvar );
         else
            return pMemvar;
      }
   }
   return NULL;
}
memvars.c475
VOIDhb_memvarNewParameter( PHB_SYMB pSymbol, PHB_ITEM pValue )
void hb_memvarNewParameter( PHB_SYMB pSymbol, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarNewParameter(%p, %p)", pSymbol, pValue));

   hb_memvarCreateFromDynSymbol( pSymbol->pDynSym, VS_PRIVATE, pValue );
}
memvars.c494
STATIC HB_DYNS_PTRhb_memvarFindSymbol( char * szArg, ULONG ulLen )
static HB_DYNS_PTR hb_memvarFindSymbol( char * szArg, ULONG ulLen )
{
   HB_DYNS_PTR pDynSym = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarFindSymbol(%p,%lu)", szArg, ulLen));

   if( ulLen && szArg && *szArg )
   {
      char szUprName[ HB_SYMBOL_NAME_LEN + 1 ];
      int iSize = 0;

      do
      {
         char cChar = *szArg++;

         if( cChar >= 'a' && cChar <= 'z' )
         {
            szUprName[ iSize++ ] = cChar - ( 'a' - 'A' );
         }
         else if( cChar == ' ' || cChar == '\t' || cChar == '\n' )
         {
            if( iSize )
               break;
         }
         else if( !cChar )
         {
            break;
         }
         else
         {
            szUprName[ iSize++ ] = cChar;
         }
      }
      while( --ulLen && iSize < HB_SYMBOL_NAME_LEN );

      if( iSize )
      {
         szUprName[ iSize ] = '\0';
         pDynSym = hb_dynsymFind( szUprName );
      }
   }
   return pDynSym;
}
memvars.c503
CHAR *hb_memvarGetStrValuePtr( char * szVarName, ULONG *pulLen )
char * hb_memvarGetStrValuePtr( char * szVarName, ULONG *pulLen )
{
   HB_DYNS_PTR pDynVar;
   char * szValue = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarGetStrValuePtr(%s, %li)", szVarName, pulLen));

   pDynVar = hb_memvarFindSymbol( szVarName, *pulLen );

   if( pDynVar )
   {
      /* there is dynamic symbol with the requested name - check if it is
       * a memvar variable
       */
      PHB_ITEM pMemvar = hb_dynsymGetMemvar( pDynVar );

      if( pMemvar )
      {
         /* variable contains some data
          */
         if( HB_IS_BYREF( pMemvar ) )
            pMemvar = hb_itemUnRef( pMemvar );

         if( HB_IS_STRING( pMemvar ) )
         {
            szValue = pMemvar->item.asString.value;
            *pulLen = pMemvar->item.asString.length;
         }
      }
   }

   return szValue;
}
memvars.c547
VOIDhb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue )
void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue )
{
   PHB_DYNS pDynVar = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromItem(%p, %d, %p)", pMemvar, bScope, pValue));

   /* find dynamic symbol or creeate one */
   if( HB_IS_SYMBOL( pMemvar ) )
      /* pDynVar = hb_dynsymGet( pMemvar->item.asSymbol.value->szName ); */
      pDynVar = pMemvar->item.asSymbol.value->pDynSym;
   else if( HB_IS_STRING( pMemvar ) )
      pDynVar = hb_dynsymGet( pMemvar->item.asString.value );

   if( pDynVar )
      hb_memvarCreateFromDynSymbol( pDynVar, bScope, pValue );
   else
      hb_errRT_BASE( EG_ARG, 3008, NULL, "&", HB_ERR_ARGS_BASEPARAMS );
}
memvars.c581
STATIC VOIDhb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITEM pValue )
static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITEM pValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarCreateFromDynSymbol(%p, %d, %p)", pDynVar, bScope, pValue));

   if( bScope & VS_PUBLIC )
   {
      /* If the variable with the same name exists already
       * then the current value have to be unchanged
       */
      if( ! hb_dynsymGetMemvar( pDynVar ) )
      {
         PHB_ITEM pMemvar = hb_memvarValueNew();

         hb_dynsymSetMemvar( pDynVar, pMemvar );

         if( pValue )
         {
            hb_itemCopy( pMemvar, pValue );
            /* Remove MEMOFLAG if exists (assignment from field). */
            pMemvar->type &= ~HB_IT_MEMOFLAG;
         }
         else
         {
            /* new PUBLIC variable - initialize it to .F.
             */
            pMemvar->type = HB_IT_LOGICAL;

            /* NOTE: PUBLIC variables named CLIPPER and HARBOUR are initialized */
            /*       to .T., this is normal Clipper behaviour. [vszakats] */

            pMemvar->item.asLogical.value =
                        ( strcmp( pDynVar->pSymbol->szName, "HARBOUR" ) == 0 ||
                          strcmp( pDynVar->pSymbol->szName, "CLIPPER" ) == 0 );
         }
      }
   }
   else
   {
      /* Create new PRIVATE var and add it to the PRIVATE variables stack
       */
      hb_memvarAddPrivate( pDynVar, pValue );
   }
}
memvars.c613
STATIC VOIDhb_memvarRelease( HB_ITEM_PTR pMemvar )
static void hb_memvarRelease( HB_ITEM_PTR pMemvar )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarRelease(%p)", pMemvar));

   if( HB_IS_STRING( pMemvar ) )
   {
      PHB_DYNS pDynSymbol = hb_memvarFindSymbol( pMemvar->item.asString.value,
                                                 pMemvar->item.asString.length );

      if( pDynSymbol && hb_dynsymGetMemvar( pDynSymbol ) )
      {
         ULONG ulBase = hb_stackGetPrivateStack()->count;

         /* Find the variable with a requested name that is currently visible
          * Start from the top of the stack.
          */
         while( ulBase > 0 )
         {
            if( pDynSymbol == hb_stackGetPrivateStack()->stack[ --ulBase ].pDynSym )
            {
               /* reset current value to NIL - the overriden variables will be
                * visible after exit from current procedure
                */
               PHB_ITEM pMemvar = hb_dynsymGetMemvar( pDynSymbol );
               if( pMemvar )
                  hb_itemClear( pMemvar );
               return;
            }
         }

         /* No match found for PRIVATEs - it's PUBLIC so let's remove it.
          */
         hb_memvarDetachDynSym( pDynSymbol, NULL );
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 3008, NULL, "RELEASE", HB_ERR_ARGS_BASEPARAMS );
}
memvars.c657
STATIC VOIDhb_memvarReleaseWithMask( const char *szMask, BOOL bInclude )
static void hb_memvarReleaseWithMask( const char *szMask, BOOL bInclude )
{
   ULONG ulBase = hb_stackGetPrivateStack()->count;
   PHB_DYNS pDynVar;
   PHB_ITEM pMemvar;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarReleaseWithMask(%s, %d)", szMask, (int) bInclude));

   while( ulBase > hb_stackGetPrivateStack()->base )
   {
      --ulBase;
      pDynVar = hb_stackGetPrivateStack()->stack[ ulBase ].pDynSym;
      /* reset current value to NIL - the overriden variables will be
       * visible after exit from current procedure
       */
      pMemvar = hb_dynsymGetMemvar( pDynVar );
      if( pMemvar )
      {
         BOOL fMatch = hb_strMatchCaseWildExact( pDynVar->pSymbol->szName, szMask );
         if( bInclude ? fMatch : !fMatch )
            hb_itemClear( pMemvar );
      }
   }
}
memvars.c701
STATIC INThb_memvarScopeGet( PHB_DYNS pDynVar )
static int hb_memvarScopeGet( PHB_DYNS pDynVar )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarScopeGet(%p)", pDynVar));

   if( hb_dynsymGetMemvar( pDynVar ) == 0 )
      return HB_MV_UNKNOWN;
   else
   {
      ULONG ulBase = hb_stackGetPrivateStack()->count;    /* start from the top of the stack */

      while( ulBase )
      {
         if( pDynVar == hb_stackGetPrivateStack()->stack[ --ulBase ].pDynSym )
         {
            if( ulBase >= hb_stackGetPrivateStack()->base )
               return HB_MV_PRIVATE_LOCAL;
            else
               return HB_MV_PRIVATE_GLOBAL;
         }
      }
      return HB_MV_PUBLIC;
   }
}
memvars.c731
INThb_memvarScope( char * szVarName, ULONG ulLength )
int hb_memvarScope( char * szVarName, ULONG ulLength )
{
   PHB_DYNS pDynVar;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarScope(%s, %lu)", szVarName, ulLength));

   pDynVar = hb_memvarFindSymbol( szVarName, ulLength );

   if( pDynVar )
      return hb_memvarScopeGet( pDynVar );
   else
      return HB_MV_NOT_FOUND;
}
memvars.c757
STATIC HB_DYNS_FUNC(hb_memvarClear )
static HB_DYNS_FUNC( hb_memvarClear )
{
   HB_SYMBOL_UNUSED( Cargo );

   if( hb_dynsymGetMemvar( pDynSymbol ) )
      hb_memvarDetachDynSym( pDynSymbol, NULL );

   return TRUE;
}
memvars.c773
VOIDhb_memvarsClear( void )
void hb_memvarsClear( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarsClear()"));

   hb_stackClearMevarsBase();
   hb_stackGetPrivateStack()->base = 0;
   hb_memvarSetPrivatesBase( 0 );
   hb_dynsymEval( hb_memvarClear, NULL );
}
memvars.c785
STATIC HB_DYNS_FUNC(hb_memvarCountPublics )
static HB_DYNS_FUNC( hb_memvarCountPublics )
{
   if( hb_memvarScopeGet( pDynSymbol ) == HB_MV_PUBLIC )
      ( * ( ( int * )Cargo ) )++;

   return TRUE;
}
memvars.c796
STATIC INThb_memvarCount( int iScope )
static int hb_memvarCount( int iScope )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_memvarCount(%d)", iScope));

   if( iScope == HB_MV_PUBLIC )
   {
      int iPublicCnt = 0;

      hb_dynsymProtectEval( hb_memvarCountPublics, ( void * ) &iPublicCnt );
      return iPublicCnt;
   }
   else
      return hb_stackGetPrivateStack()->count;  /* number of PRIVATE variables */
}
memvars.c807
STATIC HB_DYNS_FUNC(hb_memvarFindPublicByPos )
static HB_DYNS_FUNC( hb_memvarFindPublicByPos )
{
   BOOL bCont = TRUE;

   if( hb_memvarScopeGet( pDynSymbol ) == HB_MV_PUBLIC )
   {
      struct mv_PUBLIC_var_info *pStruPub = (struct mv_PUBLIC_var_info *) Cargo;
      if( pStruPub->iPos-- == 0 )
      {
         pStruPub->bFound  = TRUE;
         pStruPub->pDynSym = pDynSymbol;
         bCont = FALSE;
      }
   }

   return bCont;
}
memvars.c824
STATIC HB_ITEM_PTRhb_memvarDebugVariable( int iScope, int iPos, const char ** pszName )
static HB_ITEM_PTR hb_memvarDebugVariable( int iScope, int iPos, const char ** pszName )
{
   PHB_ITEM pValue = NULL;
   *pszName = NULL;

   HB_TRACE(HB_TR_DEBUG, ("hb_memvarDebugVariable(%d, %d, %p)", iScope, iPos, pszName));

   if( iPos > 0 )
   {
      --iPos;
      if( iScope == HB_MV_PUBLIC )
      {
         struct mv_PUBLIC_var_info struPub;

         struPub.iPos   = iPos;
         struPub.bFound = FALSE;
         /* enumerate existing dynamic symbols and fill this structure
          * with info for requested PUBLIC variable
          */
         hb_dynsymProtectEval( hb_memvarFindPublicByPos, ( void * ) &struPub );
         if( struPub.bFound )
         {
            pValue = hb_dynsymGetMemvar( struPub.pDynSym );
            *pszName = struPub.pDynSym->pSymbol->szName;
         }
      }
      else
      {
         if( ( ULONG ) iPos < hb_stackGetPrivateStack()->count )
         {
            HB_DYNS_PTR pDynSym = hb_stackGetPrivateStack()->stack[ iPos ].pDynSym;

            pValue = hb_dynsymGetMemvar( pDynSym );
            *pszName = pDynSym->pSymbol->szName;
         }
      }
   }

   return pValue;
}
memvars.c845
STATIC HB_DYNS_FUNC(hb_memvarCountVisible )
static HB_DYNS_FUNC( hb_memvarCountVisible )
{
   PHB_ITEM pMemvar = hb_dynsymGetMemvar( pDynSymbol );

   if( pMemvar )
   {
      struct mv_memvarArray_info *pMVInfo = ( struct mv_memvarArray_info * ) Cargo;
      if( !pMVInfo->iScope ||
          ( hb_memvarScopeGet( pDynSymbol ) & pMVInfo->iScope ) != 0 )
      {
         ++pMVInfo->ulCount;
      }
   }
   return TRUE;
}
memvars.c891
STATIC HB_DYNS_FUNC(hb_memvarStoreInArray )
static HB_DYNS_FUNC( hb_memvarStoreInArray )
{
   PHB_ITEM pMemvar = hb_dynsymGetMemvar( pDynSymbol );

   if( pMemvar )
   {
      struct mv_memvarArray_info *pMVInfo = ( struct mv_memvarArray_info * ) Cargo;
      if( !pMVInfo->iScope ||
          ( hb_memvarScopeGet( pDynSymbol ) & pMVInfo->iScope ) != 0 )
      {
         PHB_ITEM pItem = hb_arrayGetItemPtr( pMVInfo->pArray, ++pMVInfo->ulPos );
         hb_arrayNew( pItem, 2 );
         hb_arraySetSymbol( pItem, 1, pDynSymbol->pSymbol );
         pItem = hb_arrayGetItemPtr( pItem, 2 );
         if( pMVInfo->fCopy )
         {
            hb_itemCopy( pItem, pMemvar );
            hb_memvarDetachLocal( pItem );
         }
         else
         {
            pItem->type = HB_IT_BYREF | HB_IT_MEMVAR;
            pItem->item.asMemvar.value = pMemvar;
            hb_xRefInc( pMemvar );
         }
         /* stop execution if all symbols are saved */
         if( pMVInfo->ulPos >= pMVInfo->ulCount )
            return FALSE;
      }
   }
   return TRUE;
}
memvars.c907
PHB_ITEMhb_memvarSaveInArray( int iScope, BOOL fCopy )
PHB_ITEM hb_memvarSaveInArray( int iScope, BOOL fCopy )
{
   struct mv_memvarArray_info MVInfo;

   iScope &= HB_MV_PUBLIC | HB_MV_PRIVATE;
   if( iScope == ( HB_MV_PUBLIC | HB_MV_PRIVATE ) )
      iScope = 0;

   MVInfo.pArray = NULL;
   MVInfo.ulPos = MVInfo.ulCount = 0;
   MVInfo.iScope = iScope;
   MVInfo.fCopy = fCopy;

   hb_dynsymProtectEval( hb_memvarCountVisible, ( void * ) &MVInfo );
   if( MVInfo.ulCount > 0 )
   {
      MVInfo.pArray = hb_itemArrayNew( MVInfo.ulCount );
      hb_dynsymEval( hb_memvarStoreInArray, ( void * ) &MVInfo );
   }
   return MVInfo.pArray;
}
memvars.c940
VOIDhb_memvarRestoreFromArray( PHB_ITEM pArray )
void hb_memvarRestoreFromArray( PHB_ITEM pArray )
{
   ULONG ulCount, ulPos;

   ulCount = hb_arrayLen( pArray );
   for( ulPos = 1; ulPos <= ulCount; ++ulPos )
   {
      PHB_ITEM pItem = hb_arrayGetItemPtr( pArray, ulPos );
      PHB_DYNS pDynSym = hb_arrayGetSymbol( pItem, 1 )->pDynSym;
      PHB_ITEM pMemvar = hb_arrayGetItemPtr( pItem, 2 )->item.asMemvar.value;
      hb_memvarValueIncRef( pMemvar );
      if( hb_dynsymGetMemvar( pDynSym ) )
         hb_memvarDetachDynSym( pDynSym, pMemvar );
      else
         hb_dynsymSetMemvar( pDynSym, pMemvar );
   }
}
memvars.c962
STATIC CONST CHAR *hb_memvarGetMask( int iParam )
static const char * hb_memvarGetMask( int iParam )
{
   const char * pszMask = hb_parc( iParam );
   if( !pszMask || pszMask[ 0 ] == '*' )
      pszMask = "*";
   return pszMask;
}
memvars.c982
HB_FUNC__MVPUBLIC(void)
HB_FUNC( __MVPUBLIC )
{
   int iCount = hb_pcount();

   if( iCount )
   {
      int i;

      for( i = 1; i <= iCount; i++ )
      {
         PHB_ITEM pMemvar = hb_param( i, HB_IT_ANY );

         if( pMemvar )
         {
            if( HB_IS_ARRAY( pMemvar ) )
            {
               /* we are accepting an one-dimensional array of strings only
                */
               ULONG j, ulLen = hb_arrayLen( pMemvar );

               for( j = 1; j <= ulLen; j++ )
               {
                  hb_memvarCreateFromItem( hb_arrayGetItemPtr( pMemvar, j ), VS_PUBLIC, NULL );
               }
            }
            else
               hb_memvarCreateFromItem( pMemvar, VS_PUBLIC, NULL );
         }
      }
   }
}
memvars.c990
HB_FUNC__MVPRIVATE(void)
HB_FUNC( __MVPRIVATE )
{
   int iCount = hb_pcount();

   if( iCount )
   {
      int i;

      for( i = 1; i <= iCount; i++ )
      {
         PHB_ITEM pMemvar = hb_param( i, HB_IT_ANY );

         if( pMemvar )
         {
            if( HB_IS_ARRAY( pMemvar ) )
            {
               /* we are accepting an one-dimensional array of strings only
                */
               ULONG j, ulLen = hb_arrayLen( pMemvar );

               for( j = 1; j <= ulLen; j++ )
               {
                  hb_memvarCreateFromItem( hb_arrayGetItemPtr( pMemvar, j ), VS_PRIVATE, NULL );
               }
            }
            else
               hb_memvarCreateFromItem( pMemvar, VS_PRIVATE, NULL );
         }
      }
      hb_memvarUpdatePrivatesBase();
   }
}
memvars.c1022
HB_FUNC__MVXRELEASE(void)
HB_FUNC( __MVXRELEASE )
{
   int iCount = hb_pcount();

   if( iCount )
   {
      int i;

      for( i = 1; i <= iCount; i++ )
      {
         PHB_ITEM pMemvar = hb_param( i, HB_IT_ANY );

         if( pMemvar )
         {
            if( HB_IS_ARRAY( pMemvar ) )
            {
               /* we are accepting an one-dimensional array of strings only
                */
               ULONG j, ulLen = hb_arrayLen( pMemvar );

               for( j = 1; j <= ulLen; j++ )
               {
                  hb_memvarRelease( hb_arrayGetItemPtr( pMemvar, j ) );
               }
            }
            else
               hb_memvarRelease( pMemvar );
         }
      }
   }
}
memvars.c1055
HB_FUNC__MVRELEASE(void)
HB_FUNC( __MVRELEASE )
{
   int iCount = hb_pcount();

   if( iCount && ISCHAR( 1 ) )
   {
      BOOL bIncludeVar;
      const char * pszMask;

      pszMask = hb_memvarGetMask( 1 );
      bIncludeVar = ( pszMask[ 0 ] == '*' && !pszMask[ 1 ] ) ||
                    iCount < 2 || hb_parl( 2 );
      hb_memvarReleaseWithMask( pszMask, bIncludeVar );
   }
}
memvars.c1087
HB_FUNC__MVSCOPE(void)
HB_FUNC( __MVSCOPE )
{
   int iMemvar = HB_MV_ERROR;

   if( hb_pcount() )
   {
      PHB_ITEM pVarName = hb_param( 1, HB_IT_STRING );

      if( pVarName )
         iMemvar = hb_memvarScope( pVarName->item.asString.value,
                                   pVarName->item.asString.length );
   }

   hb_retni( iMemvar );
}
memvars.c1103
HB_FUNC__MVCLEAR(void)
HB_FUNC( __MVCLEAR )
{
   hb_memvarsClear();
}
memvars.c1119
HB_FUNC__MVDBGINFO(void)
HB_FUNC( __MVDBGINFO )
{
   int iCount = hb_pcount();

   if( iCount == 1 )          /* request for a number of variables */
      hb_retni( hb_memvarCount( hb_parni( 1 ) ) );

   else if( iCount >= 2 )     /* request for a value of variable */
   {
      HB_ITEM_PTR pValue;
      const char * szName;

      pValue = hb_memvarDebugVariable( hb_parni( 1 ), hb_parni( 2 ), &szName );

      if( pValue )
      {
         /*the requested variable was found
          */
         if( iCount >= 3 && ISBYREF( 3 ) )
         {
            /* we have to use this variable regardless of its current value
             */
            HB_ITEM_PTR pName = hb_param( 3, HB_IT_ANY );

            hb_itemPutC( pName, szName ); /* clear an old value and copy a new one */
            /* szName points directly to a symbol name - it cannot be released
             */
         }
         hb_itemReturn( pValue );
         /* pValue points directly to the item structure used by this variable
          * this item cannot be released
          */
      }
      else
      {
         hb_ret(); /* return NIL value */

         if( iCount >= 3 && ISBYREF( 3 ) )
         {
            /* we have to use this variable regardless of its current value
             */
            HB_ITEM_PTR pName = hb_param( 3, HB_IT_ANY );

            hb_itemPutC( pName, "?" ); /* clear an old value and copy a new one */
         }
      }
   }
}
memvars.c1124
HB_FUNC__MVEXIST(void)
HB_FUNC( __MVEXIST )
{
   PHB_DYNS pDyn;
   pDyn = hb_memvarFindSymbol( hb_parc( 1 ), hb_parclen( 1 ) );
   hb_retl( pDyn && hb_dynsymGetMemvar( pDyn ) );
}
memvars.c1173
HB_FUNC__MVGET(void)
HB_FUNC( __MVGET )
{
   HB_ITEM_PTR pName = hb_param( 1, HB_IT_STRING );

   if( pName )
   {
      HB_DYNS_PTR pDynVar = hb_memvarFindSymbol( pName->item.asString.value,
                                                 pName->item.asString.length );

      if( pDynVar )
      {
         PHB_ITEM pValue = hb_stackAllocItem();

         hb_memvarGetValue( pValue, pDynVar->pSymbol );
         hb_itemReturnForward( pValue );
         hb_stackDec();
      }
      else
      {
         /* Generate an error with retry possibility
          * (user created error handler can create this variable)
          */
         HB_ITEM_PTR pError;

         pError = hb_errRT_New( ES_ERROR, NULL, EG_NOVAR, 1003,
                                 NULL, pName->item.asString.value, 0, EF_CANRETRY );

         while( hb_errLaunch( pError ) == E_RETRY )
         {
            pDynVar = hb_memvarFindSymbol( hb_itemGetCPtr( pName ),
                                           hb_itemGetCLen( pName ) );
            if( pDynVar )
            {
               PHB_ITEM pValue = hb_stackAllocItem();

               hb_memvarGetValue( pValue, pDynVar->pSymbol );
               hb_itemReturnForward( pValue );
               hb_stackDec();
               break;
            }
         }
         hb_errRelease( pError );
      }
   }
   else
   {
      /* either the first parameter is not specified or it has a wrong type
       * (it must be a string)
       * This is not a critical error - we can continue normal processing
       */
      hb_errRT_BASE_SubstR( EG_ARG, 3009, NULL, NULL, HB_ERR_ARGS_BASEPARAMS );
   }
}
memvars.c1180
HB_FUNC__MVPUT(void)
HB_FUNC( __MVPUT )
{
   HB_ITEM_PTR pName = hb_param( 1, HB_IT_STRING );
   HB_ITEM_PTR pValue = hb_paramError( 2 );

   if( pName )
   {
      /* the first parameter is a string with not empty variable name
       */
      HB_DYNS_PTR pDynVar = hb_memvarFindSymbol( pName->item.asString.value,
                                                 pName->item.asString.length );
      if( pDynVar )
      {
         /* variable was declared somwhere - assign a new value
          */
         hb_memvarSetValue( pDynVar->pSymbol, pValue );
      }
      else
      {
         /* attempt to assign a value to undeclared variable
          * create the PRIVATE one
          */
         hb_memvarCreateFromDynSymbol( hb_dynsymGet( pName->item.asString.value ), VS_PRIVATE, pValue );
      }
      hb_memvarUpdatePrivatesBase();
      hb_itemReturn( pValue );
   }
   else
   {
      /* either the first parameter is not specified or it has a wrong type
       * (it must be a string)
       * This is not a critical error - we can continue normal processing
       */
      HB_ITEM_PTR pRetValue = hb_errRT_BASE_Subst( EG_ARG, 3010, NULL, NULL, HB_ERR_ARGS_BASEPARAMS );

      if( pRetValue )
         hb_itemRelease( pRetValue );
      hb_itemReturn( pValue );
   }
}

#define HB_MEM_REC_LEN          32
#define HB_MEM_NUM_LEN          8

typedef struct
{
   const char * pszMask;
   BOOL bIncludeMask;
   BYTE * buffer;
   HB_FHANDLE fhnd;
} MEMVARSAVE_CARGO;
memvars.c1234
STATIC HB_DYNS_FUNC(hb_memvarSave )
static HB_DYNS_FUNC( hb_memvarSave )
{
   const char * pszMask    = ( ( MEMVARSAVE_CARGO * ) Cargo )->pszMask;
   BOOL bIncludeMask = ( ( MEMVARSAVE_CARGO * ) Cargo )->bIncludeMask;
   BYTE * buffer     = ( ( MEMVARSAVE_CARGO * ) Cargo )->buffer;
   HB_FHANDLE fhnd   = ( ( MEMVARSAVE_CARGO * ) Cargo )->fhnd;
   PHB_ITEM pMemvar;

   /* NOTE: Harbour name lengths are not limited, but the .mem file
            structure is not flexible enough to allow for it.
            [vszakats] */

   pMemvar = hb_dynsymGetMemvar( pDynSymbol );
   if( pMemvar )
   {
      BOOL bMatch = hb_strMatchCaseWildExact( pDynSymbol->pSymbol->szName, pszMask );

      /* Process it if it matches the passed mask */
      if( bIncludeMask ? bMatch : ! bMatch )
      {
         /* NOTE: Clipper will not initialize the record buffer with
                  zeros, so they will look trashed. [vszakats] */
         memset( buffer, 0, HB_MEM_REC_LEN );

         /* NOTE: Save only the first 10 characters of the name */
         hb_strncpy( ( char * ) buffer, pDynSymbol->pSymbol->szName, 10 );

         if( HB_IS_STRING( pMemvar ) && ( hb_itemGetCLen( pMemvar ) + 1 ) <= SHRT_MAX )
         {
            /* Store the closing zero byte, too */
            USHORT uiLength = ( USHORT ) ( hb_itemGetCLen( pMemvar ) + 1 );

            buffer[ 11 ] = 'C' + 128;
            buffer[ 16 ] = HB_LOBYTE( uiLength );
            buffer[ 17 ] = HB_HIBYTE( uiLength );

            hb_fsWrite( fhnd, buffer, HB_MEM_REC_LEN );
            hb_fsWrite( fhnd, ( BYTE * ) hb_itemGetCPtr( pMemvar ), uiLength );
         }
         else if( HB_IS_NUMERIC( pMemvar ) )
         {
            BYTE byNum[ sizeof( double ) ];
            int iWidth;
            int iDec;

            hb_itemGetNLen( pMemvar, &iWidth, &iDec );

            buffer[ 11 ] = 'N' + 128;
#ifdef HB_C52_STRICT
/* NOTE: This is the buggy, but fully CA-Cl*pper compatible method. [vszakats] */
            buffer[ 16 ] = ( BYTE ) iWidth + ( HB_IS_DOUBLE( pMemvar ) ? ( BYTE ) ( iDec + 1 ) : 0 );
#else
/* NOTE: This would be the correct method, but Clipper is buggy here. [vszakats] */
            buffer[ 16 ] = ( BYTE ) iWidth + ( iDec == 0 ? 0 : ( BYTE ) ( iDec + 1 ) );
#endif
            buffer[ 17 ] = ( BYTE ) iDec;

            HB_PUT_LE_DOUBLE( byNum, hb_itemGetND( pMemvar ) );

            hb_fsWrite( fhnd, buffer, HB_MEM_REC_LEN );
            hb_fsWrite( fhnd, byNum, sizeof( byNum ) );
         }
         else if( HB_IS_DATE( pMemvar ) )
         {
            BYTE byNum[ sizeof( double ) ];
            double dNumber = ( double ) hb_itemGetDL( pMemvar );

            buffer[ 11 ] = 'D' + 128;
            buffer[ 16 ] = 1;
            buffer[ 17 ] = 0;

            HB_PUT_LE_DOUBLE( byNum, dNumber );

            hb_fsWrite( fhnd, buffer, HB_MEM_REC_LEN );
            hb_fsWrite( fhnd, byNum, sizeof( byNum ) );
         }
         else if( HB_IS_LOGICAL( pMemvar ) )
         {
            BYTE byLogical[ 1 ];

            buffer[ 11 ] = 'L' + 128;
            buffer[ 16 ] = sizeof( BYTE );
            buffer[ 17 ] = 0;

            byLogical[ 0 ] = hb_itemGetL( pMemvar ) ? 1 : 0;

            hb_fsWrite( fhnd, buffer, HB_MEM_REC_LEN );
            hb_fsWrite( fhnd, byLogical, sizeof( BYTE ) );
         }
      }
   }
   return TRUE;
}
memvars.c1288
HB_FUNC__MVSAVE(void)
HB_FUNC( __MVSAVE )
{
   /* Clipper also checks for the number of arguments here */
   if( hb_pcount() == 3 && ISCHAR( 1 ) && ISCHAR( 2 ) && ISLOG( 3 ) )
   {
      PHB_FNAME pFileName;
      char szFileName[ _POSIX_PATH_MAX + 1 ];
      HB_FHANDLE fhnd;

      /* Generate filename */

      pFileName = hb_fsFNameSplit( hb_parc( 1 ) );

      if( pFileName->szExtension == NULL && hb_stackSetStruct()->HB_SET_DEFEXTENSIONS )
         pFileName->szExtension = ".mem";

      if( ! pFileName->szPath )
         pFileName->szPath = hb_stackSetStruct()->HB_SET_DEFAULT;

      hb_fsFNameMerge( szFileName, pFileName );
      hb_xfree( pFileName );

      /* Create .mem file */

      do
      {
         fhnd = hb_fsCreate( ( BYTE * ) szFileName, FC_NORMAL );
      }
#ifdef HB_C52_STRICT
      while( fhnd == FS_ERROR &&
             hb_errRT_BASE_Ext1( EG_CREATE, 2006, NULL, szFileName,
                                 hb_fsError(), EF_CANDEFAULT | EF_CANRETRY,
                                 0 ) == E_RETRY );
#else
      while( fhnd == FS_ERROR &&
             hb_errRT_BASE_Ext1( EG_CREATE, 2006, NULL, szFileName,
                                 hb_fsError(), EF_CANDEFAULT | EF_CANRETRY,
                                 HB_ERR_ARGS_BASEPARAMS ) == E_RETRY );
#endif

      if( fhnd != FS_ERROR )
      {
         BYTE buffer[ HB_MEM_REC_LEN ];
         MEMVARSAVE_CARGO msc;

         msc.pszMask      = hb_memvarGetMask( 2 );
         msc.bIncludeMask = hb_parl( 3 );
         msc.buffer       = buffer;
         msc.fhnd         = fhnd;

         /* Walk through all visible memory variables and save each one */

         hb_dynsymEval( hb_memvarSave, ( void * ) &msc );

         buffer[ 0 ] = '\x1A';
         hb_fsWrite( fhnd, buffer, 1 );

         hb_fsClose( fhnd );
      }
   }
   else
      /* NOTE: Undocumented error message in CA-Cl*pper 5.2e and 5.3x. [ckedem] */
      hb_errRT_BASE( EG_ARG, 2008, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
memvars.c1382
HB_FUNC__MVRESTORE(void)
HB_FUNC( __MVRESTORE )
{
   /* Clipper checks for the number of arguments here here, but we cannot
      in Harbour since we have two optional parameters as an extension. */
#ifdef HB_C52_STRICT
   if( hb_pcount() == 2 && ISCHAR( 1 ) && ISLOG( 2 ) )
#else
   if( ISCHAR( 1 ) && ISLOG( 2 ) )
#endif
   {
      PHB_FNAME pFileName;
      char szFileName[ _POSIX_PATH_MAX + 1 ];
      HB_FHANDLE fhnd;

      BOOL bAdditive = hb_parl( 2 );

      /* Clear all memory variables if not ADDITIVE */

      if( ! bAdditive )
         hb_memvarsClear();

      /* Generate filename */

      pFileName = hb_fsFNameSplit( hb_parc( 1 ) );

      if( pFileName->szExtension == NULL && hb_stackSetStruct()->HB_SET_DEFEXTENSIONS )
         pFileName->szExtension = ".mem";

      if( ! pFileName->szPath )
         pFileName->szPath = hb_stackSetStruct()->HB_SET_DEFAULT;

      hb_fsFNameMerge( szFileName, pFileName );
      hb_xfree( pFileName );

      /* Open .mem file */

      do
      {
         fhnd = hb_fsOpen( ( BYTE * ) szFileName, FO_READ | FO_DENYWRITE | FO_PRIVATE );
      }
#ifdef HB_C52_STRICT
      while( fhnd == FS_ERROR &&
             hb_errRT_BASE_Ext1( EG_OPEN, 2005, NULL, szFileName,
                                 hb_fsError(), EF_CANDEFAULT | EF_CANRETRY,
                                 0 ) == E_RETRY );
#else
      while( fhnd == FS_ERROR &&
             hb_errRT_BASE_Ext1( EG_OPEN, 2005, NULL, szFileName,
                                 hb_fsError(), EF_CANDEFAULT | EF_CANRETRY,
                                 HB_ERR_ARGS_BASEPARAMS ) == E_RETRY );
#endif

      if( fhnd != FS_ERROR )
      {
         BOOL bIncludeMask;
         BYTE buffer[ HB_MEM_REC_LEN ];
         const char * pszMask;

#ifdef HB_C52_STRICT
         pszMask = "*";
         bIncludeMask = TRUE;
#else
         pszMask = hb_memvarGetMask( 3 );
         bIncludeMask = !ISLOG( 4 ) || hb_parl( 4 );
#endif

         while( hb_fsRead( fhnd, buffer, HB_MEM_REC_LEN ) == HB_MEM_REC_LEN )
         {
            char *szName = hb_strdup( ( char * ) buffer );
            USHORT uiType = ( USHORT ) ( buffer[ 11 ] - 128 );
            USHORT uiWidth = ( USHORT ) buffer[ 16 ];
            USHORT uiDec = ( USHORT ) buffer[ 17 ];
            PHB_ITEM pItem = NULL;

            switch( uiType )
            {
               case 'C':
               {
                  BYTE * pbyString;

                  uiWidth += uiDec * 256;
                  pbyString = ( BYTE * ) hb_xgrab( uiWidth );

                  if( hb_fsRead( fhnd, pbyString, uiWidth ) == uiWidth )
                     pItem = hb_itemPutCL( NULL, ( char * ) pbyString, uiWidth - 1 );

                  hb_xfree( pbyString );

                  break;
               }

               case 'N':
               {
                  BYTE pbyNumber[ HB_MEM_NUM_LEN ];

                  if( hb_fsRead( fhnd, pbyNumber, HB_MEM_NUM_LEN ) == HB_MEM_NUM_LEN )
                     pItem = hb_itemPutNLen( NULL, HB_GET_LE_DOUBLE( pbyNumber ), uiWidth - ( uiDec ? ( uiDec + 1 ) : 0 ), uiDec );

                  break;
               }

               case 'D':
               {
                  BYTE pbyNumber[ HB_MEM_NUM_LEN ];

                  if( hb_fsRead( fhnd, pbyNumber, HB_MEM_NUM_LEN ) == HB_MEM_NUM_LEN )
                     pItem = hb_itemPutDL( NULL, ( long ) HB_GET_LE_DOUBLE( pbyNumber ) );

                  break;
               }

               case 'L':
               {
                  BYTE pbyLogical[ 1 ];

                  if( hb_fsRead( fhnd, pbyLogical, 1 ) == 1 )
                     pItem = hb_itemPutL( NULL, pbyLogical[ 0 ] != 0 );

                  break;
               }
            }

            if( pItem )
            {
               BOOL bMatch = hb_strMatchCaseWildExact( szName, pszMask );

               /* Process it if it matches the passed mask */
               if( bIncludeMask ? bMatch : ! bMatch )
               {
                  /* the first parameter is a string with not empty variable name */
                  HB_DYNS_PTR pDynVar = hb_memvarFindSymbol( szName, strlen( szName ) );

                  if( pDynVar )
                     /* variable was declared somwhere - assign a new value */
                     hb_memvarSetValue( pDynVar->pSymbol, pItem );
                  else
                     /* attempt to assign a value to undeclared variable create the PRIVATE one */
                     hb_memvarCreateFromDynSymbol( hb_dynsymGet( szName ), VS_PRIVATE, pItem );

                  hb_itemReturn( pItem );
               }

               hb_itemRelease( pItem );
            }

            hb_xfree( szName );
         }

         hb_fsClose( fhnd );
         hb_memvarUpdatePrivatesBase();
      }
      else
         hb_retl( FALSE );
   }
   else
      /* NOTE: Undocumented error message in CA-Cl*pper 5.2e and 5.3x. [ckedem] */
      hb_errRT_BASE( EG_ARG, 2007, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
memvars.c1451
HB_FUNC__MVSETBASE(void)
HB_FUNC( __MVSETBASE )
{
   long lOffset = hb_stackBaseProcOffset( 0 );

   if( lOffset > 0 )
      hb_stackItem( lOffset )->item.asSymbol.stackstate->ulPrivateBase =
                                                hb_memvarGetPrivatesBase();
}
memvars.c1610
PHB_ITEMhb_memvarGetValueBySym( PHB_DYNS pDynSym )
PHB_ITEM hb_memvarGetValueBySym( PHB_DYNS pDynSym )
{
   return hb_dynsymGetMemvar( pDynSym );
}
memvars.c1625
memvclip.c
TypeFunctionSourceLine
HB_FUNC__QQPUB(void)
HB_FUNC( __QQPUB )
{
   /* In Clipper __QQPUB function does not check number of parameters
      or parameter type - just simply takes directly the top item from
      VM stack */
   if( hb_pcount() == 1 && hb_param( 1, HB_IT_STRING ) )
   {
      HB_FUNC_EXEC( __MVPUBLIC );
   }
}
memvclip.c66
HB_FUNC__MCLEAR(void)
HB_FUNC( __MCLEAR )
{
   HB_FUNC_EXEC( __MVCLEAR );
}
memvclip.c81
HB_FUNC__MRELEASE(void)
HB_FUNC( __MRELEASE )
{
   HB_FUNC_EXEC( __MVRELEASE );
}
memvclip.c86
HB_FUNC__MXRELEASE(void)
HB_FUNC( __MXRELEASE )
{
   HB_FUNC_EXEC( __MVXRELEASE );
}
memvclip.c91
HB_FUNC__MSAVE(void)
HB_FUNC( __MSAVE )
{
   HB_FUNC_EXEC( __MVSAVE );
}
memvclip.c96
HB_FUNC__MRESTORE(void)
HB_FUNC( __MRESTORE )
{
   HB_FUNC_EXEC( __MVRESTORE );
}
memvclip.c101
pcount.c
TypeFunctionSourceLine
HB_FUNCPCOUNT(void)
HB_FUNC( PCOUNT )
{
   /* Skip current function */
   hb_retni( ( hb_stackItem( hb_stackBaseItem()->item.asSymbol.stackstate->lBaseItem ) )->item.asSymbol.paramcnt );
}
pcount.c58
proc.c
TypeFunctionSourceLine
HB_FUNCHB_METHODNAME(void)
HB_FUNC( HB_METHODNAME )
{
   char szName[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ];

   hb_retc( hb_procname( hb_parni( 1 ) + 1, szName, TRUE ) );
}
proc.c76
HB_FUNCPROCNAME(void)
HB_FUNC( PROCNAME )
{
   char szName[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ];

   hb_retc( hb_procname( hb_parni( 1 ) + 1, szName, FALSE ) );
}
proc.c83
HB_FUNCPROCLINE(void)
HB_FUNC( PROCLINE )
{
   long lOffset = hb_stackBaseProcOffset( hb_parni( 1 ) + 1 );

   if( lOffset > 0 )
      hb_retni( hb_stackItem( lOffset )->item.asSymbol.stackstate->uiLineNo );
   else
      hb_retni( 0 );
}
proc.c90
HB_FUNCPROCFILE(void)
HB_FUNC( PROCFILE )
{
#ifndef HB_C52_STRICT
   PHB_SYMB pSym = NULL;

   if( ISSYMBOL( 1 ) )
   {
      pSym = hb_itemGetSymbol( hb_param( 1, HB_IT_SYMBOL ) );
   }
   else if( ISCHAR( 1 ) )
   {
      PHB_DYNS pDynSym = hb_dynsymFindName( hb_parc( 1 ) );

      if( pDynSym )
         pSym = pDynSym->pSymbol;
   }
   else
   {
      long lOffset = hb_stackBaseProcOffset( hb_parni( 1 ) + 1 );

      if( lOffset > 0 )
      {
         pSym = hb_stackItem( lOffset )->item.asSymbol.value;

         if( pSym == &hb_symEval || pSym->pDynSym == hb_symEval.pDynSym )
         {
            PHB_ITEM pSelf = hb_stackItem( lOffset + 1 );

            if( HB_IS_BLOCK( pSelf ) )
               pSym = pSelf->item.asBlock.value->pDefSymb;
         }
      }
   }

   hb_retc( hb_vmFindModuleSymbolName( hb_vmGetRealFuncSym( pSym ) ) );
#else
   hb_retc( NULL );
#endif
}
proc.c105
CHAR *hb_procname( int iLevel, char * szName, BOOL fMethodName )
char * hb_procname( int iLevel, char * szName, BOOL fMethodName )
{
   long lOffset = hb_stackBaseProcOffset( iLevel );

   szName[ 0 ] = '\0';
   if( lOffset > 0 )
   {
      PHB_ITEM pBase, pSelf;

      pBase = hb_stackItem( lOffset );
      pSelf = hb_stackItem( lOffset + 1 );

      if( fMethodName && lOffset > 0 &&
          pBase->item.asSymbol.value == &hb_symEval &&
          pBase->item.asSymbol.stackstate->uiClass )
      {
         long lPrevOffset = hb_stackItem( lOffset )->item.asSymbol.stackstate->lBaseItem;

         if( hb_stackItem( lPrevOffset )->item.asSymbol.stackstate->uiClass ==
             pBase->item.asSymbol.stackstate->uiClass &&
             hb_stackItem( lPrevOffset )->item.asSymbol.stackstate->uiMethod ==
             pBase->item.asSymbol.stackstate->uiMethod )
         {
            pBase = hb_stackItem( lPrevOffset );
            pSelf = hb_stackItem( lPrevOffset + 1 );
         }
      }

      if( pBase->item.asSymbol.value == &hb_symEval ||
          pBase->item.asSymbol.value->pDynSym == hb_symEval.pDynSym )
      {
         hb_strncat( szName, "(b)", HB_PROCBUF_LEN );

         if( HB_IS_BLOCK( pSelf ) )
            hb_strncat( szName, pSelf->item.asBlock.value->pDefSymb->szName,
                        HB_PROCBUF_LEN );
         else
            hb_strncat( szName, pBase->item.asSymbol.value->szName, HB_PROCBUF_LEN );
      }
      else
      {
         /* it is a method name? */
         if( pBase->item.asSymbol.stackstate->uiClass )
         {
            hb_strncat( szName, hb_clsName( pBase->item.asSymbol.stackstate->uiClass ),
                        HB_PROCBUF_LEN );
            hb_strncat( szName, ":", HB_PROCBUF_LEN );
         }
         hb_strncat( szName, pBase->item.asSymbol.value->szName, HB_PROCBUF_LEN );
      }
   }

   return szName;
}
proc.c150
BOOLhb_procinfo( int iLevel, char * szName, USHORT * puiLine, char * szFile )
BOOL hb_procinfo( int iLevel, char * szName, USHORT * puiLine, char * szFile )
{
   long lOffset = hb_stackBaseProcOffset( iLevel );

   if( lOffset > 0 )
   {
      PHB_ITEM pBase, pSelf;
      PHB_SYMB pSym;

      pBase = hb_stackItem( lOffset );
      pSelf = hb_stackItem( lOffset + 1 );

      pSym = pBase->item.asSymbol.value;

      if( szName )
      {
         szName[ 0 ] = '\0';
         if( pSym == &hb_symEval || pSym->pDynSym == hb_symEval.pDynSym )
         {
            hb_strncat( szName, "(b)", HB_PROCBUF_LEN );

            if( HB_IS_BLOCK( pSelf ) )
               hb_strncat( szName, pSelf->item.asBlock.value->pDefSymb->szName,
                           HB_PROCBUF_LEN );
            else
               hb_strncat( szName, pSym->szName, HB_PROCBUF_LEN );
         }
         else
         {
            if( pBase->item.asSymbol.stackstate->uiClass ) /* it is a method name */
            {
               hb_strncat( szName, hb_clsName( pBase->item.asSymbol.stackstate->uiClass ),
                           HB_PROCBUF_LEN );
               hb_strncat( szName, ":", HB_PROCBUF_LEN );
            }
            hb_strncat( szName, pSym->szName, HB_PROCBUF_LEN );
         }
      }

      if( puiLine )
         * puiLine = pBase->item.asSymbol.stackstate->uiLineNo;

      if( szFile )
      {
         char * szModule;

         if( HB_IS_BLOCK( pSelf ) &&
             ( pSym == &hb_symEval || pSym->pDynSym == hb_symEval.pDynSym ) )
            pSym = pSelf->item.asBlock.value->pDefSymb;

         szModule = hb_vmFindModuleSymbolName( hb_vmGetRealFuncSym( pSym ) );

         if( szModule )
            hb_strncpy( szFile, szModule, _POSIX_PATH_MAX );
         else
            szFile[ 0 ] = '\0';
      }

      return TRUE;
   }

   if( szName )
      szName[ 0 ] = '\0';
   if( puiLine )
      * puiLine = 0;
   if( szFile )
      szFile[ 0 ] = '\0';

   return FALSE;
}
proc.c205
pvalue.c
TypeFunctionSourceLine
HB_FUNCHB_PVALUE(void)
HB_FUNC( HB_PVALUE )
{
   LONG lOffset = hb_stackBaseItem()->item.asSymbol.stackstate->lBaseItem;
   USHORT uiParam = ( USHORT ) hb_parni( 1 );

   if( uiParam && uiParam <= hb_stackItem( lOffset )->item.asSymbol.paramcnt )
   {
      PHB_ITEM pItem = hb_stackItem( lOffset + 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 );
   }
}
pvalue.c58
runner.c
TypeFunctionSourceLine
STATIC INThb_hrbReadHead( char * szBody, ULONG ulBodySize, ULONG * pulBodyOffset )
static int hb_hrbReadHead( char * szBody, ULONG ulBodySize, ULONG * pulBodyOffset )
{
   char * pVersion;

   HB_TRACE(HB_TR_DEBUG, ("hb_hrbReadHead(%p,%lu,%p)", szBody, ulBodySize, pulBodyOffset ));

   if( ulBodySize < 6 || memcmp( szHead, szBody, 4 ) )
      return 0;

   pVersion = szBody + 4;
   *pulBodyOffset += 6;

   return HB_PCODE_MKSHORT( pVersion );
}
runner.c102
STATIC BOOLhb_hrbReadValue( char * szBody, ULONG ulBodySize, ULONG * pulBodyOffset, ULONG * pulValue )
static BOOL hb_hrbReadValue( char * szBody, ULONG ulBodySize, ULONG * pulBodyOffset, ULONG * pulValue )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_hrbReadValue(%p,%lu,%p,%p)", szBody, ulBodySize, pulBodyOffset, pulValue));

   if( *pulBodyOffset + 4 < ulBodySize )
   {
      *pulValue = HB_PCODE_MKLONG( szBody + *pulBodyOffset );
      *pulBodyOffset += 4;

      if( *pulValue <= 0x00FFFFFFUL )
      {
         return TRUE;
      }
   }

   return FALSE;
}
runner.c117
STATIC CHAR *hb_hrbReadId( char * szBody, ULONG ulBodySize, ULONG * ulBodyOffset )
static char * hb_hrbReadId( char * szBody, ULONG ulBodySize, ULONG * ulBodyOffset )
{
   char * szIdx;

   HB_TRACE(HB_TR_DEBUG, ("hb_hrbReadId(%p,%lu,%p)", szBody, ulBodySize, ulBodyOffset));

   szIdx = &szBody[ *ulBodyOffset ];

   do
   {
      if( *ulBodyOffset > ulBodySize )
         return NULL;
   }
   while( szBody[ ( *ulBodyOffset )++ ] );

   return hb_strdup( szIdx );
}
runner.c135
STATIC ULONGhb_hrbFindSymbol( const char * szName, PHB_DYNF pDynFunc, ULONG ulLoaded )
static ULONG hb_hrbFindSymbol( const char * szName, PHB_DYNF pDynFunc, ULONG ulLoaded )
{
   ULONG ulRet;

   HB_TRACE(HB_TR_DEBUG, ("hb_hrbFindSymbol(%s, %p, %lu)", szName, pDynFunc, ulLoaded));

   for( ulRet = 0; ulRet < ulLoaded; ++ulRet )
   {
      if( ! strcmp( szName, pDynFunc[ ulRet ].szName ) )
         return ulRet;
   }

   return SYM_NOT_FOUND;
}
runner.c155
STATIC VOIDhb_hrbFreeSymbols( PHB_SYMB pSymbols, ULONG ulSymbols )
static void hb_hrbFreeSymbols( PHB_SYMB pSymbols, ULONG ulSymbols )
{
   ULONG ul;

   for( ul = 0; ul < ulSymbols; ul++ )
   {
      if( pSymbols[ ul ].szName )
         hb_xfree( ( void * ) pSymbols[ ul ].szName );
   }
   hb_xfree( pSymbols );
}
runner.c170
STATIC VOIDhb_hrbInitStatic( PHRB_BODY pHrbBody )
static void hb_hrbInitStatic( PHRB_BODY pHrbBody )
{
   if( ! pHrbBody->fInit && ! pHrbBody->fExit )
   {
      ULONG ul;

      pHrbBody->fInit = TRUE;
      /* Initialize static variables first */
      for( ul = 0; ul < pHrbBody->ulSymbols; ul++ )    /* Check _INITSTATICS functions */
      {
         if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_INITEXIT )
         {
            /* call (_INITSTATICS) function. This function assigns
             * literal values to static variables only. There is no need
             * to pass any parameters to this function because they
             * cannot be used to initialize static variable.
             */

            /* changed to call VM execution instead of direct function address call
             * pHrbBody->pSymRead[ ul ].value.pFunPtr();
             * [MLombardo]
             */

            hb_vmPushSymbol( &(pHrbBody->pSymRead[ ul ]) );
            hb_vmPushNil();
            hb_vmDo( 0 );

         }
      }
   }
}
runner.c182
STATIC VOIDhb_hrbInit( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams )
static void hb_hrbInit( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams )
{
   if( pHrbBody->fInit )
   {
      if( hb_vmRequestReenter() )
      {
         ULONG ul;
         int i;

         pHrbBody->fInit = FALSE;
         pHrbBody->fExit = TRUE;

         for( ul = 0; ul < pHrbBody->ulSymbols; ul++ )    /* Check INIT functions */
         {
            if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_INIT )
            {
               hb_vmPushSymbol( pHrbBody->pSymRead + ul );
               hb_vmPushNil();
               for( i = 0; i < iPCount; i++ )
                  hb_vmPush( pParams[ i ] );
               hb_vmDo( ( USHORT ) iPCount );
               if( hb_vmRequestQuery() != 0 )
                  break;
            }
         }

         hb_vmRequestRestore();
      }
   }
}
runner.c214
STATIC VOIDhb_hrbExit( PHRB_BODY pHrbBody )
static void hb_hrbExit( PHRB_BODY pHrbBody )
{
   if( pHrbBody->fExit )
   {
      if( hb_vmRequestReenter() )
      {
         ULONG ul;

         pHrbBody->fExit = FALSE;
         pHrbBody->fInit = TRUE;

         for( ul = 0; ul < pHrbBody->ulSymbols; ul++ )
         {
            if( ( pHrbBody->pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == HB_FS_EXIT )
            {
               hb_vmPushSymbol( pHrbBody->pSymRead + ul );
               hb_vmPushNil();
               hb_vmDo( 0 );
               if( hb_vmRequestQuery() != 0 )
                  break;
            }
         }

         hb_vmRequestRestore();
      }
   }
}
runner.c245
STATIC VOIDhb_hrbUnLoad( PHRB_BODY pHrbBody )
static void hb_hrbUnLoad( PHRB_BODY pHrbBody )
{
   ULONG ul;

   hb_hrbExit( pHrbBody );

   if( pHrbBody->pModuleSymbols )
   {
      hb_vmFreeSymbols( pHrbBody->pModuleSymbols );
   }

   if( pHrbBody->pDynFunc )
   {
      for( ul = 0; ul < pHrbBody->ulFuncs; ul++ )
      {
         PHB_DYNS pDyn;

         if( pHrbBody->pDynFunc[ ul ].szName &&
             pHrbBody->pDynFunc[ ul ].pCodeFunc )
         {
            pDyn = hb_dynsymFind( pHrbBody->pDynFunc[ ul ].szName );
            if( pDyn && pDyn->pSymbol->value.pCodeFunc ==
                        pHrbBody->pDynFunc[ ul ].pCodeFunc )
            {
               pDyn->pSymbol->value.pCodeFunc = NULL;
            }
         }
         if( pHrbBody->pDynFunc[ ul ].pCodeFunc )
            hb_xfree( pHrbBody->pDynFunc[ ul ].pCodeFunc );
         if( pHrbBody->pDynFunc[ ul ].pCode )
            hb_xfree( pHrbBody->pDynFunc[ ul ].pCode );
         if( pHrbBody->pDynFunc[ ul ].szName )
            hb_xfree( pHrbBody->pDynFunc[ ul ].szName );
      }

      hb_xfree( pHrbBody->pDynFunc );
   }

   hb_xfree( pHrbBody );
}
runner.c273
STATIC PHRB_BODYhb_hrbLoad( char* szHrbBody, ULONG ulBodySize )
static PHRB_BODY hb_hrbLoad( char* szHrbBody, ULONG ulBodySize )
{
   PHRB_BODY pHrbBody = NULL;

   if( szHrbBody )
   {
      ULONG ulBodyOffset = 0;
      ULONG ulSize;                                /* Size of function */
      ULONG ul, ulPos;

      PHB_SYMB pSymRead;                           /* Symbols read     */
      PHB_DYNF pDynFunc;                           /* Functions read   */
      PHB_DYNS pDynSym;

      int iVersion = hb_hrbReadHead( szHrbBody, ulBodySize, &ulBodyOffset );

      if( iVersion == 0 )
      {
         hb_errRT_BASE( EG_CORRUPTION, 9995, NULL, HB_ERR_FUNCNAME, 0 );
         return NULL;
      }

      pHrbBody = ( PHRB_BODY ) hb_xgrab( sizeof( HRB_BODY ) );

      pHrbBody->fInit = FALSE;
      pHrbBody->fExit = FALSE;
      pHrbBody->lSymStart = -1;
      pHrbBody->ulFuncs = 0;
      pHrbBody->pSymRead = NULL;
      pHrbBody->pDynFunc = NULL;
      pHrbBody->pModuleSymbols = NULL;
      if( ! hb_hrbReadValue( szHrbBody, ulBodySize, &ulBodyOffset, &pHrbBody->ulSymbols ) ||
            pHrbBody->ulSymbols == 0 )
      {
         hb_hrbUnLoad( pHrbBody );
         hb_errRT_BASE( EG_CORRUPTION, 9996, NULL, HB_ERR_FUNCNAME, 0 );
         return NULL;
      }

      pSymRead = ( PHB_SYMB ) hb_xgrab( pHrbBody->ulSymbols * sizeof( HB_SYMB ) );

      for( ul = 0; ul < pHrbBody->ulSymbols; ul++ )  /* Read symbols in .hrb */
      {
         pSymRead[ ul ].szName = hb_hrbReadId( szHrbBody, ulBodySize, &ulBodyOffset );
         if( pSymRead[ ul ].szName == NULL || ulBodyOffset + 2 > ulBodySize )
            break;
         pSymRead[ ul ].scope.value = ( BYTE ) szHrbBody[ ulBodyOffset++ ];
         pSymRead[ ul ].value.pCodeFunc = ( PHB_PCODEFUNC ) ( HB_PTRDIFF ) szHrbBody[ ulBodyOffset++ ];
         pSymRead[ ul ].pDynSym = NULL;

         if( pHrbBody->lSymStart == -1 &&
             ( pSymRead[ ul ].scope.value & HB_FS_FIRST ) != 0 &&
             ( pSymRead[ ul ].scope.value & HB_FS_INITEXIT ) == 0 )
         {
            pHrbBody->lSymStart = ul;
         }
      }

      if( ul < pHrbBody->ulSymbols ||
          /* Read number of functions */
          ! hb_hrbReadValue( szHrbBody, ulBodySize, &ulBodyOffset, &pHrbBody->ulFuncs ) )
      {
         hb_hrbFreeSymbols( pSymRead, ul );
         hb_hrbUnLoad( pHrbBody );
         hb_errRT_BASE( EG_CORRUPTION, 9997, NULL, HB_ERR_FUNCNAME, 0 );
         return NULL;
      }

      pHrbBody->pSymRead = pSymRead;

      if( pHrbBody->ulFuncs )
      {
         pDynFunc = ( PHB_DYNF ) hb_xgrab( pHrbBody->ulFuncs * sizeof( HB_DYNF ) );
         memset( pDynFunc, 0, pHrbBody->ulFuncs * sizeof( HB_DYNF ) );
         pHrbBody->pDynFunc = pDynFunc;

         for( ul = 0; ul < pHrbBody->ulFuncs; ul++ )
         {
            /* Read name of function */
            pDynFunc[ ul ].szName = hb_hrbReadId( szHrbBody, ulBodySize, &ulBodyOffset );
            if( pDynFunc[ ul ].szName == NULL )
               break;

            /* Read size of function */
            if( ! hb_hrbReadValue( szHrbBody, ulBodySize, &ulBodyOffset, &ulSize ) ||
                ulBodyOffset + ulSize > ulBodySize )
               break;

            /* Copy function body */
            pDynFunc[ ul ].pCode = ( BYTE * ) hb_xgrab( ulSize );
            memcpy( ( char * ) pDynFunc[ ul ].pCode, szHrbBody + ulBodyOffset, ulSize );
            ulBodyOffset += ulSize;

            pDynFunc[ ul ].pCodeFunc = (PHB_PCODEFUNC) hb_xgrab( sizeof( HB_PCODEFUNC ) );
            pDynFunc[ ul ].pCodeFunc->pCode    = pDynFunc[ ul ].pCode;
            pDynFunc[ ul ].pCodeFunc->pSymbols = pSymRead;
         }

         if( ul < pHrbBody->ulFuncs )
         {
            hb_hrbFreeSymbols( pSymRead, pHrbBody->ulSymbols );
            hb_hrbUnLoad( pHrbBody );
            hb_errRT_BASE( EG_CORRUPTION, 9998, NULL, HB_ERR_FUNCNAME, 0 );
            return NULL;
         }
      }

      /* End of PCODE loading, now linking */

      for( ul = 0; ul < pHrbBody->ulSymbols; ul++ )
      {
         if( pSymRead[ ul ].value.pCodeFunc == ( PHB_PCODEFUNC ) SYM_FUNC )
         {
            ulPos = hb_hrbFindSymbol( pSymRead[ ul ].szName, pHrbBody->pDynFunc, pHrbBody->ulFuncs );

            if( ulPos == SYM_NOT_FOUND )
            {
               pSymRead[ ul ].value.pCodeFunc = ( PHB_PCODEFUNC ) SYM_EXTERN;
            }
            else
            {
               pSymRead[ ul ].value.pCodeFunc = ( PHB_PCODEFUNC ) pHrbBody->pDynFunc[ ulPos ].pCodeFunc;
               pSymRead[ ul ].scope.value |= HB_FS_PCODEFUNC | HB_FS_LOCAL;
            }
         }
         else if( pSymRead[ ul ].value.pCodeFunc == ( PHB_PCODEFUNC ) SYM_DEFERRED )
         {
            pSymRead[ ul ].value.pCodeFunc = ( PHB_PCODEFUNC ) SYM_EXTERN;
            pSymRead[ ul ].scope.value |= HB_FS_DEFERRED;
         }

         /* External function */
         if( pSymRead[ ul ].value.pCodeFunc == ( PHB_PCODEFUNC ) SYM_EXTERN )
         {
            pDynSym = hb_dynsymFind( pSymRead[ ul ].szName );

            if( pDynSym )
            {
               pSymRead[ ul ].value.pFunPtr = pDynSym->pSymbol->value.pFunPtr;
               if( pDynSym->pSymbol->scope.value & HB_FS_PCODEFUNC )
               {
                  pSymRead[ ul ].scope.value |= HB_FS_PCODEFUNC;
               }
            }
            else if( ( pSymRead[ ul ].scope.value & HB_FS_DEFERRED ) == 0 )
            {
               char szName[ HB_SYMBOL_NAME_LEN + 1 ];

               hb_strncpy( szName, pSymRead[ ul ].szName, sizeof( szName ) - 1 );
               hb_hrbFreeSymbols( pSymRead, pHrbBody->ulSymbols );
               hb_hrbUnLoad( pHrbBody );
               hb_errRT_BASE( EG_ARG, 6101, "Unknown or unregistered symbol", szName, 0 );
               return NULL;
            }
         }
      }

      pHrbBody->pModuleSymbols = hb_vmRegisterSymbols( pHrbBody->pSymRead,
               ( USHORT ) pHrbBody->ulSymbols, "pcode.hrb", 0, TRUE, FALSE );

      if( pHrbBody->pModuleSymbols->pModuleSymbols != pSymRead )
      {
         /*
          * Old unused symbol table has been recycled - free the one
          * we allocated and disactivate static initialization [druzus]
          */
         pHrbBody->pSymRead = pHrbBody->pModuleSymbols->pModuleSymbols;
         hb_hrbFreeSymbols( pSymRead, pHrbBody->ulSymbols );

         pHrbBody->fInit = TRUE;
      }
      else
      {
         /* mark symbol table as dynamically allocated so HVM will free it on exit */
         pHrbBody->pModuleSymbols->fAllocated = TRUE;

         /* initialize static variables */
         hb_hrbInitStatic( pHrbBody );
      }
   }

   return pHrbBody;
}
runner.c314
STATIC PHRB_BODYhb_hrbLoadFromFile( char* szHrb )
static PHRB_BODY hb_hrbLoadFromFile( char* szHrb )
{
   char szFileName[ _POSIX_PATH_MAX + 1 ];
   PHRB_BODY pHrbBody = NULL;
   PHB_FNAME pFileName;
   HB_FHANDLE hFile;

   /* Create full filename */

   pFileName = hb_fsFNameSplit( szHrb );
   if( pFileName->szExtension == NULL && hb_stackSetStruct()->HB_SET_DEFEXTENSIONS )
   {
      pFileName->szExtension = ".hrb";
   }
   hb_fsFNameMerge( szFileName, pFileName );
   hb_xfree( pFileName );

   /* Open as binary */

   do
   {
      hFile = hb_fsOpen( ( BYTE * ) szFileName, FO_READ );
   }
   while( hFile == FS_ERROR &&
          hb_errRT_BASE_Ext1( EG_OPEN, 6102, NULL, szFileName, hb_fsError(),
                              EF_CANDEFAULT | EF_CANRETRY,
                              HB_ERR_ARGS_BASEPARAMS ) == E_RETRY );

   if( hFile != FS_ERROR )
   {
      ULONG ulBodySize = hb_fsSeek( hFile, 0, FS_END );

      if( ulBodySize )
      {
         BYTE * pbyBuffer;

         pbyBuffer = ( BYTE * ) hb_xgrab( ulBodySize + sizeof( char ) + 1 );
         hb_fsSeek( hFile, 0, FS_SET );
         hb_fsReadLarge( hFile, pbyBuffer, ulBodySize );
         pbyBuffer[ ulBodySize ] = '\0';

         pHrbBody = hb_hrbLoad( ( char * ) pbyBuffer, ( ULONG ) ulBodySize );
         hb_xfree( pbyBuffer );
      }
      hb_fsClose( hFile );
   }

   return pHrbBody;
}
runner.c498
STATIC VOIDhb_hrbDo( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams )
static void hb_hrbDo( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams )
{
   PHB_ITEM pRetVal = NULL;
   int i;

   hb_hrbInit( pHrbBody, iPCount, pParams );

   /* May not have a startup symbol, if first symbol was an INIT Symbol (was executed already).*/
   if( pHrbBody->lSymStart >= 0 && hb_vmRequestQuery() == 0 )
   {
      hb_vmPushSymbol( &pHrbBody->pSymRead[ pHrbBody->lSymStart ] );
      hb_vmPushNil();

      for( i = 0; i < iPCount; i++ )
         hb_vmPush( pParams[ i ] );

      hb_vmDo( ( USHORT ) iPCount );

      pRetVal = hb_itemNew( NULL );
      hb_itemMove( pRetVal, hb_stackReturnItem() );
   }

   hb_hrbExit( pHrbBody );

   if( pRetVal )
   {
      hb_itemReturnRelease( pRetVal );
   }
}
runner.c548
STATIC HB_GARBAGE_FUNC(hb_hrb_Destructor )
static HB_GARBAGE_FUNC( hb_hrb_Destructor )
{
   PHRB_BODY * pHrbPtr = ( PHRB_BODY * ) Cargo;

   if( *pHrbPtr )
   {
      hb_hrbUnLoad( *pHrbPtr );
      *pHrbPtr = NULL;
   }
}
runner.c578
STATIC PHRB_BODYhb_hrbParam( int iParam )
static PHRB_BODY hb_hrbParam( int iParam )
{
   PHRB_BODY * pHrbPtr = ( PHRB_BODY * ) hb_parptrGC( hb_hrb_Destructor, iParam );

   return pHrbPtr ? *pHrbPtr : NULL;
}
runner.c590
STATIC VOIDhb_hrbReturn( PHRB_BODY pHrbBody )
static void hb_hrbReturn( PHRB_BODY pHrbBody )
{
   PHRB_BODY * pHrbPtr = ( PHRB_BODY * ) hb_gcAlloc( sizeof( PHRB_BODY ),
                                                     hb_hrb_Destructor );
   *pHrbPtr = pHrbBody;
   hb_retptrGC( pHrbPtr );
}

/*
   HB_HRBRUN(  [, xParam1 [, xParamN ] ] ) -> return value.

   This program will get the data from the .hrb file and run the p-code
   contained in it.
runner.c597
HB_FUNCHB_HRBRUN(void)
   In due time it should also be able to collect the data from the
   binary/executable itself
*/
HB_FUNC( HB_HRBRUN )
{
   ULONG ulLen = hb_parclen( 1 );

   if( ulLen > 0 )
   {
      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 iPCount = hb_pcount() - 1, i;
         PHB_ITEM * pParams = NULL;

         if( iPCount > 0 )
         {
            pParams = ( PHB_ITEM * ) hb_xgrab( sizeof( PHB_ITEM ) * iPCount );
            for( i = 0; i < iPCount; i++ )
               pParams[ i ] = hb_stackItemFromBase( i + 2 );
         }

         hb_hrbDo( pHrbBody, iPCount, pParams );

         if( pParams )
            hb_xfree( pParams );

         hb_hrbUnLoad( pHrbBody );
         hb_retl( TRUE );
      }
      else
         hb_retl( FALSE );
   }
   else
      hb_errRT_BASE( EG_ARG, 6103, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
runner.c611
HB_FUNCHB_HRBLOAD(void)
HB_FUNC( HB_HRBLOAD )
{
   ULONG ulLen = hb_parclen( 1 );

   if( ulLen > 0 )
   {
      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 iPCount = hb_pcount() - 1;
         PHB_ITEM * pParams = NULL;
         int i;

         if( iPCount > 0 )
         {
            pParams = ( PHB_ITEM * ) hb_xgrab( sizeof( PHB_ITEM ) * iPCount );

            for( i = 0; i < iPCount; i++ )
               pParams[ i ] = hb_stackItemFromBase( i + 2 );
         }

         hb_hrbInit( pHrbBody, iPCount, pParams );

         if( pParams )
            hb_xfree( pParams );
      }
      hb_hrbReturn( pHrbBody );
   }
   else
      hb_errRT_BASE( EG_ARG, 9998, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
runner.c655
HB_FUNCHB_HRBDO(void)
HB_FUNC( HB_HRBDO )
{
   PHRB_BODY pHrbBody = hb_hrbParam( 1 );

   if( pHrbBody )
   {
      int iPCount = hb_pcount() - 1;
      PHB_ITEM * pParams = NULL;
      int i;

      if( iPCount > 0 )
      {
         pParams = ( PHB_ITEM * ) hb_xgrab( sizeof( PHB_ITEM ) * iPCount );

         for( i = 0; i < iPCount; i++ )
            pParams[ i ] = hb_stackItemFromBase( i + 2 );
      }

      hb_hrbDo( pHrbBody, iPCount, pParams );

      if( pParams )
         hb_xfree( pParams );
   }
   else
      hb_errRT_BASE( EG_ARG, 6104, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
runner.c694
HB_FUNCHB_HRBUNLOAD(void)
HB_FUNC( HB_HRBUNLOAD )
{
   PHRB_BODY * pHrbPtr = ( PHRB_BODY * ) hb_parptrGC( hb_hrb_Destructor, 1 );

   if( pHrbPtr )
   {
      PHRB_BODY pHrbBody = *pHrbPtr;

      if( pHrbBody )
      {
         *pHrbPtr = NULL;
         hb_hrbUnLoad( pHrbBody );
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 6105, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
runner.c721
HB_FUNCHB_HRBGETFUNSYM(void)
HB_FUNC( HB_HRBGETFUNSYM )
{
   PHRB_BODY pHrbBody = hb_hrbParam( 1 );
   char * szName = hb_parc( 2 );

   if( pHrbBody && szName )
   {
      PHB_SYMB pSym;
      ULONG ulPos;

      for( ulPos = 0, pSym = pHrbBody->pSymRead; ulPos < pHrbBody->ulSymbols; ++pSym, ++ulPos )
      {
         if( pSym->value.pFunPtr != NULL && hb_stricmp( szName, pSym->szName ) == 0 )
         {
            hb_itemPutSymbol( hb_stackReturnItem(), pSym );
            break;
         }
      }
   }
   else
      hb_errRT_BASE( EG_ARG, 6106, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
runner.c739
HB_FUNC__HRBRUN(void)
HB_FUNC( __HRBRUN )
{
   HB_FUNC_EXEC( HB_HRBRUN );
}
runner.c764
HB_FUNC__HRBLOAD(void)
HB_FUNC( __HRBLOAD )
{
   HB_FUNC_EXEC( HB_HRBLOAD );
}
runner.c769
HB_FUNC__HRBUNLOAD(void)
HB_FUNC( __HRBUNLOAD )
{
   HB_FUNC_EXEC( HB_HRBUNLOAD );
}
runner.c774
HB_FUNC__HRBDO(void)
HB_FUNC( __HRBDO )
{
   HB_FUNC_EXEC( HB_HRBDO );
}
runner.c779
HB_FUNC__HRBGETFU(void)
HB_FUNC( __HRBGETFU )
{
   HB_FUNC_EXEC( HB_HRBGETFUNSYM );
}
runner.c784
set.c
TypeFunctionSourceLine
STATIC CHARset_char( PHB_ITEM pItem, char oldChar )
static char set_char( PHB_ITEM pItem, char oldChar )
{
   char newChar = oldChar;

   HB_TRACE(HB_TR_DEBUG, ("set_char(%p, %c)", pItem, oldChar));

   if( HB_IS_STRING( pItem ) )
   {
      /* Only replace if string has at least one character. */
      ULONG ulLen = hb_itemGetCLen( pItem );
      if( ulLen > 0 )
      {
         newChar = *hb_itemGetCPtr( pItem );
      }
   }
   return newChar;
}
set.c80
STATIC BOOLset_logical( PHB_ITEM pItem, BOOL bDefault )
static BOOL set_logical( PHB_ITEM pItem, BOOL bDefault )
{
   BOOL bLogical = bDefault;

   HB_TRACE(HB_TR_DEBUG, ("set_logical(%p)", pItem));

   if( HB_IS_LOGICAL( pItem ) )
      bLogical = hb_itemGetL( pItem );
   else if( HB_IS_STRING( pItem ) )
   {
      char * szString = hb_itemGetCPtr( pItem );
      ULONG ulLen = hb_itemGetCLen( pItem );

      if( ulLen >= 2
       && toupper( ( UCHAR ) szString[ 0 ] ) == 'O'
       && toupper( ( UCHAR ) szString[ 1 ] ) == 'N' )
         bLogical = TRUE;
      else if( ulLen >= 3
       && toupper( ( UCHAR ) szString[ 0 ] ) == 'O'
       && toupper( ( UCHAR ) szString[ 1 ] ) == 'F'
       && toupper( ( UCHAR ) szString[ 2 ] ) == 'F' )
         bLogical = FALSE;
   }

   return bLogical;
}
set.c98
STATIC INTset_number( PHB_ITEM pItem, int iOldValue )
static int set_number( PHB_ITEM pItem, int iOldValue )
{
   HB_TRACE(HB_TR_DEBUG, ("set_number(%p, %d)", pItem, iOldValue));

   return HB_IS_NUMERIC( pItem ) ? hb_itemGetNI( pItem ) : iOldValue;
}
set.c129
STATIC CHAR *set_string( PHB_ITEM pItem, char * szOldString )
static char * set_string( PHB_ITEM pItem, char * szOldString )
{
   char * szString;

   HB_TRACE(HB_TR_DEBUG, ("set_string(%p, %s)", pItem, szOldString));

   if( HB_IS_STRING( pItem ) || HB_IS_NIL( pItem ) )
   {
      if( szOldString )
         hb_xfree( szOldString );
      /* Limit size of SET strings to 64K, truncating if source is longer */
      szString = hb_strndup( hb_itemGetCPtr( pItem ), USHRT_MAX );
   }
   else
      szString = szOldString;

   return szString;
}
set.c136
STATIC VOIDclose_binary( HB_FHANDLE handle )
static void close_binary( HB_FHANDLE handle )
{
   HB_TRACE(HB_TR_DEBUG, ("close_binary(%p)", handle));

   if( handle != FS_ERROR )
   {
      /* Close the file handle without disrupting the current
         user file error value */
      hb_fsClose( handle );
   }
}
set.c155
STATIC VOIDclose_text( PHB_SET_STRUCT pSet, HB_FHANDLE handle )
static void close_text( PHB_SET_STRUCT pSet, HB_FHANDLE handle )
{
   HB_TRACE(HB_TR_DEBUG, ("close_text(%p,%p)", pSet, handle));

   if( handle != FS_ERROR )
   {
      /* Close the file handle without disrupting the current
         user file error value */
      if( pSet->HB_SET_EOF )
         hb_fsWrite( handle, ( BYTE * ) "\x1A", 1 );
      hb_fsClose( handle );
   }
}
set.c167
STATIC HB_FHANDLEopen_handle( PHB_SET_STRUCT pSet, const char * file_name, BOOL bAppend, const char * def_ext, HB_set_enum set_specifier )
static HB_FHANDLE open_handle( PHB_SET_STRUCT pSet, const char * file_name, BOOL bAppend, const char * def_ext, HB_set_enum set_specifier )
{
   HB_FHANDLE handle;
   char path[ _POSIX_PATH_MAX + 1 ];
   BOOL bPipe = FALSE;
   HB_TRACE(HB_TR_DEBUG, ("open_handle(%p, %s, %d, %s, %d)", pSet, file_name, (int) bAppend, def_ext, (int) set_specifier));

   /* Create full filename */
#if defined(HB_OS_UNIX_COMPATIBLE)
   bPipe = set_specifier == HB_SET_PRINTFILE && file_name[ 0 ] == '|';
   if( bPipe )
   {
      file_name++;
      bAppend = FALSE;
   }
#endif
   if( ! bPipe )
   {
      PHB_FNAME pFilename = hb_fsFNameSplit( file_name );

      if( pSet->HB_SET_DEFEXTENSIONS && pFilename->szExtension == NULL && def_ext )
      {
#if defined(HB_OS_OS2) || defined(HB_OS_W32) || defined(HB_OS_DOS)
         if( pFilename->szName )
         {
            int iLen = ( int ) strlen( pFilename->szName );
            if( ( iLen == 3 &&
                  ( hb_stricmp( pFilename->szName, "PRN" ) == 0 ||
                    hb_stricmp( pFilename->szName, "CON" ) == 0 ) ) ||
                ( iLen == 4 &&
                  ( ( hb_strnicmp( pFilename->szName, "LPT", 3 ) == 0 &&
                      pFilename->szName[3] >= '1' && pFilename->szName[3] <= '3' ) ||
                    ( hb_strnicmp( pFilename->szName, "COM", 3 ) == 0 &&
                      pFilename->szName[3] >= '1' && pFilename->szName[3] <= '9' ) ) ) )
            {
               hb_strupr( ( char * ) pFilename->szName );
               def_ext = NULL;
            }
         }
#endif
         pFilename->szExtension = def_ext;
      }
      if( pFilename->szPath == NULL && pSet->HB_SET_DEFAULT )
         pFilename->szPath = pSet->HB_SET_DEFAULT;

      hb_fsFNameMerge( path, pFilename );
      hb_xfree( pFilename );
   }

   /* Open the file either in append (bAppend) or truncate mode (!bAppend), but
      always use binary mode */

   /* QUESTION: What sharing mode does Clipper use ? [vszakats] */

   handle = FS_ERROR;
   while( handle == FS_ERROR )
   {
      BOOL bCreate = FALSE;

      if( bPipe )
         handle = hb_fsPOpen( ( BYTE * ) file_name, ( BYTE * ) "w" );
      else
      {
         if( bAppend )
         {  /* Append mode */
            if( hb_fsFile( ( BYTE * ) path ) )
            {  /* If the file already exists, open it (in read-write mode, in
                  case of non-Unix and text modes). */
               handle = hb_fsOpen( ( BYTE * ) path, FO_READWRITE | FO_DENYWRITE );
               if( handle != FS_ERROR )
               {  /* Position to EOF */
                  /* Special binary vs. text file handling - even for UN*X, now
                     that there's an HB_SET_EOF flag. */
                  if( set_specifier == HB_SET_PRINTFILE )
                  {  /* PRINTFILE is always binary and needs no special handling. */
                     hb_fsSeek( handle, 0, FS_END );
                  }
                  else
                  {  /* All other files are text files and may have an EOF
                        ('\x1A') character at the end (both UN*X and non-UN*X,
                        now that theres an HB_SET_EOF flag). */
                     char cEOF = '\0';
                     hb_fsSeek( handle, -1, FS_END ); /* Position to last char. */
                     hb_fsRead( handle, ( BYTE * ) &cEOF, 1 );   /* Read the last char. */
                     if( cEOF == '\x1A' )             /* If it's an EOF, */
                     {
                        hb_fsSeek( handle, -1, FS_END ); /* Then write over it. */
                     }
                  }
               }
            }
            else bCreate = TRUE; /* Otherwise create a new file. */
         }
         else bCreate = TRUE; /* Always create a new file for overwrite mode. */

         if( bCreate )
            handle = hb_fsCreate( ( BYTE * ) path, FC_NORMAL );
      }

      if( handle == FS_ERROR )
      {
         USHORT uiAction;

         /* NOTE: using switch() here will result in a compiler warning.
                  [vszakats] */
         if( set_specifier == HB_SET_ALTFILE )
            uiAction = hb_errRT_TERM( EG_CREATE, 2013, NULL, path, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY );
         else if( set_specifier == HB_SET_PRINTFILE )
            uiAction = hb_errRT_TERM( EG_CREATE, 2014, NULL, path, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY );
         else if( set_specifier == HB_SET_EXTRAFILE )
            uiAction = hb_errRT_TERM( EG_CREATE, 2015, NULL, path, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY );
         else
            uiAction = E_DEFAULT;

         if( uiAction != E_RETRY )
            break;
      }
   }
   return handle;
}
set.c181
HB_EXPORT BOOLhb_setSetCentury( BOOL new_century_setting )
HB_EXPORT BOOL hb_setSetCentury( BOOL new_century_setting )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();
   BOOL old_century_setting = pSet->hb_set_century;

   pSet->hb_set_century = new_century_setting;
   /*
    * if the setting changed, adjust the current date format to use
    * the correct number of year digits.
    */
   if( old_century_setting != new_century_setting )
   {
      int count, digit, size, y_size, y_start, y_stop;
      char * szDateFormat, * szNewFormat;

      /* Convert to upper case and determine where year is */
      y_start = y_stop = -1;
      szDateFormat = pSet->HB_SET_DATEFORMAT;
      size = strlen( szDateFormat );
      for( count = 0; count < size; count++ )
      {
         digit = toupper( ( UCHAR ) szDateFormat[ count ] );
         if( digit == 'Y' )
         {
            if( y_start == -1 )
               y_start = count;
         }
         else if( y_start > -1 && y_stop == -1 )
            y_stop = count;
         szDateFormat[ count ] = ( char ) digit;
      }
      /* Determine size of year in current format */
      if( y_start < 0 )
      {
         y_start = 0; /* There is no year in the current format */
         y_stop = 0;
      }
      else if( y_stop < 0 )
         y_stop = size; /* All digits are year digits */
      y_size = y_stop - y_start;
      /* Calculate size of new format */
      size -= y_size;
      if( new_century_setting )
         size += 4;
      else size += 2;

      /* Create the new date format */
      szNewFormat = ( char * ) hb_xgrab( size + 1 );

      {
         int format_len;
         if( y_start > 0 ) memcpy( szNewFormat, szDateFormat, y_start );
         szNewFormat[ y_start ] = '\0';
         hb_strncat( szNewFormat, "YY", size );
         if( new_century_setting )
            hb_strncat( szNewFormat, "YY", size );
         format_len = strlen( szDateFormat );
         if( y_stop < format_len )
            hb_strncat( szNewFormat, szDateFormat + y_stop, size );
         /* DATE FORMAT is under direct control of SET, so notify when it
            it is changed indirectly via __SETCENTURY() */
         hb_setListenerNotify( HB_SET_DATEFORMAT, HB_SET_LISTENER_BEFORE );
         hb_xfree( szDateFormat );
         pSet->HB_SET_DATEFORMAT = szNewFormat;
         hb_setListenerNotify( HB_SET_DATEFORMAT, HB_SET_LISTENER_AFTER );
      }
   }

   /* Return the previous setting */
   return old_century_setting;
}
set.c302
HB_FUNC__SETCENTURY(void)
HB_FUNC( __SETCENTURY )
{
   BOOL old_century_setting = hb_setGetCentury();
   PHB_ITEM pNewVal = hb_param( 1, HB_IT_ANY );

   if( pNewVal )
      hb_setSetCentury( set_logical( pNewVal, old_century_setting ) );

   hb_retl( old_century_setting );
}
set.c374
HB_FUNCSETCANCEL(void)
HB_FUNC( SETCANCEL )
{
   hb_retl( hb_setGetCancel() );
   /* SETCANCEL() accepts only logical parameters */
   hb_setSetItem( HB_SET_CANCEL, hb_param( 1, HB_IT_LOGICAL ) );
}
set.c385
HB_FUNCSET(void)
HB_FUNC( SET )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();
   int args = hb_pcount();
   BOOL bFlag;

   HB_set_enum set_specifier = ( args > 0 ) ? ( HB_set_enum ) hb_parni( 1 ) : HB_SET_INVALID_;
   PHB_ITEM pArg2 = ( args > 1 ) ? hb_param( 2, HB_IT_ANY ) : NULL;
   PHB_ITEM pArg3 = ( args > 2 ) ? hb_param( 3, HB_IT_ANY ) : NULL;

   if( args > 1 )
      hb_setListenerNotify( set_specifier, HB_SET_LISTENER_BEFORE );

   switch( set_specifier )
   {
      case HB_SET_ALTERNATE:
         hb_retl( pSet->HB_SET_ALTERNATE );
         if( args > 1 )
            pSet->HB_SET_ALTERNATE = set_logical( pArg2, pSet->HB_SET_ALTERNATE );
         break;
      case HB_SET_ALTFILE:
         if( pSet->HB_SET_ALTFILE )
            hb_retc( pSet->HB_SET_ALTFILE );
         else
            hb_retc( NULL );
         if( args > 1 )
         {
            if( HB_IS_NIL( pArg2 ) )
            {
               if( pSet->HB_SET_ALTFILE )
               {
                  hb_xfree( pSet->HB_SET_ALTFILE );
                  pSet->HB_SET_ALTFILE = NULL;
               }
            }
            else
            {
               pSet->HB_SET_ALTFILE = set_string( pArg2, pSet->HB_SET_ALTFILE );
            }
         }
         if( args > 2 )
            bFlag = set_logical( pArg3, FALSE );
         else
            bFlag = FALSE;
         if( args > 1 )
         {
            close_text( pSet, pSet->hb_set_althan );
            if( pSet->HB_SET_ALTFILE && pSet->HB_SET_ALTFILE[0] != '\0' )
               pSet->hb_set_althan = open_handle( pSet, pSet->HB_SET_ALTFILE, bFlag, ".txt", HB_SET_ALTFILE );
            else
               pSet->hb_set_althan = FS_ERROR;
         }
         break;
      case HB_SET_AUTOPEN:
         hb_retl( pSet->HB_SET_AUTOPEN );
         if( args > 1 )
            pSet->HB_SET_AUTOPEN = set_logical( pArg2, pSet->HB_SET_AUTOPEN );
         break;
      case HB_SET_AUTORDER:
         hb_retni( pSet->HB_SET_AUTORDER );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_AUTORDER ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_AUTORDER = set_number( pArg2, pSet->HB_SET_AUTORDER );
         }
         break;
      case HB_SET_AUTOSHARE:
         hb_retni( pSet->HB_SET_AUTOSHARE );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_AUTOSHARE ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_AUTOSHARE = set_number( pArg2, pSet->HB_SET_AUTOSHARE );
         }
         break;
      case HB_SET_BELL:
         hb_retl( pSet->HB_SET_BELL );
         if( args > 1 )
            pSet->HB_SET_BELL = set_logical( pArg2, pSet->HB_SET_BELL );
         break;
      case HB_SET_CANCEL:
         hb_retl( pSet->HB_SET_CANCEL );
         if( args > 1 )
            pSet->HB_SET_CANCEL = set_logical( pArg2, pSet->HB_SET_CANCEL );
         break;
      case HB_SET_COLOR:
         hb_retc( hb_conSetColor( args >= 2 && HB_IS_STRING( pArg2 ) ? hb_itemGetCPtr( pArg2 ) : ( char * ) NULL ) );
         break;
      case HB_SET_CONFIRM:
         hb_retl( pSet->HB_SET_CONFIRM );
         if( args > 1 )
            pSet->HB_SET_CONFIRM = set_logical( pArg2, pSet->HB_SET_CONFIRM );
         break;
      case HB_SET_CONSOLE:
         hb_retl( pSet->HB_SET_CONSOLE );
         if( args > 1 )
            pSet->HB_SET_CONSOLE = set_logical( pArg2, pSet->HB_SET_CONSOLE );
         break;
      case HB_SET_CURSOR:
         if( args >= 2 && HB_IS_NUMERIC( pArg2 ) )
            hb_retni( hb_conSetCursor( TRUE, ( USHORT ) hb_itemGetNI( pArg2 ) ) );
         else
            hb_retni( hb_conSetCursor( FALSE, 0 ) );
         break;
      case HB_SET_DATEFORMAT:
         if( pSet->HB_SET_DATEFORMAT )
            hb_retc( pSet->HB_SET_DATEFORMAT );
         else
            hb_retc( NULL );

         if( args > 1 )
         {
            BOOL flag = FALSE;
            unsigned int i, iLen;
            int ch, year = 0;

            pSet->HB_SET_DATEFORMAT = set_string( pArg2, pSet->HB_SET_DATEFORMAT );
            iLen = ( unsigned int ) strlen( pSet->HB_SET_DATEFORMAT );
            for( i = 0; i < iLen; i++ )
            {
               ch = pSet->HB_SET_DATEFORMAT[i];
               if( !flag && ( ch == 'Y' || ch == 'y' ) )
                  year++;   /* Only count the first set of consecutive "Y"s. */
               else if( year )
                  flag = TRUE; /* Indicate non-consecutive. */
            }

            flag = ( year >= 4 );

            if( flag != pSet->hb_set_century )
            {
               /* CENTURY is not controlled directly by SET, so there is no
                  notification for changing it indirectly via DATE FORMAT. */
               pSet->hb_set_century = flag;
            }
         }
         break;
      case HB_SET_DEBUG:
         hb_retl( pSet->HB_SET_DEBUG );
         if( args > 1 )
            pSet->HB_SET_DEBUG = set_logical( pArg2, pSet->HB_SET_DEBUG );
         break;
      case HB_SET_DECIMALS:
         hb_retni( pSet->HB_SET_DECIMALS );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_DECIMALS ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_DECIMALS = set_number( pArg2, pSet->HB_SET_DECIMALS );
         }
         break;
      case HB_SET_DEFAULT:
         if( pSet->HB_SET_DEFAULT )
            hb_retc( pSet->HB_SET_DEFAULT );
         else
            hb_retc( NULL );
         if( args > 1 )
            pSet->HB_SET_DEFAULT = set_string( pArg2, pSet->HB_SET_DEFAULT );
         break;
      case HB_SET_DELETED:
         hb_retl( pSet->HB_SET_DELETED );
         if( args > 1 )
            pSet->HB_SET_DELETED = set_logical( pArg2, pSet->HB_SET_DELETED );
         break;
      case HB_SET_DELIMCHARS:
         if( pSet->HB_SET_DELIMCHARS )
            hb_retc( pSet->HB_SET_DELIMCHARS );
         else
            hb_retc( NULL );
         if( args > 1 )
            pSet->HB_SET_DELIMCHARS = set_string( pArg2, pSet->HB_SET_DELIMCHARS );
         break;
      case HB_SET_DELIMITERS:
         hb_retl( pSet->HB_SET_DELIMITERS );
         if( args > 1 )
            pSet->HB_SET_DELIMITERS = set_logical( pArg2, pSet->HB_SET_DELIMITERS );
         break;
      case HB_SET_DEVICE:
         if( pSet->HB_SET_DEVICE )
            hb_retc( pSet->HB_SET_DEVICE );
         else
            hb_retc( NULL );
         if( args > 1 && ! HB_IS_NIL( pArg2 ) )
         {
            /* If the print file is not already open, open it in overwrite mode. */
            pSet->HB_SET_DEVICE = set_string( pArg2, pSet->HB_SET_DEVICE );
            if( hb_stricmp( pSet->HB_SET_DEVICE, "PRINTER" ) == 0 && pSet->hb_set_printhan == FS_ERROR &&
                pSet->HB_SET_PRINTFILE && pSet->HB_SET_PRINTFILE[0] != '\0' )
               pSet->hb_set_printhan = open_handle( pSet, pSet->HB_SET_PRINTFILE, FALSE, NULL, HB_SET_PRINTFILE );
         }
         break;
      case HB_SET_EOF:
         hb_retl( pSet->HB_SET_EOF );
         if( args > 1 )
            pSet->HB_SET_EOF = set_logical( pArg2, pSet->HB_SET_EOF );
         break;
      case HB_SET_EPOCH:
         hb_retni( pSet->HB_SET_EPOCH );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_EPOCH ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_EPOCH = set_number( pArg2, pSet->HB_SET_EPOCH );
         }
         break;
      case HB_SET_ESCAPE:
         hb_retl( pSet->HB_SET_ESCAPE );
         if( args > 1 )
            pSet->HB_SET_ESCAPE = set_logical( pArg2, pSet->HB_SET_ESCAPE );
         break;
      case HB_SET_EVENTMASK:
         hb_retni( pSet->HB_SET_EVENTMASK );
         if( args > 1 )
            pSet->HB_SET_EVENTMASK = set_number( pArg2, pSet->HB_SET_EVENTMASK );
         break;
      case HB_SET_EXACT:
         hb_retl( pSet->HB_SET_EXACT );
         if( args > 1 )
            pSet->HB_SET_EXACT = set_logical( pArg2, pSet->HB_SET_EXACT );
         break;
      case HB_SET_EXCLUSIVE:
         hb_retl( pSet->HB_SET_EXCLUSIVE );
         if( args > 1 )
            pSet->HB_SET_EXCLUSIVE = set_logical( pArg2, pSet->HB_SET_EXCLUSIVE );
         break;
      case HB_SET_EXIT:
         hb_retl( pSet->HB_SET_EXIT );
         /* NOTE: Otherwise ReadExit() will always set the value. [vszakats] */
         if( pArg2 != NULL && !HB_IS_NIL( pArg2 ) )
            pSet->HB_SET_EXIT = set_logical( pArg2, pSet->HB_SET_EXIT );
         break;
      case HB_SET_EXTRA:
         hb_retl( pSet->HB_SET_EXTRA );
         if( args > 1 )
            pSet->HB_SET_EXTRA = set_logical( pArg2, pSet->HB_SET_EXTRA );
         break;
      case HB_SET_EXTRAFILE:
         if( pSet->HB_SET_EXTRAFILE )
            hb_retc( pSet->HB_SET_EXTRAFILE );
         else
            hb_retc( NULL );
         if( args > 1 )
         {
            if( HB_IS_NIL( pArg2 ) )
            {
               if( pSet->HB_SET_EXTRAFILE )
               {
                  hb_xfree( pSet->HB_SET_EXTRAFILE );
                  pSet->HB_SET_EXTRAFILE = NULL;
               }
            }
            else
            {
               pSet->HB_SET_EXTRAFILE = set_string( pArg2, pSet->HB_SET_EXTRAFILE );
            }
         }
         if( args > 2 )
            bFlag = set_logical( pArg3, FALSE );
         else
            bFlag = FALSE;
         if( args > 1 && ! HB_IS_NIL( pArg2 ) )
         {
            close_text( pSet, pSet->hb_set_extrahan );
            if( pSet->HB_SET_EXTRAFILE && pSet->HB_SET_EXTRAFILE[0] != '\0' )
               pSet->hb_set_extrahan = open_handle( pSet, pSet->HB_SET_EXTRAFILE, bFlag, ".prn", HB_SET_EXTRAFILE );
            else
               pSet->hb_set_extrahan = FS_ERROR;
         }
         break;
      case HB_SET_FIXED:
         hb_retl( pSet->HB_SET_FIXED );
         if( args > 1 )
            pSet->HB_SET_FIXED = set_logical( pArg2, pSet->HB_SET_FIXED );
         break;
      case HB_SET_INSERT:
         hb_retl( pSet->HB_SET_INSERT );
         if( args > 1 )
            pSet->HB_SET_INSERT = set_logical( pArg2, pSet->HB_SET_INSERT );
         break;
      case HB_SET_INTENSITY:
         hb_retl( pSet->HB_SET_INTENSITY );
         if( args > 1 )
            pSet->HB_SET_INTENSITY = set_logical( pArg2, pSet->HB_SET_INTENSITY );
         break;
      case HB_SET_MARGIN:
         hb_retni( pSet->HB_SET_MARGIN );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_MARGIN ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_MARGIN = set_number( pArg2, pSet->HB_SET_MARGIN );
         }
         break;
      case HB_SET_MBLOCKSIZE:
         hb_retni( pSet->HB_SET_MBLOCKSIZE );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_MBLOCKSIZE ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_MBLOCKSIZE = set_number( pArg2, pSet->HB_SET_MBLOCKSIZE );
         }
         break;
      case HB_SET_MCENTER:
         hb_retl( pSet->HB_SET_MCENTER );
         if( args > 1 )
            pSet->HB_SET_MCENTER = set_logical( pArg2, pSet->HB_SET_MCENTER );
         break;
      case HB_SET_MESSAGE:
         hb_retni( pSet->HB_SET_MESSAGE );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_MESSAGE ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_MESSAGE = set_number( pArg2, pSet->HB_SET_MESSAGE );
         }
         break;
      case HB_SET_MFILEEXT:
         hb_retc( pSet->HB_SET_MFILEEXT );
         if( args > 1 )
            pSet->HB_SET_MFILEEXT = set_string( pArg2, pSet->HB_SET_MFILEEXT );
         break;
      case HB_SET_OPTIMIZE:
         hb_retl( pSet->HB_SET_OPTIMIZE );
         if( args > 1 )
            pSet->HB_SET_OPTIMIZE = set_logical( pArg2, pSet->HB_SET_OPTIMIZE );
         break;
      case HB_SET_FORCEOPT:
         hb_retl( pSet->HB_SET_FORCEOPT );
         if( args > 1 )
            pSet->HB_SET_FORCEOPT = set_logical( pArg2, pSet->HB_SET_FORCEOPT );
         break;
      case HB_SET_STRICTREAD:
         hb_retl( pSet->HB_SET_STRICTREAD );
         if( args > 1 )
            pSet->HB_SET_STRICTREAD = set_logical( pArg2, pSet->HB_SET_STRICTREAD );
         break;
      case HB_SET_HARDCOMMIT:
         hb_retl( pSet->HB_SET_HARDCOMMIT );
         if( args > 1 )
            pSet->HB_SET_HARDCOMMIT = set_logical( pArg2, pSet->HB_SET_HARDCOMMIT );
         break;
      case HB_SET_PATH:
         if( pSet->HB_SET_PATH )
            hb_retc( pSet->HB_SET_PATH );
         else
            hb_retc( NULL );
         if( args > 1 )
         {
            pSet->HB_SET_PATH = set_string( pArg2, pSet->HB_SET_PATH );
            hb_fsFreeSearchPath( pSet->hb_set_path );
            pSet->hb_set_path = NULL;
            hb_fsAddSearchPath( pSet->HB_SET_PATH, &pSet->hb_set_path );
         }
         break;
      case HB_SET_PRINTER:
         hb_retl( pSet->HB_SET_PRINTER );
         if( args > 1 )
            pSet->HB_SET_PRINTER = set_logical( pArg2, pSet->HB_SET_PRINTER );
         break;
      case HB_SET_PRINTFILE:
         if( pSet->HB_SET_PRINTFILE )
            hb_retc( pSet->HB_SET_PRINTFILE );
         else
            hb_retc( NULL );
         if( args > 1 && ! HB_IS_NIL( pArg2 ) )
            pSet->HB_SET_PRINTFILE = set_string( pArg2, pSet->HB_SET_PRINTFILE );
         if( args > 2 )
            bFlag = set_logical( pArg3, FALSE );
         else
            bFlag = FALSE;
         if( args > 1 && ! HB_IS_NIL( pArg2 ) )
         {
            close_binary( pSet->hb_set_printhan );
            pSet->hb_set_printhan = FS_ERROR;
            if( pSet->HB_SET_PRINTFILE && pSet->HB_SET_PRINTFILE[0] != '\0' )
               pSet->hb_set_printhan = open_handle( pSet, pSet->HB_SET_PRINTFILE, bFlag, ".prn", HB_SET_PRINTFILE );
         }
         break;
      case HB_SET_SCOREBOARD:
         hb_retl( pSet->HB_SET_SCOREBOARD );
         if( args > 1 )
            pSet->HB_SET_SCOREBOARD = set_logical( pArg2, pSet->HB_SET_SCOREBOARD );
         break;
      case HB_SET_SCROLLBREAK:
         hb_retl( pSet->HB_SET_SCROLLBREAK );
         if( args > 1 )
            pSet->HB_SET_SCROLLBREAK = set_logical( pArg2, pSet->HB_SET_SCROLLBREAK );
         break;
      case HB_SET_SOFTSEEK:
         hb_retl( pSet->HB_SET_SOFTSEEK );
         if( args > 1 )
            pSet->HB_SET_SOFTSEEK = set_logical( pArg2, pSet->HB_SET_SOFTSEEK );
         break;
      case HB_SET_TYPEAHEAD:
         hb_retni( pSet->HB_SET_TYPEAHEAD );
         if( args > 1 )
         {
            /* Set the value and limit the range */
            int old = pSet->HB_SET_TYPEAHEAD;
            pSet->HB_SET_TYPEAHEAD = set_number( pArg2, old );
            if( pSet->HB_SET_TYPEAHEAD == 0 )
               /* Do nothing */ ;
            else if( pSet->HB_SET_TYPEAHEAD < 16 )
               pSet->HB_SET_TYPEAHEAD = 16;
            else if( pSet->HB_SET_TYPEAHEAD > 4096 )
               pSet->HB_SET_TYPEAHEAD = 4096;
            /* reset keyboard buffer */
            hb_inkeyReset();
         }
         break;
      case HB_SET_UNIQUE:
         hb_retl( pSet->HB_SET_UNIQUE );
         if( args > 1 )
            pSet->HB_SET_UNIQUE = set_logical( pArg2, pSet->HB_SET_UNIQUE );
         break;
      case HB_SET_VIDEOMODE:
         hb_retni( pSet->HB_SET_VIDEOMODE );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_VIDEOMODE ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_VIDEOMODE = set_number( pArg2, pSet->HB_SET_VIDEOMODE );
         }
         break;
      case HB_SET_WRAP:
         hb_retl( pSet->HB_SET_WRAP );
         if( args > 1 )
            pSet->HB_SET_WRAP = set_logical( pArg2, pSet->HB_SET_WRAP );
         break;
      case HB_SET_LANGUAGE:
         hb_retc( hb_langID() );
         if( args > 1 && HB_IS_STRING( pArg2 ) )
            hb_langSelectID( hb_itemGetCPtr( pArg2 ) );
         break;
      case HB_SET_CODEPAGE:
         hb_retc( hb_cdpID() );
         if( args > 1 && HB_IS_STRING( pArg2 ) )
            hb_cdpSelectID( hb_itemGetCPtr( pArg2 ) );
         break;
      case HB_SET_IDLEREPEAT:
         hb_retl( pSet->HB_SET_IDLEREPEAT );
         if( args > 1 )
            pSet->HB_SET_IDLEREPEAT = set_logical( pArg2, pSet->HB_SET_IDLEREPEAT );
         break;
      case HB_SET_FILECASE:
         hb_retni( pSet->HB_SET_FILECASE );
         if( args > 1 )
         {
            if( HB_IS_STRING( pArg2 ) )
            {
               if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "LOWER" ) )
                  pSet->HB_SET_FILECASE = HB_SET_CASE_LOWER;
               else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "UPPER" ) )
                  pSet->HB_SET_FILECASE = HB_SET_CASE_UPPER;
               else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) )
                  pSet->HB_SET_FILECASE = HB_SET_CASE_MIXED;
               else
                  hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            }
            else if( HB_IS_NUMERIC( pArg2 ) )
            {
               if( set_number( pArg2, pSet->HB_SET_FILECASE ) < 0 )
                  hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
               else
                  pSet->HB_SET_FILECASE = set_number( pArg2, pSet->HB_SET_FILECASE );
            }
            else
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
         }
         break;
      case HB_SET_DIRCASE:
         hb_retni( pSet->HB_SET_DIRCASE );
         if( args > 1 )
         {
            if( HB_IS_STRING( pArg2 ) )
            {
               if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "LOWER" ) )
                  pSet->HB_SET_DIRCASE = HB_SET_CASE_LOWER;
               else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "UPPER" ) )
                  pSet->HB_SET_DIRCASE = HB_SET_CASE_UPPER;
               else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) )
                  pSet->HB_SET_DIRCASE = HB_SET_CASE_MIXED;
               else
                  hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            }
            else if( HB_IS_NUMERIC( pArg2 ) )
            {
               if( set_number( pArg2, pSet->HB_SET_DIRCASE ) < 0 )
                  hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
               else
                  pSet->HB_SET_DIRCASE = set_number( pArg2, pSet->HB_SET_DIRCASE );
            }
            else
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
         }
         break;
      case HB_SET_DIRSEPARATOR:
      {
         char szDirSep[ 2 ];
         szDirSep[ 0 ] = ( char ) pSet->HB_SET_DIRSEPARATOR;
         szDirSep[ 1 ] = '\0';
         hb_retc( szDirSep );
         if( args > 1 )
            pSet->HB_SET_DIRSEPARATOR = set_char( pArg2, ( char ) pSet->HB_SET_DIRSEPARATOR );
         break;
      }
      case HB_SET_DBFLOCKSCHEME:
         hb_retni( pSet->HB_SET_DBFLOCKSCHEME );
         if( args > 1 )
         {
            if( set_number( pArg2, pSet->HB_SET_DBFLOCKSCHEME ) < 0 )
               hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            else
               pSet->HB_SET_DBFLOCKSCHEME = set_number( pArg2, pSet->HB_SET_DBFLOCKSCHEME );
         }
         break;
      case HB_SET_DEFEXTENSIONS:
         hb_retl( pSet->HB_SET_DEFEXTENSIONS );
         if( args > 1 )
            pSet->HB_SET_DEFEXTENSIONS = set_logical( pArg2, pSet->HB_SET_DEFEXTENSIONS );
         break;
      case HB_SET_EOL:
         if( pSet->HB_SET_EOL )
            hb_retc( pSet->HB_SET_EOL );
         else
            hb_retc( NULL );
         if( args > 1 )
            pSet->HB_SET_EOL = set_string( pArg2, pSet->HB_SET_EOL );
         break;
      case HB_SET_TRIMFILENAME:
         hb_retl( pSet->HB_SET_TRIMFILENAME );
         if( args > 1 )
            pSet->HB_SET_TRIMFILENAME = set_logical( pArg2, pSet->HB_SET_TRIMFILENAME );
         break;
      case HB_SET_HBOUTLOG:
         hb_retc( pSet->HB_SET_HBOUTLOG );
         if( args > 1 )
         {
            pSet->HB_SET_HBOUTLOG = set_string( pArg2, pSet->HB_SET_HBOUTLOG );
            hb_xsetfilename( pSet->HB_SET_HBOUTLOG );
         }
         break;
      case HB_SET_HBOUTLOGINFO:
         hb_retc( pSet->HB_SET_HBOUTLOGINFO );
         if( args > 1 )
         {
            pSet->HB_SET_HBOUTLOGINFO = set_string( pArg2, pSet->HB_SET_HBOUTLOGINFO );
            hb_xsetinfo( pSet->HB_SET_HBOUTLOGINFO );
         }
         break;

      case HB_SET_INVALID_:
         /* Return NIL if called with invalid SET specifier */
         break;

#if 0
      /*
       * intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
       */
      default:
         break;
#endif
   }
   if( args > 1 )
      hb_setListenerNotify( set_specifier, HB_SET_LISTENER_AFTER );
}
set.c392
VOIDhb_setInitialize( PHB_SET_STRUCT pSet )
void hb_setInitialize( PHB_SET_STRUCT pSet )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_setInitialize(%p)", pSet));

   pSet->HB_SET_ALTERNATE = FALSE;
   pSet->HB_SET_ALTFILE = NULL;
   pSet->hb_set_althan = FS_ERROR;
   pSet->HB_SET_AUTOPEN = TRUE;
   pSet->HB_SET_AUTORDER = 0;
   pSet->HB_SET_AUTOSHARE = 0;
   pSet->HB_SET_BELL = FALSE;
   pSet->HB_SET_CANCEL = TRUE;
   pSet->hb_set_century = FALSE;
   pSet->HB_SET_COLOR = ( char * ) hb_xgrab( HB_CLRSTR_LEN + 1 );
   hb_strncpy( pSet->HB_SET_COLOR, "W/N,N/W,N/N,N/N,N/W", HB_CLRSTR_LEN );
   pSet->HB_SET_CONFIRM = FALSE;
   pSet->HB_SET_CONSOLE = TRUE;
   pSet->HB_SET_DATEFORMAT = hb_strdup( "mm/dd/yy" );
   /*
    * Tests shows that Clipper has two different flags to control ALT+D
    * and ALTD() behavior and on startup these flags are not synchronized.
    * When application starts _SET_DEBUG is set to FALSE but debugger
    * can be activated by hitting K_ALT_D or calling ALTD() function without
    * parameter. It means that some other internal flag enables these
    * operations.
    * Because Harbour is using _SET_DEBUG flag only then we have to
    * initialize it to TRUE when debugger is linked to keep real Clipper
    * behavior or we will have to add second flag too and try to replicate
    * exactly unsynchronized behavior of these flags which exists in Clipper.
    * IMHO it's a bug in Clipper (side effect of some internal solutions) and
    * we should not try to emulate it [druzus].
    */
   /* pSet->HB_SET_DEBUG = FALSE; */
   pSet->HB_SET_DEBUG = hb_dynsymFind( "__DBGENTRY" ) ? TRUE : FALSE;
   pSet->HB_SET_DECIMALS = 2;
   pSet->HB_SET_DEFAULT = hb_strdup( "" );
   pSet->HB_SET_DELETED = FALSE;
   pSet->HB_SET_DELIMCHARS = hb_strdup( "::" );
   pSet->HB_SET_DELIMITERS = FALSE;
   pSet->HB_SET_DEVICE = hb_strdup( "SCREEN" );
#if defined(HB_OS_UNIX_COMPATIBLE)
   pSet->HB_SET_EOF = FALSE;
#else
   pSet->HB_SET_EOF = TRUE;
#endif
   pSet->HB_SET_EPOCH = 1900;
   pSet->HB_SET_ESCAPE = TRUE;
   pSet->HB_SET_EVENTMASK = INKEY_KEYBOARD;
   pSet->HB_SET_EXACT = FALSE;
   pSet->HB_SET_EXCLUSIVE = TRUE;
   pSet->HB_SET_EXIT = FALSE;
   pSet->HB_SET_EXTRA = FALSE;
   pSet->HB_SET_EXTRAFILE = NULL;
   pSet->hb_set_extrahan = FS_ERROR;
   pSet->HB_SET_FIXED = FALSE;
   pSet->HB_SET_FORCEOPT = FALSE;
   pSet->HB_SET_HARDCOMMIT = TRUE;
   pSet->HB_SET_IDLEREPEAT = TRUE;
   pSet->HB_SET_INSERT = FALSE;
   pSet->HB_SET_INTENSITY = TRUE;
   pSet->HB_SET_MARGIN = 0;
   pSet->HB_SET_MBLOCKSIZE = 0;
   pSet->HB_SET_MCENTER = FALSE;
   pSet->HB_SET_MESSAGE = 0;
   pSet->HB_SET_MFILEEXT = hb_strdup( "" );
   pSet->HB_SET_OPTIMIZE = TRUE;
   pSet->HB_SET_PATH = hb_strdup( "" );
   pSet->hb_set_path = NULL;
   pSet->HB_SET_PRINTER = FALSE;
   /* Default printer device */
#if defined(HB_OS_UNIX)
   pSet->HB_SET_PRINTFILE = hb_strdup( "|lpr" );
#elif defined(HB_OS_DOS)
   pSet->HB_SET_PRINTFILE = hb_strdup( "PRN" );
#elif defined(HB_OS_WIN_32) || defined(HB_OS_OS2)
   pSet->HB_SET_PRINTFILE = hb_strdup( "LPT1" );
#else
   pSet->HB_SET_PRINTFILE = hb_strdup( "PRN" ); /* TOFIX */
#endif
   pSet->hb_set_printhan = FS_ERROR;
   pSet->HB_SET_SCOREBOARD = TRUE;
   pSet->HB_SET_SCROLLBREAK = TRUE;
   pSet->HB_SET_SOFTSEEK = FALSE;
   pSet->HB_SET_STRICTREAD = FALSE;
   pSet->HB_SET_TYPEAHEAD = HB_DEFAULT_INKEY_BUFSIZE;
   pSet->HB_SET_UNIQUE = FALSE;
   pSet->HB_SET_FILECASE = HB_SET_CASE_MIXED;
   pSet->HB_SET_DIRCASE = HB_SET_CASE_MIXED;
   pSet->HB_SET_DIRSEPARATOR = HB_OS_PATH_DELIM_CHR;
   pSet->HB_SET_VIDEOMODE = 0;
   pSet->HB_SET_WRAP = FALSE;
   pSet->HB_SET_DBFLOCKSCHEME = 0;
   pSet->HB_SET_DEFEXTENSIONS = TRUE;
   pSet->HB_SET_EOL = hb_strdup( hb_conNewLine() );
   pSet->HB_SET_TRIMFILENAME = FALSE;
   pSet->HB_SET_HBOUTLOG = hb_strdup( "hb_out.log" );
   pSet->HB_SET_HBOUTLOGINFO = hb_strdup( "" );

   hb_xsetfilename( pSet->HB_SET_HBOUTLOG );
   hb_xsetinfo( pSet->HB_SET_HBOUTLOGINFO );

   pSet->hb_set_listener = NULL;
}
set.c969
VOIDhb_setRelease( PHB_SET_STRUCT pSet )
void hb_setRelease( PHB_SET_STRUCT pSet )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_setRelease()"));

   close_text( pSet, pSet->hb_set_althan );
   close_text( pSet, pSet->hb_set_extrahan );
   close_binary( pSet->hb_set_printhan );

   if( pSet->HB_SET_ALTFILE )       hb_xfree( pSet->HB_SET_ALTFILE );
   if( pSet->HB_SET_DATEFORMAT )    hb_xfree( pSet->HB_SET_DATEFORMAT );
   if( pSet->HB_SET_DEFAULT )       hb_xfree( pSet->HB_SET_DEFAULT );
   if( pSet->HB_SET_DELIMCHARS )    hb_xfree( pSet->HB_SET_DELIMCHARS );
   if( pSet->HB_SET_DEVICE )        hb_xfree( pSet->HB_SET_DEVICE );
   if( pSet->HB_SET_EXTRAFILE )     hb_xfree( pSet->HB_SET_EXTRAFILE );
   if( pSet->HB_SET_MFILEEXT  )     hb_xfree( pSet->HB_SET_MFILEEXT );
   if( pSet->HB_SET_PATH )          hb_xfree( pSet->HB_SET_PATH );
   if( pSet->HB_SET_PRINTFILE )     hb_xfree( pSet->HB_SET_PRINTFILE );
   if( pSet->HB_SET_COLOR )         hb_xfree( pSet->HB_SET_COLOR );
   if( pSet->HB_SET_EOL )           hb_xfree( pSet->HB_SET_EOL );
   if( pSet->HB_SET_HBOUTLOG )      hb_xfree( pSet->HB_SET_HBOUTLOG );
   if( pSet->HB_SET_HBOUTLOGINFO )  hb_xfree( pSet->HB_SET_HBOUTLOGINFO );

   pSet->HB_SET_TYPEAHEAD = 0;     hb_inkeyReset(); /* reset keyboard buffer */

   hb_fsFreeSearchPath( pSet->hb_set_path );

   /* Free all set listeners */
   if( pSet->hb_set_listener )
   {
      PHB_SET_LISTENER pListener = ( ( PHB_SET_LISTENER_LST )
                                     pSet->hb_set_listener )->first;
      while( pListener )
      {
         PHB_SET_LISTENER pNext = pListener->next;
         hb_xfree( pListener );
         pListener = pNext;
      }
      hb_xfree( pSet->hb_set_listener );
   }
}
set.c1073
PHB_SET_STRUCThb_setClone( PHB_SET_STRUCT pSrc )
PHB_SET_STRUCT hb_setClone( PHB_SET_STRUCT pSrc )
{
   PHB_SET_STRUCT pSet = ( PHB_SET_STRUCT ) hb_xgrab( sizeof( HB_SET_STRUCT ) );

   memcpy( pSet, pSrc, sizeof( HB_SET_STRUCT ) );

   pSet->hb_set_althan = pSet->hb_set_extrahan = pSet->hb_set_printhan = FS_ERROR;

   pSet->hb_set_listener = NULL;

   pSet->HB_SET_TYPEAHEAD = HB_DEFAULT_INKEY_BUFSIZE;

   pSet->HB_SET_COLOR = ( char * ) hb_xgrab( HB_CLRSTR_LEN + 1 );
   hb_strncpy( pSet->HB_SET_COLOR, pSrc->HB_SET_COLOR, HB_CLRSTR_LEN );

   if( pSet->HB_SET_ALTFILE )      pSet->HB_SET_ALTFILE      = hb_strdup( pSet->HB_SET_ALTFILE );
   if( pSet->HB_SET_DATEFORMAT )   pSet->HB_SET_DATEFORMAT   = hb_strdup( pSet->HB_SET_DATEFORMAT );
   if( pSet->HB_SET_DEFAULT )      pSet->HB_SET_DEFAULT      = hb_strdup( pSet->HB_SET_DEFAULT );
   if( pSet->HB_SET_DELIMCHARS )   pSet->HB_SET_DELIMCHARS   = hb_strdup( pSet->HB_SET_DELIMCHARS );
   if( pSet->HB_SET_DEVICE )       pSet->HB_SET_DEVICE       = hb_strdup( pSet->HB_SET_DEVICE );
   if( pSet->HB_SET_EXTRAFILE )    pSet->HB_SET_EXTRAFILE    = hb_strdup( pSet->HB_SET_EXTRAFILE );
   if( pSet->HB_SET_MFILEEXT  )    pSet->HB_SET_MFILEEXT     = hb_strdup( pSet->HB_SET_MFILEEXT );
   if( pSet->HB_SET_PATH )         pSet->HB_SET_PATH         = hb_strdup( pSet->HB_SET_PATH );
   if( pSet->HB_SET_PRINTFILE )    pSet->HB_SET_PRINTFILE    = hb_strdup( pSet->HB_SET_PRINTFILE );
   if( pSet->HB_SET_EOL )          pSet->HB_SET_EOL          = hb_strdup( pSet->HB_SET_EOL );
   if( pSet->HB_SET_HBOUTLOG )     pSet->HB_SET_HBOUTLOG     = hb_strdup( pSet->HB_SET_HBOUTLOG );
   if( pSet->HB_SET_HBOUTLOGINFO ) pSet->HB_SET_HBOUTLOGINFO = hb_strdup( pSet->HB_SET_HBOUTLOGINFO );

   return pSet;
}
set.c1114
INThb_setListenerAdd( HB_SET_LISTENER_CALLBACK * callback )
int hb_setListenerAdd( HB_SET_LISTENER_CALLBACK * callback )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();
   PHB_SET_LISTENER p_sl = (PHB_SET_LISTENER) hb_xgrab( sizeof( HB_SET_LISTENER ) );
   PHB_SET_LISTENER_LST pList;

   if( !pSet->hb_set_listener )
   {
      pSet->hb_set_listener = hb_xgrab( sizeof( HB_SET_LISTENER_LST ) );
      memset( pSet->hb_set_listener, 0, sizeof( HB_SET_LISTENER_LST ) );
   }
   pList = ( PHB_SET_LISTENER_LST ) pSet->hb_set_listener;

   p_sl->callback = callback;
   p_sl->listener = ++pList->counter;
   p_sl->next = NULL;

   if( pList->last )
      pList->last->next = p_sl;
   else if( ! pList->first )
      pList->first = p_sl;
   pList->last = p_sl;

   return p_sl->listener;
}
set.c1145
VOIDhb_setListenerNotify( HB_set_enum set, HB_set_listener_enum when )
void hb_setListenerNotify( HB_set_enum set, HB_set_listener_enum when )
{
   PHB_SET_LISTENER_LST pList = ( PHB_SET_LISTENER_LST ) hb_stackSetStruct()->hb_set_listener;
   if( pList )
   {
      PHB_SET_LISTENER p_sl = pList->first;
      while( p_sl )
      {
         (* p_sl->callback)( set, when );
         p_sl = p_sl->next;
      }
   }
}
set.c1171
INThb_setListenerRemove( int listener )
int hb_setListenerRemove( int listener )
{
   PHB_SET_LISTENER_LST pList = ( PHB_SET_LISTENER_LST ) hb_stackSetStruct()->hb_set_listener;
   if( pList )
   {
      PHB_SET_LISTENER p_sl = pList->first;
      PHB_SET_LISTENER p_sl_prev = NULL;
      while( p_sl )
      {
         if( listener == p_sl->listener )
         {
            listener = -listener;
            if( p_sl_prev )
               p_sl_prev->next = p_sl->next;
            else
               pList->first = p_sl->next;
            if( p_sl == pList->last )
               pList->last = p_sl_prev;
            hb_xfree( p_sl );
            break;
         }
         p_sl_prev = p_sl;
         p_sl = p_sl->next;
      }
   }
   return listener;
}
set.c1185
HB_EXPORT BOOLhb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem )
HB_EXPORT BOOL hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();
   BOOL fResult = FALSE;
   char * szValue;
   int iValue;

   if( pItem )
   {
      hb_setListenerNotify( set_specifier, HB_SET_LISTENER_BEFORE );

      switch( set_specifier )
      {
         case HB_SET_ALTERNATE:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_ALTERNATE = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_AUTOPEN:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_AUTOPEN = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_BELL:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_BELL = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_CANCEL:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_CANCEL = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_CONFIRM:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_CONFIRM = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_CONSOLE:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_CONSOLE = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_DEBUG:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_DEBUG = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_DELETED:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_DELETED = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_DELIMITERS:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_DELIMITERS = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_EOF:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_EOF = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_ESCAPE:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_ESCAPE = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_EXACT:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_EXACT = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_EXCLUSIVE:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_EXCLUSIVE = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_EXIT:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_EXIT = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_EXTRA:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_EXTRA = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_FIXED:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_FIXED = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_IDLEREPEAT:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_IDLEREPEAT = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_INSERT:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_INSERT = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_INTENSITY:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_INTENSITY = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_MCENTER:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_MCENTER = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_OPTIMIZE:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_OPTIMIZE = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_FORCEOPT:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_FORCEOPT = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_PRINTER:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_PRINTER = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_SCOREBOARD:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_SCOREBOARD = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_SCROLLBREAK:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_SCROLLBREAK = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_SOFTSEEK:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_SOFTSEEK = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_STRICTREAD:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_STRICTREAD = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_UNIQUE:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_UNIQUE = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_WRAP:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_WRAP = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_HARDCOMMIT:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_HARDCOMMIT = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_DEFEXTENSIONS:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_DEFEXTENSIONS = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;
         case HB_SET_TRIMFILENAME:
            if( HB_IS_LOGICAL( pItem ) )
            {
               pSet->HB_SET_TRIMFILENAME = hb_itemGetL( pItem );
               fResult = TRUE;
            }
            break;

         case HB_SET_MBLOCKSIZE:
            if( HB_IS_NUMERIC( pItem ) )
            {
               iValue = hb_itemGetNI( pItem );
               if( iValue >= 0 )
               {
                  pSet->HB_SET_MBLOCKSIZE = iValue;
                  fResult = TRUE;
               }
            }
            break;
         case HB_SET_DBFLOCKSCHEME:
            if( HB_IS_NUMERIC( pItem ) )
            {
               iValue = hb_itemGetNI( pItem );
               if( iValue >= 0 )
               {
                  pSet->HB_SET_DBFLOCKSCHEME = iValue;
                  fResult = TRUE;
               }
            }
            break;

         case HB_SET_MFILEEXT:
            if( HB_IS_STRING( pItem ) || HB_IS_NIL( pItem ) )
            {
               szValue = hb_strndup( hb_itemGetCPtr( pItem ), USHRT_MAX );
               if( pSet->HB_SET_MFILEEXT )
                  hb_xfree( pSet->HB_SET_MFILEEXT );
               pSet->HB_SET_MFILEEXT = szValue;
               fResult = TRUE;
            }
            break;

         case HB_SET_ALTFILE:
         case HB_SET_AUTORDER:
         case HB_SET_AUTOSHARE:
         case HB_SET_COLOR:
         case HB_SET_CURSOR:
         case HB_SET_DATEFORMAT:
         case HB_SET_DECIMALS:
         case HB_SET_DEFAULT:
         case HB_SET_DELIMCHARS:
         case HB_SET_DEVICE:
         case HB_SET_EPOCH:
         case HB_SET_EVENTMASK:
         case HB_SET_EXTRAFILE:
         case HB_SET_MARGIN:
         case HB_SET_MESSAGE:
         case HB_SET_PATH:
         case HB_SET_PRINTFILE:
         case HB_SET_TYPEAHEAD:
         case HB_SET_VIDEOMODE:
         case HB_SET_LANGUAGE:
         case HB_SET_CODEPAGE:
         case HB_SET_FILECASE:
         case HB_SET_DIRCASE:
         case HB_SET_DIRSEPARATOR:
         case HB_SET_EOL:
         case HB_SET_HBOUTLOG:
         case HB_SET_HBOUTLOGINFO:
         case HB_SET_INVALID_:
            break;
#if 0
         /*
          * intentionally removed default: clause to enable C compiler warning
          * when not all HB_SET_* cases are implemented. [druzus]
          */
         default:
            break;
#endif
      }
      hb_setListenerNotify( set_specifier, HB_SET_LISTENER_AFTER );
   }

   return fResult;
}
set.c1213
HB_EXPORT BOOLhb_setGetL( HB_set_enum set_specifier )
HB_EXPORT BOOL    hb_setGetL( HB_set_enum set_specifier )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();

   switch( set_specifier )
   {
      case HB_SET_ALTERNATE:
         return pSet->HB_SET_ALTERNATE;
      case HB_SET_AUTOPEN:
         return pSet->HB_SET_AUTOPEN;
      case HB_SET_BELL:
         return pSet->HB_SET_BELL;
      case HB_SET_CANCEL:
         return pSet->HB_SET_CANCEL;
      case HB_SET_CONFIRM:
         return pSet->HB_SET_CONFIRM;
      case HB_SET_CONSOLE:
         return pSet->HB_SET_CONSOLE;
      case HB_SET_DEBUG:
         return pSet->HB_SET_DEBUG;
      case HB_SET_DELETED:
         return pSet->HB_SET_DELETED;
      case HB_SET_DELIMITERS:
         return pSet->HB_SET_DELIMITERS;
      case HB_SET_EOF:
         return pSet->HB_SET_EOF;
      case HB_SET_ESCAPE:
         return pSet->HB_SET_ESCAPE;
      case HB_SET_EXACT:
         return pSet->HB_SET_EXACT;
      case HB_SET_EXCLUSIVE:
         return pSet->HB_SET_EXCLUSIVE;
      case HB_SET_EXIT:
         return pSet->HB_SET_EXIT;
      case HB_SET_EXTRA:
         return pSet->HB_SET_EXTRA;
      case HB_SET_FIXED:
         return pSet->HB_SET_FIXED;
      case HB_SET_IDLEREPEAT:
         return pSet->HB_SET_IDLEREPEAT;
      case HB_SET_INSERT:
         return pSet->HB_SET_INSERT;
      case HB_SET_INTENSITY:
         return pSet->HB_SET_INTENSITY;
      case HB_SET_MCENTER:
         return pSet->HB_SET_MCENTER;
      case HB_SET_OPTIMIZE:
         return pSet->HB_SET_OPTIMIZE;
      case HB_SET_FORCEOPT:
         return pSet->HB_SET_FORCEOPT;
      case HB_SET_PRINTER:
         return pSet->HB_SET_PRINTER;
      case HB_SET_SCOREBOARD:
         return pSet->HB_SET_SCOREBOARD;
      case HB_SET_SCROLLBREAK:
         return pSet->HB_SET_SCROLLBREAK;
      case HB_SET_SOFTSEEK:
         return pSet->HB_SET_SOFTSEEK;
      case HB_SET_STRICTREAD:
         return pSet->HB_SET_STRICTREAD;
      case HB_SET_UNIQUE:
         return pSet->HB_SET_UNIQUE;
      case HB_SET_WRAP:
         return pSet->HB_SET_WRAP;
      case HB_SET_HARDCOMMIT:
         return pSet->HB_SET_HARDCOMMIT;
      case HB_SET_DEFEXTENSIONS:
         return pSet->HB_SET_DEFEXTENSIONS;
      case HB_SET_TRIMFILENAME:
         return pSet->HB_SET_TRIMFILENAME;

      case HB_SET_ALTFILE:
      case HB_SET_AUTORDER:
      case HB_SET_AUTOSHARE:
      case HB_SET_COLOR:
      case HB_SET_CURSOR:
      case HB_SET_DATEFORMAT:
      case HB_SET_DECIMALS:
      case HB_SET_DEFAULT:
      case HB_SET_DELIMCHARS:
      case HB_SET_DEVICE:
      case HB_SET_EPOCH:
      case HB_SET_EVENTMASK:
      case HB_SET_EXTRAFILE:
      case HB_SET_MARGIN:
      case HB_SET_MBLOCKSIZE:
      case HB_SET_MESSAGE:
      case HB_SET_MFILEEXT:
      case HB_SET_PATH:
      case HB_SET_PRINTFILE:
      case HB_SET_TYPEAHEAD:
      case HB_SET_VIDEOMODE:
      case HB_SET_LANGUAGE:
      case HB_SET_CODEPAGE:
      case HB_SET_FILECASE:
      case HB_SET_DIRCASE:
      case HB_SET_DIRSEPARATOR:
      case HB_SET_DBFLOCKSCHEME:
      case HB_SET_EOL:
      case HB_SET_HBOUTLOG:
      case HB_SET_HBOUTLOGINFO:
      case HB_SET_INVALID_:
         break;
#if 0
      /*
       * intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
       */
      default:
         break;
#endif
   }

   hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, 0 );
   return FALSE;
}
set.c1529
HB_EXPORT CHAR *hb_setGetCPtr( HB_set_enum set_specifier )
HB_EXPORT char *  hb_setGetCPtr( HB_set_enum set_specifier )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();

   switch( set_specifier )
   {
      case HB_SET_ALTFILE:
         return pSet->HB_SET_ALTFILE;
      case HB_SET_COLOR:
         return pSet->HB_SET_COLOR;
      case HB_SET_DATEFORMAT:
         return pSet->HB_SET_DATEFORMAT;
      case HB_SET_DEFAULT:
         return pSet->HB_SET_DEFAULT;
      case HB_SET_DELIMCHARS:
         return pSet->HB_SET_DELIMCHARS;
      case HB_SET_DEVICE:
         return pSet->HB_SET_DEVICE;
      case HB_SET_EXTRAFILE:
         return pSet->HB_SET_EXTRAFILE;
      case HB_SET_PATH:
         return pSet->HB_SET_PATH;
      case HB_SET_MFILEEXT:
         return pSet->HB_SET_MFILEEXT;
      case HB_SET_PRINTFILE:
         return pSet->HB_SET_PRINTFILE;
      case HB_SET_EOL:
         return pSet->HB_SET_EOL;
      case HB_SET_HBOUTLOG:
         return pSet->HB_SET_HBOUTLOG;
      case HB_SET_HBOUTLOGINFO:
         return pSet->HB_SET_HBOUTLOGINFO;
      case HB_SET_LANGUAGE:
         return hb_langID();
      case HB_SET_CODEPAGE:
         return hb_cdpID();
      case HB_SET_ALTERNATE:
      case HB_SET_AUTOPEN:
      case HB_SET_AUTORDER:
      case HB_SET_AUTOSHARE:
      case HB_SET_BELL:
      case HB_SET_CANCEL:
      case HB_SET_CONFIRM:
      case HB_SET_CONSOLE:
      case HB_SET_CURSOR:
      case HB_SET_DEBUG:
      case HB_SET_DECIMALS:
      case HB_SET_DELETED:
      case HB_SET_DELIMITERS:
      case HB_SET_EOF:
      case HB_SET_EPOCH:
      case HB_SET_ESCAPE:
      case HB_SET_EVENTMASK:
      case HB_SET_EXACT:
      case HB_SET_EXCLUSIVE:
      case HB_SET_EXIT:
      case HB_SET_EXTRA:
      case HB_SET_FIXED:
      case HB_SET_INSERT:
      case HB_SET_INTENSITY:
      case HB_SET_MARGIN:
      case HB_SET_MBLOCKSIZE:
      case HB_SET_MCENTER:
      case HB_SET_MESSAGE:
      case HB_SET_OPTIMIZE:
      case HB_SET_FORCEOPT:
      case HB_SET_STRICTREAD:
      case HB_SET_HARDCOMMIT:
      case HB_SET_PRINTER:
      case HB_SET_SCOREBOARD:
      case HB_SET_SCROLLBREAK:
      case HB_SET_SOFTSEEK:
      case HB_SET_TYPEAHEAD:
      case HB_SET_UNIQUE:
      case HB_SET_VIDEOMODE:
      case HB_SET_WRAP:
      case HB_SET_IDLEREPEAT:
      case HB_SET_FILECASE:
      case HB_SET_DIRCASE:
      case HB_SET_DIRSEPARATOR:
      case HB_SET_DBFLOCKSCHEME:
      case HB_SET_DEFEXTENSIONS:
      case HB_SET_TRIMFILENAME:
      case HB_SET_INVALID_:
         break;
#if 0
      /*
       * intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
       */
      default:
         break;
#endif
   }

   hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, 0 );
   return FALSE;
}
set.c1646
HB_EXPORT INThb_setGetNI( HB_set_enum set_specifier )
HB_EXPORT int     hb_setGetNI( HB_set_enum set_specifier )
{
   PHB_SET_STRUCT pSet = hb_stackSetStruct();

   switch( set_specifier )
   {
      case HB_SET_AUTORDER:
         return pSet->HB_SET_AUTORDER;
      case HB_SET_AUTOSHARE:
         return pSet->HB_SET_AUTOSHARE;
      case HB_SET_DECIMALS:
         return pSet->HB_SET_DECIMALS;
      case HB_SET_EPOCH:
         return pSet->HB_SET_EPOCH;
      case HB_SET_EVENTMASK:
         return pSet->HB_SET_EVENTMASK;
      case HB_SET_MARGIN:
         return pSet->HB_SET_MARGIN;
      case HB_SET_MBLOCKSIZE:
         return pSet->HB_SET_MBLOCKSIZE;
      case HB_SET_MESSAGE:
         return pSet->HB_SET_MESSAGE;
      case HB_SET_TYPEAHEAD:
         return pSet->HB_SET_TYPEAHEAD;
      case HB_SET_FILECASE:
         return pSet->HB_SET_FILECASE;
      case HB_SET_DIRCASE:
         return pSet->HB_SET_DIRCASE;
      case HB_SET_DIRSEPARATOR:
         return pSet->HB_SET_DIRSEPARATOR;
      case HB_SET_VIDEOMODE:
         return pSet->HB_SET_VIDEOMODE;
      case HB_SET_DBFLOCKSCHEME:
         return pSet->HB_SET_DBFLOCKSCHEME;

      case HB_SET_ALTERNATE:
      case HB_SET_ALTFILE:
      case HB_SET_AUTOPEN:
      case HB_SET_BELL:
      case HB_SET_CANCEL:
      case HB_SET_COLOR:
      case HB_SET_CONFIRM:
      case HB_SET_CONSOLE:
      case HB_SET_CURSOR:
      case HB_SET_DATEFORMAT:
      case HB_SET_DEBUG:
      case HB_SET_DEFAULT:
      case HB_SET_DELETED:
      case HB_SET_DELIMCHARS:
      case HB_SET_DELIMITERS:
      case HB_SET_DEVICE:
      case HB_SET_EOF:
      case HB_SET_ESCAPE:
      case HB_SET_EXACT:
      case HB_SET_EXCLUSIVE:
      case HB_SET_EXIT:
      case HB_SET_EXTRA:
      case HB_SET_EXTRAFILE:
      case HB_SET_FIXED:
      case HB_SET_INSERT:
      case HB_SET_INTENSITY:
      case HB_SET_MCENTER:
      case HB_SET_MFILEEXT:
      case HB_SET_OPTIMIZE:
      case HB_SET_FORCEOPT:
      case HB_SET_STRICTREAD:
      case HB_SET_HARDCOMMIT:
      case HB_SET_PATH:
      case HB_SET_PRINTER:
      case HB_SET_PRINTFILE:
      case HB_SET_SCOREBOARD:
      case HB_SET_SCROLLBREAK:
      case HB_SET_SOFTSEEK:
      case HB_SET_UNIQUE:
      case HB_SET_WRAP:
      case HB_SET_LANGUAGE:
      case HB_SET_CODEPAGE:
      case HB_SET_IDLEREPEAT:
      case HB_SET_EOL:
      case HB_SET_DEFEXTENSIONS:
      case HB_SET_TRIMFILENAME:
      case HB_SET_HBOUTLOG:
      case HB_SET_HBOUTLOGINFO:
      case HB_SET_INVALID_:
         break;
#if 0
      /*
       * intentionally removed default: clause to enable C compiler warning
       * when not all HB_SET_* cases are implemented. [druzus]
       */
      default:
         break;
#endif
   }

   hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, 0 );
   return FALSE;
}
set.c1745
HB_EXPORT LONGhb_setGetNL( HB_set_enum set_specifier )
HB_EXPORT long    hb_setGetNL( HB_set_enum set_specifier )
{
   return hb_setGetNI( set_specifier );
}
set.c1844
HB_EXPORT HB_PATHNAMES *hb_setGetFirstSetPath( void )
HB_EXPORT HB_PATHNAMES * hb_setGetFirstSetPath( void )
{
   return hb_stackSetStruct()->hb_set_path;
}
set.c1849
HB_EXPORT HB_FHANDLEhb_setGetAltHan( void )
HB_EXPORT HB_FHANDLE hb_setGetAltHan( void )
{
   return hb_stackSetStruct()->hb_set_althan;
}
set.c1855
HB_EXPORT BOOLhb_setGetCentury( void )
HB_EXPORT BOOL    hb_setGetCentury( void )
{
   return hb_stackSetStruct()->hb_set_century;
}
set.c1860
HB_EXPORT HB_FHANDLEhb_setGetExtraHan( void )
HB_EXPORT HB_FHANDLE hb_setGetExtraHan( void )
{
   return hb_stackSetStruct()->hb_set_extrahan;
}
set.c1865
HB_EXPORT HB_FHANDLEhb_setGetPrintHan( void )
HB_EXPORT HB_FHANDLE hb_setGetPrintHan( void )
{
   return hb_stackSetStruct()->hb_set_printhan;
}
set.c1870
HB_EXPORT BOOLhb_setGetAlternate( void )
HB_EXPORT BOOL    hb_setGetAlternate( void )
{
   return hb_stackSetStruct()->HB_SET_ALTERNATE;
}
set.c1875
HB_EXPORT CHAR *hb_setGetAltFile( void )
HB_EXPORT char *  hb_setGetAltFile( void )
{
   return hb_stackSetStruct()->HB_SET_ALTFILE;
}
set.c1880
HB_EXPORT BOOLhb_setGetAutOpen( void )
HB_EXPORT BOOL    hb_setGetAutOpen( void )
{
   return hb_stackSetStruct()->HB_SET_AUTOPEN;
}
set.c1885
HB_EXPORT INThb_setGetAutOrder( void )
HB_EXPORT int     hb_setGetAutOrder( void )
{
   return hb_stackSetStruct()->HB_SET_AUTORDER;
}
set.c1890
HB_EXPORT INThb_setGetAutoShare( void )
HB_EXPORT int     hb_setGetAutoShare( void )
{
   return hb_stackSetStruct()->HB_SET_AUTOSHARE;
}
set.c1895
HB_EXPORT BOOLhb_setGetBell( void )
HB_EXPORT BOOL    hb_setGetBell( void )
{
   return hb_stackSetStruct()->HB_SET_BELL;
}
set.c1900
HB_EXPORT BOOLhb_setGetCancel( void )
HB_EXPORT BOOL    hb_setGetCancel( void )
{
   return hb_stackSetStruct()->HB_SET_CANCEL;
}
set.c1905
HB_EXPORT CHAR *hb_setGetColor( void )
HB_EXPORT char *  hb_setGetColor( void )
{
   return hb_stackSetStruct()->HB_SET_COLOR;
}
set.c1910
HB_EXPORT BOOLhb_setGetConfirm( void )
HB_EXPORT BOOL    hb_setGetConfirm( void )
{
   return hb_stackSetStruct()->HB_SET_CONFIRM;
}
set.c1915
HB_EXPORT BOOLhb_setGetConsole( void )
HB_EXPORT BOOL    hb_setGetConsole( void )
{
   return hb_stackSetStruct()->HB_SET_CONSOLE;
}
set.c1920
HB_EXPORT CHAR *hb_setGetDateFormat( void )
HB_EXPORT char *  hb_setGetDateFormat( void )
{
   return hb_stackSetStruct()->HB_SET_DATEFORMAT;
}
set.c1925
HB_EXPORT BOOLhb_setGetDebug( void )
HB_EXPORT BOOL    hb_setGetDebug( void )
{
   return hb_stackSetStruct()->HB_SET_DEBUG;
}
set.c1930
HB_EXPORT INThb_setGetDecimals( void )
HB_EXPORT int     hb_setGetDecimals( void )
{
   return hb_stackSetStruct()->HB_SET_DECIMALS;
}
set.c1935
HB_EXPORT CHAR *hb_setGetDefault( void )
HB_EXPORT char *  hb_setGetDefault( void )
{
   return hb_stackSetStruct()->HB_SET_DEFAULT;
}
set.c1940
HB_EXPORT BOOLhb_setGetDeleted( void )
HB_EXPORT BOOL    hb_setGetDeleted( void )
{
   return hb_stackSetStruct()->HB_SET_DELETED;
}
set.c1945
HB_EXPORT CHAR *hb_setGetDelimChars( void )
HB_EXPORT char *  hb_setGetDelimChars( void )
{
   return hb_stackSetStruct()->HB_SET_DELIMCHARS;
}
set.c1950
HB_EXPORT BOOLhb_setGetDelimiters( void )
HB_EXPORT BOOL    hb_setGetDelimiters( void )
{
   return hb_stackSetStruct()->HB_SET_DELIMITERS;
}
set.c1955
HB_EXPORT CHAR *hb_setGetDevice( void )
HB_EXPORT char *  hb_setGetDevice( void )
{
   return hb_stackSetStruct()->HB_SET_DEVICE;
}
set.c1960
HB_EXPORT BOOLhb_setGetEOF( void )
HB_EXPORT BOOL    hb_setGetEOF( void )
{
   return hb_stackSetStruct()->HB_SET_EOF;
}
set.c1965
HB_EXPORT INThb_setGetEpoch( void )
HB_EXPORT int     hb_setGetEpoch( void )
{
   return hb_stackSetStruct()->HB_SET_EPOCH;
}
set.c1970
HB_EXPORT BOOLhb_setGetEscape( void )
HB_EXPORT BOOL    hb_setGetEscape( void )
{
   return hb_stackSetStruct()->HB_SET_ESCAPE;
}
set.c1975
HB_EXPORT INThb_setGetEventMask( void )
HB_EXPORT int     hb_setGetEventMask( void )
{
   return hb_stackSetStruct()->HB_SET_EVENTMASK;
}
set.c1980
HB_EXPORT BOOLhb_setGetExact( void )
HB_EXPORT BOOL    hb_setGetExact( void )
{
   return hb_stackSetStruct()->HB_SET_EXACT;
}
set.c1985
HB_EXPORT BOOLhb_setGetExclusive( void )
HB_EXPORT BOOL    hb_setGetExclusive( void )
{
   return hb_stackSetStruct()->HB_SET_EXCLUSIVE;
}
set.c1990
HB_EXPORT BOOLhb_setGetExit( void )
HB_EXPORT BOOL    hb_setGetExit( void )
{
   return hb_stackSetStruct()->HB_SET_EXIT;
}
set.c1995
HB_EXPORT BOOLhb_setGetExtra( void )
HB_EXPORT BOOL    hb_setGetExtra( void )
{
   return hb_stackSetStruct()->HB_SET_EXTRA;
}
set.c2000
HB_EXPORT CHAR *hb_setGetExtraFile( void )
HB_EXPORT char *  hb_setGetExtraFile( void )
{
   return hb_stackSetStruct()->HB_SET_EXTRAFILE;
}
set.c2005
HB_EXPORT BOOLhb_setGetFixed( void )
HB_EXPORT BOOL    hb_setGetFixed( void )
{
   return hb_stackSetStruct()->HB_SET_FIXED;
}
set.c2010
HB_EXPORT BOOLhb_setGetIdleRepeat( void )
HB_EXPORT BOOL    hb_setGetIdleRepeat( void )
{
   return hb_stackSetStruct()->HB_SET_IDLEREPEAT;
}
set.c2015
HB_EXPORT BOOLhb_setGetInsert( void )
HB_EXPORT BOOL    hb_setGetInsert( void )
{
   return hb_stackSetStruct()->HB_SET_INSERT;
}
set.c2020
HB_EXPORT BOOLhb_setGetIntensity( void )
HB_EXPORT BOOL    hb_setGetIntensity( void )
{
   return hb_stackSetStruct()->HB_SET_INTENSITY;
}
set.c2025
HB_EXPORT CHAR *hb_setGetPath( void )
HB_EXPORT char *  hb_setGetPath( void )
{
   return hb_stackSetStruct()->HB_SET_PATH;
}
set.c2030
HB_EXPORT INThb_setGetMargin( void )
HB_EXPORT int     hb_setGetMargin( void )
{
   return hb_stackSetStruct()->HB_SET_MARGIN;
}
set.c2035
HB_EXPORT INThb_setGetMBlockSize( void )
HB_EXPORT int     hb_setGetMBlockSize( void )
{
   return hb_stackSetStruct()->HB_SET_MBLOCKSIZE;
}
set.c2040
HB_EXPORT BOOLhb_setGetMCenter( void )
HB_EXPORT BOOL    hb_setGetMCenter( void )
{
   return hb_stackSetStruct()->HB_SET_MCENTER;
}
set.c2045
HB_EXPORT INThb_setGetMessage( void )
HB_EXPORT int     hb_setGetMessage( void )
{
   return hb_stackSetStruct()->HB_SET_MESSAGE;
}
set.c2050
HB_EXPORT CHAR *hb_setGetMFileExt( void )
HB_EXPORT char *  hb_setGetMFileExt( void )
{
   return hb_stackSetStruct()->HB_SET_MFILEEXT;
}
set.c2055
HB_EXPORT BOOLhb_setGetOptimize( void )
HB_EXPORT BOOL    hb_setGetOptimize( void )
{
   return hb_stackSetStruct()->HB_SET_OPTIMIZE;
}
set.c2060
HB_EXPORT BOOLhb_setGetPrinter( void )
HB_EXPORT BOOL    hb_setGetPrinter( void )
{
   return hb_stackSetStruct()->HB_SET_PRINTER;
}
set.c2065
HB_EXPORT CHAR *hb_setGetPrintFile( void )
HB_EXPORT char *  hb_setGetPrintFile( void )
{
   return hb_stackSetStruct()->HB_SET_PRINTFILE;
}
set.c2070
HB_EXPORT BOOLhb_setGetScoreBoard( void )
HB_EXPORT BOOL    hb_setGetScoreBoard( void )
{
   return hb_stackSetStruct()->HB_SET_SCOREBOARD;
}
set.c2075
HB_EXPORT BOOLhb_setGetScrollBreak( void )
HB_EXPORT BOOL    hb_setGetScrollBreak( void )
{
   return hb_stackSetStruct()->HB_SET_SCROLLBREAK;
}
set.c2080
HB_EXPORT BOOLhb_setGetSoftSeek( void )
HB_EXPORT BOOL    hb_setGetSoftSeek( void )
{
   return hb_stackSetStruct()->HB_SET_SOFTSEEK;
}
set.c2085
HB_EXPORT BOOLhb_setGetStrictRead( void )
HB_EXPORT BOOL    hb_setGetStrictRead( void )
{
   return hb_stackSetStruct()->HB_SET_STRICTREAD;
}
set.c2090
HB_EXPORT INThb_setGetTypeAhead( void )
HB_EXPORT int     hb_setGetTypeAhead( void )
{
   return hb_stackSetStruct()->HB_SET_TYPEAHEAD;
}
set.c2095
HB_EXPORT BOOLhb_setGetUnique( void )
HB_EXPORT BOOL    hb_setGetUnique( void )
{
   return hb_stackSetStruct()->HB_SET_UNIQUE;
}
set.c2100
HB_EXPORT INThb_setGetFileCase( void )
HB_EXPORT int     hb_setGetFileCase( void )
{
   return hb_stackSetStruct()->HB_SET_FILECASE;
}
set.c2105
HB_EXPORT INThb_setGetDirCase( void )
HB_EXPORT int     hb_setGetDirCase( void )
{
   return hb_stackSetStruct()->HB_SET_DIRCASE;
}
set.c2110
HB_EXPORT INThb_setGetDirSeparator( void )
HB_EXPORT int     hb_setGetDirSeparator( void )
{
   return hb_stackSetStruct()->HB_SET_DIRSEPARATOR;
}
set.c2115
HB_EXPORT INThb_setGetVideoMode( void )
HB_EXPORT int     hb_setGetVideoMode( void )
{
   return hb_stackSetStruct()->HB_SET_VIDEOMODE;
}
set.c2120
HB_EXPORT BOOLhb_setGetWrap( void )
HB_EXPORT BOOL    hb_setGetWrap( void )
{
   return hb_stackSetStruct()->HB_SET_WRAP;
}
set.c2125
HB_EXPORT INThb_setGetDBFLockScheme( void )
HB_EXPORT int     hb_setGetDBFLockScheme( void )
{
   return hb_stackSetStruct()->HB_SET_DBFLOCKSCHEME;
}
set.c2130
HB_EXPORT BOOLhb_setGetHardCommit( void )
HB_EXPORT BOOL    hb_setGetHardCommit( void )
{
   return hb_stackSetStruct()->HB_SET_HARDCOMMIT;
}
set.c2135
HB_EXPORT BOOLhb_setGetForceOpt( void )
HB_EXPORT BOOL    hb_setGetForceOpt( void )
{
   return hb_stackSetStruct()->HB_SET_FORCEOPT;
}
set.c2140
HB_EXPORT BOOLhb_setGetDefExtension( void )
HB_EXPORT BOOL    hb_setGetDefExtension( void )
{
   return hb_stackSetStruct()->HB_SET_DEFEXTENSIONS;
}
set.c2145
HB_EXPORT CHAR *hb_setGetEOL( void )
HB_EXPORT char *  hb_setGetEOL( void )
{
   return hb_stackSetStruct()->HB_SET_EOL;
}
set.c2150
HB_EXPORT BOOLhb_setGetTrimFileName( void )
HB_EXPORT BOOL    hb_setGetTrimFileName( void )
{
   return hb_stackSetStruct()->HB_SET_TRIMFILENAME;
}
set.c2155
HB_EXPORT CHAR *hb_setGetHBOUTLOG( void )
HB_EXPORT char *  hb_setGetHBOUTLOG( void )
{
   return hb_stackSetStruct()->HB_SET_HBOUTLOG;
}
set.c2160
HB_EXPORT CHAR *hb_setGetHBOUTLOGINFO( void )
HB_EXPORT char *  hb_setGetHBOUTLOGINFO( void )
{
   return hb_stackSetStruct()->HB_SET_HBOUTLOGINFO;
}
set.c2165
thread.c
TypeFunctionSourceLine
STATIC VOIDhb_threadTimeInit( struct timespec * ts, ULONG ulMilliSec )
   static void hb_threadTimeInit( struct timespec * ts, ULONG ulMilliSec )
   {
#     if _POSIX_C_SOURCE >= 199309L
      clock_gettime( CLOCK_REALTIME, ts );
#     else
      struct timeval tv;
      gettimeofday( &tv, NULL );
      ts->tv_sec  = tv.tv_sec;
      ts->tv_nsec = tv.tv_usec * 1000l;
#     endif
      ts->tv_nsec += ( ulMilliSec % 1000 ) * 1000000l;
      ts->tv_sec  += ulMilliSec / 1000 + ts->tv_nsec / 1000000000l;
      ts->tv_nsec %= 1000000000l;
   }
#  endif

#  if defined( HB_CRITICAL_INIT )
   static HB_RAWCRITICAL_T s_critical_init;
thread.c85
STATIC VOIDhb_threadCriticalInit( HB_CRITICAL_T * critical )
   static void hb_threadCriticalInit( HB_CRITICAL_T * critical )
   {
      if( !s_fThreadInit )
         hb_threadInit();

      HB_CRITICAL_LOCK( s_critical_init );
      if( !critical->fInit )
      {
         HB_CRITICAL_INIT( critical->critical );
         critical->fInit = TRUE;
      }
      HB_CRITICAL_UNLOCK( s_critical_init );
   }
#  else
   static HB_CRITICAL_NEW( s_critical_init );
thread.c103
STATIC VOIDhb_threadCondInit( HB_COND_T * cond )
      static void hb_threadCondInit( HB_COND_T * cond )
      {
         if( !s_fThreadInit )
            hb_threadInit();

         HB_CRITICAL_LOCK( s_critical_init );
         if( !cond->fInit )
         {
            HB_COND_INIT( cond->cond );
#     if defined( HB_CRITICAL_INIT )
            HB_CRITICAL_INIT( cond->critical );
#     endif
            cond->waiters = 0;
            cond->fInit = TRUE;
         }
         HB_CRITICAL_UNLOCK( s_critical_init );
      }
thread.c121
VOIDhb_threadInit( void )
void hb_threadInit( void )
{
   if( !s_fThreadInit )
   {
#if !defined( HB_MT_VM )
      /* nothing to do */
#elif defined( HB_CRITICAL_INIT )
      HB_CRITICAL_INIT( s_critical_init );
#endif
      s_fThreadInit = TRUE;
   }
}
thread.c142
VOIDhb_threadExit( void )
void hb_threadExit( void )
{
   if( s_fThreadInit )
   {
      s_fThreadInit = FALSE;
#if !defined( HB_MT_VM )
      /* nothing to do */
#elif defined( HB_CRITICAL_DESTROY )
      HB_CRITICAL_DESTROY( s_critical_init );
#endif
   }
}
thread.c155
VOIDhb_threadEnterCriticalSection( HB_CRITICAL_T * critical )
void hb_threadEnterCriticalSection( HB_CRITICAL_T * critical )
{
#if !defined( HB_MT_VM )
   HB_SYMBOL_UNUSED( critical );
#elif defined( HB_CRITICAL_INIT )
   if( !critical->fInit )
      hb_threadCriticalInit( critical );
   HB_CRITICAL_LOCK( critical->critical );
#else
   HB_CRITICAL_LOCK( *critical );
#endif
}
thread.c168
VOIDhb_threadLeaveCriticalSection( HB_CRITICAL_T * critical )
void hb_threadLeaveCriticalSection( HB_CRITICAL_T * critical )
{
#if !defined( HB_MT_VM )
   HB_SYMBOL_UNUSED( critical );
#elif defined( HB_CRITICAL_INIT )
   HB_CRITICAL_UNLOCK( critical->critical );
#else
   HB_CRITICAL_UNLOCK( *critical );
#endif
}
thread.c181
BOOLhb_threadCondSignal( HB_COND_T * cond )
BOOL hb_threadCondSignal( HB_COND_T * cond )
{
#if !defined( HB_MT_VM )

   HB_SYMBOL_UNUSED( cond );
   return FALSE;

#elif defined( HB_PTHREAD_API )

#  if defined( HB_COND_INIT )
      if( !cond->fInit )
         hb_threadCondInit( cond );
#  endif
   return pthread_cond_signal( HB_COND_GET( cond ) ) == 0;

#else

   if( !cond->fInit )
      hb_threadCondInit( cond );

   HB_CRITICAL_LOCK( cond->critical );
   if( cond->waiters )
   {
      HB_COND_SIGNAL( cond->cond );
      cond->waiters--;
   }
   HB_CRITICAL_UNLOCK( cond->critical );

   return TRUE;

#endif
}
thread.c192
BOOLhb_threadCondBroadcast( HB_COND_T * cond )
BOOL hb_threadCondBroadcast( HB_COND_T * cond )
{
#if !defined( HB_MT_VM )

   HB_SYMBOL_UNUSED( cond );
   return FALSE;

#elif defined( HB_PTHREAD_API )

#  if defined( HB_COND_INIT )
      if( !cond->fInit )
         hb_threadCondInit( cond );
#  endif
   return pthread_cond_broadcast( HB_COND_GET( cond ) ) == 0;

#else

   if( !cond->fInit )
      hb_threadCondInit( cond );

   HB_CRITICAL_LOCK( cond->critical );
   if( cond->waiters )
   {
      HB_COND_SIGNALN( cond->cond, cond->waiters );
      cond->waiters = 0;
   }
   HB_CRITICAL_UNLOCK( cond->critical );

   return TRUE;

#endif
}
thread.c225
BOOLhb_threadCondWait( HB_COND_T * cond, HB_CRITICAL_T * mutex )
BOOL hb_threadCondWait( HB_COND_T * cond, HB_CRITICAL_T * mutex )
{
#if !defined( HB_MT_VM )

   HB_SYMBOL_UNUSED( cond );
   HB_SYMBOL_UNUSED( mutex );
   return FALSE;

#elif defined( HB_PTHREAD_API )

#  if defined( HB_COND_INIT )
      if( !cond->fInit )
         hb_threadCondInit( cond );
#  endif
   return pthread_cond_wait( HB_COND_GET( cond ), HB_CRITICAL_GET( mutex ) ) == 0;

#else

   BOOL fResult;

   if( !cond->fInit )
      hb_threadCondInit( cond );

   /* mutex should be already locked so it's not necessary
    * to make initialization test here
    */

   HB_CRITICAL_LOCK( cond->critical );
   cond->waiters++;
   HB_CRITICAL_UNLOCK( cond->critical );

   HB_CRITICAL_UNLOCK( mutex->critical );
   fResult = HB_COND_WAIT( cond->cond );
   HB_CRITICAL_LOCK( mutex->critical );

   return fResult;

#endif
}
thread.c258
BOOLhb_threadCondTimedWait( HB_COND_T * cond, HB_CRITICAL_T * mutex, ULONG ulMilliSec )
BOOL hb_threadCondTimedWait( HB_COND_T * cond, HB_CRITICAL_T * mutex, ULONG ulMilliSec )
{
#if !defined( HB_MT_VM )

   HB_SYMBOL_UNUSED( cond );
   HB_SYMBOL_UNUSED( mutex );
   HB_SYMBOL_UNUSED( ulMilliSec );
   return FALSE;

#elif defined( HB_PTHREAD_API )
   struct timespec ts;

#  if defined( HB_COND_INIT )
      if( !cond->fInit )
         hb_threadCondInit( cond );
#  endif
   hb_threadTimeInit( &ts, ulMilliSec );
   return pthread_cond_timedwait( HB_COND_GET( cond ), HB_CRITICAL_GET( mutex ), &ts ) == 0;

#else

   BOOL fResult;

   if( !cond->fInit )
      hb_threadCondInit( cond );

   /* mutex should be already locked so it's not necessary
    * to make initialization test here
    */

   HB_CRITICAL_LOCK( cond->critical );
   cond->waiters++;
   HB_CRITICAL_UNLOCK( cond->critical );

   HB_CRITICAL_UNLOCK( mutex->critical );
   fResult = HB_COND_TIMEDWAIT( cond->cond, ulMilliSec );
   HB_CRITICAL_LOCK( mutex->critical );

   return fResult;

#endif
}
thread.c298
HB_THREAD_Thb_threadCreate( PHB_THREAD_STARTFUNC start_func, void * Cargo )
HB_THREAD_T hb_threadCreate( PHB_THREAD_STARTFUNC start_func, void * Cargo )
{
   HB_THREAD_T th_id;

#if !defined( HB_MT_VM )
   HB_SYMBOL_UNUSED( start_func );
   HB_SYMBOL_UNUSED( Cargo );
   th_id = 0;
#elif defined( HB_PTHREAD_API )
   if( pthread_create( &th_id, NULL, start_func, Cargo ) != 0 )
      th_id = 0;
#elif defined( HB_OS_WIN_32 )
   th_id = ( HANDLE ) _beginthreadex( NULL, 0, start_func, Cargo, 0, NULL );
#elif defined( HB_OS_OS2 )
   th_id = _beginthread( ( void * ) start_func, NULL, 128 * 1024, Cargo );
#else
   { int TODO_MT; }
   th_id = 0;
#endif

   return th_id;
}
thread.c341
BOOLhb_threadJoin( HB_THREAD_T th_id )
BOOL hb_threadJoin( HB_THREAD_T th_id )
{
#if !defined( HB_MT_VM )
   HB_SYMBOL_UNUSED( th_id );
   return FALSE;
#elif defined( HB_PTHREAD_API )
   return pthread_join( th_id, NULL ) == 0;
#elif defined( HB_OS_WIN_32 )
   if( WaitForSingleObject( th_id, INFINITE ) != WAIT_FAILED )
   {
      CloseHandle( th_id );
      return TRUE;
   }
   return FALSE;
#elif defined( HB_OS_OS2 )
   APIRET rc = DosWaitThread( &th_id, DCWW_WAIT );
   /* TOFIX: ERROR_INVALID_THREADID is a hack for failing DosWaitThread()
    *        when thread terminates before DosWaitThread() call.
    *        OS2 users please check and fix this code if possible.
    */
   return rc == NO_ERROR || rc == ERROR_INVALID_THREADID;
#else
   { int TODO_MT; }
   return FALSE;
#endif
}
thread.c364
BOOLhb_threadDetach( HB_THREAD_T th_id )
BOOL hb_threadDetach( HB_THREAD_T th_id )
{
#if !defined( HB_MT_VM )
   HB_SYMBOL_UNUSED( th_id );
   return FALSE;
#elif defined( HB_PTHREAD_API )
   return pthread_detach( th_id ) == 0;
#elif defined( HB_OS_WIN_32 )
   return CloseHandle( th_id ) != 0;
#elif defined( HB_OS_OS2 )
   APIRET rc = DosWaitThread( &th_id, DCWW_NOWAIT );
   return rc == NO_ERROR || rc == ERROR_INVALID_THREADID;
#else
   { int TODO_MT; }
   return FALSE;
#endif
}

thread.c391
STATIC HB_GARBAGE_FUNC(hb_threadDestructor )
static HB_GARBAGE_FUNC( hb_threadDestructor )
{
   PHB_THREADSTATE pThread = ( PHB_THREADSTATE ) Cargo;

   if( pThread->pParams )
   {
      hb_itemRelease( pThread->pParams );
      pThread->pParams = NULL;
   }
   if( pThread->pMemvars )
   {
      hb_itemRelease( pThread->pMemvars );
      pThread->pMemvars = NULL;
   }
   if( pThread->pResult )
   {
      hb_itemRelease( pThread->pResult );
      pThread->pResult = NULL;
   }
   if( pThread->pSet )
   {
      hb_setRelease( pThread->pSet );
      hb_xfree( pThread->pSet );
      pThread->pSet = NULL;
   }
   if( pThread->th_id != 0 )
   {
      hb_threadDetach( pThread->th_id );
      pThread->th_id = 0;
   }
}
thread.c415
STATIC HB_THREAD_STARTFUNC(hb_threadStartVM )
static HB_THREAD_STARTFUNC( hb_threadStartVM )
{
#if defined( HB_MT_VM )
   PHB_ITEM pThItm = ( PHB_ITEM ) Cargo;
   ULONG ulPCount, ulParam;
   PHB_THREADSTATE pThread;

   pThread = ( PHB_THREADSTATE ) hb_itemGetPtrGC( pThItm, hb_threadDestructor );

   hb_vmThreadInit( ( void * ) pThread );

   ulPCount = hb_arrayLen( pThread->pParams );
   if( ulPCount > 0 )
   {
      PHB_ITEM pStart = hb_arrayGetItemPtr( pThread->pParams, 1 );

      if( HB_IS_BLOCK( pStart ) )
      {
         hb_vmPushSymbol( &hb_symEval );
         hb_vmPush( pStart );
      }
      else if( HB_IS_SYMBOL( pStart ) )
      {
         hb_vmPush( pStart );
         hb_vmPushNil();
      }
      else if( HB_IS_STRING( pStart ) )
      {
         hb_vmPushDynSym( hb_dynsymGet( hb_itemGetCPtr( pStart ) ) );
         hb_vmPushNil();
      }
      else
         ulPCount = 0;
   }

   if( ulPCount > 0 )
   {
      for( ulParam = 2; ulParam <= ulPCount; ++ulParam )
         hb_vmPush( hb_arrayGetItemPtr( pThread->pParams, ulParam ) );

      hb_itemRelease( pThread->pParams );
      pThread->pParams = NULL;

      hb_vmDo( ( USHORT ) ( ulPCount - 1 ) );
   }
   else
   {
      hb_itemRelease( pThread->pParams );
      pThread->pParams = NULL;
      if( pThread->pMemvars )
      {
         hb_itemRelease( pThread->pMemvars );
         pThread->pMemvars = NULL;
      }

      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 0 );
   }

   /* hb_vmThreadQuit() unlocks and release HVM stack and may release
    * also pThItm item so we should not access any HVM items or
    * pThread structure after this function.
    */
   hb_vmThreadQuit();

   HB_THREAD_END
#else
   hb_itemRelease( ( PHB_ITEM ) Cargo );
   HB_THREAD_RAWEND
#endif
}
thread.c447
PHB_THREADSTATEhb_threadStateNew( void )
PHB_THREADSTATE hb_threadStateNew( void )
{
   PHB_ITEM pThItm;
   PHB_THREADSTATE pThread;

   pThItm = hb_itemNew( NULL );
   pThread = ( PHB_THREADSTATE )
                  hb_gcAlloc( sizeof( HB_THREADSTATE ), hb_threadDestructor );
   memset( pThread, 0, sizeof( HB_THREADSTATE ) );
   hb_itemPutPtrGC( pThItm, pThread );

   pThread->pszCDP  = HB_MACRO2STRING( HB_CODEPAGE_DEFAULT );
   pThread->pszLang = HB_MACRO2STRING( HB_LANG_DEFAULT );
   pThread->pThItm  = pThItm;

   return pThread;
}
thread.c518
STATIC PHB_THREADSTATEhb_thParam( int iParam )
static PHB_THREADSTATE hb_thParam( int iParam )
{
   PHB_THREADSTATE pThread = ( PHB_THREADSTATE ) hb_parptrGC( hb_threadDestructor, iParam );

   if( pThread )
      return pThread;

   hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   return NULL;
}
thread.c536
HB_FUNCHB_THREADSTART(void)
HB_FUNC( HB_THREADSTART )
{
   ULONG ulAttr = 0, ulStart = 1;
   const char * szFuncName = NULL;
   PHB_SYMB pSymbol = NULL;
   PHB_ITEM pStart;

   pStart = hb_param( ulStart, HB_IT_ANY );
   while( pStart && HB_IS_NUMERIC( pStart ) )
   {
      ulAttr |= ( ULONG ) hb_itemGetNL( pStart );
      pStart = hb_param( ++ulStart, HB_IT_ANY );
   }

   if( pStart )
   {
      if( HB_IS_STRING( pStart ) )
      {
         PHB_DYNS pDynSym;
         szFuncName = hb_itemGetCPtr( pStart );
         pDynSym = hb_dynsymFindName( szFuncName );
         if( pDynSym )
            pSymbol = pDynSym->pSymbol;
         if( !pSymbol || !pSymbol->value.pFunPtr )
            pStart = NULL;
      }
      else if( HB_IS_SYMBOL( pStart ) )
      {
         pSymbol = hb_itemGetSymbol( pStart );
         if( !pSymbol->value.pFunPtr )
         {
            szFuncName = pSymbol->szName;
            pStart = NULL;
         }
      }
      else if( !HB_IS_BLOCK( pStart ) )
         pStart = NULL;
   }

   if( pStart )
   {
      PHB_ITEM pReturn;
      PHB_THREADSTATE pThread;
      ULONG ulPCount, ulParam;

      pThread = hb_threadStateNew();
      pReturn = pThread->pThItm;

      pThread->pszCDP    = hb_cdpID();
      pThread->pszLang   = hb_langID();
      pThread->pszDefRDD = hb_stackRDD()->szDefaultRDD;
      pThread->pSet      = hb_setClone( hb_stackSetStruct() );
      pThread->pParams   = hb_arrayBaseParams();

      ulPCount = hb_arrayLen( pThread->pParams );
      /* remove thread attributes */
      if( ulStart > 1 )
      {
         for( ulParam = 1; ulParam < ulStart; ++ulParam )
            hb_arrayDel( pThread->pParams, 1 );
         ulPCount -= ulStart - 1;
         hb_arraySize( pThread->pParams, ulPCount );
      }
      if( HB_IS_STRING( pStart ) && pSymbol )
         hb_itemPutSymbol( hb_arrayGetItemPtr( pThread->pParams, 1 ), pSymbol );
      /* detach LOCAL variables passed by reference */
      for( ulParam = 1; ulParam <= ulPCount; ++ulParam )
      {
         PHB_ITEM pParam = hb_arrayGetItemPtr( pThread->pParams, ulParam );
         if( HB_IS_BYREF( pParam ) )
         {
            if( ulParam == 1 )
               hb_itemCopy( pParam, hb_itemUnRef( pParam ) );
            else
               hb_memvarDetachLocal( pParam );
         }
      }

      if( ( ulAttr & HB_THREAD_INHERIT_MEMVARS ) != 0 )
      {
         int iScope = 0;
         if( ( ulAttr & HB_THREAD_INHERIT_PUBLIC ) != 0 )
            iScope |= HB_MV_PUBLIC;
         if( ( ulAttr & HB_THREAD_INHERIT_PRIVATE ) != 0 )
            iScope |= HB_MV_PRIVATE;
         pThread->pMemvars = hb_memvarSaveInArray( iScope,
                                    ( ulAttr & HB_THREAD_MEMVARS_COPY ) != 0 );
      }

      /* make copy of thread pointer item before we pass it to new thread
       * to avoid race condition
       */
      hb_itemReturn( pReturn );

#if defined( HB_MT_VM )
      if( hb_vmThreadRegister( ( void * ) pThread ) )
#endif
         pThread->th_id = hb_threadCreate( hb_threadStartVM, ( void * ) pReturn );

      if( pThread->th_id == 0 )
      {
#if defined( HB_MT_VM )
         hb_vmThreadRelease( pThread );
#else
         hb_itemRelease( pReturn );
#endif
         hb_ret();
      }
   }
   else
   {
      if( szFuncName )
         hb_errRT_BASE_SubstR( EG_NOFUNC, 1001, NULL, szFuncName, 0 );
      else
         hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}
thread.c547
HB_FUNCHB_THREADSELF(void)
HB_FUNC( HB_THREADSELF )
{
#if defined( HB_MT_VM )
   PHB_THREADSTATE pThread = ( PHB_THREADSTATE ) hb_vmThreadState();
   if( pThread )
      hb_itemReturn( pThread->pThItm );
#endif
}
thread.c665
HB_FUNCHB_THREADID(void)
HB_FUNC( HB_THREADID )
{
#if defined( HB_MT_VM )
   PHB_THREADSTATE pThread = ( PHB_THREADSTATE ) hb_vmThreadState();
   if( pThread )
      hb_retnint( ( HB_PTRDIFF ) pThread->th_id );
   else
#endif
      hb_retnint( 0 );
}
thread.c674
HB_FUNCHB_THREADJOIN(void)
HB_FUNC( HB_THREADJOIN )
{
   PHB_THREADSTATE pThread = hb_thParam( 1 );

   if( pThread )
   {
      BOOL fResult = FALSE;

      if( pThread->th_id )
      {
         hb_vmUnlock();
         fResult = hb_threadJoin( pThread->th_id );
         if( fResult )
            pThread->th_id = 0;
         hb_vmLock();
      }
      if( fResult )
      {
         if( pThread->pResult )
         {
            hb_itemParamStoreForward( 2, pThread->pResult );
            hb_itemRelease( pThread->pResult );
            pThread->pResult = NULL;
         }
      }
      hb_retl( fResult );
   }
}
thread.c685
HB_FUNCHB_THREADDETACH(void)
HB_FUNC( HB_THREADDETACH )
{
   PHB_THREADSTATE pThread = hb_thParam( 1 );

   if( pThread )
   {
      BOOL fResult = FALSE;

      if( pThread->th_id && hb_threadDetach( pThread->th_id ) )
      {
         pThread->th_id = 0;
         fResult = TRUE;
      }
      hb_retl( fResult );
   }
}
thread.c714
HB_FUNCHB_THREADQUITREQUEST(void)
HB_FUNC( HB_THREADQUITREQUEST )
{
   PHB_THREADSTATE pThread = hb_thParam( 1 );

   if( pThread )
   {
      BOOL fResult = FALSE;

#if defined( HB_MT_VM )
      if( pThread->fActive )
      {
         hb_vmThreadQuitRequest( ( void * ) pThread );
         fResult = TRUE;
      }
#endif
      hb_retl( fResult );
   }
}
thread.c731
HB_FUNCHB_THREADWAITFORALL(void)
HB_FUNC( HB_THREADWAITFORALL )
{
#if defined( HB_MT_VM )
   hb_vmWaitForThreads();
#endif
}
thread.c750
HB_FUNCHB_THREADTERMINATEALL(void)
HB_FUNC( HB_THREADTERMINATEALL )
{
#if defined( HB_MT_VM )
   hb_vmTerminateThreads();
#endif
}

/* II. MUTEXES */

typedef struct _HB_MUTEX
{
   int                  lock_count;
   int                  lockers;
   int                  waiters;
   PHB_ITEM             events;
   HB_THREAD_ID         owner;
   HB_RAWCRITICAL_T     mutex;
   HB_RAWCOND_T         cond;
   BOOL                 fSync;
   struct _HB_MUTEX *   pNext;
   struct _HB_MUTEX *   pPrev;
}
HB_MUTEX, * PHB_MUTEX;

typedef struct _HB_MTXLST
{
   int                  lock_count;
   PHB_MUTEX            pMutex;
   struct _HB_MTXLST *  pNext;
}
HB_MTXLST, * PHB_MTXLST;

static PHB_MUTEX s_pSyncList = NULL;
static PHB_MUTEX s_pMutexList = NULL;
thread.c757
STATIC VOIDhb_mutexLink( PHB_MUTEX *pList, PHB_MUTEX pItem )
static void hb_mutexLink( PHB_MUTEX *pList, PHB_MUTEX pItem )
{
   if( *pList )
   {
      pItem->pNext = *pList;
      pItem->pPrev = (*pList)->pPrev;
      pItem->pPrev->pNext = pItem;
      (*pList)->pPrev = pItem;
   }
   else
   {
      *pList = pItem->pNext = pItem->pPrev = pItem;
   }
}
thread.c792
STATIC VOIDhb_mutexUnlink( PHB_MUTEX *pList, PHB_MUTEX pItem )
static void hb_mutexUnlink( PHB_MUTEX *pList, PHB_MUTEX pItem )
{
   pItem->pPrev->pNext = pItem->pNext;
   pItem->pNext->pPrev = pItem->pPrev;
   if( *pList == pItem )
   {
      *pList = pItem->pNext;
      if( *pList == pItem )
         *pList = NULL;    /* this was the last block */
   }
}
thread.c807
STATIC VOIDhb_mutexUnlockList( PHB_MUTEX * pList, PHB_MTXLST * pStore )
static void hb_mutexUnlockList( PHB_MUTEX * pList, PHB_MTXLST * pStore )
{
   HB_CRITICAL_LOCK( s_critical_init );
   if( *pList )
   {
      PHB_MUTEX pMutex = *pList;
      do
      {
         if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
         {
            HB_CRITICAL_LOCK( pMutex->mutex );
            if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
            {
               if( pStore )
               {
                  *pStore = ( PHB_MTXLST ) hb_xgrab( sizeof( HB_MTXLST ) );
                  (*pStore)->lock_count = pMutex->lock_count;
                  (*pStore)->pMutex = pMutex;
                  pStore = &(*pStore)->pNext;
                  *pStore = NULL;
               }
               pMutex->lock_count = 0;
               pMutex->owner = ( HB_THREAD_ID ) 0;
               HB_COND_SIGNALN( pMutex->cond, pMutex->lockers );
            }
            HB_CRITICAL_UNLOCK( pMutex->mutex );
         }
         pMutex = pMutex->pNext;
      }
      while( pMutex != *pList );
   }
   HB_CRITICAL_UNLOCK( s_critical_init );
}
thread.c820
STATIC VOIDhb_mutexLockList( PHB_MTXLST pList )
static void hb_mutexLockList( PHB_MTXLST pList )
{
   while( pList )
   {
      PHB_MUTEX pMutex = pList->pMutex;

      HB_CRITICAL_LOCK( pMutex->mutex );
      pMutex->lockers++;
      while( pMutex->lock_count != 0 )
      {
#if defined( HB_PTHREAD_API )
         pthread_cond_wait( &pMutex->cond, &pMutex->mutex );
#else
         HB_CRITICAL_UNLOCK( pMutex->mutex );
         ( void ) HB_COND_WAIT( pMutex->cond );
         HB_CRITICAL_LOCK( pMutex->mutex );
#endif
      }
      pMutex->lockers--;
      pMutex->lock_count = pList->lock_count;
      pMutex->owner = HB_THREAD_SELF();
      HB_CRITICAL_UNLOCK( pMutex->mutex );
      {
         PHB_MTXLST pFree = pList;
         pList = pList->pNext;
         hb_xfree( pFree );
      }
   }
}
thread.c854
VOIDhb_threadMutexUnlockAll( void )
void hb_threadMutexUnlockAll( void )
{
   hb_mutexUnlockList( &s_pMutexList, NULL );
   hb_mutexUnlockList( &s_pSyncList, NULL );
}
thread.c884
STATIC HB_GARBAGE_FUNC(hb_mutexDestructor )
static HB_GARBAGE_FUNC( hb_mutexDestructor )
{
   PHB_MUTEX pMutex = ( PHB_MUTEX ) Cargo;

#if defined( HB_MT_VM )
   HB_CRITICAL_LOCK( s_critical_init );
   hb_mutexUnlink( pMutex->fSync ? &s_pSyncList : &s_pMutexList, pMutex );
   HB_CRITICAL_UNLOCK( s_critical_init );
#else
   hb_mutexUnlink( pMutex->fSync ? &s_pSyncList : &s_pMutexList, pMutex );
#endif

   if( pMutex->events )
      hb_itemRelease( pMutex->events );

#if !defined( HB_MT_VM )
   /* nothing */
#elif defined( HB_PTHREAD_API )
   pthread_mutex_destroy( &pMutex->mutex );
   pthread_cond_destroy( &pMutex->cond );
#else
   HB_CRITICAL_DESTROY( pMutex->mutex );
   HB_COND_DESTROY( pMutex->cond );
#endif
}
thread.c892
STATIC PHB_MUTEXhb_mutexPtr( PHB_ITEM pItem )
static PHB_MUTEX hb_mutexPtr( PHB_ITEM pItem )
{
   return ( PHB_MUTEX ) hb_itemGetPtrGC( pItem, hb_mutexDestructor );
}
thread.c918
STATIC PHB_ITEMhb_mutexParam( int iParam )
static PHB_ITEM hb_mutexParam( int iParam )
{
   PHB_ITEM pItem = hb_param( iParam, HB_IT_POINTER );

   if( hb_itemGetPtrGC( pItem, hb_mutexDestructor ) )
      return pItem;

   hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   return NULL;
}
thread.c923
PHB_ITEMhb_threadMutexCreate( BOOL fSync )
PHB_ITEM hb_threadMutexCreate( BOOL fSync )
{
   PHB_MUTEX pMutex;
   PHB_ITEM pItem;

   pItem = hb_itemNew( NULL );
   pMutex = ( PHB_MUTEX ) hb_gcAlloc( sizeof( HB_MUTEX ), hb_mutexDestructor );
   memset( pMutex, 0, sizeof( HB_MUTEX ) );
   pItem = hb_itemPutPtrGC( pItem, pMutex );

#if !defined( HB_MT_VM )
   /* nothing */
#elif defined( HB_PTHREAD_API )
   pthread_mutex_init( &pMutex->mutex, NULL );
   pthread_cond_init( &pMutex->cond, NULL );
#else
   HB_CRITICAL_INIT( pMutex->mutex );
   HB_COND_INIT( pMutex->cond );
#endif

   pMutex->fSync = fSync;
#if defined( HB_MT_VM )
   HB_CRITICAL_LOCK( s_critical_init );
   hb_mutexLink( fSync ? &s_pSyncList : &s_pMutexList, pMutex );
   HB_CRITICAL_UNLOCK( s_critical_init );
#else
   hb_mutexLink( fSync ? &s_pSyncList : &s_pMutexList, pMutex );
#endif

   return pItem;
}
thread.c934
BOOLhb_threadMutexLock( PHB_ITEM pItem )
BOOL hb_threadMutexLock( PHB_ITEM pItem )
{
   PHB_MUTEX pMutex = hb_mutexPtr( pItem );
   BOOL fResult = FALSE;

   if( pMutex )
   {
      if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
         pMutex->lock_count++;
      else
      {
         hb_vmUnlock();

#if !defined( HB_MT_VM )
         pMutex->lock_count = 1;
         pMutex->owner = HB_THREAD_SELF();
         fResult = TRUE;
#else
         HB_CRITICAL_LOCK( pMutex->mutex );
         pMutex->lockers++;
         while( pMutex->lock_count != 0 )
         {
#if defined( HB_PTHREAD_API )
            pthread_cond_wait( &pMutex->cond, &pMutex->mutex );
#else
            HB_CRITICAL_UNLOCK( pMutex->mutex );
            ( void ) HB_COND_WAIT( pMutex->cond );
            HB_CRITICAL_LOCK( pMutex->mutex );
#endif
         }
         pMutex->lockers--;
         pMutex->lock_count = 1;
         pMutex->owner = HB_THREAD_SELF();
         HB_CRITICAL_UNLOCK( pMutex->mutex );
         fResult = TRUE;
#endif

         hb_vmLock();
      }
   }
   return fResult;
}
thread.c966
BOOLhb_threadMutexTimedLock( PHB_ITEM pItem, ULONG ulMilliSec )
BOOL hb_threadMutexTimedLock( PHB_ITEM pItem, ULONG ulMilliSec )
{
   PHB_MUTEX pMutex = hb_mutexPtr( pItem );
   BOOL fResult = FALSE;

   if( pMutex )
   {
      if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
         pMutex->lock_count++;
      else
      {
         hb_vmUnlock();

#if !defined( HB_MT_VM )
         HB_SYMBOL_UNUSED( ulMilliSec );
         pMutex->lock_count = 1;
         pMutex->owner = HB_THREAD_SELF();
         fResult = TRUE;
#elif defined( HB_PTHREAD_API )
         pthread_mutex_lock( &pMutex->mutex );
         if( ulMilliSec && pMutex->lock_count != 0 )
         {
            struct timespec ts;

            hb_threadTimeInit( &ts, ulMilliSec );

            /* pthread_cond_signal() wakes up at least one thread
             * but it's not guaranteed it's exactly one thread so
             * we should use while look here.
             */
            pMutex->lockers++;
            while( pMutex->lock_count == 0 )
            {
               if( pthread_cond_timedwait( &pMutex->cond, &pMutex->mutex, &ts ) != 0 )
                  break;
            }
            pMutex->lockers--;
         }
         if( pMutex->lock_count == 0 )
         {
            pMutex->lock_count = 1;
            pMutex->owner = HB_THREAD_SELF();
            fResult = TRUE;
         }
         pthread_mutex_unlock( &pMutex->mutex );
#else
         HB_CRITICAL_LOCK( pMutex->mutex );
         if( ulMilliSec && pMutex->lock_count != 0 )
         {
            pMutex->lockers++;
            HB_CRITICAL_UNLOCK( pMutex->mutex );
            ( void ) HB_COND_TIMEDWAIT( pMutex->cond, ulMilliSec );
            HB_CRITICAL_LOCK( pMutex->mutex );
            pMutex->lockers--;
         }
         if( pMutex->lock_count == 0 )
         {
            pMutex->lock_count = 1;
            pMutex->owner = HB_THREAD_SELF();
            fResult = TRUE;
         }
         HB_CRITICAL_UNLOCK( pMutex->mutex );
#endif

         hb_vmLock();
      }
   }
   return fResult;
}
thread.c1009
BOOLhb_threadMutexUnlock( PHB_ITEM pItem )
BOOL hb_threadMutexUnlock( PHB_ITEM pItem )
{
   PHB_MUTEX pMutex = hb_mutexPtr( pItem );
   BOOL fResult = FALSE;

   if( pMutex )
   {
      HB_CRITICAL_LOCK( pMutex->mutex );
      if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
      {
         if( --pMutex->lock_count == 0 )
         {
            pMutex->owner = ( HB_THREAD_ID ) 0;
            HB_COND_SIGNALN( pMutex->cond, pMutex->lockers );
         }
         fResult = TRUE;
      }
      HB_CRITICAL_UNLOCK( pMutex->mutex );
   }
   return fResult;
}
thread.c1079
VOIDhb_threadMutexNotify( PHB_ITEM pItem, PHB_ITEM pNotifier, BOOL fWaiting )
void hb_threadMutexNotify( PHB_ITEM pItem, PHB_ITEM pNotifier, BOOL fWaiting )
{
   PHB_MUTEX pMutex = hb_mutexPtr( pItem );

   if( pMutex )
   {
      HB_CRITICAL_LOCK( pMutex->mutex );
      if( !fWaiting )
      {
         if( !pMutex->events )
         {
            pMutex->events = hb_itemArrayNew( 1 );
            if( pNotifier && !HB_IS_NIL( pNotifier ) )
               hb_arraySet( pMutex->events, 1, pNotifier );
         }
         else if( pNotifier )
            hb_arrayAdd( pMutex->events, pNotifier );
         else
            hb_arraySize( pMutex->events, hb_arrayLen( pMutex->events ) + 1 );
         HB_COND_SIGNAL( pMutex->cond );
      }
      else if( pMutex->waiters )
      {
         int iCount = pMutex->waiters;
         ULONG ulLen;

         if( pMutex->events )
         {
            ulLen = hb_arrayLen( pMutex->events );
            hb_arraySize( pMutex->events, ulLen + pMutex->waiters );
         }
         else
         {
            ulLen = pMutex->waiters;
            pMutex->events = hb_itemArrayNew( ulLen );
         }
         if( pNotifier && !HB_IS_NIL( pNotifier ) )
         {
            do
               hb_arraySet( pMutex->events, ++ulLen, pNotifier );
            while( --iCount );
         }
         HB_COND_SIGNALN( pMutex->cond, pMutex->waiters );
      }
      HB_CRITICAL_UNLOCK( pMutex->mutex );
   }
}
thread.c1101
PHB_ITEMhb_threadMutexSubscribe( PHB_ITEM pItem, BOOL fClear )
PHB_ITEM hb_threadMutexSubscribe( PHB_ITEM pItem, BOOL fClear )
{
   PHB_MUTEX pMutex = hb_mutexPtr( pItem );
   PHB_ITEM pResult = NULL;

   if( pMutex )
   {
#if !defined( HB_MT_VM )
      if( pMutex->events && hb_arrayLen( pMutex->events ) > 0 )
      {
         if( fClear && pMutex->events )
            hb_arraySize( pMutex->events, 0 );
         else
         {
            pResult = hb_itemNew( NULL );
            hb_arrayGet( pMutex->events, 1, pResult );
            hb_arrayDel( pMutex->events, 1 );
            hb_arraySize( pMutex->events, hb_arrayLen( pMutex->events ) - 1 );
         }
      }
#else
      PHB_MTXLST pSyncList = NULL;

      hb_mutexUnlockList( &s_pSyncList, &pSyncList );
      hb_vmUnlock();

      HB_CRITICAL_LOCK( pMutex->mutex );

      if( fClear && pMutex->events )
         hb_arraySize( pMutex->events, 0 );

      pMutex->waiters++;
      while( !pMutex->events || hb_arrayLen( pMutex->events ) == 0 )
      {
#  if defined( HB_PTHREAD_API )
         pthread_cond_wait( &pMutex->cond, &pMutex->mutex );
#  else
         HB_CRITICAL_UNLOCK( pMutex->mutex );
         ( void ) HB_COND_WAIT( pMutex->cond );
         HB_CRITICAL_LOCK( pMutex->mutex );
#  endif
      }
      pMutex->waiters--;

      if( pMutex->events && hb_arrayLen( pMutex->events ) > 0 )
      {
         pResult = hb_itemNew( NULL );
         hb_arrayGet( pMutex->events, 1, pResult );
         hb_arrayDel( pMutex->events, 1 );
         hb_arraySize( pMutex->events, hb_arrayLen( pMutex->events ) - 1 );
      }

      HB_CRITICAL_UNLOCK( pMutex->mutex );

      hb_vmLock();
      hb_mutexLockList( pSyncList );
#endif
   }
   return pResult;
}
thread.c1149
PHB_ITEMhb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fClear )
PHB_ITEM hb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fClear )
{
   PHB_MUTEX pMutex = hb_mutexPtr( pItem );
   PHB_ITEM pResult = NULL;

   if( pMutex )
   {
#if !defined( HB_MT_VM )
      HB_SYMBOL_UNUSED( ulMilliSec );

      if( pMutex->events && hb_arrayLen( pMutex->events ) > 0 )
      {
         if( fClear && pMutex->events )
            hb_arraySize( pMutex->events, 0 );
         else
         {
            pResult = hb_itemNew( NULL );
            hb_arrayGet( pMutex->events, 1, pResult );
            hb_arrayDel( pMutex->events, 1 );
            hb_arraySize( pMutex->events, hb_arrayLen( pMutex->events ) - 1 );
         }
      }
#else
      PHB_MTXLST pSyncList = NULL;

      hb_mutexUnlockList( &s_pSyncList, &pSyncList );
      hb_vmUnlock();

      HB_CRITICAL_LOCK( pMutex->mutex );

      if( fClear && pMutex->events )
         hb_arraySize( pMutex->events, 0 );

      if( ulMilliSec && !( pMutex->events && hb_arrayLen( pMutex->events ) > 0 ) )
      {
         pMutex->waiters++;
#  if defined( HB_PTHREAD_API )
         {
            struct timespec ts;

            hb_threadTimeInit( &ts, ulMilliSec );
            while( !pMutex->events || hb_arrayLen( pMutex->events ) == 0 )
            {
               if( pthread_cond_timedwait( &pMutex->cond, &pMutex->mutex, &ts ) != 0 )
                  break;
            }
         }
#  else
         HB_CRITICAL_UNLOCK( pMutex->mutex );
         ( void ) HB_COND_TIMEDWAIT( pMutex->cond, ulMilliSec );
         HB_CRITICAL_LOCK( pMutex->mutex );
#  endif
         pMutex->waiters--;
      }

      if( pMutex->events && hb_arrayLen( pMutex->events ) > 0 )
      {
         pResult = hb_itemNew( NULL );
         hb_arrayGet( pMutex->events, 1, pResult );
         hb_arrayDel( pMutex->events, 1 );
         hb_arraySize( pMutex->events, hb_arrayLen( pMutex->events ) - 1 );
      }

      HB_CRITICAL_UNLOCK( pMutex->mutex );

      hb_vmLock();
      hb_mutexLockList( pSyncList );
#endif
   }
   return pResult;
}
thread.c1210
HB_FUNCHB_MUTEXCREATE(void)
HB_FUNC( HB_MUTEXCREATE )
{
   hb_itemReturnRelease( hb_threadMutexCreate( FALSE ) );
}
thread.c1282
HB_FUNCHB_MUTEXLOCK(void)
HB_FUNC( HB_MUTEXLOCK )
{
   PHB_ITEM pItem = hb_mutexParam( 1 );

   if( pItem )
   {
      if( ISNUM( 2 ) )
      {
         ULONG ulMilliSec = 0;
         double dTimeOut = hb_parnd( 1 );
         if( dTimeOut > 0 )
            ulMilliSec = ( ULONG ) ( dTimeOut * 1000 );
         hb_retl( hb_threadMutexTimedLock( pItem, ulMilliSec ) );
      }
      else
         hb_retl( hb_threadMutexLock( pItem ) );
   }
}
thread.c1287
HB_FUNCHB_MUTEXUNLOCK(void)
HB_FUNC( HB_MUTEXUNLOCK )
{
   PHB_ITEM pItem = hb_mutexParam( 1 );

   if( pItem )
      hb_retl( hb_threadMutexUnlock( pItem ) );
}
thread.c1306
HB_FUNCHB_MUTEXNOTIFY(void)
HB_FUNC( HB_MUTEXNOTIFY )
{
   PHB_ITEM pItem = hb_mutexParam( 1 );

   if( pItem )
      hb_threadMutexNotify( pItem, hb_param( 2, HB_IT_ANY ), FALSE );
}
thread.c1314
HB_FUNCHB_MUTEXNOTIFYALL(void)
HB_FUNC( HB_MUTEXNOTIFYALL )
{
   PHB_ITEM pItem = hb_mutexParam( 1 );

   if( pItem )
      hb_threadMutexNotify( pItem, hb_param( 2, HB_IT_ANY ), TRUE );
}
thread.c1322
HB_FUNCHB_MUTEXSUBSCRIBE(void)
HB_FUNC( HB_MUTEXSUBSCRIBE )
{
   PHB_ITEM pItem = hb_mutexParam( 1 );

   if( pItem )
   {
      PHB_ITEM pResult;

      if( ISNUM( 2 ) )
      {
         ULONG ulMilliSec = 0;
         double dTimeOut = hb_parnd( 1 );
         if( dTimeOut > 0 )
            ulMilliSec = ( ULONG ) ( dTimeOut * 1000 );
         pResult = hb_threadMutexTimedSubscribe( pItem, ulMilliSec, FALSE );
      }
      else
         pResult = hb_threadMutexSubscribe( pItem, FALSE );

      hb_itemParamStoreForward( 3, pResult);
      hb_itemRelease( pResult );
      hb_retl( pResult != NULL );
   }
}
thread.c1330
HB_FUNCHB_MUTEXSUBSCRIBENOW(void)
HB_FUNC( HB_MUTEXSUBSCRIBENOW )
{
   PHB_ITEM pItem = hb_mutexParam( 1 );

   if( pItem )
   {
      PHB_ITEM pResult;

      if( ISNUM( 2 ) )
      {
         ULONG ulMilliSec = 0;
         double dTimeOut = hb_parnd( 1 );
         if( dTimeOut > 0 )
            ulMilliSec = ( ULONG ) ( dTimeOut * 1000 );
         pResult = hb_threadMutexTimedSubscribe( pItem, ulMilliSec, TRUE );
      }
      else
         pResult = hb_threadMutexSubscribe( pItem, TRUE );

      hb_itemParamStoreForward( 3, pResult);
      hb_itemRelease( pResult );
      hb_retl( pResult != NULL );
   }
}
thread.c1355
HB_FUNCHB_MTVM(void)
HB_FUNC( HB_MTVM )
{
#if defined( HB_MT_VM )
   hb_retl( TRUE );
#else
   hb_retl( FALSE );
#endif
}
thread.c1380
vm.c
TypeFunctionSourceLine
HB_EXPORT HB_VMHANDLEhb_xvalloc( ULONG nSize, USHORT nFlags )
HB_EXPORT HB_VMHANDLE hb_xvalloc( ULONG nSize, USHORT nFlags )
{
   /* TODO */
   HB_SYMBOL_UNUSED( nSize );
   HB_SYMBOL_UNUSED( nFlags );
   return 0;
}
vm.c60
HB_EXPORT VOIDhb_xvfree( HB_VMHANDLE h )
HB_EXPORT void hb_xvfree( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
}
vm.c68
HB_EXPORT HB_VMHANDLEhb_xvrealloc( HB_VMHANDLE h, ULONG nSize, USHORT nFlags )
HB_EXPORT HB_VMHANDLE hb_xvrealloc( HB_VMHANDLE h, ULONG nSize, USHORT nFlags )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( nSize );
   HB_SYMBOL_UNUSED( nFlags );
   return 0;
}
vm.c74
HB_EXPORT VOID *hb_xvlock( HB_VMHANDLE h )
HB_EXPORT void * hb_xvlock( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   return NULL;
}
vm.c83
HB_EXPORT VOIDhb_xvunlock( HB_VMHANDLE h )
HB_EXPORT void hb_xvunlock( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
}
vm.c90
HB_EXPORT VOID *hb_xvwire( HB_VMHANDLE h )
HB_EXPORT void * hb_xvwire( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   return NULL;
}
vm.c98
HB_EXPORT VOIDhb_xvunwire( HB_VMHANDLE h )
HB_EXPORT void hb_xvunwire( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
}
vm.c105
HB_EXPORT ULONGhb_xvlockcount( HB_VMHANDLE h )
HB_EXPORT ULONG hb_xvlockcount( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   return 0;
}
vm.c114
HB_EXPORT ULONGhb_xvsize( HB_VMHANDLE h )
HB_EXPORT ULONG hb_xvsize( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   return 0;
}
vm.c121
HB_EXPORT HB_VMHANDLEhb_xvheapnew( ULONG nSize )
HB_EXPORT HB_VMHANDLE hb_xvheapnew( ULONG nSize )
{
   /* TODO */
   HB_SYMBOL_UNUSED( nSize );
   return 0;
}
vm.c130
HB_EXPORT VOIDhb_xvheapdestroy( HB_VMHANDLE h )
HB_EXPORT void hb_xvheapdestroy( HB_VMHANDLE h )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
}
vm.c137
HB_EXPORT HB_VMHANDLEhb_xvheapresize( HB_VMHANDLE h, ULONG nSize )
HB_EXPORT HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, ULONG nSize )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( nSize );
   return 0;
}
vm.c143
HB_EXPORT ULONGhb_xvheapalloc( HB_VMHANDLE h, ULONG nSize )
HB_EXPORT ULONG hb_xvheapalloc( HB_VMHANDLE h, ULONG nSize )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( nSize );
   return 0;
}
vm.c151
HB_EXPORT VOIDhb_xvheapfree( HB_VMHANDLE h, ULONG nOffset )
HB_EXPORT void hb_xvheapfree( HB_VMHANDLE h, ULONG nOffset )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( nOffset );
}
vm.c159
HB_EXPORT VOID *hb_xvheaplock( HB_VMHANDLE h, ULONG nOffset )
HB_EXPORT void * hb_xvheaplock( HB_VMHANDLE h, ULONG nOffset )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( nOffset );
   return NULL;
}
vm.c166
HB_EXPORT VOIDhb_xvheapunlock( HB_VMHANDLE h, ULONG nOffset )
HB_EXPORT void hb_xvheapunlock( HB_VMHANDLE h, ULONG nOffset )
{
   /* TODO */
   HB_SYMBOL_UNUSED( h );
   HB_SYMBOL_UNUSED( nOffset );
}
vm.c174
harbinit.prg
TypeFunctionSourceLine
PROCEDURECLIPPER520()
PROCEDURE CLIPPER520()
   RETURN
harbinit.prg58
PROCEDURECLIPPER530()
PROCEDURE CLIPPER530()
   RETURN
harbinit.prg64
PROCEDUREClipInit
PROCEDURE ClipInit

   MEMVAR GetList

   PUBLIC GetList := {}

   ErrorSys()

   /* TOFIX: In Clipper this function is not called from here CLIPINIT(). */
   /* NOTE: In Clipper __SETHELPK() is called *after* ERRORSYS(). */
   IF Type( "HELP()" ) == "UI"
      __SetHelpK()
   ENDIF

   RETURN
harbinit.prg75
PROCEDURE__SetHelpK()
PROCEDURE __SetHelpK()

   SET KEY K_F1 TO __XHELP

   RETURN
harbinit.prg91

Page url: http://www.yourdomain.com/help/index.html?vm.htm