Index: trunk/abdev/BasicCompiler64/CodeGenerator.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/CodeGenerator.cpp	(revision 316)
+++ trunk/abdev/BasicCompiler64/CodeGenerator.cpp	(revision 317)
@@ -1716,2 +1716,12 @@
 	pNativeCode->PutUserProcSchedule( pUserProc, false );
 }
+void CodeGenerator::op_mov_RV_vtbl( int reg, const CClass *pClass )
+{
+	// mov reg,vtblAddress
+
+	//オペコード、レジスタ
+	pNativeCode->Put( (char)(0xB8|REGISTER_OPERAND(reg)) );
+
+	//DISP32
+	pNativeCode->PutVtblSchedule( pClass );
+}
Index: trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp	(revision 316)
+++ trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp	(revision 317)
@@ -510,16 +510,24 @@
 			//仮想関数テーブルを初期化
 			if( compiler.pCompilingClass->IsExistVirtualFunctions()
-				&& !compiler.pCompilingClass->IsAbstract() ){
-					//関数テーブルに値をセット
-					int offset = (int)compiler.pCompilingClass->GetVtblGlobalOffset();
-
-					//mov rax,offset
-					compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,offset, Schedule::DataTable );
-
-					//Thisポインタをrcxにコピー
-					SetThisPtrToReg(REG_RCX);
-
-					//mov qword ptr[rcx],rax
-					compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RCX,0,MOD_BASE);
+				&& !compiler.pCompilingClass->IsAbstract() )
+			{
+				// mov rax,vtblAddress
+				compiler.codeGenerator.op_mov_RV_vtbl( REG_RAX, compiler.pCompilingClass );
+
+				//Thisポインタをrcxにコピー
+				SetThisPtrToReg(REG_RCX);
+
+				//mov qword ptr[rcx],rax
+				compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RCX,0,MOD_BASE);
+
+
+				// 仮想関数になるメソッドに使用チェックをつける
+				BOOST_FOREACH( const CMethod *pMethod, compiler.pCompilingClass->GetMethods() )
+				{
+					if( pMethod->IsVirtual() )
+					{
+						pMethod->GetUserProc().Using();
+					}
+				}
 			}
 		}
Index: trunk/abdev/BasicCompiler64/Compile_Var.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/Compile_Var.cpp	(revision 316)
+++ trunk/abdev/BasicCompiler64/Compile_Var.cpp	(revision 317)
@@ -13,7 +13,4 @@
 //変数
 // TODO: xml未完成
-int AllGlobalVarSize;
-int AllInitGlobalVarSize;
-
 int AllLocalVarSize;
 
Index: trunk/abdev/BasicCompiler64/MakePeHdr.cpp
===================================================================
--- trunk/abdev/BasicCompiler64/MakePeHdr.cpp	(revision 316)
+++ trunk/abdev/BasicCompiler64/MakePeHdr.cpp	(revision 317)
@@ -789,9 +789,9 @@
 	//グローバル変数情報を扱う構造体も初期バッファの有無による配置を行う
 	//（デバッグ情報で利用される）
-	extern int AllInitGlobalVarSize;
 	BOOST_FOREACH( Variable *pVar, compiler.GetObjectModule().meta.GetGlobalVars() ){
 		if(pVar->GetOffsetAddress()&0x80000000){
 			pVar->SetOffsetAddress(
-				(pVar->GetOffsetAddress()&0x7FFFFFFF)+AllInitGlobalVarSize
+				(pVar->GetOffsetAddress()&0x7FFFFFFF)
+				+ compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize()
 			);
 		}
@@ -863,8 +863,15 @@
 
 	//リライタブルセクションのファイル上のサイズ（グローバル変数の初期情報のみを格納）
-	extern int AllInitGlobalVarSize;
-	if(AllInitGlobalVarSize%FILE_ALIGNMENT) FileSize_RWSection=AllInitGlobalVarSize+(FILE_ALIGNMENT-AllInitGlobalVarSize%FILE_ALIGNMENT);
+	if( compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize() % FILE_ALIGNMENT )
+	{
+		FileSize_RWSection =
+			compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize()
+			+ (FILE_ALIGNMENT-compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize()%FILE_ALIGNMENT);
+	}
 	else{
-		if(AllInitGlobalVarSize) FileSize_RWSection=AllInitGlobalVarSize;
+		if( compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize() )
+		{
+			FileSize_RWSection = compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize();
+		}
 		else FileSize_RWSection=FILE_ALIGNMENT;
 	}
@@ -927,6 +934,6 @@
 
 	//リライタブルセクションのメモリ上のサイズ
-	extern int AllGlobalVarSize;
-	i=AllInitGlobalVarSize+AllGlobalVarSize;
+	i = compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize()
+		+ compiler.GetObjectModule().meta.GetGlobalVars().GetAllSize();
 	if(i%MEM_ALIGNMENT) MemSize_RWSection=i+(MEM_ALIGNMENT-i%MEM_ALIGNMENT);
 	else MemSize_RWSection=i;
@@ -1312,5 +1319,6 @@
 	memset((char *)RWSectionHeader.Name,0,IMAGE_SIZEOF_SHORT_NAME);
 	lstrcpy((char *)RWSectionHeader.Name,".data");
-	RWSectionHeader.Misc.VirtualSize=			AllInitGlobalVarSize+AllGlobalVarSize;
+	RWSectionHeader.Misc.VirtualSize=			compiler.GetObjectModule().meta.GetGlobalVars().initAreaBuffer.GetSize()
+												+ compiler.GetObjectModule().meta.GetGlobalVars().GetAllSize();
 	RWSectionHeader.VirtualAddress=				MemPos_RWSection;
 	RWSectionHeader.SizeOfRawData=				FileSize_RWSection;
Index: trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
===================================================================
--- trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 316)
+++ trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 317)
@@ -364,8 +364,10 @@
 	void op_fld_ptr_esp(int type);
 	void op_zero_reg(int reg);
+
 	void op_call( const UserProc *pUserProc );
 	void op_call( const DllProc *pDllProc );
 	void op_ret();
 	void op_addressof( int reg, const UserProc *pUserProc );
+	void op_mov_RV_vtbl( int reg, const CClass *pClass );
 
 #else
