Index: /trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h	(revision 558)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h	(revision 559)
@@ -437,13 +437,29 @@
 	long comVtblOffset;
 	long vtblMasterListOffset;
+public:
 	std::vector<long> vtblMasterList;
-public:
+	LONG_PTR GetVtblOffset() const
+	{
+		return vtbl_offset;
+	}
+	void SetVtblOffset( int vtblOffset )
+	{
+		this->vtbl_offset = vtblOffset;
+	}
+	long GetComVtblOffset() const
+	{
+		return comVtblOffset;
+	}
+	void SetComVtblOffset( int comVtblOffset )
+	{
+		this->comVtblOffset = comVtblOffset;
+	}
 	void GetVtblMasterListIndexAndVtblIndex( const UserProc *pUserProc, int &vtblMasterListIndex, int &vtblIndex ) const;
 	int GetVtblMasterListIndex( const CClass *pClass ) const;
-	long GetComVtblOffset() const;
 	long GetVtblMasterListOffset() const;
-	void GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset );
-	void GenerateFullVTables();
-	void ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection );
+	void SetVtblMasterListOffset( int vtblMasterListOffset )
+	{
+		this->vtblMasterListOffset = vtblMasterListOffset;
+	}
 	bool IsAbstract() const;
 
@@ -484,10 +500,4 @@
 	bool Insert( CClass *pClass, int nowLine );
 	CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
-
-	// vtblを一時的に生成
-	void GenerateVTables();
-
-	// vtblのを正規のオフセットで再構築
-	void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection );
 
 	virtual void InitStaticMember();
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/include/Method.h
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/include/Method.h	(revision 558)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/include/Method.h	(revision 559)
@@ -273,6 +273,3 @@
 	// 仮想メソッドの個数を取得
 	int GetVtblNum() const;
-
-	// vtblを生成
-	void GenerateVTablePart( long &vtableDataTableOffset ) const;
-};
+};
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/include/VtblGenerator.h
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/include/VtblGenerator.h	(revision 559)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/include/VtblGenerator.h	(revision 559)
@@ -0,0 +1,20 @@
+#pragma once
+
+namespace ActiveBasic{ namespace Compiler{
+
+
+class VtblGenerator
+{
+public:
+	// vtblを一時的に生成
+	static LONG_PTR GenerateVTablePart( const Methods &methods );
+	static void GenerateFullVTables( CClass &_class );
+	static void GenerateVTablesForAllClasses( Classes &classes );
+
+	// vtblのを正規のオフセットで再構築
+	static void ActionVtblSchedule( CClass &_class, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection );
+	static void ActionVtblScheduleForAllClasses( Classes &classes, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection );
+};
+
+
+}}
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp	(revision 558)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp	(revision 559)
@@ -724,8 +724,4 @@
 	return 0;
 }
-long CClass::GetComVtblOffset() const
-{
-	return comVtblOffset;
-}
 long CClass::GetVtblMasterListOffset() const
 {
@@ -737,114 +733,4 @@
 
 	return vtblMasterListOffset;
-}
-void CClass::GenerateVTableMasterList( const std::vector<long> &vtableMasterList, long &offset )
-{
-	offset = compiler.GetObjectModule().dataTable.AddBinary(
-		(void *)&vtableMasterList[0],
-		static_cast<int>(vtableMasterList.size()*sizeof(LONG_PTR))
-	);
-}
-void CClass::GenerateFullVTables()
-{
-	if( IsAbstract() )
-	{
-		// 抽象クラスは無視
-		return;
-	}
-	if( !IsUsing() )
-	{
-		// 使われていないクラスは無視
-		return;
-	}
-
-	// vtblマスターリストの元データに不要なデータが含まれていたらエラー
-	if( vtblMasterList.size() )
-	{
-		compiler.errorMessenger.OutputFatalError();
-	}
-
-	// 自身のクラスのvtblを生成
-	GetDynamicMethods().GenerateVTablePart( this->vtbl_offset );
-	vtblMasterList.push_back( this->vtbl_offset );
-
-	// インターフェイスのvtblを生成
-	BOOST_FOREACH( const ::Interface *pInterface, interfaces )
-	{
-		long tempVtblOffset;
-		pInterface->GetDynamicMethods().GenerateVTablePart( tempVtblOffset );
-		vtblMasterList.push_back( tempVtblOffset );
-
-		pInterface->SetVtblOffset( tempVtblOffset );
-
-		if( pInterface->GetClass().IsComInterface() )
-		{
-			if( this->comVtblOffset )
-			{
-				compiler.errorMessenger.OutputFatalError();
-			}
-			this->comVtblOffset = tempVtblOffset;
-		}
-	}
-
-	// vtblマスターリストを生成
-	GenerateVTableMasterList( vtblMasterList, this->vtblMasterListOffset );
-}
-void CClass::ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection )
-{
-	if( IsAbstract() )
-	{
-		// 抽象クラスは無視
-		return;
-	}
-	if( !IsUsing() )
-	{
-		// 使われていないクラスは無視
-		return;
-	}
-	if(vtbl_offset==-1) return;
-
-	// 自身のクラスのvtbl
-	{
-		LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + vtbl_offset);
-
-		for( int i=0; i<GetVtblNum(); i++ ){
-			const UserProc *pUserProc = (UserProc *)pVtbl[i];
-			if(!pUserProc) continue;
-
-			if( pUserProc->GetBeginOpAddress() == 0
-				&& pUserProc->GetEndOpAddress() == 0 )
-			{
-				Jenga::Throw( "未解決の仮想関数が存在する" );
-			}
-
-			pVtbl[i] = pUserProc->GetBeginOpAddress() + ImageBase + MemPos_CodeSection;
-		}
-	}
-
-	// インターフェイスのvtbl
-	BOOST_FOREACH( const ::Interface *pInterface, interfaces )
-	{
-		LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + pInterface->GetVtblOffset());
-
-		for( int i=0; i<pInterface->GetClass().GetVtblNum(); i++ ){
-			const UserProc *pUserProc = (UserProc *)pVtbl[i];
-			if(!pUserProc) continue;
-
-			if( pUserProc->GetBeginOpAddress() == 0
-				&& pUserProc->GetEndOpAddress() == 0 )
-			{
-				Jenga::Throw( "未解決の仮想関数が存在する" );
-			}
-
-			pVtbl[i] = pUserProc->GetBeginOpAddress() + ImageBase + MemPos_CodeSection;
-		}
-	}
-
-	// vtblマスターリスト
-	LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + vtblMasterListOffset );
-	for( int i=0; i<static_cast<int>(vtblMasterList.size()); i++ )
-	{
-		pVtblMasterList[i] = vtblMasterList[i] + ImageBase + MemPos_DataSection;
-	}
 }
 bool CClass::IsAbstract() const
@@ -905,23 +791,4 @@
 
 	return pClass;	
-}
-
-void Classes::GenerateVTables()
-{
-	Iterator_Reset();
-	while( Iterator_HasNext() )
-	{
-		CClass *pClass = Iterator_GetNext();
-		pClass->GenerateFullVTables();
-	}
-}
-
-void Classes::ActionVtblSchedule( LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ){
-	Iterator_Reset();
-	while( Iterator_HasNext() )
-	{
-		CClass *pClass = Iterator_GetNext();
-		pClass->ActionVtblSchedule( ImageBase, MemPos_CodeSection, MemPos_DataSection);
-	}
 }
 
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/src/Method.cpp
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/src/Method.cpp	(revision 558)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/src/Method.cpp	(revision 559)
@@ -36,5 +36,5 @@
 {
 	// 静的メソッドがコピーコンストラトされることは想定しない
-	compiler.errorMessenger.OutputFatalError();
+	throw;
 }
 
@@ -144,38 +144,2 @@
 	return count;
 }
-
-void Methods::GenerateVTablePart( long &vtableDataTableOffset ) const
-{
-	const UserProc **ppsi = (const UserProc **)malloc(GetVtblNum()*sizeof(UserProc *));
-
-	//関数テーブルに値をセット
-	int i2 = 0;
-	const Methods &methods = *this;
-	BOOST_FOREACH( const CMethod *pMethod, methods ){
-		if(pMethod->IsVirtual()){
-			if( !pMethod->GetUserProc().IsUsing() )
-			{
-				//ts((char *)pMethod->GetUserProc().GetFullName().c_str());
-			}
-			pMethod->GetUserProc().Using();
-
-			if(pMethod->IsAbstract()){
-				compiler.errorMessenger.OutputFatalError();
-
-				ppsi[i2]=0;
-			}
-			else{
-				ppsi[i2]=&pMethod->GetUserProc();
-			}
-			i2++;
-		}
-	}
-
-	vtableDataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( (void *)ppsi, GetVtblNum()*sizeof(LONG_PTR) );
-
-	for( int i=0; i < GetVtblNum(); i++ ){
-		pobj_Reloc->AddSchedule_DataSection(static_cast<DWORD>(vtableDataTableOffset+i*sizeof(LONG_PTR)));
-	}
-
-	free(ppsi);
-}
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp	(revision 559)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp	(revision 559)
@@ -0,0 +1,171 @@
+#include "stdafx.h"
+
+using namespace ActiveBasic::Compiler;
+
+LONG_PTR VtblGenerator::GenerateVTablePart( const Methods &methods )
+{
+	const UserProc **ppsi = (const UserProc **)malloc(methods.GetVtblNum()*sizeof(UserProc *));
+
+	//関数テーブルに値をセット
+	int i2 = 0;
+	BOOST_FOREACH( const CMethod *pMethod, methods )
+	{
+		if(pMethod->IsVirtual()){
+			if( !pMethod->GetUserProc().IsUsing() )
+			{
+				//ts((char *)pMethod->GetUserProc().GetFullName().c_str());
+			}
+			pMethod->GetUserProc().Using();
+
+			if(pMethod->IsAbstract())
+			{
+				throw;
+			}
+
+			ppsi[i2]=&pMethod->GetUserProc();
+
+			i2++;
+		}
+	}
+
+	LONG_PTR vtableDataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( (void *)ppsi, methods.GetVtblNum()*sizeof(LONG_PTR) );
+
+	for( int i=0; i < methods.GetVtblNum(); i++ )
+	{
+		pobj_Reloc->AddSchedule_DataSection(static_cast<DWORD>(vtableDataTableOffset+i*sizeof(LONG_PTR)));
+	}
+
+	free(ppsi);
+
+	return vtableDataTableOffset;
+}
+
+void VtblGenerator::GenerateFullVTables( CClass &_class )
+{
+	if( _class.IsAbstract() )
+	{
+		// 抽象クラスは無視
+		return;
+	}
+	if( !_class.IsUsing() )
+	{
+		// 使われていないクラスは無視
+		return;
+	}
+
+	// vtblマスターリストの元データに不要なデータが含まれていたらエラー
+	if( _class.vtblMasterList.size() )
+	{
+		throw;
+	}
+
+	// 自身のクラスのvtblを生成
+	LONG_PTR thisClassVtblOffset = GenerateVTablePart( _class.GetDynamicMethods() );
+	_class.SetVtblOffset( thisClassVtblOffset );
+	_class.vtblMasterList.push_back( thisClassVtblOffset );
+
+	// インターフェイスのvtblを生成
+	BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
+	{
+		LONG_PTR tempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() );
+		_class.vtblMasterList.push_back( tempVtblOffset );
+
+		pInterface->SetVtblOffset( tempVtblOffset );
+
+		if( pInterface->GetClass().IsComInterface() )
+		{
+			if( _class.GetComVtblOffset() )
+			{
+				throw;
+			}
+			_class.SetComVtblOffset( tempVtblOffset );
+		}
+	}
+
+	// vtblマスターリストを生成
+	int offset = compiler.GetObjectModule().dataTable.AddBinary(
+		(void *)&_class.vtblMasterList[0],
+		static_cast<int>(_class.vtblMasterList.size()*sizeof(LONG_PTR))
+	);
+	_class.SetVtblMasterListOffset( offset );
+}
+
+void VtblGenerator::GenerateVTablesForAllClasses( Classes &classes )
+{
+	classes.Iterator_Reset();
+	while( classes.Iterator_HasNext() )
+	{
+		GenerateFullVTables( *classes.Iterator_GetNext() );
+	}
+}
+
+void VtblGenerator::ActionVtblSchedule( CClass &_class, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection )
+{
+	if( _class.IsAbstract() )
+	{
+		// 抽象クラスは無視
+		return;
+	}
+	if( !_class.IsUsing() )
+	{
+		// 使われていないクラスは無視
+		return;
+	}
+	if( _class.GetVtblOffset() == -1 )
+	{
+		return;
+	}
+
+	// 自身のクラスのvtbl
+	{
+		LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + _class.GetVtblOffset());
+
+		for( int i=0; i<_class.GetVtblNum(); i++ ){
+			const UserProc *pUserProc = (UserProc *)pVtbl[i];
+			if(!pUserProc) continue;
+
+			if( pUserProc->GetBeginOpAddress() == 0
+				&& pUserProc->GetEndOpAddress() == 0 )
+			{
+				Jenga::Throw( "未解決の仮想関数が存在する" );
+			}
+
+			pVtbl[i] = pUserProc->GetBeginOpAddress() + ImageBase + MemPos_CodeSection;
+		}
+	}
+
+	// インターフェイスのvtbl
+	BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
+	{
+		LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + pInterface->GetVtblOffset());
+
+		for( int i=0; i<pInterface->GetClass().GetVtblNum(); i++ ){
+			const UserProc *pUserProc = (UserProc *)pVtbl[i];
+			if(!pUserProc) continue;
+
+			if( pUserProc->GetBeginOpAddress() == 0
+				&& pUserProc->GetEndOpAddress() == 0 )
+			{
+				Jenga::Throw( "未解決の仮想関数が存在する" );
+			}
+
+			pVtbl[i] = pUserProc->GetBeginOpAddress() + ImageBase + MemPos_CodeSection;
+		}
+	}
+
+	// vtblマスターリスト
+	LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + _class.GetVtblMasterListOffset() );
+	for( int i=0; i<static_cast<int>(_class.vtblMasterList.size()); i++ )
+	{
+		pVtblMasterList[i] = _class.vtblMasterList[i] + ImageBase + MemPos_DataSection;
+	}
+}
+
+void VtblGenerator::ActionVtblScheduleForAllClasses( Classes &classes, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection )
+{
+	classes.Iterator_Reset();
+	while( classes.Iterator_HasNext() )
+	{
+		ActionVtblSchedule( *classes.Iterator_GetNext(), ImageBase, MemPos_CodeSection, MemPos_DataSection );
+	}
+}
Index: /trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp
===================================================================
--- /trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp	(revision 558)
+++ /trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp	(revision 559)
@@ -537,5 +537,7 @@
 	/////////////////////////////////////////////////////////////////
 
-	compiler.GetObjectModule().meta.GetClasses().GenerateVTables();
+	ActiveBasic::Compiler::VtblGenerator::GenerateVTablesForAllClasses(
+		compiler.GetObjectModule().meta.GetClasses()
+	);
 
 
@@ -1089,5 +1091,10 @@
 	////////////////////////////////////////
 	//仮想関数データテーブルスケジュール
-	compiler.GetObjectModule().meta.GetClasses().ActionVtblSchedule( ImageBase, MemPos_CodeSection, MemPos_DataSection );
+	ActiveBasic::Compiler::VtblGenerator::ActionVtblScheduleForAllClasses(
+		compiler.GetObjectModule().meta.GetClasses(),
+		ImageBase,
+		MemPos_CodeSection,
+		MemPos_DataSection
+	);
 
 
Index: /trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj
===================================================================
--- /trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj	(revision 558)
+++ /trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj	(revision 559)
@@ -1288,4 +1288,8 @@
 					>
 				</File>
+				<File
+					RelativePath="..\BasicCompiler_Common\src\VtblGenerator.cpp"
+					>
+				</File>
 				<Filter
 					Name="Langauge Classes"
@@ -1481,4 +1485,8 @@
 					>
 				</File>
+				<File
+					RelativePath="..\BasicCompiler_Common\include\VtblGenerator.h"
+					>
+				</File>
 				<Filter
 					Name="Language Classes"
Index: /trunk/ab5.0/abdev/compiler_x86/stdafx.h
===================================================================
--- /trunk/ab5.0/abdev/compiler_x86/stdafx.h	(revision 558)
+++ /trunk/ab5.0/abdev/compiler_x86/stdafx.h	(revision 559)
@@ -71,2 +71,3 @@
 #include <Program.h>
 #include <LexicalAnalyzer.h>
+#include <VtblGenerator.h>
