Index: BasicCompiler_Common/Class.cpp
===================================================================
--- BasicCompiler_Common/Class.cpp	(revision 73)
+++ BasicCompiler_Common/Class.cpp	(revision 75)
@@ -16,5 +16,5 @@
 
 
-CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, bool isRef, char *buffer, int NowLine ){
+CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, bool isRef, char *buffer, int nowLine ){
 	extern int cp;
 
@@ -23,5 +23,5 @@
 	char init_buf[VN_SIZE];
 	char constract_parameter[VN_SIZE];
-	GetDimentionFormat(buffer,isRef,VarName,SubScripts,&TypeInfo,init_buf,constract_parameter);
+	GetDimentionFormat(buffer,VarName,SubScripts,*this,init_buf,constract_parameter);
 
 	//重複チェック
@@ -30,8 +30,8 @@
 	}
 
-	if(TypeInfo.type==DEF_OBJECT){
-		if(TypeInfo.u.pobj_Class->IsAbstract()){
+	if( IsObject() ){
+		if( GetClass().IsAbstract() ){
 			//抽象クラスだったとき
-			SetError(125,TypeInfo.u.pobj_Class->name,cp);
+			SetError(125,GetClass().name,cp);
 		}
 	}
@@ -47,7 +47,4 @@
 	this->isConst = isConst;
 
-	//参照型かどうか
-	this->isRef = isRef;
-
 	//初期データ
 	InitBuf=(char *)HeapAlloc(hHeap,0,lstrlen(init_buf)+1);
@@ -59,28 +56,22 @@
 
 	//ソースコードの位置
-	source_code_address=NowLine;
-}
-CMember::CMember(CMember *pobj){
-	//コピーコンストラクタ
-	memset(this,0,sizeof(CMember));
+	source_code_address=nowLine;
+}
+CMember::CMember(CMember &member):
+	Type( member )
+{
 
 	//name
-	name=(char *)HeapAlloc(hHeap,0,lstrlen(pobj->name)+1);
-	lstrcpy(name,pobj->name);
+	name=(char *)HeapAlloc(hHeap,0,lstrlen(member.name)+1);
+	lstrcpy(name,member.name);
 
 	//定数扱いかどうか
-	isConst = pobj->isConst;
-
-	//参照型かどうか
-	isRef = pobj->isRef;
+	isConst = member.isConst;
 
 	//SubScripts
-	memcpy(SubScripts,pobj->SubScripts,MAX_ARRAYDIM*sizeof(int));
-
-	//TypeInfo
-	TypeInfo=pobj->TypeInfo;
+	memcpy(SubScripts,member.SubScripts,MAX_ARRAYDIM*sizeof(int));
 
 	//ソースコードの位置
-	source_code_address=pobj->source_code_address;
+	source_code_address=member.source_code_address;
 }
 CMember::CMember(){
@@ -95,12 +86,4 @@
 bool CMember::IsConst(){
 	return isConst;
-}
-bool CMember::IsRef(){
-	return isRef;
-}
-
-int CMember::GetSize(){
-	//メンバサイズを取得
-	return GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex);
 }
 
@@ -126,6 +109,5 @@
 				temporary,
 				member->SubScripts,
-				member->TypeInfo,
-				GetTypeSize(member->TypeInfo.type,member->TypeInfo.u.lpIndex),
+				*member,
 				member->InitBuf,
 				member->ConstractParameter,
@@ -151,5 +133,5 @@
 	memset(this,0,sizeof(CMethod));
 
-	psi=pobj->psi;
+	pUserProc=pobj->pUserProc;
 
 	bAbstract=pobj->bAbstract;
@@ -224,5 +206,5 @@
 	iMemberNum=pInheritsClass->iMemberNum;
 	for(i3=0;i3<pInheritsClass->iMemberNum;i3++){
-		ppobj_Member[i3]=new CMember(pInheritsClass->ppobj_Member[i3]);
+		ppobj_Member[i3]=new CMember( *pInheritsClass->ppobj_Member[i3] );
 
 		//dwAccess
@@ -263,11 +245,11 @@
 	iMemberNum++;
 }
-void CClass::AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int NowLine ){
-	CMember *member = new CMember( this, dwAccess, isConst, isRef, buffer, NowLine );
+void CClass::AddStaticMember( DWORD dwAccess, bool isConst, bool isRef, char *buffer, int nowLine ){
+	CMember *member = new CMember( this, dwAccess, isConst, isRef, buffer, nowLine );
 	staticMembers.push_back( member );
 }
-void CClass::AddMethod( SubInfo *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){
+void CClass::AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){
 	CMethod *method = new CMethod();
-	method->psi = psi;
+	method->pUserProc = pUserProc;
 	method->dwAccess = dwAccess;
 	method->isConst = isConst;
@@ -277,8 +259,11 @@
 
 	methods.push_back( method );
-}
-void CClass::AddStaticMethod(SubInfo *psi,DWORD dwAccess){
+
+	// プロシージャオブジェクトと関連付け
+	pUserProc->SetMethod( method );
+}
+void CClass::AddStaticMethod(UserProc *pUserProc,DWORD dwAccess){
 	CMethod *method = new CMethod();
-	method->psi=psi;
+	method->pUserProc=pUserProc;
 	method->dwAccess=dwAccess;
 	method->bAbstract=0;
@@ -287,4 +272,7 @@
 
 	staticMethods.push_back( method );
+
+	// プロシージャオブジェクトと関連付け
+	pUserProc->SetMethod( method );
 }
 BOOL CClass::DupliCheckAll(const char *name){
@@ -296,5 +284,5 @@
 	//メソッド
 	foreach( CMethod *method, methods ){
-		if( lstrcmp( name, method->psi->name ) == 0 ){
+		if( lstrcmp( name, method->pUserProc->GetName().c_str() ) == 0 ){
 			return 1;
 		}
@@ -322,59 +310,63 @@
 	return 0;
 }
-CMethod *CClass::GetMethodInfo( SubInfo *psi ){
+CMethod *CClass::GetMethodInfo( UserProc *pUserProc ) const
+{
 	for( int i=(int)methods.size()-1; i>=0; i-- ){
-		if( psi == methods[i]->psi ) return methods[i];
+		if( pUserProc == methods[i]->pUserProc ) return methods[i];
 	}
 	return NULL;
 }
-CMethod *CClass::GetStaticMethodInfo( SubInfo *psi ){
+CMethod *CClass::GetStaticMethodInfo( UserProc *pUserProc ) const
+{
 	for( int i=(int)staticMethods.size()-1; i>=0; i-- ){
-		if( psi == staticMethods[i]->psi ) return staticMethods[i];
+		if( pUserProc == staticMethods[i]->pUserProc ) return staticMethods[i];
 	}
 	return NULL;
 }
-bool CClass::IsExistMethod( const char *name ){
+bool CClass::IsExistMethod( const char *name ) const
+{
 	foreach( CMethod *method, methods ){
-		if( lstrcmp( method->psi->name, name ) == 0 ) return true;
+		if( method->pUserProc->GetName() == name ) return true;
 	}
 	return false;
 }
-bool CClass::IsExistStaticMethod( const char *name ){
+bool CClass::IsExistStaticMethod( const char *name ) const
+{
 	foreach( CMethod *method, staticMethods ){
-		if( lstrcmp( method->psi->name, name ) == 0 ) return true;
+		if( method->pUserProc->GetName() == name ) return true;
 	}
 	return false;
 }
 
-void CClass::EnumStaticMethod( const char *methodName, std::vector<SubInfo *> &subs ) const
+void CClass::EnumStaticMethod( const char *methodName, std::vector<UserProc *> &subs ) const
 {
 	foreach( CMethod *method, staticMethods ){
-		if(lstrcmp(methodName,method->psi->name)==0){
-			subs.push_back( method->psi );
-		}
-	}
-}
-
-void CClass::EnumMethod( const char *methodName, std::vector<SubInfo *> &subs ) const
+		if( method->pUserProc->GetName() == methodName ){
+			subs.push_back( method->pUserProc );
+		}
+	}
+}
+
+void CClass::EnumMethod( const char *methodName, std::vector<UserProc *> &subs ) const
 {
 	//オブジェクトのメンバ関数の場合
 	//※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
 	for( int i=(int)methods.size()-1; i>=0; i-- ){
-		if(lstrcmp(methodName,methods[i]->psi->name)==0){
-			subs.push_back( methods[i]->psi );
-		}
-	}
-}
-
-void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<SubInfo *> &subs ) const
+		if( methods[i]->pUserProc->GetName() == methodName ){
+			subs.push_back( methods[i]->pUserProc );
+		}
+	}
+}
+
+void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<UserProc *> &subs ) const
 {
 	//オブジェクトのメンバ関数の場合
 	//※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
 	for( int i=(int)methods.size()-1; i>=0; i-- ){
-		SubInfo *psi = methods[i]->psi;
-		char *temp = psi->name;
+		UserProc *pUserProc = methods[i]->pUserProc;
+		const char *temp = pUserProc->GetName().c_str();
 		if(temp[0]==1&&temp[1]==ESC_OPERATOR){
 			if((BYTE)temp[2]==idOperatorCalc){
-				subs.push_back( psi );
+				subs.push_back( pUserProc );
 			}
 		}
@@ -423,7 +415,7 @@
 		//アラインメントを算出
 		int member_size;
-		if(pMember->TypeInfo.type==DEF_STRUCT){
+		if( pMember->IsStruct() ){
 			//メンバクラスのアラインメントを取得
-			member_size=pMember->TypeInfo.u.pobj_Class->GetAlignment();
+			member_size=pMember->GetClass().GetAlignment();
 		}
 		else{
@@ -486,7 +478,7 @@
 		CMember *pMember = ppobj_Member[i];
 
-		if(pMember->TypeInfo.type==DEF_STRUCT){
+		if(pMember->IsStruct()){
 			//メンバクラスのアラインメントを取得
-			member_size=pMember->TypeInfo.u.pobj_Class->GetAlignment();
+			member_size=pMember->GetClass().GetAlignment();
 		}
 		else{
@@ -508,10 +500,10 @@
 
 
-int CClass::GetFuncNumInVtbl( const SubInfo *psi ) const
+int CClass::GetFuncNumInVtbl( const UserProc *pUserProc ) const
 {
 	int n = 0;
 	foreach( CMethod *method, methods ){
-		if( method->psi == psi ) break;
-		if( method->psi->bVirtual ) n++;
+		if( method->pUserProc == pUserProc ) break;
+		if( method->bVirtual ) n++;
 	}
 	return n;
@@ -527,6 +519,6 @@
 	//////////////////////////////////////
 
-	SubInfo **ppsi;
-	ppsi=(SubInfo **)HeapAlloc(hHeap,0,vtbl_num*sizeof(SubInfo *));
+	UserProc **ppsi;
+	ppsi=(UserProc **)HeapAlloc(hHeap,0,vtbl_num*sizeof(UserProc *));
 
 	//関数テーブルに値をセット
@@ -534,5 +526,5 @@
 	foreach( CMethod *method, methods ){
 		if(method->bVirtual){
-			method->psi->bUse=1;
+			method->pUserProc->Using();
 
 			if(method->bAbstract){
@@ -542,5 +534,5 @@
 				ppsi[i2]=0;
 			}
-			else ppsi[i2]=method->psi;
+			else ppsi[i2]=method->pUserProc;
 			i2++;
 		}
@@ -565,11 +557,12 @@
 	int i;
 	for(i=0;i<vtbl_num;i++){
-		SubInfo *psi;
-		psi=(SubInfo *)pVtbl[i];
-		if(!psi) continue;
-		pVtbl[i]=psi->CompileAddress+ImageBase+MemPos_CodeSection;
-	}
-}
-bool CClass::IsAbstract(){
+		UserProc *pUserProc;
+		pUserProc=(UserProc *)pVtbl[i];
+		if(!pUserProc) continue;
+		pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection;
+	}
+}
+bool CClass::IsAbstract() const
+{
 	//未実装の仮想関数を持つ場合はtrueを返す
 
@@ -584,6 +577,6 @@
 	//コンポジションの関係にあるメンバも検査する
 	for(int i=0;i < iMemberNum;i++){
-		if(ppobj_Member[i]->TypeInfo.type==DEF_OBJECT){
-			if(ppobj_Member[i]->TypeInfo.u.pobj_Class->IsAbstract())
+		if(ppobj_Member[i]->IsObject()){
+			if(ppobj_Member[i]->GetClass().IsAbstract())
 				return true;
 		}
@@ -604,5 +597,6 @@
 
 //コンストラクタをコンパイル中かどうかを判別
-bool CClass::IsCompilingConstructor(){
+bool CClass::IsCompilingConstructor() const
+{
 	return isCompilingConstructor;
 }
@@ -619,5 +613,6 @@
 
 //デストラクタをコンパイル中かどうかを判別
-bool CClass::IsCompilingDestructor(){
+bool CClass::IsCompilingDestructor() const
+{
 	return isCompilingDestructor;
 }
@@ -625,5 +620,6 @@
 
 //自身と等しいクラスかどうかを確認
-bool CClass::IsEquals( CClass *pClass ){
+bool CClass::IsEquals( const CClass *pClass ) const
+{
 	if( this == pClass ) return true;
 	return false;
@@ -631,5 +627,6 @@
 
 //自身の派生クラスかどうかを確認
-bool CClass::IsSubClass( CClass *pClass ){
+bool CClass::IsSubClass( const CClass *pClass ) const
+{
 	pClass = pClass->pobj_InheritsClass;
 	while( pClass ){
@@ -641,5 +638,6 @@
 
 //自身と等しいまたは派生クラスかどうかを確認
-bool CClass::IsEqualsOrSubClass( CClass *pClass ){
+bool CClass::IsEqualsOrSubClass( const CClass *pClass ) const
+{
 	if( IsEquals( pClass ) ) return true;
 	return IsSubClass( pClass );
@@ -722,5 +720,5 @@
 }
 
-CClass *CDBClass::AddClass(const char *name,int NowLine){
+CClass *CDBClass::AddClass(const char *name,int nowLine){
 	//////////////////////////////////////////////////////////////////////////
 	// クラスを追加
@@ -753,5 +751,5 @@
 			if(lstrcmp(name,pobj_c2->name)==0){
 				//重複した場合
-				SetError(15,name,NowLine);
+				SetError(15,name,nowLine);
 				return 0;
 			}
@@ -781,6 +779,6 @@
 			basbuf[i+1]==ESC_INTERFACE
 			)){
-				int NowLine;
-				NowLine=i;
+				int nowLine;
+				nowLine=i;
 
 				i+=2;
@@ -802,10 +800,10 @@
 
 				//クラスを追加
-				CClass *pClass = pobj_DBClass->AddClass(temporary,NowLine);
+				CClass *pClass = pobj_DBClass->AddClass(temporary,nowLine);
 				if( pClass ){
-					if( basbuf[NowLine+1] == ESC_CLASS ){
+					if( basbuf[nowLine+1] == ESC_CLASS ){
 						pClass->classType = CClass::Class;
 					}
-					else if( basbuf[NowLine+1] == ESC_INTERFACE ){
+					else if( basbuf[nowLine+1] == ESC_INTERFACE ){
 						pClass->classType = CClass::Interface;
 					}
@@ -820,5 +818,5 @@
 
 void CDBClass::AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
-						 BOOL bVirtual, BOOL bOverride, char *buffer, int NowLine){
+						 BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine){
 	int i,i2;
 	char temporary[VN_SIZE];
@@ -835,7 +833,7 @@
 
 	//関数ハッシュへ登録
-	SubInfo *psi;
-	psi=AddSubData(buffer,NowLine,bVirtual,pobj_c,bStatic);
-	if(!psi) return;
+	UserProc *pUserProc;
+	pUserProc=AddSubData(buffer,nowLine,bVirtual,pobj_c, (bStatic!=0) );
+	if(!pUserProc) return;
 
 
@@ -849,5 +847,5 @@
 
 		//標準コンストラクタ（引数なし）
-		if(psi->params.size()==0) fConstructor=1;
+		if(pUserProc->Params().size()==0) fConstructor=1;
 
 		//強制的にConst修飾子をつける
@@ -857,5 +855,5 @@
 		//デストラクタの場合はその名前が正しいかチェックを行う
 		if(lstrcmp(temporary+1,pobj_c->name)!=0)
-			SetError(117,NULL,NowLine);
+			SetError(117,NULL,nowLine);
 		else
 			bDestructor=1;
@@ -864,5 +862,5 @@
 		// コンストラクタ、デストラクタのアクセシビリティをチェック
 		if(dwAccess!=ACCESS_PUBLIC){
-			SetError(116,NULL,NowLine);
+			SetError(116,NULL,nowLine);
 			dwAccess=ACCESS_PUBLIC;
 		}
@@ -884,5 +882,5 @@
 
 	if(pobj_c->DupliCheckMember(temporary)){
-		SetError(15,temporary,NowLine);
+		SetError(15,temporary,nowLine);
 		return;
 	}
@@ -893,8 +891,8 @@
 		if(method->pobj_InheritsClass) continue;
 
-		if(lstrcmp(temporary,method->psi->name)==0){
-			if( Parameter::Equals( method->psi->params, psi->params ) ){
+		if( method->pUserProc->GetName() == temporary ){
+			if( Parameter::Equals( method->pUserProc->Params(), pUserProc->Params() ) ){
 				//関数名、パラメータ属性が合致したとき
-				SetError(15,psi->name,NowLine);
+				SetError(15,pUserProc->GetName().c_str(),nowLine);
 				return;
 			}
@@ -903,22 +901,24 @@
 
 	//仮想関数の場合
-	if(bAbstract) psi->bCompile=1;
+	if(bAbstract) pUserProc->CompleteCompile();
 
 	//メソッドのオーバーライド
 	foreach( CMethod *method, pobj_c->methods ){
-		if(lstrcmp(temporary,method->psi->name)==0){
-			if( Parameter::Equals( method->psi->params, psi->params ) ){
-
-				if(method->psi->bVirtual){
+		if( method->pUserProc->GetName() == temporary ){
+			if( Parameter::Equals( method->pUserProc->Params(), pUserProc->Params() ) ){
+
+				if(method->bVirtual){
 					//メンバ関数を上書き
-					method->psi=psi;
+					method->pUserProc=pUserProc;
 					method->bAbstract=0;
 
 					if(!bOverride){
-						SetError(127,NULL,NowLine);
+						SetError(127,NULL,nowLine);
 					}
 					if(method->dwAccess!=dwAccess){
-						SetError(128,NULL,NowLine);
+						SetError(128,NULL,nowLine);
 					}
+
+					pUserProc->SetMethod( method );
 					return;
 				}
@@ -927,38 +927,38 @@
 	}
 
-	if(psi->bVirtual){
+	if(bVirtual){
 		pobj_c->vtbl_num++;
 	}
 
 	if(bOverride){
-		SetError(12,"Override",NowLine);
+		SetError(12,"Override",nowLine);
 	}
 
 	if(bStatic){
-		pobj_c->AddStaticMethod(psi,dwAccess);
+		pobj_c->AddStaticMethod(pUserProc,dwAccess);
 	}
 	else{
-		pobj_c->AddMethod(psi, dwAccess, isConst, bAbstract, bVirtual);
-	}
-}
-
-BOOL CDBClass::MemberVar_LoopRefCheck(CClass *pobj_c){
+		pobj_c->AddMethod(pUserProc, dwAccess, isConst, bAbstract, bVirtual);
+	}
+}
+
+BOOL CDBClass::MemberVar_LoopRefCheck(const CClass &objClass){
 	int i,i2,bRet=1;
-	for(i=0;i<pobj_c->iMemberNum;i++){
-		CMember *pMember = pobj_c->ppobj_Member[i];
-		if(pMember->TypeInfo.type==DEF_OBJECT){
+	for(i=0;i<objClass.iMemberNum;i++){
+		const CMember *pMember = objClass.ppobj_Member[i];
+		if(pMember->IsObject()){
 			//循環参照でないかをチェック
-			if(pobj_LoopRefCheck->check(pMember->TypeInfo.u.pobj_Class->name)){
+			if(pobj_LoopRefCheck->check(pMember->GetClass().name)){
 				extern int cp;
-				SetError(124,pMember->TypeInfo.u.pobj_Class->name,cp);
+				SetError(124,pMember->GetClass().name,cp);
 				return 0;
 			}
 
-			pobj_LoopRefCheck->add(pobj_c->name);
-
-			i2=MemberVar_LoopRefCheck(pMember->TypeInfo.u.pobj_Class);
+			pobj_LoopRefCheck->add(objClass.name);
+
+			i2=MemberVar_LoopRefCheck(pMember->GetClass());
 			if(bRet==1) bRet=i2;
 
-			pobj_LoopRefCheck->del(pobj_c->name);
+			pobj_LoopRefCheck->del(objClass.name);
 		}
 	}
@@ -1347,19 +1347,19 @@
 
 
-						if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.type==DEF_OBJECT||
-							pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.type==DEF_STRUCT){
-							if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.u.pobj_Class->ppobj_Member==0){
+						if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsObject()||
+							pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsStruct()){
+							if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->GetClass().ppobj_Member==0){
 								//参照先が読み取られていないとき
-								GetClass_recur(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.u.pobj_Class->name);
+								GetClass_recur(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->GetClass().name);
 							}
 						}
 
 
-						if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.type==DEF_OBJECT){
+						if(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->IsObject()){
 							//循環参照のチェック
 							pobj_LoopRefCheck->add(pobj_c->name);
-							if(!MemberVar_LoopRefCheck(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.u.pobj_Class)){
+							if(!MemberVar_LoopRefCheck(pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->GetClass())){
 								//エラー回避
-								pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->TypeInfo.type=DEF_PTR_VOID;
+								pobj_c->ppobj_Member[pobj_c->iMemberNum-1]->SetBasicType( DEF_PTR_VOID );
 							}
 							pobj_LoopRefCheck->del(pobj_c->name);
@@ -1438,10 +1438,10 @@
 }
 
-void CDBClass::StartCompile( SubInfo *psi ){
-	pCompilingClass = psi->pobj_ParentClass;
+void CDBClass::StartCompile( UserProc *pUserProc ){
+	pCompilingClass = pUserProc->GetParentClassPtr();
 	if( pCompilingClass ){
-		pCompilingMethod = pCompilingClass->GetMethodInfo( psi );
+		pCompilingMethod = pCompilingClass->GetMethodInfo( pUserProc );
 		if( !pCompilingMethod ){
-			pCompilingMethod = pCompilingClass->GetStaticMethodInfo( psi );
+			pCompilingMethod = pCompilingClass->GetStaticMethodInfo( pUserProc );
 			if( !pCompilingMethod ){
 				SetError(300,NULL,cp);
