ChangeLog 20000109-14:25 GMT+1
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
20000109-14:25 GMT+1 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
*include/hbexpr.c
|
||||
*source/compiler/expropt.c
|
||||
*source/compiler/harbour.y
|
||||
* fixed STATIC var1[0], var2[3,4] initialization failure
|
||||
|
||||
2000-01-07 GMT +3 Luiz Rafael Culik <Culik@sl.conex.net>
|
||||
* gt.b32
|
||||
! Added RTF.prg
|
||||
|
||||
@@ -451,7 +451,7 @@ static void hb_compExprPushPreOp( HB_EXPR_PTR, BYTE );
|
||||
static void hb_compExprPushPostOp( HB_EXPR_PTR, BYTE );
|
||||
static void hb_compExprUsePreOp( HB_EXPR_PTR, BYTE );
|
||||
static void hb_compExprUseAliasMacro( HB_EXPR_PTR, BYTE );
|
||||
|
||||
static void hb_compExprCheckStaticInitializers( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
#endif
|
||||
|
||||
static BOOL hb_compExprCheckMacroVar( char * );
|
||||
@@ -1366,7 +1366,15 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx
|
||||
pRightExpr = hb_compExprListStrip( HB_EXPR_USE( pRightExpr, HB_EA_REDUCE ) );
|
||||
pExpr->value.asOperator.pRight = pRightExpr;
|
||||
|
||||
if( pRightExpr->ExprType > HB_ET_FUNREF )
|
||||
if( pRightExpr->ExprType == HB_ET_ARGLIST )
|
||||
{
|
||||
/* HB_ET_ARGLIST is used in case of STATIC var[dim1, dim2, dimN]
|
||||
* was used - we have to check if all array dimensions are
|
||||
* constant values
|
||||
*/
|
||||
hb_compExprCheckStaticInitializers( pLeftExpr, pRightExpr );
|
||||
}
|
||||
else if( pRightExpr->ExprType > HB_ET_FUNREF )
|
||||
{
|
||||
/* Illegal initializer for static variable (not a constant value)
|
||||
*/
|
||||
@@ -1374,29 +1382,11 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx
|
||||
}
|
||||
else if( pRightExpr->ExprType == HB_ET_ARRAY )
|
||||
{
|
||||
/* Scan an array for illegal initializers.
|
||||
/* { elem1, elem2, elemN } was used as initializer
|
||||
* Scan an array for illegal initializers.
|
||||
* An array item have to be a const value too.
|
||||
*/
|
||||
HB_EXPR_PTR pElem = pRightExpr->value.asList.pExprList;
|
||||
HB_EXPR_PTR pNext;
|
||||
HB_EXPR_PTR * pPrev;
|
||||
|
||||
pPrev = &pRightExpr->value.asList.pExprList;
|
||||
while( pElem )
|
||||
{
|
||||
/* NOTE: During reduction the expression can be replaced by the
|
||||
* new one - this will break the linked list of expressions.
|
||||
* (classical case of replacing an item in a linked list)
|
||||
*/
|
||||
pNext = pElem->pNext; /* store next expression in case the current will be reduced */
|
||||
pElem = hb_compExprListStrip( HB_EXPR_USE( pElem, HB_EA_REDUCE ) );
|
||||
if( pElem->ExprType > HB_ET_FUNREF )
|
||||
hb_compErrorStatic( pLeftExpr->value.asSymbol, pElem );
|
||||
*pPrev = pElem; /* store a new expression into the previous one */
|
||||
pElem->pNext = pNext; /* restore the link to next expression */
|
||||
pPrev = &pElem->pNext;
|
||||
pElem = pNext;
|
||||
}
|
||||
hb_compExprCheckStaticInitializers( pLeftExpr, pRightExpr );
|
||||
}
|
||||
|
||||
return pExpr;
|
||||
@@ -5868,3 +5858,29 @@ static void hb_compExprCBVarDel( HB_CBVAR_PTR pVars )
|
||||
HB_XFREE( pDel );
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HB_MACRO_SUPPORT
|
||||
static void hb_compExprCheckStaticInitializers( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr )
|
||||
{
|
||||
HB_EXPR_PTR pElem = pRightExpr->value.asList.pExprList;
|
||||
HB_EXPR_PTR pNext;
|
||||
HB_EXPR_PTR * pPrev;
|
||||
|
||||
pPrev = &pRightExpr->value.asList.pExprList;
|
||||
while( pElem )
|
||||
{
|
||||
/* NOTE: During reduction the expression can be replaced by the
|
||||
* new one - this will break the linked list of expressions.
|
||||
* (classical case of replacing an item in a linked list)
|
||||
*/
|
||||
pNext = pElem->pNext; /* store next expression in case the current will be reduced */
|
||||
pElem = hb_compExprListStrip( HB_EXPR_USE( pElem, HB_EA_REDUCE ) );
|
||||
if( pElem->ExprType > HB_ET_FUNREF )
|
||||
hb_compErrorStatic( pLeftExpr->value.asSymbol, pElem );
|
||||
*pPrev = pElem; /* store a new expression into the previous one */
|
||||
pElem->pNext = pNext; /* restore the link to next expression */
|
||||
pPrev = &pElem->pNext;
|
||||
pElem = pNext;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -84,6 +84,8 @@ static void hb_compElseIfFix( void * pIfElseIfs ); /* implements the ElseIfs pco
|
||||
static void hb_compRTVariableAdd( HB_EXPR_PTR, BOOL );
|
||||
static void hb_compRTVariableGen( char * );
|
||||
|
||||
static void hb_compVariableDim( char *, HB_EXPR_PTR );
|
||||
|
||||
/* Misc functions defined in harbour.c */
|
||||
extern void hb_compGenError( char* _szErrors[], char cPrefix, int iError, char * szError1, char * szError2 );
|
||||
extern void hb_compGenWarning( char* _szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2);
|
||||
@@ -1062,44 +1064,8 @@ VarDef : IDENTIFIER AsType
|
||||
}
|
||||
}
|
||||
|
||||
| IDENTIFIER DimList
|
||||
{
|
||||
if( hb_comp_iVarScope == VS_PUBLIC || hb_comp_iVarScope == VS_PRIVATE )
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( $2 );
|
||||
hb_compVariableAdd( $1, 'A' );
|
||||
hb_compExprDelete( hb_compExprGenPush( $2 ) );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
hb_compRTVariableAdd( hb_compExprNewRTVar( $1, NULL ), TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( $2 );
|
||||
hb_compVariableAdd( $1, 'A' );
|
||||
hb_compExprDelete( hb_compExprGenPush( $2 ) );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( $1 ) ) );
|
||||
}
|
||||
}
|
||||
| IDENTIFIER DimList AS_ARRAY
|
||||
{
|
||||
if( hb_comp_iVarScope == VS_PUBLIC || hb_comp_iVarScope == VS_PRIVATE )
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( $2 );
|
||||
hb_compVariableAdd( $1, 'A' );
|
||||
hb_compExprDelete( hb_compExprGenPush( $2 ) );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
hb_compRTVariableAdd( hb_compExprNewRTVar( $1, NULL ), TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( $2 );
|
||||
hb_compVariableAdd( $1, 'A' );
|
||||
hb_compExprDelete( hb_compExprGenPush( $2 ) );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( $1 ) ) );
|
||||
}
|
||||
}
|
||||
| IDENTIFIER DimList { hb_compVariableDim( $1, $2 ); }
|
||||
| IDENTIFIER DimList AS_ARRAY { hb_compVariableDim( $1, $2 ); }
|
||||
;
|
||||
|
||||
/* NOTE: DimList and DimIndex is the same as ArrayIndex and IndexList
|
||||
@@ -1828,3 +1794,44 @@ static void hb_compRTVariableGen( char * szCreateFun )
|
||||
}
|
||||
hb_comp_rtvars = NULL;
|
||||
}
|
||||
|
||||
static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue )
|
||||
{
|
||||
if( hb_comp_iVarScope == VS_PUBLIC || hb_comp_iVarScope == VS_PRIVATE )
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( pInitValue );
|
||||
hb_compVariableAdd( szName, 'A' );
|
||||
hb_compExprDelete( hb_compExprGenPush( pInitValue ) );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
hb_compRTVariableAdd( hb_compExprNewRTVar( szName, NULL ), TRUE );
|
||||
}
|
||||
else if( hb_comp_iVarScope == VS_STATIC )
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( pInitValue );
|
||||
HB_EXPR_PTR pVar = hb_compExprNewVar( szName );
|
||||
HB_EXPR_PTR pAssign;
|
||||
|
||||
hb_compStaticDefStart(); /* switch to statics pcode buffer */
|
||||
/* create a static variable */
|
||||
hb_compVariableAdd( szName, 'A' );
|
||||
/* create an array */
|
||||
hb_compExprGenPush( pInitValue );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
/* check if valid initializers were used but don't generate any code */
|
||||
pAssign = hb_compExprAssignStatic( pVar, pInitValue );
|
||||
/* now pop an array */
|
||||
hb_compExprGenPop( pVar );
|
||||
/* delete all used expressions */
|
||||
hb_compExprDelete( pAssign );
|
||||
hb_compStaticDefEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
USHORT uCount = hb_compExprListLen( pInitValue );
|
||||
|
||||
hb_compVariableAdd( szName, 'A' );
|
||||
hb_compExprDelete( hb_compExprGenPush( pInitValue ) );
|
||||
hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ) );
|
||||
hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName ) ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user