diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6e4f66f025..b680ef0562 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,21 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-09-01 16:43 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbcomp.h + * harbour/include/hbcompdf.h + * harbour/source/compiler/hbmain.c + * harbour/source/compiler/genc.c + * harbour/source/compiler/genhrb.c + % removed FUNCALLS internal structures and functions. + It simplifies compiler code, reduce memory usage and + increase performance due to eliminating unnecessary + structures which were update and scanned in previous. + Now we have all necessary information in symbol table. + + * harbour/contrib/hbnetio/netiocli.c + + added support for DNS addresses + 2009-09-01 14:02 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/config/global.mk ! fixed MinGW prefix detection in some cross installations, i.e. diff --git a/harbour/contrib/hbnetio/netiocli.c b/harbour/contrib/hbnetio/netiocli.c index 5252daf1dd..7a55ad2485 100644 --- a/harbour/contrib/hbnetio/netiocli.c +++ b/harbour/contrib/hbnetio/netiocli.c @@ -300,6 +300,7 @@ static PHB_CONCLI s_fileConnect( const char ** pszFilename, HB_SOCKET sd; PHB_CONDATA pConData = ( PHB_CONDATA ) hb_stackGetTSD( &s_conData ); char server[ NETIO_SERVERNAME_MAX ]; + char * pszIpAddres; if( pConData->port ) { @@ -369,7 +370,11 @@ static PHB_CONCLI s_fileConnect( const char ** pszFilename, } } - conn = s_fileConFind( pszServer, iPort ); + pszIpAddres = hb_socketResolveAddr( pszServer, HB_SOCKET_AF_INET ); + if( pszIpAddres == NULL ) + return NULL; + + conn = s_fileConFind( pszIpAddres, iPort ); if( conn == NULL ) { sd = hb_socketOpen( HB_SOCKET_PF_INET, HB_SOCKET_PT_STREAM, 0 ); @@ -378,7 +383,7 @@ static PHB_CONCLI s_fileConnect( const char ** pszFilename, void * pSockAddr; unsigned uiLen; - if( hb_socketInetAddr( &pSockAddr, &uiLen, pszServer, iPort ) ) + if( hb_socketInetAddr( &pSockAddr, &uiLen, pszIpAddres, iPort ) ) { hb_socketSetKeepAlive( sd, TRUE ); if( hb_socketConnect( sd, pSockAddr, uiLen, iTimeOut ) == 0 ) @@ -390,7 +395,7 @@ static PHB_CONCLI s_fileConnect( const char ** pszFilename, HB_PUT_LE_UINT16( &msgbuf[ 4 ], len ); memset( msgbuf + 6, '\0', sizeof( msgbuf ) - 6 ); - conn = s_fileConNew( sd, pszServer, iPort, iTimeOut ); + conn = s_fileConNew( sd, pszIpAddres, iPort, iTimeOut ); sd = HB_NO_SOCKET; if( !s_fileSendMsg( conn, msgbuf, NETIO_LOGINSTRID, len, TRUE ) || @@ -414,8 +419,7 @@ static PHB_CONCLI s_fileConnect( const char ** pszFilename, HB_NETIO_LOCK if( s_defaultInit ) { - if( pszServer != s_defaultServer ) - hb_strncpy( s_defaultServer, pszServer, sizeof( s_defaultServer ) - 1 ); + hb_strncpy( s_defaultServer, pszIpAddres, sizeof( s_defaultServer ) - 1 ); s_defaultPort = iPort; s_defaultTimeOut = iTimeOut; s_defaultInit = FALSE; @@ -423,6 +427,8 @@ static PHB_CONCLI s_fileConnect( const char ** pszFilename, HB_NETIO_UNLOCK } + hb_xfree( pszIpAddres ); + return conn; } diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 66a6a0b90e..10d7fdbe3e 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -138,16 +138,9 @@ extern int hb_compVariableScope( HB_COMP_DECL, const char * ); #define FUN_ATTACHED 0x0100 /* function attached to function list */ extern void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */ -extern PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunName ); /* locates a previously defined function */ -extern void hb_compAnnounce( HB_COMP_DECL, const char * ); - -extern PINLINE hb_compInlineAdd( HB_COMP_DECL, const char * szFunName, int iLine ); -extern PINLINE hb_compInlineFind( HB_COMP_DECL, const char * szFunName ); - -extern void hb_compFunctionMarkStatic( HB_COMP_DECL, const char * szFunName ); - -extern PFUNCALL hb_compFunCallFind( HB_COMP_DECL, const char * szFunName ); /* locates a previously defined called function */ extern BOOL hb_compFunCallCheck( HB_COMP_DECL, const char *, int ); +extern PINLINE hb_compInlineAdd( HB_COMP_DECL, const char * szFunName, int iLine ); +extern void hb_compFunctionMarkStatic( HB_COMP_DECL, const char * szFunName ); extern PHB_VARTYPE hb_compVarTypeNew( HB_COMP_DECL, char cVarType, const char * szFromClass ); extern void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, PHB_VARTYPE pVarType ); /* add a new param, local, static variable to a function definition or a public or private */ @@ -171,7 +164,6 @@ extern void hb_compDeclaredParameterAdd( HB_COMP_DECL, const char * szVarName, P extern void hb_compGenBreak( HB_COMP_DECL ); /* generate code for BREAK statement */ -extern void hb_compExternGen( HB_COMP_DECL ); /* generates the symbols for the EXTERN names */ extern void hb_compExternAdd( HB_COMP_DECL, const char * szExternName, HB_SYMBOLSCOPE cScope ); /* defines a new extern name */ extern void hb_compModuleAdd( HB_COMP_DECL, const char * szModuleName, BOOL fForce ); diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index 1920b48347..a6b2a4b2ad 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -459,14 +459,6 @@ typedef struct int iCount; /* number of defined inlines */ } INLINES; -/* structure to control all Clipper defined functions */ -typedef struct -{ - PFUNCALL pFirst; /* pointer to the first called funtion */ - PFUNCALL pLast; /* pointer to the last called function */ - int iCount; /* number of defined functions */ -} FUNCALLS; - /* compiler symbol support structure */ typedef struct _COMSYMBOL { @@ -638,7 +630,6 @@ typedef struct _HB_COMP HB_HASH_TABLE_PTR pIdentifiers; FUNCTIONS functions; - FUNCALLS funcalls; SYMBOLS symbols; INLINES inlines; PEXTERN externs; diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 1d658ce752..1c8d57d2ca 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -318,7 +318,7 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the } else if( pSym->cScope & HB_FS_DEFERRED ) /* is it a function declared as dynamic */ fprintf( yyc, " | HB_FS_DEFERRED}, {NULL}, NULL }" ); - else if( pSym->bFunc /* && hb_compFunCallFind( HB_COMP_PARAM, pSym->szName ) */ ) /* is it a function called from this module */ + else if( pSym->bFunc ) /* is it a function called from this module */ hb_compGenCFunc( yyc, "}, {HB_FUNCNAME( %s )}, NULL }", pSym->szName, FALSE ); else fprintf( yyc, "}, {NULL}, NULL }" ); /* memvar | alias | message */ diff --git a/harbour/source/compiler/genhrb.c b/harbour/source/compiler/genhrb.c index a071ebab31..75f352c943 100644 --- a/harbour/source/compiler/genhrb.c +++ b/harbour/source/compiler/genhrb.c @@ -106,12 +106,11 @@ void hb_compGenBufPortObj( HB_COMP_DECL, BYTE ** pBufPtr, ULONG * pulSize ) */ *ptr++ = ( BYTE ) pSym->cScope; /* symbol type */ - /* if( hb_compFunctionFind( HB_COMP_PARAM, pSym->szName ) ) */ if( pSym->cScope & HB_FS_LOCAL ) *ptr++ = SYM_FUNC; /* function defined in this module */ else if( pSym->cScope & HB_FS_DEFERRED ) *ptr++ = SYM_DEFERRED; /* lately bound function */ - else if( pSym->bFunc /* && hb_compFunCallFind( HB_COMP_PARAM, pSym->szName ) */ ) + else if( pSym->bFunc ) *ptr++ = SYM_EXTERN; /* external function */ else *ptr++ = SYM_NOLINK; /* other symbol */ diff --git a/harbour/source/compiler/hbmain.c b/harbour/source/compiler/hbmain.c index c4516f56fb..f7996ebe49 100644 --- a/harbour/source/compiler/hbmain.c +++ b/harbour/source/compiler/hbmain.c @@ -1899,34 +1899,6 @@ static PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) return pNext; } -/* - * This function adds the name of called function into the list - * as they have to be placed on the symbol table later than the - * first public symbol - */ -static PFUNCALL hb_compFunCallAdd( HB_COMP_DECL, const char * szFunctionName, - HB_SYMBOLSCOPE cScope ) -{ - PFUNCALL pFunc = ( PFUNCALL ) hb_xgrab( sizeof( _FUNCALL ) ); - - pFunc->szName = szFunctionName; - pFunc->cScope = cScope; - pFunc->pNext = NULL; - if( ! HB_COMP_PARAM->funcalls.iCount ) - { - HB_COMP_PARAM->funcalls.pFirst = pFunc; - HB_COMP_PARAM->funcalls.pLast = pFunc; - } - else - { - HB_COMP_PARAM->funcalls.pLast->pNext = pFunc; - HB_COMP_PARAM->funcalls.pLast = pFunc; - } - HB_COMP_PARAM->funcalls.iCount++; - - return pFunc; -} - /* * This function adds the name of external symbol into the list of externals * as they have to be placed on the symbol table later than the first @@ -1979,6 +1951,34 @@ static void hb_compAddFunc( HB_COMP_DECL, PFUNCTION pFunc ) HB_COMP_PARAM->functions.iCount++; } +static PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunctionName ) +{ + PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst; + + while( pFunc ) + { + if( ( pFunc->funFlags & FUN_FILE_DECL ) == 0 && + ! strcmp( pFunc->szName, szFunctionName ) ) + break; + pFunc = pFunc->pNext; + } + return pFunc; +} + +static BOOL hb_compIsModuleFunc( HB_COMP_DECL, const char * szFunctionName ) +{ + PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst; + + while( pFunc ) + { + if( ( pFunc->cScope & HB_FS_STATIC ) == 0 && + hb_stricmp( pFunc->szName, szFunctionName ) == 0 ) + break; + pFunc = pFunc->pNext; + } + return pFunc != NULL; +} + static BOOL hb_compRegisterFunc( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, BOOL fError ) { @@ -2066,23 +2066,12 @@ void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cS void hb_compFunctionMarkStatic( HB_COMP_DECL, const char * szFunName ) { - if( hb_compFunctionFind( HB_COMP_PARAM, szFunName ) == NULL ) + PCOMSYMBOL pSym = hb_compSymbolFind( HB_COMP_PARAM, szFunName, NULL, HB_SYM_FUNCNAME ); + + if( pSym ) { - PFUNCALL pFunc = hb_compFunCallFind( HB_COMP_PARAM, szFunName ); - - if( pFunc ) - { - PCOMSYMBOL pSym = hb_compSymbolFind( HB_COMP_PARAM, szFunName, NULL, HB_SYM_FUNCNAME ); - - if( pSym ) - { - if( ( pSym->cScope & HB_FS_DEFERRED ) == 0 ) - { - pSym->cScope |= HB_FS_STATIC | HB_FS_LOCAL; - pFunc->cScope |= HB_FS_STATIC; - } - } - } + if( ( pSym->cScope & ( HB_FS_DEFERRED | HB_FS_LOCAL ) ) == 0 ) + pSym->cScope |= HB_FS_STATIC | HB_FS_LOCAL; } } @@ -2119,7 +2108,7 @@ PINLINE hb_compInlineAdd( HB_COMP_DECL, const char * szFunName, int iLine ) /* create an ANNOUNCEd procedure */ -void hb_compAnnounce( HB_COMP_DECL, const char * szFunName ) +static void hb_compAnnounce( HB_COMP_DECL, const char * szFunName ) { PFUNCTION pFunc; @@ -2159,7 +2148,8 @@ void hb_compGenBreak( HB_COMP_DECL ) hb_compGenPushFunCall( "BREAK", HB_COMP_PARAM ); } -void hb_compExternGen( HB_COMP_DECL ) /* generates the symbols for the EXTERN names */ +/* generates the symbols for the EXTERN names */ +static void hb_compExternGen( HB_COMP_DECL ) { PEXTERN pDelete; @@ -2173,21 +2163,12 @@ void hb_compExternGen( HB_COMP_DECL ) /* generates the symbols for the EXTERN na if( pSym ) { - PFUNCALL pFunc = hb_compFunCallFind( HB_COMP_PARAM, HB_COMP_PARAM->externs->szName ); pSym->cScope |= cScope; - if( !pFunc ) - { - if( ( cScope & HB_FS_DEFERRED ) == 0 ) - hb_compFunCallAdd( HB_COMP_PARAM, HB_COMP_PARAM->externs->szName, pSym->cScope ); - } - else - pFunc->cScope |= pSym->cScope; } else if( ( cScope & HB_FS_DEFERRED ) == 0 ) { pSym = hb_compSymbolAdd( HB_COMP_PARAM, HB_COMP_PARAM->externs->szName, NULL, HB_SYM_FUNCNAME ); pSym->cScope |= cScope; - hb_compFunCallAdd( HB_COMP_PARAM, HB_COMP_PARAM->externs->szName, pSym->cScope ); } pDelete = HB_COMP_PARAM->externs; HB_COMP_PARAM->externs = HB_COMP_PARAM->externs->pNext; @@ -2195,60 +2176,6 @@ void hb_compExternGen( HB_COMP_DECL ) /* generates the symbols for the EXTERN na } } -PFUNCALL hb_compFunCallFind( HB_COMP_DECL, const char * szFunctionName ) /* returns a previously called defined function */ -{ - PFUNCALL pFunc = HB_COMP_PARAM->funcalls.pFirst; - - while( pFunc ) - { - if( ! strcmp( pFunc->szName, szFunctionName ) ) - break; - pFunc = pFunc->pNext; - } - return pFunc; -} - -PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunctionName ) /* returns a previously defined function */ -{ - PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst; - - while( pFunc ) - { - if( ( pFunc->funFlags & FUN_FILE_DECL ) == 0 && - ! strcmp( pFunc->szName, szFunctionName ) ) - break; - pFunc = pFunc->pNext; - } - return pFunc; -} - -PINLINE hb_compInlineFind( HB_COMP_DECL, const char * szFunctionName ) -{ - PINLINE pInline = HB_COMP_PARAM->inlines.pFirst; - - while( pInline ) - { - if( pInline->szName && strcmp( pInline->szName, szFunctionName ) == 0 ) - break; - pInline = pInline->pNext; - } - return pInline; -} - -static BOOL hb_compIsModuleFunc( HB_COMP_DECL, const char * szFunctionName ) -{ - PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst; - - while( pFunc ) - { - if( ( pFunc->cScope & HB_FS_STATIC ) == 0 && - hb_stricmp( pFunc->szName, szFunctionName ) == 0 ) - break; - pFunc = pFunc->pNext; - } - return pFunc != NULL; -} - static void hb_compNOOPadd( PFUNCTION pFunc, ULONG ulPos ) { pFunc->pCode[ ulPos ] = HB_P_NOOP; @@ -2933,16 +2860,9 @@ void hb_compGenPushFunCall( const char * szFunName, HB_COMP_DECL ) if( szFunction ) szFunName = szFunction; - if( hb_compSymbolFind( HB_COMP_PARAM, szFunName, &wSym, HB_SYM_FUNCNAME ) != NULL ) - { - if( ! hb_compFunCallFind( HB_COMP_PARAM, szFunName ) ) - hb_compFunCallAdd( HB_COMP_PARAM, szFunName, 0 ); - } - else - { + if( !hb_compSymbolFind( HB_COMP_PARAM, szFunName, &wSym, HB_SYM_FUNCNAME ) ) hb_compSymbolAdd( HB_COMP_PARAM, szFunName, &wSym, HB_SYM_FUNCNAME ); - hb_compFunCallAdd( HB_COMP_PARAM, szFunName, 0 ); - } + hb_compGenPCode3( HB_P_PUSHFUNCSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ), HB_COMP_PARAM ); } @@ -2971,17 +2891,8 @@ void hb_compGenPushSymbol( const char * szSymbolName, BOOL bFunction, HB_COMP_DE { USHORT wSym; - if( hb_compSymbolFind( HB_COMP_PARAM, szSymbolName, &wSym, bFunction ) != NULL ) /* the symbol was found on the symbol table */ - { - if( bFunction && ! hb_compFunCallFind( HB_COMP_PARAM, szSymbolName ) ) - hb_compFunCallAdd( HB_COMP_PARAM, szSymbolName, 0 ); - } - else - { + if( !hb_compSymbolFind( HB_COMP_PARAM, szSymbolName, &wSym, bFunction ) ) hb_compSymbolAdd( HB_COMP_PARAM, szSymbolName, &wSym, bFunction ); - if( bFunction ) - hb_compFunCallAdd( HB_COMP_PARAM, szSymbolName, 0 ); - } if( wSym > 255 ) hb_compGenPCode3( HB_P_PUSHSYM, HB_LOBYTE( wSym ), HB_HIBYTE( wSym ), HB_COMP_PARAM ); @@ -3729,9 +3640,6 @@ static void hb_compInitVars( HB_COMP_DECL ) HB_COMP_PARAM->functions.iCount = 0; HB_COMP_PARAM->functions.pFirst = NULL; HB_COMP_PARAM->functions.pLast = NULL; - HB_COMP_PARAM->funcalls.iCount = 0; - HB_COMP_PARAM->funcalls.pFirst = NULL; - HB_COMP_PARAM->funcalls.pLast = NULL; HB_COMP_PARAM->szAnnounce = NULL; HB_COMP_PARAM->fLongOptimize = TRUE; @@ -3891,14 +3799,6 @@ void hb_compCompileEnd( HB_COMP_DECL ) HB_COMP_PARAM->functions.pFirst = NULL; } - while( HB_COMP_PARAM->funcalls.pFirst ) - { - PFUNCALL pFunc = HB_COMP_PARAM->funcalls.pFirst; - - HB_COMP_PARAM->funcalls.pFirst = pFunc->pNext; - hb_xfree( ( void * ) pFunc ); - } - while( HB_COMP_PARAM->externs ) { PEXTERN pExtern = HB_COMP_PARAM->externs; @@ -4223,7 +4123,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff hb_compOptimizeFrames( HB_COMP_PARAM, pFunc ); if( szFirstFunction == NULL && - ! ( pFunc->cScope & (HB_FS_INIT | HB_FS_EXIT) ) ) + ! ( pFunc->cScope & ( HB_FS_INIT | HB_FS_EXIT ) ) ) { szFirstFunction = pFunc->szName; }