diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d4ad2199d3..8f76d17d90 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,24 @@ +20000422-21:36 GMT+1 Victor Szakats + + * 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 * 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 diff --git a/harbour/include/hbpcode.h b/harbour/include/hbpcode.h index 7036118653..67e779f791 100644 --- a/harbour/include/hbpcode.h +++ b/harbour/include/hbpcode.h @@ -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 */ diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 566f64e790..6a1d21ce2a 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -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 ], diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 12af18aef8..f0ae9f0e1b 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -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 ); } diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index 316582f4f0..1935580517 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -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; diff --git a/harbour/source/rtl/browdbx.prg b/harbour/source/rtl/browdbx.prg index 2602d4aa24..ce1d384762 100644 --- a/harbour/source/rtl/browdbx.prg +++ b/harbour/source/rtl/browdbx.prg @@ -71,11 +71,4 @@ FUNCTION dbSkipper( nRecs ) RETURN nSkipped -#else - -/* NOTE: To make it compile */ - -STATIC PROCEDURE Dummy() - RETURN - #endif diff --git a/harbour/source/rtl/input.prg b/harbour/source/rtl/input.prg index 2b4e47a898..83becdeeaa 100644 --- a/harbour/source/rtl/input.prg +++ b/harbour/source/rtl/input.prg @@ -42,12 +42,5 @@ FUNCTION __Input( xPrompt ) RETURN iif( Empty( cString ), NIL, &cString ) -#else - -/* NOTE: To make it compile */ - -STATIC PROCEDURE Dummy() - RETURN - #endif diff --git a/harbour/source/rtl/setta.prg b/harbour/source/rtl/setta.prg index aa0f3c399b..9e3693b40e 100644 --- a/harbour/source/rtl/setta.prg +++ b/harbour/source/rtl/setta.prg @@ -40,12 +40,5 @@ FUNCTION SetTypeahead( nSize ) RETURN Set( _SET_TYPEAHEAD, nSize ) -#else - -/* NOTE: To make it compile */ - -STATIC PROCEDURE Dummy() - RETURN - #endif