From 2fad3600c7252dcc62fb026dbcab38c351dba09f Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Mon, 14 Oct 2002 15:46:57 +0000 Subject: [PATCH] see changelog --- harbour/include/hbcomp.h | 11 ++++---- harbour/include/hbexprb.c | 4 +-- harbour/include/hbmacro.h | 4 +-- harbour/include/hbvmpub.h | 4 +-- harbour/source/compiler/genc.c | 7 ++++- harbour/source/compiler/harbour.c | 44 +++++++++++++++++-------------- harbour/source/compiler/harbour.y | 6 ++--- harbour/source/vm/dynsym.c | 7 ++--- harbour/source/vm/hvm.c | 2 +- harbour/source/vm/macro.c | 16 ++++++----- 10 files changed, 58 insertions(+), 47 deletions(-) diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index c5e46d53cc..57cf25542f 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -342,7 +342,7 @@ extern void hb_compGenPushLogical( int iTrueFalse ); /* pushes a logical val extern void hb_compGenPushLong( long lNumber ); /* Pushes a long number on the virtual machine stack */ extern void hb_compGenPushNil( void ); /* Pushes nil on the virtual machine stack */ extern void hb_compGenPushString( char * szText, ULONG ulLen ); /* Pushes a string on the virtual machine stack */ -extern void hb_compGenPushSymbol( char * szSymbolName, int iIsFunction ); /* Pushes a symbol on to the Virtual machine stack */ +extern void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias ); /* Pushes a symbol on to the Virtual machine stack */ extern void hb_compGenPushAliasedVar( char *, BOOL, char *, long ); extern void hb_compGenPopAliasedVar( char *, BOOL, char *, long ); extern void hb_compGenPushFunRef( char * ); @@ -462,9 +462,9 @@ extern BOOL hb_comp_bDontGenLineNum; extern FILES hb_comp_files; extern int hb_comp_iStaticCnt; extern int hb_comp_iErrorCount; - + extern char * hb_comp_szAnnounce; - + extern PHB_FNAME hb_comp_pOutPath; extern BOOL hb_comp_bCredits; extern BOOL hb_comp_bBuildInfo; @@ -475,13 +475,13 @@ extern BOOL hb_comp_bFileVersionInfo; extern BOOL hb_comp_bLogo; extern BOOL hb_comp_bSyntaxCheckOnly; extern int hb_comp_iLanguage; - + extern USHORT hb_comp_wSeqCounter; extern USHORT hb_comp_wForCounter; extern USHORT hb_comp_wIfCounter; extern USHORT hb_comp_wWhileCounter; extern USHORT hb_comp_wCaseCounter; - + extern char * hb_comp_szDeclaredFun; extern char * hb_comp_szLastMethod; @@ -529,4 +529,3 @@ extern ULONG hb_comp_Supported; #endif #endif /* HB_COMP_H_ */ - diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 2a8a14a344..6c978d2d03 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1587,7 +1587,7 @@ static HB_EXPR_FUNC( hb_compExprUseAlias ) case HB_EA_LVALUE: break; case HB_EA_PUSH_PCODE: - HB_EXPR_PCODE2( hb_compGenPushSymbol, pSelf->value.asSymbol, 0 ); + HB_EXPR_PCODE3( hb_compGenPushSymbol, pSelf->value.asSymbol, FALSE, TRUE ); break; case HB_EA_POP_PCODE: case HB_EA_PUSH_POP: @@ -1637,7 +1637,7 @@ static HB_EXPR_FUNC( hb_compExprUseRTVariable ) break; case HB_EA_PUSH_PCODE: if( pSelf->value.asRTVar.szName ) - HB_EXPR_PCODE2( hb_compGenPushSymbol, pSelf->value.asRTVar.szName, 0 ); /* this is not a functio */ + HB_EXPR_PCODE3( hb_compGenPushSymbol, pSelf->value.asRTVar.szName, FALSE, FALSE ); /* this is not a functio */ else HB_EXPR_USE( pSelf->value.asRTVar.pMacro, HB_EA_PUSH_PCODE ); break; diff --git a/harbour/include/hbmacro.h b/harbour/include/hbmacro.h index 175f870607..163c68366f 100644 --- a/harbour/include/hbmacro.h +++ b/harbour/include/hbmacro.h @@ -133,7 +133,7 @@ extern void hb_compGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_BISON_PTR pMacro ) extern void hb_compGenJumpHere( ULONG ulOffset, HB_BISON_PTR pMacro ); extern ULONG hb_compGenJumpTrue( LONG lOffset, HB_BISON_PTR pMacro ); extern void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_BISON_PTR pMacro ); -extern void hb_compGenPushSymbol( char * szSymbolName, int isFunction, HB_BISON_PTR pMacro ); +extern void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_BISON_PTR pMacro ); extern void hb_compGenPushLong( long lNumber, HB_BISON_PTR pMacro ); extern void hb_compGenMessage( char * szMsgName, HB_BISON_PTR pMacro ); extern void hb_compGenMessageData( char * szMsg, HB_BISON_PTR pMacro ); @@ -159,4 +159,4 @@ extern void hb_compCodeBlockEnd( HB_BISON_PTR pMacro ); } #endif -#endif /* HB_MACRO_H_ */ +#endif /* HB_MACRO_H_ */ \ No newline at end of file diff --git a/harbour/include/hbvmpub.h b/harbour/include/hbvmpub.h index 0fc9500538..4b58efb797 100644 --- a/harbour/include/hbvmpub.h +++ b/harbour/include/hbvmpub.h @@ -93,7 +93,7 @@ typedef struct _HB_DYNS typedef HB_DYNS_FUNC( PHB_DYNS_FUNC ); /* Harbour Functions scope ( HB_SYMBOLSCOPE ) */ -#define HB_FS_PUBLIC ( ( HB_SYMBOLSCOPE ) 0x00 ) +#define HB_FS_PUBLIC ( ( HB_SYMBOLSCOPE ) 0x01 ) #define HB_FS_STATIC ( ( HB_SYMBOLSCOPE ) 0x02 ) #define HB_FS_FIRST ( ( HB_SYMBOLSCOPE ) 0x04 ) #define HB_FS_INIT ( ( HB_SYMBOLSCOPE ) 0x08 ) @@ -108,4 +108,4 @@ extern void HB_EXPORT hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols ); /* } #endif -#endif /* HB_VMPUB_H_ */ +#endif /* HB_VMPUB_H_ */ \ No newline at end of file diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index df2806b3b3..99fbcd6851 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -158,8 +158,13 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou fprintf( yyc, "{ \"%s\", ", pSym->szName ); if( pSym->cScope & HB_FS_STATIC ) + { fprintf( yyc, "HB_FS_STATIC" ); + if( pSym->cScope & HB_FS_PUBLIC ) + fprintf( yyc, " | HB_FS_PUBLIC" ); + } + else if( pSym->cScope & HB_FS_INIT ) fprintf( yyc, "HB_FS_INIT" ); @@ -1990,4 +1995,4 @@ static void hb_compGenCCompact( PFUNCTION pFunc, FILE * yyc ) if( nChar != 0) fprintf( yyc, "\n" ); -} +} \ No newline at end of file diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 31c9bd6407..34df280c72 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -88,18 +88,18 @@ SYMBOLS hb_comp_symbols; PCOMDECLARED hb_comp_pFirstDeclared; PCOMDECLARED hb_comp_pLastDeclared; PCOMDECLARED hb_comp_pReleaseDeclared; - + PCOMCLASS hb_comp_pFirstClass; PCOMCLASS hb_comp_pLastClass; PCOMCLASS hb_comp_pReleaseClass; char * hb_comp_szFromClass; PCOMDECLARED hb_comp_pLastMethod; - + int hb_comp_iLine; /* currently processed line number (globaly) */ char * hb_comp_szFile; /* File Name of last compiled line */ PFUNCTION hb_comp_pInitFunc; PHB_FNAME hb_comp_pFileName = NULL; - + BOOL hb_comp_bPPO = FALSE; /* flag indicating, is ppo output needed */ FILE * hb_comp_yyppo = NULL; /* output .ppo file */ BOOL hb_comp_bStartProc = TRUE; /* holds if we need to create the starting procedure */ @@ -940,7 +940,7 @@ void hb_compDeclaredInit( void ) _DECL s_006 = { "ADEL" , 'A', 2 , (BYTE*)"AN" , NULL , NULL , &s_005}; _DECL s_007 = { "ADIR" , 'N', 6 , (BYTE*)"\x9d\x9b\x9b\x9b\x9b\x9b" , NULL , NULL , &s_006}; _DECL s_008 = { "AEVAL" , 'A', 4 , (BYTE*)"AB\xa8\xa8" , NULL , NULL , &s_007}; - _DECL s_009 = { "AFIELDS" , 'N', 4 , (BYTE*)"A\x9b\x9b\x9b" , NULL , NULL , &s_008}; + _DECL s_009 = { "AFIELDS" , 'N', 4 , (BYTE*)"A\x9b\x9b\x9b" , NULL , NULL , &s_008}; _DECL s_010 = { "AFILL" , 'A', 4 , (BYTE*)"A \xa8\xa8" , NULL , NULL , &s_009}; _DECL s_011 = { "AINS" , 'A', 2 , (BYTE*)"AN" , NULL , NULL , &s_010}; _DECL s_012 = { "ALERT" , 'N', 4 , (BYTE*)"C\x9b\x9d\xa8" , NULL , NULL , &s_011}; @@ -1375,7 +1375,7 @@ PCOMSYMBOL hb_compSymbolAdd( char * szSymbolName, USHORT * pwPos ) pSym = ( PCOMSYMBOL ) hb_xgrab( sizeof( COMSYMBOL ) ); pSym->szName = szSymbolName; - pSym->cScope = 0; + pSym->cScope = HB_FS_PUBLIC; pSym->cType = hb_comp_cVarType; pSym->pNext = NULL; @@ -1690,7 +1690,7 @@ PCOMSYMBOL hb_compSymbolKill( PCOMSYMBOL pSym ) void hb_compGenBreak( void ) { - hb_compGenPushSymbol( hb_strdup("BREAK"), 1 ); + hb_compGenPushSymbol( hb_strdup("BREAK"), TRUE, FALSE ); hb_compGenPushNil(); } @@ -2558,7 +2558,7 @@ void hb_compGenFieldPCode( BYTE bPCode, int wVar, char * szVarName, PFUNCTION pF else if( bPCode == HB_P_PUSHFIELD ) bPCode = HB_P_PUSHALIASEDFIELD; - hb_compGenPushSymbol( hb_strdup( pField->szAlias ), 0 ); + hb_compGenPushSymbol( hb_strdup( pField->szAlias ), FALSE, TRUE ); } hb_compGenVarPCode( bPCode, szVarName ); } @@ -2760,7 +2760,7 @@ void hb_compGenPopAliasedVar( char * szVarName, } else { /* database alias */ - hb_compGenPushSymbol( hb_strdup( szAlias ), 0 ); + hb_compGenPushSymbol( hb_strdup( szAlias ), FALSE, TRUE ); hb_compGenVarPCode( HB_P_POPALIASEDFIELD, szVarName ); } } @@ -3001,7 +3001,7 @@ void hb_compGenPushAliasedVar( char * szVarName, } else { /* database alias */ - hb_compGenPushSymbol( hb_strdup( szAlias ), 0 ); + hb_compGenPushSymbol( hb_strdup( szAlias ), FALSE, TRUE ); hb_compGenVarPCode( HB_P_PUSHALIASEDFIELD, szVarName ); } } @@ -3055,10 +3055,10 @@ void hb_compGenPushFunCall( char * szFunName ) { /* Abbreviated function name was used - change it for whole name */ - hb_compGenPushSymbol( hb_compIdentifierNew( szFunction, TRUE ), 1 ); + hb_compGenPushSymbol( hb_compIdentifierNew( szFunction, TRUE ), TRUE, FALSE ); } else - hb_compGenPushSymbol( szFunName, 1 ); + hb_compGenPushSymbol( szFunName, TRUE, FALSE ); } /* generates the pcode to push a long number on the virtual machine stack */ @@ -3122,19 +3122,24 @@ void hb_compGenPushString( char * szText, ULONG ulStrLen ) } /* generates the pcode to push a symbol on the virtual machine stack */ -void hb_compGenPushSymbol( char * szSymbolName, int iIsFunction ) +void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias ) { + PCOMSYMBOL pSym; USHORT wSym; - if( ! hb_compSymbolFind( szSymbolName, &wSym ) ) /* the symbol was not found on the symbol table */ + if( ( pSym = hb_compSymbolFind( szSymbolName, &wSym ) ) != NULL ) /* the symbol was found on the symbol table */ { - hb_compSymbolAdd( szSymbolName, &wSym ); - if( iIsFunction ) + if( bFunction && ! hb_compFunCallFind( szSymbolName ) ) hb_compFunCallAdd( szSymbolName ); + + if( bAlias ) + pSym->cScope |= HB_FS_PUBLIC; } else { - if( iIsFunction && ! hb_compFunCallFind( szSymbolName ) ) + hb_compSymbolAdd( szSymbolName, &wSym ); + + if( bFunction ) hb_compFunCallAdd( szSymbolName ); } @@ -3144,7 +3149,6 @@ void hb_compGenPushSymbol( char * szSymbolName, int iIsFunction ) hb_compGenPCode2( HB_P_PUSHSYMNEAR, ( BYTE ) wSym, ( BOOL ) 1 ); } - static void hb_compCheckDuplVars( PVAR pVar, char * szVarName ) { while( pVar ) @@ -3574,11 +3578,11 @@ void hb_compSequenceFinish( ULONG ulStartPos, int bUsualStmts ) void hb_compFieldSetAlias( char * szAlias, int iField ) { PVAR pVar; - + pVar = hb_comp_functions.pLast->pFields; while( iField-- && pVar ) pVar = pVar->pNext; - + while( pVar ) { pVar->szAlias = szAlias; @@ -4236,4 +4240,4 @@ int hb_compAutoOpen( char * szPrg, BOOL * pbSkipGen ) } return iStatus; -} +} \ No newline at end of file diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index e4dc256dcb..580e91077b 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -57,7 +57,7 @@ extern void yy_delete_buffer( void * ); /* yacc functions to manage multiple fil /* lex & yacc related prototypes */ #if !defined(__GNUC__) && !defined(__IBMCPP__) #if 0 - /* This makes BCC 551 fail with Bison 1.30, even with the + /* This makes BCC 551 fail with Bison 1.30, even with the supplied harbour.simple file, which makes Bison 1.30 blow. [vszakats] */ void __yy_memcpy ( char*, const char*, unsigned int ); /* to satisfy Borland compiler */ @@ -2011,7 +2011,7 @@ static void hb_compRTVariableGen( char * szCreateFun ) HB_RTVAR_PTR pDel; /* generate the function call frame */ - hb_compGenPushSymbol( hb_strdup( szCreateFun ), 1); + hb_compGenPushSymbol( hb_strdup( szCreateFun ), TRUE, FALSE ); hb_compGenPushNil(); /* push variable names to create */ @@ -2083,4 +2083,4 @@ static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName ) ) ); } -} +} \ No newline at end of file diff --git a/harbour/source/vm/dynsym.c b/harbour/source/vm/dynsym.c index d4212330e7..5f1f8f3278 100644 --- a/harbour/source/vm/dynsym.c +++ b/harbour/source/vm/dynsym.c @@ -100,9 +100,10 @@ PHB_DYNS hb_dynsymNew( PHB_SYMB pSymbol ) /* creates a new dynamic symbol */ HB_TRACE(HB_TR_DEBUG, ("hb_dynsymNew(%p)", pSymbol)); pDynSym = hb_dynsymFind( pSymbol->szName ); /* Find position */ + if( pDynSym ) /* If name exists */ { - if( ! ( pSymbol->cScope & ( HB_FS_STATIC | HB_FS_INIT | HB_FS_EXIT ) ) ) /* only for HB_FS_PUBLIC */ + if( pSymbol->cScope & HB_FS_PUBLIC ) /* only for HB_FS_PUBLIC */ { if( ( ! pDynSym->pFunPtr ) && pSymbol->pFunPtr ) /* The DynSym existed */ { @@ -144,7 +145,7 @@ PHB_DYNS hb_dynsymNew( PHB_SYMB pSymbol ) /* creates a new dynamic symbol */ pDynSym->ulTime = 0; /* profiler support */ pDynSym->ulRecurse = 0; - if( ! ( pSymbol->cScope & ( HB_FS_STATIC | HB_FS_INIT | HB_FS_EXIT ) ) ) /* only for HB_FS_PUBLIC */ + if( pSymbol->cScope & HB_FS_PUBLIC ) /* only for HB_FS_PUBLIC */ { if( pDynSym->pFunPtr != pSymbol->pFunPtr ) /* it contains a function pointer */ pDynSym->pFunPtr = pSymbol->pFunPtr; /* place the function at DynSym */ @@ -397,4 +398,4 @@ HB_FUNC( __DYNSGETPRF ) /* profiler: It returns an array with a function or proc } } -#endif +#endif \ No newline at end of file diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index bb0e60bd16..8a7591fca2 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -4466,7 +4466,7 @@ void HB_EXPORT hb_vmProcessSymbols( PHB_SYMB pModuleSymbols, USHORT uiModuleSymb if( ( ! s_pSymStart ) && ( hSymScope & HB_FS_FIRST && ! ( hSymScope & HB_FS_INITEXIT ) ) ) s_pSymStart = pModuleSymbols + ui; /* first public defined symbol to start execution */ - if( ( hSymScope == HB_FS_PUBLIC ) || ( hSymScope & ( HB_FS_MESSAGE | HB_FS_MEMVAR | HB_FS_FIRST ) ) ) + if( hSymScope & ( HB_FS_PUBLIC | HB_FS_MESSAGE | HB_FS_MEMVAR | HB_FS_FIRST ) ) hb_dynsymNew( pModuleSymbols + ui ); } } diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index f1cb7138e2..dcc4284f95 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -1,4 +1,4 @@ -/* +/* * $Id$ */ @@ -1108,11 +1108,13 @@ void hb_compMemvarGenPCode( BYTE bPCode, char * szVarName, HB_MACRO_DECL ) } /* generates the pcode to push a symbol on the virtual machine stack */ -void hb_compGenPushSymbol( char * szSymbolName, int isFunction, HB_MACRO_DECL ) +void hb_compGenPushSymbol( char * szSymbolName, BOOL bFunction, BOOL bAlias, HB_MACRO_DECL ) { HB_DYNS_PTR pSym; - HB_SYMBOL_UNUSED( isFunction ); + HB_SYMBOL_UNUSED( bFunction ); + HB_SYMBOL_UNUSED( bAlias ); + if( HB_MACRO_DATA->Flags & HB_MACRO_GEN_TYPE ) { /* we are determining the type of expression (called from TYPE() function) @@ -1236,7 +1238,7 @@ void hb_compGenPopAliasedVar( char * szVarName, } else { /* database alias */ - hb_compGenPushSymbol( szAlias, 0, HB_MACRO_PARAM ); + hb_compGenPushSymbol( szAlias, FALSE, TRUE, HB_MACRO_PARAM ); hb_compMemvarGenPCode( HB_P_MPOPALIASEDFIELD, szVarName, HB_MACRO_PARAM ); } } @@ -1338,7 +1340,7 @@ void hb_compGenPushAliasedVar( char * szVarName, } else { /* database alias */ - hb_compGenPushSymbol( szAlias, 0, HB_MACRO_PARAM ); + hb_compGenPushSymbol( szAlias, FALSE, TRUE, HB_MACRO_PARAM ); hb_compMemvarGenPCode( HB_P_MPUSHALIASEDFIELD, szVarName, HB_MACRO_PARAM ); } } @@ -1388,12 +1390,12 @@ void hb_compGenPushFunCall( char * szFunName, HB_MACRO_DECL ) { /* Abbreviated function name was used - change it for whole name */ - hb_compGenPushSymbol( szFunction, 0, HB_MACRO_PARAM ); + hb_compGenPushSymbol( szFunction, FALSE, FALSE, HB_MACRO_PARAM ); } else { HB_MACRO_DATA->status |= HB_MACRO_UDF; /* this is used in hb_macroGetType */ - hb_compGenPushSymbol( szFunName, 0, HB_MACRO_PARAM ); + hb_compGenPushSymbol( szFunName, FALSE, FALSE, HB_MACRO_PARAM ); } }