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