Index: BasicCompiler32/MakePeHdr.cpp
===================================================================
--- BasicCompiler32/MakePeHdr.cpp	(revision 73)
+++ BasicCompiler32/MakePeHdr.cpp	(revision 75)
@@ -8,5 +8,5 @@
 // 特殊関数の構造体ポインタ
 ////////////////////////////
-SubInfo
+UserProc
 	*pSub_System_StartupProgram,
 	*pSub_DebugSys_StartProc,
@@ -150,7 +150,7 @@
 
 	//関数ポインタ情報を初期化
-	extern PROCPTRINFO *pProcPtrInfo;
+	extern ProcPointer **ppProcPtrInfo;
 	extern int ProcPtrInfoNum;
-	pProcPtrInfo=(PROCPTRINFO *)HeapAlloc(hHeap,0,1);
+	ppProcPtrInfo=(ProcPointer **)HeapAlloc(hHeap,0,1);
 	ProcPtrInfoNum=0;
 
@@ -184,95 +184,95 @@
 
 	if(pSub_System_StartupProgram=GetSubHash("_System_StartupProgram",1))
-		pSub_System_StartupProgram->bUse=1;
+		pSub_System_StartupProgram->Using();
 
 	if(pSub_DebugSys_StartProc=GetSubHash("_DebugSys_StartProc",1))
-		pSub_DebugSys_StartProc->bUse=1;
+		pSub_DebugSys_StartProc->Using();
 
 	if(pSub_DebugSys_EndProc=GetSubHash("_DebugSys_EndProc",1))
-		pSub_DebugSys_EndProc->bUse=1;
+		pSub_DebugSys_EndProc->Using();
 
 	if(pSub_DebugSys_SaveContext=GetSubHash("_DebugSys_SaveContext",1))
-		pSub_DebugSys_SaveContext->bUse=1;
+		pSub_DebugSys_SaveContext->Using();
 
 	if(pSub_System_GetEip=GetSubHash("_System_GetEip",1)){
-		pSub_System_GetEip->bUse=1;
-		pSub_System_GetEip->bSystem=1;
+		pSub_System_GetEip->Using();
+		pSub_System_GetEip->ThisIsSystemProc();
 	}
 
 	if(pSub_System_InitDllGlobalVariables=GetSubHash("_System_InitDllGlobalVariables",1)){
-		pSub_System_InitDllGlobalVariables->bUse=1;
-		pSub_System_InitDllGlobalVariables->bSystem=1;
+		pSub_System_InitDllGlobalVariables->Using();
+		pSub_System_InitDllGlobalVariables->ThisIsSystemProc();
 	}
 
 	if(pSub_System_InitStaticLocalVariables=GetSubHash("_System_InitStaticLocalVariables",1)){
-		pSub_System_InitStaticLocalVariables->bUse=1;
-		pSub_System_InitStaticLocalVariables->bSystem=1;
+		pSub_System_InitStaticLocalVariables->Using();
+		pSub_System_InitStaticLocalVariables->ThisIsSystemProc();
 	}
 
 	if(pSub_System_Call_Destructor_of_GlobalObject=GetSubHash("_System_Call_Destructor_of_GlobalObject",1)){
-		pSub_System_Call_Destructor_of_GlobalObject->bUse=1;
-		pSub_System_Call_Destructor_of_GlobalObject->bSystem=1;
+		pSub_System_Call_Destructor_of_GlobalObject->Using();
+		pSub_System_Call_Destructor_of_GlobalObject->ThisIsSystemProc();
 	}
 
 	if(pSub_System_GetSp=GetSubHash("_System_GetSp",1)){
-		pSub_System_GetSp->bUse=1;
-		pSub_System_GetSp->bSystem=1;
+		pSub_System_GetSp->Using();
+		pSub_System_GetSp->ThisIsSystemProc();
 	}
 
 	if(pSub_pow=GetSubHash("pow",1))
-		pSub_pow->bUse=1;
+		pSub_pow->Using();
 
 	if(pSub_calloc=GetSubHash("calloc",1))
-		pSub_calloc->bUse=1;
+		pSub_calloc->Using();
 
 	if(pSub_realloc=GetSubHash("realloc",1))
-		pSub_realloc->bUse=1;
+		pSub_realloc->Using();
 
 	if(pSub_free=GetSubHash("free",1))
-		pSub_free->bUse=1;
+		pSub_free->Using();
 
 	if( pSub_System_GC_malloc_ForObject = GetSubHash( "_System_GC_malloc_ForObject",1 ) )
-		pSub_System_GC_malloc_ForObject->bUse = 1;
+		pSub_System_GC_malloc_ForObject->Using();
 
 	if( pSub_System_GC_malloc_ForObjectPtr = GetSubHash( "_System_GC_malloc_ForObjectPtr",1 ) )
-		pSub_System_GC_malloc_ForObjectPtr->bUse = 1;
+		pSub_System_GC_malloc_ForObjectPtr->Using();
 
 	if( pSub_System_GC_free_for_SweepingDelete = GetSubHash( "_System_GC_free_for_SweepingDelete",1 ) )
-		pSub_System_GC_free_for_SweepingDelete->bUse = 1;
+		pSub_System_GC_free_for_SweepingDelete->Using();
 
 	pSub_allrem=GetSubHash("_allrem");
-	pSub_allrem->bUse=1;
-	pSub_allrem->bSystem=1;
+	pSub_allrem->Using();
+	pSub_allrem->ThisIsSystemProc();
 
 	pSub_aullrem=GetSubHash("_aullrem");
-	pSub_aullrem->bUse=1;
-	pSub_aullrem->bSystem=1;
+	pSub_aullrem->Using();
+	pSub_aullrem->ThisIsSystemProc();
 
 	pSub_allmul=GetSubHash("_allmul");
-	pSub_allmul->bUse=1;
-	pSub_allmul->bSystem=1;
+	pSub_allmul->Using();
+	pSub_allmul->ThisIsSystemProc();
 
 	pSub_alldiv=GetSubHash("_alldiv");
-	pSub_alldiv->bUse=1;
-	pSub_alldiv->bSystem=1;
+	pSub_alldiv->Using();
+	pSub_alldiv->ThisIsSystemProc();
 
 	pSub_aulldiv=GetSubHash("_aulldiv");
-	pSub_aulldiv->bUse=1;
-	pSub_aulldiv->bSystem=1;
+	pSub_aulldiv->Using();
+	pSub_aulldiv->ThisIsSystemProc();
 
 	pSub_allshl=GetSubHash("_allshl");
-	pSub_allshl->bUse=1;
-	pSub_allshl->bSystem=1;
+	pSub_allshl->Using();
+	pSub_allshl->ThisIsSystemProc();
 
 	pSub_allshr=GetSubHash("_allshr");
-	pSub_allshr->bUse=1;
-	pSub_allshr->bSystem=1;
+	pSub_allshr->Using();
+	pSub_allshr->ThisIsSystemProc();
 
 	pSub_aullshr=GetSubHash("_aullshr");
-	pSub_aullshr->bUse=1;
-	pSub_aullshr->bSystem=1;
+	pSub_aullshr->Using();
+	pSub_aullshr->ThisIsSystemProc();
 
 	pSub_esp_error=GetSubHash("_esp_error");
-	pSub_esp_error->bUse=1;
+	pSub_esp_error->Using();
 
 
@@ -391,5 +391,5 @@
 
 		//call _System_Call_Destructor_of_GlobalObject
-		extern SubInfo *pSub_System_Call_Destructor_of_GlobalObject;
+		extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;
 		op_call(pSub_System_Call_Destructor_of_GlobalObject);
 
@@ -425,4 +425,5 @@
 	for(i=0;i<SynonymErrorNum;i++) HeapDefaultFree(SynonymErrorWords[i]);
 	HeapDefaultFree(SynonymErrorWords);
+	SynonymErrorWords=0;
 
 
@@ -451,10 +452,9 @@
 	////////////////////////////////
 	for(i=0;i<MAX_HASH;i++){
-		extern DECLAREINFO **ppDeclareHash;
-		DECLAREINFO *pdi;
-		pdi=ppDeclareHash[i];
-		while(pdi){
-			if(pdi->bUse==0){
-				pdi=pdi->pNextData;
+		extern DllProc **ppDeclareHash;
+		const DllProc *pDllProc = ppDeclareHash[i];
+		while(pDllProc){
+			if( !pDllProc->IsUsing() ){
+				pDllProc=pDllProc->pNextData;
 				continue;
 			}
@@ -462,5 +462,5 @@
 			//エラーチェック
 			HINSTANCE hLib;
-			hLib=LoadLibrary(pdi->file);
+			hLib=LoadLibrary( pDllProc->GetDllFileName().c_str() );
 			if(!hLib){
 				extern char OutputFileName[MAX_PATH];
@@ -468,22 +468,22 @@
 				_splitpath(OutputFileName,temp2,temp3,NULL,NULL);
 				lstrcat(temp2,temp3);
-				lstrcpy(temp3,pdi->file);
+				lstrcpy(temp3,pDllProc->GetDllFileName().c_str());
 				GetFullPath(temp3,temp2);
 				hLib=LoadLibrary(temp3);
 
 				if(!hLib){
-					SetError(-106,pdi->file,pdi->pos);
+					SetError(-106,pDllProc->GetDllFileName().c_str(),pDllProc->GetCodePos());
 				}
 			}
 
 			if(hLib){
-				if(!GetProcAddress(hLib,pdi->alias)){
+				if(!GetProcAddress(hLib,pDllProc->GetAlias().c_str())){
 					FreeLibrary(hLib);
-					SetError(-107,pdi->alias,pdi->pos);
+					SetError(-107,pDllProc->GetAlias(),pDllProc->GetCodePos());
 				}
 				FreeLibrary(hLib);
 			}
 
-			pdi=pdi->pNextData;
+			pDllProc=pDllProc->pNextData;
 		}
 	}
@@ -522,40 +522,41 @@
 		ExportNamesLength=lstrlen(lpExportNames)+1;
 
-		extern SubInfo **ppSubHash;
-		SubInfo *psi,*psi2;
+		extern UserProc **ppSubHash;
+		UserProc *pUserProc,*psi2;
 		while(1){
 			//辞書順にサーチ
 			temporary[0]=0;
 			for(i=0,psi2=0;i<MAX_HASH;i++){
-				psi=ppSubHash[i];
-				while(psi){
-					if(psi->bExport){
+				pUserProc=ppSubHash[i];
+				while(pUserProc){
+					if(pUserProc->IsExport()){
 						if(temporary[0]=='\0'){
-							lstrcpy(temporary,psi->name);
-							psi2=psi;
+							lstrcpy(temporary,pUserProc->GetName().c_str());
+							psi2=pUserProc;
 						}
 						else{
 							i3=lstrlen(temporary);
-							i4=lstrlen(psi->name);
+							i4=(int)pUserProc->GetName().size();
 							if(i3<i4) i3=i4;
-							if(memcmp(temporary,psi->name,i3)>0){
-								lstrcpy(temporary,psi->name);
-								psi2=psi;
+							if(memcmp(temporary,pUserProc->GetName().c_str(),i3)>0){
+								lstrcpy(temporary,pUserProc->GetName().c_str());
+								psi2=pUserProc;
 							}
 						}
 					}
-					psi=psi->pNextData;
+					pUserProc=pUserProc->pNextData;
 				}
 			}
 			if(psi2==0) break;
-			psi=psi2;
-
-			psi->bExport=0;
-
-			if(lstrcmpi(psi->name,"DllMain")==0)
-				DllMain_EntryPoint=psi->CompileAddress;
+			pUserProc=psi2;
+
+			pUserProc->ExportOff();
+
+			if( pUserProc->GetName() == "DllMain" ){
+				DllMain_EntryPoint=pUserProc->beginOpAddress;
+			}
 
 			lpdwExportAddressTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportAddressTable,(ExportNum+1)*sizeof(DWORD));
-			lpdwExportAddressTable[ExportNum]=psi->CompileAddress;
+			lpdwExportAddressTable[ExportNum]=pUserProc->beginOpAddress;
 
 			lpdwExportNamePointerTable=(DWORD *)HeapReAlloc(hHeap,0,lpdwExportNamePointerTable,(ExportNum+1)*sizeof(DWORD));
@@ -565,5 +566,5 @@
 			lpwExportOrdinalTable[ExportNum]=ExportNum;
 
-			lstrcpy(lpExportNames+ExportNamesLength,psi->name);
+			lstrcpy(lpExportNames+ExportNamesLength,pUserProc->GetName().c_str());
 			ExportNamesLength+=lstrlen(lpExportNames+ExportNamesLength)+1;
 
@@ -598,6 +599,5 @@
 	//インポートDLL情報
 	/////////////////////
-	extern DECLAREINFO **ppDeclareHash;
-	DECLAREINFO *pdi;
+	extern DllProc **ppDeclareHash;
 	char **ppDllNames;
 	int ImportDllNum;
@@ -621,27 +621,28 @@
 	ImportDllNum=0;
 	for(i=0;i<MAX_HASH;i++){
-		pdi=ppDeclareHash[i];
-		while(pdi){
-			if(pdi->dwType==DECLARE_STATIC||
-				pdi->bUse==0){
-				pdi=pdi->pNextData;
+		const DllProc *pDllProc=ppDeclareHash[i];
+		while(pDllProc){
+			if( !pDllProc->IsUsing() ){
+				pDllProc=pDllProc->pNextData;
 				continue;
 			}
 
-			if(lstrlen(pdi->file)>16){
+			if( pDllProc->GetDllFileName().size() > 16 ){
 				SetError(7,NULL,cp);
 				break;
 			}
 			for(i2=0;i2<ImportDllNum;i2++){
-				if(lstrcmp(ppDllNames[i2],pdi->file)==0) break;
+				if( pDllProc->GetDllFileName() == ppDllNames[i2] ){
+					break;
+				}
 			}
 			if(i2==ImportDllNum){
 				ppDllNames=(char **)HeapReAlloc(hHeap,0,ppDllNames,(ImportDllNum+1)*sizeof(char **));
 				ppDllNames[ImportDllNum]=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,16);
-				lstrcpy(ppDllNames[ImportDllNum],pdi->file);
+				lstrcpy(ppDllNames[ImportDllNum],pDllProc->GetDllFileName().c_str());
 				ImportDllNum++;
 			}
 
-			pdi=pdi->pNextData;
+			pDllProc=pDllProc->pNextData;
 		}
 	}
@@ -660,18 +661,17 @@
 		pImportTable[i].Name=i3+i*0x10;
 		for(i2=0;i2<MAX_HASH;i2++){
-			pdi=ppDeclareHash[i2];
-			while(pdi){
-				if(pdi->dwType==DECLARE_STATIC||
-					pdi->bUse==0){
-					pdi=pdi->pNextData;
+			const DllProc *pDllProc=ppDeclareHash[i2];
+			while(pDllProc){
+				if( !pDllProc->IsUsing() ){
+					pDllProc=pDllProc->pNextData;
 					continue;
 				}
 
-				if(lstrcmp(ppDllNames[i],pdi->file)==0){
+				if( pDllProc->GetDllFileName() == ppDllNames[i] ){
 					//ルックアップデータのサイズを追加
 					LookupSize+=sizeof(DWORD);
 				}
 
-				pdi=pdi->pNextData;
+				pDllProc=pDllProc->pNextData;
 			}
 		}
@@ -691,15 +691,14 @@
 	for(i=0,i5=0;i<ImportDllNum;i++){
 		for(i2=0;i2<MAX_HASH;i2++){
-			pdi=ppDeclareHash[i2];
-			while(pdi){
-				if(pdi->dwType==DECLARE_STATIC||
-					pdi->bUse==0){
-					pdi=pdi->pNextData;
+			DllProc *pDllProc=ppDeclareHash[i2];
+			while(pDllProc){
+				if( !pDllProc->IsUsing() ){
+					pDllProc=pDllProc->pNextData;
 					continue;
 				}
 
-				if(lstrcmp(ppDllNames[i],pdi->file)==0){
+				if( pDllProc->GetDllFileName() == ppDllNames[i] ){
 					//ルックアップの位置をセット（後にインポート アドレス テーブルにセットしなおされる）
-					pdi->LookupAddress=i3+(i5*sizeof(DWORD));
+					pDllProc->SetLookupAddress( i3+(i5*sizeof(DWORD)) );
 
 					//ルックアップ テーブル
@@ -709,6 +708,6 @@
 					pHintTable[HintSize++]=0;
 					pHintTable[HintSize++]=0;
-					lstrcpy(pHintTable+HintSize,pdi->alias);
-					i4=lstrlen(pdi->alias);
+					lstrcpy(pHintTable+HintSize,pDllProc->GetAlias().c_str());
+					i4=(int)pDllProc->GetAlias().size();
 					HintSize+=i4+1;
 					if(i4%2==0) pHintTable[HintSize++]=0;
@@ -720,5 +719,5 @@
 				}
 
-				pdi=pdi->pNextData;
+				pDllProc=pDllProc->pNextData;
 			}
 		}
@@ -993,17 +992,17 @@
 
 		for(i2=0;i2<MAX_HASH;i2++){
-			pdi=ppDeclareHash[i2];
-			while(pdi){
-				if(pdi->bUse==0){
-					pdi=pdi->pNextData;
+			const DllProc *pDllProc=ppDeclareHash[i2];
+			while(pDllProc){
+				if( !pDllProc->IsUsing() ){
+					pDllProc=pDllProc->pNextData;
 					continue;
 				}
 
-				if(lstrcmp(ppDllNames[i],pdi->file)==0){
+				if( pDllProc->GetDllFileName() == ppDllNames[i] ){
 					//ルックアップ テーブル
 					pLookupTable[i5++]+=MemPos_ImportSection;
 				}
 
-				pdi=pdi->pNextData;
+				pDllProc=pDllProc->pNextData;
 			}
 		}
@@ -1028,6 +1027,5 @@
 	// インポートテーブルスケジュール（インポート アドレス テーブルを指し示させる）
 	for(i=0;i<pobj_ImportAddrSchedule->num;i++){
-		DECLAREINFO *pdi;
-		pdi=pobj_ImportAddrSchedule->ppdi[i];
+		const DllProc *pDllProc=pobj_ImportAddrSchedule->ppdi[i];
 		*((long *)(OpBuffer+pobj_ImportAddrSchedule->pObpValues[i]))=
 			ImageBase+
@@ -1035,5 +1033,5 @@
 			LookupSize+			//ルックアップテーブル
 			HintSize+			//ヒント名（関数名）テーブル
-			pdi->LookupAddress;
+			pDllProc->GetLookupAddress();
 	}
 	delete pobj_ImportAddrSchedule;
@@ -1043,6 +1041,6 @@
 	// プロシージャポインタスケジュール
 	for(i=0;i<pobj_SubAddrSchedule->num;i++){
-		if(pobj_SubAddrSchedule->ppsi[i]->CompileAddress==0
-			&&pobj_SubAddrSchedule->ppsi[i]->EndOpAddr==0){
+		if(pobj_SubAddrSchedule->ppsi[i]->beginOpAddress==0
+			&&pobj_SubAddrSchedule->ppsi[i]->endOpAddress==0){
 			SetError(300,NULL,-1);
 		}
@@ -1050,9 +1048,9 @@
 		if(pobj_SubAddrSchedule->pbCall[i]){
 			*((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=
-				pobj_SubAddrSchedule->ppsi[i]->CompileAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));
+				pobj_SubAddrSchedule->ppsi[i]->beginOpAddress-(pobj_SubAddrSchedule->pObpValues[i]+sizeof(long));
 		}
 		else{
 			*((long *)(OpBuffer+pobj_SubAddrSchedule->pObpValues[i]))=
-				pobj_SubAddrSchedule->ppsi[i]->CompileAddress+ImageBase+MemPos_CodeSection;
+				pobj_SubAddrSchedule->ppsi[i]->beginOpAddress+ImageBase+MemPos_CodeSection;
 		}
 	}
