@eagleoutice/flowr 2.2.13 → 2.2.15

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 (145) hide show
  1. package/README.md +4 -4
  2. package/cli/repl/commands/repl-cfg.d.ts +2 -2
  3. package/cli/repl/commands/repl-cfg.js +4 -4
  4. package/cli/repl/commands/repl-commands.js +3 -3
  5. package/cli/repl/commands/repl-execute.js +2 -1
  6. package/cli/repl/server/connection.js +1 -1
  7. package/cli/script-core/statistics-helper-core.js +1 -1
  8. package/config.js +1 -1
  9. package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
  10. package/control-flow/cfg-dead-code.d.ts +4 -0
  11. package/control-flow/cfg-dead-code.js +81 -0
  12. package/control-flow/cfg-simplification.d.ts +17 -6
  13. package/control-flow/cfg-simplification.js +23 -19
  14. package/control-flow/control-flow-graph.d.ts +2 -1
  15. package/control-flow/control-flow-graph.js +1 -0
  16. package/control-flow/dfg-cfg-guided-visitor.d.ts +4 -4
  17. package/control-flow/dfg-cfg-guided-visitor.js +1 -1
  18. package/control-flow/extract-cfg.d.ts +2 -2
  19. package/control-flow/extract-cfg.js +70 -67
  20. package/control-flow/semantic-cfg-guided-visitor.d.ts +17 -8
  21. package/control-flow/semantic-cfg-guided-visitor.js +50 -17
  22. package/control-flow/simple-visitor.d.ts +4 -0
  23. package/control-flow/simple-visitor.js +14 -0
  24. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -2
  25. package/dataflow/environments/built-in-config.d.ts +1 -0
  26. package/dataflow/environments/built-in.d.ts +10 -1
  27. package/dataflow/environments/built-in.js +9 -3
  28. package/dataflow/environments/default-builtin-config.js +1 -1
  29. package/dataflow/environments/resolve-by-name.d.ts +0 -36
  30. package/dataflow/environments/resolve-by-name.js +0 -240
  31. package/dataflow/eval/resolve/alias-tracking.d.ts +87 -0
  32. package/dataflow/eval/resolve/alias-tracking.js +349 -0
  33. package/dataflow/eval/resolve/resolve.d.ts +34 -0
  34. package/dataflow/eval/resolve/resolve.js +93 -0
  35. package/dataflow/eval/values/general.d.ts +27 -0
  36. package/dataflow/eval/values/general.js +73 -0
  37. package/dataflow/eval/values/intervals/interval-constants.d.ts +4 -0
  38. package/dataflow/eval/values/intervals/interval-constants.js +27 -0
  39. package/dataflow/eval/values/logical/logical-constants.d.ts +7 -0
  40. package/dataflow/eval/values/logical/logical-constants.js +31 -0
  41. package/dataflow/eval/values/r-value.d.ts +58 -0
  42. package/dataflow/eval/values/r-value.js +90 -0
  43. package/dataflow/eval/values/scalar/scalar-consatnts.d.ts +15 -0
  44. package/dataflow/eval/values/scalar/scalar-consatnts.js +35 -0
  45. package/dataflow/eval/values/sets/set-constants.d.ts +7 -0
  46. package/dataflow/eval/values/sets/set-constants.js +34 -0
  47. package/dataflow/eval/values/string/string-constants.d.ts +8 -0
  48. package/dataflow/eval/values/string/string-constants.js +40 -0
  49. package/dataflow/eval/values/vectors/vector-constants.d.ts +14 -0
  50. package/dataflow/eval/values/vectors/vector-constants.js +35 -0
  51. package/dataflow/graph/unknown-replacement.d.ts +11 -0
  52. package/dataflow/graph/unknown-replacement.js +12 -0
  53. package/dataflow/graph/unknown-side-effect.d.ts +7 -0
  54. package/dataflow/graph/unknown-side-effect.js +13 -0
  55. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -5
  56. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +4 -2
  57. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +12 -9
  58. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -4
  59. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +9 -2
  60. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +12 -15
  61. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -0
  62. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  63. package/documentation/doc-util/doc-cfg.d.ts +1 -1
  64. package/documentation/doc-util/doc-cfg.js +3 -3
  65. package/documentation/doc-util/doc-query.d.ts +6 -3
  66. package/documentation/doc-util/doc-query.js +3 -1
  67. package/documentation/print-cfg-wiki.js +31 -31
  68. package/documentation/print-dataflow-graph-wiki.js +4 -3
  69. package/documentation/print-engines-wiki.js +1 -1
  70. package/documentation/print-linter-wiki.d.ts +1 -0
  71. package/documentation/print-linter-wiki.js +76 -0
  72. package/documentation/print-query-wiki.js +80 -0
  73. package/linter/linter-executor.d.ts +9 -0
  74. package/linter/linter-executor.js +26 -0
  75. package/linter/linter-format.d.ts +65 -0
  76. package/linter/linter-format.js +9 -0
  77. package/linter/linter-rules.d.ts +42 -0
  78. package/linter/linter-rules.js +14 -0
  79. package/linter/rules/1-deprecated-functions.d.ts +34 -0
  80. package/linter/rules/1-deprecated-functions.js +54 -0
  81. package/linter/rules/2-file-path-validity.d.ts +48 -0
  82. package/linter/rules/2-file-path-validity.js +93 -0
  83. package/package.json +2 -1
  84. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  85. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
  86. package/queries/catalog/call-context-query/call-context-query-format.js +5 -1
  87. package/queries/catalog/cluster-query/cluster-query-format.d.ts +2 -0
  88. package/queries/catalog/cluster-query/cluster-query-format.js +5 -1
  89. package/queries/catalog/config-query/config-query-format.d.ts +1 -0
  90. package/queries/catalog/config-query/config-query-format.js +2 -1
  91. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +3 -0
  92. package/queries/catalog/control-flow-query/control-flow-query-executor.js +20 -0
  93. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +81 -0
  94. package/queries/catalog/control-flow-query/control-flow-query-format.js +34 -0
  95. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
  96. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -1
  97. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  98. package/queries/catalog/dataflow-query/dataflow-query-format.js +9 -1
  99. package/queries/catalog/dependencies-query/dependencies-query-executor.js +33 -32
  100. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -0
  101. package/queries/catalog/dependencies-query/dependencies-query-format.js +10 -1
  102. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
  103. package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -1
  104. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
  105. package/queries/catalog/id-map-query/id-map-query-format.js +2 -1
  106. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -0
  107. package/queries/catalog/lineage-query/lineage-query-format.js +5 -1
  108. package/queries/catalog/linter-query/linter-query-executor.d.ts +3 -0
  109. package/queries/catalog/linter-query/linter-query-executor.js +28 -0
  110. package/queries/catalog/linter-query/linter-query-format.d.ts +80 -0
  111. package/queries/catalog/linter-query/linter-query-format.js +44 -0
  112. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -0
  113. package/queries/catalog/location-map-query/location-map-query-format.js +2 -1
  114. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
  115. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -1
  116. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  117. package/queries/catalog/origin-query/origin-query-format.js +5 -1
  118. package/queries/catalog/project-query/project-query-executor.js +1 -1
  119. package/queries/catalog/project-query/project-query-format.d.ts +1 -0
  120. package/queries/catalog/project-query/project-query-format.js +2 -1
  121. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +3 -3
  122. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -1
  123. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -23
  124. package/queries/catalog/search-query/search-query-format.d.ts +1 -0
  125. package/queries/catalog/search-query/search-query-format.js +5 -1
  126. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  127. package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -1
  128. package/queries/query.d.ts +143 -1
  129. package/queries/query.js +4 -0
  130. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -4
  131. package/r-bridge/retriever.js +1 -1
  132. package/search/flowr-search-builder.d.ts +31 -2
  133. package/search/flowr-search-builder.js +30 -0
  134. package/search/flowr-search.d.ts +7 -1
  135. package/search/search-executor/search-enrichers.d.ts +73 -0
  136. package/search/search-executor/search-enrichers.js +101 -0
  137. package/search/search-executor/search-generators.d.ts +6 -1
  138. package/search/search-executor/search-generators.js +21 -1
  139. package/search/search-executor/search-mappers.d.ts +19 -0
  140. package/search/search-executor/search-mappers.js +21 -0
  141. package/search/search-executor/search-transformer.d.ts +12 -0
  142. package/search/search-executor/search-transformer.js +11 -1
  143. package/slicing/criterion/parse.d.ts +8 -0
  144. package/slicing/criterion/parse.js +20 -0
  145. package/util/version.js +1 -1
@@ -0,0 +1,58 @@
1
+ import type { RNumberValue, RStringValue } from '../../../r-bridge/lang-4.x/convert-values';
2
+ import type { RLogicalValue } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-logical';
3
+ export declare const Top: {
4
+ type: symbol;
5
+ };
6
+ export declare const Bottom: {
7
+ type: symbol;
8
+ };
9
+ export type Lift<N> = N | typeof Top | typeof Bottom;
10
+ export type Unlift<N> = N extends typeof Top ? never : N extends typeof Bottom ? never : N;
11
+ export interface ValueInterval<Limit extends ValueNumber = ValueNumber> {
12
+ type: 'interval';
13
+ start: Limit;
14
+ startInclusive: boolean;
15
+ end: Limit;
16
+ endInclusive: boolean;
17
+ }
18
+ /**
19
+ * An R vector with either a known set of elements or a known domain.
20
+ */
21
+ export interface ValueVector<Elements extends Lift<unknown[]> = Lift<Value[]>, Domain extends Lift<Value> = Lift<Value>> {
22
+ type: 'vector';
23
+ elements: Elements;
24
+ /** if we do not know the amount of elements, we can still know the domain */
25
+ elementDomain: Domain;
26
+ }
27
+ /** describes the static case of we do not know which value */
28
+ export interface ValueSet<Elements extends Lift<unknown[]> = Lift<Value[]>> {
29
+ type: 'set';
30
+ elements: Elements;
31
+ }
32
+ export interface ValueNumber<Num extends Lift<RNumberValue> = Lift<RNumberValue>> {
33
+ type: 'number';
34
+ value: Num;
35
+ }
36
+ export interface ValueString<Str extends Lift<RStringValue> = Lift<RStringValue>> {
37
+ type: 'string';
38
+ value: Str;
39
+ }
40
+ export interface ValueMissing {
41
+ type: 'missing';
42
+ }
43
+ export type TernaryLogical = RLogicalValue | 'maybe';
44
+ export interface ValueLogical {
45
+ type: 'logical';
46
+ value: Lift<TernaryLogical>;
47
+ }
48
+ export type Value = Lift<ValueInterval | ValueVector | ValueSet | ValueNumber | ValueString | ValueLogical | ValueMissing>;
49
+ export type ValueType<V> = V extends {
50
+ type: infer T;
51
+ } ? T : never;
52
+ export type ValueTypes = ValueType<Value>;
53
+ export declare function typeOfValue<V extends Value>(value: V): V['type'];
54
+ export declare function isTop<V extends Lift<unknown>>(value: V): value is typeof Top;
55
+ export declare function isBottom<V extends Lift<unknown>>(value: V): value is typeof Bottom;
56
+ export declare function isValue<V extends Lift<unknown>>(value: V): value is Unlift<V>;
57
+ export declare function asValue<V extends Lift<unknown>>(value: V): Unlift<V>;
58
+ export declare function stringifyValue(value: Lift<Value>): string;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Bottom = exports.Top = void 0;
4
+ exports.typeOfValue = typeOfValue;
5
+ exports.isTop = isTop;
6
+ exports.isBottom = isBottom;
7
+ exports.isValue = isValue;
8
+ exports.asValue = asValue;
9
+ exports.stringifyValue = stringifyValue;
10
+ const assert_1 = require("../../../util/assert");
11
+ exports.Top = { type: Symbol('⊤') };
12
+ exports.Bottom = { type: Symbol('⊥') };
13
+ function typeOfValue(value) {
14
+ return value.type;
15
+ }
16
+ // @ts-expect-error -- this is a save cast
17
+ function isTop(value) {
18
+ return value === exports.Top;
19
+ }
20
+ // @ts-expect-error -- this is a save cast
21
+ function isBottom(value) {
22
+ return value === exports.Bottom;
23
+ }
24
+ function isValue(value) {
25
+ return !isTop(value) && !isBottom(value);
26
+ }
27
+ function asValue(value) {
28
+ (0, assert_1.guard)(isValue(value), 'Expected a value, but got a top or bottom value');
29
+ return value;
30
+ }
31
+ function tryStringifyBoTop(value, otherwise, onTop = () => '⊤', onBottom = () => '⊥') {
32
+ if (isTop(value)) {
33
+ return onTop();
34
+ }
35
+ else if (isBottom(value)) {
36
+ return onBottom();
37
+ }
38
+ else {
39
+ return otherwise(value);
40
+ }
41
+ }
42
+ function stringifyRNumberSuffix(value) {
43
+ let suffix = '';
44
+ if (value.markedAsInt) {
45
+ suffix += 'L';
46
+ }
47
+ if (value.complexNumber) {
48
+ suffix += 'i';
49
+ }
50
+ // do something about iL even though it is impossible?
51
+ return suffix;
52
+ }
53
+ function renderString(value) {
54
+ const quote = value.quotes;
55
+ const raw = value.flag === 'raw';
56
+ if (raw) {
57
+ return `r${quote}(${value.str})${quote}`;
58
+ }
59
+ else {
60
+ return `${quote}${JSON.stringify(value.str).slice(1, -1)}${quote}`;
61
+ }
62
+ }
63
+ function stringifyValue(value) {
64
+ return tryStringifyBoTop(value, v => {
65
+ const t = v.type;
66
+ switch (t) {
67
+ case 'interval':
68
+ return `${v.startInclusive ? '[' : '('}${stringifyValue(v.start)}, ${stringifyValue(v.end)}${v.endInclusive ? ']' : ')'}`;
69
+ case 'vector':
70
+ return tryStringifyBoTop(v.elements, e => {
71
+ return `<${stringifyValue(v.elementDomain)}> c(${e.map(stringifyValue).join(',')})`;
72
+ }, () => `⊤ (vector, ${stringifyValue(v.elementDomain)})`, () => `⊥ (vector, ${stringifyValue(v.elementDomain)})`);
73
+ case 'set':
74
+ return tryStringifyBoTop(v.elements, e => {
75
+ return e.length === 1 ? stringifyValue(e[0]) : `{ ${e.map(stringifyValue).join(',')} }`;
76
+ }, () => '⊤ (set)', () => '⊥ (set)');
77
+ case 'number':
78
+ return tryStringifyBoTop(v.value, n => `${n.num}${stringifyRNumberSuffix(n)}`, () => '⊤ (number)', () => '⊥ (number)');
79
+ case 'string':
80
+ return tryStringifyBoTop(v.value, renderString, () => '⊤ (string)', () => '⊥ (string)');
81
+ case 'logical':
82
+ return tryStringifyBoTop(v.value, l => l === 'maybe' ? 'maybe' : l ? 'TRUE' : 'FALSE', () => '⊤ (logical)', () => '⊥ (logical)');
83
+ case 'missing':
84
+ return '(missing)';
85
+ default:
86
+ (0, assert_1.assertUnreachable)(t);
87
+ }
88
+ });
89
+ }
90
+ //# sourceMappingURL=r-value.js.map
@@ -0,0 +1,15 @@
1
+ import type { Lift, ValueNumber } from '../r-value';
2
+ import type { RNumberValue } from '../../../../r-bridge/lang-4.x/convert-values';
3
+ export declare function getScalarFromInteger(num: number, markedAsInt?: boolean, complexNumber?: boolean): ValueNumber<RNumberValue>;
4
+ export declare function liftScalar(value: Lift<RNumberValue>): ValueNumber;
5
+ export declare const ValueIntegerOne: ValueNumber<RNumberValue>;
6
+ export declare const ValueNumberComplexOne: ValueNumber<RNumberValue>;
7
+ export declare const ValueIntegerZero: ValueNumber<RNumberValue>;
8
+ export declare const ValueIntegerNegativeOne: ValueNumber<RNumberValue>;
9
+ export declare const ValueIntegerPositiveInfinity: ValueNumber<RNumberValue>;
10
+ export declare const ValueNumberPositiveInfinity: ValueNumber<RNumberValue>;
11
+ export declare const ValueIntegerNegativeInfinity: ValueNumber<RNumberValue>;
12
+ export declare const ValueNumberEpsilon: ValueNumber<RNumberValue>;
13
+ export declare const ValueNumberOneHalf: ValueNumber<RNumberValue>;
14
+ export declare const ValueIntegerTop: ValueNumber<Lift<RNumberValue>>;
15
+ export declare const ValueIntegerBottom: ValueNumber<Lift<RNumberValue>>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValueIntegerBottom = exports.ValueIntegerTop = exports.ValueNumberOneHalf = exports.ValueNumberEpsilon = exports.ValueIntegerNegativeInfinity = exports.ValueNumberPositiveInfinity = exports.ValueIntegerPositiveInfinity = exports.ValueIntegerNegativeOne = exports.ValueIntegerZero = exports.ValueNumberComplexOne = exports.ValueIntegerOne = void 0;
4
+ exports.getScalarFromInteger = getScalarFromInteger;
5
+ exports.liftScalar = liftScalar;
6
+ const r_value_1 = require("../r-value");
7
+ function getScalarFromInteger(num, markedAsInt = Number.isInteger(num), complexNumber = false) {
8
+ return {
9
+ type: 'number',
10
+ value: {
11
+ markedAsInt,
12
+ num,
13
+ complexNumber
14
+ }
15
+ };
16
+ }
17
+ function liftScalar(value) {
18
+ return {
19
+ type: 'number',
20
+ value: value
21
+ };
22
+ }
23
+ const epsilon = 1e-7;
24
+ exports.ValueIntegerOne = getScalarFromInteger(1);
25
+ exports.ValueNumberComplexOne = getScalarFromInteger(1, false, true);
26
+ exports.ValueIntegerZero = getScalarFromInteger(0);
27
+ exports.ValueIntegerNegativeOne = getScalarFromInteger(-1);
28
+ exports.ValueIntegerPositiveInfinity = getScalarFromInteger(Number.POSITIVE_INFINITY);
29
+ exports.ValueNumberPositiveInfinity = getScalarFromInteger(Number.POSITIVE_INFINITY, false);
30
+ exports.ValueIntegerNegativeInfinity = getScalarFromInteger(Number.NEGATIVE_INFINITY);
31
+ exports.ValueNumberEpsilon = getScalarFromInteger(epsilon, false);
32
+ exports.ValueNumberOneHalf = getScalarFromInteger(0.5, false);
33
+ exports.ValueIntegerTop = liftScalar(r_value_1.Top);
34
+ exports.ValueIntegerBottom = liftScalar(r_value_1.Bottom);
35
+ //# sourceMappingURL=scalar-consatnts.js.map
@@ -0,0 +1,7 @@
1
+ import type { Lift, Value, ValueSet } from '../r-value';
2
+ import { Top } from '../r-value';
3
+ export declare function setFrom<V extends Value[]>(...elements: V): Lift<ValueSet<Value[]>>;
4
+ export declare function isSet<V extends Value>(element: V): boolean;
5
+ export declare const ValueEmptySet: Lift<ValueSet<Value[]>>;
6
+ export declare const ValueSetTop: ValueSet<typeof Top>;
7
+ export declare const ValueSetBottom: ValueSet<typeof Top>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValueSetBottom = exports.ValueSetTop = exports.ValueEmptySet = void 0;
4
+ exports.setFrom = setFrom;
5
+ exports.isSet = isSet;
6
+ const general_1 = require("../general");
7
+ const r_value_1 = require("../r-value");
8
+ function flattenSetElements(s) {
9
+ return (0, general_1.bottomTopGuard)(s) ?? s.flatMap(e => {
10
+ return e.type === 'set' ? flattenSetElements(e.elements) : e;
11
+ });
12
+ }
13
+ function setFrom(...elements) {
14
+ const vals = elements.flatMap(e => {
15
+ return e.type === 'set' ? flattenSetElements(e.elements) : e;
16
+ });
17
+ return (0, general_1.bottomTopGuard)(...vals) ?? {
18
+ type: 'set',
19
+ elements: vals
20
+ };
21
+ }
22
+ function isSet(element) {
23
+ return element.type === 'set';
24
+ }
25
+ exports.ValueEmptySet = setFrom();
26
+ exports.ValueSetTop = {
27
+ type: 'set',
28
+ elements: r_value_1.Top
29
+ };
30
+ exports.ValueSetBottom = {
31
+ type: 'set',
32
+ elements: r_value_1.Top
33
+ };
34
+ //# sourceMappingURL=set-constants.js.map
@@ -0,0 +1,8 @@
1
+ import type { RStringValue } from '../../../../r-bridge/lang-4.x/convert-values';
2
+ import type { Lift, Value, ValueString } from '../r-value';
3
+ export declare function stringFrom(str: RStringValue | string): ValueString;
4
+ export declare function liftString(str: Lift<RStringValue>): ValueString;
5
+ export declare function collectStrings(a: Value[]): string[] | undefined;
6
+ export declare const ValueEmptyString: ValueString<Lift<RStringValue>>;
7
+ export declare const ValueStringTop: ValueString<Lift<RStringValue>>;
8
+ export declare const ValueStringBot: ValueString<Lift<RStringValue>>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValueStringBot = exports.ValueStringTop = exports.ValueEmptyString = void 0;
4
+ exports.stringFrom = stringFrom;
5
+ exports.liftString = liftString;
6
+ exports.collectStrings = collectStrings;
7
+ const general_1 = require("../general");
8
+ const r_value_1 = require("../r-value");
9
+ function stringFrom(str) {
10
+ return {
11
+ type: 'string',
12
+ value: typeof str === 'string' ? {
13
+ quotes: '"',
14
+ str: str
15
+ } : str,
16
+ };
17
+ }
18
+ function liftString(str) {
19
+ return {
20
+ type: 'string',
21
+ value: str
22
+ };
23
+ }
24
+ function collectStrings(a) {
25
+ if ((0, general_1.bottomTopGuard)(a)) {
26
+ return undefined;
27
+ }
28
+ const values = [];
29
+ for (const value of a) {
30
+ if (value.type !== 'string' || !(0, r_value_1.isValue)(value) || !(0, r_value_1.isValue)(value.value)) {
31
+ return undefined;
32
+ }
33
+ values.push(value.value.str);
34
+ }
35
+ return values;
36
+ }
37
+ exports.ValueEmptyString = stringFrom('');
38
+ exports.ValueStringTop = liftString(r_value_1.Top);
39
+ exports.ValueStringBot = liftString(r_value_1.Bottom);
40
+ //# sourceMappingURL=string-constants.js.map
@@ -0,0 +1,14 @@
1
+ import type { Lift, Value, ValueVector } from '../r-value';
2
+ /**
3
+ * Creates an abstract vector from abstract values
4
+ * @param elements - elements that the vector should contain
5
+ * @returns abstract ValueVector
6
+ */
7
+ export declare function vectorFrom<V extends Lift<Value[]>>(elements: V): ValueVector<V>;
8
+ /**
9
+ * Flattens all elements inside of a vector
10
+ * A set containing only one element is also replaced by its only element
11
+ * @param s - vector to flatten
12
+ * @returns flattened vactor, if all elements are not bottom / top
13
+ */
14
+ export declare function flattenVectorElements(s: Lift<Value[]>): Lift<Value[]>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vectorFrom = vectorFrom;
4
+ exports.flattenVectorElements = flattenVectorElements;
5
+ const r_value_1 = require("../r-value");
6
+ const assert_1 = require("../../../../util/assert");
7
+ const general_1 = require("../general");
8
+ /**
9
+ * Creates an abstract vector from abstract values
10
+ * @param elements - elements that the vector should contain
11
+ * @returns abstract ValueVector
12
+ */
13
+ function vectorFrom(elements) {
14
+ (0, assert_1.guard)((0, r_value_1.isTop)(elements) || (0, r_value_1.isBottom)(elements) || Array.isArray(elements), 'Expected array of values');
15
+ return {
16
+ type: 'vector',
17
+ elements,
18
+ elementDomain: r_value_1.Top
19
+ };
20
+ }
21
+ /**
22
+ * Flattens all elements inside of a vector
23
+ * A set containing only one element is also replaced by its only element
24
+ * @param s - vector to flatten
25
+ * @returns flattened vactor, if all elements are not bottom / top
26
+ */
27
+ function flattenVectorElements(s) {
28
+ return (0, general_1.bottomTopGuard)(s) ?? s.flatMap(e => {
29
+ return e.type === 'vector' ? flattenVectorElements(e.elements) :
30
+ e.type === 'set' && (0, r_value_1.isValue)(e.elements) && e.elements.length === 1 ?
31
+ e.elements[0].type === 'vector' ? flattenVectorElements(e.elements[0].elements) : e.elements :
32
+ e;
33
+ });
34
+ }
35
+ //# sourceMappingURL=vector-constants.js.map
@@ -0,0 +1,11 @@
1
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import type { REnvironmentInformation } from '../environments/environment';
3
+ export type ReplacementOperatorHandlerArgs = {
4
+ operator: string;
5
+ target: string | undefined;
6
+ env: REnvironmentInformation;
7
+ id: NodeId;
8
+ };
9
+ export type ReplacementOperatorHandler = (args: ReplacementOperatorHandlerArgs) => void;
10
+ export declare function onReplacementOperator(handler: ReplacementOperatorHandler): void;
11
+ export declare function handleReplacementOperator(args: ReplacementOperatorHandlerArgs): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onReplacementOperator = onReplacementOperator;
4
+ exports.handleReplacementOperator = handleReplacementOperator;
5
+ const handlers = [];
6
+ function onReplacementOperator(handler) {
7
+ handlers.push(handler);
8
+ }
9
+ function handleReplacementOperator(args) {
10
+ handlers.forEach(handler => handler(args));
11
+ }
12
+ //# sourceMappingURL=unknown-replacement.js.map
@@ -0,0 +1,7 @@
1
+ import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
2
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
+ import type { REnvironmentInformation } from '../environments/environment';
4
+ import type { DataflowGraph } from './graph';
5
+ export type UnknownSideEffectHandler = (graph: DataflowGraph, env: REnvironmentInformation, id: NodeId, target?: LinkTo<RegExp | string>) => void;
6
+ export declare function onUnknownSideEffect(handler: UnknownSideEffectHandler): void;
7
+ export declare function handleUnknownSideEffect(graph: DataflowGraph, env: REnvironmentInformation, id: NodeId, target?: LinkTo<RegExp | string>): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onUnknownSideEffect = onUnknownSideEffect;
4
+ exports.handleUnknownSideEffect = handleUnknownSideEffect;
5
+ const handlers = [];
6
+ function onUnknownSideEffect(handler) {
7
+ handlers.push(handler);
8
+ }
9
+ function handleUnknownSideEffect(graph, env, id, target) {
10
+ graph.markIdForUnknownSideEffects(id, target);
11
+ handlers.forEach(handler => handler(graph, env, id, target));
12
+ }
13
+ //# sourceMappingURL=unknown-side-effect.js.map
@@ -10,7 +10,10 @@ const edge_1 = require("../../../../../graph/edge");
10
10
  const identifier_1 = require("../../../../../environments/identifier");
11
11
  const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
12
12
  const unnamed_call_handling_1 = require("../unnamed-call-handling");
13
+ const general_1 = require("../../../../../eval/values/general");
14
+ const r_value_1 = require("../../../../../eval/values/r-value");
13
15
  const log_1 = require("../../../../../../util/log");
16
+ const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
14
17
  function processApply(name, args, rootId, data, config) {
15
18
  const { indexOfFunction = 1, nameOfFunctionArgument, unquoteFunction, resolveInEnvironment, resolveValue } = config;
16
19
  /* as the length is one-based and the argument filter mapping is zero-based, we do not have to subtract 1 */
@@ -54,9 +57,9 @@ function processApply(name, args, rootId, data, config) {
54
57
  else if (val.type === type_1.RType.Symbol) {
55
58
  functionId = val.info.id;
56
59
  if (resolveValue) {
57
- const resolved = (0, resolve_by_name_1.resolveValueOfVariable)(val.content, data.environment);
58
- if (resolved?.length === 1 && typeof resolved[0] === 'string') {
59
- functionName = resolved[0];
60
+ const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: data.environment, idMap: data.completeAst.idMap }));
61
+ if (resolved?.elements.length === 1 && resolved.elements[0].type === 'string') {
62
+ functionName = (0, r_value_1.isValue)(resolved.elements[0].value) ? resolved.elements[0].value.str : undefined;
60
63
  }
61
64
  }
62
65
  else {
@@ -72,7 +75,7 @@ function processApply(name, args, rootId, data, config) {
72
75
  logger_1.dataflowLogger.warn(`Expected symbol or string as function argument at index ${index}, but got ${JSON.stringify(val)} instead.`);
73
76
  return information;
74
77
  }
75
- const allOtherArguments = processedArguments.filter((_, i) => i !== index).map((arg, i) => {
78
+ const allOtherArguments = processedArguments.map((arg, i) => {
76
79
  const counterpart = args[i];
77
80
  if (arg && counterpart !== r_function_call_1.EmptyArgument) {
78
81
  return {
@@ -85,7 +88,7 @@ function processApply(name, args, rootId, data, config) {
85
88
  else {
86
89
  return r_function_call_1.EmptyArgument;
87
90
  }
88
- });
91
+ }).filter((_, i) => i !== index);
89
92
  if (anonymous) {
90
93
  const rootFnId = functionId;
91
94
  functionId = 'anon-' + rootFnId;
@@ -20,6 +20,8 @@ const containers_1 = require("../../../../../../util/containers");
20
20
  const config_1 = require("../../../../../../config");
21
21
  const named_call_handling_1 = require("../named-call-handling");
22
22
  const built_in_1 = require("../../../../../environments/built-in");
23
+ const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
24
+ const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
23
25
  function toReplacementSymbol(target, prefix, superAssignment) {
24
26
  return {
25
27
  type: type_1.RType.Symbol,
@@ -142,7 +144,7 @@ args, rootId, data, config) {
142
144
  name, args: effectiveArgs, rootId, data, forceArgs: config.forceArgs,
143
145
  origin: 'builtin:assignment'
144
146
  }).information;
145
- info.graph.markIdForUnknownSideEffects(rootId);
147
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(info.graph, info.environment, rootId);
146
148
  return info;
147
149
  }
148
150
  function extractSourceAndTarget(args) {
@@ -269,7 +271,7 @@ function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignme
269
271
  function processAssignmentToSymbol(config) {
270
272
  const { nameOfAssignmentFunction, source, args: [targetArg, sourceArg], target, rootId, data, information, makeMaybe, quoteSource } = config;
271
273
  const referenceType = checkTargetReferenceType(source, sourceArg);
272
- const aliases = (0, resolve_by_name_1.getAliases)([source.info.id], information.graph, information.environment);
274
+ const aliases = (0, alias_tracking_1.getAliases)([source.info.id], information.graph, information.environment);
273
275
  const writeNodes = produceWrittenNodes(rootId, targetArg, referenceType, data, makeMaybe ?? false, aliases);
274
276
  if (writeNodes.length !== 1 && log_1.log.settings.minLevel <= 4 /* LogLevel.Warn */) {
275
277
  log_1.log.warn(`Unexpected write number in assignment: ${JSON.stringify(writeNodes)}`);
@@ -12,9 +12,12 @@ const log_1 = require("../../../../../../util/log");
12
12
  const built_in_source_1 = require("./built-in-source");
13
13
  const edge_1 = require("../../../../../graph/edge");
14
14
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
15
- const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
16
15
  const append_1 = require("../../../../../environments/append");
17
16
  const assert_1 = require("../../../../../../util/assert");
17
+ const general_1 = require("../../../../../eval/values/general");
18
+ const string_constants_1 = require("../../../../../eval/values/string/string-constants");
19
+ const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
20
+ const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
18
21
  const arrays_1 = require("../../../../../../util/collections/arrays");
19
22
  function processEvalCall(name, args, rootId, data, config) {
20
23
  if (args.length !== 1 || args[0] === r_function_call_1.EmptyArgument || !args[0].value) {
@@ -30,7 +33,7 @@ function processEvalCall(name, args, rootId, data, config) {
30
33
  }
31
34
  if (!(0, config_1.getConfig)().solver.evalStrings) {
32
35
  (0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping eval call ${JSON.stringify(evalArgument)} (disabled in config file)`);
33
- information.graph.markIdForUnknownSideEffects(rootId);
36
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
34
37
  return information;
35
38
  }
36
39
  const code = resolveEvalToCode(evalArgument.value, data.environment, data.completeAst.idMap);
@@ -62,7 +65,7 @@ function processEvalCall(name, args, rootId, data, config) {
62
65
  };
63
66
  }
64
67
  (0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Non-constant argument ${JSON.stringify(args)} for eval is currently not supported, skipping`);
65
- information.graph.markIdForUnknownSideEffects(rootId);
68
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
66
69
  return information;
67
70
  }
68
71
  function resolveEvalToCode(evalArgument, env, idMap) {
@@ -77,9 +80,9 @@ function resolveEvalToCode(evalArgument, env, idMap) {
77
80
  return [arg.value.content.str];
78
81
  }
79
82
  else if (arg.value?.type === type_1.RType.Symbol) {
80
- const resolve = (0, resolve_by_name_1.resolveValueOfVariable)(arg.value.content, env, idMap);
81
- if (resolve?.every(r => typeof r === 'object' && r !== null && 'str' in r)) {
82
- return resolve.map(r => r.str);
83
+ const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(arg.value.info.id, { environment: env, idMap: idMap }));
84
+ if (resolved) {
85
+ return (0, string_constants_1.collectStrings)(resolved.elements);
83
86
  }
84
87
  }
85
88
  else if (arg.value?.type === type_1.RType.FunctionCall && arg.value.named && ['paste', 'paste0'].includes(arg.value.functionName.content)) {
@@ -104,9 +107,9 @@ function getAsString(val, env, idMap) {
104
107
  return [val.content.str];
105
108
  }
106
109
  else if (val.type === type_1.RType.Symbol) {
107
- const resolved = (0, resolve_by_name_1.resolveValueOfVariable)(val.content, env, idMap);
108
- if (resolved?.every(r => typeof r === 'object' && r !== null && 'str' in r)) {
109
- return resolved.map(r => r.str);
110
+ const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(val.info.id, { environment: env, idMap: idMap }));
111
+ if (resolved) {
112
+ return (0, string_constants_1.collectStrings)(resolved.elements);
110
113
  }
111
114
  }
112
115
  return undefined;
@@ -7,11 +7,12 @@ const known_call_handling_1 = require("../known-call-handling");
7
7
  const common_1 = require("../common");
8
8
  const unpack_argument_1 = require("../argument/unpack-argument");
9
9
  const logger_1 = require("../../../../../logger");
10
- const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
11
10
  const edge_1 = require("../../../../../graph/edge");
12
11
  const append_1 = require("../../../../../environments/append");
13
12
  const identifier_1 = require("../../../../../environments/identifier");
14
13
  const environment_1 = require("../../../../../environments/environment");
14
+ const general_1 = require("../../../../../eval/values/general");
15
+ const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
15
16
  function processIfThenElse(name, args, rootId, data) {
16
17
  if (args.length !== 2 && args.length !== 3) {
17
18
  logger_1.dataflowLogger.warn(`If-then-else ${name.content} has something different from 2 or 3 arguments, skipping`);
@@ -33,9 +34,9 @@ function processIfThenElse(name, args, rootId, data) {
33
34
  let then;
34
35
  let makeThenMaybe = false;
35
36
  // we should defer this to the abstract interpretation
36
- const values = (0, resolve_by_name_1.resolveValueOfVariable)(condArg?.lexeme, data.environment, data.completeAst.idMap);
37
- const conditionIsAlwaysFalse = values?.every(d => d === false) ?? false;
38
- const conditionIsAlwaysTrue = values?.every(d => d === true) ?? false;
37
+ const values = (0, alias_tracking_1.resolveIdToValue)(condArg?.info.id, { environment: data.environment, idMap: data.completeAst.idMap });
38
+ const conditionIsAlwaysFalse = (0, general_1.valueSetGuard)(values)?.elements.every(d => d.type === 'logical' && d.value === false) ?? false;
39
+ const conditionIsAlwaysTrue = (0, general_1.valueSetGuard)(values)?.elements.every(d => d.type === 'logical' && d.value === true) ?? false;
39
40
  if (!conditionIsAlwaysFalse) {
40
41
  then = (0, processor_1.processDataflowFor)(thenArg, data);
41
42
  if (then.entryPoint) {
@@ -17,6 +17,7 @@ const unpack_argument_1 = require("../argument/unpack-argument");
17
17
  const built_in_access_1 = require("./built-in-access");
18
18
  const built_in_1 = require("../../../../../environments/built-in");
19
19
  const identifier_1 = require("../../../../../environments/identifier");
20
+ const unknown_replacement_1 = require("../../../../../graph/unknown-replacement");
20
21
  function processReplacementFunction(name,
21
22
  /** The last one has to be the value */
22
23
  args, rootId, data, config) {
@@ -60,9 +61,15 @@ args, rootId, data, config) {
60
61
  origin: 'builtin:replacement',
61
62
  link: config.assignRootId ? { origin: [config.assignRootId] } : undefined
62
63
  });
63
- const firstArg = (0, unpack_argument_1.unpackArgument)(args[0])?.info.id;
64
+ const firstArg = (0, unpack_argument_1.unpackArgument)(args[0]);
65
+ (0, unknown_replacement_1.handleReplacementOperator)({
66
+ operator: name.content,
67
+ target: firstArg?.lexeme,
68
+ env: res.environment,
69
+ id: rootId
70
+ });
64
71
  if (firstArg) {
65
- res.graph.addEdge(firstArg, rootId, edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Reads);
72
+ res.graph.addEdge(firstArg.info.id, rootId, edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Reads);
66
73
  }
67
74
  /* a replacement reads all of its call args as well, at least as far as I am aware of */
68
75
  for (const arg of callArgs) {