@eagleoutice/flowr 2.10.4 → 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.
Files changed (115) hide show
  1. package/README.md +31 -14
  2. package/abstract-interpretation/absint-visitor.d.ts +17 -22
  3. package/abstract-interpretation/absint-visitor.js +47 -48
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +0 -3
  5. package/abstract-interpretation/data-frame/shape-inference.d.ts +2 -1
  6. package/abstract-interpretation/data-frame/shape-inference.js +5 -4
  7. package/abstract-interpretation/domains/abstract-domain.d.ts +17 -16
  8. package/abstract-interpretation/domains/abstract-domain.js +25 -27
  9. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  10. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +32 -0
  11. package/abstract-interpretation/domains/multi-value-state-domain.js +60 -0
  12. package/abstract-interpretation/domains/partial-product-domain.d.ts +43 -0
  13. package/abstract-interpretation/domains/partial-product-domain.js +163 -0
  14. package/abstract-interpretation/domains/product-domain.d.ts +2 -29
  15. package/abstract-interpretation/domains/product-domain.js +6 -123
  16. package/abstract-interpretation/domains/set-range-domain.js +3 -3
  17. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  18. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  19. package/abstract-interpretation/domains/state-abstract-domain.d.ts +13 -28
  20. package/abstract-interpretation/domains/state-abstract-domain.js +16 -38
  21. package/abstract-interpretation/domains/state-domain-like.d.ts +36 -0
  22. package/abstract-interpretation/domains/state-domain-like.js +3 -0
  23. package/cli/flowr.js +11 -1
  24. package/config.d.ts +13 -0
  25. package/config.js +24 -3
  26. package/control-flow/basic-cfg-guided-visitor.d.ts +1 -1
  27. package/control-flow/semantic-cfg-guided-visitor.d.ts +4 -0
  28. package/control-flow/semantic-cfg-guided-visitor.js +23 -32
  29. package/dataflow/environments/built-in-proc-name.d.ts +7 -1
  30. package/dataflow/environments/built-in-proc-name.js +6 -0
  31. package/dataflow/environments/built-in.d.ts +6 -0
  32. package/dataflow/environments/built-in.js +6 -0
  33. package/dataflow/environments/default-builtin-config.d.ts +63 -1
  34. package/dataflow/environments/default-builtin-config.js +15 -4
  35. package/dataflow/environments/identifier.d.ts +14 -0
  36. package/dataflow/graph/vertex.d.ts +6 -0
  37. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -0
  38. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +6 -0
  39. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +99 -2
  40. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +13 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +48 -0
  42. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +75 -0
  43. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +196 -0
  44. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +2 -0
  45. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +38 -21
  46. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +5 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +27 -13
  48. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +14 -4
  49. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +27 -0
  50. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +97 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +23 -0
  52. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +90 -0
  53. package/documentation/doc-readme.js +13 -2
  54. package/documentation/doc-util/doc-types.d.ts +11 -2
  55. package/documentation/doc-util/doc-types.js +31 -9
  56. package/documentation/wiki-absint.d.ts +17 -2
  57. package/documentation/wiki-absint.js +83 -24
  58. package/documentation/wiki-analyzer.js +3 -4
  59. package/documentation/wiki-interface.js +22 -16
  60. package/documentation/wiki-mk/doc-context.d.ts +14 -1
  61. package/documentation/wiki-mk/doc-context.js +6 -0
  62. package/documentation/wiki-normalized-ast.d.ts +0 -9
  63. package/documentation/wiki-normalized-ast.js +9 -60
  64. package/linter/linter-rules.d.ts +4 -3
  65. package/linter/rules/problematic-inputs.d.ts +13 -7
  66. package/linter/rules/problematic-inputs.js +109 -60
  67. package/package.json +3 -3
  68. package/project/flowr-analyzer-builder.d.ts +6 -3
  69. package/project/flowr-analyzer-builder.js +12 -5
  70. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +4 -3
  71. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +17 -4
  72. package/project/plugins/flowr-analyzer-plugin.d.ts +1 -1
  73. package/project/plugins/flowr-analyzer-plugin.js +1 -1
  74. package/queries/catalog/dependencies-query/function-info/read-functions.js +2 -0
  75. package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
  76. package/queries/catalog/input-sources-query/input-source-functions.d.ts +7 -0
  77. package/queries/catalog/input-sources-query/input-source-functions.js +56 -0
  78. package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +1 -1
  79. package/queries/catalog/input-sources-query/input-sources-query-executor.js +19 -53
  80. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -1
  81. package/queries/catalog/input-sources-query/input-sources-query-format.js +28 -11
  82. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +21 -42
  83. package/queries/catalog/input-sources-query/simple-input-classifier.js +168 -104
  84. package/r-bridge/data/data.d.ts +28 -2
  85. package/r-bridge/data/data.js +34 -2
  86. package/r-bridge/lang-4.x/ast/model/model.d.ts +5 -6
  87. package/r-bridge/lang-4.x/ast/model/model.js +0 -1
  88. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +6 -6
  89. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +6 -6
  90. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +6 -6
  91. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +6 -6
  92. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +6 -6
  93. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +6 -6
  94. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +6 -6
  95. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -6
  96. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +6 -6
  97. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +6 -6
  98. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +6 -6
  99. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +6 -6
  100. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +6 -6
  101. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -6
  102. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +6 -6
  103. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +6 -6
  104. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +6 -6
  105. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +6 -6
  106. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +6 -6
  107. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +6 -6
  108. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +6 -6
  109. package/util/record.d.ts +18 -3
  110. package/util/record.js +22 -1
  111. package/util/version.js +1 -1
  112. package/abstract-interpretation/normalized-ast-fold.d.ts +0 -119
  113. package/abstract-interpretation/normalized-ast-fold.js +0 -181
  114. package/project/plugins/flowr-analyzer-plugin-defaults.d.ts +0 -5
  115. package/project/plugins/flowr-analyzer-plugin-defaults.js +0 -37
@@ -4,23 +4,32 @@ exports.processGet = processGet;
4
4
  const known_call_handling_1 = require("../known-call-handling");
5
5
  const unpack_argument_1 = require("../argument/unpack-argument");
6
6
  const make_argument_1 = require("../argument/make-argument");
7
+ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
8
  const logger_1 = require("../../../../../logger");
8
9
  const retriever_1 = require("../../../../../../r-bridge/retriever");
9
10
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
10
11
  const edge_1 = require("../../../../../graph/edge");
11
12
  const identifier_1 = require("../../../../../environments/identifier");
12
13
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
14
+ const built_in_envir_utils_1 = require("./built-in-envir-utils");
13
15
  /**
14
16
  * Processes a built-in 'get' function call.
17
+ *
18
+ * When an `envir` argument is present and resolves to a variable with a tracked environment
19
+ * state (set up by `new.env()` + `assign(..., envir=...)`), the lookup is performed inside
20
+ * that environment so that the correct definition is found and the returned {@link DataflowInformation}
21
+ * contains the right read edges.
15
22
  */
16
23
  function processGet(name, args, rootId, data) {
17
- if (args.length !== 1) {
18
- logger_1.dataflowLogger.warn(`symbol access with ${identifier_1.Identifier.toString(name.content)} has not 1 argument, skipping`);
19
- return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
20
- }
21
- const retrieve = (0, unpack_argument_1.unpackNonameArg)(args[0]);
24
+ /* use the custom environment for resolution when envir points to a tracked env */
25
+ const resolution = (0, built_in_envir_utils_1.resolveEnvirArg)(args, data);
26
+ /* the first arg must be a string naming the variable to retrieve */
27
+ const firstArg = args.length >= 1 ? args[0] : undefined;
28
+ const retrieve = firstArg !== undefined && firstArg !== r_function_call_1.EmptyArgument
29
+ ? (0, unpack_argument_1.unpackNonameArg)(firstArg)
30
+ : undefined;
22
31
  if (retrieve === undefined || retrieve.type !== type_1.RType.String) {
23
- logger_1.dataflowLogger.warn(`symbol access with ${identifier_1.Identifier.toString(name.content)} has not 1 argument, skipping`);
32
+ logger_1.dataflowLogger.warn(`symbol access with ${identifier_1.Identifier.toString(name.content)} has not 1 string argument, skipping`);
24
33
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
25
34
  }
26
35
  const treatTargetAsSymbol = {
@@ -30,18 +39,23 @@ function processGet(name, args, rootId, data) {
30
39
  lexeme: retrieve.lexeme,
31
40
  location: retrieve.location
32
41
  };
42
+ /* resolve in the custom environment if one was found, else the global one.
43
+ * Pass remaining original args (e.g. envir=e) so they appear as Use vertices in the graph. */
33
44
  const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
34
45
  name,
35
- args: (0, make_argument_1.wrapArgumentsUnnamed)([treatTargetAsSymbol], data.completeAst.idMap),
46
+ args: [...(0, make_argument_1.wrapArgumentsUnnamed)([treatTargetAsSymbol], data.completeAst.idMap), ...args.slice(1)],
36
47
  rootId,
37
- data,
48
+ data: resolution ? resolution.envirData : data,
38
49
  origin: built_in_proc_name_1.BuiltInProcName.Get
39
50
  });
40
- const firstArg = processedArguments[0];
41
- if (firstArg) {
42
- // get 'reads' its first argument
43
- information.graph.addEdge(rootId, firstArg.entryPoint, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads);
51
+ const firstProcessed = processedArguments[0];
52
+ if (firstProcessed) {
53
+ information.graph.addEdge(rootId, firstProcessed.entryPoint, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads);
54
+ }
55
+ if (resolution) {
56
+ information.graph.addEdge(rootId, resolution.envirNodeId, edge_1.EdgeType.Reads);
44
57
  }
45
- return information;
58
+ /* restore the caller's (global) environment so we don't leak envState upward */
59
+ return { ...information, environment: data.environment };
46
60
  }
47
61
  //# sourceMappingURL=built-in-get.js.map
@@ -11,6 +11,7 @@ const scoping_1 = require("../../../../../environments/scoping");
11
11
  const identifier_1 = require("../../../../../environments/identifier");
12
12
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
13
13
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
14
+ const built_in_envir_utils_1 = require("./built-in-envir-utils");
14
15
  /**
15
16
  * Processes a built-in 'local' function call.
16
17
  */
@@ -29,6 +30,8 @@ function processLocal(name, args, rootId, data, config) {
29
30
  if (!expr) {
30
31
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
31
32
  }
33
+ /* when envir resolves to a tracked environment, evaluate expr inside it */
34
+ const envirResolution = env ? (0, built_in_envir_utils_1.resolveEnvirArg)(args, data, config.args.env) : undefined;
32
35
  const dfEnv = env ? (0, processor_1.processDataflowFor)(env, data) : info_1.DataflowInformation.initialize(rootId, data);
33
36
  if ((0, info_1.alwaysExits)(dfEnv)) {
34
37
  (0, common_1.patchFunctionCall)({
@@ -41,8 +44,10 @@ function processLocal(name, args, rootId, data, config) {
41
44
  });
42
45
  return dfEnv;
43
46
  }
44
- const bodyData = { ...data, environment: (0, scoping_1.pushLocalEnvironment)(data.environment) };
45
- const dfExpr = (0, processor_1.processDataflowFor)(expr, bodyData);
47
+ const baseEnvironment = envirResolution
48
+ ? envirResolution.envirData.environment // evaluate in the tracked custom env
49
+ : (0, scoping_1.pushLocalEnvironment)(data.environment); // normal new local scope
50
+ const dfExpr = (0, processor_1.processDataflowFor)(expr, { ...data, environment: baseEnvironment });
46
51
  (0, common_1.patchFunctionCall)({
47
52
  nextGraph: dfEnv.graph,
48
53
  rootId,
@@ -53,9 +58,9 @@ function processLocal(name, args, rootId, data, config) {
53
58
  });
54
59
  const ingoing = dfEnv.in.concat(dfExpr.in, dfEnv.unknownReferences, dfExpr.unknownReferences);
55
60
  ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
56
- return {
61
+ const baseResult = {
57
62
  hooks: dfExpr.hooks.concat(dfEnv.hooks),
58
- environment: (0, scoping_1.popLocalEnvironment)(dfExpr.environment),
63
+ environment: envirResolution ? data.environment : (0, scoping_1.popLocalEnvironment)(dfExpr.environment),
59
64
  exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints),
60
65
  graph: dfEnv.graph.mergeWith(dfExpr.graph),
61
66
  entryPoint: rootId,
@@ -63,5 +68,10 @@ function processLocal(name, args, rootId, data, config) {
63
68
  out: dfExpr.out.concat(dfEnv.out),
64
69
  unknownReferences: []
65
70
  };
71
+ /* move all definitions made inside the body into the custom env's tracked state */
72
+ if (envirResolution) {
73
+ return (0, built_in_envir_utils_1.routeWrittenToCustomEnv)(baseResult, envirResolution.envDef, rootId);
74
+ }
75
+ return baseResult;
66
76
  }
67
77
  //# sourceMappingURL=built-in-local.js.map
@@ -0,0 +1,27 @@
1
+ import type { DataflowProcessorInformation } from '../../../../../processor';
2
+ import type { DataflowInformation } from '../../../../../info';
3
+ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
+ import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
+ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
+ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ import { type REnvironmentInformation } from '../../../../../environments/environment';
8
+ /**
9
+ * Processes `new.env()` and `rlang::new_environment()`.
10
+ *
11
+ * The resulting function-call vertex carries the {@link BuiltInProcName.NewEnv} origin so that
12
+ * `processAssignment` can detect it and attach an `envState` to the assigned variable.
13
+ *
14
+ * When the `parent` argument can be statically resolved (a tracked env variable or an
15
+ * `emptyenv()`-family call), the resolved parent is stored in the vertex's `newEnvParent`
16
+ * field so that {@link createFreshEnvState} can use it.
17
+ */
18
+ export declare function processNewEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
19
+ /**
20
+ * Creates the initial (empty) environment state for a freshly created `new.env()`.
21
+ *
22
+ * When called from `processAssignmentToSymbol`, pass `sourceInfo` so that a
23
+ * statically-resolved `parent` argument (stored in the vertex's `newEnvParent` field)
24
+ * is honoured. Without `sourceInfo` (or when no `newEnvParent` is present), falls back
25
+ * to the current execution environment as parent.
26
+ */
27
+ export declare function createFreshEnvState(data: Pick<DataflowProcessorInformation<never>, 'environment'>, sourceInfo?: DataflowInformation): REnvironmentInformation;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processNewEnv = processNewEnv;
4
+ exports.createFreshEnvState = createFreshEnvState;
5
+ const known_call_handling_1 = require("../known-call-handling");
6
+ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
+ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
8
+ const scoping_1 = require("../../../../../environments/scoping");
9
+ const environment_1 = require("../../../../../environments/environment");
10
+ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
11
+ const unpack_argument_1 = require("../argument/unpack-argument");
12
+ const vertex_1 = require("../../../../../graph/vertex");
13
+ const convert_values_1 = require("../../../../../../r-bridge/lang-4.x/convert-values");
14
+ const built_in_envir_utils_1 = require("./built-in-envir-utils");
15
+ const EmptyParentEnvFunctions = new Set(['emptyenv', 'baseenv']);
16
+ /**
17
+ * Processes `new.env()` and `rlang::new_environment()`.
18
+ *
19
+ * The resulting function-call vertex carries the {@link BuiltInProcName.NewEnv} origin so that
20
+ * `processAssignment` can detect it and attach an `envState` to the assigned variable.
21
+ *
22
+ * When the `parent` argument can be statically resolved (a tracked env variable or an
23
+ * `emptyenv()`-family call), the resolved parent is stored in the vertex's `newEnvParent`
24
+ * field so that {@link createFreshEnvState} can use it.
25
+ */
26
+ function processNewEnv(name, args, rootId, data) {
27
+ const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.NewEnv }).information;
28
+ if (data.ctx.config.solver.trackEnvironments) {
29
+ const parentState = resolveNewEnvParentArg(args, data);
30
+ const vertex = result.graph.getVertex(rootId);
31
+ if (parentState !== undefined && (0, vertex_1.isFunctionCallVertex)(vertex)) {
32
+ vertex.newEnvParent = parentState;
33
+ }
34
+ }
35
+ return result;
36
+ }
37
+ /**
38
+ * Scans `args` for the `parent` argument and returns the {@link REnvironmentInformation}
39
+ * to use as the parent of the newly-created environment, or `undefined` to fall through
40
+ * to the default (current execution environment).
41
+ *
42
+ * Recognised patterns:
43
+ * - `parent = <tracked-env-var>` - returns that variable's `envState`
44
+ * - `parent = emptyenv()` / `parent = baseenv()` - returns an isolated env (no user scope)
45
+ * - everything else - `undefined` (fall through)
46
+ */
47
+ function resolveNewEnvParentArg(args, data) {
48
+ for (const arg of args) {
49
+ if (arg === r_function_call_1.EmptyArgument || arg.name?.content !== 'parent') {
50
+ continue;
51
+ }
52
+ const node = (0, unpack_argument_1.unpackArg)(arg);
53
+ if (!node) {
54
+ return undefined;
55
+ }
56
+ if (node.type === type_1.RType.Symbol) {
57
+ if (node.content === convert_values_1.RNull) {
58
+ return undefined;
59
+ }
60
+ return (0, built_in_envir_utils_1.resolveSymbolToEnvir)(node.content, node.info.id, data)?.envDef.envState;
61
+ }
62
+ if (r_function_call_1.RFunctionCall.isNamed(node) && node.functionName.type === type_1.RType.Symbol
63
+ && EmptyParentEnvFunctions.has(node.functionName.content)) {
64
+ return createIsolatedEnvState(data);
65
+ }
66
+ return undefined;
67
+ }
68
+ return undefined;
69
+ }
70
+ function createIsolatedEnvState(data) {
71
+ let root = data.environment.current;
72
+ while (!root.builtInEnv) {
73
+ root = root.parent;
74
+ }
75
+ return { current: new environment_1.Environment(root), level: 0 };
76
+ }
77
+ /**
78
+ * Creates the initial (empty) environment state for a freshly created `new.env()`.
79
+ *
80
+ * When called from `processAssignmentToSymbol`, pass `sourceInfo` so that a
81
+ * statically-resolved `parent` argument (stored in the vertex's `newEnvParent` field)
82
+ * is honoured. Without `sourceInfo` (or when no `newEnvParent` is present), falls back
83
+ * to the current execution environment as parent.
84
+ */
85
+ function createFreshEnvState(data, sourceInfo) {
86
+ if (sourceInfo !== undefined) {
87
+ const vertex = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
88
+ if ((0, vertex_1.isFunctionCallVertex)(vertex) && vertex.newEnvParent !== undefined) {
89
+ return {
90
+ current: new environment_1.Environment(vertex.newEnvParent.current),
91
+ level: vertex.newEnvParent.level + 1
92
+ };
93
+ }
94
+ }
95
+ return (0, scoping_1.pushLocalEnvironment)(data.environment);
96
+ }
97
+ //# sourceMappingURL=built-in-new-env.js.map
@@ -0,0 +1,23 @@
1
+ import type { DataflowProcessorInformation } from '../../../../../processor';
2
+ import type { DataflowInformation } from '../../../../../info';
3
+ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
+ import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
+ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
+ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ /**
8
+ * Processes `with(data, expr)` and `within(data, expr)`.
9
+ *
10
+ * When `data` is a variable that holds a tracked {@link InGraphIdentifierDefinition#envState},
11
+ * the expression `expr` is evaluated in that environment's scope so that reads of names
12
+ * defined there resolve correctly.
13
+ *
14
+ * - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
15
+ * - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
16
+ *
17
+ * Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
18
+ * args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
19
+ *
20
+ * Falls back to a normal function-call analysis when the data argument cannot be resolved
21
+ * to a tracked environment.
22
+ */
23
+ export declare function processWithEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processWithEnv = processWithEnv;
4
+ const processor_1 = require("../../../../../processor");
5
+ const known_call_handling_1 = require("../known-call-handling");
6
+ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
+ const identifier_1 = require("../../../../../environments/identifier");
8
+ const built_in_envir_utils_1 = require("./built-in-envir-utils");
9
+ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
10
+ const common_1 = require("../common");
11
+ const edge_1 = require("../../../../../graph/edge");
12
+ const linker_1 = require("../../../../linker");
13
+ /** Formal parameter names for `with(data, expr, ...)` and `within(data, expr, ...)`. */
14
+ const withParams = ['data', 'expr'];
15
+ /**
16
+ * Processes `with(data, expr)` and `within(data, expr)`.
17
+ *
18
+ * When `data` is a variable that holds a tracked {@link InGraphIdentifierDefinition#envState},
19
+ * the expression `expr` is evaluated in that environment's scope so that reads of names
20
+ * defined there resolve correctly.
21
+ *
22
+ * - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
23
+ * - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
24
+ *
25
+ * Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
26
+ * args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
27
+ *
28
+ * Falls back to a normal function-call analysis when the data argument cannot be resolved
29
+ * to a tracked environment.
30
+ */
31
+ function processWithEnv(name, args, rootId, data) {
32
+ if (args.length < 2) {
33
+ return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
34
+ }
35
+ const bound = (0, built_in_envir_utils_1.bindArgs)(args, withParams);
36
+ const dataArg = bound.get('data');
37
+ const exprArg = bound.get('expr');
38
+ if (dataArg === undefined || dataArg === r_function_call_1.EmptyArgument || dataArg.value === undefined ||
39
+ exprArg === undefined || exprArg === r_function_call_1.EmptyArgument || exprArg.value === undefined) {
40
+ return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
41
+ }
42
+ const envirResolution = (0, built_in_envir_utils_1.resolveArgToEnvir)(dataArg, data);
43
+ if (!envirResolution) {
44
+ return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
45
+ }
46
+ /* evaluate data arg in the caller's scope (it is just read) */
47
+ const dfDataArg = (0, processor_1.processDataflowFor)(dataArg.value, data);
48
+ /* evaluate expr in the resolved env's scope so variable lookup uses envState */
49
+ const dfExpr = (0, processor_1.processDataflowFor)(exprArg.value, {
50
+ ...data,
51
+ environment: envirResolution.envirData.environment
52
+ });
53
+ /*
54
+ * processSymbol puts symbol uses in unknownReferences without creating reads edges.
55
+ * Explicitly link expr's unknown references against the envState so reads edges are
56
+ * created for names that resolve there (e.g. `x` in `with(e, x)` -> assign).
57
+ * References that cannot be resolved in envState are kept for the outer scope.
58
+ */
59
+ const remainingFromExpr = [];
60
+ (0, linker_1.linkInputs)(dfExpr.unknownReferences, envirResolution.envirData.environment, remainingFromExpr, dfExpr.graph, false);
61
+ (0, common_1.patchFunctionCall)({
62
+ nextGraph: dfDataArg.graph,
63
+ rootId,
64
+ name,
65
+ data,
66
+ argumentProcessResult: [dfDataArg, dfExpr],
67
+ origin: built_in_proc_name_1.BuiltInProcName.With
68
+ });
69
+ const merged = dfDataArg.graph.mergeWith(dfExpr.graph);
70
+ merged.addEdge(rootId, envirResolution.envirNodeId, edge_1.EdgeType.Reads);
71
+ const ingoing = dfDataArg.in.concat(dfExpr.in, dfDataArg.unknownReferences, remainingFromExpr, /* unresolved expr refs propagate to outer scope */ [{ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function }]);
72
+ /* within routes body writes back into the data environment; with discards them */
73
+ const isWithin = identifier_1.Identifier.getName(name.content) === 'within';
74
+ let resultEnv = data.environment;
75
+ if (isWithin && dfExpr.out.length > 0) {
76
+ const tempResult = { ...dfExpr, environment: data.environment };
77
+ resultEnv = (0, built_in_envir_utils_1.routeWrittenToCustomEnv)(tempResult, envirResolution.envDef, rootId).environment;
78
+ }
79
+ return {
80
+ hooks: dfDataArg.hooks.concat(dfExpr.hooks),
81
+ environment: resultEnv,
82
+ exitPoints: dfDataArg.exitPoints.concat(dfExpr.exitPoints),
83
+ graph: merged,
84
+ entryPoint: rootId,
85
+ in: ingoing,
86
+ out: [], /* writes are inside envState, not directly in outer scope */
87
+ unknownReferences: []
88
+ };
89
+ }
90
+ //# sourceMappingURL=built-in-with.js.map
@@ -17,9 +17,20 @@ const doc_issue_1 = require("./doc-util/doc-issue");
17
17
  const strings_1 = require("../util/text/strings");
18
18
  const doc_maker_1 = require("./wiki-mk/doc-maker");
19
19
  const PublicationsMain = [
20
+ {
21
+ header: 'Supporting the Comprehension of Data Analysis Scripts (FSE \'25, Tool)',
22
+ description: 'This refers to an updated tool demonstration of the framework. Preprint available at <a href="https://doi.org/10.48550/arXiv.2604.15963" target="_blank">arXiv:2604.15963</a>.',
23
+ doi: 'https://doi.org/10.1145/3803437.3806402',
24
+ bibtex: String.raw `@article{10.1145/3803437.3806402,
25
+ author = {Sihler, Florian and Gerstl, Oliver and Pfrenger, Lars and Schubert, Julian and Tichy, Matthias},
26
+ title = {Supporting the Comprehension of Data Analysis Scripts},
27
+ year = {2026},
28
+ doi = {10.1145/3803437.3806402}
29
+ }`
30
+ },
20
31
  {
21
32
  header: 'Statically Analyzing the Dataflow of R Programs (OOPSLA \'25)',
22
- description: 'Please cite this paper if you are using flowR in your research.',
33
+ description: '**Please cite this paper if you are using flowR in your research.**',
23
34
  doi: 'https://doi.org/10.1145/3763087',
24
35
  bibtex: String.raw `@article{10.1145/3763087,
25
36
  author = {Sihler, Florian and Tichy, Matthias},
@@ -42,7 +53,7 @@ const PublicationsMain = [
42
53
  },
43
54
  {
44
55
  header: 'flowR: A Static Program Slicer for R (ASE \'24, Tool)',
45
- description: `This refers to the tool-demonstration of the <a href="${doc_files_1.FlowrVsCode}">VS Code Extension</a>.`,
56
+ description: `This refers to the tool-demonstration of the <a href="${doc_files_1.FlowrVsCode}" target="_blank">VS Code Extension</a>.`,
46
57
  doi: 'https://doi.org/10.1145/3691620.3695359',
47
58
  bibtex: `@inproceedings{DBLP:conf/kbse/SihlerT24,
48
59
  author = {Florian Sihler and
@@ -59,7 +59,7 @@ export declare function getStartLineOfTypeScriptNode(node: ts.Node, sourceFile:
59
59
  * Return the link to the type in the source code.
60
60
  * If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
61
61
  */
62
- export declare function getTypePathLink(elem: Pick<TypeElementInSource, 'filePath' | 'lineNumber'>, prefix?: string): string;
62
+ export declare function getTypePathLink(elem: Pick<TypeElementInSource, 'filePath' | 'lineNumber'>, relative?: boolean): string;
63
63
  export interface MermaidClassDiagramArguments {
64
64
  readonly inlineTypes?: readonly string[];
65
65
  readonly simplify?: boolean;
@@ -130,6 +130,8 @@ export interface FnElementInfo {
130
130
  doNotAutoGobble?: boolean;
131
131
  /** Whether to hide the "Defined at ..." line */
132
132
  hideDefinedAt?: boolean;
133
+ /** Whether lines with import statements in the code should be skipped */
134
+ skipImports?: boolean;
133
135
  }
134
136
  /**
135
137
  * Print an element from the info as code block.
@@ -137,7 +139,14 @@ export interface FnElementInfo {
137
139
  *
138
140
  * This is great to show examples that are directly taken from the source code.
139
141
  */
140
- export declare function printCodeOfElement({ program, info, dropLinesEnd, dropLinesStart, doNotAutoGobble, hideDefinedAt }: FnElementInfo, name: string): string;
142
+ export declare function printCodeOfElement(info: FnElementInfo, name: string): string;
143
+ /**
144
+ * Print a source file as code block.
145
+ * If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
146
+ *
147
+ * This is great to show examples that are directly taken from the source code.
148
+ */
149
+ export declare function printCodeOfFile(info: FnElementInfo, relativePath: string): string;
141
150
  /**
142
151
  * Create a short link to a type in the documentation.
143
152
  * If you create a wiki, please refer to the functions provided by the {@link GeneralDocContext}.
@@ -46,6 +46,7 @@ exports.visualizeMermaidClassDiagram = visualizeMermaidClassDiagram;
46
46
  exports.getTypesFromFolder = getTypesFromFolder;
47
47
  exports.printHierarchy = printHierarchy;
48
48
  exports.printCodeOfElement = printCodeOfElement;
49
+ exports.printCodeOfFile = printCodeOfFile;
49
50
  exports.shortLink = shortLink;
50
51
  exports.shortLinkFile = shortLinkFile;
51
52
  exports.getDocumentationForType = getDocumentationForType;
@@ -353,9 +354,9 @@ function getTypePathForTypeScript({ filePath }) {
353
354
  * Return the link to the type in the source code.
354
355
  * If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
355
356
  */
356
- function getTypePathLink(elem, prefix = doc_files_1.RemoteFlowrFilePathBaseRef) {
357
+ function getTypePathLink(elem, relative = false) {
357
358
  const fromSource = getTypePathForTypeScript(elem);
358
- return `${prefix}/${fromSource}#L${elem.lineNumber}`;
359
+ return `${relative ? '' : doc_files_1.RemoteFlowrFilePathBaseRef}${fromSource}#L${elem.lineNumber}`;
359
360
  }
360
361
  function generateMermaidClassDiagram(hierarchyList, rootName, options, visited = new Set()) {
361
362
  const collect = { nodeLines: [], edgeLines: [] };
@@ -480,10 +481,10 @@ function implSnippet(node, program, showName = true, nesting = 0, open = false,
480
481
  }
481
482
  if (showImplSnippet) {
482
483
  const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
483
- text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
484
+ text += `\n<details${open ? ' open' : ''}><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
484
485
  }
485
486
  else {
486
- text += `\n<br/><i>(Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a>)</i>\n`;
487
+ text += `\n<br/><i>(Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, true)}</a>)</i>\n`;
487
488
  }
488
489
  const init = showName ? `* ${bold}[${node.name}](${getTypePathLink(node)})${bold} ${sep}${indent}` : '';
489
490
  return ` ${indent}${showName ? init : ''} ${text.replaceAll('\t', ' ').split(/\n/g).join(`\n${indent} `)}`;
@@ -535,13 +536,31 @@ function printHierarchy({ program, info, root, ignoredTypes, collapseFromNesting
535
536
  *
536
537
  * This is great to show examples that are directly taken from the source code.
537
538
  */
538
- function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart = 0, doNotAutoGobble, hideDefinedAt }, name) {
539
- const node = info.find(e => e.name === name);
539
+ function printCodeOfElement(info, name) {
540
+ const node = info.info.find(e => e.name === name);
540
541
  if (!node) {
541
542
  console.error(`Could not find node ${name} when resolving function!`);
542
543
  return '';
543
544
  }
544
- let code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName)).trim();
545
+ const code = node.node.getFullText(info.program.getSourceFile(node.node.getSourceFile().fileName)).trim();
546
+ return printCode(info, code, getTypePathLink(node, true));
547
+ }
548
+ /**
549
+ * Print a source file as code block.
550
+ * If you create a wiki, please refer to the functions provided by the {@link GeneralWikiContext}.
551
+ *
552
+ * This is great to show examples that are directly taken from the source code.
553
+ */
554
+ function printCodeOfFile(info, relativePath) {
555
+ const fullPath = path_1.default.resolve(__dirname, `../../../${relativePath}`);
556
+ const code = info.program.getSourceFile(fullPath)?.getFullText().trim();
557
+ if (!code) {
558
+ console.error(`Could not find source file ${relativePath}!`);
559
+ return '';
560
+ }
561
+ return printCode(info, code, relativePath);
562
+ }
563
+ function printCode({ dropLinesEnd = 0, dropLinesStart = 0, doNotAutoGobble, hideDefinedAt, skipImports }, code, definedAt) {
545
564
  if (dropLinesStart > 0 || dropLinesEnd > 0) {
546
565
  const lines = code.split(/\n/g);
547
566
  if (dropLinesStart + dropLinesEnd >= lines.length) {
@@ -549,6 +568,9 @@ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart =
549
568
  }
550
569
  code = lines.slice(dropLinesStart, lines.length - dropLinesEnd).join('\n');
551
570
  }
571
+ if (skipImports) {
572
+ code = code.replaceAll(/^import\s.*\n/gm, '').trim();
573
+ }
552
574
  if (!doNotAutoGobble) {
553
575
  // gobble leading spaces
554
576
  const lines = code.replaceAll('\t', ' ').split(/\n/g);
@@ -563,11 +585,11 @@ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart =
563
585
  code = lines.map(line => line.startsWith(' '.repeat(gobble)) ? line.slice(gobble) : line).join('\n');
564
586
  }
565
587
  }
566
- if (hideDefinedAt) {
588
+ if (hideDefinedAt || !definedAt) {
567
589
  return (0, doc_code_1.codeBlock)('ts', code);
568
590
  }
569
591
  else {
570
- return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></i>\n`;
592
+ return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${doc_files_1.RemoteFlowrFilePathBaseRef}${definedAt}">${definedAt}</a></i>\n`;
571
593
  }
572
594
  }
573
595
  function fuzzyCompare(a, b) {
@@ -1,5 +1,20 @@
1
- import type { DocMakerArgs } from './wiki-mk/doc-maker';
2
- import { DocMaker } from './wiki-mk/doc-maker';
1
+ import { type AbsintVisitorConfiguration, AbstractInterpretationVisitor } from '../abstract-interpretation/absint-visitor';
2
+ import { IntervalDomain } from '../abstract-interpretation/domains/interval-domain';
3
+ import { StateAbstractDomain } from '../abstract-interpretation/domains/state-abstract-domain';
4
+ import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexValue } from '../dataflow/graph/vertex';
5
+ import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
6
+ import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
7
+ import { DocMaker, type DocMakerArgs } from './wiki-mk/doc-maker';
8
+ export declare class IntervalInferenceVisitor extends AbstractInterpretationVisitor<StateAbstractDomain<IntervalDomain>> {
9
+ constructor(config: AbsintVisitorConfiguration);
10
+ protected onNumberConstant({ vertex, node }: {
11
+ vertex: DataflowGraphVertexValue;
12
+ node: RNumber<ParentInformation>;
13
+ }): void;
14
+ protected onFunctionCall({ call }: {
15
+ call: DataflowGraphVertexFunctionCall;
16
+ }): void;
17
+ }
3
18
  export declare class WikiAbsint extends DocMaker<'wiki/Abstract Interpretation.md'> {
4
19
  constructor();
5
20
  protected text({ ctx }: DocMakerArgs): Promise<string>;