Wiki source code of Kieler Compiler

Version 28.1 by aas2 on 2017/04/04 13:06

Hide last authors
aas2 28.1 1 {{panel borderStyle="dashed" title="Project Overview"}}
cmot 10.1 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
cmot 26.1 9
10 **To see the KielerCompiler in action, we provide an Online SCCharts Compiler [[here>>doc:Online Compiler]].**
cmot 10.1 11 {{/panel}}
12
cmot 11.1 13 = Kieler Compiler (KiCo) =
14
aas2 28.1 15 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. **To see the KielerCompiler in action, we provide an Online SCCharts Compiler [[here>>url:http://www.sccharts.com/||shape="rect"]].**
cmot 1.1 16
17
18
19 {{toc/}}
20
21 == General ==
22
23 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.
24
aas2 28.1 25 (% class="wrapped" %)
cmot 16.1 26 |=(((
aas2 28.1 27 (% class="content-wrapper" %)
28 (((
cmot 25.1 29 [[image:attach:IMAG4642.jpg]]
aas2 28.1 30 )))
cmot 16.1 31 )))|=(((
aas2 28.1 32 (% class="content-wrapper" %)
33 (((
cmot 24.1 34 [[image:attach:KiCo.jpg]]
cmot 16.1 35 )))
aas2 28.1 36 )))
cmot 1.1 37
38 == Extension Point ==
39
cmot 3.1 40 In order to add a transformation to KiCo you must follow these steps:
cmot 1.1 41
cmot 3.1 42 1. (((
43 Add dependency to
44
45 {{{de.cau.cs.kieler.kico}}}
46
aas2 28.1 47 \\
cmot 3.1 48 )))
49 1. Add the extension
50
51
cmot 8.1 52 {{{de.cau.cs.kieler.kico.transformation}}}(((
aas2 28.1 53 \\
cmot 8.1 54 )))
55 1. (((
cmot 9.1 56 Add one of the following extension element
cmot 3.1 57
58 [[image:attach:KiCo2.jpg]]
cmot 8.1 59 )))
cmot 3.1 60
aas2 28.1 61 (% class="wrapped" %)
cmot 3.1 62 |=(((
63 Extension Element
64 )))|=(((
65 Description
66 )))
67 |(((
68 transformationClass
69 )))|(((
70 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
71
72 * getId(): Returns a unique String ID for this transformation. This is the ID the transformation will be referenced throughout KiCo.
73 * getName(): Optionally return a String name for this transformation. If null is returned here the ID will be used as a name.
74 * 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.
75 * transform(EObject): Returns an EObject and does the central transformation.
76 )))
77 |(((
78 transformationMethod
79 )))|(((
80 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:
81
82 * class: The class where the transform method is implemented in
83 * 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.
84 * id: The unique String ID for this transformation. This is the ID the transformation will be referenced throughout KiCo.
85 * name: An optional String name for this transformation. If nothing is entered here the ID will be used as a name.
cmot 19.1 86 * 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 87 )))
88 |(((
89 transformationGroup
90 )))|(((
91 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:
92
93 * 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 94 * 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 95 * name: An optional String name for this transformation. If nothing is entered here the ID will be used as a name.
cmot 14.1 96 * 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 97 )))
98
cmot 4.1 99 === Example ===
100
101 {{code title="plugin.xml"}}
102 <extension
103 point="de.cau.cs.kieler.kico.transformation">
104 <transformationGroup
105 id="NORMALIZE"
106 dependencies="TRIGGEREFFECT, SURFACEDEPTH"
107 name="Transform All Normalize">
108 </transformationGroup>
cmot 20.1 109
cmot 4.1 110 <transformationMethod
111 class="de.cau.cs.kieler.sccharts.extensions.SCChartsCoreTransformation"
112 id="TRIGGEREFFECT"
113 method="transformTriggerEffect"
114 name="Transform Trigger and Effect">
115 </transformationMethod>
cmot 20.1 116
cmot 4.1 117 <transformationMethod
118 class="de.cau.cs.kieler.sccharts.extensions.SCChartsCoreTransformation"
119 id="SURFACEDEPTH"
120 method="transformSurfaceDepth"
121 name="Transform Surface Depth">
122 </transformationMethod>
cmot 20.1 123
cmot 4.1 124 <transformationGroup
125 id="ALL"
126 dependencies="CORE NORMALIZE"
127 name="Transform All">
128 </transformationGroup>
129 </extension>
130 {{/code}}
131
aas2 28.1 132 \\
cmot 3.1 133
cmot 1.1 134 == Compilation ==
135
cmot 5.1 136 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:
137
aas2 28.1 138 (% class="wrapped" %)
cmot 5.1 139 |=(((
140 Method
141 )))|=(((
142 Description
143 )))
144 |(((
cmot 6.1 145 \\
146
147 {{{EObject KielerCompiler.compile(List&#x3c;String&#x3e; transformationIDs, EObject eObject)}}}
cmot 5.1 148 )))|(((
149 * 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.
150 * eObject: The EObject that is the input to the compilation process.
151 * Returns: The EObject returned from the last model transformation called by KiCo.
152 )))
153 |(((
cmot 6.1 154 \\
155
156 {{{EObject KielerCompiler.compile(String transformationIDs, EObject eObject)}}}
cmot 5.1 157 )))|(((
158 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.
159 )))
160 |(((
cmot 6.1 161
162 \\
163
164 {{{EObject KielerCompiler.compile(List&#x3c;String&#x3e; transformationIDs, EObject eObject, boolean autoexpand)}}}
cmot 5.1 165 )))|(((
166 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.
167 )))
168
169 === Examples ===
170
171 {{code title="Java Code"}}
172 import de.cau.cs.kieler.kico.KielerCompiler;
173 ...
174 private MyEObjectClass myMethod(EObject eObject) {
175 ...
176 transformed = (MyEObjectClass) KielerCompiler.compile("ABORT, SIGNAL", eObject);
177 ...
178 return transformed
179 }
180 {{/code}}
181
182 {{code title="Xtend Code"}}
183 import de.cau.cs.kieler.kico.KielerCompiler
184 ...
185 def dispatch MyEObjectClass myMethod(EObject eObject) {
186 transformed = KielerCompiler.compile("ABORT, SIGNAL", eObject) as MyEObjectClass
187 ...
188 transformed
189 }
190
191
192
193
194 {{/code}}
cmot 12.1 195
cmot 20.1 196 === Requirement Completion ===
197
aas2 28.1 198 \\
cmot 20.1 199
aas2 28.1 200 (% class="wrapped" %)
cmot 20.1 201 |=(((
aas2 28.1 202 (% class="content-wrapper" %)
203 (((
cmot 20.1 204 (% style="text-align: center;" %)
205 Original
206
aas2 28.1 207 (% class="wrapped" %)
cmot 20.1 208 |=(((
aas2 28.1 209 (% class="content-wrapper" %)
210 (((
cmot 20.1 211 [[image:attach:dependencies2.jpg]]
cmot 21.1 212
213 (% style="text-align: center;" %)
214 Original Dependency
215 Graph
aas2 28.1 216 )))
cmot 20.1 217 )))|=(((
aas2 28.1 218 (% class="content-wrapper" %)
219 (((
cmot 22.1 220 (% style="text-align: center;" %)
cmot 21.1 221 [[image:attach:dependencies3.jpg]]
222
223 (% style="text-align: center;" %)
224 Two alternative
225 transformation
226 implementations
227 for Abort
cmot 20.1 228 )))
aas2 28.1 229 )))
cmot 20.1 230
aas2 28.1 231 \\
232 )))
cmot 20.1 233 )))|=(((
aas2 28.1 234 (% class="content-wrapper" %)
235 (((
cmot 20.1 236 (% style="text-align: center;" %)
237 Example 1
238
aas2 28.1 239 (% class="wrapped" %)
cmot 20.1 240 |=(((
aas2 28.1 241 (% class="content-wrapper" %)
242 (((
cmot 20.1 243 [[image:attach:dependencies4.jpg]]
cmot 21.1 244
245 (% style="text-align: center;" %)
246 Selected for
247 transformation
aas2 28.1 248 )))
cmot 20.1 249 )))|=(((
aas2 28.1 250 (% class="content-wrapper" %)
251 (((
cmot 20.1 252 [[image:attach:dependencies4b.jpg]]
cmot 21.1 253
254 (% style="text-align: center;" %)
255 Auto selected
256 requirements
cmot 20.1 257 )))
aas2 28.1 258 )))
cmot 20.1 259
aas2 28.1 260 \\
cmot 20.1 261 )))
aas2 28.1 262 )))
cmot 20.1 263
aas2 28.1 264 \\
cmot 20.1 265
aas2 28.1 266 \\
cmot 20.1 267
aas2 28.1 268 (% class="wrapped" %)
cmot 20.1 269 |=(((
aas2 28.1 270 (% class="content-wrapper" %)
271 (((
cmot 23.1 272 (% style="text-align: center;" %)
cmot 20.1 273 Example 2
274
aas2 28.1 275 (% class="wrapped" %)
cmot 20.1 276 |=(((
aas2 28.1 277 (% class="content-wrapper" %)
278 (((
cmot 20.1 279 [[image:attach:dependencies5.jpg]]
cmot 21.1 280
281 (% style="text-align: center;" %)
282 Selected for
283 transformation
aas2 28.1 284 )))
cmot 21.1 285 )))|=(% style="text-align: center;" %)(% style="text-align: center;" %)
286 (((
aas2 28.1 287 (% class="content-wrapper" %)
288 (((
cmot 20.1 289 [[image:attach:dependencies5b.jpg]]
cmot 22.1 290
291 Auto selected
cmot 21.1 292 requirements
293 using DEFAULT
294 of alternative
295 group
cmot 22.1 296
aas2 28.1 297 \\
cmot 20.1 298 )))
aas2 28.1 299 )))
cmot 20.1 300
aas2 28.1 301 \\
302 )))
cmot 20.1 303 )))|=(((
aas2 28.1 304 (% class="content-wrapper" %)
305 (((
cmot 20.1 306 (% style="text-align: center;" %)
307 Example 3
308
aas2 28.1 309 (% class="wrapped" %)
cmot 20.1 310 |=(((
aas2 28.1 311 (% class="content-wrapper" %)
312 (((
cmot 20.1 313 [[image:attach:dependencies6.jpg]]
cmot 21.1 314
315 (% style="text-align: center;" %)
316 Selected for
317 transformation
aas2 28.1 318 )))
cmot 20.1 319 )))|=(((
aas2 28.1 320 (% class="content-wrapper" %)
321 (((
cmot 20.1 322 [[image:attach:dependencies6b.jpg]]
cmot 21.1 323
324 (% style="text-align: center;" %)
325 Auto selected
326 requirements
327 using selected
328 alternative
cmot 20.1 329 )))
aas2 28.1 330 )))
cmot 20.1 331
aas2 28.1 332 \\
cmot 20.1 333 )))
aas2 28.1 334 )))
cmot 20.1 335
aas2 28.1 336 \\
cmot 20.1 337
cmot 12.1 338 == Help / Problems / FAQs ==
339
340 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).
341
aas2 28.1 342 (% class="wrapped" %)
cmot 12.1 343 |=(((
344 Symptom
345 )))|=(((
346 Reason
347 )))|=(((
348 Solution
349 )))
350 |(((
351 You get the following run time error:
352
353
354 \\\\\\\\\\\\\\\\[[java:102>>url:http://java:102||shape="rect"]]
355 [[java:136>>url:http://java:136||shape="rect"]]
356 [[java:164>>url:http://java:164||shape="rect"]]\\
357
358 {{{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.)...}}}
359 )))|(((
360 There is a transformation with ID "ABORT2" referenced
361 either by the initial call to KielerCompiler.compile() or
362 by some of the dependent transformations /
363 transformation group.
364
365 But KiCo could not find any registered transformation
366 with ID "ABORT2".
367
368 Maybe the plugin declaring "ABORT2" was not loaded
369 or the ID is misspelled.
370
aas2 28.1 371 \\
cmot 12.1 372 )))|(((
373 Check why "ABORT2" may not be found
374 by KiCo, more specifically, check if the
375 declaring can be loaded (sometimes
376 compiler error prevent it from being loaded
377 or it has unsatisfied dependencies).
378 Also check the spelling of the ID, maybe
379 the declaring plugin defines the transformation
380 with the ID "abort2".
381 )))
382 |(((
cmot 13.1 383 You get the following error:
384
385 {{{!ENTRY de.cau.cs.kieler.kico 2 2 2014-03-17 11:26:13.818}}}
386
387 \\
388
389 {{{!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 390 )))|(((
cmot 13.1 391 The trasformation with ID "TERMINATION" is already
392 registered and this ID cannot be used a second time.
393 The component "de.cau...sccharts" tries to register
394 a transformation with this ID while this ID is already
395 taken.
cmot 12.1 396 )))|(((
cmot 13.1 397 Rename one of the IDs or form a group of
398 transformations.
cmot 12.1 399 )))