@eagleoutice/flowr 2.17.1 → 2.17.2
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/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/dataflow/environments/ambient-state-name.d.ts +4 -0
- package/dataflow/environments/ambient-state-name.js +4 -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 +2 -0
- package/dataflow/environments/built-in-props.js +3 -1
- package/dataflow/environments/built-in.d.ts +16 -6
- package/dataflow/environments/built-in.js +45 -4
- package/dataflow/environments/default-builtin-config.d.ts +846 -21
- package/dataflow/environments/default-builtin-config.js +120 -26
- package/dataflow/environments/environment.d.ts +19 -2
- package/dataflow/environments/environment.js +90 -19
- package/dataflow/environments/identifier.d.ts +18 -0
- package/dataflow/environments/query-fn-props.js +4 -3
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/eval/resolve/node-value.d.ts +1 -1
- package/dataflow/eval/resolve/node-value.js +2 -2
- package/dataflow/eval/resolve/resolve-argument.js +1 -1
- package/dataflow/extractor.js +20 -4
- package/dataflow/graph/df-helper.d.ts +34 -1
- package/dataflow/graph/df-helper.js +60 -0
- package/dataflow/info.d.ts +2 -0
- package/dataflow/info.js +4 -0
- package/dataflow/internal/linker.js +21 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +144 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +8 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +43 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +67 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +134 -88
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +87 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +23 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +18 -15
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +8 -7
- package/documentation/wiki-dataflow-graph.js +20 -1
- package/linter/rules/undefined-symbol.js +2 -2
- package/package.json +1 -1
- package/project/attached-packages.d.ts +11 -6
- package/project/attached-packages.js +37 -9
- package/queries/catalog/signature-query/signature-query-executor.js +15 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -2
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/model.js +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +12 -1
- package/reconstruct/reconstruct.js +2 -5
- package/search/search-executor/search-enrichers.js +17 -2
- package/search/search-executor/search-generators.js +6 -2
- package/slicing/static/slice-call.d.ts +16 -0
- package/slicing/static/slice-call.js +42 -0
- package/slicing/static/static-slicer.js +6 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
|
@@ -249,6 +249,8 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
249
249
|
case built_in_proc_name_1.BuiltInProcName.StackEnv:
|
|
250
250
|
case built_in_proc_name_1.BuiltInProcName.With:
|
|
251
251
|
case built_in_proc_name_1.BuiltInProcName.Attach:
|
|
252
|
+
case built_in_proc_name_1.BuiltInProcName.Detach:
|
|
253
|
+
case built_in_proc_name_1.BuiltInProcName.Prefer:
|
|
252
254
|
case built_in_proc_name_1.BuiltInProcName.EnvContents:
|
|
253
255
|
case built_in_proc_name_1.BuiltInProcName.ListToEnv:
|
|
254
256
|
case built_in_proc_name_1.BuiltInProcName.Default:
|
|
@@ -42,6 +42,10 @@ export declare const AmbientStateName: {
|
|
|
42
42
|
readonly workingDirectory: "#wd";
|
|
43
43
|
/** whether console output is diverted into a file or connection, as `sink(file)` does and `sink()` undoes */
|
|
44
44
|
readonly sink: "#sink";
|
|
45
|
+
/** the project root `here::here()` builds its paths from, found from the working directory unless `here::i_am` names it */
|
|
46
|
+
readonly projectRoot: "#project-root";
|
|
47
|
+
/** where packages are installed and loaded from, which `.libPaths(new)` changes and every package load reads */
|
|
48
|
+
readonly libPaths: "#lib-paths";
|
|
45
49
|
/** the file creation mask `Sys.umask` sets */
|
|
46
50
|
readonly umask: "#umask";
|
|
47
51
|
/** the state of the random number generator, which `set.seed` sets and every draw advances */
|
|
@@ -57,6 +57,10 @@ exports.AmbientStateName = {
|
|
|
57
57
|
workingDirectory: '#wd',
|
|
58
58
|
/** whether console output is diverted into a file or connection, as `sink(file)` does and `sink()` undoes */
|
|
59
59
|
sink: '#sink',
|
|
60
|
+
/** the project root `here::here()` builds its paths from, found from the working directory unless `here::i_am` names it */
|
|
61
|
+
projectRoot: '#project-root',
|
|
62
|
+
/** where packages are installed and loaded from, which `.libPaths(new)` changes and every package load reads */
|
|
63
|
+
libPaths: '#lib-paths',
|
|
60
64
|
/** the file creation mask `Sys.umask` sets */
|
|
61
65
|
umask: '#umask',
|
|
62
66
|
/** the state of the random number generator, which `set.seed` sets and every draw advances */
|
|
@@ -98,6 +98,10 @@ export declare enum BuiltInProcName {
|
|
|
98
98
|
Try = "builtin:try",
|
|
99
99
|
/** for `attach` calls that inject environment contents into the search path, see {@link processAttach} */
|
|
100
100
|
Attach = "builtin:attach",
|
|
101
|
+
/** for `detach` and `unloadNamespace`, see {@link processDetach} */
|
|
102
|
+
Detach = "builtin:detach",
|
|
103
|
+
/** for `conflicted::conflict_prefer` and `conflicts_prefer`, see {@link processPrefer} */
|
|
104
|
+
Prefer = "builtin:prefer",
|
|
101
105
|
EnvContents = "builtin:env-contents",
|
|
102
106
|
ListToEnv = "builtin:list2env",
|
|
103
107
|
/** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
|
|
@@ -102,6 +102,10 @@ var BuiltInProcName;
|
|
|
102
102
|
BuiltInProcName["Try"] = "builtin:try";
|
|
103
103
|
/** for `attach` calls that inject environment contents into the search path, see {@link processAttach} */
|
|
104
104
|
BuiltInProcName["Attach"] = "builtin:attach";
|
|
105
|
+
/** for `detach` and `unloadNamespace`, see {@link processDetach} */
|
|
106
|
+
BuiltInProcName["Detach"] = "builtin:detach";
|
|
107
|
+
/** for `conflicted::conflict_prefer` and `conflicts_prefer`, see {@link processPrefer} */
|
|
108
|
+
BuiltInProcName["Prefer"] = "builtin:prefer";
|
|
105
109
|
BuiltInProcName["EnvContents"] = "builtin:env-contents";
|
|
106
110
|
BuiltInProcName["ListToEnv"] = "builtin:list2env";
|
|
107
111
|
/** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
|
|
@@ -176,6 +176,8 @@ export declare enum SemanticCallTag {
|
|
|
176
176
|
AttachesPackage = "attaches-package",
|
|
177
177
|
/** answers whether a package is available, like `require`, `requireNamespace`, or `find.package` */
|
|
178
178
|
ChecksPackage = "checks-package",
|
|
179
|
+
/** takes a package off the search path, like `detach` or `unloadNamespace` */
|
|
180
|
+
DetachesPackage = "detaches-package",
|
|
179
181
|
/** registers a class, generic, method, or global name without computing anything else, like `setClass` or `utils::globalVariables` */
|
|
180
182
|
Declares = "declares",
|
|
181
183
|
/** reads which environment it runs in, like `environment()` or `parent.frame()`, so moving the call into another frame changes its result */
|
|
@@ -184,6 +184,8 @@ var SemanticCallTag;
|
|
|
184
184
|
SemanticCallTag["AttachesPackage"] = "attaches-package";
|
|
185
185
|
/** answers whether a package is available, like `require`, `requireNamespace`, or `find.package` */
|
|
186
186
|
SemanticCallTag["ChecksPackage"] = "checks-package";
|
|
187
|
+
/** takes a package off the search path, like `detach` or `unloadNamespace` */
|
|
188
|
+
SemanticCallTag["DetachesPackage"] = "detaches-package";
|
|
187
189
|
/** registers a class, generic, method, or global name without computing anything else, like `setClass` or `utils::globalVariables` */
|
|
188
190
|
SemanticCallTag["Declares"] = "declares";
|
|
189
191
|
/** reads which environment it runs in, like `environment()` or `parent.frame()`, so moving the call into another frame changes its result */
|
|
@@ -243,7 +245,7 @@ exports.PropagatedProps = getPropMask([
|
|
|
243
245
|
SemanticCallTag.Process, SemanticCallTag.User, SemanticCallTag.CommandLine, SemanticCallTag.Graphics,
|
|
244
246
|
SemanticCallTag.Database, SemanticCallTag.Reads, SemanticCallTag.Writes, SemanticCallTag.Prints,
|
|
245
247
|
SemanticCallTag.Eval, SemanticCallTag.Html, SemanticCallTag.JavaScript, SemanticCallTag.LoadsPackage, SemanticCallTag.AttachesPackage,
|
|
246
|
-
SemanticCallTag.ChecksPackage
|
|
248
|
+
SemanticCallTag.ChecksPackage, SemanticCallTag.DetachesPackage
|
|
247
249
|
]);
|
|
248
250
|
/** Checks whether a {@link PropSelector} is a bitfield of {@link CallProp}s */
|
|
249
251
|
function isCallProp(selector) {
|
|
@@ -20,7 +20,7 @@ import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x
|
|
|
20
20
|
import type { PotentiallyEmptyRArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
21
21
|
import { RSymbol } from '../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
22
22
|
import { type BuiltIn, NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
23
|
-
import { processLibrary } from '../internal/process/functions/call/built-in/built-in-library';
|
|
23
|
+
import { processLibrary, processPrefer } from '../internal/process/functions/call/built-in/built-in-library';
|
|
24
24
|
import { processSourceCall } from '../internal/process/functions/call/built-in/built-in-source';
|
|
25
25
|
import { processApply } from '../internal/process/functions/call/built-in/built-in-apply';
|
|
26
26
|
import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
@@ -52,7 +52,7 @@ import { processClassRelation } from '../internal/process/functions/call/built-i
|
|
|
52
52
|
import { processS4Use } from '../internal/process/functions/call/built-in/built-in-s-four';
|
|
53
53
|
import { processStackEnv } from '../internal/process/functions/call/built-in/built-in-stack-env';
|
|
54
54
|
import { processEnvContents, processListToEnv } from '../internal/process/functions/call/built-in/built-in-env-contents';
|
|
55
|
-
import { processAttach } from '../internal/process/functions/call/built-in/built-in-attach';
|
|
55
|
+
import { processAttach, processDetach } from '../internal/process/functions/call/built-in/built-in-attach';
|
|
56
56
|
import { processWithEnv } from '../internal/process/functions/call/built-in/built-in-with';
|
|
57
57
|
import { processNamespaceAccess } from '../internal/process/functions/call/built-in/built-in-namespace-access';
|
|
58
58
|
import { processLoadCall } from '../internal/process/functions/call/built-in/built-in-load';
|
|
@@ -77,7 +77,12 @@ export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierRefere
|
|
|
77
77
|
definedAt: BuiltIn;
|
|
78
78
|
value: T;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
/** The global state a call reads or writes, applied for every processor (see {@link PlacesAmbientItself}). */
|
|
81
|
+
export interface AmbientConfig {
|
|
82
|
+
/** how the call reads or writes global state like the graphics parameters, the options, or files, see {@link AmbientStateAccess} */
|
|
83
|
+
readonly ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
84
|
+
}
|
|
85
|
+
export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo, AmbientConfig {
|
|
81
86
|
readonly cfg?: ExitPointType;
|
|
82
87
|
/** see {@link ProcessKnownFunctionCallInput#alternativeArgsFrom} */
|
|
83
88
|
readonly alternativeArgsFrom?: number;
|
|
@@ -90,8 +95,6 @@ export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo {
|
|
|
90
95
|
readonly hasUnknownSideEffects?: boolean | LinkTo<RegExp | string>;
|
|
91
96
|
/** without arguments, the result is the frame the call runs in, like `environment()`, so within a function it reads every binding of the frame */
|
|
92
97
|
readonly readsFrame?: boolean;
|
|
93
|
-
/** how the call reads or writes global state like the graphics parameters or the options, see {@link AmbientStateAccess} */
|
|
94
|
-
readonly ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
|
|
95
98
|
/** the call changes that state for a scope only, see {@link AmbientScope} */
|
|
96
99
|
readonly scope?: AmbientScope;
|
|
97
100
|
/** record mapping the actual function name called to the arguments that should be treated as function calls */
|
|
@@ -103,6 +106,11 @@ export interface DefaultBuiltInProcessorConfiguration extends BuiltInFnInfo {
|
|
|
103
106
|
* data instead of variables, while everything else in them is evaluated in the caller's frame as usual.
|
|
104
107
|
*/
|
|
105
108
|
readonly markArgsAsMasked?: NseArguments | readonly number[];
|
|
109
|
+
/**
|
|
110
|
+
* The formals whose arguments name variables the call reads by their string value, like `save("x", list = v)`:
|
|
111
|
+
* a string literal anywhere, any other value except in `...`, where a symbol is the variable itself.
|
|
112
|
+
*/
|
|
113
|
+
readonly namesIn?: readonly string[];
|
|
106
114
|
/**
|
|
107
115
|
* Name that should be used for the origin (useful when needing to differentiate between
|
|
108
116
|
* functions like 'return' that use the default builtin processor)
|
|
@@ -116,7 +124,7 @@ export interface BuiltInEvalHandlerArgs extends ResolveInfo {
|
|
|
116
124
|
}
|
|
117
125
|
export type BuiltInEvalHandler = (args: BuiltInEvalHandlerArgs) => Value;
|
|
118
126
|
declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, readAllArguments, cfg, alternativeArgsFrom, hasUnknownSideEffects, ambient, scope, treatAsFnCall, markArgsAsNSE: nse, markArgsAsMasked: masked, keepArgumentOut, sig, readsFrame }: DefaultBuiltInProcessorConfiguration): DataflowInformation;
|
|
119
|
-
declare function defaultBuiltInProcessorReadallArgs<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, markArgsAsNSE: nse, markArgsAsMasked: masked, sig,
|
|
127
|
+
declare function defaultBuiltInProcessorReadallArgs<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, { useAsProcessor, markArgsAsNSE: nse, markArgsAsMasked: masked, sig, namesIn }: Pick<DefaultBuiltInProcessorConfiguration, 'useAsProcessor' | 'markArgsAsNSE' | 'markArgsAsMasked' | 'sig' | 'ambient' | 'namesIn'>): DataflowInformation;
|
|
120
128
|
export declare const BuiltInProcessorMapper: {
|
|
121
129
|
readonly "builtin:acc": typeof processAccess;
|
|
122
130
|
readonly "builtin:app": typeof processApply;
|
|
@@ -156,6 +164,8 @@ export declare const BuiltInProcessorMapper: {
|
|
|
156
164
|
readonly "builtin:env-contents": typeof processEnvContents;
|
|
157
165
|
readonly "builtin:list2env": typeof processListToEnv;
|
|
158
166
|
readonly "builtin:attach": typeof processAttach;
|
|
167
|
+
readonly "builtin:detach": typeof processDetach;
|
|
168
|
+
readonly "builtin:prefer": typeof processPrefer;
|
|
159
169
|
readonly "builtin:nenv": typeof processNewEnv;
|
|
160
170
|
readonly "builtin:class-gen": typeof processClassGenerator;
|
|
161
171
|
readonly "builtin:class-relation": typeof processClassRelation;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuiltIns = exports.BuiltInEvalHandlerMapper = exports.BuiltInProcessorMapper = void 0;
|
|
4
|
+
const ambient_state_name_1 = require("./ambient-state-name");
|
|
4
5
|
const function_semantics_1 = require("../fn/function-semantics");
|
|
5
6
|
const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
|
|
6
7
|
const built_in_access_1 = require("../internal/process/functions/call/built-in/built-in-access");
|
|
@@ -47,6 +48,10 @@ const built_in_recall_1 = require("../internal/process/functions/call/built-in/b
|
|
|
47
48
|
const built_in_s_seven_new_generic_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-new-generic");
|
|
48
49
|
const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
|
|
49
50
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
51
|
+
const common_1 = require("../internal/process/functions/call/common");
|
|
52
|
+
const node_value_1 = require("../eval/resolve/node-value");
|
|
53
|
+
const resolve_helper_1 = require("./resolve-helper");
|
|
54
|
+
const linker_1 = require("../internal/linker");
|
|
50
55
|
const built_in_proc_name_1 = require("./built-in-proc-name");
|
|
51
56
|
const built_in_purrr_formula_1 = require("../internal/process/functions/call/built-in/built-in-purrr-formula");
|
|
52
57
|
const built_in_new_env_1 = require("../internal/process/functions/call/built-in/built-in-new-env");
|
|
@@ -206,7 +211,7 @@ function dropQuotedReferences(res, processedArguments, nsePositions, lastEnv) {
|
|
|
206
211
|
res.environment = lastEnv;
|
|
207
212
|
}
|
|
208
213
|
}
|
|
209
|
-
function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, markArgsAsNSE: nse, markArgsAsMasked: masked, sig,
|
|
214
|
+
function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsProcessor = built_in_proc_name_1.BuiltInProcName.Default, markArgsAsNSE: nse, markArgsAsMasked: masked, sig, namesIn }) {
|
|
210
215
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
211
216
|
name, args, rootId, data, sig, origin: useAsProcessor, nonFunction: dataArgumentSymbols(args, sig), keepArgumentGraphs: nse !== undefined || masked !== undefined
|
|
212
217
|
});
|
|
@@ -214,8 +219,29 @@ function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsPro
|
|
|
214
219
|
const first = firstParameterArgument(args, sig === undefined ? undefined : function_semantics_1.FunctionSemantics.call.signature.layout(sig));
|
|
215
220
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, nse, { first });
|
|
216
221
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, masked, { kind: known_call_handling_1.NseKind.DataMasked, first });
|
|
217
|
-
|
|
222
|
+
if (namesIn !== undefined && sig !== undefined) {
|
|
223
|
+
readNamedVariables(information, args, rootId, data, sig, namesIn);
|
|
224
|
+
}
|
|
225
|
+
return information;
|
|
218
226
|
}
|
|
227
|
+
/** Links the call to the variables its {@link DefaultBuiltInProcessorConfiguration#namesIn} arguments name, an unknown name being an unknown side effect. */
|
|
228
|
+
function readNamedVariables(information, args, rootId, data, sig, namesIn) {
|
|
229
|
+
const bound = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), Object.fromEntries(sig.map(([n]) => [n, n])));
|
|
230
|
+
for (const formal of namesIn) {
|
|
231
|
+
for (const id of bound.get(formal) ?? []) {
|
|
232
|
+
const value = r_argument_1.RArgument.getValue(args, id);
|
|
233
|
+
const names = r_string_1.RString.is(value) ? [value.content.str] : formal === '...' || value === undefined ? [] : node_value_1.NodeValue.stringsOf(value.info.id, data);
|
|
234
|
+
if (names === undefined) {
|
|
235
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
236
|
+
}
|
|
237
|
+
for (const name of names ?? []) {
|
|
238
|
+
(0, linker_1.linkFieldReads)(information.graph, rootId, resolve_helper_1.Resolve.byName(name, data.environment), false);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** The processors that apply the configured {@link BuiltInFnInfo#ambient} access themselves, where it belongs among their steps; the others have it applied after them. */
|
|
244
|
+
const PlacesAmbientItself = new Set([built_in_proc_name_1.BuiltInProcName.Default, built_in_proc_name_1.BuiltInProcName.Source]);
|
|
219
245
|
/**
|
|
220
246
|
* A call that reads or writes the files its arguments name accesses the {@link AmbientStateName.files|files on disk} as well.
|
|
221
247
|
* Closing a device writes the file its opening already wrote, and only a device's file name may number its pages (`plot%03d.png`).
|
|
@@ -240,6 +266,15 @@ function withFileAccess(config) {
|
|
|
240
266
|
type, numbered, sig: glob || sig === undefined ? undefined : split ? built_in_props_1.FnSig.resources(sig, type === "write-files" /* AmbientStateAccessType.WriteFiles */) : sig
|
|
241
267
|
}))] };
|
|
242
268
|
}
|
|
269
|
+
/** A call starting a process hands it every environment variable, a call loading a package looks for it in the library paths. */
|
|
270
|
+
function withImplicitReads(config) {
|
|
271
|
+
const { tags, ambient } = (config ?? {});
|
|
272
|
+
const reads = [
|
|
273
|
+
...tags?.includes(built_in_props_1.SemanticCallTag.Process) ? [ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.Env)] : [],
|
|
274
|
+
...tags?.includes(built_in_props_1.SemanticCallTag.LoadsPackage) ? [ambient_state_name_1.AmbientStateName.libPaths] : []
|
|
275
|
+
];
|
|
276
|
+
return reads.length === 0 ? config : { ...config, ambient: [...[ambient ?? []].flat(), ...reads.map(state => ({ type: "read-state" /* AmbientStateAccessType.ReadState */, state }))] };
|
|
277
|
+
}
|
|
243
278
|
exports.BuiltInProcessorMapper = {
|
|
244
279
|
[built_in_proc_name_1.BuiltInProcName.Access]: built_in_access_1.processAccess,
|
|
245
280
|
[built_in_proc_name_1.BuiltInProcName.Apply]: built_in_apply_1.processApply,
|
|
@@ -279,6 +314,8 @@ exports.BuiltInProcessorMapper = {
|
|
|
279
314
|
[built_in_proc_name_1.BuiltInProcName.EnvContents]: built_in_env_contents_1.processEnvContents,
|
|
280
315
|
[built_in_proc_name_1.BuiltInProcName.ListToEnv]: built_in_env_contents_1.processListToEnv,
|
|
281
316
|
[built_in_proc_name_1.BuiltInProcName.Attach]: built_in_attach_1.processAttach,
|
|
317
|
+
[built_in_proc_name_1.BuiltInProcName.Detach]: built_in_attach_1.processDetach,
|
|
318
|
+
[built_in_proc_name_1.BuiltInProcName.Prefer]: built_in_library_1.processPrefer,
|
|
282
319
|
[built_in_proc_name_1.BuiltInProcName.NewEnv]: built_in_new_env_1.processNewEnv,
|
|
283
320
|
[built_in_proc_name_1.BuiltInProcName.ClassGenerator]: built_in_class_generator_1.processClassGenerator,
|
|
284
321
|
[built_in_proc_name_1.BuiltInProcName.ClassRelation]: built_in_class_relation_1.processClassRelation,
|
|
@@ -338,7 +375,11 @@ class BuiltIns {
|
|
|
338
375
|
(0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(exports.BuiltInProcessorMapper))}!`);
|
|
339
376
|
const mappedEval = evalHandler === undefined ? undefined : exports.BuiltInEvalHandlerMapper[evalHandler];
|
|
340
377
|
(0, assert_1.guard)(evalHandler === undefined || mappedEval !== undefined, () => `Eval handler ${evalHandler} is unknown! Please pass a valid one of ${JSON.stringify(Object.keys(exports.BuiltInEvalHandlerMapper))}!`);
|
|
341
|
-
config = withFileAccess(config);
|
|
378
|
+
config = withImplicitReads(withFileAccess(config));
|
|
379
|
+
const ambient = PlacesAmbientItself.has(processor) ? undefined : config?.ambient;
|
|
380
|
+
const process = ambient === undefined
|
|
381
|
+
? (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config)
|
|
382
|
+
: (name, args, rootId, data) => (0, built_in_ambient_state_1.applyAmbientStateAccess)(mappedProcessor(name, args, rootId, data, config), args, rootId, data, ambient);
|
|
342
383
|
for (const name of names) {
|
|
343
384
|
const n = identifier_1.Identifier.getName(name);
|
|
344
385
|
const id = node_id_1.NodeId.toBuiltIn(n);
|
|
@@ -346,7 +387,7 @@ class BuiltIns {
|
|
|
346
387
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
347
388
|
definedAt: id,
|
|
348
389
|
cds: undefined,
|
|
349
|
-
processor:
|
|
390
|
+
processor: process,
|
|
350
391
|
config,
|
|
351
392
|
evalHandler: mappedEval,
|
|
352
393
|
processorName: processor,
|