1 | ' 実装中...
|
---|
2 | '(※ まだ組み込んでいません)
|
---|
3 |
|
---|
4 |
|
---|
5 | 'Namespace System
|
---|
6 |
|
---|
7 |
|
---|
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 | ' 中間的な実装(継承専用)
|
---|
41 | Class TypeBaseImpl
|
---|
42 | Inherits TypeInfo
|
---|
43 |
|
---|
44 | strNamespace As String
|
---|
45 | name As String
|
---|
46 |
|
---|
47 | baseType As TypeInfo
|
---|
48 | 'interfaces As f(^^;;;
|
---|
49 |
|
---|
50 | Protected
|
---|
51 |
|
---|
52 | Sub TypeBaseImpl()
|
---|
53 | strNamespace = ""
|
---|
54 | name = ""
|
---|
55 | baseType = Nothing
|
---|
56 | End Sub
|
---|
57 |
|
---|
58 | Sub TypeBaseImpl( strNamespace As String, name As String )
|
---|
59 | This.strNamespace = strNamespace
|
---|
60 | This.name = name
|
---|
61 | This.baseType = Nothing
|
---|
62 | End Sub
|
---|
63 |
|
---|
64 | Sub TypeBaseImpl( strNamespace As String, name As String, baseType As TypeInfo )
|
---|
65 | This.strNamespace = strNamespace
|
---|
66 | This.name = name
|
---|
67 | This.baseType = baseType
|
---|
68 | End Sub
|
---|
69 |
|
---|
70 | /*
|
---|
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
|
---|
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
|
---|
141 | Inherits TypeBaseImpl
|
---|
142 | Public
|
---|
143 | Sub _System_TypeForValueType( name As String )
|
---|
144 | TypeInfo( "", name )
|
---|
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
|
---|
154 | Inherits TypeBaseImpl
|
---|
155 | Public
|
---|
156 | Sub _System_TypeForClass( strNamespace As String, name As String, baseType As TypeInfo )
|
---|
157 | TypeBaseImpl( strNamespace, name, baseType )
|
---|
158 | End Sub
|
---|
159 | Sub ~_System_TypeForClass()
|
---|
160 | End Sub
|
---|
161 | Override Function IsClass() As Boolean
|
---|
162 | Return True
|
---|
163 | End Function
|
---|
164 |
|
---|
165 | Sub SetBaseType( baseType As TypeInfo )
|
---|
166 | This.baseType = baseType
|
---|
167 | End Sub
|
---|
168 | End Class
|
---|
169 |
|
---|
170 | ' インターフェイスを管理するためのクラス
|
---|
171 | Class _System_TypeForInterface
|
---|
172 | Inherits TypeBaseImpl
|
---|
173 | Public
|
---|
174 | End Class
|
---|
175 |
|
---|
176 | ' 列挙体を管理するためのクラス
|
---|
177 | Class _System_TypeForEnum
|
---|
178 | Inherits TypeBaseImpl
|
---|
179 | Public
|
---|
180 | End Class
|
---|
181 |
|
---|
182 | ' デリゲートを管理するためのクラス
|
---|
183 | Class _System_TypeForDelegate
|
---|
184 | Inherits TypeBaseImpl
|
---|
185 | Public
|
---|
186 | End Class
|
---|
187 |
|
---|
188 |
|
---|
189 | '--------------------------------------------------------------------
|
---|
190 | ' プロセスに存在するすべての型を管理する(シングルトン クラス)
|
---|
191 | '--------------------------------------------------------------------
|
---|
192 | Class _System_TypeBase
|
---|
193 | pTypes As *TypeInfo
|
---|
194 | count As Long
|
---|
195 |
|
---|
196 | Sub _System_TypeBase()
|
---|
197 | pTypes = GC_malloc( 1 )
|
---|
198 | count = 0
|
---|
199 | End Sub
|
---|
200 | Sub ~_System_TypeBase()
|
---|
201 | End Sub
|
---|
202 |
|
---|
203 | Sub Add( typeInfo As TypeInfo )
|
---|
204 | pTypes = realloc( pTypes, ( count + 1 ) * SizeOf(*TypeInfo) )
|
---|
205 | pTypes[count] = typeInfo
|
---|
206 | count++
|
---|
207 | End Sub
|
---|
208 |
|
---|
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 |
|
---|
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
|
---|
237 |
|
---|
238 | Static Sub InitializeUserTypes()
|
---|
239 | ' このメソッドの実装はコンパイラが自動生成する
|
---|
240 |
|
---|
241 | #generate InitializeUserTypes
|
---|
242 |
|
---|
243 | '例:
|
---|
244 | 'obj.Add( New _System_TypeForClass( "System", "String" ) )
|
---|
245 | 'obj.Search( "String" ).SetBaseType( Search( "Object" ) )
|
---|
246 | End Sub
|
---|
247 |
|
---|
248 | Public
|
---|
249 |
|
---|
250 | Static Sub _NextPointerForGC()
|
---|
251 | ' TODO: 実装
|
---|
252 | End Sub
|
---|
253 |
|
---|
254 | Static Sub Initialize()
|
---|
255 | ' 値型を初期化
|
---|
256 | InitializeValueType()
|
---|
257 |
|
---|
258 | ' Class / Interface / Enum / Delegate を初期化
|
---|
259 | InitializeUserTypes()
|
---|
260 | End Sub
|
---|
261 | End Class
|
---|
262 |
|
---|
263 | ' End Namespace ' System
|
---|