@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
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
|
|
|
24
24
|
|
|
25
25
|
```shell
|
|
26
26
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
27
|
-
flowR repl using flowR v2.10.
|
|
27
|
+
flowR repl using flowR v2.10.5, R grammar v14 (tree-sitter engine)
|
|
28
28
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -35,7 +35,7 @@ It offers a wide variety of features, for example:
|
|
|
35
35
|
```text
|
|
36
36
|
Query: linter (2 ms)
|
|
37
37
|
╰ Deprecated Functions (deprecated-functions):
|
|
38
|
-
╰ Metadata: totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs:
|
|
38
|
+
╰ Metadata: totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 1, processTimeMs: 0
|
|
39
39
|
╰ File Path Validity (file-path-validity):
|
|
40
40
|
╰ certain:
|
|
41
41
|
╰ Path `/root/x.txt` at 1.1-23
|
|
@@ -45,7 +45,7 @@ It offers a wide variety of features, for example:
|
|
|
45
45
|
╰ Absolute Paths (absolute-file-paths):
|
|
46
46
|
╰ certain:
|
|
47
47
|
╰ Path `/root/x.txt` at 1.1-23
|
|
48
|
-
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
48
|
+
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0
|
|
49
49
|
╰ Unused Definitions (unused-definitions):
|
|
50
50
|
╰ Metadata: totalConsidered: 0, searchTimeMs: 0, processTimeMs: 0
|
|
51
51
|
╰ Naming Convention (naming-convention):
|
|
@@ -53,7 +53,7 @@ It offers a wide variety of features, for example:
|
|
|
53
53
|
╰ Network Functions (network-functions):
|
|
54
54
|
╰ Metadata: totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 0, processTimeMs: 0
|
|
55
55
|
╰ Dataframe Access Validation (dataframe-access-validation):
|
|
56
|
-
╰ Metadata: numOperations: 0, numAccesses: 0, totalAccessed: 0, searchTimeMs: 0, processTimeMs:
|
|
56
|
+
╰ Metadata: numOperations: 0, numAccesses: 0, totalAccessed: 0, searchTimeMs: 0, processTimeMs: 1
|
|
57
57
|
╰ Dead Code (dead-code):
|
|
58
58
|
╰ Metadata: consideredNodes: 5, searchTimeMs: 0, processTimeMs: 0
|
|
59
59
|
╰ Useless Loops (useless-loop):
|
|
@@ -61,10 +61,10 @@ It offers a wide variety of features, for example:
|
|
|
61
61
|
╰ Problematic inputs (problematic-inputs):
|
|
62
62
|
╰ Metadata: searchTimeMs: 0, processTimeMs: 0
|
|
63
63
|
╰ Stop without call.=False argument (stop-call):
|
|
64
|
-
╰ Metadata: consideredNodes: 0, searchTimeMs:
|
|
64
|
+
╰ Metadata: consideredNodes: 0, searchTimeMs: 0, processTimeMs: 0
|
|
65
65
|
╰ Roxygen Arguments (roxygen-arguments):
|
|
66
66
|
╰ Metadata: searchTimeMs: 0, processTimeMs: 0
|
|
67
|
-
All queries together required ≈2 ms (1ms accuracy, total
|
|
67
|
+
All queries together required ≈2 ms (1ms accuracy, total 2 ms)
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
|
|
@@ -88,17 +88,17 @@ It offers a wide variety of features, for example:
|
|
|
88
88
|
|
|
89
89
|
Query: **linter** (2 ms)\
|
|
90
90
|
╰ **Deprecated Functions** (deprecated-functions):\
|
|
91
|
-
╰ _Metadata_: <code>totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs:
|
|
91
|
+
╰ _Metadata_: <code>totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
92
92
|
╰ **File Path Validity** (file-path-validity):\
|
|
93
93
|
╰ certain:\
|
|
94
94
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
95
|
-
╰ _Metadata_: <code>totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
95
|
+
╰ _Metadata_: <code>totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0</code>\
|
|
96
96
|
╰ **Seeded Randomness** (seeded-randomness):\
|
|
97
97
|
╰ _Metadata_: <code>consumerCalls: 0, callsWithFunctionProducers: 0, callsWithAssignmentProducers: 0, callsWithNonConstantProducers: 0, callsWithOtherBranchProducers: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
98
98
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
99
99
|
╰ certain:\
|
|
100
100
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
101
|
-
╰ _Metadata_: <code>totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
101
|
+
╰ _Metadata_: <code>totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
102
102
|
╰ **Unused Definitions** (unused-definitions):\
|
|
103
103
|
╰ _Metadata_: <code>totalConsidered: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
104
104
|
╰ **Naming Convention** (naming-convention):\
|
|
@@ -106,7 +106,7 @@ It offers a wide variety of features, for example:
|
|
|
106
106
|
╰ **Network Functions** (network-functions):\
|
|
107
107
|
╰ _Metadata_: <code>totalCalls: 0, totalFunctionDefinitions: 0, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
108
108
|
╰ **Dataframe Access Validation** (dataframe-access-validation):\
|
|
109
|
-
╰ _Metadata_: <code>numOperations: 0, numAccesses: 0, totalAccessed: 0, searchTimeMs: 0, processTimeMs:
|
|
109
|
+
╰ _Metadata_: <code>numOperations: 0, numAccesses: 0, totalAccessed: 0, searchTimeMs: 0, processTimeMs: 1</code>\
|
|
110
110
|
╰ **Dead Code** (dead-code):\
|
|
111
111
|
╰ _Metadata_: <code>consideredNodes: 5, searchTimeMs: 0, processTimeMs: 0</code>\
|
|
112
112
|
╰ **Useless Loops** (useless-loop):\
|
|
@@ -121,7 +121,7 @@ It offers a wide variety of features, for example:
|
|
|
121
121
|
|
|
122
122
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
123
123
|
|
|
124
|
-
The analysis required _2.
|
|
124
|
+
The analysis required _2.2 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
125
125
|
|
|
126
126
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
127
127
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -138,7 +138,7 @@ It offers a wide variety of features, for example:
|
|
|
138
138
|
".meta": {
|
|
139
139
|
"totalCalls": 0,
|
|
140
140
|
"totalFunctionDefinitions": 0,
|
|
141
|
-
"searchTimeMs":
|
|
141
|
+
"searchTimeMs": 0,
|
|
142
142
|
"processTimeMs": 0
|
|
143
143
|
}
|
|
144
144
|
},
|
|
@@ -161,7 +161,7 @@ It offers a wide variety of features, for example:
|
|
|
161
161
|
"totalUnknown": 0,
|
|
162
162
|
"totalWritesBeforeAlways": 0,
|
|
163
163
|
"totalValid": 0,
|
|
164
|
-
"searchTimeMs":
|
|
164
|
+
"searchTimeMs": 1,
|
|
165
165
|
"processTimeMs": 0
|
|
166
166
|
}
|
|
167
167
|
},
|
|
@@ -193,7 +193,7 @@ It offers a wide variety of features, for example:
|
|
|
193
193
|
".meta": {
|
|
194
194
|
"totalConsidered": 1,
|
|
195
195
|
"totalUnknown": 0,
|
|
196
|
-
"searchTimeMs":
|
|
196
|
+
"searchTimeMs": 0,
|
|
197
197
|
"processTimeMs": 0
|
|
198
198
|
}
|
|
199
199
|
},
|
|
@@ -230,7 +230,7 @@ It offers a wide variety of features, for example:
|
|
|
230
230
|
"numAccesses": 0,
|
|
231
231
|
"totalAccessed": 0,
|
|
232
232
|
"searchTimeMs": 0,
|
|
233
|
-
"processTimeMs":
|
|
233
|
+
"processTimeMs": 1
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
"dead-code": {
|
|
@@ -342,7 +342,7 @@ It offers a wide variety of features, for example:
|
|
|
342
342
|
|
|
343
343
|
```shell
|
|
344
344
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
345
|
-
flowR repl using flowR v2.10.
|
|
345
|
+
flowR repl using flowR v2.10.5, R grammar v14 (tree-sitter engine)
|
|
346
346
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
347
347
|
```
|
|
348
348
|
|
|
@@ -356,7 +356,7 @@ It offers a wide variety of features, for example:
|
|
|
356
356
|
N <- 10
|
|
357
357
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
358
358
|
sum
|
|
359
|
-
All queries together required ≈
|
|
359
|
+
All queries together required ≈2 ms (1ms accuracy, total 3 ms)
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
|
|
@@ -390,7 +390,7 @@ It offers a wide variety of features, for example:
|
|
|
390
390
|
|
|
391
391
|
|
|
392
392
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
393
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
393
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">97.4 ms</span></i> (as of May 9, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
394
394
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
395
395
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
|
|
396
396
|
|
|
@@ -426,7 +426,7 @@ It offers a wide variety of features, for example:
|
|
|
426
426
|
|
|
427
427
|
```shell
|
|
428
428
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
429
|
-
flowR repl using flowR v2.10.
|
|
429
|
+
flowR repl using flowR v2.10.5, R grammar v14 (tree-sitter engine)
|
|
430
430
|
R> :dataflow* test/testfiles/example.R
|
|
431
431
|
```
|
|
432
432
|
|
|
@@ -734,7 +734,7 @@ It offers a wide variety of features, for example:
|
|
|
734
734
|
```
|
|
735
735
|
|
|
736
736
|
|
|
737
|
-
(The analysis required _1.
|
|
737
|
+
(The analysis required _1.4 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
|
|
738
738
|
|
|
739
739
|
|
|
740
740
|
|
|
@@ -6,7 +6,6 @@ import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexVariableD
|
|
|
6
6
|
import { type NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
7
7
|
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
8
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
9
|
-
import { type AnyAbstractDomain } from './domains/abstract-domain';
|
|
10
9
|
import type { AnyStateDomain, ValueDomain } from './domains/state-domain-like';
|
|
11
10
|
export type AbsintVisitorConfiguration = Omit<SemanticCfgGuidedVisitorConfiguration<NoInfo, ControlFlowInformation, NormalizedAst>, 'defaultVisitingOrder' | 'defaultVisitingType'>;
|
|
12
11
|
/**
|
|
@@ -14,7 +13,7 @@ export type AbsintVisitorConfiguration = Omit<SemanticCfgGuidedVisitorConfigurat
|
|
|
14
13
|
*
|
|
15
14
|
* However, the visitor does not yet support inter-procedural abstract interpretation and abstract condition semantics.
|
|
16
15
|
*/
|
|
17
|
-
export declare abstract class AbstractInterpretationVisitor<StateDomain extends AnyStateDomain
|
|
16
|
+
export declare abstract class AbstractInterpretationVisitor<StateDomain extends AnyStateDomain, Config extends AbsintVisitorConfiguration = AbsintVisitorConfiguration> extends SemanticCfgGuidedVisitor<NoInfo, ControlFlowInformation, NormalizedAst, DataflowGraph, Config & {
|
|
18
17
|
defaultVisitingOrder: 'forward';
|
|
19
18
|
defaultVisitingType: 'exit';
|
|
20
19
|
}> {
|
|
@@ -28,9 +28,9 @@ export interface StateDomainLike<Domain extends AnyAbstractDomain> {
|
|
|
28
28
|
/**
|
|
29
29
|
* A type representing any state abstract domain that stores abstract values for AST nodes.
|
|
30
30
|
*/
|
|
31
|
-
export type AnyStateDomain<Domain extends AnyAbstractDomain> = AnyAbstractDomain & StateDomainLike<Domain>;
|
|
31
|
+
export type AnyStateDomain<Domain extends AnyAbstractDomain = AnyAbstractDomain> = AnyAbstractDomain & StateDomainLike<Domain>;
|
|
32
32
|
/**
|
|
33
33
|
* The type of the value abstract domain of a state abstract domain.
|
|
34
34
|
* @template StateDomain - The state abstract domain to get the value abstract domain type for
|
|
35
35
|
*/
|
|
36
|
-
export type ValueDomain<StateDomain extends AnyStateDomain
|
|
36
|
+
export type ValueDomain<StateDomain extends AnyStateDomain> = StateDomain extends AnyStateDomain<infer Domain> ? Domain : never;
|
package/config.d.ts
CHANGED
|
@@ -142,6 +142,12 @@ export interface FlowrConfig extends MergeableRecord {
|
|
|
142
142
|
* Should we include eval(parse(text="...")) calls in the dataflow graph?
|
|
143
143
|
*/
|
|
144
144
|
readonly evalStrings: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Track user-created environments (`new.env()`, `assign(..., envir=e)`, `get(..., envir=e)`,
|
|
147
|
+
* `local({}, envir=e)`, `e$x <- v`, `attach(e)`) with precise per-variable envState.
|
|
148
|
+
* When disabled all envir-style calls fall through to the conservative global treatment.
|
|
149
|
+
*/
|
|
150
|
+
readonly trackEnvironments: boolean;
|
|
145
151
|
/** These keys are only intended for use within code, allowing to instrument the dataflow analyzer! */
|
|
146
152
|
readonly instrument: {
|
|
147
153
|
/**
|
package/config.js
CHANGED
|
@@ -99,6 +99,7 @@ exports.FlowrConfig = {
|
|
|
99
99
|
solver: {
|
|
100
100
|
variables: VariableResolve.Alias,
|
|
101
101
|
evalStrings: true,
|
|
102
|
+
trackEnvironments: true,
|
|
102
103
|
resolveSource: {
|
|
103
104
|
dropPaths: DropPathsOption.No,
|
|
104
105
|
ignoreCapitalization: true,
|
|
@@ -161,6 +162,7 @@ exports.FlowrConfig = {
|
|
|
161
162
|
solver: joi_1.default.object({
|
|
162
163
|
variables: joi_1.default.string().valid(...Object.values(VariableResolve)).description('How to resolve variables and their values.'),
|
|
163
164
|
evalStrings: joi_1.default.boolean().description('Should we include eval(parse(text="...")) calls in the dataflow graph?'),
|
|
165
|
+
trackEnvironments: joi_1.default.boolean().optional().description('Track user-created environments (new.env, assign/get/local with envir=, dollar-assign, attach). When false, all envir-style calls fall through conservatively.'),
|
|
164
166
|
instrument: joi_1.default.object({
|
|
165
167
|
dataflowExtractors: joi_1.default.any().optional().description('These keys are only intended for use within code, allowing to instrument the dataflow analyzer!')
|
|
166
168
|
}),
|
|
@@ -12,7 +12,7 @@ export interface BasicCfgGuidedVisitorConfiguration<ControlFlow extends ControlF
|
|
|
12
12
|
* Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
|
|
13
13
|
*/
|
|
14
14
|
export declare class BasicCfgGuidedVisitor<ControlFlow extends ControlFlowInformation = ControlFlowInformation, Config extends BasicCfgGuidedVisitorConfiguration<ControlFlow> = BasicCfgGuidedVisitorConfiguration<ControlFlow>> {
|
|
15
|
-
|
|
15
|
+
readonly config: Config;
|
|
16
16
|
protected readonly visited: Map<NodeId, number>;
|
|
17
17
|
constructor(config: Config);
|
|
18
18
|
/**
|
|
@@ -252,6 +252,9 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
252
252
|
return this.onRecallCall({ call });
|
|
253
253
|
case built_in_proc_name_1.BuiltInProcName.PurrrFormula:
|
|
254
254
|
return this.onPurrFormulaCall({ call });
|
|
255
|
+
case built_in_proc_name_1.BuiltInProcName.NewEnv:
|
|
256
|
+
case built_in_proc_name_1.BuiltInProcName.With:
|
|
257
|
+
case built_in_proc_name_1.BuiltInProcName.Attach:
|
|
255
258
|
case built_in_proc_name_1.BuiltInProcName.Default:
|
|
256
259
|
case built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs:
|
|
257
260
|
case built_in_proc_name_1.BuiltInProcName.Function:
|
|
@@ -80,10 +80,16 @@ export declare enum BuiltInProcName {
|
|
|
80
80
|
TableAssignment = "table:assign",
|
|
81
81
|
/** for `try` calls, see {@link processTryCatch} */
|
|
82
82
|
Try = "builtin:try",
|
|
83
|
+
/** for `attach` calls that inject environment contents into the search path, see {@link processAttach} */
|
|
84
|
+
Attach = "builtin:attach",
|
|
85
|
+
/** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
|
|
86
|
+
NewEnv = "builtin:new-env",
|
|
83
87
|
/** for unnamed directly-linked function calls */
|
|
84
88
|
Unnamed = "unnamed",
|
|
85
89
|
/** for vector construction calls, see {@link processVector} */
|
|
86
90
|
Vector = "builtin:vector",
|
|
87
91
|
/** for `while` loops, see {@link processWhileLoop} */
|
|
88
|
-
WhileLoop = "builtin:while-loop"
|
|
92
|
+
WhileLoop = "builtin:while-loop",
|
|
93
|
+
/** for `with` calls that evaluate an expression inside a named environment, see {@link processWithEnv} */
|
|
94
|
+
With = "builtin:with"
|
|
89
95
|
}
|
|
@@ -84,11 +84,17 @@ var BuiltInProcName;
|
|
|
84
84
|
BuiltInProcName["TableAssignment"] = "table:assign";
|
|
85
85
|
/** for `try` calls, see {@link processTryCatch} */
|
|
86
86
|
BuiltInProcName["Try"] = "builtin:try";
|
|
87
|
+
/** for `attach` calls that inject environment contents into the search path, see {@link processAttach} */
|
|
88
|
+
BuiltInProcName["Attach"] = "builtin:attach";
|
|
89
|
+
/** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
|
|
90
|
+
BuiltInProcName["NewEnv"] = "builtin:new-env";
|
|
87
91
|
/** for unnamed directly-linked function calls */
|
|
88
92
|
BuiltInProcName["Unnamed"] = "unnamed";
|
|
89
93
|
/** for vector construction calls, see {@link processVector} */
|
|
90
94
|
BuiltInProcName["Vector"] = "builtin:vector";
|
|
91
95
|
/** for `while` loops, see {@link processWhileLoop} */
|
|
92
96
|
BuiltInProcName["WhileLoop"] = "builtin:while-loop";
|
|
97
|
+
/** for `with` calls that evaluate an expression inside a named environment, see {@link processWithEnv} */
|
|
98
|
+
BuiltInProcName["With"] = "builtin:with";
|
|
93
99
|
})(BuiltInProcName || (exports.BuiltInProcName = BuiltInProcName = {}));
|
|
94
100
|
//# sourceMappingURL=built-in-proc-name.js.map
|
|
@@ -44,6 +44,9 @@ import { processS7NewGeneric } from '../internal/process/functions/call/built-in
|
|
|
44
44
|
import { processS7Dispatch } from '../internal/process/functions/call/built-in/built-in-s-seven-dispatch';
|
|
45
45
|
import { BuiltInProcName } from './built-in-proc-name';
|
|
46
46
|
import { processPurrrFormula } from '../internal/process/functions/call/built-in/built-in-purrr-formula';
|
|
47
|
+
import { processNewEnv } from '../internal/process/functions/call/built-in/built-in-new-env';
|
|
48
|
+
import { processAttach } from '../internal/process/functions/call/built-in/built-in-attach';
|
|
49
|
+
import { processWithEnv } from '../internal/process/functions/call/built-in/built-in-with';
|
|
47
50
|
export type BuiltInIdentifierProcessor = <OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>) => DataflowInformation;
|
|
48
51
|
export type BuiltInIdentifierProcessorWithConfig<Config> = <OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: Config) => DataflowInformation;
|
|
49
52
|
export interface BuiltInIdentifierDefinition extends IdentifierReference {
|
|
@@ -115,6 +118,9 @@ export declare const BuiltInProcessorMapper: {
|
|
|
115
118
|
readonly "builtin:special-bin-op": typeof processSpecialBinOp;
|
|
116
119
|
readonly "builtin:stopifnot": typeof processStopIfNot;
|
|
117
120
|
readonly "builtin:try": typeof processTryCatch;
|
|
121
|
+
readonly "builtin:attach": typeof processAttach;
|
|
122
|
+
readonly "builtin:new-env": typeof processNewEnv;
|
|
123
|
+
readonly "builtin:with": typeof processWithEnv;
|
|
118
124
|
readonly "builtin:vector": typeof processVector;
|
|
119
125
|
readonly "builtin:while-loop": typeof processWhileLoop;
|
|
120
126
|
};
|
|
@@ -42,6 +42,9 @@ const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/
|
|
|
42
42
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
43
43
|
const built_in_proc_name_1 = require("./built-in-proc-name");
|
|
44
44
|
const built_in_purrr_formula_1 = require("../internal/process/functions/call/built-in/built-in-purrr-formula");
|
|
45
|
+
const built_in_new_env_1 = require("../internal/process/functions/call/built-in/built-in-new-env");
|
|
46
|
+
const built_in_attach_1 = require("../internal/process/functions/call/built-in/built-in-attach");
|
|
47
|
+
const built_in_with_1 = require("../internal/process/functions/call/built-in/built-in-with");
|
|
45
48
|
function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument, useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, forceArgs, readAllArguments, cfg, hasUnknownSideEffects, treatAsFnCall }) {
|
|
46
49
|
const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs, origin: useAsProcessor });
|
|
47
50
|
if (returnsNthArgument !== undefined) {
|
|
@@ -142,6 +145,9 @@ exports.BuiltInProcessorMapper = {
|
|
|
142
145
|
[built_in_proc_name_1.BuiltInProcName.SpecialBinOp]: built_in_special_bin_op_1.processSpecialBinOp,
|
|
143
146
|
[built_in_proc_name_1.BuiltInProcName.StopIfNot]: built_in_stop_if_not_1.processStopIfNot,
|
|
144
147
|
[built_in_proc_name_1.BuiltInProcName.Try]: built_in_try_catch_1.processTryCatch,
|
|
148
|
+
[built_in_proc_name_1.BuiltInProcName.Attach]: built_in_attach_1.processAttach,
|
|
149
|
+
[built_in_proc_name_1.BuiltInProcName.NewEnv]: built_in_new_env_1.processNewEnv,
|
|
150
|
+
[built_in_proc_name_1.BuiltInProcName.With]: built_in_with_1.processWithEnv,
|
|
145
151
|
[built_in_proc_name_1.BuiltInProcName.Vector]: built_in_vector_1.processVector,
|
|
146
152
|
[built_in_proc_name_1.BuiltInProcName.WhileLoop]: built_in_while_loop_1.processWhileLoop,
|
|
147
153
|
};
|
|
@@ -23,6 +23,11 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
23
23
|
readonly names: ["NULL", "NA", "NaN", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_"];
|
|
24
24
|
readonly value: null;
|
|
25
25
|
readonly assumePrimitive: true;
|
|
26
|
+
}, {
|
|
27
|
+
readonly type: "constant";
|
|
28
|
+
readonly names: [".GlobalEnv", ".BaseNamespaceEnv", ".BaseEnv"];
|
|
29
|
+
readonly value: null;
|
|
30
|
+
readonly assumePrimitive: true;
|
|
26
31
|
}, {
|
|
27
32
|
readonly type: "constant";
|
|
28
33
|
readonly names: ["TRUE", "T"];
|
|
@@ -424,6 +429,7 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
424
429
|
readonly config: {
|
|
425
430
|
readonly targetVariable: true;
|
|
426
431
|
readonly mayHaveMoreArgs: true;
|
|
432
|
+
readonly environmentArg: "envir";
|
|
427
433
|
};
|
|
428
434
|
readonly assumePrimitive: true;
|
|
429
435
|
}, {
|
|
@@ -948,6 +954,38 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
948
954
|
};
|
|
949
955
|
};
|
|
950
956
|
readonly assumePrimitive: false;
|
|
957
|
+
}, {
|
|
958
|
+
readonly type: "function";
|
|
959
|
+
readonly names: ["with", "within"];
|
|
960
|
+
readonly processor: BuiltInProcName.With;
|
|
961
|
+
readonly config: {};
|
|
962
|
+
readonly assumePrimitive: false;
|
|
963
|
+
}, {
|
|
964
|
+
readonly type: "function";
|
|
965
|
+
readonly names: ["new.env", Identifier];
|
|
966
|
+
readonly processor: BuiltInProcName.NewEnv;
|
|
967
|
+
readonly config: {};
|
|
968
|
+
readonly assumePrimitive: true;
|
|
969
|
+
}, {
|
|
970
|
+
readonly type: "function";
|
|
971
|
+
readonly names: ["globalenv", "baseenv", "emptyenv", "parent.env", "parent.frame", "environmentName", "as.environment", "pos.to.env", "sys.frame", "sys.frames", "topenv"];
|
|
972
|
+
readonly processor: BuiltInProcName.Default;
|
|
973
|
+
readonly config: {};
|
|
974
|
+
readonly assumePrimitive: true;
|
|
975
|
+
}, {
|
|
976
|
+
readonly type: "function";
|
|
977
|
+
readonly names: ["load", "load_image"];
|
|
978
|
+
readonly processor: BuiltInProcName.Default;
|
|
979
|
+
readonly config: {
|
|
980
|
+
readonly hasUnknownSideEffects: true;
|
|
981
|
+
};
|
|
982
|
+
readonly assumePrimitive: false;
|
|
983
|
+
}, {
|
|
984
|
+
readonly type: "function";
|
|
985
|
+
readonly names: ["attach"];
|
|
986
|
+
readonly processor: BuiltInProcName.Attach;
|
|
987
|
+
readonly config: {};
|
|
988
|
+
readonly assumePrimitive: false;
|
|
951
989
|
}, {
|
|
952
990
|
readonly type: "function";
|
|
953
991
|
readonly names: ["for"];
|
|
@@ -1091,6 +1129,20 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
1091
1129
|
readonly config: {};
|
|
1092
1130
|
readonly assumePrimitive: true;
|
|
1093
1131
|
readonly evalHandler: "built-in:c";
|
|
1132
|
+
}, {
|
|
1133
|
+
readonly type: "function";
|
|
1134
|
+
readonly names: [Identifier, Identifier];
|
|
1135
|
+
readonly processor: BuiltInProcName.Default;
|
|
1136
|
+
readonly config: {
|
|
1137
|
+
readonly returnsNthArgument: 0;
|
|
1138
|
+
};
|
|
1139
|
+
}, {
|
|
1140
|
+
readonly type: "function";
|
|
1141
|
+
readonly names: [Identifier];
|
|
1142
|
+
readonly processor: BuiltInProcName.Default;
|
|
1143
|
+
readonly config: {
|
|
1144
|
+
readonly hasUnknownSideEffects: true;
|
|
1145
|
+
};
|
|
1094
1146
|
}, {
|
|
1095
1147
|
readonly type: "function";
|
|
1096
1148
|
readonly names: ["setnames", "setNames", "setkey", "setkeyv", "setindex", "setindexv", "setattr"];
|
|
@@ -1103,7 +1155,7 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
1103
1155
|
};
|
|
1104
1156
|
}, {
|
|
1105
1157
|
readonly type: "function";
|
|
1106
|
-
readonly names: ["sys.on.exit", "par", "tpar", "sink", "requireNamespace", "loadNamespace", "attachNamespace", "asNamespace", Identifier, "
|
|
1158
|
+
readonly names: ["sys.on.exit", "par", "tpar", "sink", "requireNamespace", "loadNamespace", "attachNamespace", "asNamespace", Identifier, "unname", "data", "dir.create", "dir_create", "Sys.chmod", "unlink", "file.remove", "file.rename", "file.copy", "file.link", "file.append", "Sys.junction"];
|
|
1107
1159
|
readonly processor: BuiltInProcName.Default;
|
|
1108
1160
|
readonly config: {
|
|
1109
1161
|
readonly hasUnknownSideEffects: true;
|
|
@@ -98,6 +98,7 @@ function toRegex(n) {
|
|
|
98
98
|
*/
|
|
99
99
|
exports.DefaultBuiltinConfig = [
|
|
100
100
|
{ type: 'constant', names: ['NULL', 'NA', 'NaN', 'NA_integer_', 'NA_real_', 'NA_complex_', 'NA_character_'], value: null, assumePrimitive: true },
|
|
101
|
+
{ type: 'constant', names: ['.GlobalEnv', '.BaseNamespaceEnv', '.BaseEnv'], value: null, assumePrimitive: true },
|
|
101
102
|
{ type: 'constant', names: ['TRUE', 'T'], value: true, assumePrimitive: true },
|
|
102
103
|
{ type: 'constant', names: ['FALSE', 'F'], value: false, assumePrimitive: true },
|
|
103
104
|
{
|
|
@@ -259,7 +260,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
259
260
|
{ type: 'function', names: [identifier_1.Identifier.make('from', 'import'), identifier_1.Identifier.make('library', 'base'), identifier_1.Identifier.make('require', 'base')], processor: built_in_proc_name_1.BuiltInProcName.Library, config: {}, assumePrimitive: false },
|
|
260
261
|
{ type: 'function', names: ['<-', '='], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { canBeReplacement: true }, assumePrimitive: true },
|
|
261
262
|
{ type: 'function', names: [':='], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: {}, assumePrimitive: true },
|
|
262
|
-
{ type: 'function', names: ['assign', 'setValidity'], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { targetVariable: true, mayHaveMoreArgs: true }, assumePrimitive: true },
|
|
263
|
+
{ type: 'function', names: ['assign', 'setValidity'], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { targetVariable: true, mayHaveMoreArgs: true, environmentArg: 'envir' }, assumePrimitive: true },
|
|
263
264
|
{ type: 'function', names: ['setMethod'], processor: built_in_proc_name_1.BuiltInProcName.AssignmentLike, config: { targetVariable: true, canBeReplacement: false, target: { idx: 0, name: 'f' }, source: { idx: 2, name: 'definition' }, modesForFn: ['s4'] }, assumePrimitive: true },
|
|
264
265
|
{ type: 'function', names: ['delayedAssign'], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { quoteSource: true, targetVariable: true }, assumePrimitive: true },
|
|
265
266
|
{ type: 'function', names: ['<<-'], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { superAssignment: true, canBeReplacement: true }, assumePrimitive: true },
|
|
@@ -422,6 +423,13 @@ exports.DefaultBuiltinConfig = [
|
|
|
422
423
|
{ type: 'function', names: [identifier_1.Identifier.make('enquo', 'rlang'), identifier_1.Identifier.make('enquos', 'rlang'), identifier_1.Identifier.make('quo', 'rlang'), identifier_1.Identifier.make('quos', 'rlang'), identifier_1.Identifier.make('sym', 'rlang'), identifier_1.Identifier.make('syms', 'rlang'), identifier_1.Identifier.make('ensym', 'rlang'), identifier_1.Identifier.make('ensyms', 'rlang'), identifier_1.Identifier.make('expr', 'rlang'), identifier_1.Identifier.make('exprs', 'rlang'), identifier_1.Identifier.make('quo_name', 'rlang'), identifier_1.Identifier.make('as_name', 'rlang'), identifier_1.Identifier.make('as_label', 'rlang'), identifier_1.Identifier.make('as_string', 'rlang')], processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, libFn: true }, assumePrimitive: true },
|
|
423
424
|
{ type: 'function', names: [identifier_1.Identifier.make('call2', 'rlang'), identifier_1.Identifier.make('exec', 'rlang'), identifier_1.Identifier.make('invoke', 'purrr'), identifier_1.Identifier.make('invoke_map', 'purrr')], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, hasUnknownSideEffects: true, unquoteFunction: true }, assumePrimitive: false },
|
|
424
425
|
{ type: 'function', names: ['local'], processor: built_in_proc_name_1.BuiltInProcName.Local, config: { args: { env: 'envir', expr: 'expr' } }, assumePrimitive: false },
|
|
426
|
+
{ type: 'function', names: ['with', 'within'], processor: built_in_proc_name_1.BuiltInProcName.With, config: {}, assumePrimitive: false },
|
|
427
|
+
{ type: 'function', names: ['new.env', identifier_1.Identifier.make('new_environment', 'rlang')], processor: built_in_proc_name_1.BuiltInProcName.NewEnv, config: {}, assumePrimitive: true },
|
|
428
|
+
{ type: 'function', names: ['globalenv', 'baseenv', 'emptyenv', 'parent.env', 'parent.frame', 'environmentName', 'as.environment', 'pos.to.env', 'sys.frame', 'sys.frames', 'topenv'],
|
|
429
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default, config: {}, assumePrimitive: true },
|
|
430
|
+
{ type: 'function', names: ['load', 'load_image'], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true }, assumePrimitive: false },
|
|
431
|
+
/* attach injects an environment's contents into the search path; detach reverses it (treated as unknown side effect) */
|
|
432
|
+
{ type: 'function', names: ['attach'], processor: built_in_proc_name_1.BuiltInProcName.Attach, config: {}, assumePrimitive: false },
|
|
425
433
|
{ type: 'function', names: ['for'], processor: built_in_proc_name_1.BuiltInProcName.ForLoop, config: {}, assumePrimitive: true },
|
|
426
434
|
{ type: 'function', names: ['repeat'], processor: built_in_proc_name_1.BuiltInProcName.RepeatLoop, config: {}, assumePrimitive: true },
|
|
427
435
|
{ type: 'function', names: ['while'], processor: built_in_proc_name_1.BuiltInProcName.WhileLoop, config: {}, assumePrimitive: true },
|
|
@@ -438,6 +446,8 @@ exports.DefaultBuiltinConfig = [
|
|
|
438
446
|
{ type: 'function', names: ['Recall'], processor: built_in_proc_name_1.BuiltInProcName.Recall, config: { libFn: true }, assumePrimitive: false },
|
|
439
447
|
{ type: 'function', names: ['sys.function'], processor: built_in_proc_name_1.BuiltInProcName.Recall, config: { libFn: true, unknownOnNonZeroArg: true }, assumePrimitive: false },
|
|
440
448
|
{ type: 'function', names: ['c'], processor: built_in_proc_name_1.BuiltInProcName.Vector, config: {}, assumePrimitive: true, evalHandler: 'built-in:c' },
|
|
449
|
+
{ type: 'function', names: [identifier_1.Identifier.make('cmpfun', 'compiler'), identifier_1.Identifier.make('compile', 'compiler')], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0 } },
|
|
450
|
+
{ type: 'function', names: [identifier_1.Identifier.make('loadcmp', 'compiler')], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true } },
|
|
441
451
|
{
|
|
442
452
|
type: 'function',
|
|
443
453
|
names: ['setnames', 'setNames', 'setkey', 'setkeyv', 'setindex', 'setindexv', 'setattr'],
|
|
@@ -457,7 +467,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
457
467
|
'requireNamespace', 'loadNamespace', 'attachNamespace', 'asNamespace',
|
|
458
468
|
identifier_1.Identifier.make('use', 'base'),
|
|
459
469
|
/* weird env attachments */
|
|
460
|
-
'
|
|
470
|
+
'unname', 'data',
|
|
461
471
|
/* file creation/removal */
|
|
462
472
|
'dir.create', 'dir_create', 'Sys.chmod', 'unlink', 'file.remove', 'file.rename', 'file.copy', 'file.link', 'file.append', 'Sys.junction'
|
|
463
473
|
],
|
|
@@ -516,7 +526,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
516
526
|
config: {
|
|
517
527
|
readIndices: false
|
|
518
528
|
}
|
|
519
|
-
}
|
|
529
|
+
},
|
|
520
530
|
];
|
|
521
531
|
/**
|
|
522
532
|
* Expensive and naive lookup of the default processor for a built-in function name
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BuiltInIdentifierConstant, BuiltInIdentifierDefinition } from './built-in';
|
|
2
2
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { ControlDependency } from '../info';
|
|
4
|
+
import type { REnvironmentInformation } from './environment';
|
|
4
5
|
/** this is just a safe-guard type to prevent mixing up branded identifiers with normal strings */
|
|
5
6
|
export type BrandedIdentifier = string & {
|
|
6
7
|
__brand?: 'identifier';
|
|
@@ -198,7 +199,20 @@ export interface InGraphIdentifierDefinition extends IdentifierReference {
|
|
|
198
199
|
* For example, in `x <- 3; y <- x`, the definition of `y` will have the value `3` in its value set
|
|
199
200
|
*/
|
|
200
201
|
readonly value?: NodeId[];
|
|
202
|
+
/**
|
|
203
|
+
* If this variable holds an R environment (created by `new.env()` etc.),
|
|
204
|
+
* this tracks the current known state of that environment.
|
|
205
|
+
* Use this to resolve variables assigned via `assign(name, val, envir=<this var>)`.
|
|
206
|
+
*/
|
|
207
|
+
readonly envState?: REnvironmentInformation;
|
|
201
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* A narrowed variant of {@link InGraphIdentifierDefinition} that is guaranteed to have a non-undefined `name`.
|
|
211
|
+
* Prefer this over the inline intersection `InGraphIdentifierDefinition & { name: Identifier }`.
|
|
212
|
+
*/
|
|
213
|
+
export type NamedInGraphIdentifierDefinition = InGraphIdentifierDefinition & {
|
|
214
|
+
readonly name: Identifier;
|
|
215
|
+
};
|
|
202
216
|
/**
|
|
203
217
|
* Stores the definition of an identifier within an {@link IEnvironment}.
|
|
204
218
|
*
|
|
@@ -110,6 +110,12 @@ export interface DataflowGraphVertexFunctionCall extends DataflowGraphVertexBase
|
|
|
110
110
|
environment: REnvironmentInformation | undefined;
|
|
111
111
|
/** More detailed Information on this function call */
|
|
112
112
|
origin: FunctionOriginInformation[] | 'unnamed';
|
|
113
|
+
/**
|
|
114
|
+
* For `new.env()`-family calls: the resolved parent {@link REnvironmentInformation} that the
|
|
115
|
+
* freshly-created environment should inherit from. Set by `processNewEnv` when the `parent`
|
|
116
|
+
* argument can be statically resolved (tracked env variable or `emptyenv()`-family call).
|
|
117
|
+
*/
|
|
118
|
+
newEnvParent?: REnvironmentInformation;
|
|
113
119
|
}
|
|
114
120
|
/** Describes the processor responsible for a function call */
|
|
115
121
|
export type FunctionOriginInformation = BuiltInProcName;
|
|
@@ -12,6 +12,8 @@ const built_in_assignment_1 = require("./built-in-assignment");
|
|
|
12
12
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
13
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
14
14
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
15
|
+
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
16
|
+
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
15
17
|
function tableAssignmentProcessor(name, args, rootId, data, outInfo) {
|
|
16
18
|
outInfo.definitionRootNodes.push(rootId);
|
|
17
19
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.TableAssignment }).information;
|
|
@@ -57,6 +59,20 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
57
59
|
}
|
|
58
60
|
/* we include the read edges to the constant arguments as well so that they are included if necessary */
|
|
59
61
|
}
|
|
62
|
+
/* for $ access on a tracked env variable, add Reads edges to the field definition in envState */
|
|
63
|
+
if (config.treatIndicesAsString && identifier_1.Identifier.getName(name.content) === '$'
|
|
64
|
+
&& head !== r_function_call_1.EmptyArgument && head.value?.type === type_1.RType.Symbol
|
|
65
|
+
&& args.length >= 2 && args[1] !== r_function_call_1.EmptyArgument) {
|
|
66
|
+
const envirResolution = (0, built_in_envir_utils_1.resolveSymbolToEnvir)(head.value.content, head.value.info.id, data);
|
|
67
|
+
if (envirResolution) {
|
|
68
|
+
const fieldNode = (0, unpack_argument_1.unpackArg)(args[1]);
|
|
69
|
+
const fieldName = fieldNode?.type === type_1.RType.String ? fieldNode.content.str : fieldNode?.lexeme;
|
|
70
|
+
const fieldDefs = fieldName ? envirResolution.envDef.envState.current.memory.get(fieldName) : undefined;
|
|
71
|
+
for (const fd of fieldDefs ?? []) {
|
|
72
|
+
info.graph.addEdge(name.info.id, fd.nodeId, edge_1.EdgeType.Reads);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
60
76
|
return {
|
|
61
77
|
...info,
|
|
62
78
|
/*
|
|
@@ -21,6 +21,12 @@ export interface AssignmentConfiguration extends ForceArguments {
|
|
|
21
21
|
readonly targetVariable?: boolean;
|
|
22
22
|
readonly mayHaveMoreArgs?: boolean;
|
|
23
23
|
readonly modesForFn?: DataflowGraphVertexFunctionDefinition['mode'];
|
|
24
|
+
/**
|
|
25
|
+
* The name of the argument that selects the target environment (e.g. `'envir'` for `assign`).
|
|
26
|
+
* When present and the argument resolves to a variable with a tracked {@link InGraphIdentifierDefinition#envState},
|
|
27
|
+
* the assignment is routed into that environment instead of the current scope.
|
|
28
|
+
*/
|
|
29
|
+
readonly environmentArg?: string;
|
|
24
30
|
}
|
|
25
31
|
export interface ExtendedAssignmentConfiguration extends AssignmentConfiguration {
|
|
26
32
|
readonly source: {
|