@eagleoutice/flowr 2.10.5 → 2.10.6
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 +20 -20
- package/abstract-interpretation/absint-visitor.d.ts +1 -2
- package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
- package/config.d.ts +6 -0
- package/config.js +2 -0
- package/control-flow/basic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +3 -0
- package/dataflow/environments/built-in-proc-name.d.ts +7 -1
- package/dataflow/environments/built-in-proc-name.js +6 -0
- package/dataflow/environments/built-in.d.ts +6 -0
- package/dataflow/environments/built-in.js +6 -0
- package/dataflow/environments/default-builtin-config.d.ts +53 -1
- package/dataflow/environments/default-builtin-config.js +13 -3
- package/dataflow/environments/identifier.d.ts +14 -0
- package/dataflow/graph/vertex.d.ts +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +99 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +48 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +75 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +196 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +27 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +27 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +97 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +23 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +90 -0
- package/documentation/doc-util/doc-types.d.ts +11 -2
- package/documentation/doc-util/doc-types.js +31 -9
- package/documentation/wiki-absint.d.ts +16 -0
- package/documentation/wiki-absint.js +50 -15
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +14 -1
- package/documentation/wiki-mk/doc-context.js +6 -0
- package/documentation/wiki-normalized-ast.d.ts +0 -9
- package/documentation/wiki-normalized-ast.js +9 -60
- package/linter/linter-rules.d.ts +2 -1
- package/linter/rules/problematic-inputs.d.ts +9 -4
- package/linter/rules/problematic-inputs.js +108 -58
- package/package.json +1 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +2 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +7 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +3 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +3 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +3 -1
- package/r-bridge/data/data.d.ts +28 -2
- package/r-bridge/data/data.js +34 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/model/model.js +0 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -3
- package/util/version.js +1 -1
- package/abstract-interpretation/normalized-ast-fold.d.ts +0 -119
- package/abstract-interpretation/normalized-ast-fold.js +0 -181
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processNewEnv = processNewEnv;
|
|
4
|
+
exports.createFreshEnvState = createFreshEnvState;
|
|
5
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
6
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
|
+
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
8
|
+
const scoping_1 = require("../../../../../environments/scoping");
|
|
9
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
10
|
+
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
11
|
+
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
12
|
+
const vertex_1 = require("../../../../../graph/vertex");
|
|
13
|
+
const convert_values_1 = require("../../../../../../r-bridge/lang-4.x/convert-values");
|
|
14
|
+
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
15
|
+
const EmptyParentEnvFunctions = new Set(['emptyenv', 'baseenv']);
|
|
16
|
+
/**
|
|
17
|
+
* Processes `new.env()` and `rlang::new_environment()`.
|
|
18
|
+
*
|
|
19
|
+
* The resulting function-call vertex carries the {@link BuiltInProcName.NewEnv} origin so that
|
|
20
|
+
* `processAssignment` can detect it and attach an `envState` to the assigned variable.
|
|
21
|
+
*
|
|
22
|
+
* When the `parent` argument can be statically resolved (a tracked env variable or an
|
|
23
|
+
* `emptyenv()`-family call), the resolved parent is stored in the vertex's `newEnvParent`
|
|
24
|
+
* field so that {@link createFreshEnvState} can use it.
|
|
25
|
+
*/
|
|
26
|
+
function processNewEnv(name, args, rootId, data) {
|
|
27
|
+
const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.NewEnv }).information;
|
|
28
|
+
if (data.ctx.config.solver.trackEnvironments) {
|
|
29
|
+
const parentState = resolveNewEnvParentArg(args, data);
|
|
30
|
+
const vertex = result.graph.getVertex(rootId);
|
|
31
|
+
if (parentState !== undefined && (0, vertex_1.isFunctionCallVertex)(vertex)) {
|
|
32
|
+
vertex.newEnvParent = parentState;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Scans `args` for the `parent` argument and returns the {@link REnvironmentInformation}
|
|
39
|
+
* to use as the parent of the newly-created environment, or `undefined` to fall through
|
|
40
|
+
* to the default (current execution environment).
|
|
41
|
+
*
|
|
42
|
+
* Recognised patterns:
|
|
43
|
+
* - `parent = <tracked-env-var>` - returns that variable's `envState`
|
|
44
|
+
* - `parent = emptyenv()` / `parent = baseenv()` - returns an isolated env (no user scope)
|
|
45
|
+
* - everything else - `undefined` (fall through)
|
|
46
|
+
*/
|
|
47
|
+
function resolveNewEnvParentArg(args, data) {
|
|
48
|
+
for (const arg of args) {
|
|
49
|
+
if (arg === r_function_call_1.EmptyArgument || arg.name?.content !== 'parent') {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const node = (0, unpack_argument_1.unpackArg)(arg);
|
|
53
|
+
if (!node) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (node.type === type_1.RType.Symbol) {
|
|
57
|
+
if (node.content === convert_values_1.RNull) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return (0, built_in_envir_utils_1.resolveSymbolToEnvir)(node.content, node.info.id, data)?.envDef.envState;
|
|
61
|
+
}
|
|
62
|
+
if (r_function_call_1.RFunctionCall.isNamed(node) && node.functionName.type === type_1.RType.Symbol
|
|
63
|
+
&& EmptyParentEnvFunctions.has(node.functionName.content)) {
|
|
64
|
+
return createIsolatedEnvState(data);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function createIsolatedEnvState(data) {
|
|
71
|
+
let root = data.environment.current;
|
|
72
|
+
while (!root.builtInEnv) {
|
|
73
|
+
root = root.parent;
|
|
74
|
+
}
|
|
75
|
+
return { current: new environment_1.Environment(root), level: 0 };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates the initial (empty) environment state for a freshly created `new.env()`.
|
|
79
|
+
*
|
|
80
|
+
* When called from `processAssignmentToSymbol`, pass `sourceInfo` so that a
|
|
81
|
+
* statically-resolved `parent` argument (stored in the vertex's `newEnvParent` field)
|
|
82
|
+
* is honoured. Without `sourceInfo` (or when no `newEnvParent` is present), falls back
|
|
83
|
+
* to the current execution environment as parent.
|
|
84
|
+
*/
|
|
85
|
+
function createFreshEnvState(data, sourceInfo) {
|
|
86
|
+
if (sourceInfo !== undefined) {
|
|
87
|
+
const vertex = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
|
|
88
|
+
if ((0, vertex_1.isFunctionCallVertex)(vertex) && vertex.newEnvParent !== undefined) {
|
|
89
|
+
return {
|
|
90
|
+
current: new environment_1.Environment(vertex.newEnvParent.current),
|
|
91
|
+
level: vertex.newEnvParent.level + 1
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return (0, scoping_1.pushLocalEnvironment)(data.environment);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=built-in-new-env.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
/**
|
|
8
|
+
* Processes `with(data, expr)` and `within(data, expr)`.
|
|
9
|
+
*
|
|
10
|
+
* When `data` is a variable that holds a tracked {@link InGraphIdentifierDefinition#envState},
|
|
11
|
+
* the expression `expr` is evaluated in that environment's scope so that reads of names
|
|
12
|
+
* defined there resolve correctly.
|
|
13
|
+
*
|
|
14
|
+
* - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
|
|
15
|
+
* - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
|
|
16
|
+
*
|
|
17
|
+
* Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
|
|
18
|
+
* args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
|
|
19
|
+
*
|
|
20
|
+
* Falls back to a normal function-call analysis when the data argument cannot be resolved
|
|
21
|
+
* to a tracked environment.
|
|
22
|
+
*/
|
|
23
|
+
export declare function processWithEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processWithEnv = processWithEnv;
|
|
4
|
+
const processor_1 = require("../../../../../processor");
|
|
5
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
6
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
8
|
+
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
9
|
+
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
10
|
+
const common_1 = require("../common");
|
|
11
|
+
const edge_1 = require("../../../../../graph/edge");
|
|
12
|
+
const linker_1 = require("../../../../linker");
|
|
13
|
+
/** Formal parameter names for `with(data, expr, ...)` and `within(data, expr, ...)`. */
|
|
14
|
+
const withParams = ['data', 'expr'];
|
|
15
|
+
/**
|
|
16
|
+
* Processes `with(data, expr)` and `within(data, expr)`.
|
|
17
|
+
*
|
|
18
|
+
* When `data` is a variable that holds a tracked {@link InGraphIdentifierDefinition#envState},
|
|
19
|
+
* the expression `expr` is evaluated in that environment's scope so that reads of names
|
|
20
|
+
* defined there resolve correctly.
|
|
21
|
+
*
|
|
22
|
+
* - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
|
|
23
|
+
* - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
|
|
24
|
+
*
|
|
25
|
+
* Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
|
|
26
|
+
* args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
|
|
27
|
+
*
|
|
28
|
+
* Falls back to a normal function-call analysis when the data argument cannot be resolved
|
|
29
|
+
* to a tracked environment.
|
|
30
|
+
*/
|
|
31
|
+
function processWithEnv(name, args, rootId, data) {
|
|
32
|
+
if (args.length < 2) {
|
|
33
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
|
|
34
|
+
}
|
|
35
|
+
const bound = (0, built_in_envir_utils_1.bindArgs)(args, withParams);
|
|
36
|
+
const dataArg = bound.get('data');
|
|
37
|
+
const exprArg = bound.get('expr');
|
|
38
|
+
if (dataArg === undefined || dataArg === r_function_call_1.EmptyArgument || dataArg.value === undefined ||
|
|
39
|
+
exprArg === undefined || exprArg === r_function_call_1.EmptyArgument || exprArg.value === undefined) {
|
|
40
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
|
|
41
|
+
}
|
|
42
|
+
const envirResolution = (0, built_in_envir_utils_1.resolveArgToEnvir)(dataArg, data);
|
|
43
|
+
if (!envirResolution) {
|
|
44
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
|
|
45
|
+
}
|
|
46
|
+
/* evaluate data arg in the caller's scope (it is just read) */
|
|
47
|
+
const dfDataArg = (0, processor_1.processDataflowFor)(dataArg.value, data);
|
|
48
|
+
/* evaluate expr in the resolved env's scope so variable lookup uses envState */
|
|
49
|
+
const dfExpr = (0, processor_1.processDataflowFor)(exprArg.value, {
|
|
50
|
+
...data,
|
|
51
|
+
environment: envirResolution.envirData.environment
|
|
52
|
+
});
|
|
53
|
+
/*
|
|
54
|
+
* processSymbol puts symbol uses in unknownReferences without creating reads edges.
|
|
55
|
+
* Explicitly link expr's unknown references against the envState so reads edges are
|
|
56
|
+
* created for names that resolve there (e.g. `x` in `with(e, x)` -> assign).
|
|
57
|
+
* References that cannot be resolved in envState are kept for the outer scope.
|
|
58
|
+
*/
|
|
59
|
+
const remainingFromExpr = [];
|
|
60
|
+
(0, linker_1.linkInputs)(dfExpr.unknownReferences, envirResolution.envirData.environment, remainingFromExpr, dfExpr.graph, false);
|
|
61
|
+
(0, common_1.patchFunctionCall)({
|
|
62
|
+
nextGraph: dfDataArg.graph,
|
|
63
|
+
rootId,
|
|
64
|
+
name,
|
|
65
|
+
data,
|
|
66
|
+
argumentProcessResult: [dfDataArg, dfExpr],
|
|
67
|
+
origin: built_in_proc_name_1.BuiltInProcName.With
|
|
68
|
+
});
|
|
69
|
+
const merged = dfDataArg.graph.mergeWith(dfExpr.graph);
|
|
70
|
+
merged.addEdge(rootId, envirResolution.envirNodeId, edge_1.EdgeType.Reads);
|
|
71
|
+
const ingoing = dfDataArg.in.concat(dfExpr.in, dfDataArg.unknownReferences, remainingFromExpr, /* unresolved expr refs propagate to outer scope */ [{ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function }]);
|
|
72
|
+
/* within routes body writes back into the data environment; with discards them */
|
|
73
|
+
const isWithin = identifier_1.Identifier.getName(name.content) === 'within';
|
|
74
|
+
let resultEnv = data.environment;
|
|
75
|
+
if (isWithin && dfExpr.out.length > 0) {
|
|
76
|
+
const tempResult = { ...dfExpr, environment: data.environment };
|
|
77
|
+
resultEnv = (0, built_in_envir_utils_1.routeWrittenToCustomEnv)(tempResult, envirResolution.envDef, rootId).environment;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
hooks: dfDataArg.hooks.concat(dfExpr.hooks),
|
|
81
|
+
environment: resultEnv,
|
|
82
|
+
exitPoints: dfDataArg.exitPoints.concat(dfExpr.exitPoints),
|
|
83
|
+
graph: merged,
|
|
84
|
+
entryPoint: rootId,
|
|
85
|
+
in: ingoing,
|
|
86
|
+
out: [], /* writes are inside envState, not directly in outer scope */
|
|
87
|
+
unknownReferences: []
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=built-in-with.js.map
|
|
@@ -59,7 +59,7 @@ export declare function getStartLineOfTypeScriptNode(node: ts.Node, sourceFile:
|
|
|
59
59
|
* Return the link to the type in the source code.
|
|
60
60
|
* If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
|
|
61
61
|
*/
|
|
62
|
-
export declare function getTypePathLink(elem: Pick<TypeElementInSource, 'filePath' | 'lineNumber'>,
|
|
62
|
+
export declare function getTypePathLink(elem: Pick<TypeElementInSource, 'filePath' | 'lineNumber'>, relative?: boolean): string;
|
|
63
63
|
export interface MermaidClassDiagramArguments {
|
|
64
64
|
readonly inlineTypes?: readonly string[];
|
|
65
65
|
readonly simplify?: boolean;
|
|
@@ -130,6 +130,8 @@ export interface FnElementInfo {
|
|
|
130
130
|
doNotAutoGobble?: boolean;
|
|
131
131
|
/** Whether to hide the "Defined at ..." line */
|
|
132
132
|
hideDefinedAt?: boolean;
|
|
133
|
+
/** Whether lines with import statements in the code should be skipped */
|
|
134
|
+
skipImports?: boolean;
|
|
133
135
|
}
|
|
134
136
|
/**
|
|
135
137
|
* Print an element from the info as code block.
|
|
@@ -137,7 +139,14 @@ export interface FnElementInfo {
|
|
|
137
139
|
*
|
|
138
140
|
* This is great to show examples that are directly taken from the source code.
|
|
139
141
|
*/
|
|
140
|
-
export declare function printCodeOfElement(
|
|
142
|
+
export declare function printCodeOfElement(info: FnElementInfo, name: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Print a source file as code block.
|
|
145
|
+
* If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
|
|
146
|
+
*
|
|
147
|
+
* This is great to show examples that are directly taken from the source code.
|
|
148
|
+
*/
|
|
149
|
+
export declare function printCodeOfFile(info: FnElementInfo, relativePath: string): string;
|
|
141
150
|
/**
|
|
142
151
|
* Create a short link to a type in the documentation.
|
|
143
152
|
* If you create a wiki, please refer to the functions provided by the {@link GeneralDocContext}.
|
|
@@ -46,6 +46,7 @@ exports.visualizeMermaidClassDiagram = visualizeMermaidClassDiagram;
|
|
|
46
46
|
exports.getTypesFromFolder = getTypesFromFolder;
|
|
47
47
|
exports.printHierarchy = printHierarchy;
|
|
48
48
|
exports.printCodeOfElement = printCodeOfElement;
|
|
49
|
+
exports.printCodeOfFile = printCodeOfFile;
|
|
49
50
|
exports.shortLink = shortLink;
|
|
50
51
|
exports.shortLinkFile = shortLinkFile;
|
|
51
52
|
exports.getDocumentationForType = getDocumentationForType;
|
|
@@ -353,9 +354,9 @@ function getTypePathForTypeScript({ filePath }) {
|
|
|
353
354
|
* Return the link to the type in the source code.
|
|
354
355
|
* If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
|
|
355
356
|
*/
|
|
356
|
-
function getTypePathLink(elem,
|
|
357
|
+
function getTypePathLink(elem, relative = false) {
|
|
357
358
|
const fromSource = getTypePathForTypeScript(elem);
|
|
358
|
-
return `${
|
|
359
|
+
return `${relative ? '' : doc_files_1.RemoteFlowrFilePathBaseRef}${fromSource}#L${elem.lineNumber}`;
|
|
359
360
|
}
|
|
360
361
|
function generateMermaidClassDiagram(hierarchyList, rootName, options, visited = new Set()) {
|
|
361
362
|
const collect = { nodeLines: [], edgeLines: [] };
|
|
@@ -480,10 +481,10 @@ function implSnippet(node, program, showName = true, nesting = 0, open = false,
|
|
|
480
481
|
}
|
|
481
482
|
if (showImplSnippet) {
|
|
482
483
|
const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
|
|
483
|
-
text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node,
|
|
484
|
+
text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
|
|
484
485
|
}
|
|
485
486
|
else {
|
|
486
|
-
text += `\n<br/><i>(Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node,
|
|
487
|
+
text += `\n<br/><i>(Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a>)</i>\n`;
|
|
487
488
|
}
|
|
488
489
|
const init = showName ? `* ${bold}[${node.name}](${getTypePathLink(node)})${bold} ${sep}${indent}` : '';
|
|
489
490
|
return ` ${indent}${showName ? init : ''} ${text.replaceAll('\t', ' ').split(/\n/g).join(`\n${indent} `)}`;
|
|
@@ -535,13 +536,31 @@ function printHierarchy({ program, info, root, ignoredTypes, collapseFromNesting
|
|
|
535
536
|
*
|
|
536
537
|
* This is great to show examples that are directly taken from the source code.
|
|
537
538
|
*/
|
|
538
|
-
function printCodeOfElement(
|
|
539
|
-
const node = info.find(e => e.name === name);
|
|
539
|
+
function printCodeOfElement(info, name) {
|
|
540
|
+
const node = info.info.find(e => e.name === name);
|
|
540
541
|
if (!node) {
|
|
541
542
|
console.error(`Could not find node ${name} when resolving function!`);
|
|
542
543
|
return '';
|
|
543
544
|
}
|
|
544
|
-
|
|
545
|
+
const code = node.node.getFullText(info.program.getSourceFile(node.node.getSourceFile().fileName)).trim();
|
|
546
|
+
return printCode(info, code, getTypePathLink(node, true));
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Print a source file as code block.
|
|
550
|
+
* If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
|
|
551
|
+
*
|
|
552
|
+
* This is great to show examples that are directly taken from the source code.
|
|
553
|
+
*/
|
|
554
|
+
function printCodeOfFile(info, relativePath) {
|
|
555
|
+
const fullPath = path_1.default.resolve(__dirname, `../../../${relativePath}`);
|
|
556
|
+
const code = info.program.getSourceFile(fullPath)?.getFullText().trim();
|
|
557
|
+
if (!code) {
|
|
558
|
+
console.error(`Could not find source file ${relativePath}!`);
|
|
559
|
+
return '';
|
|
560
|
+
}
|
|
561
|
+
return printCode(info, code, relativePath);
|
|
562
|
+
}
|
|
563
|
+
function printCode({ dropLinesEnd = 0, dropLinesStart = 0, doNotAutoGobble, hideDefinedAt, skipImports }, code, definedAt) {
|
|
545
564
|
if (dropLinesStart > 0 || dropLinesEnd > 0) {
|
|
546
565
|
const lines = code.split(/\n/g);
|
|
547
566
|
if (dropLinesStart + dropLinesEnd >= lines.length) {
|
|
@@ -549,6 +568,9 @@ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart =
|
|
|
549
568
|
}
|
|
550
569
|
code = lines.slice(dropLinesStart, lines.length - dropLinesEnd).join('\n');
|
|
551
570
|
}
|
|
571
|
+
if (skipImports) {
|
|
572
|
+
code = code.replaceAll(/^import\s.*\n/gm, '').trim();
|
|
573
|
+
}
|
|
552
574
|
if (!doNotAutoGobble) {
|
|
553
575
|
// gobble leading spaces
|
|
554
576
|
const lines = code.replaceAll('\t', ' ').split(/\n/g);
|
|
@@ -563,11 +585,11 @@ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart =
|
|
|
563
585
|
code = lines.map(line => line.startsWith(' '.repeat(gobble)) ? line.slice(gobble) : line).join('\n');
|
|
564
586
|
}
|
|
565
587
|
}
|
|
566
|
-
if (hideDefinedAt) {
|
|
588
|
+
if (hideDefinedAt || !definedAt) {
|
|
567
589
|
return (0, doc_code_1.codeBlock)('ts', code);
|
|
568
590
|
}
|
|
569
591
|
else {
|
|
570
|
-
return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${
|
|
592
|
+
return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${doc_files_1.RemoteFlowrFilePathBaseRef}${definedAt}">${definedAt}</a></i>\n`;
|
|
571
593
|
}
|
|
572
594
|
}
|
|
573
595
|
function fuzzyCompare(a, b) {
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { type AbsintVisitorConfiguration, AbstractInterpretationVisitor } from '../abstract-interpretation/absint-visitor';
|
|
2
|
+
import { IntervalDomain } from '../abstract-interpretation/domains/interval-domain';
|
|
3
|
+
import { StateAbstractDomain } from '../abstract-interpretation/domains/state-abstract-domain';
|
|
4
|
+
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexValue } from '../dataflow/graph/vertex';
|
|
5
|
+
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
6
|
+
import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
1
7
|
import { DocMaker, type DocMakerArgs } from './wiki-mk/doc-maker';
|
|
8
|
+
export declare class IntervalInferenceVisitor extends AbstractInterpretationVisitor<StateAbstractDomain<IntervalDomain>> {
|
|
9
|
+
constructor(config: AbsintVisitorConfiguration);
|
|
10
|
+
protected onNumberConstant({ vertex, node }: {
|
|
11
|
+
vertex: DataflowGraphVertexValue;
|
|
12
|
+
node: RNumber<ParentInformation>;
|
|
13
|
+
}): void;
|
|
14
|
+
protected onFunctionCall({ call }: {
|
|
15
|
+
call: DataflowGraphVertexFunctionCall;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
2
18
|
export declare class WikiAbsint extends DocMaker<'wiki/Abstract Interpretation.md'> {
|
|
3
19
|
constructor();
|
|
4
20
|
protected text({ ctx }: DocMakerArgs): Promise<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WikiAbsint = void 0;
|
|
3
|
+
exports.WikiAbsint = exports.IntervalInferenceVisitor = void 0;
|
|
4
4
|
const absint_visitor_1 = require("../abstract-interpretation/absint-visitor");
|
|
5
5
|
const abstract_domain_1 = require("../abstract-interpretation/domains/abstract-domain");
|
|
6
6
|
const bounded_set_domain_1 = require("../abstract-interpretation/domains/bounded-set-domain");
|
|
@@ -10,10 +10,11 @@ const multi_value_state_domain_1 = require("../abstract-interpretation/domains/m
|
|
|
10
10
|
const state_abstract_domain_1 = require("../abstract-interpretation/domains/state-abstract-domain");
|
|
11
11
|
const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
|
|
12
12
|
const identifier_1 = require("../dataflow/environments/identifier");
|
|
13
|
+
const graph_1 = require("../dataflow/graph/graph");
|
|
13
14
|
const cfg_kind_1 = require("../project/cfg-kind");
|
|
14
15
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
15
|
-
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
16
16
|
const doc_code_1 = require("./doc-util/doc-code");
|
|
17
|
+
const doc_files_1 = require("./doc-util/doc-files");
|
|
17
18
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
18
19
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
19
20
|
class IntervalInferenceVisitor extends absint_visitor_1.AbstractInterpretationVisitor {
|
|
@@ -27,7 +28,7 @@ class IntervalInferenceVisitor extends absint_visitor_1.AbstractInterpretationVi
|
|
|
27
28
|
}
|
|
28
29
|
onFunctionCall({ call }) {
|
|
29
30
|
super.onFunctionCall({ call });
|
|
30
|
-
if (call.args.length === 2 && call.args.every(
|
|
31
|
+
if (call.args.length === 2 && call.args.every(graph_1.FunctionArgument.isNotEmpty)) {
|
|
31
32
|
const left = this.getAbstractValue(call.args[0].nodeId, this.currentState);
|
|
32
33
|
const right = this.getAbstractValue(call.args[1].nodeId, this.currentState);
|
|
33
34
|
if (left === undefined || right === undefined) {
|
|
@@ -44,13 +45,14 @@ class IntervalInferenceVisitor extends absint_visitor_1.AbstractInterpretationVi
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
exports.IntervalInferenceVisitor = IntervalInferenceVisitor;
|
|
47
49
|
async function inferIntervals() {
|
|
48
50
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
|
|
49
51
|
.setEngine('tree-sitter')
|
|
50
52
|
.build();
|
|
51
53
|
analyzer.addRequest(`
|
|
52
54
|
x <- 42
|
|
53
|
-
y <- if (runif() < 0.5) 6 else 12
|
|
55
|
+
y <- if (runif(1) < 0.5) 6 else 12
|
|
54
56
|
z <- x + y
|
|
55
57
|
`.trim());
|
|
56
58
|
const ast = await analyzer.normalize();
|
|
@@ -103,19 +105,19 @@ In _flowR_, an abstract domain is represented by the class ${ctx.link(abstract_d
|
|
|
103
105
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'value')} the current abstract value of the abstract domain
|
|
104
106
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'top')} to get the top element (greatest element) of the abstract domain
|
|
105
107
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'bottom')} to get the bottom element (least element) of the abstract domain
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
|
|
109
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'isTop')} to check whether the current abstract value is top
|
|
110
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'isBottom')} to check whether the current abstract value is bottom
|
|
111
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'isValue')} to check whether the current abstract value is a value (can still be top or bottom)
|
|
112
|
+
|
|
111
113
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'leq')} to check whether two abstract values are ordered with respect to the partial order of the lattice
|
|
112
114
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'join')} to join two abstract values to get the least upper bound (LUB)
|
|
113
115
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'meet')} to meet two abstract values to get the greates lower bound (GLB)
|
|
114
116
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'widen')} to perform widening with another abstract value to ensure termination of the fixpoint iteration
|
|
115
117
|
* ${ctx.linkM(abstract_domain_1.AbstractDomain, 'narrow')} to perform narrowing with another abstract value to refine the abstract value after widening
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'concretize')} representing the concretization function of the abstract domain
|
|
120
|
+
- ${ctx.linkM(abstract_domain_1.AbstractDomain, 'abstract')} representing the abstraction function of the abstract domain
|
|
119
121
|
|
|
120
122
|
${(0, doc_structure_1.details)('Class Diagram', `
|
|
121
123
|
All boxes link to their respective implementation in the source code.
|
|
@@ -124,7 +126,7 @@ ${(0, doc_code_1.codeBlock)('mermaid', ctx.mermaid(abstract_domain_1.AbstractDom
|
|
|
124
126
|
|
|
125
127
|
The ${ctx.link('Top')} and ${ctx.link('Bottom')} symbols can be used to explicitly represent the top or bottom elment of an abstract domain. Additionally, for value abstract domains, there is the ${ctx.link('SatisfiableDomain')} interface that provides the function ${ctx.link('SatisfiableDomain:::satisfies')} to check whether the current abstract value of the abstract domain satisfies a concrete value (see also ${ctx.link('NumericalComparator')} and ${ctx.link('SetComparator')}).
|
|
126
128
|
|
|
127
|
-
_flowR_ already provides different abstract domains for abstract interpretation in
|
|
129
|
+
_flowR_ already provides different abstract domains for abstract interpretation in ${(0, doc_files_1.linkFlowRSourceFile)('src/abstract-interpretation/domains')}. Many of the abstract domains are generic and can be used for differend kinds of analyses. The existing abstract domains are presented in the following. Some of the listed abstract domains can be expanded to show the inherited abstract domains.
|
|
128
130
|
|
|
129
131
|
${ctx.hierarchy(abstract_domain_1.AbstractDomain, { collapseFromNesting: 2, skipNesting: 1, reverse: true })}
|
|
130
132
|
|
|
@@ -150,7 +152,7 @@ To implement a custom abstract interpretation analysis, we can just create a new
|
|
|
150
152
|
|
|
151
153
|
For example, if we want to perform a (very basic) interval analysis using abstract interpretation in _flowR_, we can implement the following ${ctx.link(IntervalInferenceVisitor)} that extends ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)} using a ${ctx.link(state_abstract_domain_1.StateAbstractDomain)} for the ${ctx.link(interval_domain_1.IntervalDomain)}:
|
|
152
154
|
|
|
153
|
-
${ctx.code(
|
|
155
|
+
${ctx.code(IntervalInferenceVisitor, { hideDefinedAt: true })}
|
|
154
156
|
|
|
155
157
|
The interval inference visitor first overrides the ${ctx.link(`${semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor.name}:::onNumberConstant`)} function to infer intervals for visited control flow vertices that represent numeric constants. For numeric constants, the resulting interval consists just of the number value of the constant. We then update the current abstract state of the visitor by setting the inferred abstract value of the currently visited control flow vertex to the new interval.
|
|
156
158
|
|
|
@@ -158,7 +160,7 @@ In this simple example, we only want to support the addition and subtraction of
|
|
|
158
160
|
|
|
159
161
|
If we now want to run the interval inference, we can write the following code:
|
|
160
162
|
|
|
161
|
-
${ctx.code(inferIntervals, { dropLinesStart: 1, dropLinesEnd: 5 })}
|
|
163
|
+
${ctx.code(inferIntervals, { dropLinesStart: 1, dropLinesEnd: 5, hideDefinedAt: true })}
|
|
162
164
|
|
|
163
165
|
We first need a ${ctx.linkPage('wiki/Analyzer', 'flowR analyzer')} (in this case, using the ${ctx.linkPage('wiki/Engines', 'tree-sitter engine')}). In this example, we want to analyze a small example code that assigns \`42\` to the variable \`x\`, randomly assigns \`6\` or \`12\` to the variable \`y\`, and assignes the sum of \`x\` and \`y\` to the variable \`z\`. For the abstract interpretation visitor, we need to retrieve the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}, ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graph')}, ${ctx.linkPage('wiki/Control Flow Graph', 'control flow graph')}, and context of the flowR anaylzer. For performance reasons, we construct the control flow graph without simplification passes, data flow information, and function definitions. We then create a new ${ctx.link(IntervalInferenceVisitor)} using the control flow graph, dataflow graph, normalized AST, and analyzer context, and start the visitor using ${ctx.linkM(absint_visitor_1.AbstractInterpretationVisitor, 'start', { hideClass: true })}. After the visitor is finished, we retrieve the inferred abstract state at the end of the program using ${ctx.linkM(absint_visitor_1.AbstractInterpretationVisitor, 'getEndState', { hideClass: true })}.
|
|
164
166
|
|
|
@@ -168,6 +170,39 @@ ${(0, doc_code_1.codeBlock)('ts', await inferIntervals())}
|
|
|
168
170
|
<i>The output has been prettified for better readability.</i>
|
|
169
171
|
|
|
170
172
|
The AST nodes are represented as slicing criteria for better readability in the format \`<line>@<lexeme>\`. Here, the constants \`42\`, \`0.5\`, \`6\`, and \`12\` of line 1 and 2 are mapped to the intervals \`[42, 42]\`, \`[0.5, 0.5]\`, \`[6, 6]\`, and \`[12, 12]\`, respectively. The variable \`x\` of line 1 is mapped to the interval \`[42, 42]\` of the assigned value and the variable \`y\` of line 2 is assigned to the interval \`[6, 12]\` representing a sound over-approximation of the actual value, as the assigned value can be \`6\` or \`12\`. After applying the abstract semantics of the addition of \`x\` and \`y\`, the addition operation \`+\` and the variable \`z\` of line 3 are mapped to the interval \`[48, 54]\`, resulting from the addition of the interval \`[42, 42]\` of \`x\` and \`[6, 12]\` of \`y\`.
|
|
173
|
+
|
|
174
|
+
${(0, doc_structure_1.section)('Testing', 2, 'testing')}
|
|
175
|
+
|
|
176
|
+
_flowR_ provides a generic testing framework for abstract interpretation in ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/abstract-interpretation/inference.ts')}. The framework supports two kinds of tests for testing inferred abstract domain values at given source code locations (as ${ctx.link('SlicingCriteria')}):
|
|
177
|
+
|
|
178
|
+
1. **Assertion tests** — compare the inferred values against manually specified expected values (${ctx.link('assertInferredValues')}).
|
|
179
|
+
2. **Validation tests** — run the code to output the actual value at each location and compare the inferred values against the actual values (${ctx.link('validateInferredValues')}).
|
|
180
|
+
|
|
181
|
+
The test function ${ctx.link('testInferredValues')} combines both tests: it performs an assertion test when an ${ctx.link('InferenceTestCase')} record of expected values is provided, and a validation test (unless the option \`skipRun\` is set). When only a list of slicing criteria is provided instead of a ${ctx.link('InferenceTestCase')}, only the validation test is performed. For the validation test, it is required that all slicing criteria represent symbols, as the instrumentation of the code adds print statements for each symbol location after the code line of the symbol. The function takes the following arguments:
|
|
182
|
+
|
|
183
|
+
* \`name\` — the name or label of the test
|
|
184
|
+
* \`shell\` — the R shell to use for the validation test
|
|
185
|
+
* \`code\` — the R code to analyse and (for validation) to execute
|
|
186
|
+
* \`expected\` — an ${ctx.link('InferenceTestCase')} mapping slicing criteria to expected abstract values, or a list of slicing criteria for validation-only tests
|
|
187
|
+
* \`inference\` — a function that takes an ${ctx.link('AbsintVisitorConfiguration')} and returns an ${ctx.link(absint_visitor_1.AbstractInterpretationVisitor)} to perform the inference
|
|
188
|
+
* \`createOutputCode\` — a function \`(marker, symbol) => string\` that returns R code printing the analyzed properties of \`symbol\` in a line prefixed with \`marker\`
|
|
189
|
+
* \`parseOutput\` — a function \`(line) => Domain | undefined\` that parses the output line produced by \`createOutputCode\` into an abstract domain value
|
|
190
|
+
* \`options\` — optional inference test settings (_flowR_ configuration, additional project files, domain matching type, \`skipRun\`, etc.)
|
|
191
|
+
|
|
192
|
+
Additionally, ${ctx.link('assertInferredValues')} and ${ctx.link('validateInferredValues')} are available to only perform the assertions for assertion tests or validation tests without wrapping them into a test case.
|
|
193
|
+
|
|
194
|
+
When comparing inferred values with expected values, the framework supports two matching types via ${ctx.link('DomainMatchingType')}:
|
|
195
|
+
|
|
196
|
+
* ${ctx.link('DomainMatchingType::Equal')} — the inferred value must equal the expected value (default for assertion tests)
|
|
197
|
+
* ${ctx.link('DomainMatchingType::Overapproximation')} — the inferred value must be an over-approximation of the actual value via ${ctx.linkM(abstract_domain_1.AbstractDomain, 'leq')} (default for validation tests)
|
|
198
|
+
|
|
199
|
+
For example, to use the test framework for the ${ctx.link(IntervalInferenceVisitor)} defined above, we first define how to print the properties of an actual numeric scalar value in R using \`createOutputCode\` and how to parse it into an abstract domain value using \`parseOutput\`. Then, we can use ${ctx.link('testInferredValues')} to create a test for our code example by providing a test name, an R shell, the code to test, the test locations as slicing criteria with expected values, the inference visitor, and our \`createOutputCode\` and \`parseOutput\` function:
|
|
200
|
+
|
|
201
|
+
${ctx.codeFile('test/functionality/abstract-interpretation/wiki-absint.ts', { skipImports: true, hideDefinedAt: true })}
|
|
202
|
+
|
|
203
|
+
The assertion test verifies that the inferred intervals match the specified expected values exactly (using ${ctx.link('DomainMatchingType::Equal')}). The validation test instruments the code by inserting print statements after each tested location, executes the instrumented code with the R shell, and checks that each inferred interval at these locations is an over-approximation of the actual runtime value (using ${ctx.link('DomainMatchingType::Overapproximation')}). For example, the inferred interval \`[6, 12]\` for \`y\` is a sound over-approximation of the actual value \`6\` or \`12\`, depending on the random branch taken at runtime.
|
|
204
|
+
|
|
205
|
+
For an existing example of the test framework used in practice, see the data frame shape inference tests in ${(0, doc_files_1.linkFlowRSourceFile)('test/functionality/abstract-interpretation/data-frame/inference.test.ts')}, which use a domain-specific wrapper ${ctx.link('testInferredDataFrameShape')} built on top of ${ctx.link('testInferredValues')}.
|
|
171
206
|
`;
|
|
172
207
|
}
|
|
173
208
|
}
|
|
@@ -257,6 +257,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
257
257
|
solver: {
|
|
258
258
|
variables: config_1.VariableResolve.Alias,
|
|
259
259
|
evalStrings: true,
|
|
260
|
+
trackEnvironments: true,
|
|
260
261
|
resolveSource: {
|
|
261
262
|
dropPaths: config_1.DropPathsOption.No,
|
|
262
263
|
ignoreCapitalization: true,
|
|
@@ -179,7 +179,7 @@ export interface GeneralDocContext {
|
|
|
179
179
|
* @param filter - An optional filter to further specify the element to get the code for, in case multiple elements with the same name exist.
|
|
180
180
|
* @example
|
|
181
181
|
* ```ts
|
|
182
|
-
* code(exampleFn.name, { dropLinesStart: 1, dropLinesEnd: 2
|
|
182
|
+
* code(exampleFn.name, { dropLinesStart: 1, dropLinesEnd: 2 })
|
|
183
183
|
* ```
|
|
184
184
|
*
|
|
185
185
|
* Creates a code snippet for the `exampleFn` function in the code base,
|
|
@@ -203,6 +203,19 @@ export interface GeneralDocContext {
|
|
|
203
203
|
* @see {@link printCodeOfElement} - for the underlying impl.
|
|
204
204
|
*/
|
|
205
205
|
code(element: ElementIdOrRef, fmt?: Omit<FnElementInfo, 'info' | 'program'>, filter?: ElementFilter): string;
|
|
206
|
+
/**
|
|
207
|
+
* Returns the code snippet for a code file as markdown string.
|
|
208
|
+
* @param path - The path to the file to create a code snippet for.
|
|
209
|
+
* @param fmt - Formatting options for the code snippet (see {@link FnElementInfo})
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* code('src/path/to/file.ts', { skipImports: true })
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* Creates a code snippet for the source file `src/path/to/file.ts`,
|
|
216
|
+
* dropping the lines with import statements of the source code.
|
|
217
|
+
*/
|
|
218
|
+
codeFile(path: string, fmt?: Omit<FnElementInfo, 'info' | 'program'>): string;
|
|
206
219
|
/**
|
|
207
220
|
* Returns the hierarchy (e.g., class inheritance) for a code element as markdown string,
|
|
208
221
|
* including their documentation and snippets.
|
|
@@ -88,6 +88,12 @@ function makeDocContextForTypes(shell, ...rootFolders) {
|
|
|
88
88
|
...fmt,
|
|
89
89
|
}, getNameFromElementIdOrRef(element));
|
|
90
90
|
},
|
|
91
|
+
codeFile(path, fmt) {
|
|
92
|
+
return (0, doc_types_1.printCodeOfFile)({
|
|
93
|
+
program, info,
|
|
94
|
+
...fmt,
|
|
95
|
+
}, path);
|
|
96
|
+
},
|
|
91
97
|
async header(filename, purpose) {
|
|
92
98
|
const rVersion = (await shell?.usedRVersion())?.format();
|
|
93
99
|
return (0, doc_auto_gen_1.autoGenHeader)({ filename, purpose, rVersion });
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { DefaultNormalizedAstFold } from '../abstract-interpretation/normalized-ast-fold';
|
|
2
1
|
import type { DocMakerArgs } from './wiki-mk/doc-maker';
|
|
3
2
|
import { DocMaker } from './wiki-mk/doc-maker';
|
|
4
|
-
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
5
|
-
import { RBinaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
|
|
6
|
-
export declare class MyMathFold<Info> extends DefaultNormalizedAstFold<number, Info> {
|
|
7
|
-
constructor();
|
|
8
|
-
protected concat(a: number, b: number): number;
|
|
9
|
-
foldRNumber(node: RNumber<Info>): number;
|
|
10
|
-
foldRBinaryOp(node: RBinaryOp<Info>): number;
|
|
11
|
-
}
|
|
12
3
|
/**
|
|
13
4
|
* https://github.com/flowr-analysis/flowr/wiki/Normalized-AST
|
|
14
5
|
*/
|