20000502-01:14 GMT+1 Victor Szakats <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
2000-05-01 23:11:11 +00:00
parent 3fd30ff94d
commit 382f8da021
9 changed files with 45 additions and 25 deletions

View File

@@ -1,3 +1,17 @@
20000502-01:14 GMT+1 Victor Szakats <info@szelvesz.hu>
* include/hbcomp.h
* include/hbexprb.c
* include/hbmacro.h
* source/compiler/genc.c
* source/compiler/harbour.c
* source/compiler/hbpcode.c
* source/vm/hvm.c
* source/vm/macro.c
+ Added width info to the PUSHDOUBLE pcode, to be Clipper compatible.
Note that the width is not yet calculated at compiled time, but the
possibility is already there.
20000501-23:25 GMT+1 Victor Szakats <info@szelvesz.hu>
* include/Makefile

View File

@@ -229,7 +229,7 @@ extern void hb_compLinePushIfInside( void ); /* generates the pcode with the c
extern void hb_compGenMessage( char * szMsgName ); /* sends a message to an object */
extern void hb_compGenMessageData( char * szMsg ); /* generates an underscore-symbol name for a data assignment */
extern void hb_compGenPopVar( char * szVarName ); /* generates the pcode to pop a value from the virtual machine stack onto a variable */
extern void hb_compGenPushDouble( double fNumber, BYTE bDec ); /* Pushes a number on the virtual machine stack */
extern void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec ); /* Pushes a number on the virtual machine stack */
extern void hb_compGenPushFunCall( char * ); /* generates the pcode to push function's call */
extern void hb_compGenPushVar( char * szVarName ); /* generates the pcode to push a variable value to the virtual machine stack */
extern void hb_compGenPushVarRef( char * szVarName ); /* generates the pcode to push a variable by reference to the virtual machine stack */

View File

@@ -278,7 +278,7 @@ static HB_EXPR_FUNC( hb_compExprUseNumeric )
break;
case HB_EA_PUSH_PCODE:
if( pSelf->value.asNum.NumType == HB_ET_DOUBLE )
HB_EXPR_PCODE2( hb_compGenPushDouble, pSelf->value.asNum.dVal, pSelf->value.asNum.bDec );
HB_EXPR_PCODE3( hb_compGenPushDouble, pSelf->value.asNum.dVal, -1, pSelf->value.asNum.bDec );
else
HB_EXPR_PCODE1( hb_compGenPushLong, pSelf->value.asNum.lVal );
break;

View File

@@ -126,7 +126,7 @@ extern void hb_compGenPushAliasedVar( char * szVarName,
char * szAlias,
long lWorkarea, HB_MACRO_DECL );
extern void hb_compGenPushLogical( int iTrueFalse, HB_MACRO_DECL );
extern void hb_compGenPushDouble( double dNumber, BYTE bDec, HB_MACRO_DECL );
extern void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_MACRO_DECL );
extern void hb_compGenPushFunCall( char * szFunName, HB_MACRO_DECL );
extern void hb_compGenPushString( char * szText, ULONG ulStrLen, HB_MACRO_DECL );
extern void hb_compCodeBlockStart( HB_MACRO_DECL );

View File

@@ -1117,17 +1117,18 @@ static HB_GENC_FUNC( hb_p_pushdouble )
{
int i;
fprintf( cargo->yyc, "\tHB_P_PUSHDOUBLE, " );
fprintf( cargo->yyc, "\tHB_P_PUSHDOUBLE," );
++lPCodePos;
for( i = 0; i < sizeof( double ) + sizeof( BYTE ); ++i )
fprintf( cargo->yyc, "%i,", ( ( BYTE * ) pFunc->pCode )[ lPCodePos + i ] );
if( cargo->bVerbose ) fprintf( cargo->yyc, "\t/* %.*f, %d */",
for( i = 0; i < sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ); ++i )
fprintf( cargo->yyc, " %i,", ( ( BYTE * ) pFunc->pCode )[ lPCodePos + i ] );
if( cargo->bVerbose ) fprintf( cargo->yyc, "\t/* %.*f, %d, %d */",
*( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ),
*( ( double * ) &( pFunc->pCode[ lPCodePos ] ) ),
*( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ) );
*( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) ] ) ),
*( ( BYTE * ) &( pFunc->pCode[ lPCodePos + sizeof( double ) + sizeof( BYTE ) ] ) ) );
fprintf( cargo->yyc, "\n" );
return sizeof( double ) + sizeof( BYTE ) + 1;
return sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ) + 1;
}
static HB_GENC_FUNC( hb_p_pushfield )

View File

@@ -2270,17 +2270,18 @@ void hb_compGenPushNil( void )
}
/* generates the pcode to push a double number on the virtual machine stack */
void hb_compGenPushDouble( double dNumber, BYTE bDec )
void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec )
{
BYTE pBuffer[ sizeof( double ) + 2 ];
BYTE pBuffer[ sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ) ];
pBuffer[0] = HB_P_PUSHDOUBLE;
pBuffer[ 0 ] = HB_P_PUSHDOUBLE;
memcpy( ( BYTE * )&(pBuffer[1]), ( BYTE * ) &dNumber, sizeof( double ) );
memcpy( ( BYTE * ) &( pBuffer[ 1 ] ), ( BYTE * ) &dNumber, sizeof( double ) );
pBuffer[ sizeof( double ) + 1 ] = bDec;
pBuffer[ 1 + sizeof( double ) ] = bWidth;
pBuffer[ 1 + sizeof( double ) + sizeof( BYTE ) ] = bDec;
hb_compGenPCodeN( pBuffer, sizeof( double ) + 2, 1 );
hb_compGenPCodeN( pBuffer, 1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ), 1 );
}
void hb_compGenPushFunCall( char * szFunName )

View File

@@ -144,11 +144,11 @@ static BYTE s_pcode_len[] = {
3, /* HB_P_PUSHLOCAL, */
2, /* HB_P_PUSHLOCALNEAR, */
3, /* HB_P_PUSHLOCALREF, */
1+sizeof(long), /* HB_P_PUSHLONG, */
1 + sizeof( long ), /* HB_P_PUSHLONG, */
3, /* HB_P_PUSHMEMVAR, */
3, /* HB_P_PUSHMEMVARREF, */
1, /* HB_P_PUSHNIL, */
2+sizeof(double), /* HB_P_PUSHDOUBLE, */
1 + sizeof( double ) + sizeof( BYTE ) + sizeof( BYTE ), /* HB_P_PUSHDOUBLE, */
1, /* HB_P_PUSHSELF, */
3, /* HB_P_PUSHSTATIC, */
3, /* HB_P_PUSHSTATICREF, */

View File

@@ -897,8 +897,10 @@ void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
break;
case HB_P_PUSHDOUBLE:
hb_vmPushDoubleConst( * ( double * ) ( &pCode[ w + 1 ] ), -1, ( int ) * ( BYTE * ) &pCode[ w + 1 + sizeof( double ) ] );
w += 1 + sizeof( double ) + 1;
hb_vmPushDoubleConst( * ( double * ) ( &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_PUSHSTR:
@@ -3102,17 +3104,18 @@ static void hb_vmPushDoubleConst( double dNumber, int iWidth, int iDec )
if( dNumber >= 1000000000.0 )
{
/* TODO: The width calculation should be made at compile time, and the
info should be stored in the code. Thus this huge ugly and slow
hack can be replaced. [vszakats] */
HB_SYMBOL_UNUSED( iWidth );
/* NOTE: If the width info is not provided by the pcode stream,
it will be determined at runtime with a relatively slow
method. [vszakats] */
if( iWidth == -1 )
{
char buffer[ 360 ];
sprintf( buffer, "%.*f", 0, dNumber );
hb_stack.pPos->item.asDouble.length = strlen( buffer ) + 1;
}
else
hb_stack.pPos->item.asDouble.length = iWidth;
if( iDec )
hb_stack.pPos->item.asDouble.length--;

View File

@@ -1094,10 +1094,11 @@ void hb_compGenPushLogical( int iTrueFalse, HB_MACRO_DECL )
}
/* generates the pcode to push a double number on the virtual machine stack */
void hb_compGenPushDouble( double dNumber, BYTE bDec, HB_MACRO_DECL )
void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_MACRO_DECL )
{
hb_compGenPCode1( HB_P_PUSHDOUBLE, HB_MACRO_PARAM );
hb_compGenPCodeN( ( BYTE * ) &dNumber, sizeof( double ), HB_MACRO_PARAM );
hb_compGenPCode1( bWidth, HB_MACRO_PARAM );
hb_compGenPCode1( bDec, HB_MACRO_PARAM );
}