Index: BasicCompiler_Common/Class.cpp
===================================================================
--- BasicCompiler_Common/Class.cpp	(revision 50)
+++ BasicCompiler_Common/Class.cpp	(revision 51)
@@ -207,13 +207,4 @@
 	}
 
-	if(ppobj_Method){
-		//メソッド
-		for(i=0;i<iMethodNum;i++){
-			delete ppobj_Method[i];
-		}
-		HeapDefaultFree(ppobj_Method);
-		ppobj_Method=0;
-	}
-
 	if(ppobj_StaticMember){
 		//静的メンバ
@@ -225,5 +216,11 @@
 	}
 
-	foreach( CMethod *method, StaticMethods ){
+	//メソッド
+	foreach( CMethod *method, methods ){
+		delete method;
+	}
+
+	//静的メソッド
+	foreach( CMethod *method, staticMethods ){
 		delete method;
 	}
@@ -249,25 +246,21 @@
 
 	//メソッドをコピー
-	ppobj_Method=(CMethod **)HeapReAlloc(
-		hHeap,
-		0,
-		ppobj_Method,
-		pInheritsClass->iMethodNum*sizeof(CMethod *));
-	iMethodNum=pInheritsClass->iMethodNum;
-	for(i3=0;i3<pInheritsClass->iMethodNum;i3++){
-		ppobj_Method[i3]=new CMethod(pInheritsClass->ppobj_Method[i3]);
+	foreach( CMethod *baseMethod, pInheritsClass->methods ){
+		CMethod *method = new CMethod( baseMethod );
 
 		//dwAccess
-		if(pInheritsClass->ppobj_Method[i3]->dwAccess==ACCESS_PRIVATE)
-			ppobj_Method[i3]->dwAccess=ACCESS_NON;
-		else ppobj_Method[i3]->dwAccess=pInheritsClass->ppobj_Method[i3]->dwAccess;
+		if(baseMethod->dwAccess==ACCESS_PRIVATE)
+			method->dwAccess=ACCESS_NON;
+		else method->dwAccess=baseMethod->dwAccess;
 
 		//pobj_Inherits
 		// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-		if(pInheritsClass->ppobj_Method[i3]->pobj_InheritsClass==0)
-			ppobj_Method[i3]->pobj_InheritsClass=pInheritsClass;
+		if(baseMethod->pobj_InheritsClass==0)
+			method->pobj_InheritsClass=pInheritsClass;
 		else
-			ppobj_Method[i3]->pobj_InheritsClass=
-				pInheritsClass->ppobj_Method[i3]->pobj_InheritsClass;
+			method->pobj_InheritsClass=
+				baseMethod->pobj_InheritsClass;
+
+		methods.push_back( method );
 	}
 
@@ -289,14 +282,13 @@
 }
 void CClass::AddMethod( SUBINFO *psi,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){
-	ppobj_Method = (CMethod **)HeapReAlloc( hHeap, 0, ppobj_Method, (iMethodNum + 1) * sizeof(CMethod *) );
-	ppobj_Method[iMethodNum] = new CMethod();
-	ppobj_Method[iMethodNum]->psi = psi;
-	ppobj_Method[iMethodNum]->dwAccess = dwAccess;
-	ppobj_Method[iMethodNum]->isConst = isConst;
-	ppobj_Method[iMethodNum]->bAbstract = bAbstract;
-	ppobj_Method[iMethodNum]->bVirtual = bVirtual;
-	ppobj_Method[iMethodNum]->pobj_InheritsClass = 0;
-
-	iMethodNum++;
+	CMethod *method = new CMethod();
+	method->psi = psi;
+	method->dwAccess = dwAccess;
+	method->isConst = isConst;
+	method->bAbstract = bAbstract;
+	method->bVirtual = bVirtual;
+	method->pobj_InheritsClass = 0;
+
+	methods.push_back( method );
 }
 void CClass::AddStaticMethod(SUBINFO *psi,DWORD dwAccess){
@@ -308,17 +300,15 @@
 	method->pobj_InheritsClass=0;
 
-	StaticMethods.push_back( method );
+	staticMethods.push_back( method );
 }
 BOOL CClass::DupliCheckAll(const char *name){
 	//重複チェック
 
-	int i;
-
 	//メンバ
 	if(DupliCheckMember(name)) return 1;
 
 	//メソッド
-	for(i=0;i<iMethodNum;i++){
-		if(lstrcmp(name,ppobj_Method[i]->psi->name)==0){
+	foreach( CMethod *method, methods ){
+		if( lstrcmp( name, method->psi->name ) == 0 ){
 			return 1;
 		}
@@ -349,23 +339,23 @@
 }
 CMethod *CClass::GetMethodInfo( SUBINFO *psi ){
-	for( int i=iMethodNum-1; i>=0; i-- ){
-		if( psi == ppobj_Method[i]->psi ) return ppobj_Method[i];
+	for( int i=(int)methods.size()-1; i>=0; i-- ){
+		if( psi == methods[i]->psi ) return methods[i];
 	}
 	return NULL;
 }
 CMethod *CClass::GetStaticMethodInfo( SUBINFO *psi ){
-	for( int i=(int)StaticMethods.size()-1; i>=0; i-- ){
-		if( psi == StaticMethods[i]->psi ) return StaticMethods[i];
+	for( int i=(int)staticMethods.size()-1; i>=0; i-- ){
+		if( psi == staticMethods[i]->psi ) return staticMethods[i];
 	}
 	return NULL;
 }
 bool CClass::IsExistMethod( const char *name ){
-	for( int i=0; i<iMethodNum; i++ ){
-		if( lstrcmp( ppobj_Method[i]->psi->name, name ) == 0 ) return true;
+	foreach( CMethod *method, methods ){
+		if( lstrcmp( method->psi->name, name ) == 0 ) return true;
 	}
 	return false;
 }
 bool CClass::IsExistStaticMethod( const char *name ){
-	foreach( CMethod *method, StaticMethods ){
+	foreach( CMethod *method, staticMethods ){
 		if( lstrcmp( method->psi->name, name ) == 0 ) return true;
 	}
@@ -375,5 +365,5 @@
 void CClass::EnumStaticMethod( const char *methodName, std::vector<SUBINFO *> &subs ) const
 {
-	foreach( CMethod *method, StaticMethods ){
+	foreach( CMethod *method, staticMethods ){
 		if(lstrcmp(methodName,method->psi->name)==0){
 			subs.push_back( method->psi );
@@ -386,7 +376,7 @@
 	//オブジェクトのメンバ関数の場合
 	//※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
-	for(int i=iMethodNum-1;i>=0;i--){
-		if(lstrcmp(name,ppobj_Method[i]->psi->name)==0){
-			subs.push_back( ppobj_Method[i]->psi );
+	for( int i=(int)methods.size()-1; i>=0; i-- ){
+		if(lstrcmp(methodName,methods[i]->psi->name)==0){
+			subs.push_back( methods[i]->psi );
 		}
 	}
@@ -395,13 +385,36 @@
 void CClass::EnumMethod( const BYTE idOperatorCalc, std::vector<SUBINFO *> &subs ) const
 {
-	for(int i=0;i<iMethodNum;i++){
+	//オブジェクトのメンバ関数の場合
+	//※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
+	for( int i=(int)methods.size()-1; i>=0; i-- ){
 		char *temp;
-		temp=ppobj_Method[i]->psi->name;
+		temp=methods[i]->psi->name;
 		if(temp[0]==1&&temp[1]==ESC_OPERATOR){
 			if((BYTE)temp[2]==idOperatorCalc){
-				subs.push_back( ppobj_Method[i]->psi );
-			}
-		}
-	}
+				subs.push_back( methods[i]->psi );
+			}
+		}
+	}
+}
+
+//デフォルト コンストラクタ メソッドを取得
+CMethod *CClass::GetConstructorMethod() const
+{
+	if( ConstructorMemberSubIndex == -1 ) return NULL;
+	return methods[ConstructorMemberSubIndex];
+}
+
+//デフォルト コピーコンストラクタ メソッドを取得
+CMethod *CClass::GetCopyConstructorMethod() const
+{
+	if( CopyConstructorMemberSubIndex == -1 ) return NULL;
+	return methods[CopyConstructorMemberSubIndex];
+}
+
+//デストラクタ メソッドを取得
+CMethod *CClass::GetDestructorMethod() const
+{
+	if( DestructorMemberSubIndex == -1 ) return NULL;
+	return methods[DestructorMemberSubIndex];
 }
 
@@ -409,4 +422,13 @@
 LONG_PTR CClass::AddVtblDataTable(SUBINFO **ppsi,int length){
 	return AddDataTable((char *)ppsi,length);
+}
+int CClass::GetFuncNumInVtbl( const SUBINFO *psi ) const
+{
+	int n = 0;
+	foreach( CMethod *method, methods ){
+		if( method->psi == psi ) break;
+		if( method->psi->bVirtual ) n++;
+	}
+	return n;
 }
 LONG_PTR CClass::GetVtblGlobalOffset(void){
@@ -424,9 +446,10 @@
 
 	//関数テーブルに値をセット
-	for( int i=0, i2=0; i < iMethodNum; i++ ){
-		if(ppobj_Method[i]->bVirtual){
-			ppobj_Method[i]->psi->bUse=1;
-
-			if(ppobj_Method[i]->bAbstract){
+	int i2 = 0;
+	foreach( CMethod *method, methods ){
+		if(method->bVirtual){
+			method->psi->bUse=1;
+
+			if(method->bAbstract){
 				extern int cp;
 				SetError(300,NULL,cp);
@@ -434,5 +457,5 @@
 				ppsi[i2]=0;
 			}
-			else ppsi[i2]=ppobj_Method[i]->psi;
+			else ppsi[i2]=method->psi;
 			i2++;
 		}
@@ -465,9 +488,9 @@
 }
 bool CClass::IsAbstract(){
-	//未実装の仮想関数を持つ場合は1を返す
-
-	for( int i=0; i < iMethodNum; i++ ){
-		if(ppobj_Method[i]->bVirtual){
-			if(ppobj_Method[i]->bAbstract){
+	//未実装の仮想関数を持つ場合はtrueを返す
+
+	foreach( CMethod *method, methods ){
+		if(method->bVirtual){
+			if(method->bAbstract){
 				return true;
 			}
@@ -744,9 +767,9 @@
 
 	if( fConstructor == 1 )
-		pobj_c->ConstructorMemberSubIndex = pobj_c->iMethodNum;
+		pobj_c->ConstructorMemberSubIndex = (int)pobj_c->methods.size();
 	else if( fConstructor == 2 )
-		pobj_c->CopyConstructorMemberSubIndex = pobj_c->iMethodNum;
+		pobj_c->CopyConstructorMemberSubIndex = (int)pobj_c->methods.size();
 	else if( bDestructor )
-		pobj_c->DestructorMemberSubIndex = pobj_c->iMethodNum;
+		pobj_c->DestructorMemberSubIndex = (int)pobj_c->methods.size();
 
 
@@ -761,12 +784,12 @@
 	}
 
-	//メンバ関数
-	for(i=0;i<pobj_c->iMethodNum;i++){
+	//メソッド
+	foreach( CMethod *method, pobj_c->methods ){
 		//基底クラスと重複する場合はオーバーライドを行う
-		if(pobj_c->ppobj_Method[i]->pobj_InheritsClass) continue;
-
-		if(lstrcmp(temporary,pobj_c->ppobj_Method[i]->psi->name)==0){
+		if(method->pobj_InheritsClass) continue;
+
+		if(lstrcmp(temporary,method->psi->name)==0){
 			if(CompareParameter(
-				pobj_c->ppobj_Method[i]->psi->pParmInfo,pobj_c->ppobj_Method[i]->psi->ParmNum,
+				method->psi->pParmInfo,method->psi->ParmNum,
 				psi->pParmInfo,psi->ParmNum
 				)==0){
@@ -781,21 +804,21 @@
 	if(bAbstract) psi->bCompile=1;
 
-
-	for(i=0;i<pobj_c->iMethodNum;i++){
-		if(lstrcmp(temporary,pobj_c->ppobj_Method[i]->psi->name)==0){
+	//メソッドのオーバーライド
+	foreach( CMethod *method, pobj_c->methods ){
+		if(lstrcmp(temporary,method->psi->name)==0){
 			if(CompareParameter(
-				pobj_c->ppobj_Method[i]->psi->pParmInfo,pobj_c->ppobj_Method[i]->psi->ParmNum,
+				method->psi->pParmInfo,method->psi->ParmNum,
 				psi->pParmInfo,psi->ParmNum
 				)==0){
 
-				if(pobj_c->ppobj_Method[i]->psi->bVirtual){
+				if(method->psi->bVirtual){
 					//メンバ関数を上書き
-					pobj_c->ppobj_Method[i]->psi=psi;
-					pobj_c->ppobj_Method[i]->bAbstract=0;
+					method->psi=psi;
+					method->bAbstract=0;
 
 					if(!bOverride){
 						SetError(127,NULL,NowLine);
 					}
-					if(pobj_c->ppobj_Method[i]->dwAccess!=dwAccess){
+					if(method->dwAccess!=dwAccess){
 						SetError(128,NULL,NowLine);
 					}
@@ -890,6 +913,4 @@
 			pobj_c->ppobj_StaticMember=(CMember **)HeapAlloc(hHeap,0,1);
 			pobj_c->iStaticMemberNum=0;
-			pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1);
-			pobj_c->iMethodNum=0;
 
 			pobj_c->ConstructorMemberSubIndex=-1;
@@ -1050,6 +1071,4 @@
 			pobj_c->ppobj_StaticMember=(CMember **)HeapAlloc(hHeap,0,1);
 			pobj_c->iStaticMemberNum=0;
-			pobj_c->ppobj_Method=(CMethod **)HeapAlloc(hHeap,0,1);
-			pobj_c->iMethodNum=0;
 
 			pobj_c->ConstructorMemberSubIndex=-1;
