20000429-23:50 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* harbour/source/compiler/harbour.c
! Fixed hb_compVariableAdd() to utilize parameter cValueType for Codeblock local variables, so that correct type is stored.
* harbour/source/compiler/harbour.y
! Fixed hb_compExprCBVarAdd( $<asExpr>0, $1, $2 ) to hb_compExprCBVarAdd( $<asExpr>0, $1, hb_comp_cVarType ) and
hb_compExprCBVarAdd( $<asExpr>0, $3, $4 ) to hb_compExprCBVarAdd( $<asExpr>0, $3, hb_comp_cVarType ) so that
correct type is passed.
+ Added hb_comp_cVarType = ' ' to reset declared type after BlockVar[s] PRIVATE and PUBLIC.
* harbour/source/compiler/hbpcode.c
* Minor corrections to hb_compStrongType()
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
20000429-23:50 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
|
||||
* harbour/source/compiler/harbour.c
|
||||
! Fixed hb_compVariableAdd() to utilize parameter cValueType for Codeblock local variables, so that correct type is stored.
|
||||
|
||||
* harbour/source/compiler/harbour.y
|
||||
! Fixed hb_compExprCBVarAdd( $<asExpr>0, $1, $2 ) to hb_compExprCBVarAdd( $<asExpr>0, $1, hb_comp_cVarType ) and
|
||||
hb_compExprCBVarAdd( $<asExpr>0, $3, $4 ) to hb_compExprCBVarAdd( $<asExpr>0, $3, hb_comp_cVarType ) so that
|
||||
correct type is passed.
|
||||
+ Added hb_comp_cVarType = ' ' to reset declared type after BlockVar[s] PRIVATE and PUBLIC.
|
||||
|
||||
* harbour/source/compiler/hbpcode.c
|
||||
* Minor corrections to hb_compStrongType()
|
||||
|
||||
20000429-02:29 GMT-8 Brian Hays <bhays@abacuslaw.com>
|
||||
* nation.txt
|
||||
* misc.txt
|
||||
|
||||
@@ -361,7 +361,7 @@ void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */
|
||||
sprintf( szSize, "%li", ulSize );
|
||||
hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_MEMREALLOC, szSize, NULL );
|
||||
}
|
||||
|
||||
|
||||
return pResult;
|
||||
}
|
||||
|
||||
@@ -464,6 +464,7 @@ void hb_compVariableAdd( char * szVarName, char cValueType )
|
||||
else
|
||||
/* variable defined in a codeblock */
|
||||
hb_comp_iVarScope = VS_PARAMETER;
|
||||
|
||||
hb_compCheckDuplVars( pFunc->pLocals, szVarName, hb_comp_iVarScope );
|
||||
|
||||
pVar = ( PVAR ) hb_xgrab( sizeof( VAR ) );
|
||||
@@ -473,6 +474,10 @@ void hb_compVariableAdd( char * szVarName, char cValueType )
|
||||
pVar->iUsed = 0;
|
||||
pVar->pNext = NULL;
|
||||
|
||||
/* Correct Type was previously stored in the CodeBlock. */
|
||||
if( ! pFunc->szName )
|
||||
pVar->cType = cValueType;
|
||||
|
||||
if( hb_comp_iVarScope & VS_MEMVAR )
|
||||
{
|
||||
PCOMSYMBOL pSym;
|
||||
@@ -1326,9 +1331,6 @@ static void hb_compPrepareOptimize()
|
||||
|
||||
hb_comp_functions.pLast->iJumps++;
|
||||
|
||||
//printf( "Preparing for Jump #%i in: %li 3rd Byte=%i", hb_comp_functions.pLast->iJumps, ( ULONG ) ( hb_comp_functions.pLast->lPCodePos - 4 ), hb_comp_functions.pLast->pCode[ hb_comp_functions.pLast->lPCodePos ] );
|
||||
//getchar();
|
||||
|
||||
if( hb_comp_functions.pLast->pJumps )
|
||||
{
|
||||
|
||||
@@ -1644,6 +1646,10 @@ void hb_compLinePush( void ) /* generates the pcode with the currently compiled
|
||||
hb_comp_bDontGenLineNum = FALSE;
|
||||
/* clear RETURN/BREAK flag */
|
||||
hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
|
||||
|
||||
/* Resting Compile Time Stack */
|
||||
hb_comp_functions.pLast->iStackIndex = 0;
|
||||
hb_comp_functions.pLast->iFunctionIndex = 0;
|
||||
}
|
||||
|
||||
/* Generates the pcode with the currently compiled source code line
|
||||
|
||||
@@ -342,10 +342,10 @@ Statement : ExecFlow CrlfStmnt { }
|
||||
}
|
||||
| PUBLIC { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PUBLIC; }
|
||||
ExtVarList
|
||||
{ hb_compRTVariableGen( "__MVPUBLIC" ); } CrlfStmnt
|
||||
{ hb_compRTVariableGen( "__MVPUBLIC" ); hb_comp_cVarType = ' '; } CrlfStmnt
|
||||
| PRIVATE { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PRIVATE; }
|
||||
ExtVarList
|
||||
{ hb_compRTVariableGen( "__MVPRIVATE" ); } CrlfStmnt
|
||||
{ hb_compRTVariableGen( "__MVPRIVATE" ); hb_comp_cVarType = ' '; } CrlfStmnt
|
||||
|
||||
| EXITLOOP CrlfStmnt { hb_compLoopExit(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
| LOOP CrlfStmnt { hb_compLoopLoop(); hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; }
|
||||
@@ -947,8 +947,8 @@ BlockExpList : Expression { $$ = hb_compExprAddListExpr( $<asExpr
|
||||
BlockNoVar : /* empty list */ { $$ = NULL; }
|
||||
;
|
||||
|
||||
BlockVarList : IdentName AsType { hb_comp_iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $<asExpr>0, $1, $2 ); }
|
||||
| BlockVarList ',' IdentName AsType { hb_comp_iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $<asExpr>0, $3, $4 ); }
|
||||
BlockVarList : IdentName AsType { hb_comp_iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $<asExpr>0, $1, hb_comp_cVarType ); hb_comp_cVarType = ' '; }
|
||||
| BlockVarList ',' IdentName AsType { hb_comp_iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $<asExpr>0, $3, hb_comp_cVarType ); hb_comp_cVarType = ' '; }
|
||||
;
|
||||
|
||||
/* There is a conflict between the use of IF( Expr1, Expr2, Expr3 )
|
||||
|
||||
@@ -214,6 +214,8 @@ void hb_compStrongType( int iSize )
|
||||
|
||||
/* TODO Split under conitions for the different matching possible iSize. */
|
||||
|
||||
/* TODO Subject to Operator Overloading! */
|
||||
|
||||
switch ( pFunc->pCode[ ulPos ] )
|
||||
{
|
||||
/*-----------------4/26/00 0:16AM-------------------
|
||||
@@ -237,9 +239,17 @@ void hb_compStrongType( int iSize )
|
||||
/* Function Type already on stack at this position. */
|
||||
break;
|
||||
|
||||
/* Subject to Operator Overloading - Don't expect Numeric! */
|
||||
case HB_P_DEC :
|
||||
case HB_P_INC :
|
||||
sprintf( szType1, "%c", pFunc->pStack[ pFunc->iStackIndex ] );
|
||||
|
||||
if ( pFunc->pStack[ pFunc->iStackIndex ] == 'N' )
|
||||
;
|
||||
else if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' )
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "N", NULL );
|
||||
else
|
||||
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, szType1, "N" );
|
||||
|
||||
break;
|
||||
|
||||
case HB_P_JUMPFALSENEAR :
|
||||
@@ -315,7 +325,7 @@ void hb_compStrongType( int iSize )
|
||||
sprintf( szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] );
|
||||
|
||||
if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' )
|
||||
/* Override the last item with the new result type wich is already there */
|
||||
/* Override the last item with the new result type which is already there */
|
||||
;
|
||||
else if ( pFunc->pStack[ pFunc->iStackIndex ] == pFunc->pStack[ pFunc->iStackIndex - 1 ] )
|
||||
/* Override the last item with the new result type wich is already there */
|
||||
|
||||
@@ -11,8 +11,14 @@ DECLARE FUNCTION nMyFunc( ) AS NUMERIC
|
||||
|
||||
FUNCTION Main()
|
||||
|
||||
LOCAL n AS NUMERIC
|
||||
|
||||
? "This is a compiler test."
|
||||
|
||||
n := nMyFunc()
|
||||
|
||||
cVar := {|n AS NUMERIC , c AS CHARACTER, d AS DATE| n := 'A', c := 1, d := 0, .T. }
|
||||
|
||||
RETURN NIL
|
||||
|
||||
FUNCTION Hex2Dec( lVar AS LOGICAL )
|
||||
|
||||
Reference in New Issue
Block a user