20000422-21:36 GMT+1 Victor Szakats <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
2000-04-22 19:33:37 +00:00
parent a34c135487
commit 2d7f222ed0
8 changed files with 89 additions and 33 deletions

View File

@@ -1,3 +1,24 @@
20000422-21:36 GMT+1 Victor Szakats <info@szelvesz.hu>
* include/hbpcode.h
* source/compiler/harbour.c
* source/compiler/genc.c
* source/compiler/hvm.c
+ HB_P_PUSHSTRSHORT and HB_P_PUSHSYMNEAR 2 byte pcodes added.
HBTEST got 10K smaller after that.
+ HB_P_DOSHORT, HB_P_DOFUNCTION pcode handling added. But they are not yet
generated by the compiler. (TODO!)
; by Jose Lalin
* source/rtl/input.prg
* source/rtl/setta.prg
* source/rtl/browdbx.prg
- removed dummy functions to compile this modules
when HB_C52_UNDOC was not defined
* source/compiler/hbpcode.c
* Minor formatting.
20000422-11:35 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/hvm.c
* Minor correction of HB_TRACE messages for HB_P_ZERO, HB_P_ONE, HB_P_PUSHNIL, HB_P_PUSHBYTE, and HB_P_PUSHINT

View File

@@ -50,6 +50,7 @@ typedef enum
HB_P_FALSE, /* pushes false on the virtual machine stack */
HB_P_FORTEST, /* For STEP. If step > 1 less. If step < 1 greater. */
HB_P_FUNCTION, /* instructs the virtual machine to execute a function saving its result */
HB_P_FUNCTIONSHORT, /* instructs the virtual machine to execute a function saving its result */
HB_P_FRAME, /* instructs the virtual machine about how many parameters and locals a function uses */
HB_P_FUNCPTR, /* returns a function address pointer */
HB_P_GREATER, /* checks if the second latest value on the stack is greater that the lastest one */
@@ -57,6 +58,7 @@ typedef enum
HB_P_DEC, /* decrements the latest value on the virtual machine stack */
HB_P_DIVIDE, /* divides the latest two values on the stack, removing them and leaving there the result */
HB_P_DO, /* instructs the virtual machine to execute a function discarding its result */
HB_P_DOSHORT, /* instructs the virtual machine to execute a function discarding its result */
HB_P_DUPLICATE, /* places a copy of the latest virtual machine stack value on to the stack */
HB_P_DUPLTWO, /* places a copy of the latest two virtual machine stack value on to the stack */
HB_P_INC, /* increments the latest value on the virtual machine stack */
@@ -137,7 +139,9 @@ typedef enum
HB_P_PUSHSTATIC, /* pushes the contains of a static variable to the virtual machine stack */
HB_P_PUSHSTATICREF, /* pushes the a static variable by reference to the virtual machine stack */
HB_P_PUSHSTR, /* places a string on the virtual machine stack */
HB_P_PUSHSTRSHORT, /* places a string on the virtual machine stack */
HB_P_PUSHSYM, /* places a symbol on the virtual machine stack */
HB_P_PUSHSYMNEAR, /* places a symbol on the virtual machine stack */
HB_P_PUSHVARIABLE, /* pushes the contains of an undeclared variable to the virtual machine stack */
HB_P_RETVALUE, /* instructs the virtual machine to return the latest stack value */
HB_P_SEQBEGIN, /* BEGIN SEQUENCE */

View File

@@ -279,6 +279,11 @@ static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc )
lPCodePos += 3;
break;
case HB_P_DOSHORT:
fprintf( yyc, "\tHB_P_DO, %i,\n", pFunc->pCode[ lPCodePos + 1 ] );
lPCodePos += 2;
break;
case HB_P_DUPLICATE:
fprintf( yyc, "\tHB_P_DUPLICATE,\n" );
lPCodePos++;
@@ -345,6 +350,11 @@ static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc )
lPCodePos += 3;
break;
case HB_P_FUNCTIONSHORT:
fprintf( yyc, "\tHB_P_FUNCTIONSHORT, %i,\n", pFunc->pCode[ lPCodePos + 1 ] );
lPCodePos += 2;
break;
case HB_P_ARRAYGEN:
fprintf( yyc, "\tHB_P_ARRAYGEN, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],
@@ -1083,7 +1093,37 @@ static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc )
USHORT wLen = pFunc->pCode[ lPCodePos + 1 ] +
pFunc->pCode[ lPCodePos + 2 ] * 256;
if( bVerbose ) fprintf( yyc, "\t/* %i */", wLen );
lPCodePos +=3;
lPCodePos += 3;
if( wLen > 0 )
{
fprintf( yyc, "\n\t" );
while( wLen-- )
{
BYTE uchr = ( BYTE ) pFunc->pCode[ lPCodePos++ ];
/*
* NOTE: After optimization some CHR(n) can be converted
* into a string containing nonprintable characters.
*
* TODO: add switch to use hexadecimal format "%#04x"
*/
if( ( uchr < ( BYTE ) ' ' ) || ( uchr >= 127 ) )
fprintf( yyc, "%i, ", uchr );
else if( strchr( "\'\\\"", uchr ) )
fprintf( yyc, "%i, ", uchr );
else
fprintf( yyc, "\'%c\', ", uchr );
}
}
}
fprintf( yyc, "\n" );
break;
case HB_P_PUSHSTRSHORT:
fprintf( yyc, "\tHB_P_PUSHSTRSHORT, %i,", pFunc->pCode[ lPCodePos + 1 ] );
{
USHORT wLen = pFunc->pCode[ lPCodePos + 1 ];
if( bVerbose ) fprintf( yyc, "\t/* %i */", wLen );
lPCodePos += 2;
if( wLen > 0 )
{
fprintf( yyc, "\n\t" );
@@ -1117,6 +1157,14 @@ static void hb_compGenCReadable( PFUNCTION pFunc, FILE * yyc )
lPCodePos += 3;
break;
case HB_P_PUSHSYMNEAR:
fprintf( yyc, "\tHB_P_PUSHSYMNEAR, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ] );
if( bVerbose ) fprintf( yyc, "\t/* %s */", hb_compSymbolGetPos( pFunc->pCode[ lPCodePos + 1 ] )->szName );
fprintf( yyc, "\n" );
lPCodePos += 2;
break;
case HB_P_PUSHVARIABLE:
fprintf( yyc, "\tHB_P_PUSHVARIABLE, %i, %i,",
pFunc->pCode[ lPCodePos + 1 ],

View File

@@ -2280,7 +2280,10 @@ void hb_compGenPushLong( long lNumber )
/* generates the pcode to push a string on the virtual machine stack */
void hb_compGenPushString( char * szText, ULONG ulStrLen )
{
hb_compGenPCode3( HB_P_PUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ) );
if( ulStrLen > 255 )
hb_compGenPCode3( HB_P_PUSHSTR, HB_LOBYTE( ulStrLen ), HB_HIBYTE( ulStrLen ) );
else
hb_compGenPCode2( HB_P_PUSHSTRSHORT, ( BYTE ) ulStrLen );
hb_compGenPCodeN( ( BYTE * ) szText, ulStrLen );
}
@@ -2300,7 +2303,11 @@ void hb_compGenPushSymbol( char * szSymbolName, int iIsFunction )
if( iIsFunction && ! hb_compFunCallFind( szSymbolName ) )
hb_compFunCallAdd( szSymbolName );
}
hb_compGenPCode3( HB_P_PUSHSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ) );
if( wSym > 255 )
hb_compGenPCode3( HB_P_PUSHSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ) );
else
hb_compGenPCode2( HB_P_PUSHSYMNEAR, ( BYTE ) wSym );
}

View File

@@ -45,9 +45,8 @@ void hb_compGenPCode1( BYTE byte )
pFunc->lPCodeSize = HB_PCODE_CHUNK;
pFunc->lPCodePos = 0;
}
else
if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 1 )
pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK );
else if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 1 )
pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK );
pFunc->pCode[ pFunc->lPCodePos++ ] = byte;
}
@@ -62,9 +61,8 @@ void hb_compGenPCode2( BYTE byte1, BYTE byte2 )
pFunc->lPCodeSize = HB_PCODE_CHUNK;
pFunc->lPCodePos = 0;
}
else
if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 2 )
pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK );
else if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 2 )
pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK );
pFunc->pCode[ pFunc->lPCodePos++ ] = byte1;
pFunc->pCode[ pFunc->lPCodePos++ ] = byte2;
@@ -80,9 +78,8 @@ void hb_compGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3 )
pFunc->lPCodeSize = HB_PCODE_CHUNK;
pFunc->lPCodePos = 0;
}
else
if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 3 )
pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK );
else if( ( pFunc->lPCodeSize - pFunc->lPCodePos ) < 3 )
pFunc->pCode = ( BYTE * ) hb_xrealloc( pFunc->pCode, pFunc->lPCodeSize += HB_PCODE_CHUNK );
pFunc->pCode[ pFunc->lPCodePos++ ] = byte1;
pFunc->pCode[ pFunc->lPCodePos++ ] = byte2;

View File

@@ -71,11 +71,4 @@ FUNCTION dbSkipper( nRecs )
RETURN nSkipped
#else
/* NOTE: To make it compile */
STATIC PROCEDURE Dummy()
RETURN
#endif

View File

@@ -42,12 +42,5 @@ FUNCTION __Input( xPrompt )
RETURN iif( Empty( cString ), NIL, &cString )
#else
/* NOTE: To make it compile */
STATIC PROCEDURE Dummy()
RETURN
#endif

View File

@@ -40,12 +40,5 @@
FUNCTION SetTypeahead( nSize )
RETURN Set( _SET_TYPEAHEAD, nSize )
#else
/* NOTE: To make it compile */
STATIC PROCEDURE Dummy()
RETURN
#endif