Wiki source code of Kieler Compiler

Version 22.1 by cmot on 2014/03/21 14:35

Hide last authors
cmot 10.1 1 {{panel title="Project Overview" borderStyle="dashed"}}
2 Responsible:
3
cmot 11.1 4 * [[Christian Motika>>url:http://www.informatik.uni-kiel.de/rtsys/kontakt/cmot/||shape="rect"]], [[Steven Smyth>>url:http://www.informatik.uni-kiel.de/rtsys/kontakt/ssm/||shape="rect"]]
cmot 10.1 5
6 Related Theses:
7
8 * none yet
9 {{/panel}}
10
cmot 11.1 11 = Kieler Compiler (KiCo) =
12
cmot 1.1 13 In order to integrate and be able to evaluate our compiler chain from SCCharts to C or VHDL code we use the KiCo project as a generic framework that allows to register setp-by-step transformations on EObjects. These can then be handled by the generic KIEM KiCo DataComponent.
14
15
16
17 {{toc/}}
18
19 == General ==
20
21 The KIELER Compiler (KiCo) project allows to register step-by-step model transformations on EObjects that could be written in Xtend or Java. These transformations are registered using an extension point provided (see below). After registering transformations these can be used by simply call the KielerCompiler compilation method as also explained further below.
22
cmot 16.1 23 |=(((
cmot 3.1 24 [[image:attach:KiCo.jpg]]
cmot 16.1 25 )))|=(((
26 [[image:attach:KiCo3.jpg]]
27 )))
cmot 1.1 28
29 == Extension Point ==
30
cmot 3.1 31 In order to add a transformation to KiCo you must follow these steps:
cmot 1.1 32
cmot 3.1 33 1. (((
34 Add dependency to
35
36 {{{de.cau.cs.kieler.kico}}}
37
38
39 )))
40 1. Add the extension
41
42
cmot 8.1 43 {{{de.cau.cs.kieler.kico.transformation}}}(((
44
45 )))
46 1. (((
cmot 9.1 47 Add one of the following extension element
cmot 3.1 48
49 [[image:attach:KiCo2.jpg]]
cmot 8.1 50 )))
cmot 3.1 51
52 |=(((
53 Extension Element
54 )))|=(((
55 Description
56 )))
57 |(((
58 transformationClass
59 )))|(((
60 The defined class must extend "de.cau.cs.kieler.kico.Transformation" and must implement the methods defined in "de.cau.cs.kieler.kico.ITransformation". These are
61
62 * getId(): Returns a unique String ID for this transformation. This is the ID the transformation will be referenced throughout KiCo.
63 * getName(): Optionally return a String name for this transformation. If null is returned here the ID will be used as a name.
64 * getDependencies(): Optionally return a List<String> of other transformation IDs that must run BEFORE this transformation. If null is returned then this means there are no dependencies.
65 * transform(EObject): Returns an EObject and does the central transformation.
66 )))
67 |(((
68 transformationMethod
69 )))|(((
70 The defined class can be freely chosen and does not need to extend or implement any other class or interface. Although you have to give more information in the extension element now:
71
72 * class: The class where the transform method is implemented in
73 * method: The name of the transformation method. Its signature must ensure that it returns an EObject an only take an EObject argument. Otherwise it cannot be found by KiCo.
74 * id: The unique String ID for this transformation. This is the ID the transformation will be referenced throughout KiCo.
75 * name: An optional String name for this transformation. If nothing is entered here the ID will be used as a name.
cmot 19.1 76 * dependencies: An optional String as comma separated list of other transformation IDs that must run AFTER this transformation down the compile-chain. This means if the current transformation is selected to run, all transformations that have dependencies on this will be run BEFORE. If nothing is entered here then this means there are no dependencies.
cmot 3.1 77 )))
78 |(((
79 transformationGroup
80 )))|(((
81 Sometimes you may want to group other transformations and give this group a specific transformation ID as a kind of shortcut. You can do this by using the transformationGroup element giving the following information:
82
83 * id: The unique String ID for this transformation group. This is the ID the transformation group will be referenced throughout KiCo. It may also again be referenced by other transformation groups!
cmot 15.1 84 * transformations: Groups must specify their transformations. Use a String as comma separated list of other transformation IDs or transformation group IDs that should represent this group. Note that the order will be implied by the referenced transformations itself although if there is a free degree of order it can be influenced by the order specified here in the group.
cmot 3.1 85 * name: An optional String name for this transformation. If nothing is entered here the ID will be used as a name.
cmot 14.1 86 * alternatives: When selected this group specifies alternatives only. When this group is referenced, the first transformation is selected if not any other transformation from this group is already in the list of selected transformations. This is an advanced feature.
cmot 3.1 87 )))
88
cmot 4.1 89 === Example ===
90
91 {{code title="plugin.xml"}}
92 <extension
93 point="de.cau.cs.kieler.kico.transformation">
94 <transformationGroup
95 id="NORMALIZE"
96 dependencies="TRIGGEREFFECT, SURFACEDEPTH"
97 name="Transform All Normalize">
98 </transformationGroup>
cmot 20.1 99
cmot 4.1 100 <transformationMethod
101 class="de.cau.cs.kieler.sccharts.extensions.SCChartsCoreTransformation"
102 id="TRIGGEREFFECT"
103 method="transformTriggerEffect"
104 name="Transform Trigger and Effect">
105 </transformationMethod>
cmot 20.1 106
cmot 4.1 107 <transformationMethod
108 class="de.cau.cs.kieler.sccharts.extensions.SCChartsCoreTransformation"
109 id="SURFACEDEPTH"
110 method="transformSurfaceDepth"
111 name="Transform Surface Depth">
112 </transformationMethod>
cmot 20.1 113
cmot 4.1 114 <transformationGroup
115 id="ALL"
116 dependencies="CORE NORMALIZE"
117 name="Transform All">
118 </transformationGroup>
119 </extension>
120 {{/code}}
121
cmot 3.1 122
123
cmot 1.1 124 == Compilation ==
125
cmot 5.1 126 Once a bunch of model transformations are registered, these can simply be called using the KiCo central "KielerCompiler" class with its method compile(). This will be given a List<String> of transformation IDs or a comma separated String of transformation IDs as the first parameter. The second parameter is the EObject that is being transformed. It should meet the signature of the first model transformation called. Note that the actual model transformations that are done may vary because KiCo will automatically inspect the dependencies of each transformation requested (deep-recursively). If you do not like this to happen as an advanced user you can use a third parameter that will skip this autocompletion. Note that if you switch this off also NO transformation groups can be processed. Here is an overview and examples how to use the compile() method:
127
128 |=(((
129 Method
130 )))|=(((
131 Description
132 )))
133 |(((
cmot 6.1 134 \\
135
136 {{{EObject KielerCompiler.compile(List&#x3c;String&#x3e; transformationIDs, EObject eObject)}}}
cmot 5.1 137 )))|(((
138 * transformationIDs: List of Strings representing the transformation IDs and a pre-ordering. Note that KiCo may automatically modify the order to meet the dependencies of the referenced transformation IDs or transformation group IDs.
139 * eObject: The EObject that is the input to the compilation process.
140 * Returns: The EObject returned from the last model transformation called by KiCo.
141 )))
142 |(((
cmot 6.1 143 \\
144
145 {{{EObject KielerCompiler.compile(String transformationIDs, EObject eObject)}}}
cmot 5.1 146 )))|(((
147 This is a convenient method only which can be used to give transformation IDs or transformation group IDs as a comma separated String. For eObject and the return value see above.
148 )))
149 |(((
cmot 6.1 150
151 \\
152
153 {{{EObject KielerCompiler.compile(List&#x3c;String&#x3e; transformationIDs, EObject eObject, boolean autoexpand)}}}
cmot 5.1 154 )))|(((
155 This is an advanced compile method which can turn of auto-expansion with the last parameter. Use this with care! Note that if switching autoexpand off you cannot use transformation group IDs any more. Also no dependencies will be considered. The transformations will be applied straight forward in the order defined by the transformationIDs list.
156 )))
157
158 === Examples ===
159
160 {{code title="Java Code"}}
161 import de.cau.cs.kieler.kico.KielerCompiler;
162 ...
163 private MyEObjectClass myMethod(EObject eObject) {
164 ...
165 transformed = (MyEObjectClass) KielerCompiler.compile("ABORT, SIGNAL", eObject);
166 ...
167 return transformed
168 }
169 {{/code}}
170
171 {{code title="Xtend Code"}}
172 import de.cau.cs.kieler.kico.KielerCompiler
173 ...
174 def dispatch MyEObjectClass myMethod(EObject eObject) {
175 transformed = KielerCompiler.compile("ABORT, SIGNAL", eObject) as MyEObjectClass
176 ...
177 transformed
178 }
179
180
181
182
183 {{/code}}
cmot 12.1 184
cmot 20.1 185 === Requirement Completion ===
186
187
188
189 |=(((
190 (% style="text-align: center;" %)
191 Original
192
193 |=(((
194 [[image:attach:dependencies2.jpg]]
cmot 21.1 195
196 (% style="text-align: center;" %)
197 Original Dependency
198 Graph
cmot 20.1 199 )))|=(((
cmot 22.1 200 (% style="text-align: center;" %)
cmot 21.1 201 [[image:attach:dependencies3.jpg]]
202
203 (% style="text-align: center;" %)
204 Two alternative
205 transformation
206 implementations
207 for Abort
cmot 20.1 208 )))
209
210
211 )))|=(((
212 (% style="text-align: center;" %)
213 Example 1
214
215 |=(((
216 [[image:attach:dependencies4.jpg]]
cmot 21.1 217
218 (% style="text-align: center;" %)
219 Selected for
220 transformation
cmot 20.1 221 )))|=(((
222 [[image:attach:dependencies4b.jpg]]
cmot 21.1 223
224 (% style="text-align: center;" %)
225 Auto selected
226 requirements
cmot 20.1 227 )))
228
229
230 )))
231
232
233
234
235
236 |=(((
237 Example 2
238
239 |=(((
240 [[image:attach:dependencies5.jpg]]
cmot 21.1 241
242 (% style="text-align: center;" %)
243 Selected for
244 transformation
245 )))|=(% style="text-align: center;" %)(% style="text-align: center;" %)
246 (((
cmot 20.1 247 [[image:attach:dependencies5b.jpg]]
cmot 22.1 248
249 Auto selected
cmot 21.1 250 requirements
251 using DEFAULT
252 of alternative
253 group
cmot 22.1 254
255
cmot 20.1 256 )))
257
258
259 )))|=(((
260 (% style="text-align: center;" %)
261 Example 3
262
263 |=(((
264 [[image:attach:dependencies6.jpg]]
cmot 21.1 265
266 (% style="text-align: center;" %)
267 Selected for
268 transformation
cmot 20.1 269 )))|=(((
270 [[image:attach:dependencies6b.jpg]]
cmot 21.1 271
272 (% style="text-align: center;" %)
273 Auto selected
274 requirements
275 using selected
276 alternative
cmot 20.1 277 )))
278
279
280 )))
281
282
283
cmot 12.1 284 == Help / Problems / FAQs ==
285
286 Maybe you get into problems when using KiCo. The following list should give you hints to solve these. If you have a problem not considered here please write us an e-mail (see above for contact information of the persons in charge of KiCo).
287
288 |=(((
289 Symptom
290 )))|=(((
291 Reason
292 )))|=(((
293 Solution
294 )))
295 |(((
296 You get the following run time error:
297
298
299 \\\\\\\\\\\\\\\\[[java:102>>url:http://java:102||shape="rect"]]
300 [[java:136>>url:http://java:136||shape="rect"]]
301 [[java:164>>url:http://java:164||shape="rect"]]\\
302
303 {{{ENTRY de.cau.cs.kieler.klighd 4 0 2014-03-17 11:08:46.009!MESSAGE !STACK 0java.lang.RuntimeException: Cannot find a transformation with the ID 'ABORT2'. Make sure that the transformation with this ID is registered and its declaring plugin is loaded. Make sure that the ID does exactly match (case sensitive). Maybe you forgot to separate multiple ID's by a comma.    at de.cau.cs.kieler.kico.KielerCompiler.getTransformation(KielerCompiler.java:61)    at de.cau.cs.kieler.kico.KielerCompiler.getDependencies(KielerCompiler.java:82)    at de.cau.cs.kieler.kico.KielerCompiler.isDependingOn(KielerCompiler.)    at de.cau.cs.kieler.kico.KielerCompiler.insertTransformationID(KielerCompiler.)    at de.cau.cs.kieler.kico.KielerCompiler.expandDependencies(KielerCompiler.)...}}}
304 )))|(((
305 There is a transformation with ID "ABORT2" referenced
306 either by the initial call to KielerCompiler.compile() or
307 by some of the dependent transformations /
308 transformation group.
309
310 But KiCo could not find any registered transformation
311 with ID "ABORT2".
312
313 Maybe the plugin declaring "ABORT2" was not loaded
314 or the ID is misspelled.
315
316
317 )))|(((
318 Check why "ABORT2" may not be found
319 by KiCo, more specifically, check if the
320 declaring can be loaded (sometimes
321 compiler error prevent it from being loaded
322 or it has unsatisfied dependencies).
323 Also check the spelling of the ID, maybe
324 the declaring plugin defines the transformation
325 with the ID "abort2".
326 )))
327 |(((
cmot 13.1 328 You get the following error:
329
330 {{{!ENTRY de.cau.cs.kieler.kico 2 2 2014-03-17 11:26:13.818}}}
331
332 \\
333
334 {{{!MESSAGE Extension 'TERMINATION' from component: de.cau.cs.kieler.sccharts cannot beloaded becaus this ID is already taken. (de.cau.cs.kieler.kico)}}}
cmot 12.1 335 )))|(((
cmot 13.1 336 The trasformation with ID "TERMINATION" is already
337 registered and this ID cannot be used a second time.
338 The component "de.cau...sccharts" tries to register
339 a transformation with this ID while this ID is already
340 taken.
cmot 12.1 341 )))|(((
cmot 13.1 342 Rename one of the IDs or form a group of
343 transformations.
cmot 12.1 344 )))