Index: BasicCompiler_Common/Class.cpp
===================================================================
--- BasicCompiler_Common/Class.cpp	(revision 28)
+++ BasicCompiler_Common/Class.cpp	(revision 29)
@@ -215,4 +215,53 @@
 	}
 }
+void CClass::Inherits( CClass *pInheritsClass ){
+	int i3;
+
+	//メンバをコピー
+	ppobj_Member=(CMember **)HeapReAlloc(
+		hHeap,
+		0,
+		ppobj_Member,
+		pInheritsClass->iMemberNum*sizeof(CMember *));
+	iMemberNum=pInheritsClass->iMemberNum;
+	for(i3=0;i3<pInheritsClass->iMemberNum;i3++){
+		ppobj_Member[i3]=new CMember(pInheritsClass->ppobj_Member[i3]);
+
+		//dwAccess
+		if(pInheritsClass->ppobj_Member[i3]->dwAccess==ACCESS_PRIVATE)
+			ppobj_Member[i3]->dwAccess=ACCESS_NON;
+		else ppobj_Member[i3]->dwAccess=pInheritsClass->ppobj_Member[i3]->dwAccess;
+	}
+
+	//メソッドをコピー
+	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]);
+
+		//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;
+
+		//pobj_Inherits
+		// ※継承元のClassIndexをセット（入れ子継承を考慮する）
+		if(pInheritsClass->ppobj_Method[i3]->pobj_InheritsClass==0)
+			ppobj_Method[i3]->pobj_InheritsClass=pInheritsClass;
+		else
+			ppobj_Method[i3]->pobj_InheritsClass=
+				pInheritsClass->ppobj_Method[i3]->pobj_InheritsClass;
+	}
+
+	//仮想関数の数
+	vtbl_num=pInheritsClass->vtbl_num;
+
+	//継承先のクラスをメンバとして保持する
+	pobj_InheritsClass = pInheritsClass;
+}
 void CClass::AddMember( DWORD dwAccess, bool isConst, char *buffer ){
 	ppobj_Member = (CMember **)HeapReAlloc( hHeap, 0, ppobj_Member, ( iMemberNum + 1 ) * sizeof(CMember *) );
@@ -849,6 +898,6 @@
 
 				//継承元クラスを取得
-				pobj_c->pobj_InheritsClass=check(temporary);
-				if(!pobj_c->pobj_InheritsClass){
+				CClass *pInheritsClass = check(temporary);
+				if( !pInheritsClass ){
 					SetError(106,temporary,i);
 					goto Interface_InheritsError;
@@ -861,5 +910,5 @@
 				}
 
-				if(pobj_c->pobj_InheritsClass->ppobj_Member==0){
+				if( pInheritsClass->ppobj_Member == 0 ){
 					//継承先が読み取られていないとき
 					pobj_LoopRefCheck->add(pobj_c->name);
@@ -868,46 +917,6 @@
 				}
 
-				//メンバ変数をコピー
-				pobj_c->ppobj_Member=(CMember **)HeapReAlloc(
-					hHeap,
-					0,
-					pobj_c->ppobj_Member,
-					pobj_c->pobj_InheritsClass->iMemberNum*sizeof(CMember *));
-				pobj_c->iMemberNum=pobj_c->pobj_InheritsClass->iMemberNum;
-				for(i3=0;i3<pobj_c->pobj_InheritsClass->iMemberNum;i3++){
-					pobj_c->ppobj_Member[i3]=new CMember(pobj_c->pobj_InheritsClass->ppobj_Member[i3]);
-
-					//dwAccess
-					if(pobj_c->pobj_InheritsClass->ppobj_Member[i3]->dwAccess==ACCESS_PRIVATE)
-						pobj_c->ppobj_Member[i3]->dwAccess=ACCESS_NON;
-					else pobj_c->ppobj_Member[i3]->dwAccess=pobj_c->pobj_InheritsClass->ppobj_Member[i3]->dwAccess;
-				}
-
-				//メンバ関数をコピー
-				pobj_c->ppobj_Method=(CMethod **)HeapReAlloc(
-					hHeap,
-					0,
-					pobj_c->ppobj_Method,
-					pobj_c->pobj_InheritsClass->iMethodNum*sizeof(CMethod *));
-				pobj_c->iMethodNum=pobj_c->pobj_InheritsClass->iMethodNum;
-				for(i3=0;i3<pobj_c->pobj_InheritsClass->iMethodNum;i3++){
-					pobj_c->ppobj_Method[i3]=new CMethod(pobj_c->pobj_InheritsClass->ppobj_Method[i3]);
-
-					//dwAccess
-					if(pobj_c->pobj_InheritsClass->ppobj_Method[i3]->dwAccess==ACCESS_PRIVATE)
-						pobj_c->ppobj_Method[i3]->dwAccess=ACCESS_NON;
-					else pobj_c->ppobj_Method[i3]->dwAccess=pobj_c->pobj_InheritsClass->ppobj_Method[i3]->dwAccess;
-
-					//pobj_Inherits
-					// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-					if(pobj_c->pobj_InheritsClass->ppobj_Method[i3]->pobj_InheritsClass==0)
-						pobj_c->ppobj_Method[i3]->pobj_InheritsClass=pobj_c->pobj_InheritsClass;
-					else
-						pobj_c->ppobj_Method[i3]->pobj_InheritsClass=
-							pobj_c->pobj_InheritsClass->ppobj_Method[i3]->pobj_InheritsClass;
-				}
-
-				//仮想関数の数
-				pobj_c->vtbl_num=pobj_c->pobj_InheritsClass->vtbl_num;
+				//継承させる
+				pobj_c->Inherits( pInheritsClass );
 			}
 			else{
@@ -1039,22 +1048,35 @@
 			else dwAccess=ACCESS_PUBLIC;
 
-			if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS){
-				//継承を行う場合
-				for(i+=3,i2=0;;i++,i2++){
-					if(IsCommandDelimitation(basbuf[i])){
-						temporary[i2]=0;
-						break;
+			if( lstrcmp( pobj_c->name, "Object" ) == 0 || dwClassType == ESC_TYPE ){
+				//継承無し
+				pobj_c->pobj_InheritsClass=0;
+
+				//仮想関数の数を初期化
+				pobj_c->vtbl_num=0;
+			}
+			else{
+				if(basbuf[i+1]==1&&basbuf[i+2]==ESC_INHERITS){
+					//継承を行う場合
+					for(i+=3,i2=0;;i++,i2++){
+						if(IsCommandDelimitation(basbuf[i])){
+							temporary[i2]=0;
+							break;
+						}
+						temporary[i2]=basbuf[i];
 					}
-					temporary[i2]=basbuf[i];
-				}
-
-				if(lstrcmpi(temporary,pobj_c->name)==0){
-					SetError(105,temporary,i);
-					goto InheritsError;
+
+					if(lstrcmpi(temporary,pobj_c->name)==0){
+						SetError(105,temporary,i);
+						goto InheritsError;
+					}
+				}
+				else{
+					//Objectを継承する
+					lstrcpy( temporary, "Object" );
 				}
 
 				//継承元クラスを取得
-				pobj_c->pobj_InheritsClass=check(temporary);
-				if(!pobj_c->pobj_InheritsClass){
+				CClass *pInheritsClass = check(temporary);
+				if( !pInheritsClass ){
 					SetError(106,temporary,i);
 					goto InheritsError;
@@ -1067,5 +1089,5 @@
 				}
 
-				if(pobj_c->pobj_InheritsClass->ppobj_Member==0){
+				if( pInheritsClass->ppobj_Member == 0 ){
 					//継承先が読み取られていないとき
 					pobj_LoopRefCheck->add(pobj_c->name);
@@ -1074,53 +1096,6 @@
 				}
 
-				//メンバをコピー
-				pobj_c->ppobj_Member=(CMember **)HeapReAlloc(
-					hHeap,
-					0,
-					pobj_c->ppobj_Member,
-					pobj_c->pobj_InheritsClass->iMemberNum*sizeof(CMember *));
-				pobj_c->iMemberNum=pobj_c->pobj_InheritsClass->iMemberNum;
-				for(i3=0;i3<pobj_c->pobj_InheritsClass->iMemberNum;i3++){
-					pobj_c->ppobj_Member[i3]=new CMember(pobj_c->pobj_InheritsClass->ppobj_Member[i3]);
-
-					//dwAccess
-					if(pobj_c->pobj_InheritsClass->ppobj_Member[i3]->dwAccess==ACCESS_PRIVATE)
-						pobj_c->ppobj_Member[i3]->dwAccess=ACCESS_NON;
-					else pobj_c->ppobj_Member[i3]->dwAccess=pobj_c->pobj_InheritsClass->ppobj_Member[i3]->dwAccess;
-				}
-
-				//メソッドをコピー
-				pobj_c->ppobj_Method=(CMethod **)HeapReAlloc(
-					hHeap,
-					0,
-					pobj_c->ppobj_Method,
-					pobj_c->pobj_InheritsClass->iMethodNum*sizeof(CMethod *));
-				pobj_c->iMethodNum=pobj_c->pobj_InheritsClass->iMethodNum;
-				for(i3=0;i3<pobj_c->pobj_InheritsClass->iMethodNum;i3++){
-					pobj_c->ppobj_Method[i3]=new CMethod(pobj_c->pobj_InheritsClass->ppobj_Method[i3]);
-
-					//dwAccess
-					if(pobj_c->pobj_InheritsClass->ppobj_Method[i3]->dwAccess==ACCESS_PRIVATE)
-						pobj_c->ppobj_Method[i3]->dwAccess=ACCESS_NON;
-					else pobj_c->ppobj_Method[i3]->dwAccess=pobj_c->pobj_InheritsClass->ppobj_Method[i3]->dwAccess;
-
-					//pobj_Inherits
-					// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-					if(pobj_c->pobj_InheritsClass->ppobj_Method[i3]->pobj_InheritsClass==0)
-						pobj_c->ppobj_Method[i3]->pobj_InheritsClass=pobj_c->pobj_InheritsClass;
-					else
-						pobj_c->ppobj_Method[i3]->pobj_InheritsClass=
-							pobj_c->pobj_InheritsClass->ppobj_Method[i3]->pobj_InheritsClass;
-				}
-
-				//仮想関数の数
-				pobj_c->vtbl_num=pobj_c->pobj_InheritsClass->vtbl_num;
-			}
-			else{
-				//継承無し
-				pobj_c->pobj_InheritsClass=0;
-
-				//仮想関数の数を初期化
-				pobj_c->vtbl_num=0;
+				//継承させる
+				pobj_c->Inherits( pInheritsClass );
 			}
 InheritsError:
