Wiki source code of SCL Extensions
Version 8.1 by ssm on 2013/05/08 11:05
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | |||
2 | |||
3 | |||
4 | |||
5 | {{toc/}} | ||
6 | |||
7 | There are several extensions implemented to ease the work with a scl model. (de.cau.cs.kieler.scl.extensions) | ||
8 | |||
9 | = SCL Factory Extensions = | ||
10 | |||
11 | You need several Factories to handle all aspects of Yakindu (SGraph + SText) and the extended SCChart models. The SCL Factory Extension provides you with shortcuts for all factories. | ||
12 | |||
13 | |=((( | ||
14 | Shortcut | ||
15 | )))|=((( | ||
16 | Factory | ||
17 | )))|=(% colspan="1" %)(% colspan="1" %) | ||
18 | ((( | ||
19 | Description | ||
20 | ))) | ||
21 | |((( | ||
22 | SGraph() | ||
23 | )))|((( | ||
24 | SGraphFactory::eINSTANCE | ||
25 | )))|(% colspan="1" %)(% colspan="1" %) | ||
26 | ((( | ||
27 | Factory for yakindu statechart models | ||
28 | ))) | ||
29 | |(% colspan="1" %)(% colspan="1" %) | ||
30 | ((( | ||
31 | SText() | ||
32 | )))|(% colspan="1" %)(% colspan="1" %) | ||
33 | ((( | ||
34 | StextFactory::eINSTANCE | ||
35 | )))|(% colspan="1" %)(% colspan="1" %) | ||
36 | ((( | ||
37 | Factory for yakindu expressions | ||
38 | ))) | ||
39 | |(% colspan="1" %)(% colspan="1" %) | ||
40 | ((( | ||
41 | SyncGraph() | ||
42 | )))|(% colspan="1" %)(% colspan="1" %) | ||
43 | ((( | ||
44 | SyncgraphFactory::eINSTANCE | ||
45 | )))|(% colspan="1" %)(% colspan="1" %) | ||
46 | ((( | ||
47 | Factory for sgraph extensions | ||
48 | ))) | ||
49 | |(% colspan="1" %)(% colspan="1" %) | ||
50 | ((( | ||
51 | SyncText() | ||
52 | )))|(% colspan="1" %)(% colspan="1" %) | ||
53 | ((( | ||
54 | SynctextFactory::eINSTANCE | ||
55 | )))|(% colspan="1" %)(% colspan="1" %) | ||
56 | ((( | ||
57 | Factory for stext extensions | ||
58 | ))) | ||
59 | |(% colspan="1" %)(% colspan="1" %) | ||
60 | ((( | ||
61 | SCCExp() | ||
62 | )))|(% colspan="1" %)(% colspan="1" %) | ||
63 | ((( | ||
64 | SCChartsExpFactory::eINSTANCE | ||
65 | )))|(% colspan="1" %)(% colspan="1" %) | ||
66 | ((( | ||
67 | Factory for SCCharts specific expression extensions | ||
68 | ))) | ||
69 | |(% colspan="1" %)(% colspan="1" %) | ||
70 | ((( | ||
71 | SCL() | ||
72 | )))|(% colspan="1" %)(% colspan="1" %) | ||
73 | ((( | ||
74 | SclFactory::eINSTANCE | ||
75 | )))|(% colspan="1" %)(% colspan="1" %) | ||
76 | ((( | ||
77 | Factory for SCL | ||
78 | ))) | ||
79 | |||
80 | = SCL Create Extensions = | ||
81 | |||
82 | |=((( | ||
83 | Method | ||
84 | )))|=((( | ||
85 | Description | ||
86 | ))) | ||
87 | |((( | ||
88 | def boolean isEmpty(Statement) | ||
89 | )))|((( | ||
90 | Returns true, if the statement is an EmptyStatement. | ||
91 | ))) | ||
92 | |(% colspan="1" %)(% colspan="1" %) | ||
93 | ((( | ||
94 | def boolean hasInstruction(Statement) | ||
95 | )))|(% colspan="1" %)(% colspan="1" %) | ||
96 | ((( | ||
97 | Returns true, if the statement is an InstructionStatement containing an instruction. | ||
98 | ))) | ||
99 | |(% colspan="1" %)(% colspan="1" %) | ||
100 | ((( | ||
101 | def boolean isGoto(Statement) | ||
102 | )))|(% colspan="1" %)(% colspan="1" %) | ||
103 | ((( | ||
104 | Returns true, if the statement is an InstructionStatement containing a goto instruction. | ||
105 | ))) | ||
106 | |(% colspan="1" %)(% colspan="1" %) | ||
107 | ((( | ||
108 | def EmptyStatement asEmptyStatement(Statement) | ||
109 | )))|(% colspan="1" %)(% colspan="1" %) | ||
110 | ((( | ||
111 | Convenently type-cast the statement to an EmptyStatement | ||
112 | ))) | ||
113 | |(% colspan="1" %)(% colspan="1" %) | ||
114 | ((( | ||
115 | def InstructionStatement asInstructionStatement(Statement) | ||
116 | )))|(% colspan="1" %)(% colspan="1" %) | ||
117 | ((( | ||
118 | Convenently type-cast the statement to an InstructionStatement | ||
119 | ))) | ||
120 | |(% colspan="1" %)(% colspan="1" %) | ||
121 | ((( | ||
122 | def getInstruction(Statement) | ||
123 | )))|(% colspan="1" %)(% colspan="1" %) | ||
124 | ((( | ||
125 | Type-cast the statement to an InstructionStatement an return its instruction. | ||
126 | ))) | ||
127 | |(% colspan="1" %)(% colspan="1" %) | ||
128 | ((( | ||
129 | def EmptyStatement removeInstruction(Statement) | ||
130 | )))|(% colspan="1" %)(% colspan="1" %) | ||
131 | ((( | ||
132 | Creates a new EmptyStatement and copies the label and comment information from the old statement. | ||
133 | ))) | ||
134 | |(% colspan="1" %)(% colspan="1" %) | ||
135 | ((( | ||
136 | def getStatement(Instruction) | ||
137 | )))|(% colspan="1" %)(% colspan="1" %) | ||
138 | ((( | ||
139 | Returns the parent statement of a given instruction. | ||
140 | ))) | ||
141 | |||
142 | |||
143 | |||
144 | = SCL Naming Extensions = | ||
145 | |||
146 | SCL Naming Extensions provide helper functions for ID & naming services. | ||
147 | |||
148 | |=((( | ||
149 | Method | ||
150 | )))|=((( | ||
151 | Description | ||
152 | ))) | ||
153 | |((( | ||
154 | def void distributeStateIDs(Statechart) | ||
155 | )))|((( | ||
156 | Since yakindu does not make use of the ID field, one can use this method to make every ID in a statechart unique. | ||
157 | ))) | ||
158 | |(% colspan="1" %)(% colspan="1" %) | ||
159 | ((( | ||
160 | def String getHierarchicalName(SyncState, String) | ||
161 | )))|(% colspan="1" %)(% colspan="1" %) | ||
162 | ((( | ||
163 | Generates a (most likely unique) name for a state. The name is generated from all parent states and regions, which are separated by an underscore. If a region or state has no name, the element's hash code is used instead. | ||
164 | ))) | ||
165 | |||
166 | = SCL Ordering Extensions = | ||
167 | |||
168 | The Ordering Extensions provide functions, which can be used in the //xtend sort// context. | ||
169 | |||
170 | |=((( | ||
171 | Method | ||
172 | )))|=((( | ||
173 | Description | ||
174 | ))) | ||
175 | |((( | ||
176 | def **int** compareSCLRegionStateOrder(SyncState, SyncState)(% style="font-size: small;" %) | ||
177 | )))|((( | ||
178 | Sorts states according to their type. Initial states come first, final states last. | ||
179 | ))) | ||
180 | |||
181 | = SCL Statement Extensions = | ||
182 | |||
183 | //coming soon...// | ||
184 | |||
185 | = SCL Thread Extensions = | ||
186 | |||
187 | The Thread Extensions provide functions to ease the handling of SCL threads and statements in the context of SCL threads. | ||
188 | |||
189 | |=((( | ||
190 | Method | ||
191 | )))|=((( | ||
192 | Description | ||
193 | ))) | ||
194 | |((( | ||
195 | def AbstractThread getThread(Instruction) | ||
196 | |||
197 | def AbstractThread getThread(Statement)(% style="font-size: small;" %) | ||
198 | )))|((( | ||
199 | Returns the SCL thread of a SCL statement or SCL instruction. | ||
200 | ))) | ||
201 | |(% colspan="1" %)(% colspan="1" %) | ||
202 | ((( | ||
203 | def AbstractThread getMainThread(Instruction) | ||
204 | |||
205 | def AbstractThread getMainThread(Statement)(% style="font-size: small;" %) | ||
206 | )))|(% colspan="1" %)(% colspan="1" %) | ||
207 | ((( | ||
208 | Returns the main thread of a SCL program. | ||
209 | ))) | ||
210 | |(% colspan="1" %)(% colspan="1" %) | ||
211 | ((( | ||
212 | def Statement[] getControlFlow(Instruction) | ||
213 | |||
214 | def Statement[] getControlFlow(Statement) | ||
215 | )))|(% colspan="1" %)(% colspan="1" %) | ||
216 | ((( | ||
217 | Returns the control flow of an instruction/statement up to the parent of this control flow. In contrast to a thread this also includes control flows of conditional instructions. | ||
218 | ))) | ||
219 | |(% colspan="1" %)(% colspan="1" %) | ||
220 | ((( | ||
221 | def **boolean** isInSameThreadAs(Instruction, Instruction) | ||
222 | |||
223 | def **boolean** isInSameThreadAs(Statement, Statement) | ||
224 | )))|(% colspan="1" %)(% colspan="1" %) | ||
225 | ((( | ||
226 | Returns true, if both instructions/statements are in the same thread. | ||
227 | ))) | ||
228 | |(% colspan="1" %)(% colspan="1" %) | ||
229 | ((( | ||
230 | def **boolean** isInMainThread(Instruction) | ||
231 | |||
232 | def **boolean** isInMainThread(Statement) | ||
233 | )))|(% colspan="1" %)(% colspan="1" %) | ||
234 | ((( | ||
235 | Returns true, if the instruction/statement runs in the main thread. | ||
236 | ))) | ||
237 | |(% colspan="1" %)(% colspan="1" %) | ||
238 | ((( | ||
239 | def **boolean** isInThread(Instruction, AbstractThread) | ||
240 | |||
241 | def **boolean** isInThread(Statement, AbstractThread) | ||
242 | )))|(% colspan="1" %)(% colspan="1" %) | ||
243 | ((( | ||
244 | Returns true, if the instruction/statement runs in the given thread. | ||
245 | ))) | ||
246 | |(% colspan="1" %)(% colspan="1" %) | ||
247 | ((( | ||
248 | def **boolean** contains(AbstractThread, Instruction) | ||
249 | |||
250 | def **boolean** contains(AbstractThread, Statements) | ||
251 | )))|(% colspan="1" %)(% colspan="1" %) | ||
252 | ((( | ||
253 | Returns true, if the thread contains the given instruction/statement. | ||
254 | ))) | ||
255 | |(% colspan="1" %)(% colspan="1" %) | ||
256 | ((( | ||
257 | def dropPrevious(AbstractThread, Statement) | ||
258 | |||
259 | def dropPrevious(List<Statement>, Statement)(% style="font-size: small;" %) | ||
260 | )))|(% colspan="1" %)(% colspan="1" %) | ||
261 | ((( | ||
262 | Drops all preceding statements in a thread or a list of statements before the given statement. | ||
263 | ))) | ||
264 | |(% colspan="1" %)(% colspan="1" %) | ||
265 | ((( | ||
266 | def Statement getPreviousStatement(Statement) | ||
267 | )))|(% colspan="1" %)(% colspan="1" %) | ||
268 | ((( | ||
269 | Returns the preceding statement. | ||
270 | ))) | ||
271 | |(% colspan="1" %)(% colspan="1" %) | ||
272 | ((( | ||
273 | def Statement getPreviousStatementHierarchical(Statement) | ||
274 | )))|(% colspan="1" %)(% colspan="1" %) | ||
275 | ((( | ||
276 | Returns the preceding statement or the parent statement of that control flow, if no preceding statement is present. | ||
277 | ))) | ||
278 | |(% colspan="1" %)(% colspan="1" %) | ||
279 | ((( | ||
280 | def InstructionStatement getPreviousInstructionStatement(Statement) | ||
281 | )))|(% colspan="1" %)(% colspan="1" %) | ||
282 | ((( | ||
283 | Returns the preceding instruction statement. Empty statements are ignored. | ||
284 | ))) | ||
285 | |(% colspan="1" %)(% colspan="1" %) | ||
286 | ((( | ||
287 | def InstructionStatement getPreviousInstructionStatementHierarchical(Statement) | ||
288 | )))|(% colspan="1" %)(% colspan="1" %) | ||
289 | ((( | ||
290 | Returns the preceding instruction statement or the parent statement of that control flow, if no preceding statement is present. | ||
291 | ))) | ||
292 | |||
293 | = SCL Goto Extensions = | ||
294 | |||
295 | To help with the handling of the goto statement and its target instruction, use the SCL Goto Extensions. | ||
296 | |||
297 | |=((( | ||
298 | Method | ||
299 | )))|=((( | ||
300 | Description | ||
301 | ))) | ||
302 | |((( | ||
303 | def Statement getTargetStatement(Goto) | ||
304 | |||
305 | def Statement getTargetStatement(Goto, AbstractThread) | ||
306 | )))|((( | ||
307 | Returns the target statement of a goto instruction (in the context of the (given) thread). | ||
308 | ))) | ||
309 | |(% colspan="1" %)(% colspan="1" %) | ||
310 | ((( | ||
311 | def boolean targetExists(Goto) | ||
312 | |||
313 | def boolean targetExists(Goto, AbstractThread) | ||
314 | )))|(% colspan="1" %)(% colspan="1" %) | ||
315 | ((( | ||
316 | Returns true, if the target of a goto instruction exists (in the context of the (given) thread). | ||
317 | ))) | ||
318 | |(% colspan="1" %)(% colspan="1" %) | ||
319 | ((( | ||
320 | def InstructionStatement getInstructionStatement(Statement)(% style="font-size: small;" %) | ||
321 | )))|(% colspan="1" %)(% colspan="1" %) | ||
322 | ((( | ||
323 | Returns the first valid InstructionStatement in a thread after the given statement. **May return null, if no further InstructionStatement exists.** | ||
324 | |||
325 | To get a valid instruction form a goto jump, one can write "goto.getTargetStatement?.getInstructionStatement?.instruction". The result value will be the instruction or null. | ||
326 | ))) | ||
327 | |(% colspan="1" %)(% colspan="1" %) | ||
328 | ((( | ||
329 | def getIncomingGotos(Statement) | ||
330 | )))|(% colspan="1" %)(% colspan="1" %) | ||
331 | ((( | ||
332 | Returns a list of all gotos that target the given statement. If you want to retrieve the count of incoming goto jumps, use "getIncomingGotos.size". | ||
333 | ))) | ||
334 | |||
335 | = SCL Expression Extensions = | ||
336 | |||
337 | The SCL Expression Extension holds methods to help with the manipulation and constructions of the SText (and extended) expressions. | ||
338 | |||
339 | |=((( | ||
340 | Method | ||
341 | )))|=((( | ||
342 | Description | ||
343 | ))) | ||
344 | |((( | ||
345 | def Expression toExpression(RegularEventSpec) | ||
346 | )))|((( | ||
347 | Transforms a SGraph RegularEventSpec to a SText Expression. The resulting expression will be an ElementReferenceExpression. | ||
348 | ))) | ||
349 | |(% colspan="1" %)(% colspan="1" %) | ||
350 | ((( | ||
351 | def Expression negate(Expression) | ||
352 | )))|(% colspan="1" %)(% colspan="1" %) | ||
353 | ((( | ||
354 | Negates the given expression. If the Expression is an ElementReferenceExpression the result will be a LogicalNotExpression containing the expression. Otherwise the result will be a LogicalNotExpression containing a ParenthesizedExpression, which then holds the original expression. | ||
355 | ))) | ||
356 | |(% colspan="1" %)(% colspan="1" %) | ||
357 | ((( | ||
358 | def String correctSerialization(String) | ||
359 | )))|(% colspan="1" %)(% colspan="1" %) | ||
360 | ((( | ||
361 | Since the actual implementation of the SText parser may parse artefacts (like linebreaks) until matching a preceding delimeter, correctSerialization removes these artifacts, when serializing an expression. | ||
362 | ))) | ||
363 | |||
364 | = SCL Dependency Extensions = | ||
365 | |||
366 | //coming soon...// | ||
367 | |||
368 | = SCL Basic Block Extensions = | ||
369 | |||
370 | //coming soon...// |