[275] | 1 | Namespace ActiveBasic
|
---|
| 2 | Namespace Core
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | ' 中間的な実装(継承専用)
|
---|
| 6 | Class TypeBaseImpl
|
---|
| 7 | Inherits System.TypeInfo
|
---|
| 8 |
|
---|
| 9 | strNamespace As String
|
---|
| 10 | name As String
|
---|
[367] | 11 | fullName As String
|
---|
[275] | 12 |
|
---|
| 13 | Protected
|
---|
| 14 |
|
---|
| 15 | baseType As System.TypeInfo
|
---|
| 16 | 'interfaces As f(^^;;;
|
---|
| 17 |
|
---|
[367] | 18 | Sub TypeBaseImpl( strNamespace As String, name As String, fullName As String )
|
---|
[275] | 19 | This.strNamespace = strNamespace
|
---|
| 20 | This.name = name
|
---|
[367] | 21 | This.fullName = fullName
|
---|
[275] | 22 | This.baseType = Nothing
|
---|
| 23 | End Sub
|
---|
| 24 |
|
---|
| 25 | Sub ~TypeBaseImpl()
|
---|
| 26 | End Sub
|
---|
| 27 |
|
---|
| 28 | Public
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | '----------------------------------------------------------------
|
---|
| 32 | ' Public properties
|
---|
| 33 | '----------------------------------------------------------------
|
---|
| 34 |
|
---|
| 35 | Override Function BaseType() As System.TypeInfo
|
---|
| 36 | Return baseType
|
---|
| 37 | End Function
|
---|
| 38 |
|
---|
| 39 | Sub SetBaseType( baseType As System.TypeInfo )
|
---|
| 40 | This.baseType = baseType
|
---|
| 41 | End Sub
|
---|
| 42 |
|
---|
| 43 | Override Function FullName() As String
|
---|
[367] | 44 | Return fullName
|
---|
[275] | 45 | End Function
|
---|
| 46 |
|
---|
| 47 | Override Function IsArray() As Boolean
|
---|
| 48 | Return False
|
---|
| 49 | End Function
|
---|
| 50 |
|
---|
| 51 | Override Function IsByRef() As Boolean
|
---|
| 52 | Return False
|
---|
| 53 | End Function
|
---|
| 54 |
|
---|
| 55 | Override Function IsClass() As Boolean
|
---|
| 56 | Return False
|
---|
| 57 | End Function
|
---|
| 58 |
|
---|
| 59 | Override Function IsEnum() As Boolean
|
---|
| 60 | Return False
|
---|
| 61 | End Function
|
---|
| 62 |
|
---|
| 63 | Override Function IsInterface() As Boolean
|
---|
| 64 | Return False
|
---|
| 65 | End Function
|
---|
| 66 |
|
---|
| 67 | Override Function IsPointer() As Boolean
|
---|
| 68 | Return False
|
---|
| 69 | End Function
|
---|
| 70 |
|
---|
| 71 | Override Function IsValueType() As Boolean
|
---|
| 72 | Return False
|
---|
| 73 | End Function
|
---|
| 74 |
|
---|
| 75 | Override Function Name() As String
|
---|
| 76 | Return name
|
---|
| 77 | End Function
|
---|
| 78 |
|
---|
| 79 | Override Function Namespace() As String
|
---|
| 80 | Return strNamespace
|
---|
| 81 | End Function
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | '----------------------------------------------------------------
|
---|
| 86 | ' Public methods
|
---|
| 87 | '----------------------------------------------------------------
|
---|
| 88 |
|
---|
| 89 | End Class
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | ' 値型を管理するためのクラス
|
---|
| 93 | Class _System_TypeForValueType
|
---|
| 94 | Inherits TypeBaseImpl
|
---|
| 95 | Public
|
---|
| 96 | Sub _System_TypeForValueType( name As String )
|
---|
[367] | 97 | TypeBaseImpl( "", name, name )
|
---|
[275] | 98 | End Sub
|
---|
| 99 |
|
---|
| 100 | Override Function IsValueType() As Boolean
|
---|
| 101 | Return True
|
---|
| 102 | End Function
|
---|
| 103 | End Class
|
---|
| 104 |
|
---|
| 105 | ' クラスを管理するためのクラス
|
---|
| 106 | Class _System_TypeForClass
|
---|
| 107 | Inherits TypeBaseImpl
|
---|
| 108 |
|
---|
| 109 | Public
|
---|
| 110 | referenceOffsets As *Long
|
---|
| 111 | numOfReference As Long
|
---|
| 112 |
|
---|
[367] | 113 | Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String, referenceOffsets As *Long, numOfReference As Long )
|
---|
| 114 | TypeBaseImpl( strNamespace, name, fullName )
|
---|
[275] | 115 |
|
---|
| 116 | This.referenceOffsets = referenceOffsets
|
---|
| 117 | This.numOfReference = numOfReference
|
---|
| 118 | End Sub
|
---|
[367] | 119 | Sub _System_TypeForClass( strNamespace As String, name As String, fullName As String )
|
---|
| 120 | TypeBaseImpl( strNamespace, name, fullName )
|
---|
[275] | 121 | End Sub
|
---|
| 122 | Sub ~_System_TypeForClass()
|
---|
| 123 | End Sub
|
---|
| 124 |
|
---|
| 125 | Override Function IsClass() As Boolean
|
---|
| 126 | Return True
|
---|
| 127 | End Function
|
---|
| 128 | End Class
|
---|
| 129 |
|
---|
| 130 | ' インターフェイスを管理するためのクラス
|
---|
| 131 | Class _System_TypeForInterface
|
---|
| 132 | Inherits TypeBaseImpl
|
---|
| 133 | Public
|
---|
| 134 | End Class
|
---|
| 135 |
|
---|
| 136 | ' 列挙体を管理するためのクラス
|
---|
| 137 | Class _System_TypeForEnum
|
---|
| 138 | Inherits TypeBaseImpl
|
---|
| 139 | Public
|
---|
| 140 | End Class
|
---|
| 141 |
|
---|
| 142 | ' デリゲートを管理するためのクラス
|
---|
| 143 | Class _System_TypeForDelegate
|
---|
| 144 | Inherits TypeBaseImpl
|
---|
| 145 | Public
|
---|
| 146 | End Class
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | '--------------------------------------------------------------------
|
---|
| 150 | ' プロセスに存在するすべての型を管理する
|
---|
| 151 | '--------------------------------------------------------------------
|
---|
| 152 | Class _System_TypeBase
|
---|
[367] | 153 | Static types As System.Collections.Generic.Dictionary<String, TypeBaseImpl>
|
---|
[299] | 154 |
|
---|
[275] | 155 | Static isReady = False
|
---|
| 156 |
|
---|
| 157 | Static Sub Add( typeInfo As TypeBaseImpl )
|
---|
[367] | 158 | types.Add( typeInfo.FullName, typeInfo )
|
---|
[275] | 159 | End Sub
|
---|
| 160 |
|
---|
| 161 | Static Sub InitializeValueType()
|
---|
[367] | 162 | types = New System.Collections.Generic.Dictionary<String, TypeBaseImpl>(8192)
|
---|
| 163 |
|
---|
[275] | 164 | ' 値型の追加
|
---|
[367] | 165 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Byte", fullName = "Byte" ] )
|
---|
| 166 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "SByte", fullName = "SByte" ] )
|
---|
| 167 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Word", fullName = "Word" ] )
|
---|
| 168 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Integer", fullName = "Integer" ] )
|
---|
| 169 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "DWord", fullName = "DWord" ] )
|
---|
| 170 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Long", fullName = "Long" ] )
|
---|
| 171 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "QWord", fullName = "QWord" ] )
|
---|
| 172 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Int64", fullName = "Int64" ] )
|
---|
| 173 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Boolean", fullName = "Boolean" ] )
|
---|
| 174 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Single", fullName = "Single" ] )
|
---|
| 175 | Add( _System_Static_New _System_TypeForValueType[ strNamespace = "", name = "Double", fullName = "Double" ] )
|
---|
[275] | 176 | End Sub
|
---|
| 177 |
|
---|
| 178 | Static Sub InitializeUserTypes()
|
---|
| 179 | ' このメソッドの実装はコンパイラが自動生成する
|
---|
| 180 |
|
---|
| 181 | '例:
|
---|
[367] | 182 | 'Add( New _System_TypeForClass( "System", "String", "System.String", [__offsets...], __numOfOffsets ) )
|
---|
| 183 | '...
|
---|
[275] | 184 | End Sub
|
---|
[367] | 185 | Static Sub InitializeUserTypesForBaseType()
|
---|
| 186 | ' このメソッドの実装はコンパイラが自動生成する
|
---|
[275] | 187 |
|
---|
[367] | 188 | '例:
|
---|
| 189 | 'Search( "System.String" ).SetBaseType( Search( "System.Object" ) )
|
---|
| 190 | '...
|
---|
| 191 | End Sub
|
---|
| 192 |
|
---|
[275] | 193 | Public
|
---|
| 194 | Static Sub Initialize()
|
---|
| 195 | ' 値型を初期化
|
---|
| 196 | InitializeValueType()
|
---|
| 197 |
|
---|
| 198 | ' Class / Interface / Enum / Delegate を初期化
|
---|
| 199 | InitializeUserTypes()
|
---|
| 200 |
|
---|
[367] | 201 | isReady = True
|
---|
[275] | 202 |
|
---|
[367] | 203 | ' 基底クラスを登録
|
---|
| 204 | InitializeUserTypesForBaseType()
|
---|
| 205 |
|
---|
| 206 | selfTypeInfo = _System_TypeBase.Search( "System.TypeInfo" ) As System.TypeInfo
|
---|
| 207 |
|
---|
[275] | 208 | _System_DebugOnly_OutputDebugString( Ex"ready dynamic meta datas!\r\n" )
|
---|
| 209 | End Sub
|
---|
| 210 |
|
---|
| 211 | Static Sub _NextPointerForGC()
|
---|
| 212 | ' TODO: 実装
|
---|
| 213 | End Sub
|
---|
| 214 |
|
---|
[367] | 215 | Static Function Search( fullName As String ) As TypeBaseImpl
|
---|
| 216 | If Object.ReferenceEquals(types, Nothing) Then
|
---|
| 217 | Return Nothing
|
---|
| 218 | End If
|
---|
[299] | 219 |
|
---|
[367] | 220 | If isReady = False Then
|
---|
| 221 | Return Nothing
|
---|
| 222 | End If
|
---|
[275] | 223 |
|
---|
[367] | 224 | If Object.ReferenceEquals( types.Item(fullName), Nothing ) Then
|
---|
| 225 | OutputDebugString( "TypeSearch Failed: " )
|
---|
| 226 | OutputDebugString( fullName )
|
---|
| 227 | OutputDebugString( Ex"\r\n" )
|
---|
| 228 | End If
|
---|
| 229 |
|
---|
| 230 | Return types.Item(fullName)
|
---|
[275] | 231 | End Function
|
---|
| 232 |
|
---|
| 233 | Static Function IsReady() As Boolean
|
---|
| 234 | Return isReady
|
---|
| 235 | End Function
|
---|
| 236 |
|
---|
[367] | 237 | Static selfTypeInfo As System.TypeInfo
|
---|
[275] | 238 |
|
---|
| 239 | End Class
|
---|
| 240 |
|
---|
| 241 |
|
---|
| 242 | End Namespace
|
---|
| 243 | End Namespace
|
---|
[299] | 244 |
|
---|
[367] | 245 | Function _System_TypeBase_Search( fullName As String ) As ActiveBasic.Core.TypeBaseImpl
|
---|
| 246 | Return ActiveBasic.Core._System_TypeBase.Search( fullName )
|
---|
[299] | 247 | End Function
|
---|