19990917-11:30 GMT+1

This commit is contained in:
Viktor Szakats
1999-09-17 09:39:18 +00:00
parent 57386e3fd1
commit bd83a913a1
7 changed files with 242 additions and 212 deletions

View File

@@ -1,3 +1,25 @@
19990917-11:30 GMT+1 Victor Szel <info@szelvesz.hu>
* include/ctoharb.h
source/vm/hvm.c
+ WORD -> USHORT (s_wActionRequest)
+ WORD -> int (wDec)
+ WORD -> USHORT (array dimensions)
+ WORD -> ULONG (array elements)
! __XHELP now uses hb_dynsymFindName() instead of hb_dynsymFind()
* source/vm/debug.c
+ WORD -> USHORT
* Using hb_itemRelease() instead of hb_itemClear() + hb_xfree()
* Small formatting changes.
* source/vm/dynsym.c
+ WORD -> USHORT
* source/rtl/gtapi.c
+ Some types changed from char* to BYTE* to match the environment, so a
few casts could be removed.
* tests/working/dynsym.prg
+ Added test for __dynsymGetIndex(), it will now GPF, since this function
is buggy right now.
19990916-23:45 EDT Paul Tucker <ptucker@sympatico.ca>
* source/rtl/console.c
* source/rtl/gtapi.c

View File

@@ -78,7 +78,7 @@ extern void hb_vmSymbolInit_RT( void ); /* initialization of runtime suppor
extern void hb_vmRequestQuit( void );
extern void hb_vmRequestCancel( void );
extern void hb_vmRequestBreak( PHB_ITEM pItem );
extern WORD hb_vmRequestQuery( void );
extern USHORT hb_vmRequestQuery( void );
extern void hb_vmQuit( void ); /* Immediately quits the virtual machine */
/* Return values of hb_vmRequestQuery() */
@@ -116,8 +116,8 @@ extern void hb_vmNot( void ); /* changes the latest logical value
/* Array */
extern void hb_vmArrayAt( void ); /* pushes an array element to the stack, removing the array and the index from the stack */
extern void hb_vmArrayPut( void ); /* sets an array value and pushes the value on to the stack */
extern void hb_vmDimArray( WORD wDimensions ); /* generates a wDimensions Array and initialize those dimensions from the stack values */
extern void hb_vmGenArray( WORD wElements ); /* generates a wElements Array and fills it from the stack values */
extern void hb_vmDimArray( USHORT uiDimensions ); /* generates an uiDimensions Array and initialize those dimensions from the stack values */
extern void hb_vmGenArray( ULONG ulElements ); /* generates an ulElements Array and fills it from the stack values */
/* Object */
extern void hb_vmMessage( PHB_SYMB pSymMsg ); /* sends a message to an object */
@@ -144,10 +144,10 @@ extern void hb_vmForTest( void ); /* test for end condition of for */
/* Push */
extern void hb_vmPush( PHB_ITEM pItem ); /* pushes a generic item onto the stack */
extern void hb_vmPushNil( void ); /* in this case it places nil at self */
extern void hb_vmPushNumber( double dNumber, WORD wDec ); /* pushes a number on to the stack and decides if it is integer, long or double */
extern void hb_vmPushNumber( double dNumber, int iDec ); /* pushes a number on to the stack and decides if it is integer, long or double */
extern void hb_vmPushInteger( int iNumber ); /* pushes a integer number onto the stack */
extern void hb_vmPushLong( long lNumber ); /* pushes a long number onto the stack */
extern void hb_vmPushDouble( double lNumber, WORD wDec ); /* pushes a double number onto the stack */
extern void hb_vmPushDouble( double lNumber, int iDec ); /* pushes a double number onto the stack */
extern void hb_vmPushLogical( BOOL bValue ); /* pushes a logical value onto the stack */
extern void hb_vmPushString( char * szText, ULONG length ); /* pushes a string on to the stack */
extern void hb_vmPushDate( LONG lDate ); /* pushes a long date onto the stack */
@@ -161,9 +161,9 @@ extern void hb_vmPushStaticByRef( WORD iLocal ); /* pushes a static by refren
/* Pop */
extern long hb_vmPopDate( void ); /* pops the stack latest value and returns its date value as a LONG */
extern double hb_vmPopNumber( void ); /* pops the stack latest value and returns its numeric value */
extern double hb_vmPopDouble( WORD * ); /* pops the stack latest value and returns its double numeric format value */
extern double hb_vmPopDouble( int * ); /* pops the stack latest value and returns its double numeric format value */
extern BOOL hb_vmPopLogical( void ); /* pops the stack latest value and returns its logical value */
extern void hb_vmPopLocal( SHORT wLocal ); /* pops the stack latest value onto a local */
extern void hb_vmPopLocal( SHORT iLocal ); /* pops the stack latest value onto a local */
extern void hb_vmPopStatic( WORD wStatic ); /* pops the stack latest value onto a static */
extern void hb_vmPopDefStat( WORD wStatic ); /* pops the stack latest value onto a static as default init */

View File

@@ -713,7 +713,7 @@ int hb_gtWrite( BYTE * fpStr, ULONG length )
int iRow, iCol, iMaxCol, iMaxRow;
ULONG size = length;
BYTE attr = s_Color[ s_uiColorIndex ] & 0xFF;
char *fpPointer = ( char * ) fpStr;
BYTE * fpPointer = fpStr;
/* TODO: this is doing more work than needed */
@@ -769,7 +769,7 @@ int hb_gtWrite( BYTE * fpStr, ULONG length )
else size = length;
/* Now the text string can be displayed */
hb_gt_Puts( s_uiCurrentRow, s_uiCurrentCol, attr, ( BYTE * ) fpPointer, size );
hb_gt_Puts( s_uiCurrentRow, s_uiCurrentCol, attr, fpPointer, size );
/* Finally, save the new cursor position */
hb_gtSetPos( iRow, iCol );
@@ -795,10 +795,10 @@ int hb_gtWriteCon( BYTE * fpStr, ULONG length )
USHORT tmpRow = s_uiCurrentRow, tmpCol = s_uiCurrentCol;
USHORT uiMaxRow = hb_gtMaxRow();
USHORT uiMaxCol = hb_gtMaxCol();
int ch;
char * fpPtr = ( char * ) fpStr;
BYTE ch;
BYTE * fpPtr = fpStr;
#define STRNG_SIZE 500
char strng[ STRNG_SIZE ];
BYTE strng[ STRNG_SIZE ];
while( length-- )
{
@@ -852,7 +852,7 @@ int hb_gtWriteCon( BYTE * fpStr, ULONG length )
case HB_CHAR_CR:
uiCol = 0;
if( *fpPtr != '\n') ldisp = TRUE;
if( *fpPtr != HB_CHAR_LF ) ldisp = TRUE;
break;
default:
@@ -868,7 +868,7 @@ int hb_gtWriteCon( BYTE * fpStr, ULONG length )
if( ldisp || ! length )
{
if( nLen )
rc = hb_gtWrite( ( BYTE * ) strng, nLen );
rc = hb_gtWrite( strng, nLen );
nLen = 0;
if( uiRow > uiMaxRow )
{
@@ -896,8 +896,8 @@ int hb_gtScroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, S
#ifdef TEST
void main( void )
{
char * test = "Testing GT API Functions";
char * test2 = "This message wraps!";
BYTE * test = "Testing GT API Functions";
BYTE * test2 = "This message wraps!";
int iRow, iCol;
/* NOTE: always have to initialze video subsystem */
@@ -905,11 +905,11 @@ void main( void )
/* save screen (doesn't work under DOS) */
/*
char * scr;
BYTE * scr;
USHORT size;
hb_gtRectSize( 1, 1, hb_gtMaxRow(), hb_gtMaxCol(), &size );
scr = ( char * ) hb_xgrab( size );
scr = ( BYTE * ) hb_xgrab( size );
hb_gtSave( 1, 1, hb_gtMaxRow() - 1, hb_gtMaxCol() - 1, scr );
*/

View File

@@ -48,7 +48,7 @@
*
* Please aClone before assignments
* $End$ */
HARBOUR HB___ASTATIC(void)
HARBOUR HB___ASTATIC( void )
{
PHB_ITEM pStatics = hb_arrayClone( &aStatics );
@@ -61,41 +61,38 @@ HARBOUR HB___ASTATIC(void)
* $FuncName$ <xStat> __Static(<nStatic>)
* $Description$ Return a specified statics
* $End$ */
HARBOUR HB___STATIC(void)
HARBOUR HB___STATIC( void )
{
PHB_ITEM pStatic;
WORD wStatic;
USHORT uiStatic = hb_parni( 1 );
PHB_ITEM pStatic = aStatics.item.asArray.value->pItems +
stack.iStatics + uiStatic - 1;
wStatic = hb_parni(1);
pStatic = aStatics.item.asArray.value->pItems +
stack.iStatics + wStatic - 1;
hb_itemReturn( pStatic );
}
/* $Doc$
* $FuncName$ AddToArray( <pItem>, <pReturn>, <wPos> )
* $Description$ Add <pItem> to array <pReturn> at pos <wPos>
* $FuncName$ AddToArray( <pItem>, <pReturn>, <uiPos> )
* $Description$ Add <pItem> to array <pReturn> at pos <uiPos>
* $End$ */
static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, WORD wPos )
static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, ULONG ulPos )
{
PHB_ITEM pTemp;
if( pItem->type == IT_SYMBOL)
if( pItem->type == IT_SYMBOL )
{ /* Symbol is pushed as text */
pTemp = hb_itemNew(NULL); /* Create temporary string */
pTemp->type = IT_STRING;
pTemp->item.asString.length = strlen( pItem->item.asSymbol.value->szName )+2;
pTemp->item.asString.value = (char *) hb_xgrab( pTemp->item.asString.length+1 );
pTemp = hb_itemNew( NULL ); /* Create temporary string */
pTemp->type = IT_STRING;
pTemp->item.asString.length = strlen( pItem->item.asSymbol.value->szName ) + 2;
pTemp->item.asString.value = ( char * ) hb_xgrab( pTemp->item.asString.length + 1 );
sprintf( pTemp->item.asString.value, "[%s]", pItem->item.asSymbol.value->szName );
hb_itemArrayPut( pReturn, wPos, pTemp );
hb_itemClear( pTemp ); /* Get rid of temporary str.*/
hb_xfree( pTemp );
hb_itemArrayPut( pReturn, ulPos, pTemp );
hb_itemRelease( pTemp ); /* Get rid of temporary str.*/
}
else /* Normal types */
hb_itemArrayPut( pReturn, wPos, pItem );
hb_itemArrayPut( pReturn, ulPos, pItem );
}
@@ -103,15 +100,17 @@ static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, WORD wPos )
* $FuncName$ <nVars> __GlobalStackLen()
* $Description$ Returns the length of the global stack
* $End$ */
static WORD GlobalStackLen( void )
static USHORT GlobalStackLen( void )
{
PHB_ITEM pItem;
WORD nCount = 0;
USHORT uiCount = 0;
for( pItem = stack.pItems; pItem++ <= stack.pPos; nCount++ );
return( nCount );
for( pItem = stack.pItems; pItem++ <= stack.pPos; uiCount++ );
return uiCount;
}
HARBOUR HB___GLOBALSTACKLEN(void)
HARBOUR HB___GLOBALSTACKLEN( void )
{
hb_retni( GlobalStackLen() );
}
@@ -121,20 +120,21 @@ HARBOUR HB___GLOBALSTACKLEN(void)
* $FuncName$ <aStack> __aGlobalStack()
* $Description$ Returns the global stack
* $End$ */
HARBOUR HB___AGLOBALSTACK(void)
HARBOUR HB___AGLOBALSTACK( void )
{
PHB_ITEM pReturn;
PHB_ITEM pItem;
WORD wLen = GlobalStackLen();
WORD wPos = 1;
USHORT uiLen = GlobalStackLen();
USHORT uiPos = 1;
pReturn = hb_itemArrayNew( uiLen ); /* Create a transfer array */
pReturn = hb_itemArrayNew( wLen ); /* Create a transfer array */
for( pItem = stack.pItems; pItem <= stack.pPos; pItem++ )
AddToArray( pItem, pReturn, wPos++ );
AddToArray( pItem, pReturn, uiPos++ );
hb_itemReturn( pReturn );
hb_itemClear( pReturn );
hb_xfree( pReturn );
hb_itemRelease( pReturn );
}
@@ -142,17 +142,18 @@ HARBOUR HB___AGLOBALSTACK(void)
* $FuncName$ <nVars> __StackLen()
* $Description$ Returns the length of the stack of the calling function
* $End$ */
static WORD StackLen( void )
static USHORT StackLen( void )
{
PHB_ITEM pItem;
PHB_ITEM pBase = stack.pItems + stack.pBase->item.asSymbol.stackbase;
WORD nCount = 0;
USHORT uiCount = 0;
for( pItem = pBase; pItem < stack.pBase; pItem++, nCount++ );
return( nCount );
for( pItem = pBase; pItem < stack.pBase; pItem++, uiCount++ );
return uiCount;
}
HARBOUR HB___STACKLEN(void)
HARBOUR HB___STACKLEN( void )
{
hb_retni( StackLen() );
}
@@ -169,21 +170,20 @@ HARBOUR HB___STACKLEN(void)
* [x+1 .. y] Locals
* [y+1 ..] Pushed data
* $End$ */
HARBOUR HB___ASTACK(void)
HARBOUR HB___ASTACK( void )
{
PHB_ITEM pReturn;
PHB_ITEM pItem;
PHB_ITEM pBase = stack.pItems + stack.pBase->item.asSymbol.stackbase;
WORD wLen = StackLen();
WORD wPos = 1;
USHORT uiLen = StackLen();
USHORT uiPos = 1;
pReturn = hb_itemArrayNew( wLen ); /* Create a transfer array */
pReturn = hb_itemArrayNew( uiLen ); /* Create a transfer array */
for( pItem = pBase; pItem < stack.pBase; pItem++ )
AddToArray( pItem, pReturn, wPos++ );
AddToArray( pItem, pReturn, uiPos++ );
hb_itemReturn( pReturn );
hb_itemClear( pReturn );
hb_xfree( pReturn );
hb_itemRelease( pReturn );
}
@@ -194,21 +194,22 @@ HARBOUR HB___ASTACK(void)
/* TODO : put bLocals / bParams */
/* somewhere for declared parameters */
/* and locals */
HARBOUR HB___APARAM(void)
HARBOUR HB___APARAM( void )
{
PHB_ITEM pReturn;
PHB_ITEM pItem;
PHB_ITEM pBase = stack.pItems + stack.pBase->item.asSymbol.stackbase;
/* Skip function + self */
WORD wLen = pBase->item.asSymbol.paramcnt;
WORD wPos = 1;
USHORT uiLen = pBase->item.asSymbol.paramcnt;
USHORT uiPos = 1;
pReturn = hb_itemArrayNew( uiLen ); /* Create a transfer array */
for( pItem = pBase + 2; uiLen--; pItem++ )
AddToArray( pItem, pReturn, uiPos++ );
pReturn = hb_itemArrayNew( wLen ); /* Create a transfer array */
for( pItem = pBase+2; wLen--; pItem++ )
AddToArray( pItem, pReturn, wPos++ );
hb_itemReturn( pReturn );
hb_itemClear( pReturn );
hb_xfree( pReturn );
hb_itemRelease( pReturn );
}
/* -------------------------------------------------------------------------- */
@@ -218,7 +219,6 @@ HARBOUR HB___APARAM(void)
* $CATEGORY$
* Variable management
* $ONELINER$
* This function releases all PRIVATE and PUBLIC variables
* $SYNTAX$
* __GETLOCAL( <nProcLevel>, <nLocal> )
* $ARGUMENTS$

View File

@@ -43,18 +43,19 @@ typedef struct
} DYNHB_ITEM, * PDYNHB_ITEM, * DYNHB_ITEM_PTR;
static PDYNHB_ITEM s_pDynItems = NULL; /* Pointer to dynamic items */
static WORD s_wDynSymbols = 0; /* Number of symbols present */
static WORD s_wClosestDynSym = 0;
/* Closest symbol for match. hb_dynsymFind() will search for the name. */
/* If it cannot find the name, it positions itself to the */
/* closest symbol. */
static USHORT s_uiDynSymbols = 0; /* Number of symbols present */
/* Closest symbol for match. hb_dynsymFind() will search for the name. */
/* If it cannot find the name, it positions itself to the */
/* closest symbol. */
static USHORT s_uiClosestDynSym = 0; /* TOFIX: This solution is not thread safe. */
void hb_dynsymLog( void )
{
WORD w;
USHORT uiPos;
for( w = 0; w < s_wDynSymbols; w++ ) /* For all dynamic symbols */
printf( "%i %s\n", w + 1, s_pDynItems[ w ].pDynSym->pSymbol->szName );
for( uiPos = 0; uiPos < s_uiDynSymbols; uiPos++ ) /* For all dynamic symbols */
printf( "%i %s\n", uiPos + 1, s_pDynItems[ uiPos ].pDynSym->pSymbol->szName );
}
PHB_SYMB hb_symbolNew( char * szName ) /* Create a new symbol */
@@ -85,26 +86,26 @@ PHB_DYNS hb_dynsymNew( PHB_SYMB pSymbol ) /* creates a new dynamic symbol */
return pDynSym; /* Return pointer to DynSym */
}
if( s_wDynSymbols == 0 ) /* Do we have any symbols ? */
if( s_uiDynSymbols == 0 ) /* Do we have any symbols ? */
pDynSym = s_pDynItems[ 0 ].pDynSym; /* Point to first symbol */
/* *<1>* Remember we already got this one */
else
{ /* We want more symbols ! */
s_pDynItems = ( PDYNHB_ITEM ) hb_xrealloc( s_pDynItems, ( s_wDynSymbols + 1 ) * sizeof( DYNHB_ITEM ) );
s_pDynItems = ( PDYNHB_ITEM ) hb_xrealloc( s_pDynItems, ( s_uiDynSymbols + 1 ) * sizeof( DYNHB_ITEM ) );
if( s_wClosestDynSym <= s_wDynSymbols ) /* Closest < current !! */
if( s_uiClosestDynSym <= s_uiDynSymbols ) /* Closest < current !! */
{ /* Here it goes :-) */
WORD w;
USHORT uiPos;
for( w = 0; w < ( s_wDynSymbols - s_wClosestDynSym ); w++ )
memcpy( &s_pDynItems[ s_wDynSymbols - w ],
&s_pDynItems[ s_wDynSymbols - w - 1 ], sizeof( DYNHB_ITEM ) );
for( uiPos = 0; uiPos < ( s_uiDynSymbols - s_uiClosestDynSym ); uiPos++ )
memcpy( &s_pDynItems[ s_uiDynSymbols - uiPos ],
&s_pDynItems[ s_uiDynSymbols - uiPos - 1 ], sizeof( DYNHB_ITEM ) );
} /* Insert element in array */
pDynSym = ( PHB_DYNS ) hb_xgrab( sizeof( HB_DYNS ) );
s_pDynItems[ s_wClosestDynSym ].pDynSym = pDynSym; /* Enter DynSym */
s_pDynItems[ s_uiClosestDynSym ].pDynSym = pDynSym; /* Enter DynSym */
}
s_wDynSymbols++; /* Got one more symbol */
s_uiDynSymbols++; /* Got one more symbol */
pDynSym->pSymbol = pSymbol;
pDynSym->hMemvar = 0;
pDynSym->hArea = 0;
@@ -170,77 +171,80 @@ PHB_DYNS hb_dynsymFind( char * szName )
return NULL;
}
else
{ /* Classic Tree Insert Sort Mechanism
*
* Insert Sort means the new item is entered alphabetically into
* the array. In this case s_pDynItems !
*
* 1) We start in the middle of the array.
* 2a) If the symbols are equal -> we have found the symbol !!
* Champagne ! We're done.
* b) If the symbol we are looking for ('ge') is greater than the
* middle ('po'), we start looking left.
* Only the first part of the array is going to be searched.
* Go to (1)
* c) If the symbol we are looking for ('ge') is smaller than the
* middle ('ko'), we start looking right
* Only the last part of the array is going to be searched.
* Go to (1)
*/
{
/* Classic Tree Insert Sort Mechanism
*
* Insert Sort means the new item is entered alphabetically into
* the array. In this case s_pDynItems !
*
* 1) We start in the middle of the array.
* 2a) If the symbols are equal -> we have found the symbol !!
* Champagne ! We're done.
* b) If the symbol we are looking for ('ge') is greater than the
* middle ('po'), we start looking left.
* Only the first part of the array is going to be searched.
* Go to (1)
* c) If the symbol we are looking for ('ge') is smaller than the
* middle ('ko'), we start looking right
* Only the last part of the array is going to be searched.
* Go to (1)
*/
WORD wFirst = 0;
WORD wLast = s_wDynSymbols;
WORD wMiddle = wLast / 2;
USHORT uiFirst = 0;
USHORT uiLast = s_uiDynSymbols;
USHORT uiMiddle = uiLast / 2;
s_wClosestDynSym = wMiddle; /* Start in the middle */
s_uiClosestDynSym = uiMiddle; /* Start in the middle */
while( wFirst < wLast )
while( uiFirst < uiLast )
{
switch( hb_strgreater( s_pDynItems[ wMiddle ].pDynSym->pSymbol->szName, szName ) )
switch( hb_strgreater( s_pDynItems[ uiMiddle ].pDynSym->pSymbol->szName, szName ) )
{
case HB_STRGREATER_EQUAL: /* they are equals */
return s_pDynItems[ wMiddle ].pDynSym;
return s_pDynItems[ uiMiddle ].pDynSym;
case HB_STRGREATER_LEFT: /* pMiddle is greater */
wLast = wMiddle;
s_wClosestDynSym = wMiddle;
uiLast = uiMiddle;
s_uiClosestDynSym = uiMiddle;
break;
case HB_STRGREATER_RIGHT: /* szName is greater */
wFirst = wMiddle + 1;
s_wClosestDynSym = wFirst;
uiFirst = uiMiddle + 1;
s_uiClosestDynSym = uiFirst;
break;
}
wMiddle = wFirst + ( ( wLast - wFirst ) / 2 );
uiMiddle = uiFirst + ( ( uiLast - uiFirst ) / 2 );
}
}
return NULL;
}
void hb_dynsymEval( PHB_DYNS_FUNC pFunction, void * Cargo )
{
BOOL bCont = TRUE;
WORD i;
USHORT uiPos;
for( i = 0; i < s_wDynSymbols && bCont; i++ )
bCont = ( pFunction )( s_pDynItems[ i ].pDynSym, Cargo );
for( uiPos = 0; uiPos < s_uiDynSymbols && bCont; uiPos++ )
bCont = ( pFunction )( s_pDynItems[ uiPos ].pDynSym, Cargo );
}
void hb_dynsymRelease( void )
{
WORD w;
USHORT uiPos;
for( w = 0; w < s_wDynSymbols; w++ )
for( uiPos = 0; uiPos < s_uiDynSymbols; uiPos++ )
{
/* it is a allocated symbol ? */
if( ( s_pDynItems + w )->pDynSym->pSymbol->cScope == SYM_ALLOCATED )
if( ( s_pDynItems + uiPos )->pDynSym->pSymbol->cScope == SYM_ALLOCATED )
{
hb_xfree( ( s_pDynItems + w )->pDynSym->pSymbol->szName );
hb_xfree( ( s_pDynItems + w )->pDynSym->pSymbol );
hb_xfree( ( s_pDynItems + uiPos )->pDynSym->pSymbol->szName );
hb_xfree( ( s_pDynItems + uiPos )->pDynSym->pSymbol );
}
hb_xfree( ( s_pDynItems + w )->pDynSym );
hb_xfree( ( s_pDynItems + uiPos )->pDynSym );
}
hb_xfree( s_pDynItems );
@@ -248,7 +252,7 @@ void hb_dynsymRelease( void )
HARBOUR HB___DYNSCOUNT( void ) /* How much symbols do we have: dsCount = __dynsymCount() */
{
hb_retnl( s_wDynSymbols );
hb_retnl( s_uiDynSymbols );
}
HARBOUR HB___DYNSGETNAME( void ) /* Get name of symbol: cSymbol = __dynsymGetName( dsIndex ) */
@@ -258,6 +262,6 @@ HARBOUR HB___DYNSGETNAME( void ) /* Get name of symbol: cSymbol = __dynsymGetNam
HARBOUR HB___DYNSGETINDEX( void ) /* Gimme index number of symbol: dsIndex = __dynsymGetIndex( cSymbol ) */
{
hb_retnl( ( LONG ) hb_dynsymGet( hb_parc( 1 ) ) );
hb_retnl( ( LONG ) hb_dynsymFindName( hb_parc( 1 ) ) );
}

View File

@@ -75,7 +75,7 @@ static void hb_vmReleaseLocalSymbols( void ); /* releases the memory of the
static void hb_vmDebuggerShowLine( WORD wLine ); /* makes the debugger shows a specific source code line */
static void hb_vmDebuggerEndProc( void ); /* notifies the debugger for an endproc */
static void hb_vmArrayNew( HB_ITEM_PTR, WORD ); /* creates array */
static void hb_vmArrayNew( HB_ITEM_PTR, USHORT ); /* creates array */
#ifdef HARBOUR_OBJ_GENERATION
static void hb_vmProcessObjSymbols ( void ); /* process Harbour generated OBJ symbols */
@@ -116,7 +116,7 @@ static LONG s_lRecoverBase = 0;
/* Request for some action - stop processing of opcodes
*/
static WORD s_wActionRequest = 0;
static USHORT s_uiActionRequest = 0;
/* uncomment it to trace the virtual machine activity */
/* #define bHB_DEBUG */
@@ -186,7 +186,7 @@ int main( int argc, char * argv[] )
void hb_vmQuit( void )
{
s_wActionRequest = 0; /* EXIT procedures should be processed */
s_uiActionRequest = 0; /* EXIT procedures should be processed */
hb_vmDoExitFunctions(); /* process defined EXIT functions */
while( stack.pPos > stack.pItems )
@@ -509,7 +509,7 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols )
break;
case HB_P_PUSHDOUBLE:
hb_vmPushDouble( * ( double * ) ( &pCode[ w + 1 ] ), ( WORD ) * ( BYTE * ) &pCode[ w + 1 + sizeof( double ) ] );
hb_vmPushDouble( * ( double * ) ( &pCode[ w + 1 ] ), ( int ) * ( BYTE * ) &pCode[ w + 1 + sizeof( double ) ] );
w += 1 + sizeof( double ) + 1;
break;
@@ -737,9 +737,9 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols )
break;
}
if( s_wActionRequest )
if( s_uiActionRequest )
{
if( s_wActionRequest & HB_BREAK_REQUESTED )
if( s_uiActionRequest & HB_BREAK_REQUESTED )
{
if( bCanRecover )
{
@@ -760,12 +760,12 @@ void hb_vmExecute( BYTE * pCode, PHB_SYMB pSymbols )
* leave the SEQUENCE envelope on the stack - it will
* be popped either in RECOVER or END opcode
*/
s_wActionRequest = 0;
s_uiActionRequest = 0;
}
else
break;
}
else if( s_wActionRequest & HB_QUIT_REQUESTED )
else if( s_uiActionRequest & HB_QUIT_REQUESTED )
break;
}
}
@@ -895,9 +895,9 @@ void hb_vmDec( void )
{
if( IS_NUMERIC( stack.pPos - 1 ) )
{
WORD wDec;
double dNumber = hb_vmPopDouble( &wDec );
hb_vmPushNumber( --dNumber, wDec );
int iDec;
double dNumber = hb_vmPopDouble( &iDec );
hb_vmPushNumber( --dNumber, iDec );
}
else if( IS_DATE( stack.pPos - 1 ) )
hb_vmPushDate( hb_vmPopDate() - 1 );
@@ -918,19 +918,19 @@ void hb_vmDec( void )
}
}
/* This function creates an array item using 'wDimension' as an index
/* This function creates an array item using 'uiDimension' as an index
* to retrieve the number of elements from the stack
*/
static void hb_vmArrayNew( HB_ITEM_PTR pArray, WORD wDimension )
static void hb_vmArrayNew( HB_ITEM_PTR pArray, USHORT uiDimension )
{
ULONG ulElements;
HB_ITEM_PTR pDim = stack.pPos - wDimension;
HB_ITEM_PTR pDim = stack.pPos - uiDimension;
/* use the proper type of number of elements */
switch( pDim->type & ~IT_BYREF )
{
case IT_INTEGER:
ulElements = (ULONG) pDim->item.asInteger.value;
ulElements = ( ULONG ) pDim->item.asInteger.value;
break;
case IT_LONG:
@@ -938,7 +938,7 @@ static void hb_vmArrayNew( HB_ITEM_PTR pArray, WORD wDimension )
break;
case IT_DOUBLE:
ulElements = (ULONG) pDim->item.asDouble.value;
ulElements = ( ULONG ) pDim->item.asDouble.value;
break;
default:
@@ -953,23 +953,23 @@ static void hb_vmArrayNew( HB_ITEM_PTR pArray, WORD wDimension )
/* create an array */
hb_arrayNew( pArray, ulElements );
if( --wDimension )
if( --uiDimension )
{
/* call self recursively to create next dimensions
*/
while( ulElements )
hb_vmArrayNew( hb_arrayGetItemPointer( pArray, ulElements-- ), wDimension );
hb_vmArrayNew( hb_arrayGetItemPointer( pArray, ulElements-- ), uiDimension );
}
}
void hb_vmDimArray( WORD wDimensions ) /* generates a wDimensions Array and initialize those dimensions from the stack values */
void hb_vmDimArray( USHORT uiDimensions ) /* generates an uiDimensions Array and initialize those dimensions from the stack values */
{
HB_ITEM itArray;
itArray.type = IT_NIL;
hb_vmArrayNew( &itArray, wDimensions );
hb_vmArrayNew( &itArray, uiDimensions );
while( wDimensions-- )
while( uiDimensions-- )
hb_stackPop();
hb_itemCopy( stack.pPos, &itArray );
@@ -982,9 +982,9 @@ void hb_vmDivide( void )
if( IS_NUMERIC( stack.pPos - 1 ) && IS_NUMERIC( stack.pPos - 2 ) )
{
BOOL bIntegerOperands = !IS_DOUBLE( stack.pPos - 1 ) && !IS_DOUBLE( stack.pPos - 2 );
WORD wDec1, wDec2;
double d2 = hb_vmPopDouble( &wDec2 );
double d1 = hb_vmPopDouble( &wDec1 );
int iDec1, iDec2;
double d2 = hb_vmPopDouble( &iDec2 );
double d1 = hb_vmPopDouble( &iDec1 );
if( d2 == 0.0 )
{
@@ -1184,8 +1184,8 @@ void hb_vmEqual( BOOL bExact )
else if( IS_NUMERIC( pItem1 ) && IS_NUMERIC( pItem2 ) )
{
WORD wDec;
hb_vmPushLogical( hb_vmPopDouble( &wDec ) == hb_vmPopDouble( &wDec ) );
int iDec;
hb_vmPushLogical( hb_vmPopDouble( &iDec ) == hb_vmPopDouble( &iDec ) );
}
else if( IS_DATE( pItem1 ) && IS_DATE( pItem2 ) )
@@ -1239,11 +1239,11 @@ void hb_vmForTest( void ) /* Test to check the end point of the FOR */
{
if( IS_NUMERIC( stack.pPos - 1 ) )
{
WORD wDec;
int iDec;
double dStep;
BOOL bEqual;
dStep = hb_vmPopDouble( &wDec );
dStep = hb_vmPopDouble( &iDec );
/* NOTE: step of zero will cause endless loop, as in Clipper */
@@ -1253,7 +1253,7 @@ void hb_vmForTest( void ) /* Test to check the end point of the FOR */
hb_vmGreater();
bEqual = hb_vmPopLogical(); /* Logical should be on top of stack */
hb_vmPushNumber( dStep, wDec ); /* Push the step expression back on the stack */
hb_vmPushNumber( dStep, iDec ); /* Push the step expression back on the stack */
hb_vmPushLogical( bEqual );
}
else
@@ -1296,18 +1296,18 @@ void hb_vmFunction( WORD wParams )
hb_stackPush();
}
void hb_vmGenArray( WORD wElements ) /* generates a wElements Array and fills it from the stack values */
void hb_vmGenArray( ULONG ulElements ) /* generates an ulElements Array and fills it from the stack values */
{
HB_ITEM itArray;
WORD w;
ULONG ulPos;
itArray.type = IT_NIL;
hb_arrayNew( &itArray, wElements );
for( w = 0; w < wElements; w++ )
hb_itemCopy( itArray.item.asArray.value->pItems + w,
stack.pPos - wElements + w );
hb_arrayNew( &itArray, ulElements );
for( ulPos = 0; ulPos < ulElements; ulPos++ )
hb_itemCopy( itArray.item.asArray.value->pItems + ulPos,
stack.pPos - ulElements + ulPos );
for( w = 0; w < wElements; w++ )
for( ulPos = 0; ulPos < ulElements; ulPos++ )
hb_stackPop();
hb_itemCopy( stack.pPos, &itArray );
@@ -1413,9 +1413,9 @@ void hb_vmInc( void )
{
if( IS_NUMERIC( stack.pPos - 1 ) )
{
WORD wDec;
double dNumber = hb_vmPopDouble( &wDec );
hb_vmPushNumber( ++dNumber, wDec );
int iDec;
double dNumber = hb_vmPopDouble( &iDec );
hb_vmPushNumber( ++dNumber, iDec );
}
else if( IS_DATE( stack.pPos - 1 ) )
hb_vmPushDate( hb_vmPopDate() + 1 );
@@ -1657,8 +1657,8 @@ void hb_vmNotEqual( void )
else if( IS_NUMERIC( pItem1 ) && IS_NUMERIC( pItem2 ) )
{
WORD wDec;
hb_vmPushLogical( hb_vmPopDouble( &wDec ) != hb_vmPopDouble( &wDec ) );
int iDec;
hb_vmPushLogical( hb_vmPopDouble( &iDec ) != hb_vmPopDouble( &iDec ) );
}
else if( IS_DATE( pItem1 ) && IS_DATE( pItem2 ) )
@@ -1704,11 +1704,11 @@ void hb_vmMinus( void )
if( IS_NUMERIC( pItem2 ) && IS_NUMERIC( pItem1 ) )
{
WORD wDec2, wDec1;
double dNumber2 = hb_vmPopDouble( &wDec2 );
double dNumber1 = hb_vmPopDouble( &wDec1 );
int iDec2, iDec1;
double dNumber2 = hb_vmPopDouble( &iDec2 );
double dNumber1 = hb_vmPopDouble( &iDec1 );
hb_vmPushNumber( dNumber1 - dNumber2, ( wDec1 > wDec2 ) ? wDec1 : wDec2 );
hb_vmPushNumber( dNumber1 - dNumber2, ( iDec1 > iDec2 ) ? iDec1 : iDec2 );
}
else if( IS_DATE( pItem2 ) && IS_DATE( pItem1 ) )
{
@@ -1784,9 +1784,9 @@ void hb_vmModulus( void )
{
if( IS_NUMERIC( stack.pPos - 1 ) && IS_NUMERIC( stack.pPos - 2 ) )
{
WORD wDec1, wDec2;
double d2 = hb_vmPopDouble( &wDec2 );
double d1 = hb_vmPopDouble( &wDec1 );
int iDec1, iDec2;
double d2 = hb_vmPopDouble( &iDec2 );
double d1 = hb_vmPopDouble( &iDec1 );
if( d2 == 0.0 )
{
@@ -1821,11 +1821,11 @@ void hb_vmMult( void )
{
if( IS_NUMERIC( stack.pPos - 1 ) && IS_NUMERIC( stack.pPos - 2 ) )
{
WORD wDec2, wDec1;
double d2 = hb_vmPopDouble( &wDec2 );
double d1 = hb_vmPopDouble( &wDec1 );
int iDec2, iDec1;
double d2 = hb_vmPopDouble( &iDec2 );
double d1 = hb_vmPopDouble( &iDec1 );
hb_vmPushNumber( d1 * d2, wDec1 + wDec2 );
hb_vmPushNumber( d1 * d2, iDec1 + iDec2 );
}
else
{
@@ -1859,7 +1859,7 @@ void hb_vmOperatorCall( PHB_ITEM pItem1, PHB_ITEM pItem2, char * szSymbol )
hb_itemClear( &stack.Return );
hb_itemCopy( stack.pPos, pResult );
hb_stackPush();
hb_itemClear( pResult );
hb_itemClear( pResult );
}
}
}
@@ -1881,7 +1881,7 @@ void hb_vmOperatorCallUnary( PHB_ITEM pItem1, char * szSymbol )
hb_itemClear( &stack.Return );
hb_itemCopy( stack.pPos, pResult );
hb_stackPush();
hb_itemClear( pResult );
hb_itemClear( pResult );
}
}
}
@@ -1930,11 +1930,11 @@ void hb_vmPlus( void )
else if( IS_NUMERIC( pItem1 ) && IS_NUMERIC( pItem2 ) )
{
WORD wDec2, wDec1;
double dNumber1 = hb_vmPopDouble( &wDec2 );
double dNumber2 = hb_vmPopDouble( &wDec1 );
int iDec2, iDec1;
double dNumber1 = hb_vmPopDouble( &iDec2 );
double dNumber2 = hb_vmPopDouble( &iDec1 );
hb_vmPushNumber( dNumber1 + dNumber2, ( wDec1 > wDec2 ) ? wDec1 : wDec2 );
hb_vmPushNumber( dNumber1 + dNumber2, ( iDec1 > iDec2 ) ? iDec1 : iDec2 );
}
else if( IS_DATE( pItem1 ) && IS_DATE( pItem2 ) )
@@ -1947,8 +1947,8 @@ void hb_vmPlus( void )
else if( IS_DATE( pItem1 ) && IS_NUMERIC( pItem2 ) )
{
WORD wDec;
double dNumber2 = hb_vmPopDouble( &wDec );
int iDec;
double dNumber2 = hb_vmPopDouble( &iDec );
long lDate1 = hb_vmPopDate();
hb_vmPushDate( lDate1 + dNumber2 );
@@ -2017,7 +2017,7 @@ static void hb_vmPopAliasedField( PHB_SYMB pSym )
HB_DEBUG( "hb_vmPopAliasedField\n" );
}
double hb_vmPopDouble( WORD *pwDec )
double hb_vmPopDouble( int * piDec )
{
double dNumber;
@@ -2027,17 +2027,17 @@ double hb_vmPopDouble( WORD *pwDec )
{
case IT_INTEGER:
dNumber = ( double ) stack.pPos->item.asInteger.value;
*pwDec = 0;
*piDec = 0;
break;
case IT_LONG:
dNumber = ( double ) stack.pPos->item.asLong.value;
*pwDec = 0;
*piDec = 0;
break;
case IT_DOUBLE:
dNumber = stack.pPos->item.asDouble.value;
*pwDec = stack.pPos->item.asDouble.decimal;
*piDec = stack.pPos->item.asDouble.decimal;
break;
default:
@@ -2158,9 +2158,9 @@ void hb_vmPower( void )
{
if( IS_NUMERIC( stack.pPos - 1 ) && IS_NUMERIC( stack.pPos - 2 ) )
{
WORD wDec1, wDec2;
double d2 = hb_vmPopDouble( &wDec2 );
double d1 = hb_vmPopDouble( &wDec1 );
int iDec1, iDec2;
double d2 = hb_vmPopDouble( &iDec2 );
double d1 = hb_vmPopDouble( &iDec1 );
/* NOTE: Clipper always returns the result of power
with the SET number of decimal places. */
@@ -2274,10 +2274,10 @@ void hb_vmPushNil( void )
HB_DEBUG( "hb_vmPushNil\n" );
}
void hb_vmPushNumber( double dNumber, WORD wDec )
void hb_vmPushNumber( double dNumber, int iDec )
{
if( wDec )
hb_vmPushDouble( dNumber, wDec );
if( iDec )
hb_vmPushDouble( dNumber, iDec );
else if( SHRT_MIN <= dNumber && dNumber <= SHRT_MAX )
hb_vmPushInteger( dNumber );
@@ -2389,13 +2389,12 @@ void hb_vmPushDate( LONG lDate )
HB_DEBUG( "hb_vmPushDate\n" );
}
void hb_vmPushDouble( double dNumber, WORD wDec )
void hb_vmPushDouble( double dNumber, int iDec )
{
stack.pPos->type = IT_DOUBLE;
stack.pPos->item.asDouble.value = dNumber;
if( dNumber >= 10000000000.0 ) stack.pPos->item.asDouble.length = 20;
else stack.pPos->item.asDouble.length = 10;
stack.pPos->item.asDouble.decimal = ( wDec > 9 ) ? 9 : wDec;
stack.pPos->item.asDouble.length = ( dNumber > 10000000000.0 ) ? 20 : 10;
stack.pPos->item.asDouble.decimal = ( iDec > 9 ) ? 9 : iDec;
hb_stackPush();
HB_DEBUG( "hb_vmPushDouble\n" );
@@ -2588,17 +2587,17 @@ void hb_vmSFrame( PHB_SYMB pSym ) /* sets the statics frame for a function
void hb_vmStatics( PHB_SYMB pSym ) /* initializes the global aStatics array or redimensionates it */
{
WORD wStatics = hb_vmPopNumber();
USHORT uiStatics = hb_vmPopNumber();
if( IS_NIL( &aStatics ) )
{
pSym->pFunPtr = NULL; /* statics frame for this PRG */
hb_arrayNew( &aStatics, wStatics );
hb_arrayNew( &aStatics, uiStatics );
}
else
{
pSym->pFunPtr = ( PHB_FUNC )hb_arrayLen( &aStatics );
hb_arraySize( &aStatics, hb_arrayLen( &aStatics ) + wStatics );
hb_arraySize( &aStatics, hb_arrayLen( &aStatics ) + uiStatics );
}
HB_DEBUG2( "Statics %li\n", hb_arrayLen( &aStatics ) );
@@ -2819,7 +2818,7 @@ static void hb_vmDoExitFunctions( void )
hb_vmPushSymbol( pLastSymbols->pModuleSymbols + w );
hb_vmPushNil();
hb_vmDo( 0 );
if( s_wActionRequest )
if( s_uiActionRequest )
/* QUIT or BREAK was issued - stop processing
*/
return;
@@ -3074,7 +3073,7 @@ HARBOUR HB_PROCLINE( void )
void hb_vmRequestQuit( void )
{
s_wActionRequest = HB_QUIT_REQUESTED;
s_uiActionRequest = HB_QUIT_REQUESTED;
}
HARBOUR HB___QUIT( void )
@@ -3125,15 +3124,15 @@ void hb_vmRequestBreak( PHB_ITEM pItem )
{
if( pItem )
hb_itemCopy( stack.pItems + s_lRecoverBase + HB_RECOVER_VALUE, pItem );
s_wActionRequest = HB_BREAK_REQUESTED;
s_uiActionRequest = HB_BREAK_REQUESTED;
}
else
s_wActionRequest = HB_QUIT_REQUESTED;
s_uiActionRequest = HB_QUIT_REQUESTED;
}
WORD hb_vmRequestQuery( void )
USHORT hb_vmRequestQuery( void )
{
return s_wActionRequest;
return s_uiActionRequest;
}
/* NOTE: This function should normally have a parameter count check. But
@@ -3153,7 +3152,7 @@ void hb_vmRequestCancel( void )
printf( hb_consoleGetNewLine() );
printf( "Cancelled at: %s (%i)", stack.pBase->item.asSymbol.value->szName, stack.pBase->item.asSymbol.lineno );
printf( hb_consoleGetNewLine() );
s_wActionRequest = HB_QUIT_REQUESTED;
s_uiActionRequest = HB_QUIT_REQUESTED;
}
}
@@ -3163,7 +3162,7 @@ void hb_vmRequestCancel( void )
HARBOUR HB___XHELP( void )
{
PHB_DYNS pDynSym = hb_dynsymFind( "HELP" );
PHB_DYNS pDynSym = hb_dynsymFindName( "HELP" );
if( pDynSym )
{

View File

@@ -10,4 +10,9 @@ FUNCTION Main()
OutStd( __dynsGetName( nPos ), Chr(13) + Chr(10) )
NEXT
nPos := __dynsGetIndex( "MAIN" )
? "MAIN", nPos
? __dynsGetName( nPos )
RETURN NIL