Index: BasicCompiler_Common/TypeDef.cpp
===================================================================
--- BasicCompiler_Common/TypeDef.cpp	(revision 96)
+++ BasicCompiler_Common/TypeDef.cpp	(revision 113)
@@ -2,7 +2,8 @@
 
 
-TypeDef::TypeDef( const string &newName, const string &baseName ):
-	newName( newName ),
-	baseName( baseName )
+TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName )
+	: namespaceScopes( namespaceScopes )
+	, name( name )
+	, baseName( baseName )
 {
 	if( !Type::StringToType( baseName, baseType ) ){
@@ -14,4 +15,37 @@
 }
 
+bool TypeDef::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const
+{
+	if( GetName() != name ){
+		return false;
+	}
+	return NamespaceScopes::IsSameArea( this->namespaceScopes, namespaceScopes );
+}
+bool TypeDef::IsEqualSymbol( const string &fullName ) const
+{
+	char AreaName[VN_SIZE] = "";		//オブジェクト変数
+	char NestName[VN_SIZE] = "";		//入れ子メンバ
+	bool isNest = SplitMemberName( fullName.c_str(), AreaName, NestName );
+
+	if( IsEqualSymbol( NamespaceScopes( AreaName ), NestName ) ){
+		return true;
+	}
+
+	if( isNest ){
+		// 静的メンバを考慮
+
+		char AreaName2[VN_SIZE] = "";		//オブジェクト変数
+		char NestName2[VN_SIZE] = "";		//入れ子メンバ
+		bool isNest = SplitMemberName( AreaName, AreaName2, NestName2 );
+		lstrcat( NestName2, "." );
+		lstrcat( NestName2, NestName );
+
+		return IsEqualSymbol( NamespaceScopes( AreaName2 ), NestName2 );
+	}
+
+	return false;
+}
+
+
 
 TypeDefCollection::TypeDefCollection(){
@@ -19,6 +53,6 @@
 TypeDefCollection::~TypeDefCollection(){
 }
-void TypeDefCollection::Add( const string &newName, const string &baseName ){
-	TypeDef typeDef( newName, baseName );
+void TypeDefCollection::Add( const NamespaceScopes &namespaceScopes, const string &name, const string &baseName ){
+	TypeDef typeDef( namespaceScopes, name, baseName );
 	this->push_back( typeDef );
 }
@@ -26,5 +60,5 @@
 	int max = (int)(*this).size();
 	for( int i=0; i<max; i++ ){
-		if( (*this)[i].newName == typeName ){
+		if( (*this)[i].IsEqualSymbol( typeName ) ){
 			return i;
 		}
@@ -33,5 +67,5 @@
 }
 
-void TypeDefCollection::Add( const string &expression, int nowLine ){
+void TypeDefCollection::Add( const NamespaceScopes &namespaceScopes, const string &expression, int nowLine ){
 	int i;
 	char temporary[VN_SIZE];
@@ -98,5 +132,5 @@
 	cp = nowLine;
 
-	Smoothie::Meta::typeDefs.Add(temporary,pTemp);
+	Add( namespaceScopes, temporary, pTemp );
 }
 
@@ -105,9 +139,59 @@
 	clear();
 
-	int i=-1;
+	// 名前空間管理
+	NamespaceScopes &namespaceScopes = Smoothie::Lexical::liveingNamespaceScopes;
+	namespaceScopes.clear();
+
+	// Importsされた名前空間の管理
+	NamespaceScopesCollection &importedNamespaces = Smoothie::Meta::importedNamespaces;
+	importedNamespaces.clear();
+
+	int i=-1, i2;
+	char temporary[VN_SIZE];
 	while(1){
+		extern char *basbuf;
+
 		i++;
 
-		extern char *basbuf;
+		if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
+			for(i+=2,i2=0;;i2++,i++){
+				if( IsCommandDelimitation( basbuf[i] ) ){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=basbuf[i];
+			}
+			namespaceScopes.push_back( temporary );
+
+			continue;
+		}
+		else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
+			if( namespaceScopes.size() <= 0 ){
+				SetError(12, "End Namespace", i );
+			}
+			else{
+				namespaceScopes.pop_back();
+			}
+
+			i += 2;
+			continue;
+		}
+		else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){
+			for(i+=2,i2=0;;i2++,i++){
+				if( IsCommandDelimitation( basbuf[i] ) ){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=basbuf[i];
+			}
+			importedNamespaces.Imports( temporary );
+
+			continue;
+		}
+		else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
+			importedNamespaces.clear();
+			continue;
+		}
+
 		if( basbuf[i]==1 ){
 			char temporary[VN_SIZE];
@@ -122,5 +206,5 @@
 					if(basbuf[i]=='\0') break;
 				}
-				Add(temporary,i);
+				Add( namespaceScopes, temporary, i );
 
 				continue;
@@ -136,5 +220,5 @@
 					if(basbuf[i]=='\0') break;
 				}
-				Smoothie::Meta::typeDefs.Add(temporary,"Long");
+				Add( namespaceScopes, temporary, "Long" );
 			}
 		}
