1
|
1 |
"{ Package: 'cvut:fel/cface' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Cface }"
|
|
4 |
|
|
5 |
CTypeNode subclass:#CUserDefinedTypeNode
|
|
6 |
instanceVariableNames:'type'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Cface-C AST'
|
|
10 |
!
|
|
11 |
|
|
12 |
!CUserDefinedTypeNode class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
history
|
|
15 |
|
|
16 |
"Created: / 25-10-2007 / 17:44:38 / haja"
|
|
17 |
"Created: #name / 25-10-2007 / 17:44:44 / haja"
|
|
18 |
"Created: #name: / 25-10-2007 / 17:44:44 / haja"
|
|
19 |
"Created: #id / 25-10-2007 / 17:44:44 / haja"
|
|
20 |
"Created: #id: / 25-10-2007 / 17:44:44 / haja"
|
|
21 |
"Created: #acceptVisitor: / 02-11-2007 / 10:45:15 / haja"
|
|
22 |
"Created: #name:id: / 02-11-2007 / 13:50:44 / haja"
|
|
23 |
"Deleted: #id / 02-11-2007 / 13:50:50 / haja"
|
|
24 |
"Deleted: #id: / 02-11-2007 / 13:50:50 / haja"
|
|
25 |
"Deleted: #name / 02-11-2007 / 13:50:50 / haja"
|
|
26 |
"Deleted: #name: / 02-11-2007 / 13:50:50 / haja"
|
|
27 |
"Created: #names / 02-11-2007 / 13:51:15 / haja"
|
|
28 |
"Created: #reference / 02-11-2007 / 13:51:15 / haja"
|
|
29 |
"Created: #reference: / 02-11-2007 / 13:51:15 / haja"
|
|
30 |
"Created: #names: / 02-11-2007 / 13:52:13 / haja"
|
|
31 |
"Deleted: #name:id: / 02-11-2007 / 13:52:15 / haja"
|
|
32 |
"Created: #acceptNameVisitor: / 05-11-2007 / 17:34:09 / haja"
|
|
33 |
"Deleted: #acceptNameVisitor: / 12-11-2007 / 09:46:54 / haja"
|
|
34 |
"Created: #buildTypeCheckFor:on: / 19-12-2007 / 15:24:03 / haja"
|
|
35 |
"Created: #checkFundamentalType: / 19-12-2007 / 15:26:44 / haja"
|
|
36 |
"Created: #checkDefinedType: / 19-12-2007 / 15:27:03 / haja"
|
|
37 |
"Created: #fundamentalTypes / 19-12-2007 / 15:28:32 / haja"
|
|
38 |
"Created: #buildTypeCheckForFundamentalType:on: / 19-12-2007 / 15:31:42 / haja"
|
|
39 |
"Created: #buildTypeCheckForDefinedType:on: / 19-12-2007 / 15:31:52 / haja"
|
|
40 |
"Deleted: #checkDefinedType: / 19-12-2007 / 15:34:33 / haja"
|
|
41 |
"Deleted: #checkFundamentalType: / 19-12-2007 / 15:34:35 / haja"
|
|
42 |
"Created: #buildObjectCreationOn: / 19-12-2007 / 16:34:44 / haja"
|
|
43 |
"Created: #buildObjectCreationFundamentalTypeOn: / 19-12-2007 / 16:35:39 / haja"
|
|
44 |
"Created: #buildObjectCreationOnDefinedTypeOn: / 19-12-2007 / 16:36:11 / haja"
|
|
45 |
"Created: #buildValueExtractionFor:on: / 19-12-2007 / 17:26:12 / haja"
|
|
46 |
"Created: #buildValueExtractionForDefinedType:on: / 19-12-2007 / 17:26:43 / haja"
|
|
47 |
"Created: #buildValueExtractionForFundamentalType:on: / 19-12-2007 / 17:26:57 / haja"
|
|
48 |
"Created: #buildObjectCreationFor:on: / 19-12-2007 / 17:40:07 / haja"
|
|
49 |
"Created: #buildObjectCreationFundamentalTypeFor:on: / 19-12-2007 / 17:40:14 / haja"
|
|
50 |
"Created: #buildObjectCreationOnDefinedTypeFor:on: / 19-12-2007 / 17:40:23 / haja"
|
|
51 |
"Deleted: #buildObjectCreationOnDefinedTypeFor:on: / 19-12-2007 / 17:40:46 / haja"
|
|
52 |
"Created: #buildObjectCreationDefinedTypeFor:on: / 19-12-2007 / 17:42:08 / haja"
|
|
53 |
"Deleted: #buildObjectCreationFundamentalTypeOn: / 19-12-2007 / 17:42:14 / haja"
|
|
54 |
"Deleted: #buildObjectCreationOn: / 19-12-2007 / 17:42:15 / haja"
|
|
55 |
"Deleted: #buildObjectCreationOnDefinedTypeOn: / 19-12-2007 / 17:42:16 / haja"
|
|
56 |
"Created: #buildCTypeOn: / 19-12-2007 / 18:13:30 / haja"
|
|
57 |
"Created: #buildTypeDescriptionOn: / 20-12-2007 / 12:11:52 / haja"
|
|
58 |
! !
|
|
59 |
|
|
60 |
!CUserDefinedTypeNode class methodsFor:'instance creation'!
|
|
61 |
|
|
62 |
names:aNames
|
|
63 |
|
|
64 |
| anIdNode |
|
|
65 |
|
|
66 |
anIdNode := self new.
|
|
67 |
anIdNode names:aNames.
|
|
68 |
|
|
69 |
^anIdNode
|
|
70 |
|
|
71 |
"Created: / 02-11-2007 / 13:52:13 / haja"
|
|
72 |
! !
|
|
73 |
|
|
74 |
!CUserDefinedTypeNode methodsFor:'accessing'!
|
|
75 |
|
|
76 |
type
|
|
77 |
^ type
|
|
78 |
|
|
79 |
"Created: / 12-02-2008 / 23:21:13 / janfrog"
|
|
80 |
!
|
|
81 |
|
|
82 |
type:something
|
|
83 |
type := something.
|
|
84 |
|
|
85 |
"Created: / 12-02-2008 / 23:21:13 / janfrog"
|
|
86 |
! !
|
|
87 |
|
|
88 |
!CUserDefinedTypeNode methodsFor:'builder'!
|
|
89 |
|
|
90 |
buildCTypeOn:aBuilder
|
|
91 |
|
|
92 |
((reference references:EnumNode) | (reference references:StructNode) | (reference references:UnionNode)) ifTrue:[
|
|
93 |
(reference typedef) ifFalse:[
|
|
94 |
(reference references:EnumNode) ifTrue:[ aBuilder nextPutString:'enum ' ].
|
|
95 |
(reference references:StructNode) ifTrue:[ aBuilder nextPutString:'struct ' ].
|
|
96 |
(reference references:UnionNode) ifTrue:[ aBuilder nextPutString:'union ' ].
|
|
97 |
].
|
|
98 |
].
|
|
99 |
|
|
100 |
aBuilder idNamesWith:names.
|
|
101 |
|
|
102 |
"Created: / 19-12-2007 / 18:13:30 / haja"
|
|
103 |
!
|
|
104 |
|
|
105 |
buildObjectCreationDefinedTypeFor:aVariable on:aBuilder
|
|
106 |
|
|
107 |
(reference references:EnumNode) ifTrue:[
|
|
108 |
^aBuilder buildIntegerCreationFor:aVariable.
|
|
109 |
].
|
|
110 |
|
|
111 |
^aBuilder buildPointerCreationFor:aVariable.
|
|
112 |
|
|
113 |
"Created: / 19-12-2007 / 17:42:08 / haja"
|
|
114 |
!
|
|
115 |
|
|
116 |
buildObjectCreationFor:aVariable on:aBuilder
|
|
117 |
|
|
118 |
self fundamentalTypes do:[:aType| (aType = names last) ifTrue:[ ^self buildObjectCreationFundamentalTypeFor:aVariable on:aBuilder. ] ].
|
|
119 |
|
|
120 |
^self buildObjectCreationDefinedTypeFor:aVariable on:aBuilder.
|
|
121 |
|
|
122 |
"Created: / 19-12-2007 / 16:34:44 / haja"
|
|
123 |
"Modified: / 19-12-2007 / 17:44:19 / haja"
|
|
124 |
!
|
|
125 |
|
|
126 |
buildObjectCreationFundamentalTypeFor:aVariable on:aBuilder
|
|
127 |
|
|
128 |
(((names last = 'int') | (names last = 'short') | (names last = 'long')) & ((names includes:'unsigned')not)) ifTrue:[
|
|
129 |
^aBuilder buildIntegerCreationFor:aVariable.
|
|
130 |
].
|
|
131 |
|
|
132 |
(((names last = 'int') | (names last = 'short') | (names last = 'long') | (names last = 'unsigned')) & ((names includes:'signed')not)) ifTrue:[
|
|
133 |
^aBuilder buildUnsignedIntegerCreationFor:aVariable.
|
|
134 |
].
|
|
135 |
|
|
136 |
(names last = 'char') ifTrue:[
|
|
137 |
^aBuilder buildCharacterCreationFor:aVariable.
|
|
138 |
].
|
|
139 |
|
|
140 |
(names last = 'float') ifTrue:[
|
|
141 |
^aBuilder buildFloatCreationFor:aVariable.
|
|
142 |
].
|
|
143 |
(names last = 'double') ifTrue:[
|
|
144 |
^aBuilder buildDoubleCreationFor:aVariable.
|
|
145 |
].
|
|
146 |
|
|
147 |
^aBuilder buildPointerCreationFor:aVariable.
|
|
148 |
|
|
149 |
"Created: / 19-12-2007 / 17:40:14 / haja"
|
|
150 |
!
|
|
151 |
|
|
152 |
buildTypeCheckFor:aVariable on:aBuilder
|
|
153 |
|
|
154 |
self fundamentalTypes do:[:aType| (aType = names last) ifTrue:[ ^self buildTypeCheckForFundamentalType:aVariable on:aBuilder. ] ].
|
|
155 |
|
|
156 |
^self buildTypeCheckForDefinedType:aVariable on:aBuilder.
|
|
157 |
|
|
158 |
"Created: / 19-12-2007 / 15:24:02 / haja"
|
|
159 |
!
|
|
160 |
|
|
161 |
buildTypeCheckForDefinedType:aVariable on:aBuilder
|
|
162 |
|
|
163 |
(reference references:EnumNode) ifTrue:[
|
|
164 |
^aBuilder buildIntegerCheckFor:aVariable.
|
|
165 |
].
|
|
166 |
|
|
167 |
^aBuilder buildPointerCheckFor:aVariable.
|
|
168 |
|
|
169 |
"Created: / 19-12-2007 / 15:31:52 / haja"
|
|
170 |
!
|
|
171 |
|
|
172 |
buildTypeCheckForFundamentalType:aVariable on:aBuilder
|
|
173 |
|
|
174 |
((names last = 'int') | (names last = 'short') | (names last = 'long') | (names last = 'unsigned')) ifTrue:[
|
|
175 |
^aBuilder buildIntegerCheckFor:aVariable.
|
|
176 |
].
|
|
177 |
|
|
178 |
(names last = 'char') ifTrue:[
|
|
179 |
^aBuilder buildCharacterCheckFor:aVariable.
|
|
180 |
].
|
|
181 |
|
|
182 |
(names last = 'float') ifTrue:[
|
|
183 |
^aBuilder buildFloatCheckFor:aVariable.
|
|
184 |
].
|
|
185 |
(names last = 'double') ifTrue:[
|
|
186 |
^aBuilder buildDoubleCheckFor:aVariable.
|
|
187 |
].
|
|
188 |
|
|
189 |
^aBuilder buildPointerCheckFor:aVariable.
|
|
190 |
|
|
191 |
"Created: / 19-12-2007 / 15:31:42 / haja"
|
|
192 |
!
|
|
193 |
|
|
194 |
buildTypeDescriptionOn:aBuilder
|
|
195 |
|
|
196 |
(reference references:Cface::EnumNode) ifTrue:[
|
|
197 |
aBuilder nextPutString:'enumeration '.
|
|
198 |
].
|
|
199 |
(reference references:Cface::StructNode) ifTrue:[
|
|
200 |
aBuilder nextPutString:'structure '.
|
|
201 |
].
|
|
202 |
(reference references:Cface::UnionNode) ifTrue:[
|
|
203 |
aBuilder nextPutString:'union '.
|
|
204 |
].
|
|
205 |
|
|
206 |
names do:[:aName| aBuilder nextPutString:aName asString,' ' ].
|
|
207 |
|
|
208 |
"Created: / 20-12-2007 / 12:11:52 / haja"
|
|
209 |
!
|
|
210 |
|
|
211 |
buildValueExtractionFor:aVariable on:aBuilder
|
|
212 |
|
|
213 |
self fundamentalTypes do:[:aType| (aType = names last) ifTrue:[ ^self buildValueExtractionForFundamentalType:aVariable on:aBuilder. ] ].
|
|
214 |
|
|
215 |
^self buildValueExtractionForDefinedType:aVariable on:aBuilder.
|
|
216 |
|
|
217 |
"Created: / 19-12-2007 / 17:26:12 / haja"
|
|
218 |
!
|
|
219 |
|
|
220 |
buildValueExtractionForDefinedType:aVariable on:aBuilder
|
|
221 |
|
|
222 |
(reference references:EnumNode) ifTrue:[
|
|
223 |
^aBuilder buildIntegerValueExtractionFor:aVariable.
|
|
224 |
].
|
|
225 |
|
|
226 |
^aBuilder buildPointerValueExtractionFor:aVariable.
|
|
227 |
|
|
228 |
"Created: / 19-12-2007 / 17:26:43 / haja"
|
|
229 |
!
|
|
230 |
|
|
231 |
buildValueExtractionForFundamentalType:aVariable on:aBuilder
|
|
232 |
|
|
233 |
(((names last = 'int') | (names last = 'short') | (names last = 'long')) & ((names includes:'unsigned')not)) ifTrue:[
|
|
234 |
^aBuilder buildIntegerValueExtractionFor:aVariable.
|
|
235 |
].
|
|
236 |
|
|
237 |
(((names last = 'int') | (names last = 'short') | (names last = 'long') | (names last = 'unsigned')) & ((names includes:'signed')not)) ifTrue:[
|
|
238 |
^aBuilder buildUnsignedIntegerValueExtractionFor:aVariable.
|
|
239 |
].
|
|
240 |
|
|
241 |
(names last = 'char') ifTrue:[
|
|
242 |
^aBuilder buildCharacterValueExtractionFor:aVariable.
|
|
243 |
].
|
|
244 |
|
|
245 |
(names last = 'float') ifTrue:[
|
|
246 |
^aBuilder buildFloatValueExtractionFor:aVariable.
|
|
247 |
].
|
|
248 |
(names last = 'double') ifTrue:[
|
|
249 |
^aBuilder buildDoubleValueExtractionFor:aVariable.
|
|
250 |
].
|
|
251 |
|
|
252 |
^aBuilder buildPointerValueExtractionFor:aVariable.
|
|
253 |
|
|
254 |
"Created: / 19-12-2007 / 17:26:57 / haja"
|
|
255 |
! !
|
|
256 |
|
|
257 |
!CUserDefinedTypeNode methodsFor:'converting'!
|
|
258 |
|
|
259 |
resolved
|
|
260 |
type
|
|
261 |
ifNil:[ self error:'User defined type ' , cName , 'not yet resolved' ].
|
|
262 |
^ type
|
|
263 |
|
|
264 |
"Created: / 17-02-2008 / 17:56:03 / janfrog"
|
|
265 |
! !
|
|
266 |
|
|
267 |
!CUserDefinedTypeNode methodsFor:'printing'!
|
|
268 |
|
|
269 |
printOn: stream indent: level
|
|
270 |
|
|
271 |
stream nextPutAll: cName
|
|
272 |
|
|
273 |
"Created: / 17-02-2008 / 18:18:11 / janfrog"
|
|
274 |
! !
|
|
275 |
|
|
276 |
!CUserDefinedTypeNode methodsFor:'private'!
|
|
277 |
|
|
278 |
fundamentalTypes
|
|
279 |
|
|
280 |
"
|
|
281 |
Possible combinations:
|
|
282 |
|
|
283 |
char
|
|
284 |
signed char
|
|
285 |
unsigned char
|
|
286 |
|
|
287 |
int, signed int
|
|
288 |
short int, short, signed short int, signed short
|
|
289 |
long int, long, signed long int,signed long
|
|
290 |
|
|
291 |
unsigned int, unsigned
|
|
292 |
unsigned short int, unsigned short
|
|
293 |
unsigned long int, unsigned long
|
|
294 |
|
|
295 |
float
|
|
296 |
double
|
|
297 |
long double
|
|
298 |
"
|
|
299 |
|
|
300 |
^#('char' 'short' 'int' 'long' 'float' 'double' 'void' 'signed' 'unsigned').
|
|
301 |
|
|
302 |
"Created: / 19-12-2007 / 15:28:32 / haja"
|
|
303 |
! !
|
|
304 |
|
|
305 |
!CUserDefinedTypeNode methodsFor:'visiting'!
|
|
306 |
|
|
307 |
acceptVisitor:aVisitor
|
|
308 |
"Double dispatch back to the visitor, passing my type encoded in
|
|
309 |
the selector (visitor pattern)"
|
|
310 |
|
|
311 |
"stub code automatically generated - please change if required"
|
|
312 |
|
|
313 |
^ aVisitor visitCUserDefinedTypeNode:self
|
|
314 |
|
|
315 |
"Created: / 02-11-2007 / 13:50:44 / haja"
|
|
316 |
"Modified: / 12-02-2008 / 22:59:33 / janfrog"
|
|
317 |
! !
|
|
318 |
|
|
319 |
!CUserDefinedTypeNode class methodsFor:'documentation'!
|
|
320 |
|
|
321 |
version
|
|
322 |
^ '$Header: /opt/data/cvs/cvut-fel/cface/Cface__CUserDefinedTypeNode.st,v 1.1 2008/02/26 15:57:04 vranyj1 Exp $'
|
|
323 |
! !
|