Index: BasicCompiler_Common/Class.cpp
===================================================================
--- BasicCompiler_Common/Class.cpp	(revision 134)
+++ BasicCompiler_Common/Class.cpp	(revision 135)
@@ -12,141 +12,4 @@
 
 CMember *pCompilingMethod;
-
-
-
-CMember::CMember( CClass *pobj_c, DWORD access, bool isConst, bool isRef, char *buffer, int nowLine ){
-	extern int cp;
-
-						if( strstr(buffer,"environVarName")){
-							int test=0;
-						}
-
-	//構文を解析
-	char VarName[VN_SIZE];
-	char init_buf[VN_SIZE];
-	char constract_parameter[VN_SIZE];
-	GetDimentionFormat(buffer,VarName,SubScripts,*this,init_buf,constract_parameter);
-
-	//重複チェック
-	if(pobj_c->DupliCheckAll(VarName)){
-		SetError(15,VarName,cp);
-	}
-
-	//メンバ名
-	name=(char *)HeapAlloc(hHeap,0,lstrlen(VarName)+1);
-	lstrcpy(name,VarName);
-
-	//アクセス権
-	dwAccess=access;
-
-	//定数扱いかどうか
-	this->isConst = isConst;
-
-	//初期データ
-	InitBuf=(char *)HeapAlloc(hHeap,0,lstrlen(init_buf)+1);
-	lstrcpy(InitBuf,init_buf);
-
-	//コンストラクタ用のパラメータ
-	ConstractParameter=(char *)HeapAlloc(hHeap,0,lstrlen(constract_parameter)+1);
-	lstrcpy(ConstractParameter,constract_parameter);
-
-	//ソースコードの位置
-	source_code_address=nowLine;
-}
-CMember::CMember(CMember &member):
-	Type( member )
-{
-
-	//name
-	name=(char *)HeapAlloc(hHeap,0,lstrlen(member.name)+1);
-	lstrcpy(name,member.name);
-
-	//定数扱いかどうか
-	isConst = member.isConst;
-
-	//SubScripts
-	memcpy(SubScripts,member.SubScripts,MAX_ARRAYDIM*sizeof(int));
-
-	//ソースコードの位置
-	source_code_address=member.source_code_address;
-}
-CMember::CMember(){
-	memset(this,0,sizeof(CMember));
-}
-CMember::~CMember(){
-	HeapDefaultFree(name);
-	if(InitBuf) HeapDefaultFree(InitBuf);
-	if(ConstractParameter) HeapDefaultFree(ConstractParameter);
-}
-
-bool CMember::IsConst(){
-	return isConst;
-}
-
-void CMember::InitStaticMember(void){
-	//静的メンバをグローバル領域に作成
-
-	//イテレータをリセット
-	extern CDBClass *pobj_DBClass;
-	pobj_DBClass->Iterator_Reset();
-
-	int back_cp=cp;
-
-	while(pobj_DBClass->Iterator_HasNext()){
-		CClass &objClass = *pobj_DBClass->Iterator_GetNext();
-
-		// 名前空間をセット
-		Smoothie::Lexical::liveingNamespaceScopes = objClass.GetNamespaceScopes();
-
-		int i=0;
-		foreach( CMember *member, objClass.staticMembers ){
-			char temporary[VN_SIZE];
-			sprintf(temporary,"%s.%s",objClass.GetName().c_str(),member->name);
-			dim(
-				temporary,
-				member->SubScripts,
-				*member,
-				member->InitBuf,
-				member->ConstractParameter,
-				0);
-
-			//ネイティブコードバッファの再確保
-			ReallocNativeCodeBuffer();
-
-			i++;
-		}
-	}
-
-	Smoothie::Lexical::liveingNamespaceScopes.clear();
-
-	cp=back_cp;
-}
-
-
-
-//コピーコンストラクタ
-CMethod::CMethod(CMethod *pMethod)
-	: pUserProc( pMethod->pUserProc )
-	, dwAccess( pMethod->dwAccess )
-	, bAbstract( pMethod->bAbstract )
-	, bVirtual( pMethod->bVirtual )
-	, isConst( pMethod->isConst )
-	, isStatic( pMethod->isStatic )
-{
-}
-
-CMethod::CMethod( UserProc *pUserProc, DWORD dwAccess, BOOL bAbstract, BOOL bVirtual, bool isConst, bool isStatic )
-	: pUserProc( pUserProc )
-	, dwAccess( dwAccess )
-	, bAbstract( bAbstract )
-	, bVirtual( bVirtual )
-	, isConst( isConst )
-	, isStatic( isStatic )
-	, pobj_InheritsClass( NULL )
-{
-}
-CMethod::~CMethod(){
-}
-
 
 
@@ -184,14 +47,4 @@
 		delete member;
 	}
-
-	//メソッド
-	foreach( CMethod *method, methods ){
-		delete method;
-	}
-
-	//静的メソッド
-	foreach( CMethod *method, staticMethods ){
-		delete method;
-	}
 }
 
@@ -321,21 +174,22 @@
 
 	//メソッドをコピー
-	foreach( CMethod *baseMethod, inheritsClass.methods ){
-		CMethod *method = new CMethod( baseMethod );
+	foreach( const CMethod *pBaseMethod, inheritsClass.methods ){
+		CMethod *pMethod = new DynamicMethod( *pBaseMethod );
 
 		//dwAccess
-		if(baseMethod->dwAccess==ACCESS_PRIVATE)
-			method->dwAccess=ACCESS_NON;
-		else method->dwAccess=baseMethod->dwAccess;
+		if(pBaseMethod->dwAccess==ACCESS_PRIVATE)
+			pMethod->dwAccess=ACCESS_NON;
+		else pMethod->dwAccess=pBaseMethod->dwAccess;
 
 		//pobj_Inherits
 		// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-		if(baseMethod->pobj_InheritsClass==0)
-			method->pobj_InheritsClass=&inheritsClass;
-		else
-			method->pobj_InheritsClass=
-				baseMethod->pobj_InheritsClass;
-
-		methods.push_back( method );
+		if(pBaseMethod->GetInheritsClassPtr()==0){
+			pMethod->SetInheritsClassPtr( &inheritsClass );
+		}
+		else{
+			pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
+		}
+
+		methods.push_back( pMethod );
 	}
 
@@ -364,21 +218,22 @@
 
 	//メソッドをコピー
-	foreach( CMethod *baseMethod, inheritsInterface.methods ){
-		CMethod *method = new CMethod( baseMethod );
+	foreach( const CMethod *pBaseMethod, inheritsInterface.methods ){
+		CMethod *pMethod = new DynamicMethod( *pBaseMethod );
 
 		//dwAccess
-		if(baseMethod->dwAccess==ACCESS_PRIVATE)
-			method->dwAccess=ACCESS_NON;
-		else method->dwAccess=baseMethod->dwAccess;
+		if(pBaseMethod->dwAccess==ACCESS_PRIVATE)
+			pMethod->dwAccess=ACCESS_NON;
+		else pMethod->dwAccess=pBaseMethod->dwAccess;
 
 		//pobj_Inherits
 		// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-		if(baseMethod->pobj_InheritsClass==0)
-			method->pobj_InheritsClass=&inheritsInterface;
-		else
-			method->pobj_InheritsClass=
-				baseMethod->pobj_InheritsClass;
-
-		methods.push_back( method );
+		if(pBaseMethod->GetInheritsClassPtr()==0){
+			pMethod->SetInheritsClassPtr( &inheritsInterface );
+		}
+		else{
+			pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
+		}
+
+		methods.push_back( pMethod );
 	}
 
@@ -399,20 +254,4 @@
 	staticMembers.push_back( member );
 }
-void CClass::AddMethod( UserProc *pUserProc,DWORD dwAccess, bool isConst, BOOL bAbstract, BOOL bVirtual ){
-	CMethod *method = new CMethod( pUserProc, dwAccess, bAbstract, bVirtual, isConst, false );
-
-	methods.push_back( method );
-
-	// プロシージャオブジェクトと関連付け
-	pUserProc->SetMethod( method );
-}
-void CClass::AddStaticMethod(UserProc *pUserProc,DWORD dwAccess){
-	CMethod *method = new CMethod( pUserProc, dwAccess, FALSE, FALSE, false, true );
-
-	staticMethods.push_back( method );
-
-	// プロシージャオブジェクトと関連付け
-	pUserProc->SetMethod( method );
-}
 BOOL CClass::DupliCheckAll(const char *name){
 	//重複チェック
@@ -422,6 +261,6 @@
 
 	//メソッド
-	foreach( CMethod *method, methods ){
-		if( lstrcmp( name, method->pUserProc->GetName().c_str() ) == 0 ){
+	foreach( const CMethod *pMethod, methods ){
+		if( lstrcmp( name, pMethod->pUserProc->GetName().c_str() ) == 0 ){
 			return 1;
 		}
@@ -435,5 +274,5 @@
 	//メンバ
 	for( int i=0;i<iMemberNum;i++){
-		if( GetName() == ppobj_Member[i]->name ){
+		if( GetName() == ppobj_Member[i]->GetName() ){
 			return 1;
 		}
@@ -442,5 +281,5 @@
 	//静的メンバ
 	foreach( CMember *member, staticMembers ){
-		if( GetName() == member->name ){
+		if( GetName() == member->GetName() ){
 			return 1;
 		}
@@ -449,72 +288,7 @@
 	return 0;
 }
-CMethod *CClass::GetMethodInfo( UserProc *pUserProc ) const
-{
-	for( int i=(int)methods.size()-1; i>=0; i-- ){
-		if( pUserProc == methods[i]->pUserProc ){
-			return methods[i];
-		}
-	}
-	return NULL;
-}
-CMethod *CClass::GetStaticMethodInfo( UserProc *pUserProc ) const
-{
-	for( int i=(int)staticMethods.size()-1; i>=0; i-- ){
-		if( pUserProc == staticMethods[i]->pUserProc ) return staticMethods[i];
-	}
-	return NULL;
-}
-bool CClass::IsExistMethod( const char *name ) const
-{
-	foreach( CMethod *method, methods ){
-		if( method->pUserProc->GetName() == name ) return true;
-	}
-	return false;
-}
-bool CClass::IsExistStaticMethod( const char *name ) const
-{
-	foreach( CMethod *method, staticMethods ){
-		if( method->pUserProc->GetName() == name ) return true;
-	}
-	return false;
-}
-
-void CClass::EnumStaticMethod( const char *methodName, vector<UserProc *> &subs ) const
-{
-	foreach( CMethod *method, staticMethods ){
-		if( method->pUserProc->GetName() == methodName ){
-			subs.push_back( method->pUserProc );
-		}
-	}
-}
-
-void CClass::EnumMethod( const char *methodName, vector<UserProc *> &subs ) const
-{
-	//オブジェクトのメンバ関数の場合
-	//※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
-	for( int i=(int)methods.size()-1; i>=0; i-- ){
-		if( methods[i]->pUserProc->GetName() == methodName ){
-			subs.push_back( methods[i]->pUserProc );
-		}
-	}
-}
-
-void CClass::EnumMethod( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const
-{
-	//オブジェクトのメンバ関数の場合
-	//※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
-	for( int i=(int)methods.size()-1; i>=0; i-- ){
-		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( pUserProc );
-			}
-		}
-	}
-}
 
 //デフォルト コンストラクタ メソッドを取得
-CMethod *CClass::GetConstructorMethod() const
+const CMethod *CClass::GetConstructorMethod() const
 {
 	if( ConstructorMemberSubIndex == -1 ) return NULL;
@@ -523,5 +297,5 @@
 
 //デストラクタ メソッドを取得
-CMethod *CClass::GetDestructorMethod() const
+const CMethod *CClass::GetDestructorMethod() const
 {
 	if( DestructorMemberSubIndex == -1 ) return NULL;
@@ -584,5 +358,5 @@
 		if(memberName){
 			//メンバ指定がある場合は、オフセットを返す
-			if(lstrcmp(pMember->name,memberName)==0){
+			if( pMember->GetName() == memberName ){
 				if(pMemberNum) *pMemberNum=i;
 				return offset;
@@ -644,7 +418,7 @@
 {
 	int n = 0;
-	foreach( CMethod *method, methods ){
-		if( method->pUserProc == pUserProc ) break;
-		if( method->bVirtual ) n++;
+	foreach( const CMethod *pMethod, methods ){
+		if( pMethod->pUserProc == pUserProc ) break;
+		if( pMethod->IsVirtual() ) n++;
 	}
 	return n;
@@ -667,9 +441,9 @@
 	//関数テーブルに値をセット
 	int i2 = 0;
-	foreach( CMethod *method, methods ){
-		if(method->bVirtual){
-			method->pUserProc->Using();
-
-			if(method->bAbstract){
+	foreach( const CMethod *pMethod, methods ){
+		if(pMethod->IsVirtual()){
+			pMethod->pUserProc->Using();
+
+			if(pMethod->IsAbstract()){
 				extern int cp;
 				SetError(300,NULL,cp);
@@ -678,5 +452,5 @@
 			}
 			else{
-				ppsi[i2]=method->pUserProc;
+				ppsi[i2]=pMethod->pUserProc;
 			}
 			i2++;
@@ -712,7 +486,7 @@
 	// 未実装(abstract)の仮想関数を持つ場合はtrueを返す
 
-	foreach( CMethod *method, methods ){
-		if(method->bVirtual){
-			if(method->bAbstract){
+	foreach( const CMethod *pMethod, methods ){
+		if(pMethod->IsVirtual()){
+			if(pMethod->IsAbstract()){
 				return true;
 			}
@@ -1063,6 +837,6 @@
 
 
-void CDBClass::AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, BOOL bAbstract,
-						 BOOL bVirtual, BOOL bOverride, char *buffer, int nowLine){
+void CDBClass::AddMethod(CClass *pobj_c, DWORD dwAccess, BOOL bStatic, bool isConst, bool isAbstract,
+						 bool isVirtual, bool isOverride, char *buffer, int nowLine){
 	int i,i2;
 	char temporary[VN_SIZE];
@@ -1080,5 +854,5 @@
 	//関数ハッシュへ登録
 	GlobalProc *pUserProc;
-	pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,bVirtual,pobj_c, (bStatic!=0) );
+	pUserProc=AddSubData( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0) );
 	if(!pUserProc) return;
 
@@ -1129,10 +903,10 @@
 
 	//メソッド
-	foreach( CMethod *method, pobj_c->methods ){
+	foreach( const CMethod *pMethod, pobj_c->methods ){
 		//基底クラスと重複する場合はオーバーライドを行う
-		if(method->pobj_InheritsClass) continue;
-
-		if( method->pUserProc->GetName() == temporary ){
-			if( method->pUserProc->Params().Equals( pUserProc->Params() ) ){
+		if( pMethod->GetInheritsClassPtr() ) continue;
+
+		if( pMethod->pUserProc->GetName() == temporary ){
+			if( pMethod->pUserProc->Params().Equals( pUserProc->Params() ) ){
 				//関数名、パラメータ属性が合致したとき
 				SetError(15,pUserProc->GetName().c_str(),nowLine);
@@ -1143,24 +917,24 @@
 
 	//仮想関数の場合
-	if(bAbstract) pUserProc->CompleteCompile();
+	if( isAbstract ) pUserProc->CompleteCompile();
 
 	//メソッドのオーバーライド
-	foreach( CMethod *method, pobj_c->methods ){
-		if( method->pUserProc->GetName() == temporary ){
-			if( method->pUserProc->Params().Equals( pUserProc->Params() ) ){
-
-				if(method->bVirtual){
+	foreach( CMethod *pMethod, pobj_c->methods ){
+		if( pMethod->pUserProc->GetName() == temporary ){
+			if( pMethod->pUserProc->Params().Equals( pUserProc->Params() ) ){
+
+				if(pMethod->IsVirtual()){
 					//メンバ関数を上書き
-					method->pUserProc=pUserProc;
-					method->bAbstract=0;
-
-					if(!bOverride){
+					pMethod->pUserProc=pUserProc;
+					pMethod->Override();
+
+					if( !isOverride ){
 						SetError(127,NULL,nowLine);
 					}
-					if(method->dwAccess!=dwAccess){
+					if(pMethod->dwAccess!=dwAccess){
 						SetError(128,NULL,nowLine);
 					}
 
-					pUserProc->SetMethod( method );
+					pUserProc->SetMethod( pMethod );
 					return;
 				}
@@ -1169,17 +943,17 @@
 	}
 
-	if(bVirtual){
+	if( isVirtual ){
 		pobj_c->vtbl_num++;
 	}
 
-	if(bOverride){
+	if( isOverride ){
 		SetError(12,"Override",nowLine);
 	}
 
 	if(bStatic){
-		pobj_c->AddStaticMethod(pUserProc,dwAccess);
+		pobj_c->staticMethods.AddStatic(pUserProc,dwAccess);
 	}
 	else{
-		pobj_c->AddMethod(pUserProc, dwAccess, isConst, bAbstract, bVirtual);
+		pobj_c->methods.Add(pUserProc, dwAccess, isConst, isAbstract, isVirtual);
 	}
 }
@@ -1517,8 +1291,8 @@
 				else i3=0;
 
-				BOOL bVirtual=0,bAbstract=0,bOverride=0;
+				bool isVirtual = false, isAbstract = false, isOverride = false;
 				if(i3==ESC_ABSTRACT){
-					bAbstract=1;
-					bVirtual=1;
+					isAbstract=1;
+					isVirtual=1;
 					i+=2;
 
@@ -1526,6 +1300,6 @@
 				}
 				else if(i3==ESC_VIRTUAL){
-					bAbstract=0;
-					bVirtual=1;
+					isAbstract=0;
+					isVirtual=1;
 					i+=2;
 
@@ -1533,6 +1307,6 @@
 				}
 				else if(i3==ESC_OVERRIDE){
-					bOverride=1;
-					bVirtual=1;
+					isOverride=1;
+					isVirtual=1;
 
 					i+=2;
@@ -1619,11 +1393,11 @@
 						bStatic,
 						isConst,
-						bAbstract,
-						bVirtual,
-						bOverride,
+						isAbstract,
+						isVirtual,
+						isOverride,
 						temporary,
 						sub_address);
 
-					if(bAbstract) continue;
+					if( isAbstract ) continue;
 
 					for(;;i++){
@@ -1699,5 +1473,5 @@
 				sprintf( referenceOffsetsBuffer + lstrlen( referenceOffsetsBuffer ),
 					"%d",
-					objClass.GetMemberOffset( member.name ) );
+					objClass.GetMemberOffset( member.GetName().c_str() ) );
 
 				numOfReference++;
@@ -1822,7 +1596,7 @@
 		pCompilingClass->Using();
 
-		pCompilingMethod = pCompilingClass->GetMethodInfo( pUserProc );
+		pCompilingMethod = pCompilingClass->methods.GetMethodPtr( pUserProc );
 		if( !pCompilingMethod ){
-			pCompilingMethod = pCompilingClass->GetStaticMethodInfo( pUserProc );
+			pCompilingMethod = pCompilingClass->staticMethods.GetMethodPtr( pUserProc );
 			if( !pCompilingMethod ){
 				SetError(300,NULL,cp);
@@ -1838,5 +1612,5 @@
 	return pCompilingClass;
 }
-CMethod *CDBClass::GetNowCompilingMethodInfo(){
+const CMethod *CDBClass::GetNowCompilingMethodInfo(){
 	return pCompilingMethod;
 }
