diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 298e3a8396..26311f4958 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,21 @@ +20000519-15:28 GMT-8 Ron Pinkas + + * include/hbcomp.h + + Added member pParamClasses to COMDECLARED + * Changed hb_comp_szClass to hb_comp_szFromClass + + * source/compiler/harbour.y + * Changed hb_comp_szClass to hb_comp_szFromClass + + * source/compiler/harbour.c + + Added support for declared parameters of Functions/Methods AS Object FROM CLASS ... + + * source/compiler/hbpcode.c + + Added Strong Type checking for declared parameters of Functions/Methods AS Object FROM CLASS ... + + * tests/testwarn.prg + + Added code to demonstrate warnings for declared parameters of Functions/Methods AS Object FROM CLASS ... + 20000519-10:17 GMT-8 Ron Pinkas * source/compiler/harbour.y diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index a69925a2f5..cc241e3d3b 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -92,6 +92,7 @@ typedef struct _COMDECLARED BYTE * cParamTypes; USHORT iParamCount; struct _COMCLASS { char * szName; struct _COMDECLARED * pMethod; struct _COMCLASS * pNext; struct _COMDECLARED * pLast; } * pClass; + struct _COMCLASS * ( * pParamClasses ); struct _COMDECLARED * pNext; /* pointer to the next declared function */ } COMDECLARED, * PCOMDECLARED; @@ -165,9 +166,10 @@ typedef struct /* compiler symbol support structure */ typedef struct _COMSYMBOL { - char * szName; /* the name of the symbol */ - char cScope; /* the scope of the symbol */ - BYTE cType; + char * szName; /* the name of the symbol */ + char cScope; /* the scope of the symbol */ + BYTE cType; + PCOMCLASS pClass; struct _COMSYMBOL * pNext; /* pointer to the next defined symbol */ } COMSYMBOL, * PCOMSYMBOL; @@ -361,7 +363,7 @@ extern PCOMDECLARED hb_comp_pFirstDeclared; extern PCOMDECLARED hb_comp_pLastDeclared; extern PCOMCLASS hb_comp_pFirstClass; extern PCOMCLASS hb_comp_pLastClass; -extern char * hb_comp_szClass; +extern char * hb_comp_szFromClass; extern PCOMDECLARED hb_comp_pLastMethod; extern PATHNAMES * hb_comp_pIncludePath; extern PFUNCTION hb_comp_pInitFunc; diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 84336edfff..6ed0d02f1c 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -86,7 +86,7 @@ PCOMDECLARED hb_comp_pLastDeclared; PCOMCLASS hb_comp_pFirstClass; PCOMCLASS hb_comp_pLastClass; -char * hb_comp_szClass; +char * hb_comp_szFromClass; PCOMDECLARED hb_comp_pLastMethod; int hb_comp_iLine; /* currently processed line number */ @@ -474,12 +474,26 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType ) pDeclared->iParamCount++; if ( pDeclared->cParamTypes ) + { pDeclared->cParamTypes = ( BYTE * ) hb_xrealloc( pDeclared->cParamTypes, pDeclared->iParamCount ); + pDeclared->pParamClasses = ( PCOMCLASS * ) hb_xrealloc( pDeclared->pParamClasses, pDeclared->iParamCount * sizeof( COMCLASS ) ); + } else + { pDeclared->cParamTypes = ( BYTE * ) hb_xgrab( 1 ); + pDeclared->pParamClasses = ( PCOMCLASS * ) hb_xgrab( sizeof( COMCLASS ) ); + } pDeclared->cParamTypes[ pDeclared->iParamCount - 1 ] = cValueType; + if ( toupper( cValueType ) == 'S' ) + { + pDeclared->pParamClasses[ pDeclared->iParamCount - 1 ] = hb_compClassFind( hb_strdup( hb_comp_szFromClass ) ); + + /* Resetting */ + hb_comp_szFromClass = NULL; + } + return; } } @@ -491,17 +505,37 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType ) if ( hb_comp_iWarnings < 3 ) return; - /*printf( "\nAdding parameter: %s Type: %c\n", szVarName, cValueType );*/ + /* + printf( "\nAdding parameter: %s Type: %c In Method: %s Class: %s FROM CLASS: %s\n", szVarName, cValueType, hb_comp_pLastMethod->szName, hb_comp_pLastClass->szName, hb_comp_szFromClass ); + */ hb_comp_pLastMethod->iParamCount++; if ( hb_comp_pLastMethod->cParamTypes ) + { hb_comp_pLastMethod->cParamTypes = ( BYTE * ) hb_xrealloc( hb_comp_pLastMethod->cParamTypes, hb_comp_pLastMethod->iParamCount ); + hb_comp_pLastMethod->pParamClasses = ( PCOMCLASS * ) hb_xrealloc( hb_comp_pLastMethod->pParamClasses, hb_comp_pLastMethod->iParamCount * sizeof( COMCLASS ) ); + } else + { hb_comp_pLastMethod->cParamTypes = ( BYTE * ) hb_xgrab( 1 ); + hb_comp_pLastMethod->pParamClasses = ( PCOMCLASS * ) hb_xgrab( sizeof( COMCLASS ) ); + } hb_comp_pLastMethod->cParamTypes[ hb_comp_pLastMethod->iParamCount - 1 ] = cValueType; + if ( toupper( cValueType ) == 'S' ) + { + hb_comp_pLastMethod->pParamClasses[ hb_comp_pLastMethod->iParamCount - 1 ] = hb_compClassFind( hb_strdup( hb_comp_szFromClass ) ); + + /* + printf( "\nParameter: %s FROM CLASS: %s\n", szVarName, hb_comp_pLastMethod->pParamClasses[ hb_comp_pLastMethod->iParamCount - 1 ]->szName ); + */ + + /* Resetting */ + hb_comp_szFromClass = NULL; + } + return; } @@ -552,14 +586,19 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType ) if ( toupper( cValueType ) == 'S' ) { - /*printf( "\nVariable %s is of Class: %s\n", szVarName, hb_comp_szClass );*/ + /* + printf( "\nVariable %s is of Class: %s\n", szVarName, hb_comp_szFromClass ); + */ - pVar->pClass = hb_compClassFind( hb_comp_szClass ); + pVar->pClass = hb_compClassFind( hb_strdup( hb_comp_szFromClass ) ); if( ! pVar->pClass ) { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szClass, szVarName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, szVarName ); pVar->cType = 'O'; } + + /* Resetting */ + hb_comp_szFromClass = NULL; } if ( hb_comp_iVarScope & VS_PARAMETER ) @@ -872,6 +911,7 @@ PCOMDECLARED hb_compMethodAdd( PCOMCLASS pClass, char * szMethodName ) /* Last Declaration override previous declarations */ pMethod->cParamTypes = NULL; pMethod->iParamCount = 0; + pMethod->pParamClasses = NULL; return pMethod; } @@ -882,6 +922,7 @@ PCOMDECLARED hb_compMethodAdd( PCOMCLASS pClass, char * szMethodName ) pMethod->cType = ' '; // Not known yet pMethod->cParamTypes = NULL; pMethod->iParamCount = 0; + pMethod->pParamClasses = NULL; pMethod->pNext = NULL; if ( pClass->pMethod == NULL ) @@ -935,6 +976,7 @@ PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName ) pDeclared->cType = ' '; /* Not known yet */ pDeclared->cParamTypes = NULL; pDeclared->iParamCount = 0; + pDeclared->pParamClasses = NULL; return pDeclared; } @@ -945,6 +987,7 @@ PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName ) pDeclared->cType = ' '; /* Not known yet */ pDeclared->cParamTypes = NULL; pDeclared->iParamCount = 0; + pDeclared->pParamClasses = NULL; pDeclared->pNext = NULL; /* First Declare */ diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 69540049fa..8ca8a921d7 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -285,7 +285,7 @@ AsType : /* not specified */ { hb_comp_cVarType = ' '; } | AS_ARRAY { hb_comp_cVarType = 'A'; } | AS_BLOCK { hb_comp_cVarType = 'B'; } | AS_OBJECT { hb_comp_cVarType = 'O'; } - | AS_OBJECT FROMCLASS IdentName { hb_comp_cVarType = 'S'; hb_comp_szClass = $3 } + | AS_OBJECT FROMCLASS IdentName { hb_comp_cVarType = 'S'; hb_comp_szFromClass = $3 } | AS_VARIANT { hb_comp_cVarType = ' '; } | AS_NUMERIC_ARRAY { hb_comp_cVarType = 'n'; } | AS_CHARACTER_ARRAY { hb_comp_cVarType = 'c'; } @@ -294,7 +294,7 @@ AsType : /* not specified */ { hb_comp_cVarType = ' '; } | AS_ARRAY_ARRAY { hb_comp_cVarType = 'a'; } | AS_BLOCK_ARRAY { hb_comp_cVarType = 'b'; } | AS_OBJECT_ARRAY { hb_comp_cVarType = 'o'; } - | AS_OBJECT_ARRAY FROMCLASS IdentName { hb_comp_cVarType = 's'; hb_comp_szClass = $3 } + | AS_OBJECT_ARRAY FROMCLASS IdentName { hb_comp_cVarType = 's'; hb_comp_szFromClass = $3 } ; AsArray : AS_ARRAY { hb_comp_cVarType = 'A'; } @@ -1158,12 +1158,15 @@ DecMethod : IdentName '(' { hb_comp_pLastMethod = hb_compMethodAdd( hb_comp_pLa hb_comp_pLastMethod->cType = hb_comp_cVarType; if ( toupper( hb_comp_cVarType ) == 'S' ) { - hb_comp_pLastMethod->pClass = hb_compClassFind( hb_comp_szClass ); + hb_comp_pLastMethod->pClass = hb_compClassFind( hb_strdup( hb_comp_szFromClass ) ); if( ! hb_comp_pLastMethod->pClass ) { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szClass, hb_comp_pLastMethod->szName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, hb_comp_pLastMethod->szName ); hb_comp_pLastMethod->cType = ( isupper( hb_comp_cVarType ) ? 'O' :'o' ); } + + /* Resetting */ + hb_comp_szFromClass = NULL; } } hb_comp_pLastMethod = NULL; @@ -1176,12 +1179,15 @@ DecData : IdentName { hb_comp_pLastMethod = hb_compMethodAdd( hb_comp_pLastCl hb_comp_pLastMethod->cType = hb_comp_cVarType; if ( toupper( hb_comp_cVarType ) == 'S' ) { - hb_comp_pLastMethod->pClass = hb_compClassFind( hb_comp_szClass ); + hb_comp_pLastMethod->pClass = hb_compClassFind( hb_strdup( hb_comp_szFromClass ) ); if( ! hb_comp_pLastMethod->pClass ) { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szClass, hb_comp_pLastMethod->szName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, hb_comp_pLastMethod->szName ); hb_comp_pLastMethod->cType = ( isupper( hb_comp_cVarType ) ? 'O' :'o' ); } + + /* Resetting */ + hb_comp_szFromClass = NULL; } } hb_comp_pLastMethod = NULL; diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index 74d0438d4a..993a867064 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -274,7 +274,11 @@ void hb_compStrongType( int iSize ) if ( pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - if ( cSubType1 && cSubType1 == '-' ) + if ( cSubType1 == 'S' ) + sprintf( ( char * ) szType2, "%s", pDeclared->pClass->szName ); + else if ( cSubType1 == 's' ) + sprintf( ( char * ) szType2, "ARRAY OF %s", pDeclared->pClass->szName ); + else if ( cSubType1 && cSubType1 == '-' ) strcpy( ( char * ) szType2, "Variant.SubType\[NIL]" ); else if ( cSubType1 ) sprintf( ( char * ) szType2, "Variant.SubType\[%c]", pFunc->pStack[ pFunc->iStackIndex ] ); @@ -303,8 +307,8 @@ void hb_compStrongType( int iSize ) int hb_comp_iParamCount, iParamCount, iOptionals = 0; BYTE * hb_comp_cParamTypes; - hb_comp_cParamTypes = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->cParamTypes; - hb_comp_iParamCount = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->iParamCount; + hb_comp_cParamTypes = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->cParamTypes; + hb_comp_iParamCount = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->iParamCount; iParamCount = hb_comp_iParamCount; @@ -322,9 +326,10 @@ void hb_compStrongType( int iSize ) /* Now, check the types. */ if( wVar >= ( hb_comp_iParamCount - iOptionals ) && wVar <= hb_comp_iParamCount ) { - BYTE iOffset = 0, iParamBase = pFunc->iStackIndex - wVar, cFormalType; + BYTE iParamBase = pFunc->iStackIndex - wVar, cFormalType; + int iOffset = wVar; - while ( iOffset < wVar ) + while ( --iOffset >= 0 ) { cFormalType = hb_comp_cParamTypes[ iOffset ]; @@ -340,19 +345,51 @@ void hb_compStrongType( int iSize ) ; /* Parameter is NIL, always accepted. */ else if ( cFormalType == '@' && pFunc->pStack[ iParamBase + iOffset ] >= ( 'A' + VT_OFFSET_BYREF ) ) ; /* Prameter is ANY REFERENCE, and Parameter is SOME REFERENCE. */ + else if ( cFormalType == 'S' && pFunc->pStack[ iParamBase + iOffset ] == 'S' && pFunc->iStackClasses ) + { + PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; + + if ( hb_comp_pFormalClass != hb_comp_pParamClass ) + { + sprintf( ( char * ) szType1, "%i", iOffset + 1 ); + sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); + } + } + else if ( cFormalType == 's' && pFunc->pStack[ iParamBase + iOffset ] == 's' && pFunc->iStackClasses ) + { + PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; + + if ( hb_comp_pFormalClass != hb_comp_pParamClass ) + { + sprintf( ( char * ) szType1, "%i", iOffset + 1 ); + sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); + } + } else if ( cFormalType != pFunc->pStack[ iParamBase + iOffset ] ) { - if ( cFormalType > ( 'A' + VT_OFFSET_BYREF ) ) - sprintf( ( char * ) szType2, "@%c", cFormalType - VT_OFFSET_BYREF ); + if ( cFormalType == 'S' ) + { + PCOMCLASS hb_comp_pParamClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + sprintf( ( char * ) szType2, "%s", hb_comp_pParamClass->szName ); + } + else if ( cFormalType == 's' ) + { + PCOMCLASS hb_comp_pParamClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pParamClass->szName ); + } + else if ( cFormalType > ( 'A' + VT_OFFSET_BYREF ) ) + sprintf( ( char * ) szType2, "@%c", cFormalType - VT_OFFSET_BYREF ); else - sprintf( ( char * ) szType2, "%c", cFormalType ); + sprintf( ( char * ) szType2, "%c", cFormalType ); sprintf( ( char * ) szType1, "%i", iOffset + 1 ); hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); } - - iOffset++; } } else @@ -465,12 +502,15 @@ void hb_compStrongType( int iSize ) /* Now, check the types. */ if( wVar >= ( hb_comp_iParamCount - iOptionals ) && wVar <= hb_comp_iParamCount ) { - BYTE iOffset = 0, iParamBase = pFunc->iStackIndex - wVar, cFormalType; + BYTE iParamBase = pFunc->iStackIndex - wVar, cFormalType; + int iOffset = wVar; - while ( iOffset < wVar ) + while ( --iOffset >= 0 ) { cFormalType = hb_comp_cParamTypes[ iOffset ]; + /*printf( "\nFormal # %i Type: %c\n", iOffset, cFormalType );*/ + if ( cFormalType == ( ' ' + VT_OFFSET_OPTIONAL ) || cFormalType >= ( 'A' + VT_OFFSET_OPTIONAL ) ) cFormalType -= VT_OFFSET_OPTIONAL; @@ -483,9 +523,43 @@ void hb_compStrongType( int iSize ) ; /* Parameter is NIL, always accepted. */ else if ( cFormalType == '@' && pFunc->pStack[ iParamBase + iOffset ] >= ( 'A' + VT_OFFSET_BYREF ) ) ; /* Prameter is ANY REFERENCE, and Parameter is SOME REFERENCE. */ + else if ( cFormalType == 'S' && pFunc->pStack[ iParamBase + iOffset ] == 'S' && pFunc->iStackClasses ) + { + PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; + + if ( hb_comp_pFormalClass != hb_comp_pParamClass ) + { + sprintf( ( char * ) szType1, "%i", iOffset + 1 ); + sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); + } + } + else if ( cFormalType == 's' && pFunc->pStack[ iParamBase + iOffset ] == 's' && pFunc->iStackClasses ) + { + PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; + + if ( hb_comp_pFormalClass != hb_comp_pParamClass ) + { + sprintf( ( char * ) szType1, "%i", iOffset + 1 ); + sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); + hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); + } + } else if ( cFormalType != pFunc->pStack[ iParamBase + iOffset ] ) { - if ( cFormalType > ( 'A' + VT_OFFSET_BYREF ) ) + if ( cFormalType == 'S' ) + { + PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); + } + else if ( cFormalType == 's' ) + { + PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; + sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); + } + else if ( cFormalType > ( 'A' + VT_OFFSET_BYREF ) ) sprintf( ( char * ) szType2, "@%c", cFormalType - VT_OFFSET_BYREF ); else sprintf( ( char * ) szType2, "%c", cFormalType ); @@ -494,7 +568,6 @@ void hb_compStrongType( int iSize ) hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); } - iOffset++; } } else @@ -1193,6 +1266,7 @@ void hb_compStrongType( int iSize ) pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pVar->pClass; pFunc->pStack[ pFunc->iStackIndex++ ] = 'S'; } + if ( pFunc->pCode[ ulPos ] == HB_P_PUSHSTATICREF ) pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType + VT_OFFSET_BYREF; else @@ -1476,7 +1550,7 @@ void hb_compStrongType( int iSize ) case HB_P_POPVARIABLE : pFunc->iStackIndex--; - if ( pFunc->pStack[ pFunc->iStackIndex ] == 'S' && pFunc->iStackClasses > 0 ) + if ( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses > 0 ) { /* Object of declared class */ pFunc->pStackClasses[ --pFunc->iStackClasses ] = NULL; @@ -1488,7 +1562,7 @@ void hb_compStrongType( int iSize ) /* TODO: check what is aliasedvar? */ pFunc->iStackIndex--; - if ( pFunc->pStack[ pFunc->iStackIndex ] == 'S' && pFunc->iStackClasses > 0 ) + if ( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses > 0 ) { /* Object of declared class */ pFunc->pStackClasses[ --pFunc->iStackClasses ] = NULL; @@ -1538,7 +1612,7 @@ void hb_compStrongType( int iSize ) /* TODO Error Message after finalizing all possible pcodes. */ break; - if ( pFunc->pStack[ pFunc->iStackIndex ] == 'S' && pFunc->iStackClasses > 0 ) + if ( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses > 0 ) { /* Object of declared class */ pFunc->pStackClasses[ --pFunc->iStackClasses ] = NULL; @@ -1601,7 +1675,11 @@ void hb_compStrongType( int iSize ) else { char szType[2]; - if ( islower( pVar->cType ) ) + if ( pVar->cType == 'S' ) + sprintf( ( char * ) szType, "%s", pVar->pClass->szName ); + else if ( pVar->cType == 's' ) + sprintf( ( char * ) szType, "ARRAY OF %s", pVar->pClass->szName ); + else if ( islower( pVar->cType ) ) sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pVar->cType ) ); else sprintf( ( char * ) szType, "%c", pVar->cType ); @@ -1642,7 +1720,11 @@ void hb_compStrongType( int iSize ) else { char szType[2]; - if ( islower( pSym->cType ) ) + if ( pSym->cType == 'S' ) + sprintf( ( char * ) szType, "%s", pSym->pClass->szName ); + else if ( pSym->cType == 's' ) + sprintf( ( char * ) szType, "ARRAY OF %s", pSym->pClass->szName ); + else if ( islower( pSym->cType ) ) sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pSym->cType ) ); else sprintf( ( char * ) szType, "%c", pSym->cType ); @@ -1678,13 +1760,6 @@ void hb_compStrongType( int iSize ) /* TODO Error Message after finalizing all possible pcodes. */ break; - if ( pFunc->pStack[ pFunc->iStackIndex ] == 'S' && pFunc->iStackClasses > 0 ) - { - /* Object of declared class */ - pFunc->pStackClasses[ --pFunc->iStackClasses ] = NULL; - pFunc->pStack[ pFunc->iStackIndex ] = 'O'; - } - if ( pFunc->pCode[ ulPos ] == HB_P_POPLOCAL ) wVar = * ( ( SHORT * ) &( pFunc->pCode )[ ulPos + 1 ] ); else @@ -1722,7 +1797,12 @@ void hb_compStrongType( int iSize ) else { char szType[2]; - if ( islower( pVar->cType ) ) + + if ( pVar->cType == 'S' ) + sprintf( ( char * ) szType, "%s", pVar->pClass->szName ); + else if ( pVar->cType == 's' ) + sprintf( ( char * ) szType, "ARRAY OF %s", pVar->pClass->szName ); + else if ( islower( pVar->cType ) ) sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pVar->cType ) ); else sprintf( ( char * ) szType, "%c", pVar->cType ); @@ -1736,6 +1816,11 @@ void hb_compStrongType( int iSize ) ; /* Array Of may accept any Array */ else if ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); + else if ( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) + { + pFunc->pStackClasses[ --pFunc->iStackClasses ] = NULL; + /* TODO **** */ + } else if ( isupper( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); else if ( toupper( pVar->cType ) != pFunc->pStack[ pFunc->iStackIndex ] ) @@ -1752,7 +1837,7 @@ void hb_compStrongType( int iSize ) /* TODO Error Message after finalizing all possible pcodes. */ break; - if ( pFunc->pStack[ pFunc->iStackIndex ] == 'S' && pFunc->iStackClasses > 0 ) + if ( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses > 0 ) { /* Object of declared class */ pFunc->pStackClasses[ --pFunc->iStackClasses ] = NULL; @@ -1788,7 +1873,11 @@ void hb_compStrongType( int iSize ) else { char szType[2]; - if ( islower( pVar->cType ) ) + if ( pVar->cType == 'S' ) + sprintf( ( char * ) szType, "%s", pVar->pClass->szName ); + else if ( pVar->cType == 's' ) + sprintf( ( char * ) szType, "ARRAY OF %s", pVar->pClass->szName ); + else if ( islower( pVar->cType ) ) sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pVar->cType ) ); else sprintf( ( char * ) szType, "%c", pVar->cType );