Show last authors
1 {{panel title="Project Overview" borderStyle="dashed"}}
2 Responsible:
3
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"]]
5
6 Related Theses:
7
8 * none yet
9 {{/panel}}
10
11 = Kieler Compiler (KiCo) =
12
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
23 [[image:attach:KiCo.jpg]]
24
25 == Extension Point ==
26
27 In order to add a transformation to KiCo you must follow these steps:
28
29 1. (((
30 Add dependency to
31
32 {{{de.cau.cs.kieler.kico}}}
33
34
35 )))
36 1. Add the extension
37
38
39 {{{de.cau.cs.kieler.kico.transformation}}}(((
40
41 )))
42 1. (((
43 Add one of the following extension element
44
45 [[image:attach:KiCo2.jpg]]
46 )))
47
48 |=(((
49 Extension Element
50 )))|=(((
51 Description
52 )))
53 |(((
54 transformationClass
55 )))|(((
56 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
57
58 * getId(): Returns a unique String ID for this transformation. This is the ID the transformation will be referenced throughout KiCo.
59 * getName(): Optionally return a String name for this transformation. If null is returned here the ID will be used as a name.
60 * 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.
61 * transform(EObject): Returns an EObject and does the central transformation.
62 )))
63 |(((
64 transformationMethod
65 )))|(((
66 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:
67
68 * class: The class where the transform method is implemented in
69 * 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.
70 * id: The unique String ID for this transformation. This is the ID the transformation will be referenced throughout KiCo.
71 * name: An optional String name for this transformation. If nothing is entered here the ID will be used as a name.
72 * dependencies: An optional String as comma separated list of other transformation IDs that must run BEFORE this transformation. If nothing is entered here then this means there are no dependencies.
73 )))
74 |(((
75 transformationGroup
76 )))|(((
77 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:
78
79 * 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!
80 * dependencies: These are NOT optional for groups. Groups must specify their transformations as dependencies. 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.
81 * name: An optional String name for this transformation. If nothing is entered here the ID will be used as a name.
82 )))
83
84 === Example ===
85
86 {{code title="plugin.xml"}}
87 <extension
88 point="de.cau.cs.kieler.kico.transformation">
89 <transformationGroup
90 id="NORMALIZE"
91 dependencies="TRIGGEREFFECT, SURFACEDEPTH"
92 name="Transform All Normalize">
93 </transformationGroup>
94 </extension>
95 <extension
96 point="de.cau.cs.kieler.kico.transformation">
97 <transformationMethod
98 class="de.cau.cs.kieler.sccharts.extensions.SCChartsCoreTransformation"
99 id="TRIGGEREFFECT"
100 method="transformTriggerEffect"
101 name="Transform Trigger and Effect">
102 </transformationMethod>
103 </extension>
104
105 <extension
106 point="de.cau.cs.kieler.kico.transformation">
107 <transformationMethod
108 class="de.cau.cs.kieler.sccharts.extensions.SCChartsCoreTransformation"
109 id="SURFACEDEPTH"
110 method="transformSurfaceDepth"
111 name="Transform Surface Depth">
112 </transformationMethod>
113 </extension>
114
115 <extension
116 point="de.cau.cs.kieler.kico.transformation">
117 <transformationGroup
118 id="ALL"
119 dependencies="CORE NORMALIZE"
120 name="Transform All">
121 </transformationGroup>
122 </extension>
123 {{/code}}
124
125
126
127 == Compilation ==
128
129 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:
130
131 |=(((
132 Method
133 )))|=(((
134 Description
135 )))
136 |(((
137 \\
138
139 {{{EObject KielerCompiler.compile(List&#x3c;String&#x3e; transformationIDs, EObject eObject)}}}
140 )))|(((
141 * 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.
142 * eObject: The EObject that is the input to the compilation process.
143 * Returns: The EObject returned from the last model transformation called by KiCo.
144 )))
145 |(((
146 \\
147
148 {{{EObject KielerCompiler.compile(String transformationIDs, EObject eObject)}}}
149 )))|(((
150 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.
151 )))
152 |(((
153
154 \\
155
156 {{{EObject KielerCompiler.compile(List&#x3c;String&#x3e; transformationIDs, EObject eObject, boolean autoexpand)}}}
157 )))|(((
158 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.
159 )))
160
161 === Examples ===
162
163 {{code title="Java Code"}}
164 import de.cau.cs.kieler.kico.KielerCompiler;
165 ...
166 private MyEObjectClass myMethod(EObject eObject) {
167 ...
168 transformed = (MyEObjectClass) KielerCompiler.compile("ABORT, SIGNAL", eObject);
169 ...
170 return transformed
171 }
172 {{/code}}
173
174 {{code title="Xtend Code"}}
175 import de.cau.cs.kieler.kico.KielerCompiler
176 ...
177 def dispatch MyEObjectClass myMethod(EObject eObject) {
178 transformed = KielerCompiler.compile("ABORT, SIGNAL", eObject) as MyEObjectClass
179 ...
180 transformed
181 }
182
183
184
185
186 {{/code}}