@sccharts-lab/engine 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/LICENSE +277 -0
  2. package/README.md +125 -2
  3. package/dist/codegen/expr.d.ts +36 -0
  4. package/dist/codegen/expr.js +252 -0
  5. package/dist/codegen/expr.js.map +1 -0
  6. package/dist/codegen/index.d.ts +4 -0
  7. package/dist/codegen/index.js +238 -0
  8. package/dist/codegen/index.js.map +1 -0
  9. package/dist/codegen/layout.d.ts +57 -0
  10. package/dist/codegen/layout.js +306 -0
  11. package/dist/codegen/layout.js.map +1 -0
  12. package/dist/codegen/logic.d.ts +31 -0
  13. package/dist/codegen/logic.js +258 -0
  14. package/dist/codegen/logic.js.map +1 -0
  15. package/dist/codegen/methods.d.ts +17 -0
  16. package/dist/codegen/methods.js +242 -0
  17. package/dist/codegen/methods.js.map +1 -0
  18. package/dist/codegen/reset.d.ts +6 -0
  19. package/dist/codegen/reset.js +110 -0
  20. package/dist/codegen/reset.js.map +1 -0
  21. package/dist/codegen/types.d.ts +81 -0
  22. package/dist/codegen/types.js +3 -0
  23. package/dist/codegen/types.js.map +1 -0
  24. package/dist/format.d.ts +136 -0
  25. package/dist/format.js +872 -0
  26. package/dist/format.js.map +1 -0
  27. package/dist/index.d.ts +120 -0
  28. package/dist/index.js +507 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/internal.d.ts +1 -0
  31. package/dist/internal.js +4 -0
  32. package/dist/internal.js.map +1 -0
  33. package/dist/parser/ids.d.ts +4 -0
  34. package/dist/parser/ids.js +172 -0
  35. package/dist/parser/ids.js.map +1 -0
  36. package/dist/parser/imports.d.ts +2 -0
  37. package/dist/parser/imports.js +28 -0
  38. package/dist/parser/imports.js.map +1 -0
  39. package/dist/parser/interface.d.ts +10 -0
  40. package/dist/parser/interface.js +93 -0
  41. package/dist/parser/interface.js.map +1 -0
  42. package/dist/parser/kielerWording.d.ts +2 -0
  43. package/dist/parser/kielerWording.js +196 -0
  44. package/dist/parser/kielerWording.js.map +1 -0
  45. package/dist/parser/lexer.d.ts +25 -0
  46. package/dist/parser/lexer.js +334 -0
  47. package/dist/parser/lexer.js.map +1 -0
  48. package/dist/parser/parser.d.ts +29 -0
  49. package/dist/parser/parser.js +3249 -0
  50. package/dist/parser/parser.js.map +1 -0
  51. package/dist/parser/resolve.d.ts +46 -0
  52. package/dist/parser/resolve.js +919 -0
  53. package/dist/parser/resolve.js.map +1 -0
  54. package/dist/parser/source.d.ts +15 -0
  55. package/dist/parser/source.js +42 -0
  56. package/dist/parser/source.js.map +1 -0
  57. package/dist/parser/validate.d.ts +5 -0
  58. package/dist/parser/validate.js +1430 -0
  59. package/dist/parser/validate.js.map +1 -0
  60. package/dist/sim/abortRegions.d.ts +9 -0
  61. package/dist/sim/abortRegions.js +192 -0
  62. package/dist/sim/abortRegions.js.map +1 -0
  63. package/dist/sim/analysis.d.ts +113 -0
  64. package/dist/sim/analysis.js +1104 -0
  65. package/dist/sim/analysis.js.map +1 -0
  66. package/dist/sim/codegen.d.ts +30 -0
  67. package/dist/sim/codegen.js +730 -0
  68. package/dist/sim/codegen.js.map +1 -0
  69. package/dist/sim/compile.d.ts +43 -0
  70. package/dist/sim/compile.js +1062 -0
  71. package/dist/sim/compile.js.map +1 -0
  72. package/dist/sim/deps.d.ts +73 -0
  73. package/dist/sim/deps.js +481 -0
  74. package/dist/sim/deps.js.map +1 -0
  75. package/dist/sim/describe.d.ts +22 -0
  76. package/dist/sim/describe.js +272 -0
  77. package/dist/sim/describe.js.map +1 -0
  78. package/dist/sim/describePreemption.d.ts +22 -0
  79. package/dist/sim/describePreemption.js +90 -0
  80. package/dist/sim/describePreemption.js.map +1 -0
  81. package/dist/sim/describeStructure.d.ts +75 -0
  82. package/dist/sim/describeStructure.js +293 -0
  83. package/dist/sim/describeStructure.js.map +1 -0
  84. package/dist/sim/eval.d.ts +99 -0
  85. package/dist/sim/eval.js +644 -0
  86. package/dist/sim/eval.js.map +1 -0
  87. package/dist/sim/exec.d.ts +212 -0
  88. package/dist/sim/exec.js +874 -0
  89. package/dist/sim/exec.js.map +1 -0
  90. package/dist/sim/fold.d.ts +2 -0
  91. package/dist/sim/fold.js +40 -0
  92. package/dist/sim/fold.js.map +1 -0
  93. package/dist/sim/goblock.d.ts +16 -0
  94. package/dist/sim/goblock.js +171 -0
  95. package/dist/sim/goblock.js.map +1 -0
  96. package/dist/sim/guardIndices.d.ts +13 -0
  97. package/dist/sim/guardIndices.js +137 -0
  98. package/dist/sim/guardIndices.js.map +1 -0
  99. package/dist/sim/index.d.ts +43 -0
  100. package/dist/sim/index.js +138 -0
  101. package/dist/sim/index.js.map +1 -0
  102. package/dist/sim/lower.d.ts +33 -0
  103. package/dist/sim/lower.js +716 -0
  104. package/dist/sim/lower.js.map +1 -0
  105. package/dist/sim/memory.d.ts +47 -0
  106. package/dist/sim/memory.js +328 -0
  107. package/dist/sim/memory.js.map +1 -0
  108. package/dist/sim/model.d.ts +487 -0
  109. package/dist/sim/model.js +772 -0
  110. package/dist/sim/model.js.map +1 -0
  111. package/dist/sim/passes/abort.d.ts +2 -0
  112. package/dist/sim/passes/abort.js +269 -0
  113. package/dist/sim/passes/abort.js.map +1 -0
  114. package/dist/sim/passes/abortRegion.d.ts +10 -0
  115. package/dist/sim/passes/abortRegion.js +62 -0
  116. package/dist/sim/passes/abortRegion.js.map +1 -0
  117. package/dist/sim/passes/arrayAssignment.d.ts +2 -0
  118. package/dist/sim/passes/arrayAssignment.js +147 -0
  119. package/dist/sim/passes/arrayAssignment.js.map +1 -0
  120. package/dist/sim/passes/codeEffects.d.ts +2 -0
  121. package/dist/sim/passes/codeEffects.js +14 -0
  122. package/dist/sim/passes/codeEffects.js.map +1 -0
  123. package/dist/sim/passes/complexFinalState.d.ts +4 -0
  124. package/dist/sim/passes/complexFinalState.js +77 -0
  125. package/dist/sim/passes/complexFinalState.js.map +1 -0
  126. package/dist/sim/passes/connector.d.ts +2 -0
  127. package/dist/sim/passes/connector.js +18 -0
  128. package/dist/sim/passes/connector.js.map +1 -0
  129. package/dist/sim/passes/contained.d.ts +37 -0
  130. package/dist/sim/passes/contained.js +198 -0
  131. package/dist/sim/passes/contained.js.map +1 -0
  132. package/dist/sim/passes/context.d.ts +39 -0
  133. package/dist/sim/passes/context.js +3 -0
  134. package/dist/sim/passes/context.js.map +1 -0
  135. package/dist/sim/passes/countDelay.d.ts +2 -0
  136. package/dist/sim/passes/countDelay.js +51 -0
  137. package/dist/sim/passes/countDelay.js.map +1 -0
  138. package/dist/sim/passes/dataflow.d.ts +11 -0
  139. package/dist/sim/passes/dataflow.js +319 -0
  140. package/dist/sim/passes/dataflow.js.map +1 -0
  141. package/dist/sim/passes/deferred.d.ts +2 -0
  142. package/dist/sim/passes/deferred.js +345 -0
  143. package/dist/sim/passes/deferred.js.map +1 -0
  144. package/dist/sim/passes/detect.d.ts +10 -0
  145. package/dist/sim/passes/detect.js +33 -0
  146. package/dist/sim/passes/detect.js.map +1 -0
  147. package/dist/sim/passes/during.d.ts +2 -0
  148. package/dist/sim/passes/during.js +67 -0
  149. package/dist/sim/passes/during.js.map +1 -0
  150. package/dist/sim/passes/entry.d.ts +5 -0
  151. package/dist/sim/passes/entry.js +93 -0
  152. package/dist/sim/passes/entry.js.map +1 -0
  153. package/dist/sim/passes/enum.d.ts +2 -0
  154. package/dist/sim/passes/enum.js +22 -0
  155. package/dist/sim/passes/enum.js.map +1 -0
  156. package/dist/sim/passes/exit.d.ts +4 -0
  157. package/dist/sim/passes/exit.js +120 -0
  158. package/dist/sim/passes/exit.js.map +1 -0
  159. package/dist/sim/passes/finalRegion.d.ts +2 -0
  160. package/dist/sim/passes/finalRegion.js +21 -0
  161. package/dist/sim/passes/finalRegion.js.map +1 -0
  162. package/dist/sim/passes/followedBy.d.ts +2 -0
  163. package/dist/sim/passes/followedBy.js +78 -0
  164. package/dist/sim/passes/followedBy.js.map +1 -0
  165. package/dist/sim/passes/forRegion.d.ts +9 -0
  166. package/dist/sim/passes/forRegion.js +230 -0
  167. package/dist/sim/passes/forRegion.js.map +1 -0
  168. package/dist/sim/passes/history.d.ts +12 -0
  169. package/dist/sim/passes/history.js +115 -0
  170. package/dist/sim/passes/history.js.map +1 -0
  171. package/dist/sim/passes/hostCode.d.ts +2 -0
  172. package/dist/sim/passes/hostCode.js +152 -0
  173. package/dist/sim/passes/hostCode.js.map +1 -0
  174. package/dist/sim/passes/index.d.ts +4 -0
  175. package/dist/sim/passes/index.js +84 -0
  176. package/dist/sim/passes/index.js.map +1 -0
  177. package/dist/sim/passes/inheritance.d.ts +8 -0
  178. package/dist/sim/passes/inheritance.js +233 -0
  179. package/dist/sim/passes/inheritance.js.map +1 -0
  180. package/dist/sim/passes/initOperator.d.ts +2 -0
  181. package/dist/sim/passes/initOperator.js +68 -0
  182. package/dist/sim/passes/initOperator.js.map +1 -0
  183. package/dist/sim/passes/initialization.d.ts +2 -0
  184. package/dist/sim/passes/initialization.js +69 -0
  185. package/dist/sim/passes/initialization.js.map +1 -0
  186. package/dist/sim/passes/ode.d.ts +2 -0
  187. package/dist/sim/passes/ode.js +14 -0
  188. package/dist/sim/passes/ode.js.map +1 -0
  189. package/dist/sim/passes/period.d.ts +2 -0
  190. package/dist/sim/passes/period.js +106 -0
  191. package/dist/sim/passes/period.js.map +1 -0
  192. package/dist/sim/passes/prTransitions.d.ts +2 -0
  193. package/dist/sim/passes/prTransitions.js +12 -0
  194. package/dist/sim/passes/prTransitions.js.map +1 -0
  195. package/dist/sim/passes/pre.d.ts +4 -0
  196. package/dist/sim/passes/pre.js +326 -0
  197. package/dist/sim/passes/pre.js.map +1 -0
  198. package/dist/sim/passes/quirks.d.ts +2 -0
  199. package/dist/sim/passes/quirks.js +169 -0
  200. package/dist/sim/passes/quirks.js.map +1 -0
  201. package/dist/sim/passes/reference.d.ts +60 -0
  202. package/dist/sim/passes/reference.js +386 -0
  203. package/dist/sim/passes/reference.js.map +1 -0
  204. package/dist/sim/passes/regionActions.d.ts +2 -0
  205. package/dist/sim/passes/regionActions.js +56 -0
  206. package/dist/sim/passes/regionActions.js.map +1 -0
  207. package/dist/sim/passes/sequentialFollowedBy.d.ts +2 -0
  208. package/dist/sim/passes/sequentialFollowedBy.js +72 -0
  209. package/dist/sim/passes/sequentialFollowedBy.js.map +1 -0
  210. package/dist/sim/passes/signal.d.ts +2 -0
  211. package/dist/sim/passes/signal.js +230 -0
  212. package/dist/sim/passes/signal.js.map +1 -0
  213. package/dist/sim/passes/static.d.ts +5 -0
  214. package/dist/sim/passes/static.js +67 -0
  215. package/dist/sim/passes/static.js.map +1 -0
  216. package/dist/sim/passes/suspend.d.ts +10 -0
  217. package/dist/sim/passes/suspend.js +71 -0
  218. package/dist/sim/passes/suspend.js.map +1 -0
  219. package/dist/sim/passes/termination.d.ts +9 -0
  220. package/dist/sim/passes/termination.js +69 -0
  221. package/dist/sim/passes/termination.js.map +1 -0
  222. package/dist/sim/passes/timedAutomata.d.ts +10 -0
  223. package/dist/sim/passes/timedAutomata.js +437 -0
  224. package/dist/sim/passes/timedAutomata.js.map +1 -0
  225. package/dist/sim/passes/unpackClasses.d.ts +2 -0
  226. package/dist/sim/passes/unpackClasses.js +54 -0
  227. package/dist/sim/passes/unpackClasses.js.map +1 -0
  228. package/dist/sim/passes/userSchedule.d.ts +2 -0
  229. package/dist/sim/passes/userSchedule.js +43 -0
  230. package/dist/sim/passes/userSchedule.js.map +1 -0
  231. package/dist/sim/passes/weakSuspend.d.ts +2 -0
  232. package/dist/sim/passes/weakSuspend.js +145 -0
  233. package/dist/sim/passes/weakSuspend.js.map +1 -0
  234. package/dist/sim/preemptionLog.d.ts +41 -0
  235. package/dist/sim/preemptionLog.js +133 -0
  236. package/dist/sim/preemptionLog.js.map +1 -0
  237. package/dist/sim/random.d.ts +12 -0
  238. package/dist/sim/random.js +40 -0
  239. package/dist/sim/random.js.map +1 -0
  240. package/dist/sim/reasons.d.ts +29 -0
  241. package/dist/sim/reasons.js +168 -0
  242. package/dist/sim/reasons.js.map +1 -0
  243. package/dist/sim/scg.d.ts +124 -0
  244. package/dist/sim/scg.js +723 -0
  245. package/dist/sim/scg.js.map +1 -0
  246. package/dist/sim/sfr.d.ts +4 -0
  247. package/dist/sim/sfr.js +264 -0
  248. package/dist/sim/sfr.js.map +1 -0
  249. package/dist/sim/stringConditions.d.ts +3 -0
  250. package/dist/sim/stringConditions.js +42 -0
  251. package/dist/sim/stringConditions.js.map +1 -0
  252. package/dist/sim/structure/copy.d.ts +4 -0
  253. package/dist/sim/structure/copy.js +140 -0
  254. package/dist/sim/structure/copy.js.map +1 -0
  255. package/dist/sim/structure/delays.d.ts +30 -0
  256. package/dist/sim/structure/delays.js +127 -0
  257. package/dist/sim/structure/delays.js.map +1 -0
  258. package/dist/sim/structure/instance.d.ts +15 -0
  259. package/dist/sim/structure/instance.js +69 -0
  260. package/dist/sim/structure/instance.js.map +1 -0
  261. package/dist/sim/structure/methods.d.ts +19 -0
  262. package/dist/sim/structure/methods.js +550 -0
  263. package/dist/sim/structure/methods.js.map +1 -0
  264. package/dist/sim/structure/rewrite.d.ts +20 -0
  265. package/dist/sim/structure/rewrite.js +113 -0
  266. package/dist/sim/structure/rewrite.js.map +1 -0
  267. package/dist/sim/structure/track.d.ts +22 -0
  268. package/dist/sim/structure/track.js +123 -0
  269. package/dist/sim/structure/track.js.map +1 -0
  270. package/dist/sim/tracker.d.ts +77 -0
  271. package/dist/sim/tracker.js +265 -0
  272. package/dist/sim/tracker.js.map +1 -0
  273. package/dist/sim/values.d.ts +31 -0
  274. package/dist/sim/values.js +103 -0
  275. package/dist/sim/values.js.map +1 -0
  276. package/dist/types.d.ts +670 -0
  277. package/dist/types.js +9 -0
  278. package/dist/types.js.map +1 -0
  279. package/package.json +58 -3
@@ -0,0 +1,437 @@
1
+ // KIELER's Timed Automata processor (sccharts/processors/TimedAutomata.xtend). Owner: the structure workstream.
2
+ // structure.md S-35 .. S-41.
3
+ //
4
+ // A chart with clocks gets an input `deltaT` (the time since the previous tick, given by the environment) and an
5
+ // output `sleepT` (how long the environment may wait before the next tick), both of the clock type (float, or int with
6
+ // @IntegerClockType). For every clock, the states of the one region whose transitions test it (looking through
7
+ // wrapper states) get a during action `t += deltaT` (delayed: not in the tick they are entered) and, for every bound of
8
+ // their timed transitions, an immediate during action `if t < b do sleepT min= b - t`; the root starts every tick
9
+ // with `sleepT = maxSleep` (1000, or @DefaultSleep). @SimulateSleep sets `deltaT = pre(sleepT)` after the first tick,
10
+ // @NoSleep drops sleepT. A clock tested by several regions, or by a state and inside it, is rejected, unless
11
+ // @ClocksUseSD: then the declaring state advances the clock and KIELER's ClockIUR schedule orders its writes
12
+ // (clockWithSD). @DeviationOutput and @Logical clocks are not simulated.
13
+ import { allContainedStates, allStates, CVar, controlflowRegions, copyExpr, createAction, createImmediateDuringAction, ref, } from "../model.js";
14
+ export const timedAutomata = {
15
+ id: 'de.cau.cs.kieler.sccharts.processors.timedautomata',
16
+ name: 'Timed Automata',
17
+ owner: 'structure',
18
+ run(ctx) {
19
+ transform(ctx);
20
+ },
21
+ };
22
+ const MAX_SLEEP_DEFAULT = 1000;
23
+ /** Every annotation in the chart as written (KIELER searches `rootState.eAllContents`), its instances' included. */
24
+ export function chartAnnotations(ctx) {
25
+ const index = ctx.shared.index;
26
+ const charts = [];
27
+ const main = ctx.root.origin ? index?.states.get(ctx.root.origin) : undefined;
28
+ if (main)
29
+ charts.push(main);
30
+ for (const r of ctx.shared.instances ?? [])
31
+ charts.push(r.chart);
32
+ const out = [];
33
+ const visit = (value) => {
34
+ if (Array.isArray(value)) {
35
+ value.forEach(visit);
36
+ return;
37
+ }
38
+ if (!value || typeof value !== 'object')
39
+ return;
40
+ const obj = value;
41
+ if (obj.kind === 'annotation')
42
+ out.push(obj);
43
+ for (const [k, v] of Object.entries(obj))
44
+ if (k !== 'span' && v && typeof v === 'object')
45
+ visit(v);
46
+ };
47
+ charts.forEach(visit);
48
+ return out;
49
+ }
50
+ function named(list, ...names) {
51
+ const lower = names.map(n => n.toLowerCase());
52
+ return list.find(a => lower.includes(a.name.toLowerCase()));
53
+ }
54
+ function isClock(v) {
55
+ return v.type === 'clock' && !v.declKind;
56
+ }
57
+ function transform(ctx) {
58
+ const root = ctx.root;
59
+ const states = allStates(root);
60
+ if (!states.some(s => s.decls.some(isClock)))
61
+ return;
62
+ const annotations = chartAnnotations(ctx);
63
+ const intClock = [...annotations].reverse().find(a => ['integralclocktype', 'integerclocktype'].includes(a.name.toLowerCase()));
64
+ const clockType = intClock ? 'int' : 'float';
65
+ const lit = (n) => (clockType === 'int' ? { k: 'lit', t: 'int', v: Math.trunc(n) } : { k: 'lit', t: 'float', v: Math.fround(n) });
66
+ const noSleep = !!named(annotations, 'NoSleep');
67
+ const simulate = !!named(annotations, 'SimulateSleep');
68
+ const useSD = !!named(annotations, 'ClocksUseSD');
69
+ const unsupported = named(annotations, 'DeviationOutput') ??
70
+ (states.some(s => s.decls.some(v => isClock(v) && v.tags.has('@Logical'))) ? { name: 'Logical' } : undefined);
71
+ if (unsupported) {
72
+ ctx.report({
73
+ severity: 'info', code: 'unsupported', span: unsupported.span,
74
+ message: `The guide's simulator cannot run \`@${unsupported.name}\` yet`,
75
+ hint: 'This experimental part of KIELER\'s Timed Automata transformation is not implemented in the simulator. The official KIELER tools can run this chart.',
76
+ });
77
+ return;
78
+ }
79
+ const sleepAnnotation = named(annotations, 'DefaultSleep');
80
+ let maxSleep = MAX_SLEEP_DEFAULT;
81
+ if (sleepAnnotation) {
82
+ const value = sleepAnnotation.values[0];
83
+ if (value === undefined || sleepAnnotation.json) {
84
+ ctx.report({
85
+ severity: 'error', code: 'default-sleep', span: sleepAnnotation.span,
86
+ message: `\`@${sleepAnnotation.name}\` needs a value, e.g. \`@${sleepAnnotation.name} 100\``,
87
+ kieler: `@${sleepAnnotation.name} needs a ${sleepAnnotation.json ? 'plain value, not a JSON object' : 'value'}, e.g. @${sleepAnnotation.name} 100.`,
88
+ hint: `Write the default sleep time after \`@${sleepAnnotation.name}\`, or remove the annotation to keep the default of ${MAX_SLEEP_DEFAULT}. The official KIELER compiler cannot compile this either.`,
89
+ });
90
+ return;
91
+ }
92
+ const n = Number(value);
93
+ if (Number.isFinite(n))
94
+ maxSleep = n;
95
+ }
96
+ // deltaT (input) and sleepT (output): the chart's own, if declared with these names, else generated.
97
+ const own = (name) => root.decls.find(v => v.name.toLowerCase() === name.toLowerCase());
98
+ let deltaT = own('deltaT');
99
+ if (deltaT) {
100
+ if (!deltaT.init)
101
+ deltaT.init = lit(0);
102
+ if (!deltaT.input || (deltaT.type !== clockType && deltaT.type !== 'clock-time'))
103
+ ctx.report(clockVarError('deltaT', 'input', clockType, deltaT));
104
+ }
105
+ else {
106
+ deltaT = generated('deltaT', clockType, root, lit(0));
107
+ deltaT.input = true;
108
+ }
109
+ let sleepT = own('sleepT');
110
+ if (sleepT) {
111
+ if (!sleepT.init)
112
+ sleepT.init = lit(0);
113
+ if (!sleepT.output || (sleepT.type !== clockType && sleepT.type !== 'clock-time'))
114
+ ctx.report(clockVarError('sleepT', 'output', clockType, sleepT));
115
+ }
116
+ else if (!noSleep) {
117
+ sleepT = generated('sleepT', clockType, root, lit(0));
118
+ sleepT.output = true;
119
+ }
120
+ if (!noSleep && sleepT) {
121
+ const start = createImmediateDuringAction(root);
122
+ start.about = sleepT.decl;
123
+ start.effects.push({ k: 'assign', ref: ref(sleepT), op: '=', expr: lit(maxSleep), o: { hidden: true, by: sleepT.decl } });
124
+ if (simulate) {
125
+ const sim = createAction(root, 'during');
126
+ sim.about = deltaT.decl;
127
+ sim.effects.push({ k: 'assign', ref: ref(deltaT), op: '=', expr: { k: 'op', op: 'pre', args: [ref(sleepT)] }, o: { by: deltaT.decl } });
128
+ }
129
+ }
130
+ // `time` variables get the clock type.
131
+ for (const s of states)
132
+ for (const scope of [s, ...s.regions])
133
+ for (const v of scope.decls)
134
+ if (v.type === 'clock-time')
135
+ v.type = clockType;
136
+ for (const state of states.filter(s => s.decls.some(isClock))) {
137
+ for (const clock of state.decls.filter(isClock)) {
138
+ clock.type = clockType;
139
+ if (!clock.init)
140
+ clock.init = lit(0);
141
+ if (clock.dims.length) {
142
+ ctx.report({ severity: 'error', code: 'clock-array', span: clock.span, message: `\`${clock.name}\` is an array of clocks, which KIELER cannot handle yet`, kieler: 'Cannot yet handle array of clocks.', hint: 'Declare one clock per timer.' });
143
+ continue;
144
+ }
145
+ if (clock.tags.has('@Passive'))
146
+ continue;
147
+ if (useSD) {
148
+ clockWithSD(state, clock, deltaT, noSleep ? undefined : sleepT, ctx, lit);
149
+ continue;
150
+ }
151
+ // The region whose states test the clock (looking through single-state wrappers).
152
+ const regions = controlflowRegions(state);
153
+ let region = regions[0];
154
+ if (regions.length > 1) {
155
+ const using = [];
156
+ for (const r of regions) {
157
+ let test = r;
158
+ while (test.states.length === 1 && test.states[0].out.length === 0 && controlflowRegions(test.states[0]).length === 1) {
159
+ test = controlflowRegions(test.states[0])[0];
160
+ }
161
+ if (test.states.some(s => s.out.some(t => t.trigger && mentionsVar(t.trigger, clock))))
162
+ using.push(test);
163
+ }
164
+ region = using[0];
165
+ if (using.length > 1) {
166
+ // At the second region's transition that tests the clock (the first is where the clock goes).
167
+ const reading = using.slice(0, 2).map(r => r.states.flatMap(s => s.out).find(t => t.trigger && mentionsVar(t.trigger, clock)));
168
+ const second = reading[1];
169
+ const d = sharedClock(state, clock, `Clock \`${clock.name}\` is read by several concurrent regions of \`${state.name}\`.`, 'Cannot handle concurrent timed automata using the same clock. Add @ClocksUseSD annotation for experimental support based on schduling directives.', 'Declare one clock per region and reset it on entry.');
170
+ d.span = second?.trigger?.span ?? second?.span ?? clock.span;
171
+ d.related = [...new Set([...reading.flatMap(t => (t?.origin ? [t.origin] : [])), ...(d.related ?? [])])];
172
+ ctx.report(d);
173
+ }
174
+ }
175
+ if (!region) {
176
+ const d = sharedClock(state, clock, `Clock \`${clock.name}\` is used across concurrent or nested regions of \`${state.name}\`.`, 'Cannot handle concurrent or hierarchical timed automata using the same clock. Add @ClocksUseSD annotation for experimental support based on schduling directives.', 'Declare a separate clock for each region.');
177
+ d.span = clock.span;
178
+ ctx.report(d);
179
+ continue;
180
+ }
181
+ for (const sub of region.states.filter(s => !s.connector)) {
182
+ const inner = sub.actions.some(a => a.kind === 'during' || a.kind === 'exit' || a.kind === 'entry') || sub.regions.length > 0;
183
+ if (inner) {
184
+ const actionReads = sub.actions.some(a => a.trigger && mentionsVar(a.trigger, clock));
185
+ const insideReads = controlflowRegions(sub).some(r => regionMentions(r, clock));
186
+ if (actionReads || insideReads) {
187
+ ctx.report(sharedClock(sub, clock, `Clock \`${clock.name}\` is read both by \`${sub.name}\` and inside it.`, 'Cannot handle hierarchical timed automata. Add @ClocksUseSD annotation for experimental support based on SDs.', 'Give the inner regions their own clock.'));
188
+ }
189
+ }
190
+ // Time passes: a delayed during action, so not in the tick the state is entered (S-36).
191
+ const progress = createAction(sub, 'during');
192
+ progress.about = clock.decl;
193
+ progress.effects.push({ k: 'assign', ref: ref(clock), op: '+=', expr: ref(deltaT), o: { by: clock.decl, span: clock.span } });
194
+ if (!noSleep && sleepT)
195
+ handleSleep(ctx, sub, clock, sleepT, lit);
196
+ }
197
+ }
198
+ }
199
+ }
200
+ /**
201
+ * @ClocksUseSD (KIELER's "experimental support based on scheduling directives"): the clock may be shared by
202
+ * concurrent and nested regions. Its declaring state advances it once per tick (a delayed during action), and a
203
+ * schedule ClockIUR orders the clock's writes: the increment (priority 0) before resets `t = ...` (1) before
204
+ * updates (2, confluent with each other). Every state inside asks for sleep times for its timeouts.
205
+ */
206
+ function clockWithSD(state, clock, deltaT, sleepT, ctx, lit) {
207
+ const group = { name: `${clock.name}SD`, protocols: ['conflict', 'conflict', 'confluent'] };
208
+ const schedule = (f, priority) => {
209
+ f.o = { ...f.o, schedule: [...(f.o.schedule ?? []), { group, priority }] };
210
+ };
211
+ for (const s of allStates(state)) {
212
+ for (const scope of [s, ...s.regions]) {
213
+ for (const a of scope.actions)
214
+ for (const f of a.effects)
215
+ if (f.k === 'assign' && f.ref.v === clock)
216
+ schedule(f, f.op === '=' ? 1 : 2);
217
+ }
218
+ for (const t of s.out)
219
+ for (const f of t.effects)
220
+ if (f.k === 'assign' && f.ref.v === clock)
221
+ schedule(f, f.op === '=' ? 1 : 2);
222
+ if (sleepT && !s.connector)
223
+ handleSleep(ctx, s, clock, sleepT, lit);
224
+ }
225
+ const progress = createAction(state, 'during');
226
+ progress.about = clock.decl;
227
+ const increment = { k: 'assign', ref: ref(clock), op: '+=', expr: ref(deltaT), o: { by: clock.decl, span: clock.span } };
228
+ schedule(increment, 0);
229
+ progress.effects.push(increment);
230
+ }
231
+ function generated(name, type, root, init) {
232
+ const v = new CVar(name, type);
233
+ v.init = init;
234
+ v.scope = root;
235
+ // A tag, not a role: the executor reports variables without a role as the chart's own (TickResult.values).
236
+ v.tags.add(`#${name}`);
237
+ v.decl = `${root.origin ?? root.name}$${name}`;
238
+ root.decls.push(v);
239
+ return v;
240
+ }
241
+ function clockVarError(name, kind, type, v) {
242
+ return {
243
+ severity: 'error', code: 'clock-variable', span: v.span, related: v.decl ? [v.decl] : undefined,
244
+ message: `\`${name}\` is the time variable of timed charts: it must be ${kind === 'input' ? 'an input' : 'an output'} of type ${type}`,
245
+ kieler: `A variable with name ${name} already exists and is not an ${kind} variable of type ${type}`,
246
+ hint: `KIELER uses \`${name}\` for ${name === 'deltaT' ? 'the time since the previous tick' : 'the time until the next tick'} in charts with clocks. Rename your variable, or declare it as \`${kind} ${type} ${name}\`.`,
247
+ };
248
+ }
249
+ function sharedClock(state, clock, lab, kieler, hint) {
250
+ return {
251
+ severity: 'error', code: 'shared-clock', related: [state.origin ?? state.about, clock.decl].filter((x) => !!x),
252
+ message: lab, kieler, hint: `${hint} KIELER's timed automata give every clock to one region, which advances it.`,
253
+ };
254
+ }
255
+ function mentionsVar(e, v) {
256
+ let found = false;
257
+ const visit = (x) => {
258
+ if (found)
259
+ return;
260
+ if (x.k === 'ref') {
261
+ if (x.v === v)
262
+ found = true;
263
+ x.idx.forEach(visit);
264
+ }
265
+ else if (x.k === 'op')
266
+ x.args.forEach(visit);
267
+ else if (x.k === 'vector')
268
+ x.values.forEach(visit);
269
+ else if (x.k === 'call')
270
+ x.args.forEach(visit);
271
+ };
272
+ visit(e);
273
+ return found;
274
+ }
275
+ /** Does anything inside the region use the variable (KIELER's eAllContents check)? */
276
+ function regionMentions(r, v) {
277
+ for (const s of allContainedStates(r)) {
278
+ for (const a of [...s.actions, ...s.regions.flatMap(x => x.actions)]) {
279
+ if (a.trigger && mentionsVar(a.trigger, v))
280
+ return true;
281
+ if (a.effects.some(f => effectMentions(f, v)))
282
+ return true;
283
+ }
284
+ for (const t of s.out) {
285
+ if (t.trigger && mentionsVar(t.trigger, v))
286
+ return true;
287
+ if (t.effects.some(f => effectMentions(f, v)))
288
+ return true;
289
+ }
290
+ }
291
+ return false;
292
+ }
293
+ function effectMentions(f, v) {
294
+ if (f.k === 'assign')
295
+ return f.ref.v === v || (!!f.expr && mentionsVar(f.expr, v));
296
+ if (f.k === 'emit')
297
+ return !!f.value && mentionsVar(f.value, v);
298
+ return false;
299
+ }
300
+ /** KIELER's handleSleep: sleep requests for the bounds of the state's timed transitions (S-38). */
301
+ function handleSleep(ctx, state, clock, sleepT, lit) {
302
+ const constraints = [];
303
+ const complex = [];
304
+ for (const t of state.out) {
305
+ if (!t.trigger)
306
+ continue;
307
+ const visit = (e, parent, grand) => {
308
+ if (e.k === 'ref') {
309
+ if (e.v === clock) {
310
+ if (parent?.k === 'op' && parent.args.length === 2) {
311
+ const refs = parent.args.filter(a => a.k === 'ref').length;
312
+ const values = parent.args.filter(a => a.k === 'lit').length;
313
+ if (refs === 1 && values === 1)
314
+ constraints.push({ transition: t, op: parent, container: grand });
315
+ else
316
+ complex.push(parent);
317
+ }
318
+ else {
319
+ ctx.report({
320
+ severity: 'error', code: 'timing-constraint', span: e.span, related: t.origin ? [t.origin] : undefined,
321
+ message: `\`${clock.name}\` must be compared with a value here (for example \`${clock.name} >= 300\`)`,
322
+ kieler: 'Malformed timing constraint.',
323
+ hint: 'KIELER works out the sleep time from comparisons of the clock with a value, so a clock in a trigger has to be one side of such a comparison.',
324
+ });
325
+ }
326
+ }
327
+ e.idx.forEach(i => visit(i, e, parent));
328
+ }
329
+ else if (e.k === 'op')
330
+ e.args.forEach(a => visit(a, e, parent));
331
+ };
332
+ visit(t.trigger, undefined, undefined);
333
+ }
334
+ const sleepFor = (bound) => {
335
+ const during = createImmediateDuringAction(state);
336
+ during.about = clock.decl;
337
+ during.trigger = { k: 'op', op: '<', args: [ref(clock), bound] };
338
+ during.effects.push({ k: 'assign', ref: ref(sleepT), op: 'min=', expr: { k: 'op', op: '-', args: [copyExpr(bound), ref(clock)] }, o: { hidden: true, by: sleepT.decl } });
339
+ };
340
+ // 1. Comparisons with an expression: `t >= e` or `e <= t`.
341
+ for (const c of complex) {
342
+ const [a, b] = c.args;
343
+ let exp;
344
+ if (a.k === 'ref' && a.v === clock)
345
+ exp = b;
346
+ if (b.k === 'ref' && b.v === clock)
347
+ exp = a;
348
+ if (!exp) {
349
+ ctx.report({ severity: 'error', code: 'timing-constraint', span: c.span, message: 'This timing constraint does not compare the clock', kieler: 'Malformed timing constraint. No reference to clock.' });
350
+ }
351
+ else if (!((c.op === '>=' && exp === b) || (c.op === '<=' && exp === a))) {
352
+ ctx.report({
353
+ severity: 'error', code: 'timing-constraint', span: c.span,
354
+ message: `KIELER only handles \`${clock.name} >= value\` (or \`value <= ${clock.name}\`) here, not \`${c.op}\``,
355
+ kieler: `Malformed timing constraint. Operator ${c.op} not supported in clock comparison.`,
356
+ hint: `Write the timeout as \`${clock.name} >= value\`.`,
357
+ });
358
+ }
359
+ else {
360
+ sleepFor(copyExpr(exp));
361
+ }
362
+ }
363
+ // 2. Comparisons with a literal.
364
+ const value = (c) => {
365
+ const v = c.op.args.find(x => x.k === 'lit');
366
+ return v?.k === 'lit' && typeof v.v === 'number' ? v.v : 0;
367
+ };
368
+ const thresholds = [];
369
+ if (constraints.length === 1) {
370
+ const c = constraints[0];
371
+ let lower = 0;
372
+ if (c.op.op === '>=' || c.op.op === '>')
373
+ lower = value(c);
374
+ if (c.op.op === '>')
375
+ lower++;
376
+ thresholds.push(lower);
377
+ }
378
+ else if (!insignificant(constraints)) {
379
+ for (const t of [...new Set(constraints.map(c => c.transition))]) {
380
+ const own = constraints.filter(c => c.transition === t);
381
+ const bounds = [];
382
+ for (const c of own) {
383
+ if (c.op.op === '>=')
384
+ bounds.push(value(c));
385
+ else if (c.op.op !== '<=' && c.op.op !== '<') {
386
+ ctx.report({
387
+ severity: 'error', code: 'timing-constraint', span: c.op.span, related: t.origin ? [t.origin] : undefined,
388
+ message: `KIELER cannot work out the sleep time for \`${clock.name} ${c.op.op} ...\` when the state has other timeouts`,
389
+ kieler: `Malformed timing constraint. Operator ${c.op.op} not supported.`,
390
+ hint: `Write the timeouts of a state as \`${clock.name} >= value\`.`,
391
+ });
392
+ }
393
+ }
394
+ // `t >= a || t >= b` (exactly two, directly under one ||) asks for the larger bound only (S-38).
395
+ const parent = own[0]?.container;
396
+ if (own.length === 2 && parent?.k === 'op' && parent.op === '||' && own.every(c => c.container === parent)) {
397
+ if (bounds.length)
398
+ thresholds.push(Math.max(...bounds));
399
+ }
400
+ else {
401
+ thresholds.push(...bounds);
402
+ }
403
+ }
404
+ }
405
+ thresholds.sort((a, b) => a - b);
406
+ for (const t of thresholds)
407
+ sleepFor(lit(t));
408
+ }
409
+ /** KIELER's isInsignificant: `g && t >= v` and `g && t < v` on two transitions tell nothing about sleeping. */
410
+ function insignificant(cs) {
411
+ if (cs.length !== 2 || cs[0].transition === cs[1].transition)
412
+ return false;
413
+ const [a, b] = cs;
414
+ const pa = a.container;
415
+ const pb = b.container;
416
+ if (pa?.k !== 'op' || pb?.k !== 'op' || pa.op !== '&&' || pb.op !== '&&')
417
+ return false;
418
+ const ga = pa.args.find(x => x !== a.op);
419
+ const gb = pb.args.find(x => x !== b.op);
420
+ const va = a.op.args.find(x => x.k === 'lit');
421
+ const vb = b.op.args.find(x => x.k === 'lit');
422
+ if (!ga || !gb || va?.k !== 'lit' || vb?.k !== 'lit')
423
+ return false;
424
+ return sameShape(ga, gb) && va.v === vb.v && ((a.op.op === '>=' && b.op.op === '<') || (b.op.op === '>=' && a.op.op === '<'));
425
+ }
426
+ function sameShape(a, b) {
427
+ if (a.k !== b.k)
428
+ return false;
429
+ if (a.k === 'lit' && b.k === 'lit')
430
+ return a.t === b.t && a.v === b.v;
431
+ if (a.k === 'ref' && b.k === 'ref')
432
+ return a.v === b.v && a.idx.length === b.idx.length && a.idx.every((x, i) => sameShape(x, b.idx[i]));
433
+ if (a.k === 'op' && b.k === 'op')
434
+ return a.op === b.op && a.args.length === b.args.length && a.args.every((x, i) => sameShape(x, b.args[i]));
435
+ return false;
436
+ }
437
+ //# sourceMappingURL=timedAutomata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timedAutomata.js","sourceRoot":"","sources":["../../../src/sim/passes/timedAutomata.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,6BAA6B;AAC7B,EAAE;AACF,iHAAiH;AACjH,uHAAuH;AACvH,+GAA+G;AAC/G,wHAAwH;AACxH,kHAAkH;AAClH,sHAAsH;AACtH,6GAA6G;AAC7G,6GAA6G;AAC7G,yEAAyE;AAKzE,OAAO,EACH,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,YAAY,EAAE,2BAA2B,EAAE,GAAG,GAEpH,oBAAgB;AAGjB,MAAM,CAAC,MAAM,aAAa,GAAS;IAC/B,EAAE,EAAE,oDAAoD;IACxD,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,WAAW;IAClB,GAAG,CAAC,GAAgB;QAChB,SAAS,CAAC,GAAG,CAAC,CAAA;IAClB,CAAC;CACJ,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B,oHAAoH;AACpH,MAAM,UAAU,gBAAgB,CAAC,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A;IAC7B,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACrE,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACxI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5I,OAAO,KAAK,CAAA;AAChB,CAAC","sourcesContent":["// KIELER's Timed Automata processor (sccharts/processors/TimedAutomata.xtend). Owner: the structure workstream.\n// structure.md S-35 .. S-41.\n//\n// A chart with clocks gets an input `deltaT` (the time since the previous tick, given by the environment) and an\n// output `sleepT` (how long the environment may wait before the next tick), both of the clock type (float, or int with\n// @IntegerClockType). For every clock, the states of the one region whose transitions test it (looking through\n// wrapper states) get a during action `t += deltaT` (delayed: not in the tick they are entered) and, for every bound of\n// their timed transitions, an immediate during action `if t < b do sleepT min= b - t`; the root starts every tick\n// with `sleepT = maxSleep` (1000, or @DefaultSleep). @SimulateSleep sets `deltaT = pre(sleepT)` after the first tick,\n// @NoSleep drops sleepT. A clock tested by several regions, or by a state and inside it, is rejected, unless\n// @ClocksUseSD: then the declaring state advances the clock and KIELER's ClockIUR schedule orders its writes\n// (clockWithSD). @DeviationOutput and @Logical clocks are not simulated.\n\nimport type { Annotation, Diagnostic, State } from '../../types'\nimport type { ModelIndex } from '../../parser/resolve'\nimport type { Pass, PassContext } from './context'\nimport {\n allContainedStates, allStates, CVar, controlflowRegions, copyExpr, createAction, createImmediateDuringAction, ref,\n type CEffect, type CExpr, type CRegion, type CState, type CTransition,\n} from '../model'\nimport type { InstanceRecord } from './reference'\n\nexport const timedAutomata: Pass = {\n id: 'de.cau.cs.kieler.sccharts.processors.timedautomata',\n name: 'Timed Automata',\n owner: 'structure',\n run(ctx: PassContext) {\n transform(ctx)\n },\n}\n\nconst MAX_SLEEP_DEFAULT = 1000\n\n/** Every annotation in the chart as written (KIELER searches `rootState.eAllContents`), its instances' included. */\nexport function chartAnnotations(ctx: PassContext): Annotation[] {\n const index = ctx.shared.index as ModelIndex | undefined\n const charts: State[] = []\n const main = ctx.root.origin ? index?.states.get(ctx.root.origin) : undefined\n if (main) charts.push(main)\n for (const r of (ctx.shared.instances as InstanceRecord[] | undefined) ?? []) charts.push(r.chart)\n const out: Annotation[] = []\n const visit = (value: unknown) => {\n if (Array.isArray(value)) { value.forEach(visit); return }\n if (!value || typeof value !== 'object') return\n const obj = value as Record<string, unknown>\n if (obj.kind === 'annotation') out.push(obj as unknown as Annotation)\n for (const [k, v] of Object.entries(obj)) if (k !== 'span' && v && typeof v === 'object') visit(v)\n }\n charts.forEach(visit)\n return out\n}\n\nfunction named(list: Annotation[], ...names: string[]): Annotation | undefined {\n const lower = names.map(n => n.toLowerCase())\n return list.find(a => lower.includes(a.name.toLowerCase()))\n}\n\nfunction isClock(v: CVar): boolean {\n return v.type === 'clock' && !v.declKind\n}\n\nfunction transform(ctx: PassContext) {\n const root = ctx.root\n const states = allStates(root)\n if (!states.some(s => s.decls.some(isClock))) return\n const annotations = chartAnnotations(ctx)\n const intClock = [...annotations].reverse().find(a => ['integralclocktype', 'integerclocktype'].includes(a.name.toLowerCase()))\n const clockType = intClock ? 'int' : 'float'\n const lit = (n: number): CExpr => (clockType === 'int' ? { k: 'lit', t: 'int', v: Math.trunc(n) } : { k: 'lit', t: 'float', v: Math.fround(n) })\n const noSleep = !!named(annotations, 'NoSleep')\n const simulate = !!named(annotations, 'SimulateSleep')\n const useSD = !!named(annotations, 'ClocksUseSD')\n const unsupported = named(annotations, 'DeviationOutput') ??\n (states.some(s => s.decls.some(v => isClock(v) && v.tags.has('@Logical'))) ? ({ name: 'Logical' } as Annotation) : undefined)\n if (unsupported) {\n ctx.report({\n severity: 'info', code: 'unsupported', span: unsupported.span,\n message: `The guide's simulator cannot run \\`@${unsupported.name}\\` yet`,\n hint: 'This experimental part of KIELER\\'s Timed Automata transformation is not implemented in the simulator. The official KIELER tools can run this chart.',\n })\n return\n }\n const sleepAnnotation = named(annotations, 'DefaultSleep')\n let maxSleep = MAX_SLEEP_DEFAULT\n if (sleepAnnotation) {\n const value = sleepAnnotation.values[0]\n if (value === undefined || sleepAnnotation.json) {\n ctx.report({\n severity: 'error', code: 'default-sleep', span: sleepAnnotation.span,\n message: `\\`@${sleepAnnotation.name}\\` needs a value, e.g. \\`@${sleepAnnotation.name} 100\\``,\n kieler: `@${sleepAnnotation.name} needs a ${sleepAnnotation.json ? 'plain value, not a JSON object' : 'value'}, e.g. @${sleepAnnotation.name} 100.`,\n hint: `Write the default sleep time after \\`@${sleepAnnotation.name}\\`, or remove the annotation to keep the default of ${MAX_SLEEP_DEFAULT}. The official KIELER compiler cannot compile this either.`,\n })\n return\n }\n const n = Number(value)\n if (Number.isFinite(n)) maxSleep = n\n }\n\n // deltaT (input) and sleepT (output): the chart's own, if declared with these names, else generated.\n const own = (name: string) => root.decls.find(v => v.name.toLowerCase() === name.toLowerCase())\n let deltaT = own('deltaT')\n if (deltaT) {\n if (!deltaT.init) deltaT.init = lit(0)\n if (!deltaT.input || (deltaT.type !== clockType && deltaT.type !== 'clock-time')) ctx.report(clockVarError('deltaT', 'input', clockType, deltaT))\n } else {\n deltaT = generated('deltaT', clockType, root, lit(0))\n deltaT.input = true\n }\n let sleepT = own('sleepT')\n if (sleepT) {\n if (!sleepT.init) sleepT.init = lit(0)\n if (!sleepT.output || (sleepT.type !== clockType && sleepT.type !== 'clock-time')) ctx.report(clockVarError('sleepT', 'output', clockType, sleepT))\n } else if (!noSleep) {\n sleepT = generated('sleepT', clockType, root, lit(0))\n sleepT.output = true\n }\n if (!noSleep && sleepT) {\n const start = createImmediateDuringAction(root)\n start.about = sleepT.decl\n start.effects.push({ k: 'assign', ref: ref(sleepT), op: '=', expr: lit(maxSleep), o: { hidden: true, by: sleepT.decl } })\n if (simulate) {\n const sim = createAction(root, 'during')\n sim.about = deltaT.decl\n sim.effects.push({ k: 'assign', ref: ref(deltaT), op: '=', expr: { k: 'op', op: 'pre', args: [ref(sleepT)] }, o: { by: deltaT.decl } })\n }\n }\n // `time` variables get the clock type.\n for (const s of states) for (const scope of [s, ...s.regions]) for (const v of scope.decls) if (v.type === 'clock-time') v.type = clockType\n\n for (const state of states.filter(s => s.decls.some(isClock))) {\n for (const clock of state.decls.filter(isClock)) {\n clock.type = clockType\n if (!clock.init) clock.init = lit(0)\n if (clock.dims.length) {\n ctx.report({ severity: 'error', code: 'clock-array', span: clock.span, message: `\\`${clock.name}\\` is an array of clocks, which KIELER cannot handle yet`, kieler: 'Cannot yet handle array of clocks.', hint: 'Declare one clock per timer.' })\n continue\n }\n if (clock.tags.has('@Passive')) continue\n if (useSD) {\n clockWithSD(state, clock, deltaT, noSleep ? undefined : sleepT, ctx, lit)\n continue\n }\n // The region whose states test the clock (looking through single-state wrappers).\n const regions = controlflowRegions(state)\n let region: CRegion | undefined = regions[0]\n if (regions.length > 1) {\n const using: CRegion[] = []\n for (const r of regions) {\n let test = r\n while (test.states.length === 1 && test.states[0].out.length === 0 && controlflowRegions(test.states[0]).length === 1) {\n test = controlflowRegions(test.states[0])[0]\n }\n if (test.states.some(s => s.out.some(t => t.trigger && mentionsVar(t.trigger, clock)))) using.push(test)\n }\n region = using[0]\n if (using.length > 1) {\n // At the second region's transition that tests the clock (the first is where the clock goes).\n const reading = using.slice(0, 2).map(r => r.states.flatMap(s => s.out).find(t => t.trigger && mentionsVar(t.trigger, clock)))\n const second = reading[1]\n const d = sharedClock(state, clock, `Clock \\`${clock.name}\\` is read by several concurrent regions of \\`${state.name}\\`.`,\n 'Cannot handle concurrent timed automata using the same clock. Add @ClocksUseSD annotation for experimental support based on schduling directives.',\n 'Declare one clock per region and reset it on entry.')\n d.span = second?.trigger?.span ?? second?.span ?? clock.span\n d.related = [...new Set([...reading.flatMap(t => (t?.origin ? [t.origin] : [])), ...(d.related ?? [])])]\n ctx.report(d)\n }\n }\n if (!region) {\n const d = sharedClock(state, clock, `Clock \\`${clock.name}\\` is used across concurrent or nested regions of \\`${state.name}\\`.`,\n 'Cannot handle concurrent or hierarchical timed automata using the same clock. Add @ClocksUseSD annotation for experimental support based on schduling directives.',\n 'Declare a separate clock for each region.')\n d.span = clock.span\n ctx.report(d)\n continue\n }\n for (const sub of region.states.filter(s => !s.connector)) {\n const inner = sub.actions.some(a => a.kind === 'during' || a.kind === 'exit' || a.kind === 'entry') || sub.regions.length > 0\n if (inner) {\n const actionReads = sub.actions.some(a => a.trigger && mentionsVar(a.trigger, clock))\n const insideReads = controlflowRegions(sub).some(r => regionMentions(r, clock))\n if (actionReads || insideReads) {\n ctx.report(sharedClock(sub, clock, `Clock \\`${clock.name}\\` is read both by \\`${sub.name}\\` and inside it.`,\n 'Cannot handle hierarchical timed automata. Add @ClocksUseSD annotation for experimental support based on SDs.',\n 'Give the inner regions their own clock.'))\n }\n }\n // Time passes: a delayed during action, so not in the tick the state is entered (S-36).\n const progress = createAction(sub, 'during')\n progress.about = clock.decl\n progress.effects.push({ k: 'assign', ref: ref(clock), op: '+=', expr: ref(deltaT), o: { by: clock.decl, span: clock.span } })\n if (!noSleep && sleepT) handleSleep(ctx, sub, clock, sleepT, lit)\n }\n }\n }\n}\n\n/**\n * @ClocksUseSD (KIELER's \"experimental support based on scheduling directives\"): the clock may be shared by\n * concurrent and nested regions. Its declaring state advances it once per tick (a delayed during action), and a\n * schedule ClockIUR orders the clock's writes: the increment (priority 0) before resets `t = ...` (1) before\n * updates (2, confluent with each other). Every state inside asks for sleep times for its timeouts.\n */\nfunction clockWithSD(state: CState, clock: CVar, deltaT: CVar, sleepT: CVar | undefined, ctx: PassContext, lit: (n: number) => CExpr) {\n const group: ScheduleGroup = { name: `${clock.name}SD`, protocols: ['conflict', 'conflict', 'confluent'] }\n const schedule = (f: CEffect, priority: number) => {\n f.o = { ...f.o, schedule: [...(f.o.schedule ?? []), { group, priority }] }\n }\n for (const s of allStates(state)) {\n for (const scope of [s, ...s.regions]) {\n for (const a of scope.actions) for (const f of a.effects) if (f.k === 'assign' && f.ref.v === clock) schedule(f, f.op === '=' ? 1 : 2)\n }\n for (const t of s.out) for (const f of t.effects) if (f.k === 'assign' && f.ref.v === clock) schedule(f, f.op === '=' ? 1 : 2)\n if (sleepT && !s.connector) handleSleep(ctx, s, clock, sleepT, lit)\n }\n const progress = createAction(state, 'during')\n progress.about = clock.decl\n const increment: CEffect = { k: 'assign', ref: ref(clock), op: '+=', expr: ref(deltaT), o: { by: clock.decl, span: clock.span } }\n schedule(increment, 0)\n progress.effects.push(increment)\n}\n\n/** A schedule object (deps.ts): `protocols[p]` is KIELER's PriorityProtocol of priority p. */\nexport interface ScheduleGroup {\n name: string\n protocols?: ('conflict' | 'confluent' | 'commuting')[]\n}\n\nfunction generated(name: string, type: CVar['type'], root: CState, init: CExpr): CVar {\n const v = new CVar(name, type)\n v.init = init\n v.scope = root\n // A tag, not a role: the executor reports variables without a role as the chart's own (TickResult.values).\n v.tags.add(`#${name}`)\n v.decl = `${root.origin ?? root.name}$${name}`\n root.decls.push(v)\n return v\n}\n\nfunction clockVarError(name: string, kind: 'input' | 'output', type: string, v: CVar): Diagnostic {\n return {\n severity: 'error', code: 'clock-variable', span: v.span, related: v.decl ? [v.decl] : undefined,\n message: `\\`${name}\\` is the time variable of timed charts: it must be ${kind === 'input' ? 'an input' : 'an output'} of type ${type}`,\n kieler: `A variable with name ${name} already exists and is not an ${kind} variable of type ${type}`,\n hint: `KIELER uses \\`${name}\\` for ${name === 'deltaT' ? 'the time since the previous tick' : 'the time until the next tick'} in charts with clocks. Rename your variable, or declare it as \\`${kind} ${type} ${name}\\`.`,\n }\n}\n\nfunction sharedClock(state: CState, clock: CVar, lab: string, kieler: string, hint: string): Diagnostic {\n return {\n severity: 'error', code: 'shared-clock', related: [state.origin ?? state.about, clock.decl].filter((x): x is string => !!x),\n message: lab, kieler, hint: `${hint} KIELER's timed automata give every clock to one region, which advances it.`,\n }\n}\n\nfunction mentionsVar(e: CExpr, v: CVar): boolean {\n let found = false\n const visit = (x: CExpr) => {\n if (found) return\n if (x.k === 'ref') { if (x.v === v) found = true; x.idx.forEach(visit) }\n else if (x.k === 'op') x.args.forEach(visit)\n else if (x.k === 'vector') x.values.forEach(visit)\n else if (x.k === 'call') x.args.forEach(visit)\n }\n visit(e)\n return found\n}\n\n/** Does anything inside the region use the variable (KIELER's eAllContents check)? */\nfunction regionMentions(r: CRegion, v: CVar): boolean {\n for (const s of allContainedStates(r)) {\n for (const a of [...s.actions, ...s.regions.flatMap(x => x.actions)]) {\n if (a.trigger && mentionsVar(a.trigger, v)) return true\n if (a.effects.some(f => effectMentions(f, v))) return true\n }\n for (const t of s.out) {\n if (t.trigger && mentionsVar(t.trigger, v)) return true\n if (t.effects.some(f => effectMentions(f, v))) return true\n }\n }\n return false\n}\n\nfunction effectMentions(f: CEffect, v: CVar): boolean {\n if (f.k === 'assign') return f.ref.v === v || (!!f.expr && mentionsVar(f.expr, v))\n if (f.k === 'emit') return !!f.value && mentionsVar(f.value, v)\n return false\n}\n\ninterface Constraint {\n transition: CTransition\n op: Extract<CExpr, { k: 'op' }>\n /** The comparison's direct container (for the greedy-bound and insignificance patterns). */\n container?: CExpr\n}\n\n/** KIELER's handleSleep: sleep requests for the bounds of the state's timed transitions (S-38). */\nfunction handleSleep(ctx: PassContext, state: CState, clock: CVar, sleepT: CVar, lit: (n: number) => CExpr) {\n const constraints: Constraint[] = []\n const complex: Extract<CExpr, { k: 'op' }>[] = []\n for (const t of state.out) {\n if (!t.trigger) continue\n const visit = (e: CExpr, parent: CExpr | undefined, grand: CExpr | undefined) => {\n if (e.k === 'ref') {\n if (e.v === clock) {\n if (parent?.k === 'op' && parent.args.length === 2) {\n const refs = parent.args.filter(a => a.k === 'ref').length\n const values = parent.args.filter(a => a.k === 'lit').length\n if (refs === 1 && values === 1) constraints.push({ transition: t, op: parent, container: grand })\n else complex.push(parent)\n } else {\n ctx.report({\n severity: 'error', code: 'timing-constraint', span: e.span, related: t.origin ? [t.origin] : undefined,\n message: `\\`${clock.name}\\` must be compared with a value here (for example \\`${clock.name} >= 300\\`)`,\n kieler: 'Malformed timing constraint.',\n hint: 'KIELER works out the sleep time from comparisons of the clock with a value, so a clock in a trigger has to be one side of such a comparison.',\n })\n }\n }\n e.idx.forEach(i => visit(i, e, parent))\n } else if (e.k === 'op') e.args.forEach(a => visit(a, e, parent))\n }\n visit(t.trigger, undefined, undefined)\n }\n const sleepFor = (bound: CExpr) => {\n const during = createImmediateDuringAction(state)\n during.about = clock.decl\n during.trigger = { k: 'op', op: '<', args: [ref(clock), bound] }\n during.effects.push({ k: 'assign', ref: ref(sleepT), op: 'min=', expr: { k: 'op', op: '-', args: [copyExpr(bound), ref(clock)] }, o: { hidden: true, by: sleepT.decl } })\n }\n // 1. Comparisons with an expression: `t >= e` or `e <= t`.\n for (const c of complex) {\n const [a, b] = c.args\n let exp: CExpr | undefined\n if (a.k === 'ref' && a.v === clock) exp = b\n if (b.k === 'ref' && b.v === clock) exp = a\n if (!exp) {\n ctx.report({ severity: 'error', code: 'timing-constraint', span: c.span, message: 'This timing constraint does not compare the clock', kieler: 'Malformed timing constraint. No reference to clock.' })\n } else if (!((c.op === '>=' && exp === b) || (c.op === '<=' && exp === a))) {\n ctx.report({\n severity: 'error', code: 'timing-constraint', span: c.span,\n message: `KIELER only handles \\`${clock.name} >= value\\` (or \\`value <= ${clock.name}\\`) here, not \\`${c.op}\\``,\n kieler: `Malformed timing constraint. Operator ${c.op} not supported in clock comparison.`,\n hint: `Write the timeout as \\`${clock.name} >= value\\`.`,\n })\n } else {\n sleepFor(copyExpr(exp))\n }\n }\n // 2. Comparisons with a literal.\n const value = (c: Constraint): number => {\n const v = c.op.args.find(x => x.k === 'lit')\n return v?.k === 'lit' && typeof v.v === 'number' ? v.v : 0\n }\n const thresholds: number[] = []\n if (constraints.length === 1) {\n const c = constraints[0]\n let lower = 0\n if (c.op.op === '>=' || c.op.op === '>') lower = value(c)\n if (c.op.op === '>') lower++\n thresholds.push(lower)\n } else if (!insignificant(constraints)) {\n for (const t of [...new Set(constraints.map(c => c.transition))]) {\n const own = constraints.filter(c => c.transition === t)\n const bounds: number[] = []\n for (const c of own) {\n if (c.op.op === '>=') bounds.push(value(c))\n else if (c.op.op !== '<=' && c.op.op !== '<') {\n ctx.report({\n severity: 'error', code: 'timing-constraint', span: c.op.span, related: t.origin ? [t.origin] : undefined,\n message: `KIELER cannot work out the sleep time for \\`${clock.name} ${c.op.op} ...\\` when the state has other timeouts`,\n kieler: `Malformed timing constraint. Operator ${c.op.op} not supported.`,\n hint: `Write the timeouts of a state as \\`${clock.name} >= value\\`.`,\n })\n }\n }\n // `t >= a || t >= b` (exactly two, directly under one ||) asks for the larger bound only (S-38).\n const parent = own[0]?.container\n if (own.length === 2 && parent?.k === 'op' && parent.op === '||' && own.every(c => c.container === parent)) {\n if (bounds.length) thresholds.push(Math.max(...bounds))\n } else {\n thresholds.push(...bounds)\n }\n }\n }\n thresholds.sort((a, b) => a - b)\n for (const t of thresholds) sleepFor(lit(t))\n}\n\n/** KIELER's isInsignificant: `g && t >= v` and `g && t < v` on two transitions tell nothing about sleeping. */\nfunction insignificant(cs: Constraint[]): boolean {\n if (cs.length !== 2 || cs[0].transition === cs[1].transition) return false\n const [a, b] = cs\n const pa = a.container\n const pb = b.container\n if (pa?.k !== 'op' || pb?.k !== 'op' || pa.op !== '&&' || pb.op !== '&&') return false\n const ga = pa.args.find(x => x !== a.op)\n const gb = pb.args.find(x => x !== b.op)\n const va = a.op.args.find(x => x.k === 'lit')\n const vb = b.op.args.find(x => x.k === 'lit')\n if (!ga || !gb || va?.k !== 'lit' || vb?.k !== 'lit') return false\n return sameShape(ga, gb) && va.v === vb.v && ((a.op.op === '>=' && b.op.op === '<') || (b.op.op === '>=' && a.op.op === '<'))\n}\n\nfunction sameShape(a: CExpr, b: CExpr): boolean {\n if (a.k !== b.k) return false\n if (a.k === 'lit' && b.k === 'lit') return a.t === b.t && a.v === b.v\n if (a.k === 'ref' && b.k === 'ref') return a.v === b.v && a.idx.length === b.idx.length && a.idx.every((x, i) => sameShape(x, b.idx[i]))\n if (a.k === 'op' && b.k === 'op') return a.op === b.op && a.args.length === b.args.length && a.args.every((x, i) => sameShape(x, b.args[i]))\n return false\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { Pass } from "./context.js";
2
+ export declare const unpackClasses: Pass;
@@ -0,0 +1,54 @@
1
+ // Classes and structs (structure.md). KIELER's Unpack Classes processor only unpacks classes annotated @UnpackClass
2
+ // (their members become variables `<instance>_<member>`); every other class stays a C struct whose methods are C
3
+ // functions. The simulator lowers an instance's members to variables and its methods to methods of the instance
4
+ // (lower.ts declareMembers), and runs them as KIELER's C code does. Not simulated: host classes (their methods are
5
+ // C or Java code), arrays of instances and classes inside classes.
6
+ import { declsOf } from "./detect.js";
7
+ export const unpackClasses = {
8
+ id: 'de.cau.cs.kieler.sccharts.processors.unpackClasses',
9
+ name: 'Unpack Classes',
10
+ owner: 'structure',
11
+ run(ctx) {
12
+ const index = ctx.shared.index;
13
+ const checked = new Set();
14
+ for (const v of declsOf(ctx.root)) {
15
+ if (v.declKind !== 'class' && v.declKind !== 'struct')
16
+ continue;
17
+ // KIELER's checks on the declaration (UnpackClasses, Signal): once per declaration.
18
+ const d = v.decl ? index?.vos.get(v.decl)?.decl : undefined;
19
+ if (d && !checked.has(d)) {
20
+ checked.add(d);
21
+ const signal = (d.members ?? []).find(m => m.signal);
22
+ if (signal) {
23
+ ctx.report({
24
+ severity: 'error', code: 'signal-member', span: signal.span, related: v.decl ? [v.decl] : undefined,
25
+ message: `A ${d.declKind} cannot have a signal as a member (${signal.valuedObjects[0]?.name ? `\`${signal.valuedObjects[0].name}\`` : 'a signal'})`,
26
+ kieler: 'Signals in class declarations not yet supported',
27
+ hint: `Make the member a variable (\`bool ${signal.valuedObjects[0]?.name ?? 'S'}\`), or declare the signal outside the ${d.declKind}.`,
28
+ });
29
+ }
30
+ if (d.annotations.some(a => a.name === 'UnpackClass') && d.valuedObjects.length > 1) {
31
+ ctx.report({
32
+ severity: 'error', code: 'unpack-instances', span: d.annotations.find(a => a.name === 'UnpackClass').span, related: v.decl ? [v.decl] : undefined,
33
+ message: `\`@UnpackClass\` needs exactly one instance, but ${d.className ? `\`${d.className}\`` : 'this class'} has ${d.valuedObjects.length} (${d.valuedObjects.map(x => `\`${x.name}\``).join(', ')})`,
34
+ kieler: 'Unpacking multiple instances of the same class is not yet supported.',
35
+ hint: 'Remove `@UnpackClass`, or declare one instance per class.',
36
+ });
37
+ }
38
+ }
39
+ const host = v.tags.has('#host');
40
+ const what = host ? undefined : v.tags.has('#array') ? `arrays of ${v.declKind} instances (\`${v.name}\`)` : v.tags.has('#nested') ? `a ${v.declKind} inside a ${v.declKind} (\`${v.name}\`)` : undefined;
41
+ if (!host && !what)
42
+ continue;
43
+ ctx.report({
44
+ severity: 'info', code: 'unsupported', span: v.span, related: v.decl ? [v.decl] : undefined,
45
+ message: host ? `This chart uses the host class \`${v.name}\`, which cannot run in the browser` : `The guide's simulator cannot run ${what} yet`,
46
+ hint: host
47
+ ? 'A host class is implemented in the C (or Java) code next to the chart, so it needs a compiler. The official KIELER tools run this chart.'
48
+ : 'The official KIELER tools run this chart.',
49
+ });
50
+ return;
51
+ }
52
+ },
53
+ };
54
+ //# sourceMappingURL=unpackClasses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unpackClasses.js","sourceRoot":"","sources":["../../../src/sim/passes/unpackClasses.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,iHAAiH;AACjH,gHAAgH;AAChH,mHAAmH;AACnH,mEAAmE;AAKnE,OAAO,EAAE,OAAO,EAAE,oBAAgB;AAElC,MAAM,CAAC,MAAM,aAAa,GAAS;IAC/B,EAAE,EAAE,oDAAoD;IACxD,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,WAAW;IAClB,GAAG,CAAC,GAAgB;QAChB,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAA+B,CAAA;QACxD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAe,CAAA;QACtC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ;gBAAE,SAAQ;YAC/D,oFAAoF;YACpF,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;YAC3D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;gBACd,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,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,oCAAoC,IAAI,MAAM;gBAChJ,IAAI,EAAE,IAAI;oBACN,CAAC,CAAC,0IAA0I;oBAC5I,CAAC,CAAC,2CAA2C;aACpD,CAAC,CAAA;YACF,OAAM;QACV,CAAC;IACL,CAAC;CACJ,CAAA","sourcesContent":["// Classes and structs (structure.md). KIELER's Unpack Classes processor only unpacks classes annotated @UnpackClass\n// (their members become variables `<instance>_<member>`); every other class stays a C struct whose methods are C\n// functions. The simulator lowers an instance's members to variables and its methods to methods of the instance\n// (lower.ts declareMembers), and runs them as KIELER's C code does. Not simulated: host classes (their methods are\n// C or Java code), arrays of instances and classes inside classes.\n\nimport type { Declaration } from '../../types'\nimport type { ModelIndex } from '../../parser/resolve'\nimport type { Pass, PassContext } from './context'\nimport { declsOf } from './detect'\n\nexport const unpackClasses: Pass = {\n id: 'de.cau.cs.kieler.sccharts.processors.unpackClasses',\n name: 'Unpack Classes',\n owner: 'structure',\n run(ctx: PassContext) {\n const index = ctx.shared.index as ModelIndex | undefined\n const checked = new Set<Declaration>()\n for (const v of declsOf(ctx.root)) {\n if (v.declKind !== 'class' && v.declKind !== 'struct') continue\n // KIELER's checks on the declaration (UnpackClasses, Signal): once per declaration.\n const d = v.decl ? index?.vos.get(v.decl)?.decl : undefined\n if (d && !checked.has(d)) {\n checked.add(d)\n const signal = (d.members ?? []).find(m => m.signal)\n if (signal) {\n ctx.report({\n severity: 'error', code: 'signal-member', span: signal.span, related: v.decl ? [v.decl] : undefined,\n message: `A ${d.declKind} cannot have a signal as a member (${signal.valuedObjects[0]?.name ? `\\`${signal.valuedObjects[0].name}\\`` : 'a signal'})`,\n kieler: 'Signals in class declarations not yet supported',\n hint: `Make the member a variable (\\`bool ${signal.valuedObjects[0]?.name ?? 'S'}\\`), or declare the signal outside the ${d.declKind}.`,\n })\n }\n if (d.annotations.some(a => a.name === 'UnpackClass') && d.valuedObjects.length > 1) {\n ctx.report({\n severity: 'error', code: 'unpack-instances', span: d.annotations.find(a => a.name === 'UnpackClass')!.span, related: v.decl ? [v.decl] : undefined,\n message: `\\`@UnpackClass\\` needs exactly one instance, but ${d.className ? `\\`${d.className}\\`` : 'this class'} has ${d.valuedObjects.length} (${d.valuedObjects.map(x => `\\`${x.name}\\``).join(', ')})`,\n kieler: 'Unpacking multiple instances of the same class is not yet supported.',\n hint: 'Remove `@UnpackClass`, or declare one instance per class.',\n })\n }\n }\n const host = v.tags.has('#host')\n const what = host ? undefined : v.tags.has('#array') ? `arrays of ${v.declKind} instances (\\`${v.name}\\`)` : v.tags.has('#nested') ? `a ${v.declKind} inside a ${v.declKind} (\\`${v.name}\\`)` : undefined\n if (!host && !what) continue\n ctx.report({\n severity: 'info', code: 'unsupported', span: v.span, related: v.decl ? [v.decl] : undefined,\n message: host ? `This chart uses the host class \\`${v.name}\\`, which cannot run in the browser` : `The guide's simulator cannot run ${what} yet`,\n hint: host\n ? 'A host class is implemented in the C (or Java) code next to the chart, so it needs a compiler. The official KIELER tools run this chart.'\n : 'The official KIELER tools run this chart.',\n })\n return\n }\n },\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { Pass } from "./context.js";
2
+ export declare const userSchedule: Pass;