@eagleoutice/flowr 2.4.6 → 2.4.8

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 (107) hide show
  1. package/README.md +37 -33
  2. package/abstract-interpretation/data-frame/absint-visitor.js +3 -2
  3. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +40 -0
  4. package/abstract-interpretation/data-frame/dataframe-domain.js +62 -0
  5. package/abstract-interpretation/data-frame/domain.js +1 -1
  6. package/abstract-interpretation/domains/abstract-domain.d.ts +56 -0
  7. package/abstract-interpretation/domains/abstract-domain.js +19 -0
  8. package/abstract-interpretation/domains/bounded-set-domain.d.ts +43 -0
  9. package/abstract-interpretation/domains/bounded-set-domain.js +121 -0
  10. package/abstract-interpretation/domains/interval-domain.d.ts +61 -0
  11. package/abstract-interpretation/domains/interval-domain.js +208 -0
  12. package/abstract-interpretation/domains/lattice.d.ts +62 -0
  13. package/abstract-interpretation/domains/lattice.js +12 -0
  14. package/abstract-interpretation/domains/positive-interval-domain.d.ts +32 -0
  15. package/abstract-interpretation/domains/positive-interval-domain.js +91 -0
  16. package/abstract-interpretation/domains/product-domain.d.ts +37 -0
  17. package/abstract-interpretation/domains/product-domain.js +133 -0
  18. package/abstract-interpretation/domains/set-bounded-set-domain.d.ts +43 -0
  19. package/abstract-interpretation/domains/set-bounded-set-domain.js +164 -0
  20. package/abstract-interpretation/domains/singleton-domain.d.ts +38 -0
  21. package/abstract-interpretation/domains/singleton-domain.js +115 -0
  22. package/abstract-interpretation/domains/state-abstract-domain.d.ts +32 -0
  23. package/abstract-interpretation/domains/state-abstract-domain.js +179 -0
  24. package/benchmark/slicer.js +1 -1
  25. package/benchmark/summarizer/first-phase/process.js +1 -1
  26. package/cli/repl/commands/repl-query.js +11 -2
  27. package/cli/repl/core.d.ts +2 -2
  28. package/cli/repl/core.js +26 -7
  29. package/cli/repl/server/connection.js +3 -1
  30. package/cli/repl/server/messages/message-slice.d.ts +3 -0
  31. package/cli/repl/server/messages/message-slice.js +2 -0
  32. package/control-flow/extract-cfg.d.ts +3 -3
  33. package/control-flow/extract-cfg.js +4 -4
  34. package/control-flow/useless-loop.js +30 -21
  35. package/dataflow/environments/built-in.d.ts +1 -1
  36. package/dataflow/environments/default-builtin-config.d.ts +9 -0
  37. package/dataflow/environments/default-builtin-config.js +21 -21
  38. package/dataflow/environments/environment.js +18 -9
  39. package/dataflow/environments/overwrite.js +2 -2
  40. package/dataflow/extractor.js +1 -1
  41. package/dataflow/graph/diff-dataflow-graph.js +4 -4
  42. package/dataflow/graph/graph.d.ts +3 -3
  43. package/dataflow/graph/graph.js +4 -1
  44. package/dataflow/graph/quads.js +4 -4
  45. package/dataflow/info.js +1 -1
  46. package/dataflow/internal/linker.d.ts +2 -0
  47. package/dataflow/internal/linker.js +18 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
  49. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +68 -21
  50. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -2
  51. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -4
  52. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -18
  53. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -0
  54. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
  55. package/dataflow/internal/process/functions/call/common.js +4 -3
  56. package/documentation/doc-util/doc-query.js +6 -2
  57. package/documentation/doc-util/doc-types.d.ts +7 -2
  58. package/documentation/doc-util/doc-types.js +20 -4
  59. package/documentation/print-core-wiki.js +5 -1
  60. package/documentation/print-dataflow-graph-wiki.js +21 -12
  61. package/documentation/print-faq-wiki.js +5 -0
  62. package/documentation/print-interface-wiki.js +2 -0
  63. package/documentation/print-linter-wiki.js +2 -3
  64. package/documentation/print-query-wiki.js +22 -7
  65. package/linter/linter-executor.js +25 -17
  66. package/linter/linter-format.d.ts +10 -1
  67. package/linter/linter-format.js +8 -0
  68. package/linter/linter-rules.d.ts +1 -0
  69. package/linter/rules/absolute-path.js +8 -8
  70. package/linter/rules/dataframe-access-validation.js +1 -1
  71. package/linter/rules/file-path-validity.js +8 -11
  72. package/linter/rules/naming-convention.d.ts +5 -1
  73. package/linter/rules/naming-convention.js +24 -8
  74. package/linter/rules/seeded-randomness.js +2 -2
  75. package/linter/rules/unused-definition.js +1 -1
  76. package/package.json +17 -15
  77. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +5 -1
  78. package/queries/catalog/call-context-query/call-context-query-executor.js +14 -12
  79. package/queries/catalog/call-context-query/call-context-query-format.d.ts +6 -5
  80. package/queries/catalog/call-context-query/call-context-query-format.js +1 -1
  81. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -1
  82. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  83. package/queries/catalog/config-query/config-query-executor.js +7 -1
  84. package/queries/catalog/config-query/config-query-format.d.ts +7 -0
  85. package/queries/catalog/config-query/config-query-format.js +72 -1
  86. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -75
  87. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +50 -26
  88. package/queries/catalog/dependencies-query/dependencies-query-format.js +75 -20
  89. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -2
  90. package/queries/catalog/dependencies-query/function-info/visualize-functions.d.ts +2 -0
  91. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +13 -0
  92. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -1
  93. package/queries/catalog/linter-query/linter-query-format.js +4 -0
  94. package/queries/query-print.d.ts +2 -2
  95. package/queries/query-print.js +3 -2
  96. package/queries/query.d.ts +28 -21
  97. package/search/flowr-search-builder.d.ts +1 -1
  98. package/search/flowr-search-builder.js +1 -1
  99. package/search/flowr-search-filters.d.ts +20 -10
  100. package/search/flowr-search-filters.js +19 -3
  101. package/search/search-executor/search-enrichers.d.ts +1 -1
  102. package/search/search-executor/search-enrichers.js +3 -2
  103. package/search/search-executor/search-generators.js +1 -1
  104. package/search/search-executor/search-transformer.js +1 -1
  105. package/util/objects.d.ts +11 -0
  106. package/util/objects.js +26 -0
  107. package/util/version.js +1 -1
package/README.md CHANGED
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
24
24
 
25
25
  ```shell
26
26
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
27
- flowR repl using flowR v2.4.5, R v4.5.0 (r-shell engine)
27
+ flowR repl using flowR v2.4.7, R v4.5.0 (r-shell engine)
28
28
  R> :query @linter "read.csv(\"/root/x.txt\")"
29
29
  ```
30
30
 
@@ -55,7 +55,7 @@ It offers a wide variety of features, for example:
55
55
  ╰ **Dead Code** (dead-code):
56
56
  ╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":0,"processTimeMs":0}</code>
57
57
  ╰ **Useless Loops** (useless-loop):
58
- ╰ _Metadata_: <code>{"numOfUselessLoops":0,"searchTimeMs":0,"processTimeMs":1}</code>
58
+ ╰ _Metadata_: <code>{"numOfUselessLoops":0,"searchTimeMs":0,"processTimeMs":0}</code>
59
59
  All queries together required ≈3 ms (1ms accuracy, total 9 ms)
60
60
  ```
61
61
 
@@ -78,7 +78,7 @@ It offers a wide variety of features, for example:
78
78
 
79
79
  _Results (prettified and summarized):_
80
80
 
81
- Query: **linter** (13 ms)\
81
+ Query: **linter** (14 ms)\
82
82
  &nbsp;&nbsp;&nbsp;╰ **Deprecated Functions** (deprecated-functions):\
83
83
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":2,"processTimeMs":0}</code>\
84
84
  &nbsp;&nbsp;&nbsp;╰ **File Path Validity** (file-path-validity):\
@@ -86,11 +86,11 @@ It offers a wide variety of features, for example:
86
86
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ Path `/root/x.txt` at 1.1-23\
87
87
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":4,"processTimeMs":1}</code>\
88
88
  &nbsp;&nbsp;&nbsp;╰ **Seeded Randomness** (seeded-randomness):\
89
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":0,"processTimeMs":0}</code>\
89
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":0,"processTimeMs":1}</code>\
90
90
  &nbsp;&nbsp;&nbsp;╰ **Absolute Paths** (absolute-file-paths):\
91
91
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ certain:\
92
92
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ Path `/root/x.txt` at 1.1-23\
93
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":2,"processTimeMs":0}</code>\
93
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":1,"processTimeMs":1}</code>\
94
94
  &nbsp;&nbsp;&nbsp;╰ **Unused Definitions** (unused-definitions):\
95
95
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":0,"processTimeMs":0}</code>\
96
96
  &nbsp;&nbsp;&nbsp;╰ **Naming Convention** (naming-convention):\
@@ -100,12 +100,12 @@ It offers a wide variety of features, for example:
100
100
  &nbsp;&nbsp;&nbsp;╰ **Dead Code** (dead-code):\
101
101
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":1,"processTimeMs":0}</code>\
102
102
  &nbsp;&nbsp;&nbsp;╰ **Useless Loops** (useless-loop):\
103
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"numOfUselessLoops":0,"searchTimeMs":0,"processTimeMs":0}</code>\
104
- _All queries together required ≈14 ms (1ms accuracy, total 209 ms)_
103
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ _Metadata_: <code>{"numOfUselessLoops":0,"searchTimeMs":0,"processTimeMs":1}</code>\
104
+ _All queries together required ≈14 ms (1ms accuracy, total 216 ms)_
105
105
 
106
106
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
107
107
 
108
- The analysis required _209.4 ms_ (including parsing and normalization and the query) within the generation environment.
108
+ The analysis required _215.9 ms_ (including parsing and normalization and the query) within the generation environment.
109
109
 
110
110
  In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
111
111
  Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
@@ -156,7 +156,7 @@ It offers a wide variety of features, for example:
156
156
  "callsWithAssignmentProducers": 0,
157
157
  "callsWithNonConstantProducers": 0,
158
158
  "searchTimeMs": 0,
159
- "processTimeMs": 0
159
+ "processTimeMs": 1
160
160
  }
161
161
  },
162
162
  "absolute-file-paths": {
@@ -175,8 +175,8 @@ It offers a wide variety of features, for example:
175
175
  ".meta": {
176
176
  "totalConsidered": 1,
177
177
  "totalUnknown": 0,
178
- "searchTimeMs": 2,
179
- "processTimeMs": 0
178
+ "searchTimeMs": 1,
179
+ "processTimeMs": 1
180
180
  }
181
181
  },
182
182
  "unused-definitions": {
@@ -219,12 +219,12 @@ It offers a wide variety of features, for example:
219
219
  ".meta": {
220
220
  "numOfUselessLoops": 0,
221
221
  "searchTimeMs": 0,
222
- "processTimeMs": 0
222
+ "processTimeMs": 1
223
223
  }
224
224
  }
225
225
  },
226
226
  ".meta": {
227
- "timing": 13
227
+ "timing": 14
228
228
  }
229
229
  },
230
230
  ".meta": {
@@ -295,7 +295,7 @@ It offers a wide variety of features, for example:
295
295
 
296
296
  ```shell
297
297
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
298
- flowR repl using flowR v2.4.5, R v4.5.0 (r-shell engine)
298
+ flowR repl using flowR v2.4.7, R v4.5.0 (r-shell engine)
299
299
  R> :slicer test/testfiles/example.R --criterion "11@sum"
300
300
  ```
301
301
 
@@ -342,7 +342,7 @@ It offers a wide variety of features, for example:
342
342
 
343
343
 
344
344
  * 🚀 **fast data- and control-flow graphs**\
345
- Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">135.6 ms</span></i> (as of Aug 20, 2025),
345
+ Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">135.1 ms</span></i> (as of Aug 20, 2025),
346
346
  _flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
347
347
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the dataflow graph.
348
348
 
@@ -378,7 +378,7 @@ It offers a wide variety of features, for example:
378
378
 
379
379
  ```shell
380
380
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
381
- flowR repl using flowR v2.4.5, R v4.5.0 (r-shell engine)
381
+ flowR repl using flowR v2.4.7, R v4.5.0 (r-shell engine)
382
382
  R> :dataflow* test/testfiles/example.R
383
383
  ```
384
384
 
@@ -493,7 +493,7 @@ It offers a wide variety of features, for example:
493
493
  *7.10-20*
494
494
  (26, 27)`"]]
495
495
  23["`#91;RSymbol#93; sum
496
- (23, :may:)
496
+ (23, :may:36+)
497
497
  *7.3-5*`"]
498
498
  29[["`#91;RBinaryOp#93; #60;#45;
499
499
  (29, :may:36+)
@@ -510,7 +510,7 @@ It offers a wide variety of features, for example:
510
510
  *8.14-24*
511
511
  (31, 32)`"]]
512
512
  30["`#91;RSymbol#93; product
513
- (30, :may:)
513
+ (30, :may:36+)
514
514
  *8.3-9*`"]
515
515
  34[["`#91;RBinaryOp#93; #60;#45;
516
516
  (34, :may:36+)
@@ -622,64 +622,68 @@ It offers a wide variety of features, for example:
622
622
  linkStyle 44 stroke:gray,color:gray;
623
623
  23 -->|"defined-by"| 28
624
624
  23 -->|"defined-by"| 29
625
+ 23 -->|"CD-True"| 36
626
+ linkStyle 47 stroke:gray,color:gray;
625
627
  29 -->|"argument"| 28
626
628
  29 -->|"returns, argument"| 23
627
629
  29 -.->|"reads, calls"| built-in:_-
628
- linkStyle 49 stroke:gray;
630
+ linkStyle 50 stroke:gray;
629
631
  29 -->|"CD-True"| 36
630
- linkStyle 50 stroke:gray,color:gray;
632
+ linkStyle 51 stroke:gray,color:gray;
631
633
  31 -->|"reads"| 3
632
634
  31 -->|"reads"| 30
633
635
  31 -->|"CD-True"| 36
634
- linkStyle 53 stroke:gray,color:gray;
636
+ linkStyle 54 stroke:gray,color:gray;
635
637
  32 -->|"reads"| 12
636
638
  32 -->|"CD-True"| 36
637
- linkStyle 55 stroke:gray,color:gray;
639
+ linkStyle 56 stroke:gray,color:gray;
638
640
  33 -->|"reads, argument"| 31
639
641
  33 -->|"reads, argument"| 32
640
642
  33 -.->|"reads, calls"| built-in:_
641
- linkStyle 58 stroke:gray;
643
+ linkStyle 59 stroke:gray;
642
644
  33 -->|"CD-True"| 36
643
- linkStyle 59 stroke:gray,color:gray;
645
+ linkStyle 60 stroke:gray,color:gray;
644
646
  30 -->|"defined-by"| 33
645
647
  30 -->|"defined-by"| 34
648
+ 30 -->|"CD-True"| 36
649
+ linkStyle 63 stroke:gray,color:gray;
646
650
  34 -->|"argument"| 33
647
651
  34 -->|"returns, argument"| 30
648
652
  34 -.->|"reads, calls"| built-in:_-
649
- linkStyle 64 stroke:gray;
653
+ linkStyle 66 stroke:gray;
650
654
  34 -->|"CD-True"| 36
651
- linkStyle 65 stroke:gray,color:gray;
655
+ linkStyle 67 stroke:gray,color:gray;
652
656
  35 -->|"argument"| 29
653
657
  35 -->|"returns, argument"| 34
654
658
  35 -.->|"reads, calls"| built-in:_
655
- linkStyle 68 stroke:gray;
659
+ linkStyle 70 stroke:gray;
656
660
  35 -->|"CD-True"| 36
657
- linkStyle 69 stroke:gray,color:gray;
661
+ linkStyle 71 stroke:gray,color:gray;
658
662
  36 -->|"argument"| 12
659
663
  36 -->|"reads, argument"| 20
660
664
  36 -->|"argument, non-standard-evaluation"| 35
661
665
  36 -.->|"reads, calls"| built-in:for
662
- linkStyle 73 stroke:gray;
666
+ linkStyle 75 stroke:gray;
663
667
  40 -->|"reads"| 0
664
668
  40 -->|"reads"| 23
665
669
  40 -.->|"reads"| built-in:sum
666
- linkStyle 76 stroke:gray;
670
+ linkStyle 78 stroke:gray;
667
671
  44 -->|"argument"| 38
668
672
  44 -->|"reads, argument"| 40
669
673
  44 -->|"argument"| 42
670
674
  44 -.->|"reads, calls"| built-in:cat
671
- linkStyle 80 stroke:gray;
675
+ linkStyle 82 stroke:gray;
672
676
  48 -->|"reads"| 3
673
677
  48 -->|"reads"| 30
674
678
  52 -->|"argument"| 46
675
679
  52 -->|"reads, argument"| 48
676
680
  52 -->|"argument"| 50
677
681
  52 -.->|"reads, calls"| built-in:cat
678
- linkStyle 86 stroke:gray;
682
+ linkStyle 88 stroke:gray;
679
683
  ```
680
684
 
681
685
 
682
- (The analysis required _14.5 ms_ (including parse and normalize, using the [r-shell](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
686
+ (The analysis required _14.9 ms_ (including parse and normalize, using the [r-shell](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
683
687
 
684
688
 
685
689
 
@@ -137,7 +137,7 @@ class DataFrameShapeInferenceVisitor extends semantic_cfg_guided_visitor_1.Seman
137
137
  }
138
138
  /** Get all AST nodes for the predecessor vertices that are leaf nodes and exit vertices */
139
139
  getPredecessorNodes(vertexId) {
140
- return [...this.config.controlFlow.graph.outgoingEdges(vertexId)?.keys() ?? []] // outgoing dependency edges are incoming CFG edges
140
+ return this.config.controlFlow.graph.outgoingEdges(vertexId)?.keys() // outgoing dependency edges are incoming CFG edges
141
141
  .map(id => this.getCfgVertex(id))
142
142
  .flatMap(vertex => {
143
143
  if (vertex === undefined) {
@@ -150,7 +150,8 @@ class DataFrameShapeInferenceVisitor extends semantic_cfg_guided_visitor_1.Seman
150
150
  return [this.getNormalizedAst((0, control_flow_graph_1.getVertexRootId)(vertex))];
151
151
  }
152
152
  })
153
- .filter(assert_1.isNotUndefined);
153
+ .filter(assert_1.isNotUndefined)
154
+ .toArray() ?? [];
154
155
  }
155
156
  shouldWiden(vertex) {
156
157
  return (this.visited.get(vertex.id) ?? 0) >= this.config.flowrConfig.abstractInterpretation.dataFrame.wideningThreshold;
@@ -0,0 +1,40 @@
1
+ import type { AbstractDomain } from '../domains/abstract-domain';
2
+ import { PosIntervalDomain } from '../domains/positive-interval-domain';
3
+ import { ProductDomain } from '../domains/product-domain';
4
+ import { SetBoundedSetDomain } from '../domains/set-bounded-set-domain';
5
+ import { StateAbstractDomain } from '../domains/state-abstract-domain';
6
+ /** The type of the abstract product representing the shape of data frames */
7
+ export type AbstractDataFrameShape = {
8
+ colnames: SetBoundedSetDomain<string>;
9
+ cols: PosIntervalDomain;
10
+ rows: PosIntervalDomain;
11
+ };
12
+ /** The type of abstract values of a sub abstract domain (shape property) of the data frame shape product */
13
+ type DataFrameShapeProperty<Property extends keyof AbstractDataFrameShape> = AbstractDataFrameShape[Property] extends AbstractDomain<unknown, unknown, unknown, unknown, infer Lift> ? Lift : never;
14
+ /**
15
+ * The data frame abstract domain as product domain of a column names domain, column count domain, and row count domain.
16
+ */
17
+ export declare class DataFrameDomain extends ProductDomain<AbstractDataFrameShape> {
18
+ constructor(value: AbstractDataFrameShape, maxColNames?: number);
19
+ create(value: AbstractDataFrameShape, maxColNames?: number): DataFrameDomain;
20
+ /**
21
+ * The current abstract value of the column names domain.
22
+ */
23
+ get colnames(): DataFrameShapeProperty<'colnames'>;
24
+ /**
25
+ * The current abstract value of the column count domain.
26
+ */
27
+ get cols(): DataFrameShapeProperty<'cols'>;
28
+ /**
29
+ * The current abstract value of the row count domain.
30
+ */
31
+ get rows(): DataFrameShapeProperty<'rows'>;
32
+ static bottom(maxColNames?: number): DataFrameDomain;
33
+ static top(maxColNames?: number): DataFrameDomain;
34
+ }
35
+ /**
36
+ * The data frame state abstract domain as state abstract domain mapping AST node IDs to inferred abstract data frame shapes.
37
+ */
38
+ export declare class DateFrameStateDomain extends StateAbstractDomain<DataFrameDomain> {
39
+ }
40
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateFrameStateDomain = exports.DataFrameDomain = void 0;
4
+ const positive_interval_domain_1 = require("../domains/positive-interval-domain");
5
+ const product_domain_1 = require("../domains/product-domain");
6
+ const set_bounded_set_domain_1 = require("../domains/set-bounded-set-domain");
7
+ const state_abstract_domain_1 = require("../domains/state-abstract-domain");
8
+ /**
9
+ * The data frame abstract domain as product domain of a column names domain, column count domain, and row count domain.
10
+ */
11
+ class DataFrameDomain extends product_domain_1.ProductDomain {
12
+ constructor(value, maxColNames) {
13
+ super({
14
+ colnames: new set_bounded_set_domain_1.SetBoundedSetDomain(value.colnames.value, maxColNames),
15
+ cols: new positive_interval_domain_1.PosIntervalDomain(value.cols.value),
16
+ rows: new positive_interval_domain_1.PosIntervalDomain(value.rows.value)
17
+ });
18
+ }
19
+ create(value, maxColNames) {
20
+ return new DataFrameDomain(value, maxColNames);
21
+ }
22
+ /**
23
+ * The current abstract value of the column names domain.
24
+ */
25
+ get colnames() {
26
+ return this.value.colnames.value;
27
+ }
28
+ /**
29
+ * The current abstract value of the column count domain.
30
+ */
31
+ get cols() {
32
+ return this.value.cols.value;
33
+ }
34
+ /**
35
+ * The current abstract value of the row count domain.
36
+ */
37
+ get rows() {
38
+ return this.value.rows.value;
39
+ }
40
+ static bottom(maxColNames) {
41
+ return new DataFrameDomain({
42
+ colnames: set_bounded_set_domain_1.SetBoundedSetDomain.bottom(maxColNames),
43
+ cols: positive_interval_domain_1.PosIntervalDomain.bottom(),
44
+ rows: positive_interval_domain_1.PosIntervalDomain.bottom()
45
+ });
46
+ }
47
+ static top(maxColNames) {
48
+ return new DataFrameDomain({
49
+ colnames: set_bounded_set_domain_1.SetBoundedSetDomain.top(maxColNames),
50
+ cols: positive_interval_domain_1.PosIntervalDomain.top(),
51
+ rows: positive_interval_domain_1.PosIntervalDomain.top()
52
+ });
53
+ }
54
+ }
55
+ exports.DataFrameDomain = DataFrameDomain;
56
+ /**
57
+ * The data frame state abstract domain as state abstract domain mapping AST node IDs to inferred abstract data frame shapes.
58
+ */
59
+ class DateFrameStateDomain extends state_abstract_domain_1.StateAbstractDomain {
60
+ }
61
+ exports.DateFrameStateDomain = DateFrameStateDomain;
62
+ //# sourceMappingURL=dataframe-domain.js.map
@@ -105,7 +105,7 @@ function subtractColNames(set1, set2) {
105
105
  * However, this speeds up the iteration in larger loops significantly, as we are over-approximating the column names much earlier.
106
106
  */
107
107
  function wideningColNames(set1, set2) {
108
- return leqColNames(set1, set2) ? set2 : exports.ColNamesTop;
108
+ return leqColNames(set2, set1) ? set1 : exports.ColNamesTop;
109
109
  }
110
110
  /** Checks whether an abstract value of the column names domain satisfies a column name */
111
111
  function satisfiesColsNames(set, value) {
@@ -0,0 +1,56 @@
1
+ import type { Bottom, Lattice, Top } from './lattice';
2
+ /**
3
+ * The default limit of inferred constraints in {@link AbstractDomain|AbstractDomains}.
4
+ */
5
+ export declare const DEFAULT_INFERENCE_LIMIT = 50;
6
+ /**
7
+ * An abstract domain as complete lattice with a widening operator, narrowing operator, concretization function, and abstraction function.
8
+ * @template Concrete - Type of an concrete element of the concrete domain for the abstract domain
9
+ * @template Abstract - Type of an abstract element of the abstract domain representing possible elements (may exclude `Top` and `Bot`)
10
+ * @template Top - Type of the Top element of the abstract domain representing all possible elements (defaults to {@link Top})
11
+ * @template Bot - Type of the Bottom element of the abstract domain representing no possible elements (defaults to {@link Bottom})
12
+ * @template Lift - Type of the abstract elements of the abstract domain (defaults to `Abstract` or `Top` or `Bot`)
13
+ */
14
+ export interface AbstractDomain<Concrete, Abstract, Top = typeof Top, Bot = typeof Bottom, Lift extends Abstract | Top | Bot = Abstract | Top | Bot> extends Lattice<Abstract, Top, Bot, Lift> {
15
+ /**
16
+ * Widens the current abstract value with another abstract value as a sound over-approximation of the join (least upper bound) for fixpoint iteration acceleration.
17
+ */
18
+ widen(other: AbstractDomain<Concrete, Abstract, Top, Bot>): AbstractDomain<Concrete, Abstract, Top, Bot>;
19
+ /**
20
+ * Narrows the current abstract value with another abstract value as a sound over-approximation of the meet (greatest lower bound) to refine the value after widening.
21
+ */
22
+ narrow(other: AbstractDomain<Concrete, Abstract, Top, Bot>): AbstractDomain<Concrete, Abstract, Top, Bot>;
23
+ /**
24
+ * Maps the current abstract value into a set of possible concrete values as concretization function of the abstract domain.
25
+ * The result should be `Top` if the number of concrete values would reach the `limit` or the resulting set would have infinite many elements.
26
+ */
27
+ concretize(limit?: number): ReadonlySet<Concrete> | typeof Top;
28
+ /**
29
+ * Maps a set of possible concrete values into an abstract value as abstraction function of the abstract domain (should additionally be provided as static function).
30
+ */
31
+ abstract(concrete: ReadonlySet<Concrete> | typeof Top): AbstractDomain<Concrete, Abstract, Top, Bot>;
32
+ }
33
+ /**
34
+ * The type of the concrete domain of an abstract domain.
35
+ * @template Domain - The abstract domain to get the concrete domain type for
36
+ */
37
+ export type ConcreteDomain<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<infer Concrete, unknown, unknown, unknown> ? Concrete : never;
38
+ /**
39
+ * The type of the Top element (greatest element) of an abstract domain.
40
+ * @template Domain - The abstract domain to get the Top element type for
41
+ */
42
+ export type AbstractDomainTop<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<unknown, unknown, infer Top, unknown> ? Top : never;
43
+ /**
44
+ * The type of the Bottom element (least element) of an abstract domain.
45
+ * @template Domain - The abstract domain to get the Bottom element type for
46
+ */
47
+ export type AbstractDomainBottom<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<unknown, unknown, unknown, infer Bot> ? Bot : never;
48
+ /**
49
+ * The type of the abstract values of an abstract domain (including the Top and Bottom element).
50
+ * @template Domain - The abstract domain to get the abstract value type for
51
+ */
52
+ export type AbstractDomainValue<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<unknown, infer Value, infer Top, infer Bot> ? Value | Top | Bot : never;
53
+ /**
54
+ * Converts an element of an abstract domain into a string.
55
+ */
56
+ export declare function domainElementToString(value: AbstractDomain<unknown, unknown, unknown, unknown> | unknown): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_INFERENCE_LIMIT = void 0;
4
+ exports.domainElementToString = domainElementToString;
5
+ /**
6
+ * The default limit of inferred constraints in {@link AbstractDomain|AbstractDomains}.
7
+ */
8
+ exports.DEFAULT_INFERENCE_LIMIT = 50;
9
+ /**
10
+ * Converts an element of an abstract domain into a string.
11
+ */
12
+ function domainElementToString(value) {
13
+ if (typeof value === 'object' && value !== null && value.toString !== Object.prototype.toString) {
14
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
15
+ return value.toString();
16
+ }
17
+ return JSON.stringify(value);
18
+ }
19
+ //# sourceMappingURL=abstract-domain.js.map
@@ -0,0 +1,43 @@
1
+ import { type AbstractDomain } from './abstract-domain';
2
+ import { Top } from './lattice';
3
+ /** The type of the actual values of the bounded set domain as set */
4
+ export type BoundedSetValue<T> = ReadonlySet<T>;
5
+ /** The type of the Top element of the bounded set domain as {@link Top} symbol */
6
+ export type BoundedSetTop = typeof Top;
7
+ /** The type of the Bottom element of the bounded set domain as empty set */
8
+ export type BoundedSetBottom = ReadonlySet<never>;
9
+ /** The type of the abstract values of the bounded set domain that are Top, Bottom, or actual values */
10
+ export type BoundedSetLift<T> = BoundedSetValue<T> | BoundedSetTop | BoundedSetBottom;
11
+ /**
12
+ * The bounded set abstract domain as sets of possible values bounded by a `limit` indicating the maximum number of inferred values.
13
+ * The Bottom element is defined as the empty set and the Top element is defined as {@link Top} symbol.
14
+ * @template T - Type of the values in the abstract domain
15
+ * @template Value - Type of the constraint in the abstract domain (Top, Bottom, or an actual value)
16
+ */
17
+ export declare class BoundedSetDomain<T, Value extends BoundedSetLift<T> = BoundedSetLift<T>> implements AbstractDomain<T, BoundedSetValue<T>, BoundedSetTop, BoundedSetBottom, Value> {
18
+ private readonly limit;
19
+ private _value;
20
+ constructor(value: Value, limit?: number);
21
+ get value(): Value;
22
+ static top<T>(limit?: number): BoundedSetDomain<T, BoundedSetTop>;
23
+ static bottom<T>(limit?: number): BoundedSetDomain<T, BoundedSetBottom>;
24
+ static abstract<T>(concrete: ReadonlySet<T> | typeof Top, limit?: number): BoundedSetDomain<T>;
25
+ top(): BoundedSetDomain<T, BoundedSetTop>;
26
+ bottom(): BoundedSetDomain<T, BoundedSetBottom>;
27
+ equals(other: BoundedSetDomain<T>): boolean;
28
+ leq(other: BoundedSetDomain<T>): boolean;
29
+ join(...values: BoundedSetDomain<T>[]): BoundedSetDomain<T>;
30
+ meet(...values: BoundedSetDomain<T>[]): BoundedSetDomain<T>;
31
+ /**
32
+ * Subtracts another abstract value from the current abstract value by removing all elements of the other abstract value from the current abstract value.
33
+ */
34
+ subtract(other: BoundedSetDomain<T>): BoundedSetDomain<T>;
35
+ widen(other: BoundedSetDomain<T>): BoundedSetDomain<T>;
36
+ narrow(other: BoundedSetDomain<T>): BoundedSetDomain<T>;
37
+ concretize(limit?: number): ReadonlySet<T> | typeof Top;
38
+ abstract(concrete: ReadonlySet<T> | typeof Top): BoundedSetDomain<T>;
39
+ toString(): string;
40
+ isTop(): this is BoundedSetDomain<T, BoundedSetTop>;
41
+ isBottom(): this is BoundedSetDomain<T, BoundedSetBottom>;
42
+ isValue(): this is BoundedSetDomain<T, BoundedSetValue<T>>;
43
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoundedSetDomain = void 0;
4
+ const set_1 = require("../../util/collections/set");
5
+ const abstract_domain_1 = require("./abstract-domain");
6
+ const lattice_1 = require("./lattice");
7
+ /**
8
+ * The bounded set abstract domain as sets of possible values bounded by a `limit` indicating the maximum number of inferred values.
9
+ * The Bottom element is defined as the empty set and the Top element is defined as {@link Top} symbol.
10
+ * @template T - Type of the values in the abstract domain
11
+ * @template Value - Type of the constraint in the abstract domain (Top, Bottom, or an actual value)
12
+ */
13
+ class BoundedSetDomain {
14
+ limit;
15
+ _value;
16
+ constructor(value, limit = abstract_domain_1.DEFAULT_INFERENCE_LIMIT) {
17
+ if (value !== lattice_1.Top) {
18
+ this._value = (value.size > limit ? lattice_1.Top : new Set(value));
19
+ }
20
+ else {
21
+ this._value = value;
22
+ }
23
+ this.limit = limit;
24
+ }
25
+ get value() {
26
+ return this._value;
27
+ }
28
+ static top(limit) {
29
+ return new BoundedSetDomain(lattice_1.Top, limit);
30
+ }
31
+ static bottom(limit) {
32
+ return new BoundedSetDomain(new Set(), limit);
33
+ }
34
+ static abstract(concrete, limit) {
35
+ return new BoundedSetDomain(concrete, limit);
36
+ }
37
+ top() {
38
+ return BoundedSetDomain.top(this.limit);
39
+ }
40
+ bottom() {
41
+ return BoundedSetDomain.bottom(this.limit);
42
+ }
43
+ equals(other) {
44
+ return this.value === other.value || (this.isValue() && other.isValue() && (0, set_1.setEquals)(this.value, other.value));
45
+ }
46
+ leq(other) {
47
+ return other.value === lattice_1.Top || (this.isValue() && this.value.isSubsetOf(other.value));
48
+ }
49
+ join(...values) {
50
+ const result = new BoundedSetDomain(this.value, this.limit);
51
+ for (const other of values) {
52
+ if (result.value === lattice_1.Top || other.value === lattice_1.Top) {
53
+ result._value = lattice_1.Top;
54
+ }
55
+ else {
56
+ const join = result.value.union(other.value);
57
+ result._value = join.size > this.limit ? lattice_1.Top : join;
58
+ }
59
+ }
60
+ return result;
61
+ }
62
+ meet(...values) {
63
+ const result = new BoundedSetDomain(this.value, this.limit);
64
+ for (const other of values) {
65
+ if (result.value === lattice_1.Top) {
66
+ result._value = other.value;
67
+ }
68
+ else if (other.value === lattice_1.Top) {
69
+ result._value = result.value;
70
+ }
71
+ else {
72
+ result._value = result.value.intersection(other.value);
73
+ }
74
+ }
75
+ return result;
76
+ }
77
+ /**
78
+ * Subtracts another abstract value from the current abstract value by removing all elements of the other abstract value from the current abstract value.
79
+ */
80
+ subtract(other) {
81
+ if (this.value === lattice_1.Top) {
82
+ return this.top();
83
+ }
84
+ else if (other.value === lattice_1.Top) {
85
+ return new BoundedSetDomain(this.value, this.limit);
86
+ }
87
+ else {
88
+ return new BoundedSetDomain(this.value.difference(other.value), this.limit);
89
+ }
90
+ }
91
+ widen(other) {
92
+ return other.leq(this) ? new BoundedSetDomain(this.value, this.limit) : this.top();
93
+ }
94
+ narrow(other) {
95
+ return this.isTop() ? other : this;
96
+ }
97
+ concretize(limit = this.limit) {
98
+ return this.value === lattice_1.Top || this.value.size > limit ? lattice_1.Top : this.value;
99
+ }
100
+ abstract(concrete) {
101
+ return BoundedSetDomain.abstract(concrete, this.limit);
102
+ }
103
+ toString() {
104
+ if (this.value === lattice_1.Top) {
105
+ return '⊤';
106
+ }
107
+ const string = this.value.values().map(abstract_domain_1.domainElementToString).toArray().join(', ');
108
+ return `{${string}}`;
109
+ }
110
+ isTop() {
111
+ return this.value === lattice_1.Top;
112
+ }
113
+ isBottom() {
114
+ return this.value !== lattice_1.Top && this.value.size === 0;
115
+ }
116
+ isValue() {
117
+ return this.value !== lattice_1.Top;
118
+ }
119
+ }
120
+ exports.BoundedSetDomain = BoundedSetDomain;
121
+ //# sourceMappingURL=bounded-set-domain.js.map
@@ -0,0 +1,61 @@
1
+ import { type AbstractDomain } from './abstract-domain';
2
+ import { Bottom, Top } from './lattice';
3
+ /** The type of the actual values of the interval domain as tuple of the lower and upper bound */
4
+ export type IntervalValue = readonly [number, number];
5
+ /** The type of the Top element of the interval domain as interval [-∞, +∞] from -∞ to +∞ */
6
+ export type IntervalTop = readonly [typeof Infinity, typeof Infinity];
7
+ /** The type of the Bottom element of the interval domain as {@link Bottom} symbol */
8
+ export type IntervalBottom = typeof Bottom;
9
+ /** The type of the abstract values of the interval domain that are Top, Bottom, or actual values */
10
+ export type IntervalLift = IntervalValue | IntervalTop | IntervalBottom;
11
+ /**
12
+ * The interval abstract domain as intervals with possibly infinite bounds representing possible numeric values.
13
+ * The Bottom element is defined as {@link Bottom} symbol and the Top element is defined as the interval [-∞, +∞].
14
+ * @template Value - Type of the constraint in the abstract domain (Top, Bottom, or an actual value)
15
+ */
16
+ export declare class IntervalDomain<Value extends IntervalLift = IntervalLift> implements AbstractDomain<number, IntervalValue, IntervalTop, IntervalBottom, Value> {
17
+ private _value;
18
+ constructor(value: Value);
19
+ get value(): Value;
20
+ static top(): IntervalDomain<IntervalTop>;
21
+ static bottom(): IntervalDomain<IntervalBottom>;
22
+ static abstract(concrete: ReadonlySet<number> | typeof Top): IntervalDomain;
23
+ top(): IntervalDomain<IntervalTop>;
24
+ bottom(): IntervalDomain<IntervalBottom>;
25
+ equals(other: IntervalDomain): boolean;
26
+ leq(other: IntervalDomain): boolean;
27
+ join(...values: IntervalDomain[]): IntervalDomain;
28
+ meet(...values: IntervalDomain[]): IntervalDomain;
29
+ widen(other: IntervalDomain): IntervalDomain;
30
+ narrow(other: IntervalDomain): IntervalDomain;
31
+ concretize(limit?: number): ReadonlySet<number> | typeof Top;
32
+ abstract(concrete: ReadonlySet<number> | typeof Top): IntervalDomain;
33
+ /**
34
+ * Adds another abstract value to the current abstract value by adding the two lower and upper bounds, respectively.
35
+ */
36
+ add(other: IntervalDomain): IntervalDomain;
37
+ /**
38
+ * Subtracts another abstract value from the current abstract value by subtracting the two lower and upper bounds from each other, respectively.
39
+ */
40
+ subtract(other: IntervalDomain): IntervalDomain;
41
+ /**
42
+ * Creates the minimum between the current abstract value and another abstract value by creating the minimum of the two lower and upper bounds, respectively.
43
+ */
44
+ min(other: IntervalDomain): IntervalDomain;
45
+ /**
46
+ * Creates the maximum between the current abstract value and another abstract value by creating the maximum of the two lower and upper bounds, respectively.
47
+ */
48
+ max(other: IntervalDomain): IntervalDomain;
49
+ /**
50
+ * Extends the lower bound of the current abstract value down to -∞.
51
+ */
52
+ extendDown(): IntervalDomain;
53
+ /**
54
+ * Extends the upper bound of the current abstract value up to +∞.
55
+ */
56
+ extendUp(): IntervalDomain;
57
+ toString(): string;
58
+ isTop(): this is IntervalDomain<IntervalTop>;
59
+ isBottom(): this is IntervalDomain<IntervalBottom>;
60
+ isValue(): this is IntervalDomain<IntervalValue>;
61
+ }