@eagleoutice/flowr 2.17.7 → 2.17.9
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.
- package/abstract-interpretation/branch-paths.d.ts +10 -0
- package/abstract-interpretation/branch-paths.js +104 -10
- package/config.d.ts +1 -1
- package/config.js +40 -8
- package/control-flow/control-flow-graph.js +18 -2
- package/data/r-base-guards.generated.js +2 -2
- package/dataflow/environments/ambient-effect.js +4 -1
- package/dataflow/environments/built-in-props.d.ts +8 -2
- package/dataflow/environments/built-in-props.js +16 -5
- package/dataflow/environments/default-builtin-config/base-functions.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +28 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +8 -4
- package/dataflow/environments/default-builtin-config/index.js +9 -5
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +25 -0
- package/dataflow/environments/guard-facts.d.ts +28 -1
- package/dataflow/environments/pkg-name.d.ts +2 -0
- package/dataflow/environments/query-fn-props.d.ts +19 -15
- package/dataflow/environments/query-fn-props.js +46 -36
- package/dataflow/environments/removal-marker.d.ts +1 -1
- package/dataflow/environments/removal-marker.js +18 -3
- package/dataflow/environments/reserved-names.d.ts +6 -0
- package/dataflow/environments/reserved-names.js +14 -0
- package/dataflow/environments/resolve-by-name.js +5 -10
- package/dataflow/eval/resolve/alias-tracking.js +23 -6
- package/dataflow/extractor.js +103 -28
- package/dataflow/fn/argument-roles.d.ts +3 -0
- package/dataflow/fn/argument-roles.js +5 -5
- package/dataflow/fn/exceptions-of-function.d.ts +7 -0
- package/dataflow/fn/exceptions-of-function.js +15 -2
- package/dataflow/fn/function-props.d.ts +1 -1
- package/dataflow/fn/function-props.js +40 -18
- package/dataflow/fn/function-semantics.d.ts +3 -1
- package/dataflow/fn/function-semantics.js +2 -0
- package/dataflow/fn/guards/built-in-guards.js +2 -1
- package/dataflow/fn/guards/condition-grouping.d.ts +11 -0
- package/dataflow/fn/guards/condition-grouping.js +50 -3
- package/dataflow/fn/guards/function-guards.d.ts +10 -0
- package/dataflow/fn/guards/function-guards.js +130 -14
- package/dataflow/fn/guards/guard-claims.d.ts +2 -0
- package/dataflow/fn/guards/guard-claims.js +42 -2
- package/dataflow/fn/guards/guard-knowledge.d.ts +7 -1
- package/dataflow/fn/guards/guard-knowledge.js +50 -4
- package/dataflow/fn/guards/guard-term.js +10 -1
- package/dataflow/fn/higher-order-function.d.ts +15 -1
- package/dataflow/fn/higher-order-function.js +54 -10
- package/dataflow/graph/call-graph.d.ts +5 -0
- package/dataflow/graph/call-graph.js +51 -15
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +4 -2
- package/dataflow/graph/graph.d.ts +21 -0
- package/dataflow/graph/graph.js +63 -2
- package/dataflow/internal/linker.d.ts +20 -0
- package/dataflow/internal/linker.js +190 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +20 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +12 -5
- package/dataflow/internal/process/functions/call/deferred.d.ts +7 -2
- package/dataflow/internal/process/functions/call/deferred.js +63 -28
- package/dataflow/internal/process/functions/call/quoted.js +33 -7
- package/documentation/data/dfg/doc-ambient.js +3 -1
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-query.js +9 -3
- package/package.json +5 -3
- package/project/context/flowr-analyzer-context.d.ts +7 -4
- package/project/context/flowr-analyzer-context.js +8 -3
- package/project/context/flowr-analyzer-files-context.js +1 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +2 -1
- package/project/context/flowr-analyzer-functions-context.js +9 -8
- package/project/flowr-analyzer.d.ts +7 -4
- package/project/flowr-analyzer.js +37 -8
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +22 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +34 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -1
- package/project/plugins/plugin-registry.d.ts +2 -2
- package/project/plugins/plugin-registry.js +1 -1
- package/project/sigdb/build.js +41 -2
- package/project/sigdb/decode.d.ts +3 -1
- package/project/sigdb/decode.js +45 -1
- package/project/sigdb/decompress.d.ts +5 -0
- package/project/sigdb/decompress.js +17 -1
- package/project/sigdb/manifest.d.ts +2 -1
- package/project/sigdb/manifest.js +12 -5
- package/project/sigdb/native-routines.d.ts +82 -0
- package/project/sigdb/native-routines.js +178 -0
- package/project/sigdb/reader.d.ts +21 -3
- package/project/sigdb/reader.js +35 -3
- package/project/sigdb/schema.d.ts +107 -3
- package/project/sigdb/schema.js +8 -2
- package/project/sigdb/sigdb-download.js +1 -1
- package/project/sigdb/sigdb-version.d.ts +7 -1
- package/project/sigdb/sigdb-version.js +12 -9
- package/project/sigdb/spec-query.d.ts +9 -4
- package/project/sigdb/spec-query.js +71 -45
- package/queries/catalog/call-context-query/call-context-query-executor.js +76 -29
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -12
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +3 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +4 -2
- package/queries/catalog/signature-query/signature-query-executor.js +6 -2
- package/queries/catalog/signature-query/signature-query-format.d.ts +4 -0
- package/util/collections/bounded-map.d.ts +9 -0
- package/util/collections/bounded-map.js +22 -0
- package/util/collections/defaultmap.d.ts +5 -0
- package/util/collections/defaultmap.js +10 -0
- package/util/fixpoint.d.ts +6 -1
- package/util/fixpoint.js +45 -3
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/global-caches.d.ts +26 -0
- package/util/global-caches.js +43 -0
- package/util/monoid.js +2 -2
- package/util/quads.js +11 -3
- package/util/r-package-urls.d.ts +19 -0
- package/util/r-package-urls.js +41 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.norm = exports.Vocabulary = exports.WordKind = void 0;
|
|
4
|
+
exports.defineTraits = defineTraits;
|
|
4
5
|
exports.shortOf = shortOf;
|
|
5
6
|
exports.aboutWord = aboutWord;
|
|
6
7
|
exports.wordsOf = wordsOf;
|
|
@@ -16,18 +17,30 @@ exports.closed = closed;
|
|
|
16
17
|
exports.problemsOf = problemsOf;
|
|
17
18
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
18
19
|
const regex_1 = require("../../util/text/regex");
|
|
19
|
-
/** The query language of the sigdb page: `name(arg, [role], name[role], *)[prop]`. */
|
|
20
|
-
/** the kinds of words a query states: roles of an argument in parentheses, properties of a call outside */
|
|
20
|
+
/** The query language of the sigdb page: `name(arg, [role], name[role], *)[prop]{trait}`. */
|
|
21
|
+
/** the kinds of words a query states: roles of an argument in parentheses, properties of a call outside, traits of a name in braces */
|
|
21
22
|
var WordKind;
|
|
22
23
|
(function (WordKind) {
|
|
23
24
|
WordKind["Role"] = "role";
|
|
24
25
|
WordKind["Prop"] = "prop";
|
|
26
|
+
WordKind["Trait"] = "trait";
|
|
25
27
|
})(WordKind || (exports.WordKind = WordKind = {}));
|
|
26
|
-
/** the
|
|
28
|
+
/** the traits a page can tell of a name (a contract, a method, a reader, ...), see {@link defineTraits} */
|
|
29
|
+
const TraitWords = [];
|
|
30
|
+
/** the words of each kind, as the built-in configuration words them, the traits as the page defines them */
|
|
27
31
|
exports.Vocabulary = {
|
|
28
32
|
[WordKind.Role]: Object.values(built_in_props_1.ArgProps.vocabulary),
|
|
29
|
-
[WordKind.Prop]: Object.values(built_in_props_1.CallProps.vocabulary)
|
|
33
|
+
[WordKind.Prop]: Object.values(built_in_props_1.CallProps.vocabulary),
|
|
34
|
+
[WordKind.Trait]: TraitWords
|
|
30
35
|
};
|
|
36
|
+
/** Sets the words `{trait}` takes, which only the page knows how to tell of a name. */
|
|
37
|
+
function defineTraits(words) {
|
|
38
|
+
TraitWords.splice(0, TraitWords.length, ...words);
|
|
39
|
+
}
|
|
40
|
+
/** the brackets of each kind of word outside the parentheses */
|
|
41
|
+
const Brackets = { '[': ']', '{': '}' };
|
|
42
|
+
const isOpen = (c) => c in Brackets;
|
|
43
|
+
const kindOutside = (open) => open === '{' ? WordKind.Trait : WordKind.Prop;
|
|
31
44
|
/** the short forms of the tags whose words are long, the roles and properties state their own */
|
|
32
45
|
const TagShorts = {
|
|
33
46
|
[built_in_props_1.SemanticCallTag.TempFile]: 'tmpfile',
|
|
@@ -41,7 +54,7 @@ const TagShorts = {
|
|
|
41
54
|
[built_in_props_1.SemanticCallTag.JavaScript]: 'js'
|
|
42
55
|
};
|
|
43
56
|
/** every word of either kind */
|
|
44
|
-
const AllWords =
|
|
57
|
+
const AllWords = [...exports.Vocabulary[WordKind.Role], ...exports.Vocabulary[WordKind.Prop]];
|
|
45
58
|
const Shorts = new Map([
|
|
46
59
|
...AllWords.flatMap(({ word, short }) => short === undefined ? [] : [[word, short]]),
|
|
47
60
|
...Object.entries(TagShorts)
|
|
@@ -52,7 +65,7 @@ function shortOf(word) {
|
|
|
52
65
|
}
|
|
53
66
|
/** what a role or property word means, `undefined` for any other word */
|
|
54
67
|
function aboutWord(word) {
|
|
55
|
-
return AllWords.find(w => w.word === word)?.about;
|
|
68
|
+
return [...AllWords, ...TraitWords].find(w => w.word === word)?.about;
|
|
56
69
|
}
|
|
57
70
|
/** The words of a `|`-joined statement. */
|
|
58
71
|
function wordsOf(joined) {
|
|
@@ -69,16 +82,17 @@ function argsOf(args) {
|
|
|
69
82
|
const norm = (word) => shortOf(word.trim().toLowerCase()).toLowerCase();
|
|
70
83
|
exports.norm = norm;
|
|
71
84
|
const listOf = (words) => words.split(/[,|+]/).map(exports.norm).filter(Boolean);
|
|
72
|
-
/** The `[props]` groups outside the parentheses, wherever they sit, and what is left of the query without them. */
|
|
85
|
+
/** The `[props]` and `{traits}` groups outside the parentheses, wherever they sit, and what is left of the query without them. */
|
|
73
86
|
function takeProps(typed) {
|
|
74
87
|
const props = [];
|
|
88
|
+
const traits = [];
|
|
75
89
|
let body = '';
|
|
76
90
|
let depth = 0;
|
|
77
91
|
for (let at = 0; at < typed.length; at++) {
|
|
78
92
|
const c = typed[at];
|
|
79
|
-
const close = typed.indexOf(
|
|
80
|
-
if (c
|
|
81
|
-
props.push(...listOf(typed.slice(at + 1, close)));
|
|
93
|
+
const close = isOpen(c) ? typed.indexOf(Brackets[c], at) : -1;
|
|
94
|
+
if (isOpen(c) && depth === 0 && close >= 0 && opens(typed, at)) {
|
|
95
|
+
(c === '{' ? traits : props).push(...listOf(typed.slice(at + 1, close)));
|
|
82
96
|
at = close;
|
|
83
97
|
}
|
|
84
98
|
else {
|
|
@@ -86,12 +100,14 @@ function takeProps(typed) {
|
|
|
86
100
|
body += c;
|
|
87
101
|
}
|
|
88
102
|
}
|
|
89
|
-
return { body: body.trim().replace(/\s+\(/, '('), props };
|
|
103
|
+
return { body: body.trim().replace(/\s+\(/, '('), props, traits };
|
|
90
104
|
}
|
|
91
|
-
/** `[props] rest`: a
|
|
92
|
-
const LeadingProps =
|
|
93
|
-
/** whether a
|
|
94
|
-
const leads = (text) => LeadingProps.test(text) ||
|
|
105
|
+
/** `[props] rest` or `{traits} rest`: a group at the start only counts when something follows it, so `[`, `[[` and `{` stay names */
|
|
106
|
+
const LeadingProps = /^(?:\[[^\]]*\]|\{[^}]*\})\s+(\S.*)$/;
|
|
107
|
+
/** whether a bracket at the very start opens a group: something follows the group, or it is all there is */
|
|
108
|
+
const leads = (text) => LeadingProps.test(text) || /^(?:\[[^\]]+\]|\{[^}]+\})$/.test(text);
|
|
109
|
+
/** whether the bracket at `at` opens a group rather than being part of a name like `[[<-` */
|
|
110
|
+
const opens = (text, at) => (at > 0 && text[at - 1] !== text[at]) || (at === 0 && leads(text));
|
|
95
111
|
const anyArgs = { repeat: '*', name: '', roles: [] };
|
|
96
112
|
const Mark = '\uE000';
|
|
97
113
|
/** a `/pattern/` standing where a name could: after the start, a space, `(`, `,` or `]`, before whatever ends a name */
|
|
@@ -109,7 +125,7 @@ function parseSpec(input) {
|
|
|
109
125
|
const held = new RegExp(`^${Mark}(\\d+)${Mark}$`).exec(word.trim());
|
|
110
126
|
return held === null ? undefined : patterns[Number(held[1])];
|
|
111
127
|
}
|
|
112
|
-
const { body: left, props } = takeProps(shielded);
|
|
128
|
+
const { body: left, props, traits } = takeProps(shielded);
|
|
113
129
|
const withArgs = /^([^(]*)\(([^]*)\)$/.exec(left);
|
|
114
130
|
const args = withArgs === null || withArgs[2].trim() === '' ? undefined : withArgs[2].split(/,(?![^[]*\])/).flatMap((item) => {
|
|
115
131
|
const part = new RegExp(`^(${Mark}\\d+${Mark}|[^[*+?]*)(?:\\[([^\\]]*)\\])?([*+?])?$`).exec(item.trim());
|
|
@@ -124,14 +140,14 @@ function parseSpec(input) {
|
|
|
124
140
|
/* `[role]?` is at least one argument like it, with any others around it */
|
|
125
141
|
return part?.[3] === '?' ? [anyArgs, own, anyArgs] : [own];
|
|
126
142
|
});
|
|
127
|
-
if (args === undefined && props.length === 0) {
|
|
128
|
-
/* no constraint was asked for, so this is a plain name: `*`, `[`, `[[
|
|
143
|
+
if (args === undefined && props.length === 0 && traits.length === 0) {
|
|
144
|
+
/* no constraint was asked for, so this is a plain name: `*`, `[`, `[[<-`, `{` or `(` are functions too */
|
|
129
145
|
const nameRegex = (0, regex_1.slashedRegex)(typed, 'i');
|
|
130
|
-
return { rest: nameRegex === undefined ? typed.replace(/\(\s*\)$/, '').replace(/^`(.*)`$/, '$1').trim() : '', nameRegex, props };
|
|
146
|
+
return { rest: nameRegex === undefined ? typed.replace(/\(\s*\)$/, '').replace(/^`(.*)`$/, '$1').trim() : '', nameRegex, props, traits };
|
|
131
147
|
}
|
|
132
148
|
const rest = (args === undefined ? left.replace(/\(\s*\)$/, '') : withArgs?.[1] ?? '').replace(/^`(.*)`$/, '$1').trim();
|
|
133
149
|
const nameRegex = patternOf(rest);
|
|
134
|
-
return { rest: nameRegex !== undefined || /^\*+$/.test(rest) ? '' : rest, nameRegex, args, props };
|
|
150
|
+
return { rest: nameRegex !== undefined || /^\*+$/.test(rest) ? '' : rest, nameRegex, args, props, traits };
|
|
135
151
|
}
|
|
136
152
|
/** Whether the arguments a signature states fit the patterns, `*` standing for any number of them. */
|
|
137
153
|
function matchArgs(patterns, actual) {
|
|
@@ -170,14 +186,16 @@ function globOf(name) {
|
|
|
170
186
|
*/
|
|
171
187
|
function completeAt(text, caret) {
|
|
172
188
|
const before = text.slice(0, caret);
|
|
173
|
-
const open = before.lastIndexOf('[');
|
|
174
|
-
|
|
189
|
+
const open = Math.max(before.lastIndexOf('['), before.lastIndexOf('{'));
|
|
190
|
+
const bracket = before[open];
|
|
191
|
+
if (open <= 0 || bracket === undefined || before[open - 1] === bracket || before.includes(Brackets[bracket], open)) {
|
|
175
192
|
return undefined;
|
|
176
193
|
}
|
|
177
194
|
const inside = before.slice(open + 1);
|
|
178
195
|
const start = open + 1 + Math.max(inside.lastIndexOf(','), inside.lastIndexOf('|'), inside.lastIndexOf('+')) + 1;
|
|
179
196
|
const typed = before.slice(start).trimStart();
|
|
180
|
-
const
|
|
197
|
+
const inArgs = [...before.slice(0, open)].filter(c => c === '(').length > [...before.slice(0, open)].filter(c => c === ')').length;
|
|
198
|
+
const words = exports.Vocabulary[bracket === '{' ? WordKind.Trait : inArgs ? WordKind.Role : WordKind.Prop].map(w => w.word);
|
|
181
199
|
const taken = new Set(listOf(inside));
|
|
182
200
|
const options = words.filter(word => word.startsWith(typed.toLowerCase()) && word !== typed.toLowerCase() && !taken.has((0, exports.norm)(word)));
|
|
183
201
|
return options.length === 0 ? undefined : { from: caret - typed.length, to: caret, options };
|
|
@@ -188,10 +206,10 @@ function completeAt(text, caret) {
|
|
|
188
206
|
*/
|
|
189
207
|
function highlight(text) {
|
|
190
208
|
const spec = parseSpec(text.trim().replace(/^\?/, '').trim());
|
|
191
|
-
if (spec.nameRegex !== undefined && spec.args === undefined && spec.props.length === 0) {
|
|
209
|
+
if (spec.nameRegex !== undefined && spec.args === undefined && spec.props.length === 0 && spec.traits.length === 0) {
|
|
192
210
|
return [[text, 'regex']];
|
|
193
211
|
}
|
|
194
|
-
if (spec.args === undefined && spec.props.length === 0 && !/[^[]\[/.test(text)) {
|
|
212
|
+
if (spec.args === undefined && spec.props.length === 0 && spec.traits.length === 0 && !/[^[]\[|[^{]\{/.test(text)) {
|
|
195
213
|
return [[text, 'plain']];
|
|
196
214
|
}
|
|
197
215
|
const out = [];
|
|
@@ -208,17 +226,17 @@ function highlight(text) {
|
|
|
208
226
|
out.push([whole, 'regex']);
|
|
209
227
|
at += whole.length;
|
|
210
228
|
}
|
|
211
|
-
else if (c
|
|
212
|
-
const close = text.indexOf(
|
|
229
|
+
else if (isOpen(c) && (c === '[' || depth === 0) && opens(text, at)) {
|
|
230
|
+
const close = text.indexOf(Brackets[c], at);
|
|
213
231
|
const end = close < 0 ? text.length : close;
|
|
214
|
-
const kind = depth > 0 ? WordKind.Role :
|
|
215
|
-
out.push([
|
|
232
|
+
const kind = depth > 0 ? WordKind.Role : kindOutside(c);
|
|
233
|
+
out.push([c, 'punct']);
|
|
216
234
|
for (const part of text.slice(at + 1, end).split(/([,|+])/)) {
|
|
217
235
|
const known = exports.Vocabulary[kind].some(({ word }) => (0, exports.norm)(word) === (0, exports.norm)(part));
|
|
218
236
|
out.push([part, /^[,|+]$/.test(part) ? 'punct' : part.trim() === '' ? 'plain' : known ? kind : 'bad']);
|
|
219
237
|
}
|
|
220
238
|
if (close >= 0) {
|
|
221
|
-
out.push([
|
|
239
|
+
out.push([Brackets[c], 'punct']);
|
|
222
240
|
}
|
|
223
241
|
at = end + 1;
|
|
224
242
|
}
|
|
@@ -250,7 +268,8 @@ function explainAt(text, at) {
|
|
|
250
268
|
if (at >= start && at < start + part.length) {
|
|
251
269
|
switch (kind) {
|
|
252
270
|
case WordKind.Role:
|
|
253
|
-
case WordKind.Prop:
|
|
271
|
+
case WordKind.Prop:
|
|
272
|
+
case WordKind.Trait: return exports.Vocabulary[kind].find(({ word }) => (0, exports.norm)(word) === (0, exports.norm)(part))?.about;
|
|
254
273
|
case 'bad': return 'unknown';
|
|
255
274
|
case 'regex': return 'pattern';
|
|
256
275
|
default: return kind === 'plain' ? undefined : SymbolInfo[part];
|
|
@@ -270,17 +289,20 @@ function isIncomplete(text) {
|
|
|
270
289
|
if (pieces.some(([, kind]) => kind === 'bad')) {
|
|
271
290
|
return true;
|
|
272
291
|
}
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
const { open, depth } = shapeOf(text);
|
|
293
|
+
return open !== undefined || depth > 0;
|
|
294
|
+
}
|
|
295
|
+
/** What is written outside the closed groups and patterns: the bracket left open, if any, and how deep the parentheses are. */
|
|
296
|
+
function shapeOf(text) {
|
|
297
|
+
const bare = text.replace(Slashed, '$1').replace(/(?<=[^[])\[[^\]]*\]/g, '').replace(/(?<=[^{])\{[^}]*\}/g, '');
|
|
275
298
|
const depth = [...bare.replace(/^\(+/, '')].reduce((sum, c) => sum + (c === '(' ? 1 : c === ')' ? -1 : 0), 0);
|
|
276
|
-
|
|
299
|
+
const open = /(?<=[^[])\[[^\]]*$/.test(bare) ? '[' : /(?<=[^{])\{[^}]*$/.test(bare) ? '{' : undefined;
|
|
300
|
+
return { open, depth };
|
|
277
301
|
}
|
|
278
302
|
/** The query with whatever is open closed again, so a word offered inside brackets can be judged as if it were finished. */
|
|
279
303
|
function closed(text) {
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
const open = /(?<=[^[])\[[^\]]*$/.test(bare) ? ']' : '';
|
|
283
|
-
return text + open + ')'.repeat(Math.max(0, depth));
|
|
304
|
+
const { open, depth } = shapeOf(text);
|
|
305
|
+
return text + (open === undefined ? '' : Brackets[open]) + ')'.repeat(Math.max(0, depth));
|
|
284
306
|
}
|
|
285
307
|
/** The closest known word to a misspelled one: one it starts, or else within two edits. */
|
|
286
308
|
function closestWord(word, words) {
|
|
@@ -305,10 +327,9 @@ function closestWord(word, words) {
|
|
|
305
327
|
/** What is wrong with the query as written, for the reader to fix: an open bracket, an unknown word, a pattern that does not compile. */
|
|
306
328
|
function problemsOf(text) {
|
|
307
329
|
const out = [];
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
out.push('missing `]`');
|
|
330
|
+
const { open, depth } = shapeOf(text);
|
|
331
|
+
if (open !== undefined) {
|
|
332
|
+
out.push(`missing \`${Brackets[open]}\``);
|
|
312
333
|
}
|
|
313
334
|
if (depth > 0) {
|
|
314
335
|
out.push(depth === 1 ? 'missing `)`' : `missing ${depth} times \`)\``);
|
|
@@ -317,15 +338,20 @@ function problemsOf(text) {
|
|
|
317
338
|
out.push('unexpected `)`');
|
|
318
339
|
}
|
|
319
340
|
let parens = 0;
|
|
341
|
+
let group;
|
|
320
342
|
for (const [part, kind] of highlight(text)) {
|
|
321
343
|
if (kind === 'punct' && (part === '(' || part === ')')) {
|
|
322
344
|
parens += part === '(' ? 1 : -1;
|
|
323
345
|
}
|
|
346
|
+
else if (kind === 'punct' && isOpen(part)) {
|
|
347
|
+
group = part;
|
|
348
|
+
}
|
|
324
349
|
else if (kind === 'bad') {
|
|
325
350
|
const word = part.trim();
|
|
326
|
-
const
|
|
327
|
-
const near = closestWord(word, exports.Vocabulary[
|
|
328
|
-
|
|
351
|
+
const asked = parens > 0 ? WordKind.Role : kindOutside(group ?? '[');
|
|
352
|
+
const near = closestWord(word, exports.Vocabulary[asked].map(w => w.word));
|
|
353
|
+
const what = asked === WordKind.Role ? 'argument role' : asked === WordKind.Trait ? 'trait' : 'function property';
|
|
354
|
+
out.push(`\`${word}\` is no known ${what}${near === undefined ? '' : `, did you mean \`${near}\`?`}`);
|
|
329
355
|
}
|
|
330
356
|
}
|
|
331
357
|
for (const slashed of text.matchAll(Slashed)) {
|
|
@@ -17,6 +17,7 @@ const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
|
17
17
|
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
18
18
|
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
19
19
|
const queue_1 = require("../../../util/collections/queue");
|
|
20
|
+
const fixpoint_1 = require("../../../util/fixpoint");
|
|
20
21
|
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
21
22
|
/** The report of what was collected, dropping results identical to an earlier one of the same subkind. */
|
|
22
23
|
function makeReport(collector) {
|
|
@@ -88,7 +89,6 @@ function calleesOf(id, call, outgoing, graph) {
|
|
|
88
89
|
? !node_id_1.NodeId.isBuiltIn(target) || !callsDefinition
|
|
89
90
|
: edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && isBinding(target))).map(([target]) => target).toArray();
|
|
90
91
|
}
|
|
91
|
-
/* maybe we want to add caches to this */
|
|
92
92
|
/**
|
|
93
93
|
* Whether the name at a vertex the alias walk reaches names a function there: a built-in, a function definition,
|
|
94
94
|
* and a use reading one, a function definition's binding, or nothing (an unknown function), like the `print` of
|
|
@@ -115,24 +115,32 @@ function namesFunction(id, graph) {
|
|
|
115
115
|
return !reads;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* The names of the functions the call at `nodeId` may be a call of, each with the vertices naming it.
|
|
118
|
+
* The names `asked` accepts of the functions the call at `nodeId` may be a call of, each with the vertices naming it.
|
|
119
119
|
* Without `follow`, only what the call reaches directly, which is all there is when no function of interest is ever
|
|
120
120
|
* used as a value (`f <- read.csv`, `g(read.csv)`, `get("read.csv")`), as then nothing can be an alias of one.
|
|
121
|
+
* Given `below` (see {@link wantedBelow}), the walk only gives the functions asked for and, past the callee, only enters a vertex
|
|
122
|
+
* from which it can still find one it has not found yet.
|
|
121
123
|
*/
|
|
122
|
-
function retrieveAllCallAliases(nodeId, graph, follow) {
|
|
124
|
+
function retrieveAllCallAliases(nodeId, graph, follow, namesFunction, wanted, asked) {
|
|
123
125
|
/* we want the names of all functions called at the source id, including synonyms and returns */
|
|
124
126
|
const aliases = new Map();
|
|
125
127
|
const visited = new Set();
|
|
128
|
+
/* the wanted functions found so far, and whether one past the callee is still to be found from a vertex */
|
|
129
|
+
let found = 0n;
|
|
130
|
+
const leadsOn = (id) => wanted === undefined || ((wanted.below.get(id) ?? 0n) & ~found) !== 0n;
|
|
131
|
+
/* the callees are what the call names, whatever they reach */
|
|
132
|
+
const firstLevel = new Set();
|
|
126
133
|
/* we store the current call name alongside each id */
|
|
127
134
|
const queue = new queue_1.ArrayQueue([[node_id_1.NodeId.recoverContent(nodeId, graph) ?? '', nodeId]]);
|
|
128
135
|
for (let next = queue.dequeue(); next !== undefined; next = queue.dequeue()) {
|
|
129
136
|
const [str, id] = next;
|
|
130
|
-
if (visited.has(id)) {
|
|
137
|
+
if (visited.has(id) || (id !== nodeId && !leadsOn(id) && !firstLevel.has(id))) {
|
|
131
138
|
continue;
|
|
132
139
|
}
|
|
133
140
|
visited.add(id);
|
|
134
141
|
if (id !== nodeId) {
|
|
135
|
-
|
|
142
|
+
found |= wanted?.bits.get(id) ?? 0n;
|
|
143
|
+
if (asked(str) && namesFunction(id)) {
|
|
136
144
|
const present = aliases.get(str);
|
|
137
145
|
if (present) {
|
|
138
146
|
present.push(id);
|
|
@@ -145,35 +153,67 @@ function retrieveAllCallAliases(nodeId, graph, follow) {
|
|
|
145
153
|
continue;
|
|
146
154
|
}
|
|
147
155
|
}
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
156
|
+
const info = graph.getVertex(id);
|
|
157
|
+
if (info === undefined) {
|
|
150
158
|
continue;
|
|
151
159
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
/* a call reached on the way is an alias only for what it hands back, not for what it reads or calls */
|
|
161
|
+
const isStart = id === nodeId && vertex_1.DfgVertex.isFunctionCall(info);
|
|
162
|
+
for (const step of isStart ? calleesOf(id, info, graph.edgesFrom(id), graph) : aliasSteps(graph, id, info)) {
|
|
163
|
+
if (isStart) {
|
|
164
|
+
firstLevel.add(step);
|
|
165
|
+
}
|
|
166
|
+
else if (!leadsOn(step)) {
|
|
167
|
+
/* past the callee, what reaches no name asked for only names functions nobody asks about */
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
queue.enqueue([stepName(graph, id, info, step), step]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return aliases;
|
|
174
|
+
}
|
|
175
|
+
/** What the alias walk of {@link retrieveAllCallAliases} follows past `id`: what a call hands back, or what anything else reads or is defined by. */
|
|
176
|
+
function aliasSteps(graph, id, info) {
|
|
177
|
+
if (vertex_1.DfgVertex.isFunctionDefinition(info)) {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
const types = vertex_1.DfgVertex.isFunctionCall(info) ? edge_1.EdgeType.Returns : edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall;
|
|
181
|
+
return graph.edgesFrom(id).entries().filter(([, e]) => edge_1.DfEdge.includesType(e, types)).map(([t]) => t).toArray();
|
|
182
|
+
}
|
|
183
|
+
/** The name an alias step from `id` to `target` carries: the target's, or for a call without one, the call's. */
|
|
184
|
+
function stepName(graph, id, info, target) {
|
|
185
|
+
return node_id_1.NodeId.recoverContent(target, graph) ?? (vertex_1.DfgVertex.isFunctionCall(info) ? node_id_1.NodeId.recoverContent(id, graph) : undefined) ?? '';
|
|
186
|
+
}
|
|
187
|
+
/** {@link WantedBelow} of the graph. */
|
|
188
|
+
function wantedBelow(graph, wanted, namesFunction) {
|
|
189
|
+
const bits = new Map();
|
|
190
|
+
for (const [id, info] of graph.vertices(true)) {
|
|
191
|
+
for (const target of aliasSteps(graph, id, info)) {
|
|
192
|
+
if (!bits.has(target) && wanted(stepName(graph, id, info, target)) && namesFunction(target)) {
|
|
193
|
+
bits.set(target, 1n << BigInt(bits.size));
|
|
194
|
+
}
|
|
156
195
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
196
|
+
}
|
|
197
|
+
const below = new Map();
|
|
198
|
+
const components = new fixpoint_1.StronglyConnected(id => {
|
|
199
|
+
const info = graph.getVertex(id);
|
|
200
|
+
return info ? aliasSteps(graph, id, info) : [];
|
|
201
|
+
}, (members, successorsOf) => {
|
|
202
|
+
let mask = 0n;
|
|
203
|
+
for (const m of members) {
|
|
204
|
+
mask |= bits.get(m) ?? 0n;
|
|
205
|
+
for (const t of successorsOf(m)) {
|
|
206
|
+
mask |= below.get(t) ?? 0n;
|
|
166
207
|
}
|
|
167
|
-
continue;
|
|
168
208
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
: outgoing.entries().filter(([, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)).map(([t]) => t);
|
|
172
|
-
for (const call of out) {
|
|
173
|
-
queue.enqueue([node_id_1.NodeId.recoverContent(call, graph) ?? node_id_1.NodeId.recoverContent(id, graph) ?? '', call]);
|
|
209
|
+
if (mask !== 0n) {
|
|
210
|
+
members.forEach(m => below.set(m, mask));
|
|
174
211
|
}
|
|
212
|
+
});
|
|
213
|
+
for (const [id] of graph.vertices(true)) {
|
|
214
|
+
components.visit(id);
|
|
175
215
|
}
|
|
176
|
-
return
|
|
216
|
+
return { below, bits };
|
|
177
217
|
}
|
|
178
218
|
function doesFilepathMatch(file, filter) {
|
|
179
219
|
if (filter === undefined) {
|
|
@@ -271,13 +311,20 @@ async function executeCallContextQueries({ analyzer }, queries) {
|
|
|
271
311
|
const value = node_id_1.NodeId.recoverContent(id, dataflow.graph);
|
|
272
312
|
return value !== undefined && queriesFor(value).some(q => q.includeAliases);
|
|
273
313
|
});
|
|
314
|
+
/* only the aliases some query asks for count */
|
|
315
|
+
const asksAliases = (name) => queriesFor(name).some(q => q.includeAliases);
|
|
316
|
+
/* whether a vertex names a function is the same for every call reaching it */
|
|
317
|
+
const namesFunctionOf = (0, defaultmap_1.memoize)((id) => namesFunction(id, dataflow.graph));
|
|
318
|
+
/* a call whose own name asks for no aliases only has some if its walk reaches a function asked for */
|
|
319
|
+
const wanted = followAliases ? wantedBelow(dataflow.graph, asksAliases, namesFunctionOf) : undefined;
|
|
274
320
|
for (const [nodeId, info] of dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
275
321
|
const n = identifier_1.Identifier.getName(info.name);
|
|
276
322
|
/* each query matching the call by its name or, if it asks for them, by the functions it is an alias of */
|
|
277
323
|
const matched = new Map(queriesFor(n).map(q => [q, undefined]));
|
|
278
324
|
/* without a function used as a value, a call is only one of its own name, whose roots only matter if it matches */
|
|
279
|
-
|
|
280
|
-
|
|
325
|
+
const ownAliases = matched.keys().some(q => q.includeAliases);
|
|
326
|
+
if (ownAliases || (wanted !== undefined && calleesOf(nodeId, info, dataflow.graph.edgesFrom(nodeId), dataflow.graph).some(c => wanted.below.has(c)))) {
|
|
327
|
+
for (const [alias, ids] of retrieveAllCallAliases(nodeId, dataflow.graph, followAliases, namesFunctionOf, wanted, asksAliases)) {
|
|
281
328
|
for (const query of queriesFor(alias)) {
|
|
282
329
|
if (query.includeAliases) {
|
|
283
330
|
matched.set(query, [...matched.get(query) ?? [], ...ids]);
|
|
@@ -21,18 +21,7 @@ const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
|
|
|
21
21
|
async function executeExceptionQuery({ analyzer }, queries) {
|
|
22
22
|
const start = Date.now();
|
|
23
23
|
const { cg, fns } = await query_function_filter_1.QueryFunctionFilter.inCallGraph(queries, analyzer);
|
|
24
|
-
const result =
|
|
25
|
-
for (const [id] of fns) {
|
|
26
|
-
if (result[id]) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
const res = function_semantics_1.FunctionSemantics.exceptions(id, cg, { knownThrower: result });
|
|
30
|
-
for (const [k, v] of Object.entries(res)) {
|
|
31
|
-
if (!result[k]) {
|
|
32
|
-
result[k] = v;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
24
|
+
const result = function_semantics_1.FunctionSemantics.exceptionsOfAll(fns.map(([id]) => id), cg);
|
|
36
25
|
return {
|
|
37
26
|
...(0, query_meta_1.metaSince)(start),
|
|
38
27
|
/* collecting walks whatever the call graph holds, reporting stays with the definitions someone wrote */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BasicQueryData, type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import type { SigNativeRoutineInfo } from '../../../project/sigdb/schema';
|
|
2
3
|
import Joi from 'joi';
|
|
3
4
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
5
|
import type { SlicingCriterion } from '../../../slicing/criterion/parse';
|
|
@@ -19,6 +20,8 @@ export interface InspectFnGuardsQuery extends BaseQueryFormat {
|
|
|
19
20
|
readonly formals?: readonly BrandedIdentifier[];
|
|
20
21
|
/** also state what these functions of R ask for, written `name` or `pkg::name` */
|
|
21
22
|
readonly builtIns?: readonly string[];
|
|
23
|
+
/** the native routines of the analyzed package, which flowR cannot read off its compiled code itself, see {@link FunctionGuardsOptions.natives} */
|
|
24
|
+
readonly natives?: readonly SigNativeRoutineInfo[];
|
|
22
25
|
}
|
|
23
26
|
export interface InspectFnGuardsQueryResult extends BaseQueryResult {
|
|
24
27
|
/** per function definition with anything to say about it, what it asks for */
|
|
@@ -53,7 +53,7 @@ async function executeFnGuardsQuery({ analyzer }, queries) {
|
|
|
53
53
|
const filterFor = await query_function_filter_1.QueryFunctionFilter.criteria(queries, analyzer);
|
|
54
54
|
const [query = { type: 'inspect-fn-guards' }] = queries;
|
|
55
55
|
const graph = (await analyzer.dataflow()).graph;
|
|
56
|
-
const guards = function_semantics_1.FunctionSemantics.guards(query_function_filter_1.QueryFunctionFilter.definitions(graph, filterFor), graph, { ctx: analyzer.inspectContext() });
|
|
56
|
+
const guards = function_semantics_1.FunctionSemantics.guards(query_function_filter_1.QueryFunctionFilter.definitions(graph, filterFor), graph, { ctx: analyzer.inspectContext(), natives: query.natives });
|
|
57
57
|
return {
|
|
58
58
|
...(0, query_meta_1.metaSince)(start),
|
|
59
59
|
...(query.builtIns === undefined ? {} : { builtIns: statedFor(query.builtIns, analyzer.inspectContext()) }),
|
|
@@ -116,7 +116,8 @@ exports.InspectFnGuardsQueryDefinition = {
|
|
|
116
116
|
kind: joi_1.default.string().valid('explicit', 'implicit').optional().description('Keep only the conditions the function checks itself, or only those R checks for it.'),
|
|
117
117
|
onlyPure: joi_1.default.boolean().optional().description('Keep only the conditions failing before any side effect.'),
|
|
118
118
|
formals: joi_1.default.array().items(joi_1.default.string()).min(1).optional().description('Keep only what is said about the formals written as one of these names.'),
|
|
119
|
-
builtIns: joi_1.default.array().items(joi_1.default.string()).min(1).optional().description('Also state what these functions of R ask for, written `name` or `pkg::name`.')
|
|
119
|
+
builtIns: joi_1.default.array().items(joi_1.default.string()).min(1).optional().description('Also state what these functions of R ask for, written `name` or `pkg::name`.'),
|
|
120
|
+
natives: joi_1.default.array().items(joi_1.default.object().unknown()).optional().description('The native routines of the analyzed package (as the signature database records them), whose contracts the calls to them inherit.')
|
|
120
121
|
}).description('Returns what function definitions ask of the calls they return from, for all of them or just those matching the filter.'),
|
|
121
122
|
flattenInvolvedNodes: (queryResults) => Object.keys(queryResults.guards)
|
|
122
123
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BasicQueryData, type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import type { SigNativeRoutineInfo } from '../../../project/sigdb/schema';
|
|
2
3
|
import Joi from 'joi';
|
|
3
4
|
import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
5
|
import type { SlicingCriterion } from '../../../slicing/criterion/parse';
|
|
@@ -18,6 +19,8 @@ export interface InspectFnPropsQuery extends BaseQueryFormat {
|
|
|
18
19
|
readonly formals?: readonly string[];
|
|
19
20
|
/** keep only these properties, named as the {@link ArgProp}/{@link CallProp} members they are */
|
|
20
21
|
readonly props?: readonly string[];
|
|
22
|
+
/** the native routines of the analyzed package, which flowR cannot read off its compiled code itself: a call of a pure one has no effect, one starting threads runs concurrently */
|
|
23
|
+
readonly natives?: readonly SigNativeRoutineInfo[];
|
|
21
24
|
}
|
|
22
25
|
export interface InspectFnPropsQueryResult extends BaseQueryResult {
|
|
23
26
|
/** per function definition, the {@link ArgProp} mask of the formals that carry one, strictness included */
|
|
@@ -57,10 +57,10 @@ function keepProps(all, mask) {
|
|
|
57
57
|
async function executeFnPropsQuery({ analyzer }, queries) {
|
|
58
58
|
const start = Date.now();
|
|
59
59
|
const filterFor = await query_function_filter_1.QueryFunctionFilter.criteria(queries, analyzer);
|
|
60
|
-
const [{ only, formals, props, maxDepth } = {}] = queries;
|
|
60
|
+
const [{ only, formals, props, maxDepth, natives } = {}] = queries;
|
|
61
61
|
const ctx = analyzer.inspectContext();
|
|
62
62
|
const graph = (await analyzer.dataflow()).graph;
|
|
63
|
-
const inferred = function_semantics_1.FunctionSemantics.props(query_function_filter_1.QueryFunctionFilter.definitions(graph, filterFor), graph, { ctx, maxDepth, only });
|
|
63
|
+
const inferred = function_semantics_1.FunctionSemantics.props(query_function_filter_1.QueryFunctionFilter.definitions(graph, filterFor), graph, { ctx, maxDepth, only, natives });
|
|
64
64
|
return {
|
|
65
65
|
...(0, query_meta_1.metaSince)(start),
|
|
66
66
|
roles: keepRoles(inferred.roles, graph, formals && new Set(formals), props ? function_semantics_1.FunctionSemantics.call.argument.mask(props) : AllProps),
|
|
@@ -102,6 +102,7 @@ exports.InspectFnPropsQueryDefinition = {
|
|
|
102
102
|
schema: joi_1.default.object({
|
|
103
103
|
type: joi_1.default.string().valid('inspect-fn-props').required().description('The type of the query.'),
|
|
104
104
|
filter: query_function_property_1.FunctionFilterSchema,
|
|
105
|
+
natives: joi_1.default.array().items(joi_1.default.object().unknown()).optional().description('The native routines of the analyzed package (as the signature database records them), whose purity and concurrency the calls to them inherit.'),
|
|
105
106
|
maxDepth: joi_1.default.number().integer().min(1).optional().description(`How far a value is followed back through names and calls when deciding what a formal stands for (default ${argument_roles_1.DefaultDepth}).`),
|
|
106
107
|
only: joi_1.default.string().valid('arguments', 'function').optional().description('Infer only what the formals do, or only what the function itself does; both are inferred when this is left out.'),
|
|
107
108
|
formals: joi_1.default.array().items(joi_1.default.string()).min(1).optional().description('Keep only the formals written as one of these names.'),
|
|
@@ -5,6 +5,7 @@ exports.executeHigherOrderQuery = executeHigherOrderQuery;
|
|
|
5
5
|
const query_function_property_1 = require("../../query-function-property");
|
|
6
6
|
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
7
7
|
const query_function_filter_1 = require("../../query-function-filter");
|
|
8
|
+
const higher_order_function_1 = require("../../../dataflow/fn/higher-order-function");
|
|
8
9
|
const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
|
|
9
10
|
/** Execute higher-order function inspection queries on the given analyzer. */
|
|
10
11
|
async function executeHigherOrderQuery({ analyzer }, queries) {
|
|
@@ -16,9 +17,10 @@ async function executeHigherOrderQuery({ analyzer }, queries) {
|
|
|
16
17
|
invertedGraph = df_helper_1.Dataflow.invertGraph(graph, analyzer.inspectContext().env.makeCleanEnv());
|
|
17
18
|
}
|
|
18
19
|
const argumentFacts = new Map();
|
|
20
|
+
const definitionsBehind = new higher_order_function_1.DefinitionsBehind(graph);
|
|
19
21
|
const result = {};
|
|
20
22
|
for (const id of fns) {
|
|
21
|
-
result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph, argumentFacts });
|
|
23
|
+
result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph, argumentFacts, definitionsBehind });
|
|
22
24
|
}
|
|
23
25
|
return result;
|
|
24
26
|
}
|
|
@@ -8,9 +8,11 @@ const query_function_filter_1 = require("../../query-function-filter");
|
|
|
8
8
|
/** Execute recursion function inspection queries on the given analyzer. */
|
|
9
9
|
async function executeRecursionQuery({ analyzer }, queries) {
|
|
10
10
|
const { cg, fns } = await query_function_filter_1.QueryFunctionFilter.inCallGraph(queries, analyzer);
|
|
11
|
+
const ids = [...fns].map(([id]) => id);
|
|
12
|
+
const recursive = call_graph_1.CallGraph.recursiveAmong(ids, cg);
|
|
11
13
|
const result = {};
|
|
12
|
-
for (const
|
|
13
|
-
result[id] =
|
|
14
|
+
for (const id of ids) {
|
|
15
|
+
result[id] = recursive.has(id);
|
|
14
16
|
}
|
|
15
17
|
return result;
|
|
16
18
|
}
|
|
@@ -7,6 +7,7 @@ exports.signaturePackageInfo = signaturePackageInfo;
|
|
|
7
7
|
exports.signatureQueryCompleter = signatureQueryCompleter;
|
|
8
8
|
exports.executeSignatureQuery = executeSignatureQuery;
|
|
9
9
|
const semver_1 = require("semver");
|
|
10
|
+
const ambient_effect_1 = require("../../../dataflow/environments/ambient-effect");
|
|
10
11
|
const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
|
|
11
12
|
const signature_query_format_1 = require("./signature-query-format");
|
|
12
13
|
const reader_1 = require("../../../project/sigdb/reader");
|
|
@@ -157,11 +158,14 @@ function flowrViewOf(info, sigParams) {
|
|
|
157
158
|
const returns = info.sig?.find(([, p]) => (p & built_in_props_1.ArgProp.Alias) !== 0)?.[0];
|
|
158
159
|
/* flowR usually declares only the parameters it models, which is no disagreement as long as they line up */
|
|
159
160
|
const same = params.every((n, i) => n === sigParams[i]);
|
|
161
|
+
const ambient = (0, arrays_1.uniqueArray)(ambient_effect_1.Ambient.list(info.ambient).map(effect => `${effect.family}:${effect.access}`));
|
|
160
162
|
return (0, objects_1.compactRecord)({
|
|
161
163
|
props: function_semantics_1.FunctionSemantics.call.props.names([info.props ?? 0, ...info.tags ?? []]).map(name => name.toLowerCase()),
|
|
162
164
|
args: args.length > 0 ? args : undefined,
|
|
163
165
|
returns,
|
|
164
|
-
parameters: params.length > 0 && !same ? params : undefined
|
|
166
|
+
parameters: params.length > 0 && !same ? params : undefined,
|
|
167
|
+
ambient: ambient.length > 0 ? ambient : undefined,
|
|
168
|
+
muffles: info.muffles?.length ? info.muffles : undefined
|
|
165
169
|
});
|
|
166
170
|
}
|
|
167
171
|
/**
|
|
@@ -170,7 +174,7 @@ function flowrViewOf(info, sigParams) {
|
|
|
170
174
|
*/
|
|
171
175
|
function flowrView(env, pkg, name, sigParams) {
|
|
172
176
|
const info = env === undefined ? undefined : (0, query_fn_props_1.queryFnProps)(identifier_1.Identifier.make(name, pkg), { environment: env });
|
|
173
|
-
if (info === undefined || (info.props === undefined && info.sig === undefined)) {
|
|
177
|
+
if (info === undefined || (info.props === undefined && info.sig === undefined && info.ambient === undefined && info.muffles === undefined)) {
|
|
174
178
|
return undefined;
|
|
175
179
|
}
|
|
176
180
|
return flowrViewOf(info, sigParams);
|
|
@@ -134,6 +134,10 @@ export interface SignatureFlowrView {
|
|
|
134
134
|
readonly returns?: BrandedIdentifier;
|
|
135
135
|
/** flowR's own parameter names, only present when they disagree with the ones the database records */
|
|
136
136
|
readonly parameters?: readonly BrandedIdentifier[];
|
|
137
|
+
/** what the call reads or changes of the global state, as `part:access` like `option:reads` */
|
|
138
|
+
readonly ambient?: readonly string[];
|
|
139
|
+
/** the condition classes the call muffles while its code runs, like `message` for `suppressMessages` */
|
|
140
|
+
readonly muffles?: readonly string[];
|
|
137
141
|
}
|
|
138
142
|
/** one declared dependency of a package */
|
|
139
143
|
export interface SignatureDependencyView {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A map that starts over once it holds {@link cap} entries, for memos whose keys come from the analyzed code
|
|
3
|
+
* and would otherwise grow with every program a long-running flowR sees.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BoundedMap<K, V> extends Map<K, V> {
|
|
6
|
+
readonly cap: number;
|
|
7
|
+
constructor(cap: number);
|
|
8
|
+
set(key: K, value: V): this;
|
|
9
|
+
}
|