' 実装中... '(※ まだ組み込んでいません) Class TypeInfo Public Sub TypeInfo() End Sub '---------------------------------------------------------------- ' Public properties '---------------------------------------------------------------- Abstract Function BaseType() As TypeInfo Abstract Function FullName() As String Abstract Function IsArray() As Boolean Abstract Function IsByRef() As Boolean Abstract Function IsClass() As Boolean Abstract Function IsEnum() As Boolean Abstract Function IsInterface() As Boolean Abstract Function IsPointer() As Boolean Abstract Function IsValueType() As Boolean Abstract Function Name() As String Abstract Function Namespace() As String '---------------------------------------------------------------- ' Public methods '---------------------------------------------------------------- End Class ' 中間的な実装(継承専用) Class TypeImpl Inherits TypeInfo name As String strNamespace As String baseType As TypeInfo 'interfaces As f(^^;;; Protected Sub TypeImpl() name = "" strNamespace = "" baseType = Nothing End Sub Sub TypeImpl( name As String, strNamespace As String ) This.name = name This.strNamespace = strNamespace baseType = Nothing End Sub Sub TypeImpl( name As String, strNamespace As String, baseType As Type ) TypeImpl( name, strNamespace ) This.baseType = baseType End Sub /* Sub TypeImpl( name As String, strNamespace As String, baseType As Type, interfaces As ... ) TypeImpl( name, strNamespace, baseType ) End Sub */ Public '---------------------------------------------------------------- ' Public properties '---------------------------------------------------------------- Override Function BaseType() As TypeInfo Return baseType End Function Override Function FullName() As String Return strNamespace + "." + name End Function Override Function IsArray() As Boolean Return False End Function Override Function IsByRef() As Boolean Return False End Function Override Function IsClass() As Boolean Return False End Function Override Function IsEnum() As Boolean Return False End Function Override Function IsInterface() As Boolean Return False End Function Override Function IsPointer() As Boolean Return False End Function Override Function IsValueType() As Boolean Return False End Function Override Function Name() As String Return name End Function Override Function Namespace() As String Return strNamespace End Function '---------------------------------------------------------------- ' Public methods '---------------------------------------------------------------- End Class ' 値型を管理するためのクラス Class _System_TypeForValueType Inherits TypeImpl Public Sub _System_TypeForValueType( name ) TypeInfo( name, "" ) End Sub Override Function IsValueType() As Boolean Return True End Function End Class ' クラスを管理するためのクラス Class _System_TypeForClass Inherits TypeImpl Public End Class ' インターフェイスを管理するためのクラス Class _System_TypeForInterface Inherits TypeImpl Public End Class ' 列挙体を管理するためのクラス Class _System_TypeForEnum Inherits TypeImpl Public End Class ' デリゲートを管理するためのクラス Class _System_TypeForDelegate Inherits TypeImpl Public End Class '-------------------------------------------------------------------- ' プロセスに存在するすべての型を管理する(シングルトン クラス) '-------------------------------------------------------------------- Class _System_TypeBase ppTypes As *Type count As Long Sub _System_TypeBase() ppTypes = GC_malloc( 1 ) count = 0 End Sub Sub ~_System_TypeBase() Dim i As Long For i=0 To ELM( count ) Delete ppTypes[i] Next End Sub ' シングルトン オブジェクト Static obj As _System_TypeBase Public Sub Add( pType As *Type ) ppTypes = realloc( ppTypes, ( count + 1 ) * SizeOf(*Type) ) ppTypes[count] = pType count++ End Sub Static Sub _NextPointerForGC() ' TODO: 実装 End Sub Static Sub InitializeValueType() ' 値型の追加 obj.Add( New _System_TypeForValueType( "Byte" ) ) obj.Add( New _System_TypeForValueType( "SByte" ) ) obj.Add( New _System_TypeForValueType( "Word" ) ) obj.Add( New _System_TypeForValueType( "Integer" ) ) obj.Add( New _System_TypeForValueType( "DWord" ) ) obj.Add( New _System_TypeForValueType( "Long" ) ) obj.Add( New _System_TypeForValueType( "QWord" ) ) obj.Add( New _System_TypeForValueType( "Int64" ) ) obj.Add( New _System_TypeForValueType( "Boolean" ) ) obj.Add( New _System_TypeForValueType( "Single" ) ) obj.Add( New _System_TypeForValueType( "Double" ) ) End Sub End Class