Index: trunk/Include/Classes/ActiveBasic/Core/TypeInfo.ab
===================================================================
--- trunk/Include/Classes/ActiveBasic/Core/TypeInfo.ab	(revision 366)
+++ trunk/Include/Classes/ActiveBasic/Core/TypeInfo.ab	(revision 367)
@@ -9,4 +9,5 @@
 	strNamespace As String
 	name As String
+	fullName As String
 
 Protected
@@ -15,30 +16,10 @@
 	'interfaces As f(^^;;;
 
-	Sub TypeBaseImpl()
-		strNamespace = ""
-		name = ""
-		baseType = Nothing
-	End Sub
-
-	Sub TypeBaseImpl( strNamespace As String, name As String )
+	Sub TypeBaseImpl( strNamespace As String, name As String, fullName As String )
 		This.strNamespace = strNamespace
 		This.name = name
+		This.fullName = fullName
 		This.baseType = Nothing
 	End Sub
-
-	Sub TypeBaseImpl( strNamespace As String, name As String, baseType As System.TypeInfo )
-		This.strNamespace = strNamespace
-		This.name = name
-		This.baseType = baseType
-	End Sub
-
-	/*
-	Sub TypeBaseImpl( strNamespace As String, name As String, baseType As Type, interfaces As ... )
-		This.strNamespace = strNamespace
-		This.name = name
-		This.baseType = baseType
-		This.interfaces = interfaces
-	End Sub
-	*/
 
 	Sub ~TypeBaseImpl()
@@ -61,8 +42,5 @@
 
 	Override Function FullName() As String
-		If strNamespace.Length > 0 Then
-			Return strNamespace + "." + name
-		End If
-		Return name
+		Return fullName
 	End Function
 
@@ -117,5 +95,5 @@
 Public
 	Sub _System_TypeForValueType( name As String )
-		TypeBaseImpl( "", name )
+		TypeBaseImpl( "", name, name )
 	End Sub
 
@@ -133,12 +111,12 @@
 	numOfReference As Long
 
-	Sub _System_TypeForClass( strNamespace As String, name As String, referenceOffsets As *Long, numOfReference As Long )
-		TypeBaseImpl( strNamespace, name )
+	Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String, referenceOffsets As *Long, numOfReference As Long )
+		TypeBaseImpl( strNamespace, name, fullName )
 
 		This.referenceOffsets = referenceOffsets
 		This.numOfReference = numOfReference
 	End Sub
-	Sub _System_TypeForClass( strNamespace As String, name As String )
-		TypeBaseImpl( strNamespace, name )
+	Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String )
+		TypeBaseImpl( strNamespace, name, fullName )
 	End Sub
 	Sub ~_System_TypeForClass()
@@ -173,27 +151,27 @@
 '--------------------------------------------------------------------
 Class _System_TypeBase
-	Static pTypes As *TypeBaseImpl
+	Static types As System.Collections.Generic.Dictionary<String, TypeBaseImpl>
 
 	Static isReady = False
 
 	Static Sub Add( typeInfo As TypeBaseImpl )
-		pTypes = realloc( pTypes, ( count + 1 ) * SizeOf(*System.TypeInfo) )
-		pTypes[count] = typeInfo
-		count++
+		types.Add( typeInfo.FullName, typeInfo )
 	End Sub
 
 	Static Sub InitializeValueType()
+		types = New System.Collections.Generic.Dictionary<String, TypeBaseImpl>(8192)
+
 		' 値型の追加
-		Add( New _System_TypeForValueType( "Byte" ) )
-		Add( New _System_TypeForValueType( "SByte" ) )
-		Add( New _System_TypeForValueType( "Word" ) )
-		Add( New _System_TypeForValueType( "Integer" ) )
-		Add( New _System_TypeForValueType( "DWord" ) )
-		Add( New _System_TypeForValueType( "Long" ) )
-		Add( New _System_TypeForValueType( "QWord" ) )
-		Add( New _System_TypeForValueType( "Int64" ) )
-		Add( New _System_TypeForValueType( "Boolean" ) )
-		Add( New _System_TypeForValueType( "Single" ) )
-		Add( New _System_TypeForValueType( "Double" ) )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Byte", fullName = "Byte" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "SByte", fullName = "SByte" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Word", fullName = "Word" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Integer", fullName = "Integer" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "DWord", fullName = "DWord" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Long", fullName = "Long" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "QWord", fullName = "QWord" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Int64", fullName = "Int64" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Boolean", fullName = "Boolean" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Single", fullName = "Single" ] )
+		Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Double", fullName = "Double" ] )
 	End Sub
 
@@ -202,22 +180,29 @@
 
 		'例:
-		'Add( New _System_TypeForClass( "System", "String", [__offsets...], __numOfOffsets ) )
-		'Search( "System","String" ).SetBaseType( Search( "System","Object" ) )
-	End Sub
-
-Public
-	Static count As Long
+		'Add( New _System_TypeForClass( "System", "String", "System.String", [__offsets...], __numOfOffsets ) )
+		'...
+	End Sub
+	Static Sub InitializeUserTypesForBaseType()
+		' このメソッドの実装はコンパイラが自動生成する
+
+		'例:
+		'Search( "System.String" ).SetBaseType( Search( "System.Object" ) )
+		'...
+	End Sub
+
+Public
 	Static Sub Initialize()
-		pTypes = GC_malloc( 1 )
-		count = 0
-
 		' 値型を初期化
 		InitializeValueType()
 
-		isReady = True
 		' Class / Interface / Enum / Delegate を初期化
 		InitializeUserTypes()
 
-		selfTypeInfo = _System_TypeBase.Search( "System", "TypeInfo" ) As System.TypeInfo
+		isReady = True
+
+		' 基底クラスを登録
+		InitializeUserTypesForBaseType()
+
+		selfTypeInfo = _System_TypeBase.Search( "System.TypeInfo" ) As System.TypeInfo
 
 		_System_DebugOnly_OutputDebugString( Ex"ready dynamic meta datas!\r\n" )
@@ -228,15 +213,20 @@
 	End Sub
 
-	Static Function Search( strNamespace As LPSTR, typeName As LPSTR ) As TypeBaseImpl
-		' TODO: 名前空間に対応する
-
-		Dim i As Long
-		For i = 0 To ELM( count )
-			If pTypes[i].Name = typeName Then
-				Return pTypes[i]
-			End If
-		Next
-
-		Return Nothing
+	Static Function Search( fullName As String ) As TypeBaseImpl
+		If Object.ReferenceEquals(types, Nothing) Then
+			Return Nothing
+		End If
+
+		If isReady = False Then
+			Return Nothing
+		End If
+
+		If Object.ReferenceEquals( types.Item(fullName), Nothing ) Then
+			OutputDebugString( "TypeSearch Failed: " )
+			OutputDebugString( fullName )
+			OutputDebugString( Ex"\r\n" )
+		End If
+
+		Return types.Item(fullName)
 	End Function
 
@@ -245,5 +235,5 @@
 	End Function
 
-	Static selfTypeInfo = Nothing As System.TypeInfo
+	Static selfTypeInfo As System.TypeInfo
 
 End Class
@@ -253,5 +243,5 @@
 End Namespace
 
-Function _System_TypeBase_Search( strNamespace As LPSTR, typeName As LPSTR ) As ActiveBasic.Core.TypeBaseImpl
-	Return ActiveBasic.Core._System_TypeBase.Search( strNamespace, typeName )
+Function _System_TypeBase_Search( fullName As String ) As ActiveBasic.Core.TypeBaseImpl
+	Return ActiveBasic.Core._System_TypeBase.Search( fullName )
 End Function
