@eagleoutice/flowr 2.13.3 → 2.13.5
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 +32 -32
- package/abstract-interpretation/absint-visitor.js +2 -2
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +1 -1
- package/abstract-interpretation/unsupported-functions.js +1 -1
- package/cli/repl/core.js +10 -2
- package/config.d.ts +4 -1
- package/config.js +10 -1
- package/control-flow/cfg-dead-code.js +91 -15
- package/control-flow/extract-cfg.js +93 -8
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/dataflow/environments/built-in-config.d.ts +6 -3
- package/dataflow/environments/built-in-eval-name.d.ts +20 -0
- package/dataflow/environments/built-in-eval-name.js +25 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in-props.d.ts +175 -0
- package/dataflow/environments/built-in-props.js +207 -0
- package/dataflow/environments/built-in.d.ts +28 -20
- package/dataflow/environments/built-in.js +39 -8
- package/dataflow/environments/default-builtin-config.d.ts +1094 -86
- package/dataflow/environments/default-builtin-config.js +496 -212
- package/dataflow/environments/identifier.d.ts +25 -1
- package/dataflow/environments/identifier.js +24 -2
- package/dataflow/environments/query-fn-props.d.ts +102 -0
- package/dataflow/environments/query-fn-props.js +188 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -0
- package/dataflow/eval/resolve/alias-tracking.js +12 -2
- package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
- package/dataflow/eval/resolve/match-arguments.js +77 -0
- package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
- package/dataflow/eval/resolve/resolve-numbers.js +163 -0
- package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
- package/dataflow/eval/resolve/resolve-operators.js +115 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
- package/dataflow/eval/resolve/resolve-strings.js +116 -0
- package/dataflow/eval/resolve/resolve.d.ts +5 -23
- package/dataflow/eval/resolve/resolve.js +56 -87
- package/dataflow/fn/higher-order-function.js +3 -3
- package/dataflow/fn/recursive-function.js +1 -1
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/vertex.d.ts +32 -25
- package/dataflow/graph/vertex.js +40 -36
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +28 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +41 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +45 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +62 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +63 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +29 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +35 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +46 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +24 -0
- package/dataflow/internal/process/functions/process-parameter.js +2 -1
- package/documentation/data/faq/faqs.js +11 -0
- package/documentation/doc-util/doc-types.js +1 -1
- package/documentation/wiki-analyzer.js +75 -0
- package/documentation/wiki-core.js +65 -16
- package/documentation/wiki-interface.js +3 -0
- package/linter/linter-rules.d.ts +10 -11
- package/linter/rules/absolute-path.js +1 -1
- package/linter/rules/deprecated-functions.js +5 -3
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/function-finder-util.js +11 -4
- package/linter/rules/network-functions.d.ts +25 -5
- package/linter/rules/network-functions.js +51 -11
- package/linter/rules/no-leaked-credentials.js +1 -1
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +7 -1
- package/linter/rules/seeded-randomness.d.ts +5 -8
- package/linter/rules/seeded-randomness.js +17 -9
- package/linter/rules/undefined-symbol.js +1 -1
- package/linter/rules/unused-definition.js +15 -10
- package/linter/rules/useless-loop.js +1 -1
- package/package.json +3 -2
- package/project/cache/flowr-analyzer-cache.d.ts +4 -3
- package/project/cache/flowr-analyzer-cache.js +32 -13
- package/project/cache/flowr-cache.d.ts +39 -12
- package/project/cache/flowr-cache.js +5 -3
- package/project/context/flowr-analyzer-context.d.ts +8 -1
- package/project/context/flowr-analyzer-context.js +11 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +4 -2
- package/project/context/flowr-analyzer-dependencies-context.js +15 -1
- package/project/context/flowr-analyzer-files-context.d.ts +8 -4
- package/project/context/flowr-analyzer-files-context.js +20 -1
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
- package/project/context/flowr-analyzer-meta-context.js +14 -0
- package/project/context/flowr-file.d.ts +25 -3
- package/project/context/flowr-file.js +24 -2
- package/project/dependency-version-space.d.ts +37 -0
- package/project/dependency-version-space.js +118 -26
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +6 -2
- package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
- package/project/incremental/incremental-parse/edit-computation.js +61 -0
- package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
- package/project/incremental/incremental-parse/incremental-parse.js +37 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +27 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
- package/project/plugins/plugin-registry.d.ts +4 -4
- package/project/plugins/plugin-registry.js +7 -4
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/reader.d.ts +7 -0
- package/project/sigdb/reader.js +12 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +14 -13
- package/queries/catalog/dependencies-query/function-info/write-functions.js +28 -36
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +9 -10
- package/queries/catalog/input-sources-query/input-source-functions.js +23 -394
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +11 -6
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +28 -10
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +14 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +24 -0
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
- package/queries/catalog/signature-query/signature-query-executor.js +79 -3
- package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
- package/queries/catalog/signature-query/signature-query-render.js +21 -3
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
- package/r-bridge/parser.d.ts +11 -1
- package/r-bridge/parser.js +7 -4
- package/r-bridge/shell-executor.d.ts +1 -0
- package/r-bridge/shell-executor.js +1 -0
- package/r-bridge/shell.d.ts +1 -0
- package/r-bridge/shell.js +1 -0
- package/reconstruct/inline/source-inline-map.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -6
- package/search/flowr-search-filters.js +1 -8
- package/search/search-executor/search-enrichers.d.ts +2 -0
- package/search/search-executor/search-enrichers.js +29 -12
- package/util/mermaid/dfg.js +1 -1
- package/util/version.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
|
@@ -12,6 +12,7 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
12
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
13
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
14
14
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
15
|
+
const range_1 = require("../../../../../../util/range");
|
|
15
16
|
/**
|
|
16
17
|
* Processes a built-in 'get' function call.
|
|
17
18
|
*
|
|
@@ -28,17 +29,36 @@ function processGet(name, args, rootId, data) {
|
|
|
28
29
|
const retrieve = firstArg !== undefined && firstArg !== r_function_call_1.EmptyArgument
|
|
29
30
|
? (0, unpack_argument_1.unpackNonameArg)(firstArg)
|
|
30
31
|
: undefined;
|
|
31
|
-
|
|
32
|
+
let treatTargetAsSymbol = undefined;
|
|
33
|
+
if (retrieve !== undefined && retrieve.type === type_1.RType.String) {
|
|
34
|
+
treatTargetAsSymbol = {
|
|
35
|
+
type: type_1.RType.Symbol,
|
|
36
|
+
info: retrieve.info,
|
|
37
|
+
content: (0, retriever_1.removeRQuotes)(retrieve.lexeme),
|
|
38
|
+
lexeme: retrieve.lexeme,
|
|
39
|
+
location: retrieve.location
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else if (retrieve !== undefined) {
|
|
43
|
+
const resolvedName = (0, built_in_envir_utils_1.resolveConstantString)(retrieve, data);
|
|
44
|
+
if (resolvedName !== undefined) {
|
|
45
|
+
const synthId = rootId + '-get-name';
|
|
46
|
+
const synthSymbol = {
|
|
47
|
+
type: type_1.RType.Symbol,
|
|
48
|
+
info: { ...retrieve.info, id: synthId },
|
|
49
|
+
content: resolvedName,
|
|
50
|
+
lexeme: resolvedName,
|
|
51
|
+
location: retrieve.location ?? name.location ?? range_1.SourceRange.invalid()
|
|
52
|
+
};
|
|
53
|
+
data.completeAst.idMap.set(synthId, synthSymbol);
|
|
54
|
+
treatTargetAsSymbol = synthSymbol;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (treatTargetAsSymbol === undefined) {
|
|
32
58
|
logger_1.dataflowLogger.warn(`symbol access with ${identifier_1.Identifier.toString(name.content)} has not 1 string argument, skipping`);
|
|
33
|
-
|
|
59
|
+
// dynamic, unresolvable name: reached-but-unknown rather than dropped
|
|
60
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default', hasUnknownSideEffect: true }).information;
|
|
34
61
|
}
|
|
35
|
-
const treatTargetAsSymbol = {
|
|
36
|
-
type: type_1.RType.Symbol,
|
|
37
|
-
info: retrieve.info,
|
|
38
|
-
content: (0, retriever_1.removeRQuotes)(retrieve.lexeme),
|
|
39
|
-
lexeme: retrieve.lexeme,
|
|
40
|
-
location: retrieve.location
|
|
41
|
-
};
|
|
42
62
|
/* resolve in the custom environment if one was found, else the global one.
|
|
43
63
|
* Pass remaining original args (e.g. envir=e) so they appear as Use vertices in the graph. */
|
|
44
64
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
2
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
3
|
+
import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
3
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
5
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
6
|
import type { DataflowInformation } from '../../../../../info';
|
|
6
7
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
8
|
+
import type { REnvironmentInformation } from '../../../../../environments/environment';
|
|
7
9
|
/**
|
|
8
10
|
* Process a list call.
|
|
9
11
|
*
|
|
@@ -13,3 +15,5 @@ import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
17
|
export declare function processList<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
18
|
+
/** Records a `list(...)`'s named function entries as a resolvable pseudo-env, so `d$foo(...)`/`d[["foo"]](...)` link to them; `undefined` if none. */
|
|
19
|
+
export declare function resolveListToEnvState<OtherInfo>(source: RNode<OtherInfo & ParentInformation>, data: Pick<DataflowProcessorInformation<never>, 'environment'>): REnvironmentInformation | undefined;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processList = processList;
|
|
4
|
+
exports.resolveListToEnvState = resolveListToEnvState;
|
|
5
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
6
|
+
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
4
7
|
const known_call_handling_1 = require("../known-call-handling");
|
|
5
8
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
9
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
10
|
+
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
11
|
+
const define_1 = require("../../../../../environments/define");
|
|
12
|
+
const scoping_1 = require("../../../../../environments/scoping");
|
|
6
13
|
/**
|
|
7
14
|
* Process a list call.
|
|
8
15
|
*
|
|
@@ -14,4 +21,32 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
|
|
|
14
21
|
function processList(name, args, rootId, data) {
|
|
15
22
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.List }).information;
|
|
16
23
|
}
|
|
24
|
+
/** Records a `list(...)`'s named function entries as a resolvable pseudo-env, so `d$foo(...)`/`d[["foo"]](...)` link to them; `undefined` if none. */
|
|
25
|
+
function resolveListToEnvState(source, data) {
|
|
26
|
+
if (!r_function_call_1.RFunctionCall.isNamed(source)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
let envState = (0, scoping_1.pushLocalEnvironment)(data.environment);
|
|
30
|
+
let found = false;
|
|
31
|
+
for (const arg of source.arguments) {
|
|
32
|
+
if (arg === r_function_call_1.EmptyArgument || arg.name === undefined || arg.value === undefined) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const value = arg.value;
|
|
36
|
+
const isFn = value.type === type_1.RType.FunctionDefinition
|
|
37
|
+
|| (value.type === type_1.RType.Symbol && ((0, resolve_by_name_1.resolveByName)(value.content, data.environment, identifier_1.ReferenceType.Function)?.length ?? 0) > 0);
|
|
38
|
+
if (!isFn) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
envState = (0, define_1.define)({
|
|
42
|
+
type: identifier_1.ReferenceType.Function,
|
|
43
|
+
name: arg.name.content,
|
|
44
|
+
nodeId: value.info.id,
|
|
45
|
+
definedAt: value.info.id,
|
|
46
|
+
cds: undefined
|
|
47
|
+
}, false, envState);
|
|
48
|
+
found = true;
|
|
49
|
+
}
|
|
50
|
+
return found ? envState : undefined;
|
|
51
|
+
}
|
|
17
52
|
//# sourceMappingURL=built-in-list.js.map
|
|
@@ -28,7 +28,7 @@ function processNewEnv(name, args, rootId, data) {
|
|
|
28
28
|
if (data.ctx.config.solver.trackEnvironments) {
|
|
29
29
|
const parentState = resolveNewEnvParentArg(args, data);
|
|
30
30
|
const vertex = result.graph.getVertex(rootId);
|
|
31
|
-
if (parentState !== undefined &&
|
|
31
|
+
if (parentState !== undefined && vertex_1.FunctionCallVertex.is(vertex)) {
|
|
32
32
|
vertex.newEnvParent = parentState;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -85,7 +85,7 @@ function createIsolatedEnvState(data) {
|
|
|
85
85
|
function createFreshEnvState(data, sourceInfo) {
|
|
86
86
|
if (sourceInfo !== undefined) {
|
|
87
87
|
const vertex = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
|
|
88
|
-
if (
|
|
88
|
+
if (vertex_1.FunctionCallVertex.is(vertex) && vertex.newEnvParent !== undefined) {
|
|
89
89
|
return {
|
|
90
90
|
current: new environment_1.Environment(vertex.newEnvParent.current),
|
|
91
91
|
level: vertex.newEnvParent.level + 1
|
|
@@ -47,7 +47,7 @@ function processRecall(name, args, rootId, data, config) {
|
|
|
47
47
|
information.graph.addEdge(rootId, closure, edge_1.EdgeType.Calls);
|
|
48
48
|
// also kill the name of the recall function
|
|
49
49
|
const r = information.graph.getVertex(rootId);
|
|
50
|
-
if (
|
|
50
|
+
if (vertex_1.FunctionCallVertex.is(r)) {
|
|
51
51
|
r.name = unnamed_call_handling_1.UnnamedFunctionCallPrefix + rootId + '-' + identifier_1.Identifier.toString(r.name);
|
|
52
52
|
r.environment = information.environment;
|
|
53
53
|
}
|
|
@@ -24,6 +24,8 @@ export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo &
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function processMakeConstructor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
|
|
26
26
|
readonly mode?: readonly ('s7' | 's3' | 's4')[];
|
|
27
|
+
readonly wrapIndex?: number;
|
|
28
|
+
readonly wrapName?: string;
|
|
27
29
|
}): DataflowInformation;
|
|
28
30
|
/**
|
|
29
31
|
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
@@ -4,6 +4,8 @@ exports.S7SyntheticFunArgSuffix = void 0;
|
|
|
4
4
|
exports.processS7NewGeneric = processS7NewGeneric;
|
|
5
5
|
exports.processMakeConstructor = processMakeConstructor;
|
|
6
6
|
const known_call_handling_1 = require("../known-call-handling");
|
|
7
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
|
+
const built_in_apply_1 = require("./built-in-apply");
|
|
7
9
|
const logger_1 = require("../../../../../logger");
|
|
8
10
|
const linker_1 = require("../../../../linker");
|
|
9
11
|
const common_1 = require("../common");
|
|
@@ -87,8 +89,52 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
87
89
|
if (fArg?.tag === vertex_1.VertexType.FunctionDefinition && config?.mode) {
|
|
88
90
|
fArg.mode ??= config.mode.slice(); // copy: mode is mutated in place later, config.mode is shared
|
|
89
91
|
}
|
|
92
|
+
if (config?.wrapIndex !== undefined) {
|
|
93
|
+
linkWrappedFunction(info, args, config.wrapIndex, config.wrapName, data);
|
|
94
|
+
}
|
|
90
95
|
return info;
|
|
91
96
|
}
|
|
97
|
+
/** Mark the wrapped function of an eager higher-order wrapper (`Negate`/`Vectorize`/`partial`) as called. */
|
|
98
|
+
function linkWrappedFunction(info, args, wrapIndex, wrapName, data) {
|
|
99
|
+
let wrapped = undefined;
|
|
100
|
+
if (wrapName !== undefined) {
|
|
101
|
+
wrapped = args.find(a => a !== r_function_call_1.EmptyArgument && a.name?.content === wrapName);
|
|
102
|
+
}
|
|
103
|
+
if (wrapped === undefined) {
|
|
104
|
+
let pos = 0;
|
|
105
|
+
for (const a of args) {
|
|
106
|
+
if (a === r_function_call_1.EmptyArgument || a.name) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (pos === wrapIndex) {
|
|
110
|
+
wrapped = a;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
pos++;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (wrapped === undefined || wrapped === r_function_call_1.EmptyArgument || !wrapped.value) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const resolved = (0, built_in_apply_1.resolveFunctionArgument)(wrapped.value, data, {});
|
|
120
|
+
if (resolved === undefined || resolved.anonymous) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const vertex = info.graph.getVertex(resolved.functionId);
|
|
124
|
+
if (vertex?.tag !== vertex_1.VertexType.Use) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
info.graph.updateToFunctionCall({
|
|
128
|
+
tag: vertex_1.VertexType.FunctionCall,
|
|
129
|
+
id: resolved.functionId,
|
|
130
|
+
name: resolved.functionName,
|
|
131
|
+
args: [],
|
|
132
|
+
environment: data.environment,
|
|
133
|
+
onlyBuiltin: false,
|
|
134
|
+
cds: data.cds,
|
|
135
|
+
origin: [built_in_proc_name_1.BuiltInProcName.Function]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
92
138
|
/**
|
|
93
139
|
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
94
140
|
* carry one (`new_class`, `new_generic`, ...). It stands for no argument in the source, so consumers that reason
|
|
@@ -230,7 +230,7 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId) {
|
|
|
230
230
|
else if (gasLevel >= 1 /* GasLevel.Problematic */) {
|
|
231
231
|
logger_1.dataflowLogger.warn(`Approaching resource limits for source of ${JSON.stringify(request)} (gas: problematic). See ${gas_1.GasWikiRef}`);
|
|
232
232
|
}
|
|
233
|
-
const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(textRequest.r);
|
|
233
|
+
const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(textRequest.r, data.ctx);
|
|
234
234
|
const normalized = (typeof parsed !== 'string' ?
|
|
235
235
|
(0, parser_1.normalizeTreeSitter)({ files: [{ parsed, filePath: textRequest.path }] }, getId, data.ctx.config)
|
|
236
236
|
: (0, parser_1.normalize)({ files: [{ parsed, filePath: textRequest.path }] }, getId));
|
|
@@ -57,6 +57,8 @@ function resolveNodeToStackEnv(node, data) {
|
|
|
57
57
|
case default_builtin_config_1.StackEnvKind.Base:
|
|
58
58
|
case default_builtin_config_1.StackEnvKind.Empty:
|
|
59
59
|
return fixedStackEnv(kind, data);
|
|
60
|
+
case default_builtin_config_1.StackEnvKind.CallerFrame: // parent.frame(): the caller's frame, over-approximated to global (exact at a top-level call)
|
|
61
|
+
return fixedStackEnv(default_builtin_config_1.StackEnvKind.Global, data);
|
|
60
62
|
case default_builtin_config_1.StackEnvKind.Current: // environment() with no argument is the current environment
|
|
61
63
|
return firstArg === undefined ? { current: data.environment.current, level: data.environment.level } : undefined;
|
|
62
64
|
case default_builtin_config_1.StackEnvKind.Parent: {
|
|
@@ -86,7 +88,7 @@ function asSearchPathEnv(name, data) {
|
|
|
86
88
|
/** If `sourceInfo`'s entry is a {@link BuiltInProcName.StackEnv} call, the stack environment it refers to; else `undefined`. */
|
|
87
89
|
function stackEnvStateFromSource(sourceInfo, data) {
|
|
88
90
|
const vertex = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
|
|
89
|
-
if (!
|
|
91
|
+
if (!vertex_1.FunctionCallVertex.is(vertex) || vertex.name === undefined || !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.StackEnv)) {
|
|
90
92
|
return undefined;
|
|
91
93
|
}
|
|
92
94
|
return fixedStackEnv(stackEnvKind(String(vertex.name)), data);
|
|
@@ -60,8 +60,9 @@ export declare enum NseArguments {
|
|
|
60
60
|
/**
|
|
61
61
|
* Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
|
|
62
62
|
* (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
|
|
63
|
+
* Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
|
|
63
64
|
*/
|
|
64
|
-
export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments): void;
|
|
65
|
+
export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[]): void;
|
|
65
66
|
/**
|
|
66
67
|
* Marks the given arguments as being involved in R's non-standard evaluation.
|
|
67
68
|
*/
|
|
@@ -29,12 +29,13 @@ var NseArguments;
|
|
|
29
29
|
/**
|
|
30
30
|
* Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
|
|
31
31
|
* (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
|
|
32
|
+
* Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
|
|
32
33
|
*/
|
|
33
34
|
function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which) {
|
|
34
35
|
const end = which === NseArguments.First ? 1 : processedArguments.length;
|
|
35
36
|
for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
|
|
36
37
|
const arg = processedArguments[i];
|
|
37
|
-
if (arg === undefined) {
|
|
38
|
+
if (arg === undefined || (typeof which !== 'string' && !which.includes(i))) {
|
|
38
39
|
continue;
|
|
39
40
|
}
|
|
40
41
|
graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
|
|
@@ -7,12 +7,32 @@ const common_1 = require("./common");
|
|
|
7
7
|
const linker_1 = require("../../../linker");
|
|
8
8
|
const edge_1 = require("../../../../graph/edge");
|
|
9
9
|
const graph_1 = require("../../../../graph/graph");
|
|
10
|
+
const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
|
|
10
11
|
const vertex_1 = require("../../../../graph/vertex");
|
|
11
12
|
const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
12
13
|
const logger_1 = require("../../../../logger");
|
|
13
14
|
const identifier_1 = require("../../../../environments/identifier");
|
|
14
15
|
const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
|
|
16
|
+
const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
15
17
|
exports.UnnamedFunctionCallPrefix = 'unnamed-fc-';
|
|
18
|
+
/**
|
|
19
|
+
* Whether a `$`/`[[` access callee resolved a field to a stored function: a resolved dispatch (`dispatch$foo()`)
|
|
20
|
+
* carries a `Returns` edge from the access node to the field target (in addition to the base `Returns` to `accessedId`),
|
|
21
|
+
* while an opaque object (`g$greet()` on an untracked `g`) only carries the base `Returns`.
|
|
22
|
+
*/
|
|
23
|
+
function accessResolvesToField(graph, accessId, accessedId) {
|
|
24
|
+
const outgoing = graph.outgoingEdges(accessId);
|
|
25
|
+
if (outgoing === undefined) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const base = node_id_1.NodeId.normalize(accessedId);
|
|
29
|
+
for (const [target, edge] of outgoing) {
|
|
30
|
+
if (node_id_1.NodeId.normalize(target) !== base && edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
16
36
|
/**
|
|
17
37
|
* Processes an unnamed function call.
|
|
18
38
|
* For example `(function(x) { x + 1 })(5)`
|
|
@@ -53,6 +73,10 @@ function processUnnamedFunctionCall(functionCall, data) {
|
|
|
53
73
|
if (functionCall.calledFunction.type === type_1.RType.FunctionDefinition) {
|
|
54
74
|
(0, linker_1.linkArgumentsOnCall)(callArgs, functionCall.calledFunction.parameters, finalGraph);
|
|
55
75
|
}
|
|
76
|
+
else if (functionCall.calledFunction.type === type_1.RType.Access && !accessResolvesToField(finalGraph, calledRootId, functionCall.calledFunction.accessed.info.id)) {
|
|
77
|
+
// `obj$method()` whose callee did not resolve to a stored function: reached-but-unknown rather than dropped
|
|
78
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(finalGraph, data.environment, functionRootId);
|
|
79
|
+
}
|
|
56
80
|
// push the called function to the ids:
|
|
57
81
|
inIds = inIds.concat(calledFunction.in, calledFunction.unknownReferences);
|
|
58
82
|
return {
|
|
@@ -19,7 +19,8 @@ function processFunctionParameter(parameter, data) {
|
|
|
19
19
|
type: identifier_1.ReferenceType.Parameter,
|
|
20
20
|
definedAt: parameter.info.id
|
|
21
21
|
}));
|
|
22
|
-
|
|
22
|
+
// keep the default's environment so its escaping (`<<-`) writes are carried on
|
|
23
|
+
let environment = defaultValue?.environment ?? name.environment;
|
|
23
24
|
for (const writtenNode of writtenNodes) {
|
|
24
25
|
const wid = writtenNode.nodeId;
|
|
25
26
|
(0, log_1.expensiveTrace)(log_1.log, () => `parameter ${writtenNode.name} (${wid}) is defined at id ${writtenNode.definedAt} with ${defaultValue === undefined ? 'no default value' : ' a default value'}`);
|
|
@@ -6,6 +6,9 @@ const doc_files_1 = require("../../doc-util/doc-files");
|
|
|
6
6
|
const doc_code_1 = require("../../doc-util/doc-code");
|
|
7
7
|
const recommended_configs_1 = require("./recommended-configs");
|
|
8
8
|
const project_kind_1 = require("../../../project/context/project-kind");
|
|
9
|
+
const doc_cli_option_1 = require("../../doc-util/doc-cli-option");
|
|
10
|
+
const log_1 = require("../../../../test/functionality/_helper/log");
|
|
11
|
+
const log_2 = require("../../../util/log");
|
|
9
12
|
/**
|
|
10
13
|
*
|
|
11
14
|
*/
|
|
@@ -52,6 +55,14 @@ ${(0, doc_code_1.codeBlock)('shell', 'npm run flowR -- --help')}
|
|
|
52
55
|
`)
|
|
53
56
|
.addFaq('How to do *logging* in flowR?', `
|
|
54
57
|
Check out the ${ctx.linkPage('wiki/Linting and Testing', 'Logging Section in the Linting and Testing wiki page', 'logging')} for more information on how to do logging in *flowR*.
|
|
58
|
+
`)
|
|
59
|
+
.addFaq('How to get flowR to *talk*?', `
|
|
60
|
+
When using flowR from the CLI, you can use the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'verbose')} option to get more information about what flowR is doing.
|
|
61
|
+
While coding, however, you can use the ${ctx.link(log_1.setMinLevelOfAllLogs)} function to set the minimum level of logs to be displayed (this works with the ${ctx.link(log_2.FlowrLogger)} abstraction).
|
|
62
|
+
In general, you can configure the levels of individual logs, such as the general \`log\` (obtained with ${ctx.link('getActiveLog')}) or the ${ctx.link('parseLog')}.
|
|
63
|
+
Please note that flowR makes no guarantees that log outputs are persistent across versions, and it is up to the implementors to provide sensible logging.
|
|
64
|
+
If you are an implementor and want to add logging, please make sure there are no larger runtime implications when logging is disabled.
|
|
65
|
+
Have a look at the ${ctx.link(log_2.expensiveTrace)} function for example, which uses a function to generate the log message only when the log level is reached.
|
|
55
66
|
`)
|
|
56
67
|
.addFaq('How to run *tests* with *verbose* logging?', `
|
|
57
68
|
Use the dedicated npm script to run all tests with trace-level log output:
|
|
@@ -482,7 +482,7 @@ function implSnippet(node, program, showName = true, nesting = 0, open = false,
|
|
|
482
482
|
text = ' ' + text;
|
|
483
483
|
}
|
|
484
484
|
if (showImplSnippet) {
|
|
485
|
-
const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
|
|
485
|
+
const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName)).trim();
|
|
486
486
|
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`;
|
|
487
487
|
}
|
|
488
488
|
else {
|
|
@@ -28,7 +28,11 @@ const flowr_analyzer_plugin_1 = require("../project/plugins/flowr-analyzer-plugi
|
|
|
28
28
|
const flowr_analyzer_environment_context_1 = require("../project/context/flowr-analyzer-environment-context");
|
|
29
29
|
const flowr_analyzer_functions_context_1 = require("../project/context/flowr-analyzer-functions-context");
|
|
30
30
|
const flowr_analyzer_meta_context_1 = require("../project/context/flowr-analyzer-meta-context");
|
|
31
|
+
const flowr_analyzer_incremental_analysis_context_1 = require("../project/context/flowr-analyzer-incremental-analysis-context");
|
|
32
|
+
const flowr_analyzer_gas_context_1 = require("../project/context/flowr-analyzer-gas-context");
|
|
33
|
+
const flowr_analyzer_gas_plugin_1 = require("../project/plugins/gas-plugins/flowr-analyzer-gas-plugin");
|
|
31
34
|
const config_1 = require("../config");
|
|
35
|
+
const flowr_file_1 = require("../project/context/flowr-file");
|
|
32
36
|
async function analyzerQuickExample() {
|
|
33
37
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
|
|
34
38
|
.setEngine('tree-sitter')
|
|
@@ -84,6 +88,8 @@ ${(0, doc_structure_1.collapsibleToc)({
|
|
|
84
88
|
'Dependencies Context': undefined,
|
|
85
89
|
'Environment Context': undefined,
|
|
86
90
|
'Meta Context': undefined,
|
|
91
|
+
'Gas Context': undefined,
|
|
92
|
+
'Incremental Analysis Context': undefined,
|
|
87
93
|
},
|
|
88
94
|
'Caching': undefined
|
|
89
95
|
})}
|
|
@@ -441,6 +447,75 @@ ${ctx.linkM(flowr_analyzer_meta_context_1.FlowrAnalyzerMetaContext, 'getProjectV
|
|
|
441
447
|
and the project namespace via
|
|
442
448
|
${ctx.linkM(flowr_analyzer_meta_context_1.FlowrAnalyzerMetaContext, 'getNamespace', { codeFont: true, realNameWrapper: 'i' })}.
|
|
443
449
|
|
|
450
|
+
${(0, doc_structure_1.section)('Gas Context', 3)}
|
|
451
|
+
|
|
452
|
+
The ${ctx.link(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext)} (reachable as \`ctx.gas\`) acts as the resource guard of an analysis:
|
|
453
|
+
|
|
454
|
+
${ctx.hierarchy(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, { showImplSnippet: false })}
|
|
455
|
+
|
|
456
|
+
Expensive analysis sites ask for the current resource pressure with
|
|
457
|
+
${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'checkGas', { codeFont: true, realNameWrapper: 'i' })}, passing the name of the feature they are about to run
|
|
458
|
+
(see ${ctx.link('GasFeatureKey')}), and may then degrade or skip their work.
|
|
459
|
+
The level combines the current heap usage and the time elapsed since the analysis started (or since the last
|
|
460
|
+
${ctx.linkM(flowr_analyzer_context_1.FlowrAnalyzerContext, 'reset')}, which also resets the gas clock via
|
|
461
|
+
${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'reset', { codeFont: true, realNameWrapper: 'i' })}),
|
|
462
|
+
each scaled by the per-feature factor from \`config.gas.features\`.
|
|
463
|
+
Registered ${ctx.link(flowr_analyzer_gas_plugin_1.FlowrAnalyzerGasPlugin)}s may escalate the level for any key.
|
|
464
|
+
|
|
465
|
+
${(0, doc_structure_1.block)({
|
|
466
|
+
type: 'NOTE',
|
|
467
|
+
content: `
|
|
468
|
+
Gas is disabled for every feature by default, and with no gas plugins registered
|
|
469
|
+
${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'checkGas', { codeFont: true, realNameWrapper: 'i' })} returns \`GasLevel.Normal\` without measuring anything.
|
|
470
|
+
See the ${ctx.linkPage('wiki/Core', 'gas section of the Core wiki page', 'gas-resource-guard')} for the levels, the configuration, and how to write a gas plugin.
|
|
471
|
+
`.trim()
|
|
472
|
+
})}
|
|
473
|
+
|
|
474
|
+
${(0, doc_structure_1.section)('Incremental Analysis Context', 3)}
|
|
475
|
+
|
|
476
|
+
The ${ctx.link(flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext)} is a context that stores analysis information needed for making the next analysis run incremental by reusing the previous analysis results:
|
|
477
|
+
|
|
478
|
+
${ctx.hierarchy(flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext, { showImplSnippet: false })}
|
|
479
|
+
|
|
480
|
+
This context is not an analysis-result cache by itself.
|
|
481
|
+
Instead, it carries forward the minimal state needed by future incremental phases after an invalidation happened.
|
|
482
|
+
At the moment, it is used for incremental parsing with Tree-sitter, but it is intended to become the shared context for additional incremental analysis stages as well.
|
|
483
|
+
|
|
484
|
+
If the analyzer or context is reset, the incremental information is discarded via
|
|
485
|
+
${ctx.linkM(flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext, 'reset', { codeFont: true, realNameWrapper: 'i' })}.
|
|
486
|
+
In other words, this context only transports incremental handoff state between analysis runs.
|
|
487
|
+
|
|
488
|
+
${(0, doc_structure_1.section)('Incremental Parsing', 4)}
|
|
489
|
+
|
|
490
|
+
This context is used to exploit Tree-sitter's incremental parsing feature.
|
|
491
|
+
For one file, the incremental state follows a fixed lifecycle:
|
|
492
|
+
|
|
493
|
+
1. After a successful parse-oriented analysis run, the analyzer cache stores the latest Tree-sitter parse tree via
|
|
494
|
+
${ctx.linkM(flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext, 'storeOldParseResults', { codeFont: true, realNameWrapper: 'i' })}.
|
|
495
|
+
This tree is the baseline for the next incremental parse of that file.
|
|
496
|
+
2. When a mutable file provider such as ${ctx.link('FlowrInlineTextFile')} is invalidated via
|
|
497
|
+
${ctx.linkM(flowr_file_1.FlowrInlineTextFile, 'invalidate', { codeFont: true, realNameWrapper: 'i' })},
|
|
498
|
+
the analyzer receives a file invalidation event and stores the file path together with the old source text.
|
|
499
|
+
If the same file is invalidated again before the next parse, this stored old text is intentionally **not** replaced:
|
|
500
|
+
the stored parse tree still belongs to the version from before the first invalidation, so the incremental parse must keep that matching old-content baseline.
|
|
501
|
+
3. When parsing is requested again, flowR retrieves
|
|
502
|
+
* the previous parse tree from
|
|
503
|
+
${ctx.linkM(flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext, 'getOldParseResultOf', { codeFont: true, realNameWrapper: 'i' })}
|
|
504
|
+
* the stored old source text from
|
|
505
|
+
${ctx.linkM(flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext, 'getOldContentOf', { codeFont: true, realNameWrapper: 'i' })}
|
|
506
|
+
|
|
507
|
+
Using these together with the current file content, flowR computes a minimal ${ctx.link('Parser.Edit')} only when a new parse is actually requested.
|
|
508
|
+
If the file content did not change, the previous tree can be reused directly.
|
|
509
|
+
Otherwise, the edit is applied to the previous tree and Tree-sitter reparses incrementally instead of starting from scratch.
|
|
510
|
+
4. The stored old-content entry is removed when it is used because it belongs only to that previous parse snapshot.
|
|
511
|
+
After the new parse succeeds, the analyzer stores a new parse tree baseline.
|
|
512
|
+
A later invalidation must then be able to record a fresh old-content value that matches this new tree.
|
|
513
|
+
If the old-content entry were kept, later invalidations of the same file would not replace it, and the next incremental parse could compare the current file content against stale old text that no longer matches the stored previous tree.
|
|
514
|
+
|
|
515
|
+
${(0, doc_structure_1.section)('Incremental Dataflow', 4)}
|
|
516
|
+
|
|
517
|
+
This context is planned to also support future incremental dataflow graph computation.
|
|
518
|
+
|
|
444
519
|
|
|
445
520
|
${(0, doc_structure_1.section)('Caching', 2)}
|
|
446
521
|
|
|
@@ -38,6 +38,8 @@ const flowr_analyzer_context_1 = require("../project/context/flowr-analyzer-cont
|
|
|
38
38
|
const flowr_analyzer_gas_context_1 = require("../project/context/flowr-analyzer-gas-context");
|
|
39
39
|
const flowr_analyzer_gas_plugin_1 = require("../project/plugins/gas-plugins/flowr-analyzer-gas-plugin");
|
|
40
40
|
const gas_1 = require("../gas");
|
|
41
|
+
const built_in_props_1 = require("../dataflow/environments/built-in-props");
|
|
42
|
+
const query_fn_props_1 = require("../dataflow/environments/query-fn-props");
|
|
41
43
|
const semver_1 = require("semver");
|
|
42
44
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
43
45
|
const process_value_1 = require("../dataflow/internal/process/process-value");
|
|
@@ -47,8 +49,6 @@ const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
|
47
49
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
48
50
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
49
51
|
const shell_1 = require("../r-bridge/shell");
|
|
50
|
-
const log_1 = require("../../test/functionality/_helper/log");
|
|
51
|
-
const log_2 = require("../util/log");
|
|
52
52
|
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
53
53
|
async function makeAnalyzerExample() {
|
|
54
54
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
|
|
@@ -105,6 +105,60 @@ async function gasPluginExample() {
|
|
|
105
105
|
.setEngine('tree-sitter')
|
|
106
106
|
.build();
|
|
107
107
|
}
|
|
108
|
+
/** the names of the {@link CallProp} bits that make up a mask, as inline code */
|
|
109
|
+
function propNames(mask) {
|
|
110
|
+
return Object.entries(built_in_props_1.CallProp).filter(([, b]) => typeof b === 'number' && (b & mask) !== 0)
|
|
111
|
+
.map(([n]) => `\`${n}\``).join(', ');
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A table per property enum, taken straight from the configuration: what each bit means (its own doc comment),
|
|
115
|
+
* how many built-ins carry it, and which of them the signature database can state on its own.
|
|
116
|
+
*/
|
|
117
|
+
function builtInPropsTables(ctx) {
|
|
118
|
+
const index = query_fn_props_1.BuiltInIndex.default();
|
|
119
|
+
/* the doc comment of a bit is its explanation, flattened to fit a table cell; bits nothing carries are left out */
|
|
120
|
+
const table = (type, of) => [
|
|
121
|
+
`| ${type === 'CallProp' ? 'Call property' : 'Argument role'} | Built-ins | Meaning |`,
|
|
122
|
+
'| :-- | --: | :-- |',
|
|
123
|
+
...Object.entries(type === 'CallProp' ? built_in_props_1.CallProp : built_in_props_1.ArgProp)
|
|
124
|
+
.filter(([, bit]) => typeof bit === 'number' && of(bit) > 0)
|
|
125
|
+
.map(([name, bit]) => {
|
|
126
|
+
/* a `{@link}` has already become an anchor, so dropping the tags leaves the bare name and a stray space */
|
|
127
|
+
const doc = ctx.doc(`${type}::${name}`).replaceAll(/<[^>]*>/g, '').replaceAll(/\s+/g, ' ')
|
|
128
|
+
.replaceAll(/ ([),.;])/g, '$1').replaceAll('|', '\\|').trim();
|
|
129
|
+
const db = type === 'CallProp' && (bit & built_in_props_1.SigDbInferable) !== 0 ? '<sup>db</sup>' : '';
|
|
130
|
+
return `| \`${name}\`${db} | ${of(bit)} | ${doc} |`;
|
|
131
|
+
})
|
|
132
|
+
].join('\n');
|
|
133
|
+
return `${(0, doc_structure_1.details)('What each call property means', `<sup>db</sup> marks the bits the ${ctx.linkPage('wiki/Signature Database', 'signature database')}
|
|
134
|
+
states for any package function on its own (${ctx.link(query_fn_props_1.inferFnProps.name)} reads them off an entry and carries what a
|
|
135
|
+
function calls over to the function calling it).
|
|
136
|
+
|
|
137
|
+
${table('CallProp', bit => index.with(bit).length)}
|
|
138
|
+
|
|
139
|
+
Most of these combine freely. The exceptions are ${ctx.link('ExclusiveCallProps')}, which a test checks the whole
|
|
140
|
+
configuration against:
|
|
141
|
+
|
|
142
|
+
${built_in_props_1.ExclusiveCallProps.map(([bit, forbidden]) => `* \`${built_in_props_1.CallProp[bit]}\` rules out ${propNames(forbidden)}`).join('\n')}
|
|
143
|
+
|
|
144
|
+
Two pairs read like refinements but are not: \`TempFile\` does not imply \`File\` (making up a path touches no file
|
|
145
|
+
system, so a call doing both states both), and \`Reads\`/\`Writes\` say what happens to the resource an
|
|
146
|
+
\`ArgProp.Resource\` argument names, so they only ever appear next to a resource bit.`)}
|
|
147
|
+
|
|
148
|
+
${(0, doc_structure_1.details)('What each argument role means', `A role is stated per parameter in the ${ctx.link('FnSig')} of a built-in, in the order R declares
|
|
149
|
+
them, with \`...\` covering every position from where it appears. The count is how many built-ins have at least one
|
|
150
|
+
parameter in that role.
|
|
151
|
+
|
|
152
|
+
${table('ArgProp', bit => new Set(index.params(bit).map(p => p.call)).size)}`)}
|
|
153
|
+
|
|
154
|
+
So \`lapply\` is pure on its own but runs what it is handed, and says which argument that is:
|
|
155
|
+
|
|
156
|
+
${(0, doc_code_1.codeBlock)('ts', `{ type: 'function', names: Identifier.fromAll(PkgName.Base, ['lapply', 'sapply', 'vapply']),
|
|
157
|
+
processor: BuiltInProcName.Apply,
|
|
158
|
+
config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true,
|
|
159
|
+
props: CallProp.MayPure, sig: [['X', ArgProp.Value], ['FUN', ArgProp.Callee]] } }`)}
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
108
162
|
/**
|
|
109
163
|
* https://github.com/flowr-analysis/flowr/wiki/Core
|
|
110
164
|
*/
|
|
@@ -135,7 +189,7 @@ ${await (0, doc_repl_1.documentReplSession)(shell, [{
|
|
|
135
189
|
}])}
|
|
136
190
|
|
|
137
191
|
If you are brave (or desperate) enough, you can also try to use the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'verbose')} option to be dumped with information about flowR's internals (please, never use this for benchmarking).
|
|
138
|
-
See the
|
|
192
|
+
See the ${ctx.linkPage('wiki/FAQ', 'FAQ')} (*How to get flowR to talk?*) for more information.
|
|
139
193
|
`
|
|
140
194
|
})}
|
|
141
195
|
|
|
@@ -149,7 +203,6 @@ See the [Getting flowR to Talk](#getting-flowr-to-talk) section below for more i
|
|
|
149
203
|
* [Beyond the Dataflow Graph](#beyond-the-dataflow-graph)
|
|
150
204
|
* [Static Backward Slicing](#static-backward-slicing)
|
|
151
205
|
* [Gas (Resource Guard)](#gas-resource-guard)
|
|
152
|
-
* [Getting flowR to Talk](#getting-flowr-to-talk)
|
|
153
206
|
|
|
154
207
|
## Creating and Using a flowR Analyzer Instance
|
|
155
208
|
|
|
@@ -426,9 +479,16 @@ But where are all the interesting things handled then?
|
|
|
426
479
|
For that, we want to have a look at the built-in environment, which can be freely configured using flowR's ${ctx.linkPage('wiki/Interface', 'configuration system', 'configuring-flowr')}.
|
|
427
480
|
FlowR's heart and soul resides in the ${ctx.link('DefaultBuiltinConfig')} object, which is used to configure the built-in environment
|
|
428
481
|
by mapping function names to ${ctx.link('BuiltInProcessorMapper')} functions.
|
|
429
|
-
There you can find functions like ${ctx.link(built_in_access_1.processAccess)} which handles the (subset) access to a variable,
|
|
482
|
+
There you can find functions like ${ctx.link(built_in_access_1.processAccess)} which handles the (subset) access to a variable,
|
|
430
483
|
or ${ctx.link(built_in_for_loop_1.processForLoop)} which handles the primitive for loop construct (whenever it is not overwritten).
|
|
431
484
|
|
|
485
|
+
Besides the processor, an entry states what the function does with ${ctx.link('BuiltInFnInfo')}: its ${ctx.link('CallProp')} bits
|
|
486
|
+
say what the call as a whole does, its ${ctx.link('FnSig')} says what each argument is used for (in the order R declares them,
|
|
487
|
+
with \`...\` covering every position from where it appears). Anything you add there is picked up by ${ctx.link(query_fn_props_1.BuiltInIndex.name)},
|
|
488
|
+
which is how the ${ctx.linkPage('wiki/Query API', 'input-sources query')} learns which functions bring in data of their own.
|
|
489
|
+
|
|
490
|
+
${builtInPropsTables(ctx)}
|
|
491
|
+
|
|
432
492
|
Just as an example, we want to have a look at the ${ctx.link(built_in_repeat_loop_1.processRepeatLoop)} function, as it is one of the simplest built-in processors
|
|
433
493
|
we have:
|
|
434
494
|
|
|
@@ -533,17 +593,6 @@ ${ctx.doc(flowr_analyzer_gas_plugin_1.FlowrAnalyzerGasPlugin)}
|
|
|
533
593
|
|
|
534
594
|
${ctx.code(gasPluginExample, { dropLinesStart: 1, dropLinesEnd: 1, hideDefinedAt: true })}
|
|
535
595
|
|
|
536
|
-
## Helpful Things
|
|
537
|
-
|
|
538
|
-
### Getting flowR to Talk
|
|
539
|
-
|
|
540
|
-
When using flowR from the CLI, you can use the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'verbose')} option to get more information about what flowR is doing.
|
|
541
|
-
While coding, however, you can use the ${ctx.link(log_1.setMinLevelOfAllLogs)} function to set the minimum level of logs to be displayed (this works with the ${ctx.link(log_2.FlowrLogger)} abstraction).
|
|
542
|
-
In general, you can configure the levels of individual logs, such as the general \`log\` (obtained with ${ctx.link('getActiveLog')}) or the ${ctx.link('parseLog')}.
|
|
543
|
-
Please note that flowR makes no guarantees that log outputs are persistent across versions, and it is up to the implementors to provide sensible logging.
|
|
544
|
-
If you are an implementor and want to add logging, please make sure there are no larger runtime impliciations when logging is disabled.
|
|
545
|
-
Have a look at the ${ctx.link(log_2.expensiveTrace)} function for example, which uses a function to generate the log message only when the log level is reached.
|
|
546
|
-
|
|
547
596
|
`;
|
|
548
597
|
}
|
|
549
598
|
}
|