2008-10-29 17:06 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcompdf.h
* harbour/include/hbexprb.c
* harbour/source/common/expropt1.c
* harbour/source/common/expropt2.c
! change the expressions precedence - references to variables were
wrongly marked as simple expressions
* harbour/include/hbexpra.c
! fixed protection against wrong static initializers. Now code like:
static s_var := { { func(), M->var } }
or:
static s_var := { "A" => { func() => M->var } }
or:
static s_var := { @M->var }
or:
static s_var := QSelf()
is not accepted by compiler and error is generated at compile
time instead of crashing at HVM startup when static variables
are initialized
This commit is contained in:
@@ -8,6 +8,27 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2008-10-29 17:06 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbcompdf.h
|
||||
* harbour/include/hbexprb.c
|
||||
* harbour/source/common/expropt1.c
|
||||
* harbour/source/common/expropt2.c
|
||||
! change the expressions precedence - references to variables were
|
||||
wrongly marked as simple expressions
|
||||
|
||||
* harbour/include/hbexpra.c
|
||||
! fixed protection against wrong static initializers. Now code like:
|
||||
static s_var := { { func(), M->var } }
|
||||
or:
|
||||
static s_var := { "A" => { func() => M->var } }
|
||||
or:
|
||||
static s_var := { @M->var }
|
||||
or:
|
||||
static s_var := QSelf()
|
||||
is not accepted by compiler and error is generated at compile
|
||||
time instead of crashing at HVM startup when static variables
|
||||
are initialized
|
||||
|
||||
2008-10-29 08:10 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* harbour/contrib/gtwvg/tests/demowvg.prg
|
||||
! Cleaned debug call left by mistake.
|
||||
|
||||
@@ -182,9 +182,9 @@ typedef enum
|
||||
HB_ET_SELF,
|
||||
HB_ET_ARRAY,
|
||||
HB_ET_HASH,
|
||||
HB_ET_FUNREF,
|
||||
HB_ET_VARREF,
|
||||
HB_ET_REFERENCE,
|
||||
HB_ET_FUNREF,
|
||||
HB_ET_IIF,
|
||||
HB_ET_LIST,
|
||||
HB_ET_ARGLIST,
|
||||
|
||||
@@ -543,16 +543,23 @@ HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR pArray, HB_EXPR_PTR pIndex, HB_CO
|
||||
/* ************************************************************************* */
|
||||
|
||||
#ifndef HB_MACRO_SUPPORT
|
||||
static void hb_compExprCheckStaticInitializers( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr, HB_COMP_DECL )
|
||||
static void hb_compExprCheckStaticInitializer( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr, HB_COMP_DECL )
|
||||
{
|
||||
HB_EXPR_PTR pElem = pRightExpr->value.asList.pExprList;
|
||||
HB_EXPR_PTR pNext;
|
||||
HB_EXPR_PTR * pPrev;
|
||||
|
||||
pPrev = &pRightExpr->value.asList.pExprList;
|
||||
while( pElem )
|
||||
if( pRightExpr->ExprType > HB_ET_FUNREF ||
|
||||
pRightExpr->ExprType == HB_ET_SELF )
|
||||
{
|
||||
/* Illegal initializer for static variable (not a constant value)
|
||||
*/
|
||||
hb_compErrorStatic( HB_COMP_PARAM, pLeftExpr->value.asSymbol, pRightExpr );
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_compExprCheckStaticListInitializers( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightExpr, HB_COMP_DECL )
|
||||
{
|
||||
HB_EXPR_PTR * pExpr = &pRightExpr->value.asList.pExprList;
|
||||
|
||||
while( *pExpr )
|
||||
{
|
||||
pNext = pElem->pNext; /* store next expression in case the current will be reduced */
|
||||
if( !HB_SUPPORT_HARBOUR )
|
||||
{
|
||||
/* When -kc switch is used expression list is not stripped
|
||||
@@ -562,14 +569,21 @@ static void hb_compExprCheckStaticInitializers( HB_EXPR_PTR pLeftExpr, HB_EXPR_P
|
||||
* new one - this will break the linked list of expressions.
|
||||
* (classical case of replacing an item in a linked list)
|
||||
*/
|
||||
pElem = hb_compExprListStrip( pElem, HB_COMP_PARAM );
|
||||
*pPrev = pElem; /* store a new expression into the previous one */
|
||||
pElem->pNext = pNext; /* restore the link to next expression */
|
||||
pPrev = &pElem->pNext;
|
||||
HB_EXPR_PTR pNext = (*pExpr)->pNext; /* store next expression in case the current will be reduced */
|
||||
*pExpr = hb_compExprListStrip( *pExpr, HB_COMP_PARAM );
|
||||
(*pExpr)->pNext = pNext; /* restore the link to next expression */
|
||||
}
|
||||
if( pElem->ExprType > HB_ET_FUNREF )
|
||||
hb_compErrorStatic( HB_COMP_PARAM, pLeftExpr->value.asSymbol, pElem );
|
||||
pElem = pNext;
|
||||
|
||||
if( (*pExpr)->ExprType == HB_ET_ARRAY ||
|
||||
(*pExpr)->ExprType == HB_ET_HASH )
|
||||
{
|
||||
hb_compExprCheckStaticListInitializers( pLeftExpr, *pExpr, HB_COMP_PARAM );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_compExprCheckStaticInitializer( pLeftExpr, *pExpr, HB_COMP_PARAM );
|
||||
}
|
||||
pExpr = &(*pExpr)->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,7 +619,7 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx
|
||||
* was used - we have to check if all array dimensions are
|
||||
* constant values
|
||||
*/
|
||||
hb_compExprCheckStaticInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM );
|
||||
hb_compExprCheckStaticListInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM );
|
||||
}
|
||||
else if( pRightExpr->ExprType == HB_ET_ARRAY )
|
||||
{
|
||||
@@ -613,13 +627,19 @@ HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR pLeftExpr, HB_EXPR_PTR pRightEx
|
||||
* Scan an array for illegal initializers.
|
||||
* An array item have to be a const value too.
|
||||
*/
|
||||
hb_compExprCheckStaticInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM );
|
||||
hb_compExprCheckStaticListInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM );
|
||||
}
|
||||
else if( pRightExpr->ExprType > HB_ET_FUNREF )
|
||||
else if( pRightExpr->ExprType == HB_ET_HASH )
|
||||
{
|
||||
/* Illegal initializer for static variable (not a constant value)
|
||||
/* { idx1=>var1, idx2=>var2, idxN=>varN } was used as initializer
|
||||
* Scan a hash array for illegal initializers.
|
||||
* A hash item have to be a const value too.
|
||||
*/
|
||||
hb_compErrorStatic( HB_COMP_PARAM, pLeftExpr->value.asSymbol, pRightExpr );
|
||||
hb_compExprCheckStaticListInitializers( pLeftExpr, pRightExpr, HB_COMP_PARAM );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_compExprCheckStaticInitializer( pLeftExpr, pRightExpr, HB_COMP_PARAM );
|
||||
}
|
||||
|
||||
return pExpr;
|
||||
|
||||
@@ -158,9 +158,9 @@ const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ] = {
|
||||
hb_compExprUseSelf,
|
||||
hb_compExprUseArray,
|
||||
hb_compExprUseHash,
|
||||
hb_compExprUseFunRef,
|
||||
hb_compExprUseVarRef,
|
||||
hb_compExprUseRef,
|
||||
hb_compExprUseFunRef,
|
||||
hb_compExprUseIIF,
|
||||
hb_compExprUseList,
|
||||
hb_compExprUseArgList,
|
||||
|
||||
@@ -70,7 +70,7 @@ static const char * s_OperTable[ HB_EXPR_COUNT ] = {
|
||||
"SELF",
|
||||
"Array",
|
||||
"Hash",
|
||||
"@",
|
||||
"@func()",
|
||||
"@",
|
||||
"@",
|
||||
"IIF",
|
||||
@@ -134,9 +134,9 @@ static const BYTE s_PrecedTable[ HB_EXPR_COUNT ] = {
|
||||
HB_ET_NIL, /* HB_ET_SELF, */
|
||||
HB_ET_NIL, /* HB_ET_ARRAY, */
|
||||
HB_ET_NIL, /* HB_ET_HASH, */
|
||||
HB_ET_NIL, /* HB_ET_FUNREF, */
|
||||
HB_ET_NIL, /* HB_ET_VARREF, */
|
||||
HB_ET_NIL, /* HB_ET_REFERENCE, */
|
||||
HB_ET_NIL, /* HB_ET_FUNREF, */
|
||||
HB_ET_NIL, /* HB_ET_IIF, */
|
||||
HB_ET_NIL, /* HB_ET_LIST, */
|
||||
HB_ET_NIL, /* HB_ET_ARGLIST, */
|
||||
|
||||
@@ -891,6 +891,7 @@ HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
pRight->ExprType == HB_ET_STRING ||
|
||||
pRight->ExprType == HB_ET_CODEBLOCK ||
|
||||
pRight->ExprType == HB_ET_ARRAY ||
|
||||
pRight->ExprType == HB_ET_HASH ||
|
||||
pRight->ExprType == HB_ET_FUNREF ) ) ||
|
||||
( pRight->ExprType == HB_ET_NIL &&
|
||||
( pLeft->ExprType == HB_ET_NUMERIC ||
|
||||
@@ -899,6 +900,7 @@ HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
pLeft->ExprType == HB_ET_STRING ||
|
||||
pLeft->ExprType == HB_ET_CODEBLOCK ||
|
||||
pLeft->ExprType == HB_ET_ARRAY ||
|
||||
pLeft->ExprType == HB_ET_HASH ||
|
||||
pLeft->ExprType == HB_ET_FUNREF ) ) )
|
||||
{
|
||||
HB_COMP_EXPR_FREE( pLeft );
|
||||
@@ -1260,6 +1262,7 @@ HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
pRight->ExprType == HB_ET_STRING ||
|
||||
pRight->ExprType == HB_ET_CODEBLOCK ||
|
||||
pRight->ExprType == HB_ET_ARRAY ||
|
||||
pRight->ExprType == HB_ET_HASH ||
|
||||
pRight->ExprType == HB_ET_FUNREF ) ) ||
|
||||
( pRight->ExprType == HB_ET_NIL &&
|
||||
( pLeft->ExprType == HB_ET_NUMERIC ||
|
||||
@@ -1268,6 +1271,7 @@ HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
pLeft->ExprType == HB_ET_STRING ||
|
||||
pLeft->ExprType == HB_ET_CODEBLOCK ||
|
||||
pLeft->ExprType == HB_ET_ARRAY ||
|
||||
pLeft->ExprType == HB_ET_HASH ||
|
||||
pLeft->ExprType == HB_ET_FUNREF ) ) )
|
||||
{
|
||||
HB_COMP_EXPR_FREE( pLeft );
|
||||
@@ -1488,6 +1492,7 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
pExpr->ExprType == HB_ET_STRING ||
|
||||
pExpr->ExprType == HB_ET_CODEBLOCK ||
|
||||
pExpr->ExprType == HB_ET_ARRAY ||
|
||||
pExpr->ExprType == HB_ET_HASH ||
|
||||
pExpr->ExprType == HB_ET_VARREF ||
|
||||
pExpr->ExprType == HB_ET_REFERENCE ||
|
||||
pExpr->ExprType == HB_ET_FUNREF )
|
||||
|
||||
Reference in New Issue
Block a user