@eagleoutice/flowr 2.14.2 → 2.14.4
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/README.md +30 -42
- package/abstract-interpretation/absint-visitor.d.ts +45 -4
- package/abstract-interpretation/absint-visitor.js +252 -53
- package/config.d.ts +15 -8
- package/config.js +4 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -7
- package/control-flow/semantic-cfg-guided-visitor.js +23 -0
- package/dataflow/environments/default-builtin-config.d.ts +4 -13
- package/dataflow/environments/default-builtin-config.js +59 -23
- package/dataflow/environments/group-generics.d.ts +27 -0
- package/dataflow/environments/group-generics.js +39 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.js +1 -1
- package/dataflow/info.d.ts +1 -6
- package/dataflow/info.js +0 -17
- package/dataflow/internal/control-flow.d.ts +14 -2
- package/dataflow/internal/control-flow.js +24 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +11 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +21 -17
- package/documentation/doc-readme.js +0 -12
- package/documentation/wiki-absint.js +7 -2
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-signature-database.js +6 -1
- package/linter/rules/deprecated-functions.js +4 -2
- package/linter/rules/unused-definition.js +3 -3
- package/package.json +1 -1
- package/project/dependency-version-space.d.ts +1 -0
- package/project/dependency-version-space.js +1 -1
- package/project/flowr-analyzer-builder.d.ts +4 -4
- package/project/sigdb/reader.d.ts +6 -0
- package/project/sigdb/reader.js +2 -2
- package/project/sigdb/schema.d.ts +13 -1
- package/project/sigdb/schema.js +3 -1
- package/project/sigdb/signature-db.d.ts +4 -0
- package/project/sigdb/signature-db.js +8 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -2
- package/queries/catalog/signature-query/signature-query-executor.js +24 -9
- package/queries/catalog/signature-query/signature-query-format.d.ts +14 -3
- package/queries/catalog/signature-query/signature-query-render.js +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +7 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +7 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +0 -5
- package/search/search-executor/search-enrichers.d.ts +4 -0
- package/search/search-executor/search-enrichers.js +4 -4
- package/util/objects.d.ts +15 -4
- package/util/text/name-rank.js +8 -2
- package/util/version.js +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.
|
|
3
|
+
exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
|
|
4
4
|
exports.namespacePlotFunctions = namespacePlotFunctions;
|
|
5
5
|
exports.statedSignatures = statedSignatures;
|
|
6
6
|
exports.statedSignatureOf = statedSignatureOf;
|
|
@@ -175,6 +175,60 @@ const SigDataDots = [['.data', built_in_props_1.ArgProp.Value], ['...', built_in
|
|
|
175
175
|
const SigShape = [['x', built_in_props_1.ArgProp.Shape]];
|
|
176
176
|
const SigXTable = [['x', built_in_props_1.ArgProp.Value], ['table', built_in_props_1.ArgProp.Value]];
|
|
177
177
|
const SigDots = [['...', built_in_props_1.ArgProp.Value]];
|
|
178
|
+
/**
|
|
179
|
+
* The manual page documenting a base R primitive, for the ones not documented under their own name.
|
|
180
|
+
*
|
|
181
|
+
* A primitive is written in C and has no R closure, so nothing extracts a signature, a source file or a help
|
|
182
|
+
* topic for it and the signature database holds no entry at all: `base::sin` is documented under `Trig`, and
|
|
183
|
+
* guessing `sin` only names a page that does not exist. flowR states these names itself, so it carries where
|
|
184
|
+
* they are documented as well. Written the way R documents them, one page and everything it covers.
|
|
185
|
+
*/
|
|
186
|
+
const PrimitivesPerTopic = {
|
|
187
|
+
'Arithmetic': ['%%', '%/%', '*', '+', '-', '/', '^'],
|
|
188
|
+
'assignOps': ['<-', '<<-', '='],
|
|
189
|
+
'call': ['as.call'],
|
|
190
|
+
'CallExternal': ['.Call', '.External'],
|
|
191
|
+
'character': ['as.character', 'is.character'],
|
|
192
|
+
'Colon': [':'],
|
|
193
|
+
'Comparison': ['!=', '<', '<=', '==', '>', '>='],
|
|
194
|
+
'complex': ['Arg', 'Conj', 'Im', 'Mod', 'Re', 'as.complex'],
|
|
195
|
+
'Control': ['break', 'for', 'if', 'next', 'repeat', 'while'],
|
|
196
|
+
'crossprod': ['tcrossprod'],
|
|
197
|
+
'cumsum': ['cummax', 'cummin', 'cumprod'],
|
|
198
|
+
'double': ['as.double'],
|
|
199
|
+
'environment': ['baseenv', 'emptyenv', 'globalenv'],
|
|
200
|
+
'Extract': ['$', '[', '[['],
|
|
201
|
+
'Extremes': ['max', 'min'],
|
|
202
|
+
'Foreign': ['.C', '.Fortran'],
|
|
203
|
+
'function': ['return'],
|
|
204
|
+
'Hyperbolic': ['acosh', 'asinh', 'atanh', 'cosh', 'sinh', 'tanh'],
|
|
205
|
+
'integer': ['as.integer'],
|
|
206
|
+
'Internal': ['.Internal'],
|
|
207
|
+
'is.finite': ['is.infinite', 'is.nan'],
|
|
208
|
+
'list': ['is.list'],
|
|
209
|
+
'Log': ['exp', 'expm1', 'log', 'log10', 'log1p', 'log2'],
|
|
210
|
+
'Logic': ['!', '&', '&&', '|', '||'],
|
|
211
|
+
'logical': ['as.logical', 'is.logical'],
|
|
212
|
+
'MathFun': ['abs', 'sqrt'],
|
|
213
|
+
'matmult': ['%*%'],
|
|
214
|
+
'matrix': ['is.matrix'],
|
|
215
|
+
'NA': ['is.na'],
|
|
216
|
+
'nchar': ['nzchar'],
|
|
217
|
+
'ns-dblcolon': ['::', ':::'],
|
|
218
|
+
'NULL': ['is.null'],
|
|
219
|
+
'numeric': ['as.numeric', 'is.numeric'],
|
|
220
|
+
'Paren': ['(', '{'],
|
|
221
|
+
'Primitive': ['.Primitive'],
|
|
222
|
+
'raw': ['as.raw'],
|
|
223
|
+
'Round': ['ceiling', 'floor', 'round', 'signif', 'trunc'],
|
|
224
|
+
'seq': ['seq.int', 'seq_along', 'seq_len'],
|
|
225
|
+
'slotOp': ['@'],
|
|
226
|
+
'substitute': ['quote'],
|
|
227
|
+
'tilde': ['~'],
|
|
228
|
+
'Trig': ['acos', 'asin', 'atan', 'cos', 'sin', 'tan'],
|
|
229
|
+
};
|
|
230
|
+
/** {@link PrimitivesPerTopic} the way a lookup wants it: the topic documenting a name. */
|
|
231
|
+
exports.BasePrimitiveTopics = Object.fromEntries(Object.entries(PrimitivesPerTopic).flatMap(([topic, names]) => names.map(name => [name, topic])));
|
|
178
232
|
/**
|
|
179
233
|
* What flowR states about every function it carries a definition for, as `name -> signatures`. A name may be
|
|
180
234
|
* defined for several packages (`filter` is dplyr's and cohortBuilder's), so all of them are here and the
|
|
@@ -215,24 +269,6 @@ const LinkToLastPlot = {
|
|
|
215
269
|
type: 'link-to-last-call',
|
|
216
270
|
callName: toRegex(GraphicDeviceOpen.concat(exports.PlotCreate, PlotAddons, exports.GgPlotAddons, exports.TinyPlotAddons))
|
|
217
271
|
};
|
|
218
|
-
const Arith = ['+', '-', '*', '/', '^', '**', '%%', '%/%'];
|
|
219
|
-
const Compare = ['==', '!=', '<', '<=', '>', '>='];
|
|
220
|
-
const Logic = ['&', '|'];
|
|
221
|
-
/**
|
|
222
|
-
* R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
|
|
223
|
-
* `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
|
|
224
|
-
* `Ops` is what S3 calls the union of the three S4 groups it splits into.
|
|
225
|
-
*/
|
|
226
|
-
exports.RGroupGenerics = {
|
|
227
|
-
Arith, Compare, Logic,
|
|
228
|
-
Ops: [...Arith, ...Compare, ...Logic, '!'],
|
|
229
|
-
Math: ['abs', 'sign', 'sqrt', 'floor', 'ceiling', 'trunc', 'exp', 'expm1', 'log', 'log2', 'log10', 'log1p',
|
|
230
|
-
'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'acos', 'asin', 'atan', 'acosh', 'asinh', 'atanh',
|
|
231
|
-
'cumsum', 'cumprod', 'cummax', 'cummin'],
|
|
232
|
-
Math2: ['round', 'signif'],
|
|
233
|
-
Summary: ['any', 'sum', 'prod', 'min', 'max', 'range'],
|
|
234
|
-
Complex: ['Re', 'Im', 'Mod', 'Arg', 'Conj']
|
|
235
|
-
};
|
|
236
272
|
/**
|
|
237
273
|
* The internal generics: they dispatch in C rather than through `UseMethod`, so no signature can state it and
|
|
238
274
|
* the list has to be written down. Everything that dispatches from R is generated, see {@link RBasePackageStore}.
|
|
@@ -284,10 +320,6 @@ function markGenerics(definitions) {
|
|
|
284
320
|
}
|
|
285
321
|
return out;
|
|
286
322
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
|
|
289
|
-
* is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
|
|
290
|
-
*/
|
|
291
323
|
/** what creating a plot does; restated by the deprecated plot creators, which do the same but should not be used */
|
|
292
324
|
const PlotCreateConfig = {
|
|
293
325
|
forceArgs: 'all',
|
|
@@ -305,6 +337,10 @@ const PlotCreateConfig = {
|
|
|
305
337
|
},
|
|
306
338
|
props: built_in_props_1.CallProp.Graphics
|
|
307
339
|
};
|
|
340
|
+
/**
|
|
341
|
+
* Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
|
|
342
|
+
* is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
|
|
343
|
+
*/
|
|
308
344
|
exports.WrittenBuiltinDefinitions = [
|
|
309
345
|
{ type: 'constant', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['NULL', 'NA', 'NA_integer_', 'NA_real_', 'NA_complex_', 'NA_character_']), value: null, assumePrimitive: true },
|
|
310
346
|
{ type: 'constant', names: [identifier_1.Identifier.from(['NaN', "base" /* PkgName.Base */])], value: NaN, assumePrimitive: true },
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* R's group generics, kept apart from the builtin configuration so anything may ask about them without pulling
|
|
3
|
+
* the whole dataflow setup in (the signature database does, and that would be a cycle).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
|
|
7
|
+
* `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
|
|
8
|
+
* `Ops` is what S3 calls the union of the three S4 groups it splits into.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RGroupGenerics: {
|
|
11
|
+
readonly Arith: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%"];
|
|
12
|
+
readonly Compare: readonly ["==", "!=", "<", "<=", ">", ">="];
|
|
13
|
+
readonly Logic: readonly ["&", "|"];
|
|
14
|
+
readonly Ops: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%", "==", "!=", "<", "<=", ">", ">=", "&", "|", "!"];
|
|
15
|
+
readonly Math: readonly ["abs", "sign", "sqrt", "floor", "ceiling", "trunc", "exp", "expm1", "log", "log2", "log10", "log1p", "cos", "sin", "tan", "cosh", "sinh", "tanh", "acos", "asin", "atan", "acosh", "asinh", "atanh", "cumsum", "cumprod", "cummax", "cummin"];
|
|
16
|
+
readonly Math2: readonly ["round", "signif"];
|
|
17
|
+
readonly Summary: readonly ["any", "sum", "prod", "min", "max", "range"];
|
|
18
|
+
readonly Complex: readonly ["Re", "Im", "Mod", "Arg", "Conj"];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Member name to its S4 group (`sin` to `Math`, `+` to `Arith`). `Ops` is left out so `+` answers `Arith`
|
|
22
|
+
* rather than both. A package exporting such a name usually does so because it registered a method for one of
|
|
23
|
+
* its classes, so the name says far less about the package than an ordinary export would.
|
|
24
|
+
*/
|
|
25
|
+
export declare const S4GroupOfMember: ReadonlyMap<string, string>;
|
|
26
|
+
/** The S4 group generic `name` is a member of, `undefined` for a name that is in none. */
|
|
27
|
+
export declare function groupGenericOf(name: string): string | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* R's group generics, kept apart from the builtin configuration so anything may ask about them without pulling
|
|
4
|
+
* the whole dataflow setup in (the signature database does, and that would be a cycle).
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.S4GroupOfMember = exports.RGroupGenerics = void 0;
|
|
8
|
+
exports.groupGenericOf = groupGenericOf;
|
|
9
|
+
const Arith = ['+', '-', '*', '/', '^', '**', '%%', '%/%'];
|
|
10
|
+
const Compare = ['==', '!=', '<', '<=', '>', '>='];
|
|
11
|
+
const Logic = ['&', '|'];
|
|
12
|
+
/**
|
|
13
|
+
* R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
|
|
14
|
+
* `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
|
|
15
|
+
* `Ops` is what S3 calls the union of the three S4 groups it splits into.
|
|
16
|
+
*/
|
|
17
|
+
exports.RGroupGenerics = {
|
|
18
|
+
Arith, Compare, Logic,
|
|
19
|
+
Ops: [...Arith, ...Compare, ...Logic, '!'],
|
|
20
|
+
Math: ['abs', 'sign', 'sqrt', 'floor', 'ceiling', 'trunc', 'exp', 'expm1', 'log', 'log2', 'log10', 'log1p',
|
|
21
|
+
'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'acos', 'asin', 'atan', 'acosh', 'asinh', 'atanh',
|
|
22
|
+
'cumsum', 'cumprod', 'cummax', 'cummin'],
|
|
23
|
+
Math2: ['round', 'signif'],
|
|
24
|
+
Summary: ['any', 'sum', 'prod', 'min', 'max', 'range'],
|
|
25
|
+
Complex: ['Re', 'Im', 'Mod', 'Arg', 'Conj']
|
|
26
|
+
};
|
|
27
|
+
/** the S4 groups, i.e. {@link RGroupGenerics} without `Ops`, which only S3 knows */
|
|
28
|
+
const S4Groups = ['Arith', 'Compare', 'Logic', 'Math', 'Math2', 'Summary', 'Complex'];
|
|
29
|
+
/**
|
|
30
|
+
* Member name to its S4 group (`sin` to `Math`, `+` to `Arith`). `Ops` is left out so `+` answers `Arith`
|
|
31
|
+
* rather than both. A package exporting such a name usually does so because it registered a method for one of
|
|
32
|
+
* its classes, so the name says far less about the package than an ordinary export would.
|
|
33
|
+
*/
|
|
34
|
+
exports.S4GroupOfMember = new Map(S4Groups.flatMap(group => exports.RGroupGenerics[group].map(member => [member, group])));
|
|
35
|
+
/** The S4 group generic `name` is a member of, `undefined` for a name that is in none. */
|
|
36
|
+
function groupGenericOf(name) {
|
|
37
|
+
return exports.S4GroupOfMember.get(name);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=group-generics.js.map
|
|
@@ -60,8 +60,8 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
|
|
|
60
60
|
* @useInstead {@link Resolve.toValue}
|
|
61
61
|
*/
|
|
62
62
|
export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked }: ResolveInfo): ResolveResult;
|
|
63
|
-
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
64
63
|
/**
|
|
64
|
+
* Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant.
|
|
65
65
|
* @useInstead {@link Resolve.toSingleString}
|
|
66
66
|
*/
|
|
67
67
|
export declare function resolveIdToSingleString(id: NodeId | RNodeWithParent | undefined, info: ResolveInfo): string | undefined;
|
|
@@ -169,8 +169,8 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
|
|
|
169
169
|
return r_value_1.Top;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
/** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
|
|
173
172
|
/**
|
|
173
|
+
* Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant.
|
|
174
174
|
* @useInstead {@link Resolve.toSingleString}
|
|
175
175
|
*/
|
|
176
176
|
function resolveIdToSingleString(id, info) {
|
package/dataflow/info.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare function doesExitPointPropagateCalls(type: ExitPointType): boolea
|
|
|
83
83
|
* This may be as innocent as the last expression or explicit with a `return`/`break`/`next`.
|
|
84
84
|
* @see {@link ExitPointType} - for the different types of exit points
|
|
85
85
|
* @see {@link addNonDefaultExitPoints} - to easily modify lists of exit points
|
|
86
|
-
* @see {@link alwaysExits} - to check whether a
|
|
86
|
+
* @see {@link ControlFlow#alwaysExits|ControlFlow.alwaysExits()} - to check whether a subtree always jumps away
|
|
87
87
|
* @see {@link filterOutLoopExitPoints} - to remove loop exit points from a list
|
|
88
88
|
*/
|
|
89
89
|
export interface ExitPoint {
|
|
@@ -223,11 +223,6 @@ export declare function happensInEveryBranch(cds: readonly ControlDependency[] |
|
|
|
223
223
|
* @see {@link happensInEveryBranch} - for the array-based version
|
|
224
224
|
*/
|
|
225
225
|
export declare function happensInEveryBranchSet(cds: ReadonlySet<ControlDependency> | undefined): boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Checks whether the given dataflow information always exits (i.e., if there is a non-default exit point in every branch).
|
|
228
|
-
* @see {@link ExitPoint} - for the different types of exit points
|
|
229
|
-
*/
|
|
230
|
-
export declare function alwaysExits(data: DataflowInformation): boolean;
|
|
231
226
|
/**
|
|
232
227
|
* Filters out exit points which end their cascade within a loop.
|
|
233
228
|
*/
|
package/dataflow/info.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.addNonDefaultExitPoints = addNonDefaultExitPoints;
|
|
|
9
9
|
exports.overwriteExitPoints = overwriteExitPoints;
|
|
10
10
|
exports.happensInEveryBranch = happensInEveryBranch;
|
|
11
11
|
exports.happensInEveryBranchSet = happensInEveryBranchSet;
|
|
12
|
-
exports.alwaysExits = alwaysExits;
|
|
13
12
|
exports.filterOutLoopExitPoints = filterOutLoopExitPoints;
|
|
14
13
|
exports.diffControlDependency = diffControlDependency;
|
|
15
14
|
exports.diffControlDependencies = diffControlDependencies;
|
|
@@ -172,22 +171,6 @@ function coversSet(cds) {
|
|
|
172
171
|
function happensInEveryBranchSet(cds) {
|
|
173
172
|
return cds === undefined || (cds.size !== 0 && coversSet(cds));
|
|
174
173
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Checks whether the given dataflow information always exits (i.e., if there is a non-default exit point in every branch).
|
|
177
|
-
* @see {@link ExitPoint} - for the different types of exit points
|
|
178
|
-
*/
|
|
179
|
-
function alwaysExits(data) {
|
|
180
|
-
let cds = [];
|
|
181
|
-
for (const e of data.exitPoints) {
|
|
182
|
-
if (e.type !== 0 /* ExitPointType.Default */) {
|
|
183
|
-
if (e.cds === undefined) {
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
cds = cds.concat(e.cds);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return happensInEveryBranch(cds);
|
|
190
|
-
}
|
|
191
174
|
/**
|
|
192
175
|
* Filters out exit points which end their cascade within a loop.
|
|
193
176
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { DataflowGraph } from '../graph/graph';
|
|
3
|
-
import type {
|
|
4
|
-
import { ExitPointType } from '../info';
|
|
3
|
+
import type { DataflowCfgInformation } from '../info';
|
|
4
|
+
import { ControlDependency, ExitPointType } from '../info';
|
|
5
5
|
/**
|
|
6
6
|
* Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
|
|
7
7
|
* The {@link ControlFlowGraph} is a view on what is recorded here.
|
|
@@ -38,6 +38,17 @@ export declare const ControlFlow: {
|
|
|
38
38
|
* @see {@link ControlFlow#isStatement|isStatement()} - for the other kind
|
|
39
39
|
*/
|
|
40
40
|
readonly isExpression: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the subtree always jumps away instead of being left normally, i.e. whether a non-default exit
|
|
43
|
+
* point happens in every branch.
|
|
44
|
+
* @example
|
|
45
|
+
* ```r
|
|
46
|
+
* { break } # always exits
|
|
47
|
+
* { if(u) break } # only maybe
|
|
48
|
+
* ```
|
|
49
|
+
* @see {@link ControlFlow#canComplete|canComplete()} - for whether it can be left normally at all
|
|
50
|
+
*/
|
|
51
|
+
readonly alwaysExits: (this: void, info: DataflowCfgInformation) => boolean;
|
|
41
52
|
/**
|
|
42
53
|
* Whether the subtree can be left normally instead of always jumping away.
|
|
43
54
|
* @example
|
|
@@ -45,6 +56,7 @@ export declare const ControlFlow: {
|
|
|
45
56
|
* { 1 } # can complete
|
|
46
57
|
* { break } # cannot
|
|
47
58
|
* ```
|
|
59
|
+
* @see {@link ControlFlow#alwaysExits|alwaysExits()} - for whether it always jumps away
|
|
48
60
|
*/
|
|
49
61
|
readonly canComplete: (this: void, info: DataflowCfgInformation) => boolean;
|
|
50
62
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ControlFlow = void 0;
|
|
4
4
|
const edge_1 = require("../graph/edge");
|
|
5
|
+
const info_1 = require("../info");
|
|
5
6
|
const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
6
7
|
/**
|
|
7
8
|
* Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
|
|
@@ -50,6 +51,28 @@ exports.ControlFlow = {
|
|
|
50
51
|
isExpression(graph, id) {
|
|
51
52
|
return graph.idMap?.get(id) !== undefined && !exports.ControlFlow.isStatement(graph, id);
|
|
52
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* Whether the subtree always jumps away instead of being left normally, i.e. whether a non-default exit
|
|
56
|
+
* point happens in every branch.
|
|
57
|
+
* @example
|
|
58
|
+
* ```r
|
|
59
|
+
* { break } # always exits
|
|
60
|
+
* { if(u) break } # only maybe
|
|
61
|
+
* ```
|
|
62
|
+
* @see {@link ControlFlow#canComplete|canComplete()} - for whether it can be left normally at all
|
|
63
|
+
*/
|
|
64
|
+
alwaysExits(info) {
|
|
65
|
+
let cds = [];
|
|
66
|
+
for (const exit of info.exitPoints) {
|
|
67
|
+
if (exit.type !== 0 /* ExitPointType.Default */) {
|
|
68
|
+
if (exit.cds === undefined) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
cds = cds.concat(exit.cds);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return info_1.ControlDependency.happensInEveryBranch(cds);
|
|
75
|
+
},
|
|
53
76
|
/**
|
|
54
77
|
* Whether the subtree can be left normally instead of always jumping away.
|
|
55
78
|
* @example
|
|
@@ -57,6 +80,7 @@ exports.ControlFlow = {
|
|
|
57
80
|
* { 1 } # can complete
|
|
58
81
|
* { break } # cannot
|
|
59
82
|
* ```
|
|
83
|
+
* @see {@link ControlFlow#alwaysExits|alwaysExits()} - for whether it always jumps away
|
|
60
84
|
*/
|
|
61
85
|
canComplete(info) {
|
|
62
86
|
if (info.cfgExit !== undefined) {
|
|
@@ -263,7 +263,7 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
263
263
|
listEnvironments.add(ref.nodeId);
|
|
264
264
|
}
|
|
265
265
|
/** if at least built-one of the exit points encountered happens unconditionally, we exit here (dead code)! */
|
|
266
|
-
if (
|
|
266
|
+
if (control_flow_1.ControlFlow.alwaysExits(processed)) {
|
|
267
267
|
/* if there is an always-exit expression, there is no default return active anymore */
|
|
268
268
|
defaultReturnExpr = undefined;
|
|
269
269
|
break;
|
|
@@ -309,6 +309,15 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
309
309
|
/* an empty group completes on the spot, otherwise the last expression has to be able to reach the end */
|
|
310
310
|
const reachesEnd = !!withGroup && (processedExpressions.length === 0 || exitPoints.some(e => e.type === 0 /* ExitPointType.Default */));
|
|
311
311
|
const cfgEntry = control_flow_1.ControlFlow.inSequence(nextGraph, processedExpressions, reachesEnd ? rootId : undefined);
|
|
312
|
+
/*
|
|
313
|
+
* `{ break }` is entered and never left, so its `{` is reached and goes nowhere. Saying only the second
|
|
314
|
+
* half of that leaves the vertex beside the control flow, with nothing leading to it either.
|
|
315
|
+
*/
|
|
316
|
+
if (withGroup && !reachesEnd) {
|
|
317
|
+
for (const exit of exitPoints) {
|
|
318
|
+
nextGraph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
312
321
|
return {
|
|
313
322
|
/* no active nodes remain, they are consumed within the remaining read collection */
|
|
314
323
|
unknownReferences: [],
|
|
@@ -35,7 +35,7 @@ function processForLoop(name, args, rootId, data) {
|
|
|
35
35
|
const origEnv = data.environment;
|
|
36
36
|
(0, assert_1.guard)(variableArg !== undefined && vectorArg !== undefined && bodyArg !== undefined, () => `For-Loop ${JSON.stringify(args)} has missing arguments! Bad!`);
|
|
37
37
|
const vector = (0, processor_1.processDataflowFor)(vectorArg, data);
|
|
38
|
-
if (
|
|
38
|
+
if (control_flow_1.ControlFlow.alwaysExits(vector)) {
|
|
39
39
|
logger_1.dataflowLogger.warn(`For-Loop ${rootId} forces exit in vector, skipping rest`);
|
|
40
40
|
return vector;
|
|
41
41
|
}
|
|
@@ -466,16 +466,6 @@ function prepareFunctionEnvironment(data, rootId) {
|
|
|
466
466
|
}
|
|
467
467
|
return { ...data, environment: env };
|
|
468
468
|
}
|
|
469
|
-
/**
|
|
470
|
-
* Within something like `f <- function(a=b, m=3) { b <- 1; a; b <- 5; a + 1 }`
|
|
471
|
-
* `a` will be defined by `b` and `b` will be a promise object bound by the first definition of b it can find.
|
|
472
|
-
* This means that this function returns `2` due to the first `b <- 1` definition.
|
|
473
|
-
* If the code is `f <- function(a=b, m=3) { if(m > 3) { b <- 1; }; a; b <- 5; a + 1 }`, we need a link to `b <- 1` and `b <- 6`
|
|
474
|
-
* as `b` can be defined by either one of them.
|
|
475
|
-
* <p>
|
|
476
|
-
* <b>Currently we may be unable to narrow down every definition within the body as we have not implemented ways to track what covers the first definitions precisely</b>
|
|
477
|
-
*/
|
|
478
|
-
/** Links a parameter default read to the body writes of the same name (may), returning whether any was linked. */
|
|
479
469
|
/** Groups body writes by name, each list sorted by descending id (so the lowest id is last), for `linkParameterReadToBodyWrites`. */
|
|
480
470
|
function groupBodyWrites(out) {
|
|
481
471
|
const byName = new Map();
|
|
@@ -496,6 +486,17 @@ function groupBodyWrites(out) {
|
|
|
496
486
|
}
|
|
497
487
|
return byName;
|
|
498
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Within something like `f <- function(a=b, m=3) { b <- 1; a; b <- 5; a + 1 }`
|
|
491
|
+
* `a` will be defined by `b` and `b` will be a promise object bound by the first definition of b it can find.
|
|
492
|
+
* This means that this function returns `2` due to the first `b <- 1` definition.
|
|
493
|
+
* If the code is `f <- function(a=b, m=3) { if(m > 3) { b <- 1; }; a; b <- 5; a + 1 }`, we need a link to `b <- 1` and `b <- 6`
|
|
494
|
+
* as `b` can be defined by either one of them.
|
|
495
|
+
* <p>
|
|
496
|
+
* <b>Currently we may be unable to narrow down every definition within the body as we have not implemented ways to track what covers the first definitions precisely</b>
|
|
497
|
+
*
|
|
498
|
+
* Links a parameter default read to the body writes of the same name (may), returning whether any was linked.
|
|
499
|
+
*/
|
|
499
500
|
function linkParameterReadToBodyWrites(graph, read, writesByName) {
|
|
500
501
|
const writingOuts = read.name === undefined ? undefined : writesByName.get(read.name);
|
|
501
502
|
if (writingOuts === undefined) {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.processIfThenElse = processIfThenElse;
|
|
4
4
|
const match_args_1 = require("../../../../../graph/match-args");
|
|
5
5
|
const processor_1 = require("../../../../../processor");
|
|
6
|
-
const info_1 = require("../../../../../info");
|
|
7
6
|
const known_call_handling_1 = require("../known-call-handling");
|
|
8
7
|
const common_1 = require("../common");
|
|
9
8
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
@@ -54,7 +53,7 @@ function processIfThenElse(name, args, rootId, data, config) {
|
|
|
54
53
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
55
54
|
}
|
|
56
55
|
const cond = (0, processor_1.processDataflowFor)(condArg, data);
|
|
57
|
-
if (
|
|
56
|
+
if (control_flow_1.ControlFlow.alwaysExits(cond)) {
|
|
58
57
|
logger_1.dataflowLogger.warn(`If-then-else ${rootId} forces exit in condition, skipping rest`);
|
|
59
58
|
return cond;
|
|
60
59
|
}
|
|
@@ -35,7 +35,7 @@ function processLocal(name, args, rootId, data, config) {
|
|
|
35
35
|
/* when envir resolves to a tracked environment, evaluate expr inside it */
|
|
36
36
|
const envirResolution = env ? (0, built_in_envir_utils_1.resolveEnvirArg)(args, data, config.args.env) : undefined;
|
|
37
37
|
const dfEnv = env ? (0, processor_1.processDataflowFor)(env, data) : info_1.DataflowInformation.initialize(rootId, data);
|
|
38
|
-
if (
|
|
38
|
+
if (control_flow_1.ControlFlow.alwaysExits(dfEnv)) {
|
|
39
39
|
(0, common_1.patchFunctionCall)({
|
|
40
40
|
nextGraph: dfEnv.graph,
|
|
41
41
|
rootId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
-
import type
|
|
2
|
+
import { type DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
@@ -45,6 +45,15 @@ function processQuote(name, args, rootId, data, config) {
|
|
|
45
45
|
}
|
|
46
46
|
const quotedProcessed = processedArguments[config.quoteArgumentsWithIndex];
|
|
47
47
|
if (quotedProcessed) {
|
|
48
|
+
/*
|
|
49
|
+
* The expression is held on to rather than evaluated, so a `return` within it never runs and control
|
|
50
|
+
* arrives at the call. Every other jump the call catches already.
|
|
51
|
+
*/
|
|
52
|
+
for (const exit of quotedProcessed.exitPoints) {
|
|
53
|
+
if (exit.type === 1 /* ExitPointType.Return */) {
|
|
54
|
+
information.graph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
48
57
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, [config.quoteArgumentsWithIndex], { evaluated });
|
|
49
58
|
if (evaluated) {
|
|
50
59
|
/* the argument was processed in a clean env, so the escaped reads need linking by hand */
|
|
@@ -35,7 +35,7 @@ function processS3Dispatch(name, args, rootId, data, config) {
|
|
|
35
35
|
}
|
|
36
36
|
const obj = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('object')?.[0]));
|
|
37
37
|
const dfObj = obj ? (0, processor_1.processDataflowFor)(obj, data) : info_1.DataflowInformation.initialize(rootId, data);
|
|
38
|
-
if (
|
|
38
|
+
if (control_flow_1.ControlFlow.alwaysExits(dfObj)) {
|
|
39
39
|
(0, common_1.patchFunctionCall)({
|
|
40
40
|
nextGraph: dfObj.graph,
|
|
41
41
|
rootId,
|
|
@@ -106,9 +106,14 @@ function processTryCatch(name, args, rootId, data, config) {
|
|
|
106
106
|
* raises is caught here as well, so it reaches the call rather than leaving it.
|
|
107
107
|
*/
|
|
108
108
|
info.cfgExit = rootId;
|
|
109
|
-
/*
|
|
109
|
+
/*
|
|
110
|
+
* An error the block raises lands on the handler when there is one, and the `finally` follows it, which the
|
|
111
|
+
* arguments being in sequence already says. Without either, the error simply arrives at the call.
|
|
112
|
+
*/
|
|
113
|
+
const handler = res.processedArguments.find(arg => arg !== undefined && errorArg.has(arg.entryPoint));
|
|
110
114
|
const cleanup = res.processedArguments.find(arg => arg !== undefined && finallyArg.has(arg.entryPoint));
|
|
111
|
-
const caughtAt =
|
|
115
|
+
const caughtAt = handler !== undefined ? control_flow_1.ControlFlow.entryOf(handler)
|
|
116
|
+
: cleanup === undefined ? rootId : control_flow_1.ControlFlow.entryOf(cleanup);
|
|
112
117
|
for (const arg of res.processedArguments) {
|
|
113
118
|
if (arg === undefined || errorArg.has(arg.entryPoint) || finallyArg.has(arg.entryPoint)) {
|
|
114
119
|
continue;
|
|
@@ -70,7 +70,7 @@ function processWhileLoop(name, args, rootId, data) {
|
|
|
70
70
|
const conditionIsAlwaysTrue = values?.elements.every(d => d.type === 'logical' && d.value === true) ?? false;
|
|
71
71
|
(0, assert_1.guard)(condition !== undefined && body !== undefined, () => `While-Loop ${identifier_1.Identifier.toString(name.content)} has no condition or body, impossible!`);
|
|
72
72
|
const originalDependency = data.cds;
|
|
73
|
-
if (
|
|
73
|
+
if (control_flow_1.ControlFlow.alwaysExits(condition)) {
|
|
74
74
|
logger_1.dataflowLogger.warn(`While-Loop ${rootId} forces exit in condition, skipping rest`);
|
|
75
75
|
information.graph.addEdge(nameId, condition.entryPoint, edge_1.EdgeType.Reads);
|
|
76
76
|
return condition;
|
|
@@ -120,24 +120,24 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
|
|
|
120
120
|
inIds.push(fnRef);
|
|
121
121
|
// if force args is not none, we need to collect all non-default exit points from our arguments!
|
|
122
122
|
let exitPoints = undefined;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
if (nonDefaults.length > 0) {
|
|
136
|
-
exitPoints ??= [];
|
|
137
|
-
exitPoints.push(...nonDefaults);
|
|
138
|
-
}
|
|
123
|
+
/* a jump that only happens under a condition still lets the call complete, so its default exit has to stay */
|
|
124
|
+
let alwaysJumps = false;
|
|
125
|
+
if (forceArgs) {
|
|
126
|
+
for (let i = 0; i < processedArguments.length; i++) {
|
|
127
|
+
const p = processedArguments[i];
|
|
128
|
+
if (p === undefined || (forceArgs !== 'all' && !forceArgs[i])) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const before = exitPoints?.length ?? 0;
|
|
132
|
+
for (const exit of p.exitPoints) {
|
|
133
|
+
if (exit.type !== 0 /* ExitPointType.Default */) {
|
|
134
|
+
(exitPoints ??= []).push(exit);
|
|
139
135
|
}
|
|
140
136
|
}
|
|
137
|
+
alwaysJumps ||= (exitPoints?.length ?? 0) > before && control_flow_1.ControlFlow.alwaysExits(p);
|
|
138
|
+
}
|
|
139
|
+
if (exitPoints !== undefined && !alwaysJumps) {
|
|
140
|
+
exitPoints.push({ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds });
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
/* an alternative without a name is the default arm, which runs when nothing else matched */
|
|
@@ -151,7 +151,11 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
|
|
|
151
151
|
*/
|
|
152
152
|
for (const argument of processedArguments) {
|
|
153
153
|
for (const exit of argument?.exitPoints ?? []) {
|
|
154
|
-
/*
|
|
154
|
+
/*
|
|
155
|
+
* A jump within an argument the call does not pass on resumes at the call. A `return` leaves the
|
|
156
|
+
* enclosing function wherever the argument runs at all, so only a call that never evaluates it
|
|
157
|
+
* may catch one (see `processQuote`).
|
|
158
|
+
*/
|
|
155
159
|
if (exit.type !== 0 /* ExitPointType.Default */ && exit.type !== 1 /* ExitPointType.Return */ && !exitPoints?.includes(exit)) {
|
|
156
160
|
finalGraph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
|
|
157
161
|
}
|
|
@@ -264,18 +264,6 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, (0, doc_files_1.getFileCo
|
|
|
264
264
|
|
|
265
265
|
`), ' ')}
|
|
266
266
|
|
|
267
|
-
Every ▶ _Explore in Browser_ link above opens ${(0, doc_playground_1.linkToPlayground)('flowR\'s playground', { code: playgroundSample })},
|
|
268
|
-
which runs the whole analysis locally in your browser, with no setup at all. Once it is open:
|
|
269
|
-
|
|
270
|
-
| in the playground | what it does |
|
|
271
|
-
| ----------------- | ------------ |
|
|
272
|
-
| hover a name | what flowR knows about it: its value, its shape, its signature, and what the linter said |
|
|
273
|
-
| ctrl-click a name | jump to where it is defined |
|
|
274
|
-
| click a dependency | slice the script for it |
|
|
275
|
-
| alt-click anything (or <kbd>alt</kbd>+<kbd>m</kbd>) | highlight it, so a link points at it; hold <kbd>shift</kbd> to highlight more than one |
|
|
276
|
-
| _Copy link_ | hand the script, the highlights, and the layout to someone else as one url |
|
|
277
|
-
| the _flowR repl_ drawer | every command the ${ctx.linkPage('wiki/Interface', 'repl', 'using-the-repl')} carries, over the script above |
|
|
278
|
-
|
|
279
267
|
If you want to use flowR and the features it provides, feel free to check out the:
|
|
280
268
|
|
|
281
269
|
- ${ctx.linkPage('flowr:vscode', 'Visual Studio Code')}/${ctx.linkPage('flowr:positron', 'Positron')}: provides access to flowR directly in VS Code and Positron (or [vscode.dev](https://vscode.dev/))
|
|
@@ -7,6 +7,7 @@ const bounded_set_domain_1 = require("../abstract-interpretation/domains/bounded
|
|
|
7
7
|
const interval_domain_1 = require("../abstract-interpretation/domains/interval-domain");
|
|
8
8
|
const lattice_1 = require("../abstract-interpretation/domains/lattice");
|
|
9
9
|
const multi_value_state_domain_1 = require("../abstract-interpretation/domains/multi-value-state-domain");
|
|
10
|
+
const shape_inference_1 = require("../abstract-interpretation/data-frame/shape-inference");
|
|
10
11
|
const state_abstract_domain_1 = require("../abstract-interpretation/domains/state-abstract-domain");
|
|
11
12
|
const basic_cfg_guided_visitor_1 = require("../control-flow/basic-cfg-guided-visitor");
|
|
12
13
|
const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
|
|
@@ -144,8 +145,12 @@ Joining the predecessors goes through ${ctx.link(`${absint_visitor_1.AbstractInt
|
|
|
144
145
|
For \`if(u) 3 else 2\` the step onto \`3\` reports the condition \`u\` as the predecessor and the \`if\` as the branch, together with the outcome \`u\` had, so an analysis can pin the condition down on the way into a branch.
|
|
145
146
|
The other direction is ${ctx.link(`${basic_cfg_guided_visitor_1.BasicCfgGuidedVisitor.name}::getDecidedConstructs`)}: standing on \`u\`, it names the \`if\` that \`u\` decides.
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
The analysis is interprocedural: it steps into what a call dispatches to and continues with the state at the exit points of those functions, using ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}::enterCall`)}.
|
|
149
|
+
This is what the ${ctx.linkConfig('abstractInterpretation.followCalls')} configuration switches off, and ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}::shouldEnterCall`)} is the hook to decide it per call.
|
|
150
|
+
Each call site hands its own arguments to the parameters of the function it enters, so what a function is worth depends on where it is called, and every definition a call may reach is entered with the state at the call, so what the call is worth is what either of them leaves behind.
|
|
151
|
+
A definition that calls itself is run until what it leaves behind and what its parameters are worth both stop moving: \`shrink(head(x, nrow(x) - 1))\` hands over fewer rows than it was given, so the parameters are as much part of the fixpoint as the result is, and both are widened once the rounds pass the threshold so that they must stop.
|
|
152
|
+
What a call is worth is only known when every way out of every definition it reaches is: a function that leaves a frame behind on one path and something else on another says nothing about its result, the same way \`if(u) df else 42\` does not.
|
|
153
|
+
This is how a ${ctx.link(shape_inference_1.DataFrameShapeInferenceVisitor)} shape flows through the functions a program defines.
|
|
149
154
|
|
|
150
155
|
To implement a custom abstract interpretation analysis, we can just create a new class and extend the ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)}. The abstract interpretation visitor uses a \`StateDomain\` (e.g., a ${ctx.link(state_abstract_domain_1.StateAbstractDomain)}) to capture the current abstract state at each vertex in the control flow graph. We can then extend the callback functions of the ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)} to implement the abstract semantics of expressions, such as ${ctx.link(`${semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor.name}:::onNumberConstant`)}, ${ctx.link(`${absint_visitor_1.AbstractInterpretationVisitor.name}:::onFunctionCall`)} and ${ctx.link(`${semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor.name}:::onReplacementCall`)} (make sure to still call the respective super function). The abstract interpretation visitor provides the following functions to retrieve the currently inferred values:
|
|
151
156
|
|