Index: BasicCompiler32/Compile_ProcOp.cpp
===================================================================
--- BasicCompiler32/Compile_ProcOp.cpp	(revision 73)
+++ BasicCompiler32/Compile_ProcOp.cpp	(revision 75)
@@ -3,5 +3,5 @@
 
 
-void SystemProc(char *name){
+void SystemProc( const char *name ){
 	if(lstrcmp(name,"_System_GetEip")==0){
 		//mov eax,dword ptr[esp]
@@ -69,5 +69,5 @@
 					cp=GlobalVar[i].source_code_address;
 
-					TYPEINFO TypeInfo;
+					Type TypeInfo;
 					TypeInfo.type=GlobalVar[i].type;
 					TypeInfo.u.lpIndex=GlobalVar[i].u.index;
@@ -214,8 +214,8 @@
 }
 
-void CompileBufferInProcedure(SubInfo *psi){
+void CompileBufferInProcedure(UserProc *pUserProc){
 	extern char *basbuf;
 	extern HANDLE hHeap;
-	extern SubInfo **ppSubHash;
+	extern UserProc **ppSubHash;
 	extern BOOL bDebugCompile;
 	int i3,i4,VarSize,LocalVarSchedule,EspOffsetSchedule,BufferSize,BaseOffset;
@@ -224,17 +224,17 @@
 	BufferSize=128;
 
-	if(psi->bUse==0||psi->bCompile) return;
-
-	psi->bCompile=1;
+	if( pUserProc->IsUsing() == false || pUserProc->IsCompiled() ) return;
+
+	pUserProc->CompleteCompile();
 
 	extern BOOL bSystemProc;
-	if(memcmp(psi->name,"_System_",8)==0) bSystemProc=1;
+	if(memcmp(pUserProc->GetName().c_str(),"_System_",8)==0) bSystemProc=1;
 	else bSystemProc=0;
 
 	extern BOOL bDebugSupportProc;
-	if(memcmp(psi->name,"_DebugSys_",10)==0){
+	if(memcmp(pUserProc->GetName().c_str(),"_DebugSys_",10)==0){
 		if(!bDebugCompile){
-			psi->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);
-			psi->VarNum=0;
+			pUserProc->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);
+			pUserProc->VarNum=0;
 			return;
 		}
@@ -243,7 +243,7 @@
 	else bDebugSupportProc=0;
 
-	psi->CompileAddress=obp;
-
-	if(psi->bSystem){
+	pUserProc->beginOpAddress=obp;
+
+	if(pUserProc->IsSystem()){
 		extern int MaxLocalVarNum;
 		extern int AllLocalVarSize;
@@ -251,13 +251,13 @@
 		AllLocalVarSize=0;
 
-		SystemProc(psi->name);
-
-		psi->EndOpAddr=obp;
-		psi->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);
-		psi->VarNum=0;
+		SystemProc(pUserProc->GetName().c_str());
+
+		pUserProc->endOpAddress=obp;
+		pUserProc->pVar=(VARIABLE *)HeapAlloc(hHeap,0,1);
+		pUserProc->VarNum=0;
 		return;
 	}
 
-	cp=psi->address;
+	cp=pUserProc->GetCodePos();
 	for(;;cp++){
 		if(IsCommandDelimitation(basbuf[cp])) break;
@@ -280,6 +280,6 @@
 
 	//パラメータ用の変数データを考慮
-	for(i3=psi->realParams.size()-1;i3>=0;i3--){
-		Parameter &param = *psi->realParams[i3];
+	for(i3=(int)pUserProc->RealParams().size()-1;i3>=0;i3--){
+		Parameter &param = *pUserProc->RealParams()[i3];
 
 		//変数データを追加
@@ -297,5 +297,5 @@
 		if(LocalVar[MaxLocalVarNum].type==DEF_OBJECT
 			||LocalVar[MaxLocalVarNum].type==DEF_STRUCT){
-				if(psi->bExport)
+				if(pUserProc->IsExport())
 					SetError(24,NULL,cp);
 		}
@@ -340,12 +340,12 @@
 
 	//コンパイル中の関数が属するクラス
-	pobj_CompilingClass=psi->pobj_ParentClass;
+	pobj_CompilingClass=pUserProc->GetParentClassPtr();
 
 	//コンパイルスタートをクラス管理クラスに追加
-	pobj_DBClass->StartCompile( psi );
+	pobj_DBClass->StartCompile( pUserProc );
 
 	//コンパイル中の関数
-	extern SubInfo *pCompilingSubInfo;
-	pCompilingSubInfo=psi;
+	extern UserProc *pCompilingUserProc;
+	pCompilingUserProc=pUserProc;
 
 
@@ -373,23 +373,18 @@
 	OpBuffer[obp++]=(char)0x57;
 
-	if(psi->ReturnType!=DEF_NON){
+	if( !pUserProc->ReturnType().IsNull() ){
 		//戻り値が存在するとき
 
-		char *temp;
-		if(psi->name[0]==1&&psi->name[1]==ESC_OPERATOR) temp="_System_ReturnValue";
-		else temp=psi->name;
-
-		if(psi->ReturnType==DEF_STRUCT && psi->isReturnRef == false){
+		const char *temp = pUserProc->GetName().c_str();
+		if( temp[0]==1&&temp[1]==ESC_OPERATOR ){
+			temp = "_System_ReturnValue";
+		}
+
+		if( pUserProc->ReturnType().IsStruct() ){
 			//戻り値用の構造体（値型）はパラメータで引き渡される
 		}
 		else{
 			//戻り値用の変数の定義
-			if( psi->isReturnRef ){
-				sprintf(temporary,"%c%c",1,ESC_BYREF);
-			}
-			else temporary[0]=0;
-
-			sprintf(temporary+lstrlen(temporary),"%s%c%c",temp,1,ESC_AS);
-			GetTypeName(psi->ReturnType,psi->u.ReturnIndex,temporary+lstrlen(temporary));
+			sprintf(temporary,"%s%c%c%s",temp,1,ESC_AS, pUserProc->ReturnType().ToString().c_str() );
 
 			OpcodeDim(temporary,0);
@@ -444,10 +439,10 @@
 
 		//call _DebugSys_StartProc
-		extern SubInfo *pSub_DebugSys_StartProc;
+		extern UserProc *pSub_DebugSys_StartProc;
 		op_call(pSub_DebugSys_StartProc);
 	}
 
 	if(pobj_CompilingClass){
-		if(lstrcmp(psi->name,pobj_CompilingClass->name)==0){
+		if( pUserProc->GetName() == pobj_CompilingClass->name ){
 			////////////////////////////////////
 			// コンストラクタをコンパイルするとき
@@ -497,5 +492,5 @@
 
 					Opcode_CallProc(temporary,
-						pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod()->psi,
+						pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod()->pUserProc,
 						0,
 						"",
@@ -505,5 +500,5 @@
 					//基底クラスのコンストラクタを暗黙的に呼び出す
 					Opcode_CallProc("",
-						pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod()->psi,
+						pobj_CompilingClass->pobj_InheritsClass->GetConstructorMethod()->pUserProc,
 						0,
 						"",
@@ -548,5 +543,5 @@
 			}
 		}
-		else if(psi->name[0]=='~'){
+		else if( pUserProc->IsDestructor() ){
 			//デストラクタをコンパイルしたとき
 
@@ -559,7 +554,9 @@
 	//////////////////////////////////////////
 	////// プロシージャ内をコンパイル ////////
-	if(psi->dwType==SUBTYPE_SUB) CompileBuffer(ESC_ENDSUB,0);
-	else if(psi->dwType==SUBTYPE_FUNCTION) CompileBuffer(ESC_ENDFUNCTION,0);
-	else if(psi->dwType==SUBTYPE_MACRO) CompileBuffer(ESC_ENDMACRO,0);
+	if(pUserProc->IsMacro()) CompileBuffer(ESC_ENDMACRO,0);
+	else{
+		if(pUserProc->IsSub()) CompileBuffer(ESC_ENDSUB,0);
+		else if(pUserProc->IsFunction()) CompileBuffer(ESC_ENDFUNCTION,0);
+	}
 	//////////////////////////////////////////
 	//////////////////////////////////////////
@@ -573,5 +570,5 @@
 			pobj_CompilingClass->NotifyFinishConstructorCompile();
 		}
-		else if(psi->name[0]=='~'){
+		else if( pUserProc->IsDestructor() ){
 			////////////////////////////////////
 			//デストラクタをコンパイルしたとき
@@ -588,5 +585,5 @@
 				if( method ){
 					Opcode_CallProc("",
-						method->psi,
+						method->pUserProc,
 						0,
 						"",
@@ -631,5 +628,5 @@
 
 							//call destructor
-							op_call( method->psi );
+							op_call( method->pUserProc );
 						}
 					}
@@ -666,8 +663,4 @@
 	HeapDefaultFree(WithInfo.pWithCp);
 
-	//重複エラー情報管理のメモリを解放
-	for(i3=0;i3<SynonymErrorNum;i3++) HeapDefaultFree(SynonymErrorWords[i3]);
-	HeapDefaultFree(SynonymErrorWords);
-
 	//push ebp
 	AllLocalVarSize+=sizeof(long);
@@ -686,20 +679,20 @@
 
 		//call _DebugSys_EndProc
-		extern SubInfo *pSub_DebugSys_EndProc;
+		extern UserProc *pSub_DebugSys_EndProc;
 		op_call(pSub_DebugSys_EndProc);
 	}
 
-	if(psi->ReturnType!=DEF_NON){
+	if( !pUserProc->ReturnType().IsNull() ){
 		//戻り値をeax、edxに設定
 		RELATIVE_VAR RelativeVar;
 		LONG_PTR lpIndex;
 
-		char *temp;
-		if(psi->name[0]==1&&psi->name[1]==ESC_OPERATOR)
+		const char *temp = pUserProc->GetName().c_str();
+		if( temp[0]==1 && temp[1]==ESC_OPERATOR ){
 			temp="_System_ReturnValue";
-		else temp=psi->name;
+		}
 		GetVarOffsetReadWrite(temp,&i3,&RelativeVar,&lpIndex);
 
-		i3=psi->ReturnType;
+		i3=pUserProc->ReturnType().GetBasicType();
 
 		if(i3==DEF_OBJECT || i3==DEF_STRUCT){
@@ -808,5 +801,5 @@
 
 		//call _esp_error
-		extern SubInfo *pSub_esp_error;
+		extern UserProc *pSub_esp_error;
 		op_call( pSub_esp_error );
 
@@ -824,5 +817,5 @@
 	op_add_esp(AllLocalVarSize-BaseOffset);
 
-	if(BaseOffset==0||psi->bCdecl){
+	if( BaseOffset==0 || pUserProc->IsCdecl() ){
 		//ret 0
 		OpBuffer[obp++]=(char)0xC3;
@@ -835,21 +828,28 @@
 	}
 
-	psi->EndOpAddr=obp;
-	psi->pVar=LocalVar;
-	psi->VarNum=MaxLocalVarNum;
+	pUserProc->endOpAddress=obp;
+	pUserProc->pVar=LocalVar;
+	pUserProc->VarNum=MaxLocalVarNum;
+
+
+	//重複エラー情報管理のメモリを解放
+	for(i3=0;i3<SynonymErrorNum;i3++) HeapDefaultFree(SynonymErrorWords[i3]);
+	HeapDefaultFree(SynonymErrorWords);
+	SynonymErrorWords=0;
+
 
 	//ローカル変数のネーム情報は後に解放する
 }
 void CompileLocal(){
-	extern SubInfo **ppSubHash;
+	extern UserProc **ppSubHash;
 	int i2;
-	SubInfo *psi;
+	UserProc *pUserProc;
 
 	extern BOOL bDll;
 	if(bDll){
 		//DLLの場合はグローバル変数を初期化するための関数を一番初めにコンパイルする
-		psi=GetSubHash("_System_InitDllGlobalVariables");
-		if(psi){
-			CompileBufferInProcedure(psi);
+		pUserProc=GetSubHash("_System_InitDllGlobalVariables");
+		if(pUserProc){
+			CompileBufferInProcedure(pUserProc);
 		}
 		else SetError(300,NULL,cp);
@@ -858,17 +858,17 @@
 	//_System_InitStaticLocalVariablesは一番最後にコンパイル
 	//※一般関数内の静的変数オブジェクトをすべて収集しなければならない
-	extern SubInfo *pSub_System_InitStaticLocalVariables;
-	pSub_System_InitStaticLocalVariables->bCompile=1;
+	extern UserProc *pSub_System_InitStaticLocalVariables;
+	pSub_System_InitStaticLocalVariables->CompleteCompile();
 
 	//_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル
-	extern SubInfo *pSub_System_Call_Destructor_of_GlobalObject;
-	pSub_System_Call_Destructor_of_GlobalObject->bCompile=1;
+	extern UserProc *pSub_System_Call_Destructor_of_GlobalObject;
+	pSub_System_Call_Destructor_of_GlobalObject->CompleteCompile();
 
 Repeat:
 	for(i2=0;i2<MAX_HASH;i2++){
-		psi=ppSubHash[i2];
-		while(psi){
-			CompileBufferInProcedure(psi);
-			psi=psi->pNextData;
+		pUserProc=ppSubHash[i2];
+		while(pUserProc){
+			CompileBufferInProcedure(pUserProc);
+			pUserProc=pUserProc->pNextData;
 		}
 	}
@@ -876,20 +876,20 @@
 	//プロシージャコンパイルによって、プロシージャコンパイルが必要になる場合
 	for(i2=0;i2<MAX_HASH;i2++){
-		psi=ppSubHash[i2];
-		while(psi){
-			if(psi->bUse&&psi->bCompile==0){
+		pUserProc=ppSubHash[i2];
+		while(pUserProc){
+			if( pUserProc->IsUsing() && pUserProc->IsCompiled() == false ){
 				goto Repeat;
 			}
 
-			psi=psi->pNextData;
+			pUserProc=pUserProc->pNextData;
 		}
 	}
 
 	//_System_InitStaticLocalVariablesは一番最後にコンパイル
-	pSub_System_InitStaticLocalVariables->bCompile=0;
+	pSub_System_InitStaticLocalVariables->KillCompileStatus();
 	CompileBufferInProcedure(pSub_System_InitStaticLocalVariables);
 
 	//_System_Call_Destructor_of_GlobalObjectは一番最後にコンパイル
-	pSub_System_Call_Destructor_of_GlobalObject->bCompile=0;
+	pSub_System_Call_Destructor_of_GlobalObject->KillCompileStatus();
 	CompileBufferInProcedure(pSub_System_Call_Destructor_of_GlobalObject);
 }
