Index: trunk/ab5.0/abdev/BasicCompiler_Common/Subroutine.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/Subroutine.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/Subroutine.cpp	(revision 511)
@@ -321,141 +321,4 @@
 
 	return true;
-}
-
-void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs )
-{
-	extern HANDLE hHeap;
-	int i,i2,i3;
-	char temporary[8192];
-
-	// 名前空間管理
-	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
-	namespaceScopes.clear();
-
-	// Importsされた名前空間の管理
-	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
-	importedNamespaces.clear();
-
-	i=-1;
-	while(1){
-		i++;
-
-		if(source[i]==1&&(source[i+1]==ESC_CLASS||source[i+1]==ESC_INTERFACE)){
-			/*	Class ～ End Class
-				Interface ～ End Interface
-				を飛び越す			*/
-			i3=GetEndXXXCommand(source[i+1]);
-			for(i+=2,i2=0;;i++,i2++){
-				if(source[i]=='\0') break;
-				if(source[i]==1&&source[i+1]==(char)i3){
-					i++;
-					break;
-				}
-			}
-			if(source[i]=='\0') break;
-			continue;
-		}
-
-		if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
-			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( source[i] ) ){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-			namespaceScopes.push_back( temporary );
-
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
-			if( namespaceScopes.size() <= 0 ){
-				compiler.errorMessenger.Output(12, "End Namespace", i );
-			}
-			else{
-				namespaceScopes.pop_back();
-			}
-
-			i += 2;
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
-			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( source[i] ) ){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-			if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
-			{
-				compiler.errorMessenger.Output(64,temporary,cp );
-			}
-
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
-			importedNamespaces.clear();
-			continue;
-		}
-
-		if(source[i]==1&&source[i+1]==ESC_DECLARE){
-			for(i+=2,i2=0;;i2++,i++){
-				if(source[i]=='\n'){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-				if(source[i]=='\0') break;
-			}
-			dllProcs.Add(namespaceScopes,temporary,i);
-
-			continue;
-		}
-		if(source[i]==1&&(source[i+1]==ESC_SUB||source[i+1]==ESC_FUNCTION||source[i+1]==ESC_MACRO)){
-			char statementChar = source[i+1];
-
-			for(i2=0;;i2++,i++){
-				if(IsCommandDelimitation(source[i])){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-				if(source[i]=='\0') break;
-			}
-			userProcs.AddUserProc(namespaceScopes, importedNamespaces, temporary,i,false,NULL,false);
-
-			/*	Sub ～ End Sub
-				Function ～ End Function
-				Macro ～ End Macro
-				を飛び越す			*/
-			char endStatementChar = GetEndXXXCommand( statementChar );
-			for(i2=0;;i++,i2++){
-				if( source[i] == '\0' ) break;
-				if( source[i] == 1 && source[i+1] == endStatementChar ){
-					i++;
-					break;
-				}
-			}
-			if(source[i]=='\0') break;
-			continue;
-		}
-
-		//次の行
-		for(;;i++){
-			if(IsCommandDelimitation(source[i])) break;
-		}
-		if(source[i]=='\0') break;
-	}
-
-	////////////
-	// 特殊関数
-	////////////
-	namespaceScopes.clear();
-	importedNamespaces.clear();
-
-	compiler.globalAreaProcName = "_System_GlobalArea_" + compiler.GetModuleName();
-	sprintf(temporary,"%c%c%s()",1,ESC_SUB,compiler.globalAreaProcName.c_str());
-	userProcs.AddUserProc( namespaceScopes, importedNamespaces, temporary,0,false,NULL,false);
 }
 
Index: trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h	(revision 511)
@@ -411,11 +411,8 @@
 
 	// クラス継承
-	bool Inherits( const char *inheritNames, int nowLine );
 	bool InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine );
-	bool InheritsInterface( const CClass &inheritsClass, int nowLine );
 
 	// インターフェイス実装
 	bool Implements( const CClass &interfaceClass, const Types &actualTypeParameters, int nowLine );
-	bool Implements( const char *interfaceNames, int nowLine );
 
 	//メンバ、メソッドの追加
@@ -423,7 +420,4 @@
 	void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine );
 	void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine );
-
-	void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
-		bool isVirtual, bool isOverride, bool isAutoGeneration, char *buffer, int nowLine);
 
 	//重複チェック
@@ -593,5 +587,4 @@
 	bool Insert( CClass *pClass, int nowLine );
 	CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine);
-	virtual void CollectClassesForNameOnly( const BasicSource &source );
 
 	// vtblを一時的に生成
@@ -603,11 +596,4 @@
 	virtual void InitStaticMember();
 
-private:
-	bool MemberVar_LoopRefCheck(const CClass &objClass);
-public:
-	virtual void GetClass_recur(const char *lpszInheritsClass);
-	void LookaheadClass( const char *className );
-	bool LoopRefCheck( const CClass &objClass );
-	virtual void GetAllClassInfo();
 	virtual void Compile_System_InitializeUserTypes();
 	virtual void Compile_System_InitializeUserTypesForBaseType();
Index: trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h	(revision 511)
@@ -7,7 +7,27 @@
 {
 public:
+
+	// 名前空間を収集
 	static bool CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection );
+
+	// フルネーム識別子をシンボルに変換する
 	static Symbol FullNameToSymbol( const char *fullName );
 	static Symbol FullNameToSymbol( const std::string &fullName );
+
+	// クラスの名前情報を収集する
+	static void CollectClassesForNameOnly( const char *source, Classes &classes );
+
+	// クラスを収集する
+	static void AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
+		bool isVirtual, bool isOverride, const char *interfaceName, bool isAutoGeneration, int nowLine);
+	static bool Inherits( CClass &currentClass, const char *inheritNames, int nowLine );
+	static bool Implements( CClass &currentClass, const char *interfaceNames, int nowLine );
+	static void LookaheadClass( const char *className, Classes &classes );
+	static bool LoopRefCheck( const CClass &objClass );
+	static void CollectClasses( const char *source, Classes &classes );
+
+	// グローバルプロシージャを収集する
+	static UserProc* ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName = NULL );
+	static void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs );
 };
 
Index: trunk/ab5.0/abdev/BasicCompiler_Common/include/Procedure.h
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/include/Procedure.h	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/include/Procedure.h	(revision 511)
@@ -180,5 +180,5 @@
 public:
 
-	UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport, int id )
+	UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport )
 		: Procedure( namespaceScopes, name, kind, isCdecl )
 		, importedNamespaces( importedNamespaces )
@@ -187,4 +187,6 @@
 		, pMethod( NULL )
 		, isMacro( isMacro )
+		, secondParmNum( 0 )
+		, realSecondParmNum( 1 )
 		, isExport( isExport )
 		, isSystem( false )
@@ -193,6 +195,7 @@
 		, beginOpAddress( 0 )
 		, endOpAddress( 0 )
-		, id( id )
-	{
+	{
+		static int id_base=0;
+		id = ( id_base ++ );
 	}
 	UserProc()
@@ -204,4 +207,9 @@
 			delete pParam;
 		}
+	}
+
+	void SetReturnType( const Type &newReturnType )
+	{
+		returnType = newReturnType;
 	}
 
@@ -244,4 +252,8 @@
 		return realParams;
 	}
+	void SetRealParams( const Parameters &params )
+	{
+		realParams = params;
+	}
 	int GetRealSecondParmNum() const
 	{
@@ -396,6 +408,4 @@
 class UserProcs : public Jenga::Common::Hashmap<UserProc>
 {
-	std::vector<std::string> macroNames;
-
 	// XMLシリアライズ用
 private:
@@ -407,5 +417,4 @@
 		ar & boost::serialization::make_nvp("Hashmap_UserProcImpl",
 			boost::serialization::base_object<Jenga::Common::Hashmap<UserProc>>(*this));
-		ar & BOOST_SERIALIZATION_NVP( macroNames );
 	}
 
@@ -420,6 +429,4 @@
 
 	bool Insert( UserProc *pUserProc, int nowLine );
-
-	UserProc *AddUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName = NULL );
 
 	void EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs );
@@ -511,6 +518,4 @@
 };
 
-void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs );
-
 class ProcPointer : public Procedure
 {
Index: trunk/ab5.0/abdev/BasicCompiler_Common/include/Variable.h
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/include/Variable.h	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/include/Variable.h	(revision 511)
@@ -57,44 +57,8 @@
 
 public:
-	Variable( const string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData )
-		: Symbol( ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( name ) )
-		, type( type )
-		, isConst( isConst )
-		, isRef( isRef )
-		, isArray( false )
-		, isParameter( false)
-		, paramStrForConstructor( paramStrForConstructor )
-		, hasInitData( hasInitData )
-	{
-	}
-	Variable( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData )
-		: Symbol( namespaceScopes, name )
-		, type( type )
-		, isConst( isConst )
-		, isRef( isRef )
-		, isArray( false )
-		, isParameter( false)
-		, paramStrForConstructor( paramStrForConstructor )
-		, hasInitData( hasInitData )
-	{
-	}
-	Variable( const Variable &var )
-		: Symbol( var )
-		, type( var.type )
-		, isConst( var.isConst )
-		, isRef( var.isRef )
-		, isArray( var.isArray )
-		, subscripts( var.subscripts )
-		, isParameter( false )
-		, paramStrForConstructor( var.paramStrForConstructor )
-		, hasInitData( var.hasInitData )
-	{
-	}
-	Variable()
-	{
-	}
-	~Variable()
-	{
-	}
+	Variable( const string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData );
+	Variable( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData );
+	Variable( const Variable &var );
+	Variable();
 
 	void SetArray( const Subscripts &subscripts ){
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp	(revision 511)
@@ -12,4 +12,6 @@
 #endif
 
+using namespace ActiveBasic::Compiler;
+
 
 Interface::Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters )
@@ -167,81 +169,6 @@
 }
 
-bool CClass::Inherits( const char *inheritNames, int nowLine ){
-	int i = 0;
-	bool isInheritsClass = false;
-	while( true ){
-
-		char temporary[VN_SIZE];
-		for( int i2=0;; i++, i2++ ){
-			if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){
-				temporary[i2] = 0;
-				break;
-			}
-			temporary[i2] = inheritNames[i];
-		}
-
-		// ジェネリクス構文を分解
-		char className[VN_SIZE];
-		Jenga::Common::Strings typeParameterStrings;
-		SplitGenericClassInstance( temporary, className, typeParameterStrings );
-
-		// 型パラメータ文字列から型データを取得
-		Types actualTypeParameters;
-		BOOST_FOREACH( const std::string &typeParameterStr, typeParameterStrings )
-		{
-			Type type;
-			compiler.StringToType( typeParameterStr, type );
-			actualTypeParameters.push_back( type );
-		}
-
-		//継承元クラスを取得
-		const CClass *pInheritsClass = compiler.GetObjectModule().meta.GetClasses().Find(className);
-		if( !pInheritsClass ){
-			compiler.errorMessenger.Output(106,className,nowLine);
-			return false;
-		}
-
-		if( pInheritsClass->IsClass() ){
-			// クラスを継承する
-			isInheritsClass = true;
-
-			if( !InheritsClass( *pInheritsClass, actualTypeParameters, nowLine ) ){
-				return false;
-			}
-		}
-		else{
-			compiler.errorMessenger.Output(135,pInheritsClass->GetFullName().c_str(),nowLine);
-			return false;
-		}
-
-		if( inheritNames[i] == '\0' ){
-			break;
-		}
-		i++;
-	}
-
-	if( !isInheritsClass ){
-		// クラスを一つも継承していないとき
-		if( !InheritsClass( *compiler.GetObjectModule().meta.GetClasses().GetObjectClassPtr(), Types(), nowLine ) ){
-			return false;
-		}
-	}
-
-	return true;
-}
 bool CClass::InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine )
 {
-	//ループ継承でないかをチェック
-	if( !compiler.GetObjectModule().meta.GetClasses().LoopRefCheck(inheritsClass) )
-	{
-		compiler.errorMessenger.Output(123,inheritsClass.GetName(),nowLine);
-		return false;
-	}
-
-	if( !inheritsClass.IsReady() ){
-		//継承先が読み取られていないとき
-		compiler.GetObjectModule().meta.GetClasses().LookaheadClass(inheritsClass.GetName().c_str());
-	}
-
 	//メソッドをコピー
 	BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClass.GetDynamicMethods() ){
@@ -299,9 +226,4 @@
 	}
 
-	if( !interfaceClass.IsReady() ){
-		// インターフェイスが未解析のとき
-		compiler.GetObjectModule().meta.GetClasses().LookaheadClass( interfaceClass.GetName().c_str() );
-	}
-
 	::Interface *pDestInterface = new ::Interface( &interfaceClass, actualTypeParameters );
 
@@ -332,13 +254,28 @@
 		// Function Operator() As ITest
 
-		char temporary[1024];
-		sprintf(temporary,"%c%c%c%c()%c%c%s",
-			1, ESC_FUNCTION,
-			1, ESC_OPERATOR,
-			1, ESC_AS,
-			pDestInterface->GetFullNameWithActualGenericTypeParameters().c_str()
-		);
-
-		this->AddMethod(this,
+		char methodName[255] = { 1, ESC_OPERATOR, CALC_AS, '\0' };
+
+		//関数ハッシュへ登録
+		UserProc *pUserProc = new UserProc(
+			NamespaceScopes(),
+			NamespaceScopesCollection(),
+			methodName,
+			Procedure::Function,
+			false,
+			false,
+			false );
+		pUserProc->SetParentClass( this );
+
+		Parameters params;
+		params.push_back( new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) );
+		pUserProc->SetRealParams( params );
+
+		pUserProc->SetReturnType( Type( DEF_OBJECT, interfaceClass ) );
+		pUserProc->_paramStr = "";
+		pUserProc->Using();
+		compiler.GetObjectModule().meta.GetUserProcs().Insert( pUserProc, -1 );
+
+		LexicalAnalyzer::AddMethod(this,
+			pUserProc,
 			Prototype::Public,
 			0,
@@ -347,42 +284,10 @@
 			false,			// isVirtual
 			false,			// isOverride
+			"",
 			true,			// isAutoGeneration
-			temporary,
 			-1
 		);
 	}
 
-
-	return true;
-}
-bool CClass::Implements( const char *interfaceNames, int nowLine )
-{
-	Jenga::Common::Strings paramStrs;
-	SplitParameter( interfaceNames, paramStrs );
-	
-	BOOST_FOREACH( const std::string &paramStr, paramStrs )
-	{
-		char className[VN_SIZE];
-		Jenga::Common::Strings typeParameterStrings;
-		SplitGenericClassInstance( paramStr.c_str(), className, typeParameterStrings );
-
-		Types actualTypeParameters;
-		BOOST_FOREACH( const std::string &typeParameterStr, typeParameterStrings )
-		{
-			Type type;
-			compiler.StringToType( typeParameterStr, type );
-			actualTypeParameters.push_back( type );
-		}
-
-		//継承元クラスを取得
-		const CClass *pInterfaceClass = compiler.GetObjectModule().meta.GetClasses().Find( className );
-		if( !pInterfaceClass ){
-			compiler.errorMessenger.Output(106,paramStr.c_str(),nowLine);
-			continue;
-		}
-
-		// インターフェイスを継承する
-		Implements( *pInterfaceClass, actualTypeParameters, nowLine );
-	}
 
 	return true;
@@ -419,150 +324,4 @@
 		CreateMember( accessibility, isConst, isRef, buffer, nowLine )
 	);
-}
-
-void CClass::AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
-						 bool isVirtual, bool isOverride, bool isAutoGeneration, char *buffer, int nowLine){
-	int i,i2;
-	char temporary[VN_SIZE];
-
-	i=2;
-	for(i2=0;;i++,i2++){
-		if(buffer[i]=='('||buffer[i]=='\0'){
-			temporary[i2]=0;
-			break;
-		}
-		temporary[i2]=buffer[i];
-	}
-
-
-	//関数ハッシュへ登録
-	char interfaceName[VN_SIZE] = "";
-	UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().AddUserProc( NamespaceScopes(), NamespaceScopesCollection(), buffer,nowLine,isVirtual,pobj_c, (bStatic!=0), interfaceName );
-	if(!pUserProc) return;
-
-	if( isAutoGeneration )
-	{
-		// コード自動生成
-		pUserProc->ThisIsAutoGenerationProc();
-	}
-
-
-	////////////////////////////////////////////////////////////
-	// コンストラクタ、デストラクタの場合の処理
-	////////////////////////////////////////////////////////////
-	BOOL fConstructor=0,bDestructor=0;
-
-	if(lstrcmp(temporary,pobj_c->GetName().c_str())==0){
-		//コンストラクタの場合
-
-		//標準コンストラクタ（引数なし）
-		if(pUserProc->Params().size()==0) fConstructor=1;
-
-		//強制的にConst修飾子をつける
-		isConst = true;
-	}
-	else if(temporary[0]=='~'){
-		//デストラクタの場合はその名前が正しいかチェックを行う
-		if(lstrcmp(temporary+1,pobj_c->GetName().c_str())!=0)
-			compiler.errorMessenger.Output(117,NULL,nowLine);
-		else
-			bDestructor=1;
-	}
-	if(fConstructor||bDestructor){
-		// コンストラクタ、デストラクタのアクセシビリティをチェック
-
-		//強制的にConst修飾子をつける
-		isConst = true;
-	}
-
-	if( fConstructor == 1 )
-		pobj_c->SetConstructorMemberSubIndex( (int)pobj_c->GetDynamicMethods().size() );
-	else if( bDestructor )
-		pobj_c->SetDestructorMemberSubIndex( (int)pobj_c->GetDynamicMethods().size() );
-
-
-
-	//////////////////
-	// 重複チェック
-	//////////////////
-
-	if(pobj_c->DupliCheckMember(temporary)){
-		compiler.errorMessenger.Output(15,temporary,nowLine);
-		return;
-	}
-
-	//メソッド
-	BOOST_FOREACH( const CMethod *pMethod, pobj_c->GetDynamicMethods() )
-	{
-		//基底クラスと重複する場合はオーバーライドを行う
-		if( pMethod->GetInheritsClassPtr() ) continue;
-
-		if( pMethod->GetUserProc().IsEqualForOverride( pobj_c->GetSuperClassActualTypeParameters(), pUserProc ) )
-		{
-			//関数名、パラメータ、戻り値が合致したとき
-			compiler.errorMessenger.Output(15,pUserProc->GetName().c_str(),nowLine);
-			return;
-		}
-	}
-
-	//仮想関数の場合
-	if( isAbstract ) pUserProc->CompleteCompile();
-
-	// メソッドのオーバーライド
-	CMethod *pMethodForOverride = pobj_c->GetDynamicMethods().FindForOverride( pobj_c->GetSuperClassActualTypeParameters(), pUserProc );
-	if( pMethodForOverride )
-	{
-		pMethodForOverride->Override( pUserProc, accessibility, isOverride );
-		pUserProc->SetMethod( pMethodForOverride );
-		return;
-	}
-	else
-	{
-		// インターフェイス メソッドのオーバーライド
-		BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() )
-		{
-			if( interfaceName[0] )
-			{
-				if( pInterface->GetClass().GetName() != interfaceName )
-				{
-					// 指定されたインターフェイス名と整合しないとき
-					continue;
-				}
-			}
-
-			if( !pInterface->GetClass().IsReady() ){
-				// インターフェイスが未解析のとき
-				compiler.GetObjectModule().meta.GetClasses().LookaheadClass( pInterface->GetClass().GetName().c_str() );
-			}
-
-			CMethod *pMethodForOverride = pInterface->GetDynamicMethods().FindForOverride( pInterface->GetActualTypeParameters(), pUserProc );
-			if( pMethodForOverride )
-			{
-				pMethodForOverride->Override( pUserProc, accessibility, isOverride );
-				pUserProc->SetMethod( pMethodForOverride );
-				return;
-			}
-		}
-	}
-
-	if( interfaceName[0] )
-	{
-		compiler.errorMessenger.Output(139,interfaceName,nowLine);
-	}
-
-	if( isVirtual ){
-		pobj_c->AddVtblNum( 1 );
-	}
-
-	if( isOverride ){
-		compiler.errorMessenger.Output(12,"Override",nowLine);
-	}
-
-	if(bStatic){
-		pobj_c->GetStaticMethods().AddStatic( pUserProc, accessibility );
-	}
-	else{
-		pobj_c->GetDynamicMethods().Add(pUserProc, accessibility, isConst, isAbstract, isVirtual);
-	}
 }
 
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/Class_Collect.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/Class_Collect.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/Class_Collect.cpp	(revision 511)
@@ -11,4 +11,6 @@
 #include "../../compiler_x86/opcode.h"
 #endif
+
+using namespace ActiveBasic::Compiler;
 
 
@@ -70,146 +72,5 @@
 CLoopRefCheck *pobj_LoopRefCheck;
 
-
-void Classes::CollectClassesForNameOnly( const BasicSource &source )
-{
-	int i, i2;
-	char temporary[VN_SIZE];
-
-	// 名前空間管理
-	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
-	namespaceScopes.clear();
-
-	// Importsされた名前空間の管理
-	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
-	importedNamespaces.clear();
-
-	for(i=0;;i++){
-		if(source[i]=='\0') break;
-
-		if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
-			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( source[i] ) ){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-			namespaceScopes.push_back( temporary );
-
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
-			if( namespaceScopes.size() <= 0 ){
-				compiler.errorMessenger.Output(12, "End Namespace", i );
-			}
-			else{
-				namespaceScopes.pop_back();
-			}
-
-			i += 2;
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
-			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( source[i] ) ){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-			if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
-			{
-				compiler.errorMessenger.Output(64,temporary,i );
-			}
-
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
-			importedNamespaces.clear();
-			continue;
-		}
-
-		if(source[i]==1&&(
-			source[i+1]==ESC_CLASS||
-			source[i+1]==ESC_TYPE||
-			source[i+1]==ESC_INTERFACE
-			))
-		{
-			int nowLine = i;
-			i += 2;
-
-			Type blittableType;
-			if(memicmp(source.GetBuffer()+i,"Align(",6)==0){
-				//アラインメント修飾子
-				i+=6;
-				i=JumpStringInPare(source.GetBuffer(),i)+1;
-			}
-			else if( memicmp( source.GetBuffer() + i, "Blittable(", 10 ) == 0 ){
-				// Blittable修飾子
-				i+=10;
-				i+=GetStringInPare_RemovePare(temporary,source.GetBuffer()+i)+1;
-				compiler.StringToType( temporary, blittableType );
-			}
-
-			bool isEnum = false;
-			bool isDelegate = false;
-			if( source[i] == 1 && source[i+1] == ESC_ENUM ){
-				// 列挙型の場合
-				isEnum = true;
-
-				i += 2;
-			}
-			else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )
-			{
-				// デリゲートの場合
-				isDelegate = true;
-
-				i += 2;
-			}
-
-			for(i2=0;;i++,i2++){
-				if(!IsVariableChar(source[i])){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-
-			//クラスを追加
-			CClass *pClass = this->Add(namespaceScopes, importedNamespaces, temporary,nowLine);
-			if( pClass ){
-				if( source[nowLine+1] == ESC_CLASS ){
-					if( isEnum )
-					{
-						pClass->SetClassType( CClass::Enum );
-					}
-					else if( isDelegate )
-					{
-						pClass->SetClassType( CClass::Delegate );
-					}
-					else{
-						pClass->SetClassType( CClass::Class );
-					}
-				}
-				else if( source[nowLine+1] == ESC_INTERFACE ){
-					pClass->SetClassType( CClass::Interface );
-				}
-				else{
-					pClass->SetClassType( CClass::Structure );
-				}
-			}
-
-			// Blittable型の場合
-			if( !blittableType.IsNull() ){
-				pClass->SetBlittableType( blittableType );
-
-				// Blittable型として登録
-				compiler.GetObjectModule().meta.GetBlittableTypes().push_back( BlittableType( blittableType, pClass ) );
-			}
-		}
-	}
-}
-
-bool Classes::MemberVar_LoopRefCheck(const CClass &objClass){
+bool MemberVar_LoopRefCheck(const CClass &objClass){
 	if( objClass.HasSuperClass() )
 	{
@@ -246,5 +107,274 @@
 }
 
-void Classes::GetClass_recur(const char *lpszInheritsClass){
+void LexicalAnalyzer::AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
+	bool isVirtual, bool isOverride, const char *interfaceName, bool isAutoGeneration, int nowLine)
+{
+	if( isAutoGeneration )
+	{
+		// コード自動生成
+		pUserProc->ThisIsAutoGenerationProc();
+	}
+
+
+	////////////////////////////////////////////////////////////
+	// コンストラクタ、デストラクタの場合の処理
+	////////////////////////////////////////////////////////////
+	BOOL fConstructor=0,bDestructor=0;
+
+	if( pUserProc->GetName() == pobj_c->GetName() ){
+		//コンストラクタの場合
+
+		//標準コンストラクタ（引数なし）
+		if(pUserProc->Params().size()==0) fConstructor=1;
+
+		//強制的にConst修飾子をつける
+		isConst = true;
+	}
+	else if(pUserProc->GetName()[0]=='~'){
+		//デストラクタの場合はその名前が正しいかチェックを行う
+		if(lstrcmp(pUserProc->GetName().c_str()+1,pobj_c->GetName().c_str())!=0)
+			compiler.errorMessenger.Output(117,NULL,nowLine);
+		else
+			bDestructor=1;
+	}
+	if(fConstructor||bDestructor){
+		// コンストラクタ、デストラクタのアクセシビリティをチェック
+
+		//強制的にConst修飾子をつける
+		isConst = true;
+	}
+
+	if( fConstructor == 1 )
+		pobj_c->SetConstructorMemberSubIndex( (int)pobj_c->GetDynamicMethods().size() );
+	else if( bDestructor )
+		pobj_c->SetDestructorMemberSubIndex( (int)pobj_c->GetDynamicMethods().size() );
+
+
+
+	//////////////////
+	// 重複チェック
+	//////////////////
+
+	if(pobj_c->DupliCheckMember( pUserProc->GetName().c_str() )){
+		compiler.errorMessenger.Output(15,pUserProc->GetName(),nowLine);
+		return;
+	}
+
+	//メソッド
+	BOOST_FOREACH( const CMethod *pMethod, pobj_c->GetDynamicMethods() )
+	{
+		//基底クラスと重複する場合はオーバーライドを行う
+		if( pMethod->GetInheritsClassPtr() ) continue;
+
+		if( pMethod->GetUserProc().IsEqualForOverride( pobj_c->GetSuperClassActualTypeParameters(), pUserProc ) )
+		{
+			//関数名、パラメータ、戻り値が合致したとき
+			compiler.errorMessenger.Output(15,pUserProc->GetName().c_str(),nowLine);
+			return;
+		}
+	}
+
+	//仮想関数の場合
+	if( isAbstract ) pUserProc->CompleteCompile();
+
+	// メソッドのオーバーライド
+	CMethod *pMethodForOverride = pobj_c->GetDynamicMethods().FindForOverride( pobj_c->GetSuperClassActualTypeParameters(), pUserProc );
+	if( pMethodForOverride )
+	{
+		pMethodForOverride->Override( pUserProc, accessibility, isOverride );
+		pUserProc->SetMethod( pMethodForOverride );
+		return;
+	}
+	else
+	{
+		// インターフェイス メソッドのオーバーライド
+		BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() )
+		{
+			if( interfaceName[0] )
+			{
+				if( pInterface->GetClass().GetName() != interfaceName )
+				{
+					// 指定されたインターフェイス名と整合しないとき
+					continue;
+				}
+			}
+
+			if( !pInterface->GetClass().IsReady() ){
+				// インターフェイスが未解析のとき
+				LexicalAnalyzer::LookaheadClass(
+					pInterface->GetClass().GetName().c_str(),
+					compiler.GetObjectModule().meta.GetClasses()
+				);
+			}
+
+			CMethod *pMethodForOverride = pInterface->GetDynamicMethods().FindForOverride( pInterface->GetActualTypeParameters(), pUserProc );
+			if( pMethodForOverride )
+			{
+				pMethodForOverride->Override( pUserProc, accessibility, isOverride );
+				pUserProc->SetMethod( pMethodForOverride );
+				return;
+			}
+		}
+	}
+
+	if( interfaceName[0] )
+	{
+		compiler.errorMessenger.Output(139,interfaceName,nowLine);
+	}
+
+	if( isVirtual ){
+		pobj_c->AddVtblNum( 1 );
+	}
+
+	if( isOverride ){
+		compiler.errorMessenger.Output(12,"Override",nowLine);
+	}
+
+	if(bStatic){
+		pobj_c->GetStaticMethods().AddStatic( pUserProc, accessibility );
+	}
+	else{
+		pobj_c->GetDynamicMethods().Add(pUserProc, accessibility, isConst, isAbstract, isVirtual);
+	}
+}
+
+bool LexicalAnalyzer::Inherits( CClass &currentClass, const char *inheritNames, int nowLine ){
+	int i = 0;
+	bool isInheritsClass = false;
+	while( true ){
+
+		char temporary[VN_SIZE];
+		for( int i2=0;; i++, i2++ ){
+			if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){
+				temporary[i2] = 0;
+				break;
+			}
+			temporary[i2] = inheritNames[i];
+		}
+
+		// ジェネリクス構文を分解
+		char className[VN_SIZE];
+		Jenga::Common::Strings typeParameterStrings;
+		SplitGenericClassInstance( temporary, className, typeParameterStrings );
+
+		// 型パラメータ文字列から型データを取得
+		Types actualTypeParameters;
+		BOOST_FOREACH( const std::string &typeParameterStr, typeParameterStrings )
+		{
+			Type type;
+			compiler.StringToType( typeParameterStr, type );
+			actualTypeParameters.push_back( type );
+		}
+
+		//継承元クラスを取得
+		const CClass *pInheritsClass = compiler.GetObjectModule().meta.GetClasses().Find(className);
+		if( !pInheritsClass ){
+			compiler.errorMessenger.Output(106,className,nowLine);
+			return false;
+		}
+
+		if( pInheritsClass->IsClass() ){
+			// クラスを継承する
+			isInheritsClass = true;
+
+			//ループ継承でないかをチェック
+			if( !LexicalAnalyzer::LoopRefCheck(*pInheritsClass) )
+			{
+				compiler.errorMessenger.Output(123,pInheritsClass->GetName(),nowLine);
+				return false;
+			}
+
+			if( !pInheritsClass->IsReady() ){
+				//継承先が読み取られていないとき
+				LexicalAnalyzer::LookaheadClass(
+					pInheritsClass->GetName().c_str(),
+					compiler.GetObjectModule().meta.GetClasses()
+				);
+			}
+
+			if( !currentClass.InheritsClass( *pInheritsClass, actualTypeParameters, nowLine ) ){
+				return false;
+			}
+		}
+		else{
+			compiler.errorMessenger.Output(135,pInheritsClass->GetFullName().c_str(),nowLine);
+			return false;
+		}
+
+		if( inheritNames[i] == '\0' ){
+			break;
+		}
+		i++;
+	}
+
+	if( !isInheritsClass ){
+		const CClass *pObjectClass = compiler.GetObjectModule().meta.GetClasses().GetObjectClassPtr();
+		//ループ継承でないかをチェック
+		if( !LexicalAnalyzer::LoopRefCheck( *pObjectClass ) )
+		{
+			compiler.errorMessenger.Output(123,pObjectClass->GetName(),nowLine);
+			return false;
+		}
+
+		if( !pObjectClass->IsReady() ){
+			//継承先が読み取られていないとき
+			LexicalAnalyzer::LookaheadClass(
+				pObjectClass->GetName().c_str(),
+				compiler.GetObjectModule().meta.GetClasses()
+			);
+		}
+
+		// クラスを一つも継承していないとき
+		if( !currentClass.InheritsClass( *pObjectClass, Types(), nowLine ) ){
+			return false;
+		}
+	}
+
+	return true;
+}
+
+bool LexicalAnalyzer::Implements( CClass &currentClass, const char *interfaceNames, int nowLine )
+{
+	Jenga::Common::Strings paramStrs;
+	SplitParameter( interfaceNames, paramStrs );
+	
+	BOOST_FOREACH( const std::string &paramStr, paramStrs )
+	{
+		char className[VN_SIZE];
+		Jenga::Common::Strings typeParameterStrings;
+		SplitGenericClassInstance( paramStr.c_str(), className, typeParameterStrings );
+
+		Types actualTypeParameters;
+		BOOST_FOREACH( const std::string &typeParameterStr, typeParameterStrings )
+		{
+			Type type;
+			compiler.StringToType( typeParameterStr, type );
+			actualTypeParameters.push_back( type );
+		}
+
+		//継承元クラスを取得
+		const CClass *pInterfaceClass = compiler.GetObjectModule().meta.GetClasses().Find( className );
+		if( !pInterfaceClass ){
+			compiler.errorMessenger.Output(106,paramStr.c_str(),nowLine);
+			continue;
+		}
+
+		if( !pInterfaceClass->IsReady() ){
+			// インターフェイスが未解析のとき
+			LexicalAnalyzer::LookaheadClass(
+				pInterfaceClass->GetName().c_str(),
+				compiler.GetObjectModule().meta.GetClasses()
+			);
+		}
+
+		// インターフェイスを継承する
+		currentClass.Implements( *pInterfaceClass, actualTypeParameters, nowLine );
+	}
+
+	return true;
+}
+
+void GetClass_recur( const char *lpszInheritsClass, Classes &classes )
+{
 	extern char *basbuf;
 	int i,i2,i3,sub_address,top_pos;
@@ -331,5 +461,5 @@
 			SplitGenericClassInstance( temporary, className, typeParameters, true, &typeParameterBaseClassNames );
 
-			CClass *pobj_c = const_cast<CClass *>( this->Find(namespaceScopes, className) );
+			CClass *pobj_c = const_cast<CClass *>( classes.Find(namespaceScopes, className) );
 			if(!pobj_c) continue;
 
@@ -352,5 +482,5 @@
 			for( i2=0; i2<static_cast<int>(typeParameters.size()); i2++ )
 			{
-				Type baseType( DEF_OBJECT, *GetObjectClassPtr() );
+				Type baseType( DEF_OBJECT, *classes.GetObjectClassPtr() );
 				if( typeParameterBaseClassNames[i2].size() )
 				{
@@ -398,8 +528,14 @@
 
 				//継承元クラスを取得
-				const Classes &classes = *this;
 				const CClass *pInheritsClass = classes.Find(temporary);
 				if( !pInheritsClass ){
 					compiler.errorMessenger.Output(106,temporary,i);
+					goto Interface_InheritsError;
+				}
+
+				//ループ継承でないかをチェック
+				if( !LexicalAnalyzer::LoopRefCheck( *pInheritsClass ) )
+				{
+					compiler.errorMessenger.Output(123,pInheritsClass->GetName(),i);
 					goto Interface_InheritsError;
 				}
@@ -469,16 +605,25 @@
 				}
 
-				//メンバ関数を追加
-				pobj_c->AddMethod(pobj_c,
-					Prototype::Public,	//Publicアクセス権
-					0,					// bStatic
-					false,				// isConst
-					true,				// isAbstract
-					true,				// isVirtual
-					false,				// isOverride
-					false,				// isAutoGeneration
-					temporary,
-					sub_address
-					);
+				//関数ハッシュへ登録
+				char interfaceName[VN_SIZE] = "";
+				UserProc *pUserProc = LexicalAnalyzer::ParseUserProc( NamespaceScopes(), NamespaceScopesCollection(), temporary,sub_address,true,pobj_c, false, interfaceName );
+				if( pUserProc )
+				{
+					compiler.GetObjectModule().meta.GetUserProcs().Insert( pUserProc, i );
+
+					//メンバ関数を追加
+					LexicalAnalyzer::AddMethod(pobj_c,
+						pUserProc,
+						Prototype::Public,	//Publicアクセス権
+						0,					// bStatic
+						false,				// isConst
+						true,				// isAbstract
+						true,				// isVirtual
+						false,				// isOverride
+						interfaceName,
+						false,				// isAutoGeneration
+						sub_address
+						);
+				}
 			}
 		}
@@ -540,5 +685,5 @@
 			SplitGenericClassInstance( temporary, className, typeParameters, true, &typeParameterBaseClassNames );
 
-			CClass *pobj_c =  const_cast<CClass *>( this->Find(namespaceScopes, className) );
+			CClass *pobj_c =  const_cast<CClass *>( classes.Find(namespaceScopes, className) );
 			if(!pobj_c) continue;
 
@@ -552,4 +697,9 @@
 			}
 
+			if( lstrcmp(className,"Control")==0)
+			{
+				int test=0;
+			}
+
 			if(pobj_c->IsReady()){
 				//既に先読みされているとき
@@ -562,5 +712,5 @@
 			for( i2=0; i2<static_cast<int>(typeParameters.size()); i2++ )
 			{
-				Type baseType( DEF_OBJECT, *GetObjectClassPtr() );
+				Type baseType( DEF_OBJECT, *classes.GetObjectClassPtr() );
 				if( typeParameterBaseClassNames[i2].size() )
 				{
@@ -624,5 +774,5 @@
 					lstrcpy( temporary, "Object" );
 				}
-				pobj_c->Inherits( temporary, i );
+				LexicalAnalyzer::Inherits( *pobj_c, temporary, i );
 
 				if( basbuf[i+1] == 1 && basbuf[i+2] == ESC_IMPLEMENTS )
@@ -632,5 +782,5 @@
 					GetCommandToken( temporary, basbuf, i );
 
-					pobj_c->Implements( temporary, i );
+					LexicalAnalyzer::Implements( *pobj_c, temporary, i );
 				}
 			}
@@ -761,5 +911,5 @@
 							if( !pobj_c->GetDynamicMembers().back()->GetType().GetClass().IsReady() ){
 								//参照先が読み取られていないとき
-								GetClass_recur(pobj_c->GetDynamicMembers().back()->GetType().GetClass().GetName().c_str());
+								GetClass_recur( pobj_c->GetDynamicMembers().back()->GetType().GetClass().GetName().c_str(), classes );
 							}
 						}
@@ -779,16 +929,25 @@
 				}
 				else{
-					//メソッドを追加
-					cp=i;	//エラー用
-					pobj_c->AddMethod(pobj_c,
-						accessibility,
-						bStatic,
-						isConst,
-						isAbstract,
-						isVirtual,
-						isOverride,
-						false,
-						temporary,
-						sub_address);
+					//関数ハッシュへ登録
+					char interfaceName[VN_SIZE] = "";
+					UserProc *pUserProc = LexicalAnalyzer::ParseUserProc( NamespaceScopes(), NamespaceScopesCollection(), temporary,sub_address,isVirtual,pobj_c, (bStatic!=0), interfaceName );
+					if( pUserProc )
+					{
+						compiler.GetObjectModule().meta.GetUserProcs().Insert( pUserProc, i );
+
+						//メソッドを追加
+						cp=i;	//エラー用
+						LexicalAnalyzer::AddMethod(pobj_c,
+							pUserProc,
+							accessibility,
+							bStatic,
+							isConst,
+							isAbstract,
+							isVirtual,
+							isOverride,
+							interfaceName,
+							false,
+							sub_address);
+					}
 
 					if( isAbstract ) continue;
@@ -831,12 +990,12 @@
 }
 
-void Classes::LookaheadClass( const char *className )
+void LexicalAnalyzer::LookaheadClass( const char *className, Classes &classes )
 {
 	pobj_LoopRefCheck->add( className );
-	compiler.GetObjectModule().meta.GetClasses().GetClass_recur( className );
+	GetClass_recur( className, classes );
 	pobj_LoopRefCheck->del( className );
 }
 
-bool Classes::LoopRefCheck( const CClass &objClass )
+bool LexicalAnalyzer::LoopRefCheck( const CClass &objClass )
 {
 	if( pobj_LoopRefCheck->check( objClass ) )
@@ -848,10 +1007,10 @@
 }
 
-void Classes::GetAllClassInfo(void){
+void LexicalAnalyzer::CollectClasses( const char *source, Classes &classes ){
 	//ループ継承チェック用のクラス
 	pobj_LoopRefCheck=new CLoopRefCheck();
 
 	//クラスを取得
-	GetClass_recur(0);
+	GetClass_recur( 0, classes );
 
 	delete pobj_LoopRefCheck;
@@ -859,4 +1018,4 @@
 
 	// イテレータの準備
-	this->Iterator_Init();
+	classes.Iterator_Init();
 }
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp	(revision 511)
@@ -67,2 +67,456 @@
 	return FullNameToSymbol( fullName.c_str() );
 }
+
+void LexicalAnalyzer::CollectClassesForNameOnly( const char *source, Classes &classes )
+{
+	int i, i2;
+	char temporary[VN_SIZE];
+
+	// 名前空間管理
+	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
+	namespaceScopes.clear();
+
+	// Importsされた名前空間の管理
+	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
+	importedNamespaces.clear();
+
+	for(i=0;;i++){
+		if(source[i]=='\0') break;
+
+		if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
+			for(i+=2,i2=0;;i2++,i++){
+				if( IsCommandDelimitation( source[i] ) ){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+			}
+			namespaceScopes.push_back( temporary );
+
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
+			if( namespaceScopes.size() <= 0 ){
+				compiler.errorMessenger.Output(12, "End Namespace", i );
+			}
+			else{
+				namespaceScopes.pop_back();
+			}
+
+			i += 2;
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
+			for(i+=2,i2=0;;i2++,i++){
+				if( IsCommandDelimitation( source[i] ) ){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+			}
+			if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
+			{
+				compiler.errorMessenger.Output(64,temporary,i );
+			}
+
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
+			importedNamespaces.clear();
+			continue;
+		}
+
+		if(source[i]==1&&(
+			source[i+1]==ESC_CLASS||
+			source[i+1]==ESC_TYPE||
+			source[i+1]==ESC_INTERFACE
+			))
+		{
+			int nowLine = i;
+			i += 2;
+
+			Type blittableType;
+			if(memicmp(source+i,"Align(",6)==0){
+				//アラインメント修飾子
+				i+=6;
+				i=JumpStringInPare(source,i)+1;
+			}
+			else if( memicmp( source + i, "Blittable(", 10 ) == 0 ){
+				// Blittable修飾子
+				i+=10;
+				i+=GetStringInPare_RemovePare(temporary,source+i)+1;
+				compiler.StringToType( temporary, blittableType );
+			}
+
+			bool isEnum = false;
+			bool isDelegate = false;
+			if( source[i] == 1 && source[i+1] == ESC_ENUM ){
+				// 列挙型の場合
+				isEnum = true;
+
+				i += 2;
+			}
+			else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )
+			{
+				// デリゲートの場合
+				isDelegate = true;
+
+				i += 2;
+			}
+
+			for(i2=0;;i++,i2++){
+				if(!IsVariableChar(source[i])){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+			}
+
+			//クラスを追加
+			CClass *pClass = classes.Add(namespaceScopes, importedNamespaces, temporary,nowLine);
+			if( pClass ){
+				if( source[nowLine+1] == ESC_CLASS ){
+					if( isEnum )
+					{
+						pClass->SetClassType( CClass::Enum );
+					}
+					else if( isDelegate )
+					{
+						pClass->SetClassType( CClass::Delegate );
+					}
+					else{
+						pClass->SetClassType( CClass::Class );
+					}
+				}
+				else if( source[nowLine+1] == ESC_INTERFACE ){
+					pClass->SetClassType( CClass::Interface );
+				}
+				else{
+					pClass->SetClassType( CClass::Structure );
+				}
+			}
+
+			// Blittable型の場合
+			if( !blittableType.IsNull() ){
+				pClass->SetBlittableType( blittableType );
+
+				// Blittable型として登録
+				compiler.GetObjectModule().meta.GetBlittableTypes().push_back( BlittableType( blittableType, pClass ) );
+			}
+		}
+	}
+}
+
+UserProc* LexicalAnalyzer::ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName )
+{
+	int i2,i3;
+	char temporary[8192];
+
+	int i=1;
+
+	Procedure::Kind kind = Procedure::Sub;
+	bool isMacro = false;
+	if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
+	if(buffer[i]==ESC_MACRO){
+		isMacro = true;
+	}
+
+	i++;
+
+	bool isCdecl = false;
+	bool isExport = false;
+	while(1){
+		if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
+			isCdecl = true;
+
+			i+=2;
+		}
+		else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
+			isExport = true;
+
+			i+=2;
+		}
+		else break;
+	}
+
+	i2=0;
+	if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
+		if(!pobj_c){
+			compiler.errorMessenger.Output(126,NULL,nowLine);
+			return 0;
+		}
+
+		//オペレータの場合
+		temporary[i2++]=buffer[i++];
+		temporary[i2++]=buffer[i++];
+
+		int iCalcId;
+		if(buffer[i]=='='&&buffer[i+1]=='='){
+			iCalcId=CALC_EQUAL;
+			i3=2;
+		}
+		else if(buffer[i]=='='){
+			iCalcId=CALC_SUBSITUATION;
+			i3=1;
+		}
+		else if(buffer[i]=='('){
+			iCalcId=CALC_AS;
+			i3=0;
+		}
+		else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
+			iCalcId=CALC_ARRAY_SET;
+			i3=3;
+		}
+		else if(buffer[i]=='['&&buffer[i+1]==']'){
+			iCalcId=CALC_ARRAY_GET;
+			i3=2;
+		}
+		else{
+			iCalcId=GetCalcId(buffer+i,&i3);
+			i3++;
+		}
+		if(!iCalcId){
+			compiler.errorMessenger.Output(1,NULL,nowLine);
+			return 0;
+		}
+		temporary[i2++]=iCalcId;
+		temporary[i2]=0;
+
+		i+=i3;
+	}
+	else{
+		if(pobj_c){
+			//クラスメンバの場合、デストラクタには~が付くことを考慮
+			if(buffer[i]=='~'){
+				temporary[i2]='~';
+				i++;
+				i2++;
+			}
+		}
+
+		for(;;i++,i2++){
+			if(!IsVariableChar(buffer[i])){
+				temporary[i2]=0;
+				break;
+			}
+			temporary[i2]=buffer[i];
+		}
+
+		char parentName[VN_SIZE], memberName[VN_SIZE];
+		ReferenceKind refKind;
+		if( SplitMemberName( temporary, parentName, memberName, refKind ) )
+		{
+			if( pobj_c )
+			{
+				if( interfaceName )
+				{
+					lstrcpy( interfaceName, parentName );
+				}
+				else
+				{
+					compiler.errorMessenger.OutputFatalError();
+					return NULL;
+				}
+
+				char dummyMemberName[VN_SIZE];
+				if( SplitMemberName( memberName, parentName, dummyMemberName, refKind ) )
+				{
+					compiler.errorMessenger.Output(69,temporary,nowLine);
+					return NULL;
+				}
+			}
+			else
+			{
+				compiler.errorMessenger.Output(68,temporary,nowLine);
+				return NULL;
+			}
+
+			lstrcpy( temporary, memberName );
+		}
+	}
+
+	if( isMacro ){
+		//大文字に変換
+		CharUpper(temporary);
+	}
+
+	if(!pobj_c){
+		//クラスメンバ以外の場合のみ
+		//重複チェック
+
+		if(GetDeclareHash(temporary)){
+			compiler.errorMessenger.Output(15,temporary,nowLine);
+			return 0;
+		}
+	}
+
+	UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport );
+	pUserProc->SetParentClass( pobj_c );
+
+	// 親インターフェイスをセット
+	if( interfaceName && interfaceName[0] )
+	{
+		::Interface *pTargetInterface = NULL;
+		BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() )
+		{
+			if( pInterface->GetClass().GetName() == interfaceName )
+			{
+				pTargetInterface = pInterface;
+				break;
+			}
+		}
+		pUserProc->SetInterface( pTargetInterface );
+	}
+
+	if(isExport){
+		pUserProc->Using();
+	}
+
+	// パラメータを解析
+	// ※第1パラメータにに指定するデータの例："( s As String ) As String"
+	pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
+
+	pUserProc->_paramStr = buffer + i;
+
+	return pUserProc;
+}
+
+void LexicalAnalyzer::CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs )
+{
+	extern HANDLE hHeap;
+	int i,i2,i3;
+	char temporary[8192];
+
+	// 名前空間管理
+	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
+	namespaceScopes.clear();
+
+	// Importsされた名前空間の管理
+	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
+	importedNamespaces.clear();
+
+	i=-1;
+	while(1){
+		i++;
+
+		if(source[i]==1&&(source[i+1]==ESC_CLASS||source[i+1]==ESC_INTERFACE)){
+			/*	Class ～ End Class
+				Interface ～ End Interface
+				を飛び越す			*/
+			i3=GetEndXXXCommand(source[i+1]);
+			for(i+=2,i2=0;;i++,i2++){
+				if(source[i]=='\0') break;
+				if(source[i]==1&&source[i+1]==(char)i3){
+					i++;
+					break;
+				}
+			}
+			if(source[i]=='\0') break;
+			continue;
+		}
+
+		if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
+			for(i+=2,i2=0;;i2++,i++){
+				if( IsCommandDelimitation( source[i] ) ){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+			}
+			namespaceScopes.push_back( temporary );
+
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
+			if( namespaceScopes.size() <= 0 ){
+				compiler.errorMessenger.Output(12, "End Namespace", i );
+			}
+			else{
+				namespaceScopes.pop_back();
+			}
+
+			i += 2;
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
+			for(i+=2,i2=0;;i2++,i++){
+				if( IsCommandDelimitation( source[i] ) ){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+			}
+			if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
+			{
+				compiler.errorMessenger.Output(64,temporary,cp );
+			}
+
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
+			importedNamespaces.clear();
+			continue;
+		}
+
+		if(source[i]==1&&source[i+1]==ESC_DECLARE){
+			for(i+=2,i2=0;;i2++,i++){
+				if(source[i]=='\n'){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+				if(source[i]=='\0') break;
+			}
+			dllProcs.Add(namespaceScopes,temporary,i);
+
+			continue;
+		}
+		if(source[i]==1&&(source[i+1]==ESC_SUB||source[i+1]==ESC_FUNCTION||source[i+1]==ESC_MACRO)){
+			char statementChar = source[i+1];
+
+			for(i2=0;;i2++,i++){
+				if(IsCommandDelimitation(source[i])){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+				if(source[i]=='\0') break;
+			}
+
+			UserProc *pUserProc = ParseUserProc( namespaceScopes, importedNamespaces, temporary, i, false, NULL, false );
+			userProcs.Insert( pUserProc, i );
+
+			/*	Sub ～ End Sub
+				Function ～ End Function
+				Macro ～ End Macro
+				を飛び越す			*/
+			char endStatementChar = GetEndXXXCommand( statementChar );
+			for(i2=0;;i++,i2++){
+				if( source[i] == '\0' ) break;
+				if( source[i] == 1 && source[i+1] == endStatementChar ){
+					i++;
+					break;
+				}
+			}
+			if(source[i]=='\0') break;
+			continue;
+		}
+
+		//次の行
+		for(;;i++){
+			if(IsCommandDelimitation(source[i])) break;
+		}
+		if(source[i]=='\0') break;
+	}
+
+	////////////
+	// 特殊関数
+	////////////
+	namespaceScopes.clear();
+	importedNamespaces.clear();
+
+	compiler.globalAreaProcName = "_System_GlobalArea_" + compiler.GetModuleName();
+	sprintf(temporary,"%c%c%s()",1,ESC_SUB,compiler.globalAreaProcName.c_str());
+	UserProc *pUserProc = ParseUserProc( namespaceScopes, importedNamespaces, temporary, 0, false, NULL, false );
+	userProcs.Insert( pUserProc, i );
+}
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp	(revision 511)
@@ -52,4 +52,6 @@
 #include <Hashmap.h>
 #include <Configuration.h>
+#include <Class.h>
+#include <Procedure.h>
 #include <LexicalAnalyzer.h>
 #include <Program.h>
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp	(revision 511)
@@ -502,189 +502,5 @@
 	return true;
 }
-UserProc *UserProcs::AddUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName )
-{
-	int i2,i3;
-	char temporary[8192];
-
-	int i=1;
-
-	Procedure::Kind kind = Procedure::Sub;
-	bool isMacro = false;
-	if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
-	if(buffer[i]==ESC_MACRO){
-		isMacro = true;
-	}
-
-	i++;
-
-	bool isCdecl = false;
-	bool isExport = false;
-	while(1){
-		if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
-			isCdecl = true;
-
-			i+=2;
-		}
-		else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
-			isExport = true;
-
-			i+=2;
-		}
-		else break;
-	}
-
-	i2=0;
-	if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
-		if(!pobj_c){
-			compiler.errorMessenger.Output(126,NULL,nowLine);
-			return 0;
-		}
-
-		//オペレータの場合
-		temporary[i2++]=buffer[i++];
-		temporary[i2++]=buffer[i++];
-
-		int iCalcId;
-		if(buffer[i]=='='&&buffer[i+1]=='='){
-			iCalcId=CALC_EQUAL;
-			i3=2;
-		}
-		else if(buffer[i]=='='){
-			iCalcId=CALC_SUBSITUATION;
-			i3=1;
-		}
-		else if(buffer[i]=='('){
-			iCalcId=CALC_AS;
-			i3=0;
-		}
-		else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
-			iCalcId=CALC_ARRAY_SET;
-			i3=3;
-		}
-		else if(buffer[i]=='['&&buffer[i+1]==']'){
-			iCalcId=CALC_ARRAY_GET;
-			i3=2;
-		}
-		else{
-			iCalcId=GetCalcId(buffer+i,&i3);
-			i3++;
-		}
-		if(!iCalcId){
-			compiler.errorMessenger.Output(1,NULL,nowLine);
-			return 0;
-		}
-		temporary[i2++]=iCalcId;
-		temporary[i2]=0;
-
-		i+=i3;
-	}
-	else{
-		if(pobj_c){
-			//クラスメンバの場合、デストラクタには~が付くことを考慮
-			if(buffer[i]=='~'){
-				temporary[i2]='~';
-				i++;
-				i2++;
-			}
-		}
-
-		for(;;i++,i2++){
-			if(!IsVariableChar(buffer[i])){
-				temporary[i2]=0;
-				break;
-			}
-			temporary[i2]=buffer[i];
-		}
-
-		char parentName[VN_SIZE], memberName[VN_SIZE];
-		ReferenceKind refKind;
-		if( SplitMemberName( temporary, parentName, memberName, refKind ) )
-		{
-			if( pobj_c )
-			{
-				if( interfaceName )
-				{
-					lstrcpy( interfaceName, parentName );
-				}
-				else
-				{
-					compiler.errorMessenger.OutputFatalError();
-					return NULL;
-				}
-
-				char dummyMemberName[VN_SIZE];
-				if( SplitMemberName( memberName, parentName, dummyMemberName, refKind ) )
-				{
-					compiler.errorMessenger.Output(69,temporary,nowLine);
-					return NULL;
-				}
-			}
-			else
-			{
-				compiler.errorMessenger.Output(68,temporary,nowLine);
-				return NULL;
-			}
-
-			lstrcpy( temporary, memberName );
-		}
-	}
-
-	if( isMacro ){
-		//大文字に変換
-		CharUpper(temporary);
-
-		//マクロ関数の場合は名前リストに追加
-		macroNames.push_back( temporary );
-	}
-
-	if(!pobj_c){
-		//クラスメンバ以外の場合のみ
-		//重複チェック
-
-		if(GetDeclareHash(temporary)){
-			compiler.errorMessenger.Output(15,temporary,nowLine);
-			return 0;
-		}
-	}
-
-	// 識別ID
-	static int id_base=0;
-
-	UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport, (id_base++) );
-	pUserProc->SetParentClass( pobj_c );
-
-	// 親インターフェイスをセット
-	if( interfaceName && interfaceName[0] )
-	{
-		::Interface *pTargetInterface = NULL;
-		BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() )
-		{
-			if( pInterface->GetClass().GetName() == interfaceName )
-			{
-				pTargetInterface = pInterface;
-				break;
-			}
-		}
-		pUserProc->SetInterface( pTargetInterface );
-	}
-
-	if(isExport){
-		pUserProc->Using();
-	}
-
-	// パラメータを解析
-	// ※第1パラメータにに指定するデータの例："( s As String ) As String"
-	pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
-
-	pUserProc->_paramStr = buffer + i;
-
-	// ハッシュに追加
-	if( !Insert( pUserProc, nowLine ) )
-	{
-		return NULL;
-	}
-
-	return pUserProc;
-}
+
 void UserProcs::EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs )
 {
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/Variable.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/Variable.cpp	(revision 510)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/Variable.cpp	(revision 511)
@@ -4,25 +4,41 @@
 #include <Variable.h>
 
-/*
-TODO: 消す
-bool Variable::IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember ) const
+Variable::Variable( const string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData )
+	: Symbol( ActiveBasic::Compiler::LexicalAnalyzer::FullNameToSymbol( name ) )
+	, type( type )
+	, isConst( isConst )
+	, isRef( isRef )
+	, isArray( false )
+	, isParameter( false)
+	, paramStrForConstructor( paramStrForConstructor )
+	, hasInitData( hasInitData )
 {
-	if( GetName() == symbol.GetName()
-		&& compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), symbol.GetNamespaceScopes() ) )
-	{
-		return true;
-	}
-
-	if( isSupportStaticMember && symbol.GetNamespaceScopes().size() >= 1 )
-	{
-		// 静的メンバを考慮
-		NamespaceScopes namespaceScopes( symbol.GetNamespaceScopes() );
-		string name = namespaceScopes[namespaceScopes.size()-1] + "." + symbol.GetName();
-		namespaceScopes.pop_back();
-
-		return IsEqualSymbol( Symbol( namespaceScopes, name ), false );
-	}
-	return false;
-}*/
+}
+Variable::Variable( const NamespaceScopes &namespaceScopes, const string &name, const Type &type, bool isConst, bool isRef, const std::string &paramStrForConstructor, bool hasInitData )
+	: Symbol( namespaceScopes, name )
+	, type( type )
+	, isConst( isConst )
+	, isRef( isRef )
+	, isArray( false )
+	, isParameter( false)
+	, paramStrForConstructor( paramStrForConstructor )
+	, hasInitData( hasInitData )
+{
+}
+Variable::Variable( const Variable &var )
+	: Symbol( var )
+	, type( var.type )
+	, isConst( var.isConst )
+	, isRef( var.isRef )
+	, isArray( var.isArray )
+	, subscripts( var.subscripts )
+	, isParameter( false )
+	, paramStrForConstructor( var.paramStrForConstructor )
+	, hasInitData( var.hasInitData )
+{
+}
+Variable::Variable()
+{
+}
 
 
