@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,168 @@
1
+ // What a trigger read when it was checked, for describeTick's "because n == 1 held (n was 0)" and the log's
2
+ // `check` events. The values are read by the executor at the moment the condition node runs (not after the tick),
3
+ // so a transition that writes the variable it tests is explained with the value that made it fire.
4
+ //
5
+ // A probe is a variable reference of the source trigger as the core chart reads it: the passes keep every source
6
+ // reference's span (Signal: `S` stays the presence flag, `val(S)` becomes `S_val` with the span of `val(S)`; Pre:
7
+ // `pre(x)` becomes `_pre_x` with the span of `pre(x)`; References: an instance's bound variable is the referencing
8
+ // chart's, with the span of the name in the referenced chart). So the source trigger's references are matched
9
+ // with the core condition's references by span, and each is shown under its name as written: inside a referenced
10
+ // chart, the referenced chart's names with the instance's values. References the core condition no longer reads
11
+ // (constants and for-region counters, which are folded into literals) are not shown.
12
+ import { formatExpressionPlain } from "../format.js";
13
+ import { walkExpr } from "./model.js";
14
+ import { REFERENCE_SEPARATOR } from "./structure/instance.js";
15
+ const elementsCache = new WeakMap();
16
+ /** Every source transition and action of the programs the chart was compiled from, by id. */
17
+ export function sourceElements(chart, index) {
18
+ const key = index ?? chart;
19
+ const cached = elementsCache.get(key);
20
+ if (cached)
21
+ return cached;
22
+ const transitions = new Map();
23
+ const actions = new Map();
24
+ const visit = (s) => {
25
+ for (const t of s.transitions)
26
+ transitions.set(t.id, t);
27
+ for (const a of s.actions)
28
+ actions.set(a.id, a);
29
+ for (const r of s.regions) {
30
+ for (const a of r.actions)
31
+ actions.set(a.id, a);
32
+ r.states.forEach(visit);
33
+ }
34
+ };
35
+ const programs = index?.programs ?? [];
36
+ for (const p of programs)
37
+ p.charts.forEach(visit);
38
+ visit(chart);
39
+ const out = { transitions, actions };
40
+ elementsCache.set(key, out);
41
+ return out;
42
+ }
43
+ /** The source element an executor id stands for: an instance's `<prefix>/<id>` is the referenced chart's `<id>`. */
44
+ export function lookupSource(map, id) {
45
+ const direct = map.get(id);
46
+ if (direct)
47
+ return direct;
48
+ const i = id.lastIndexOf(REFERENCE_SEPARATOR);
49
+ return i < 0 ? undefined : map.get(id.slice(i + 1));
50
+ }
51
+ /** The references of a source trigger in reading order: `x`, `a[i]` (and `i`), `pre(x)`, `val(S)`. */
52
+ function sourceItems(e) {
53
+ const out = [];
54
+ const visit = (x) => {
55
+ switch (x.kind) {
56
+ case 'ref':
57
+ out.push({ name: formatExpressionPlain(x), start: x.span.start, end: x.span.end });
58
+ x.indices.forEach(visit);
59
+ break;
60
+ case 'op':
61
+ if ((x.op === 'pre' || x.op === 'val') && x.args.length === 1 && x.args[0].kind === 'ref') {
62
+ out.push({ name: formatExpressionPlain(x), start: x.span.start, end: x.span.end });
63
+ x.args[0].indices.forEach(visit);
64
+ }
65
+ else {
66
+ x.args.forEach(visit);
67
+ }
68
+ break;
69
+ case 'call':
70
+ x.args.forEach(visit);
71
+ break;
72
+ default:
73
+ break;
74
+ }
75
+ };
76
+ visit(e);
77
+ return out;
78
+ }
79
+ /**
80
+ * Probes for a core condition that implements (part of) a source trigger. `compileRef` compiles a core reference
81
+ * into a reader; references of the source trigger the condition does not read are left out.
82
+ */
83
+ export function triggerProbes(core, trigger, compileRef, valueOf) {
84
+ if (!core || !trigger)
85
+ return [];
86
+ const leaves = new Map();
87
+ walkExpr(core, e => {
88
+ if (e.k !== 'ref' || !e.span)
89
+ return;
90
+ const key = `${e.span.start}:${e.span.end}`;
91
+ const list = leaves.get(key);
92
+ if (list)
93
+ list.push(e);
94
+ else
95
+ leaves.set(key, [e]);
96
+ });
97
+ if (!leaves.size)
98
+ return [];
99
+ const items = sourceItems(trigger);
100
+ // A chart from another file has the reference's span everywhere (structure/instance.ts): no way to tell its
101
+ // references apart, so nothing is shown.
102
+ const spans = new Set(items.map(i => `${i.start}:${i.end}`));
103
+ if (spans.size < items.length && new Set(items.map(i => i.name)).size > spans.size)
104
+ return [];
105
+ const out = [];
106
+ const names = new Set();
107
+ const add = (name, r) => {
108
+ const fn = compileRef(r);
109
+ if (!fn)
110
+ return;
111
+ names.add(name);
112
+ const v = r.v;
113
+ const signal = v.role === 'presence' || (v.role === 'pre' && v.of?.role === 'presence');
114
+ out.push({ name, signal, fn, value: valueOf(r) });
115
+ };
116
+ for (const item of items) {
117
+ if (names.has(item.name))
118
+ continue;
119
+ const found = leaves.get(`${item.start}:${item.end}`);
120
+ if (!found?.length)
121
+ continue;
122
+ const r = found[0];
123
+ if (found.some(x => x.v !== r.v))
124
+ continue;
125
+ add(item.name, r);
126
+ }
127
+ // A chart from another file: every reference of the condition has the reference state's span. When the condition
128
+ // reads as many references as the trigger, in the same order, they are the trigger's.
129
+ if (!out.length && leaves.size === 1) {
130
+ const refs = [...leaves.values()][0];
131
+ if (refs.length === items.length && !spans.has([...leaves.keys()][0])) {
132
+ items.forEach((item, i) => { if (!names.has(item.name))
133
+ add(item.name, refs[i]); });
134
+ }
135
+ }
136
+ return out;
137
+ }
138
+ /** Reads the probes now (a probe that cannot be evaluated, e.g. an index out of range, is left out). */
139
+ export function readProbes(probes, rt) {
140
+ const out = [];
141
+ for (const p of probes) {
142
+ try {
143
+ const value = p.value(p.fn(rt));
144
+ out.push(p.signal ? { name: p.name, value, signal: true } : { name: p.name, value });
145
+ }
146
+ catch {
147
+ // The condition itself reports the runtime error.
148
+ }
149
+ }
150
+ return out;
151
+ }
152
+ function show(v) {
153
+ if (v === null)
154
+ return 'null';
155
+ if (Array.isArray(v))
156
+ return `{${v.map(show).join(', ')}}`;
157
+ if (typeof v === 'string')
158
+ return JSON.stringify(v);
159
+ return String(v);
160
+ }
161
+ /** "n was 0 and S was present". */
162
+ export function seenText(seen) {
163
+ const parts = seen.map(s => (s.signal ? `${s.name} was ${s.value ? 'present' : 'absent'}` : `${s.name} was ${show(s.value)}`));
164
+ if (parts.length <= 1)
165
+ return parts.join('');
166
+ return `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;
167
+ }
168
+ //# sourceMappingURL=reasons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasons.js","sourceRoot":"","sources":["../../src/sim/reasons.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,iHAAiH;AACjH,kHAAkH;AAClH,mHAAmH;AACnH,8GAA8G;AAC9G,i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AAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IAC9H,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5C,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAA;AAC5E,CAAC","sourcesContent":["// What a trigger read when it was checked, for describeTick's \"because n == 1 held (n was 0)\" and the log's\n// `check` events. The values are read by the executor at the moment the condition node runs (not after the tick),\n// so a transition that writes the variable it tests is explained with the value that made it fire.\n//\n// A probe is a variable reference of the source trigger as the core chart reads it: the passes keep every source\n// reference's span (Signal: `S` stays the presence flag, `val(S)` becomes `S_val` with the span of `val(S)`; Pre:\n// `pre(x)` becomes `_pre_x` with the span of `pre(x)`; References: an instance's bound variable is the referencing\n// chart's, with the span of the name in the referenced chart). So the source trigger's references are matched\n// with the core condition's references by span, and each is shown under its name as written: inside a referenced\n// chart, the referenced chart's names with the instance's values. References the core condition no longer reads\n// (constants and for-region counters, which are folded into literals) are not shown.\n\nimport type { Expression, LocalAction, Program, State, TraceSeen, Transition, Value } from '../types'\nimport type { ModelIndex } from '../parser/resolve'\nimport { formatExpressionPlain } from '../format'\nimport type { Fn, Runtime } from './eval'\nimport { walkExpr, type CExpr, type CRef } from './model'\nimport { REFERENCE_SEPARATOR } from './structure/instance'\n\nexport interface Probe {\n name: string\n signal: boolean\n fn: Fn\n /** Converts the run-time value for the log. */\n value: (v: ReturnType<Fn>) => Value\n}\n\ninterface SourceElements {\n transitions: Map<string, Transition>\n actions: Map<string, LocalAction>\n}\n\nconst elementsCache = new WeakMap<object, SourceElements>()\n\n/** Every source transition and action of the programs the chart was compiled from, by id. */\nexport function sourceElements(chart: State, index: ModelIndex | undefined): SourceElements {\n const key: object = index ?? chart\n const cached = elementsCache.get(key)\n if (cached) return cached\n const transitions = new Map<string, Transition>()\n const actions = new Map<string, LocalAction>()\n const visit = (s: State) => {\n for (const t of s.transitions) transitions.set(t.id, t)\n for (const a of s.actions) actions.set(a.id, a)\n for (const r of s.regions) {\n for (const a of r.actions) actions.set(a.id, a)\n r.states.forEach(visit)\n }\n }\n const programs: Program[] = index?.programs ?? []\n for (const p of programs) p.charts.forEach(visit)\n visit(chart)\n const out = { transitions, actions }\n elementsCache.set(key, out)\n return out\n}\n\n/** The source element an executor id stands for: an instance's `<prefix>/<id>` is the referenced chart's `<id>`. */\nexport function lookupSource<T>(map: Map<string, T>, id: string): T | undefined {\n const direct = map.get(id)\n if (direct) return direct\n const i = id.lastIndexOf(REFERENCE_SEPARATOR)\n return i < 0 ? undefined : map.get(id.slice(i + 1))\n}\n\ninterface Item {\n name: string\n start: number\n end: number\n}\n\n/** The references of a source trigger in reading order: `x`, `a[i]` (and `i`), `pre(x)`, `val(S)`. */\nfunction sourceItems(e: Expression): Item[] {\n const out: Item[] = []\n const visit = (x: Expression) => {\n switch (x.kind) {\n case 'ref':\n out.push({ name: formatExpressionPlain(x), start: x.span.start, end: x.span.end })\n x.indices.forEach(visit)\n break\n case 'op':\n if ((x.op === 'pre' || x.op === 'val') && x.args.length === 1 && x.args[0].kind === 'ref') {\n out.push({ name: formatExpressionPlain(x), start: x.span.start, end: x.span.end })\n x.args[0].indices.forEach(visit)\n } else {\n x.args.forEach(visit)\n }\n break\n case 'call':\n x.args.forEach(visit)\n break\n default:\n break\n }\n }\n visit(e)\n return out\n}\n\n/**\n * Probes for a core condition that implements (part of) a source trigger. `compileRef` compiles a core reference\n * into a reader; references of the source trigger the condition does not read are left out.\n */\nexport function triggerProbes(core: CExpr | undefined, trigger: Expression | undefined, compileRef: (r: CRef) => Probe['fn'] | undefined, valueOf: (r: CRef) => Probe['value']): Probe[] {\n if (!core || !trigger) return []\n const leaves = new Map<string, CRef[]>()\n walkExpr(core, e => {\n if (e.k !== 'ref' || !e.span) return\n const key = `${e.span.start}:${e.span.end}`\n const list = leaves.get(key)\n if (list) list.push(e)\n else leaves.set(key, [e])\n })\n if (!leaves.size) return []\n const items = sourceItems(trigger)\n // A chart from another file has the reference's span everywhere (structure/instance.ts): no way to tell its\n // references apart, so nothing is shown.\n const spans = new Set(items.map(i => `${i.start}:${i.end}`))\n if (spans.size < items.length && new Set(items.map(i => i.name)).size > spans.size) return []\n const out: Probe[] = []\n const names = new Set<string>()\n const add = (name: string, r: CRef) => {\n const fn = compileRef(r)\n if (!fn) return\n names.add(name)\n const v = r.v\n const signal = v.role === 'presence' || (v.role === 'pre' && v.of?.role === 'presence')\n out.push({ name, signal, fn, value: valueOf(r) })\n }\n for (const item of items) {\n if (names.has(item.name)) continue\n const found = leaves.get(`${item.start}:${item.end}`)\n if (!found?.length) continue\n const r = found[0]\n if (found.some(x => x.v !== r.v)) continue\n add(item.name, r)\n }\n // A chart from another file: every reference of the condition has the reference state's span. When the condition\n // reads as many references as the trigger, in the same order, they are the trigger's.\n if (!out.length && leaves.size === 1) {\n const refs = [...leaves.values()][0]\n if (refs.length === items.length && !spans.has([...leaves.keys()][0])) {\n items.forEach((item, i) => { if (!names.has(item.name)) add(item.name, refs[i]) })\n }\n }\n return out\n}\n\n/** Reads the probes now (a probe that cannot be evaluated, e.g. an index out of range, is left out). */\nexport function readProbes(probes: Probe[], rt: Runtime): TraceSeen[] {\n const out: TraceSeen[] = []\n for (const p of probes) {\n try {\n const value = p.value(p.fn(rt))\n out.push(p.signal ? { name: p.name, value, signal: true } : { name: p.name, value })\n } catch {\n // The condition itself reports the runtime error.\n }\n }\n return out\n}\n\nfunction show(v: Value): string {\n if (v === null) return 'null'\n if (Array.isArray(v)) return `{${v.map(show).join(', ')}}`\n if (typeof v === 'string') return JSON.stringify(v)\n return String(v)\n}\n\n/** \"n was 0 and S was present\". */\nexport function seenText(seen: TraceSeen[]): string {\n const parts = seen.map(s => (s.signal ? `${s.name} was ${s.value ? 'present' : 'absent'}` : `${s.name} was ${show(s.value)}`))\n if (parts.length <= 1) return parts.join('')\n return `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`\n}\n"]}
@@ -0,0 +1,124 @@
1
+ import type { Span } from "../types.js";
2
+ import type { CEffect, CExpr, CRegion, CState, CTransition } from "./model.js";
3
+ export type NodeKind = 'entry' | 'exit' | 'assign' | 'cond' | 'fork' | 'join' | 'surface' | 'depth';
4
+ /** Creation ranks of a node's outgoing control flows (fork: one per thread). */
5
+ export interface FlowSeq {
6
+ next?: number;
7
+ then?: number;
8
+ else?: number;
9
+ threads?: number[];
10
+ }
11
+ export interface SNode {
12
+ id: number;
13
+ kind: NodeKind;
14
+ /** The innermost thread the node belongs to (a fork and its join belong to the parent thread). */
15
+ thread: Thread;
16
+ next?: SNode;
17
+ then?: SNode;
18
+ else?: SNode;
19
+ /** fork: its threads in region order. */
20
+ threads?: Thread[];
21
+ /** fork -> join, join -> fork. */
22
+ join?: SNode;
23
+ fork?: SNode;
24
+ /** surface -> depth, depth -> surface. */
25
+ depth?: SNode;
26
+ surface?: SNode;
27
+ /** assign: the effect. */
28
+ effect?: CEffect;
29
+ /** cond: the condition. */
30
+ expr?: CExpr;
31
+ /** The core state this node implements part of. */
32
+ state?: CState;
33
+ /** cond: the transition whose trigger it tests; assign: the transition whose effect it runs. */
34
+ transition?: CTransition;
35
+ /** A schizophrenic surface copy made by the structural depth join (analysis.ts). */
36
+ schizo?: SNode;
37
+ /** Copies keep a link to the node they copy. */
38
+ copyOf?: SNode;
39
+ /** KIELER's creation rank of each outgoing control flow. */
40
+ seq?: FlowSeq;
41
+ /** Position in KIELER's node list (SCGTransformation creates nodes state by state; copies come last). */
42
+ gen?: number;
43
+ /** cond: KIELER also has an else flow to the then branch's node (the netlist's equal-branch defect). */
44
+ sameElse?: boolean;
45
+ /** cond with `sameElse`: the node both branches reach in KIELER's graph, when the simulator's then branch first
46
+ * passes marks KIELER has no nodes for (a referenced chart's transitions, scg.ts weightOf). */
47
+ sameTarget?: SNode;
48
+ /** fork: KIELER's SEQUENTIAL_PREEMPTIVE fork of a state with abort regions (abortRegions.ts): its threads run
49
+ * in order and finishing ones preempt later ones. */
50
+ preemptive?: boolean;
51
+ /** join: a par-or join (`any`): it fires as soon as any of its threads finishes (abort regions). */
52
+ any?: boolean;
53
+ /** fork: a preemptive fork whose join leads back to it within a tick (KIELER's thread reincarnation). */
54
+ reincarnation?: boolean;
55
+ /**
56
+ * assign, cond: a node of a method's (or code block's) body that KIELER's Methods processor copied into the
57
+ * graph (structure/methods.ts inline), `name` as called. Its conditions are the body's `if` tests, not a check of
58
+ * the transition the call is on. `jumpsBack`: a `goto` from this node to a label before it (the body loops within
59
+ * the tick, which KIELER cannot schedule).
60
+ */
61
+ method?: {
62
+ name: string;
63
+ jumpsBack?: {
64
+ label: string;
65
+ span?: Span;
66
+ };
67
+ };
68
+ }
69
+ export interface Thread {
70
+ id: number;
71
+ entry: SNode;
72
+ exit: SNode;
73
+ /** The region the thread runs (undefined for the root thread). */
74
+ region?: CRegion;
75
+ /** The fork that starts the thread (undefined for the root thread). */
76
+ fork?: SNode;
77
+ parent?: Thread;
78
+ depth: number;
79
+ /** A final region's thread (KIELER: exit.final). */
80
+ final: boolean;
81
+ /** Position of the thread's entry in KIELER's node list (SCGTransformation creates nodes in region order). */
82
+ rank: number;
83
+ }
84
+ export interface SCG {
85
+ nodes: SNode[];
86
+ threads: Thread[];
87
+ root: Thread;
88
+ /** First node of each core state (as KIELER's state-to-node mapping). */
89
+ stateNodes: Map<CState, SNode>;
90
+ /** Problems found while building (instantaneous loops through states without nodes, KIELER crashes). */
91
+ problems: {
92
+ message: string;
93
+ states: CState[];
94
+ kieler?: string;
95
+ }[];
96
+ /** The next free control-flow rank: rewiring a flow appends it to its new target's incoming flows. */
97
+ seq: number;
98
+ /**
99
+ * Transitions (tracker ids) of referenced charts that have no nodes: KIELER merges a state whose only transition is
100
+ * immediate, untriggered and effectless into its target. The source-level configuration follows them on entry.
101
+ */
102
+ silentHops?: string[];
103
+ }
104
+ /** A mark node that stands for no KIELER effect (KIELER's graph has no node for it, weightOf). */
105
+ export declare function noKielerNode(n: SNode | undefined): boolean;
106
+ /** `ttsCount`: the number of transitions Taken Transition Signaling counts (its reset is one effect each). */
107
+ export declare function buildSCG(root: CState, ttsCount?: number): SCG;
108
+ /** Successors of a node within a tick (a surface ends the tick; its depth is reached in the next one). */
109
+ export declare function successors(n: SNode): SNode[];
110
+ /** Successors including the surface -> depth step (for reachability). */
111
+ export declare function allSuccessors(n: SNode): SNode[];
112
+ /**
113
+ * Control-flow predecessors in the order of KIELER's incoming control flows (a depth has none from its surface).
114
+ * Flows without a rank (should not happen) come last.
115
+ */
116
+ export declare function predecessors(scg: SCG): Map<SNode, SNode[]>;
117
+ /**
118
+ * A copy of the graph (nodes, threads, state mapping) that analyses can change independently; `map` takes an
119
+ * original node to its copy.
120
+ */
121
+ export declare function cloneSCG(scg: SCG): {
122
+ scg: SCG;
123
+ map: Map<SNode, SNode>;
124
+ };