@eagleoutice/flowr 2.13.2 → 2.13.3

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 (97) hide show
  1. package/README.md +46 -44
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
  3. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
  5. package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
  6. package/config.d.ts +8 -0
  7. package/config.js +9 -1
  8. package/control-flow/control-flow-graph.js +2 -1
  9. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  10. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  11. package/dataflow/environments/append.d.ts +1 -1
  12. package/dataflow/environments/clone.d.ts +1 -1
  13. package/dataflow/environments/environment.d.ts +28 -4
  14. package/dataflow/environments/environment.js +66 -11
  15. package/dataflow/environments/overwrite.d.ts +1 -1
  16. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  17. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  18. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  19. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
  20. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
  21. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
  22. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  23. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
  24. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  25. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
  26. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
  27. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  28. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  29. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
  30. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
  31. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
  33. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
  35. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
  36. package/documentation/doc-readme.js +14 -12
  37. package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
  38. package/documentation/wiki-dataflow-graph.js +4 -24
  39. package/documentation/wiki-query.js +47 -0
  40. package/documentation/wiki-signature-database.js +3 -2
  41. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  42. package/linter/rules/undefined-symbol-util.js +3 -1
  43. package/linter/rules/undefined-symbol.js +3 -4
  44. package/package.json +21 -9
  45. package/project/context/flowr-analyzer-context.d.ts +4 -4
  46. package/project/context/flowr-analyzer-context.js +3 -3
  47. package/project/context/flowr-analyzer-dependencies-context.d.ts +11 -5
  48. package/project/context/flowr-analyzer-dependencies-context.js +8 -3
  49. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  50. package/project/dependency-version-space.d.ts +118 -26
  51. package/project/dependency-version-space.js +343 -87
  52. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
  53. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
  54. package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
  55. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  56. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
  57. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
  58. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  59. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
  60. package/project/plugins/package-version-plugins/package.d.ts +27 -10
  61. package/project/plugins/package-version-plugins/package.js +50 -25
  62. package/project/sigdb/reader.d.ts +26 -16
  63. package/project/sigdb/reader.js +52 -21
  64. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  65. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -2
  66. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
  67. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  68. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
  69. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
  70. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +53 -23
  71. package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
  72. package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
  73. package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
  74. package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
  75. package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
  76. package/queries/catalog/input-sources-query/input-types.js +64 -0
  77. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
  78. package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
  79. package/queries/catalog/project-query/project-query-executor.js +1 -1
  80. package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
  81. package/queries/catalog/signature-query/signature-query-executor.js +112 -39
  82. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
  83. package/queries/catalog/signature-query/signature-query-format.js +1 -1
  84. package/queries/catalog/signature-query/signature-query-render.js +8 -3
  85. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  86. package/r-bridge/retriever.d.ts +1 -1
  87. package/search/flowr-search-printer.js +10 -8
  88. package/slicing/static/static-slicer.d.ts +2 -2
  89. package/util/objects.js +6 -4
  90. package/util/r-base-packages.d.ts +2 -0
  91. package/util/r-base-packages.js +3 -0
  92. package/util/r-license.js +1 -4
  93. package/util/r-version.d.ts +12 -0
  94. package/util/r-version.js +16 -0
  95. package/util/range.d.ts +6 -2
  96. package/util/range.js +33 -15
  97. package/util/version.js +1 -1
@@ -1,7 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TempFileFunctions = exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = void 0;
3
+ exports.TempFileFunctions = exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = exports.LinkedInputEntryPoints = exports.LinkedInputObjects = void 0;
4
4
  const identifier_1 = require("../../../dataflow/environments/identifier");
5
+ const simple_input_classifier_1 = require("./simple-input-classifier");
6
+ /** shiny's ui-side control widgets, all taking the id of the `input` entry they feed as their first argument */
7
+ const ShinyInputWidgets = {
8
+ argName: 'inputId',
9
+ argIdx: 0,
10
+ calls: [
11
+ 'actionButton', 'actionLink', 'checkboxInput', 'checkboxGroupInput', 'dateInput', 'dateRangeInput',
12
+ 'fileInput', 'numericInput', 'passwordInput', 'radioButtons', 'selectInput', 'selectizeInput',
13
+ 'sliderInput', 'submitButton', 'textAreaInput', 'textInput', 'varSelectInput', 'varSelectizeInput'
14
+ ].map(n => identifier_1.Identifier.make(n, 'shiny'))
15
+ };
16
+ /**
17
+ * Objects that a framework binds for its users, without a definition visible in the code.
18
+ * The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same
19
+ * name out of this; where the framework is handed the function, {@link LinkedInputEntryPoints} is exact instead.
20
+ * @see {@link LinkedInputObject}
21
+ */
22
+ exports.LinkedInputObjects = [
23
+ /* shiny hands the server function its reactive `input` and `session` objects */
24
+ { name: 'input', type: simple_input_classifier_1.InputType.User, withParams: ['output'], requires: 'shiny', declaredBy: ShinyInputWidgets },
25
+ /* of the session only what the browser sends is user input, `userData` and `token` are the app's own */
26
+ { name: 'session', type: simple_input_classifier_1.InputType.User, withParams: ['input', 'output'], requires: 'shiny', fields: ['clientData', 'request'] }
27
+ ];
28
+ /** shiny binds `input`, `output`, and `session` positionally, so their names are up to whoever writes the server */
29
+ const ShinyServerParams = ['input', undefined, 'session'];
30
+ /**
31
+ * Calls that hand a function to a framework which binds its parameters by position.
32
+ * @see {@link LinkedInputEntryPoint}
33
+ */
34
+ exports.LinkedInputEntryPoints = [
35
+ { call: identifier_1.Identifier.make('shinyApp', 'shiny'), argName: 'server', argIdx: 1, params: ShinyServerParams },
36
+ { call: identifier_1.Identifier.make('shinyServer', 'shiny'), argName: 'func', argIdx: 0, params: ShinyServerParams },
37
+ { call: identifier_1.Identifier.make('moduleServer', 'shiny'), argName: 'module', argIdx: 1, params: ShinyServerParams },
38
+ { call: identifier_1.Identifier.make('callModule', 'shiny'), argName: 'module', argIdx: 0, params: ShinyServerParams }
39
+ ];
5
40
  exports.PureFunctions = [
6
41
  /* operators - syntax elements, impossible to call with :: in practice */
7
42
  '+', '-', '*', '/', '^', '%%', '%/%',
@@ -212,6 +247,40 @@ exports.PureFunctions = [
212
247
  identifier_1.Identifier.make('cov', 'stats'),
213
248
  identifier_1.Identifier.make('na.omit', 'stats'),
214
249
  identifier_1.Identifier.make('xtabs', 'stats'),
250
+ /* shiny - wrappers that hand their expression on; the reactives among them do so through a call (`r()`).
251
+ `observe`/`observeEvent`/`render*` are left out on purpose: they return an observer or render handle,
252
+ not the value of their expression. */
253
+ identifier_1.Identifier.make('reactive', 'shiny'),
254
+ identifier_1.Identifier.make('eventReactive', 'shiny'),
255
+ identifier_1.Identifier.make('bindEvent', 'shiny'),
256
+ identifier_1.Identifier.make('bindCache', 'shiny'),
257
+ identifier_1.Identifier.make('isolate', 'shiny'),
258
+ identifier_1.Identifier.make('req', 'shiny'),
259
+ identifier_1.Identifier.make('debounce', 'shiny'),
260
+ identifier_1.Identifier.make('throttle', 'shiny'),
261
+ identifier_1.Identifier.make('reactiveVal', 'shiny'),
262
+ identifier_1.Identifier.make('reactiveValues', 'shiny'),
263
+ identifier_1.Identifier.make('reactiveValuesToList', 'shiny'),
264
+ identifier_1.Identifier.make('freezeReactiveVal', 'shiny'),
265
+ /* cohortBuilder - assembling a cohort keeps the data of its source */
266
+ identifier_1.Identifier.make('cohort', 'cohortBuilder'),
267
+ identifier_1.Identifier.make('set_source', 'cohortBuilder'),
268
+ identifier_1.Identifier.make('add_source', 'cohortBuilder'),
269
+ identifier_1.Identifier.make('update_source', 'cohortBuilder'),
270
+ identifier_1.Identifier.make('add_filter', 'cohortBuilder'),
271
+ identifier_1.Identifier.make('update_filter', 'cohortBuilder'),
272
+ identifier_1.Identifier.make('rm_filter', 'cohortBuilder'),
273
+ identifier_1.Identifier.make('bind_key', 'cohortBuilder'),
274
+ identifier_1.Identifier.make('bind_keys', 'cohortBuilder'),
275
+ identifier_1.Identifier.make('as.tblist', 'cohortBuilder'),
276
+ identifier_1.Identifier.make('tblist', 'cohortBuilder'),
277
+ /* generic names, only matched bare while cohortBuilder is attached */
278
+ identifier_1.Identifier.make('filter', 'cohortBuilder'),
279
+ identifier_1.Identifier.make('step', 'cohortBuilder'),
280
+ identifier_1.Identifier.make('add_step', 'cohortBuilder'),
281
+ identifier_1.Identifier.make('rm_step', 'cohortBuilder'),
282
+ identifier_1.Identifier.make('run', 'cohortBuilder'),
283
+ identifier_1.Identifier.make('restore', 'cohortBuilder'),
215
284
  ];
216
285
  exports.SystemFunctions = [
217
286
  /* base */
@@ -321,6 +390,32 @@ exports.UserFunctions = [
321
390
  /* tcltk */
322
391
  identifier_1.Identifier.make('tk_choose.files', 'tcltk'),
323
392
  identifier_1.Identifier.make('tk_choose.dir', 'tcltk'),
393
+ /* shiny - everything the browser sends along with a request */
394
+ identifier_1.Identifier.make('parseQueryString', 'shiny'),
395
+ identifier_1.Identifier.make('getQueryString', 'shiny'),
396
+ identifier_1.Identifier.make('getUrlHash', 'shiny'),
397
+ identifier_1.Identifier.make('restoreInput', 'shiny'),
398
+ /* shinyFiles - paths the user picks in the browser */
399
+ identifier_1.Identifier.make('parseFilePaths', 'shinyFiles'),
400
+ identifier_1.Identifier.make('parseDirPath', 'shinyFiles'),
401
+ identifier_1.Identifier.make('parseSavePath', 'shinyFiles'),
402
+ identifier_1.Identifier.make('shinyFileChoose', 'shinyFiles'),
403
+ identifier_1.Identifier.make('shinyDirChoose', 'shinyFiles'),
404
+ identifier_1.Identifier.make('shinyFileSave', 'shinyFiles'),
405
+ /* cohortBuilder - the data that comes out of a cohort depends on the filters the user set */
406
+ identifier_1.Identifier.make('get_data', 'cohortBuilder'),
407
+ identifier_1.Identifier.make('sum_up', 'cohortBuilder'),
408
+ identifier_1.Identifier.make('attrition', 'cohortBuilder'),
409
+ identifier_1.Identifier.make('get_state', 'cohortBuilder'),
410
+ identifier_1.Identifier.make('code', 'cohortBuilder'),
411
+ identifier_1.Identifier.make('stat', 'cohortBuilder'),
412
+ /* shinyCohortBuilder - the gui that lets the user set those filters */
413
+ identifier_1.Identifier.make('cb_server', 'shinyCohortBuilder'),
414
+ identifier_1.Identifier.make('cb_ui', 'shinyCohortBuilder'),
415
+ identifier_1.Identifier.make('cb_chat_server', 'shinyCohortBuilder'),
416
+ identifier_1.Identifier.make('cb_chat_ui', 'shinyCohortBuilder'),
417
+ identifier_1.Identifier.make('gui', 'shinyCohortBuilder'),
418
+ identifier_1.Identifier.make('demo_app', 'shinyCohortBuilder'),
324
419
  ];
325
420
  /** R functions that produce temporary file/directory paths (sub-type of {@link InputType.File}). */
326
421
  exports.TempFileFunctions = [
@@ -10,6 +10,9 @@ const df_helper_1 = require("../../../dataflow/graph/df-helper");
10
10
  const simple_input_classifier_1 = require("./simple-input-classifier");
11
11
  const flowr_search_executor_1 = require("../../../search/flowr-search-executor");
12
12
  const record_1 = require("../../../util/record");
13
+ const identifier_1 = require("../../../dataflow/environments/identifier");
14
+ const r_base_packages_1 = require("../../../util/r-base-packages");
15
+ const environment_1 = require("../../../dataflow/environments/environment");
13
16
  /**
14
17
  * Execute an input sources query
15
18
  */
@@ -18,7 +21,9 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
18
21
  const results = {};
19
22
  const nast = await analyzer.normalize();
20
23
  const df = await analyzer.dataflow();
21
- const defaultConfig = await resolveSearches(analyzer, input_sources_query_format_1.DefaultInputClassifierConfig);
24
+ // flowR's defaults, extended by whatever the (possibly project-kind specialized) configuration adds
25
+ const defaultConfig = addAll(await resolveSearches(analyzer, input_sources_query_format_1.DefaultInputClassifierConfig), await resolveSearches(analyzer, analyzer.inspectContext().config.inputSources ?? {}));
26
+ const packages = attachedPackages(analyzer, df.environment);
22
27
  for (const query of queries) {
23
28
  const criteria = Array.isArray(query.criterion)
24
29
  ? query.criterion
@@ -33,7 +38,7 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
33
38
  const provenanceNode = nast.idMap.get(criterionId);
34
39
  const fdef = r_function_definition_1.RFunctionDefinition.rootFunctionDefinition(provenanceNode, nast.idMap);
35
40
  const provenance = df_helper_1.Dataflow.provenanceGraph(criterionId, df.graph, fdef ? model_1.RNode.collectAllIds(fdef) : undefined);
36
- results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph);
41
+ results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph, packages);
37
42
  }
38
43
  }
39
44
  return {
@@ -43,11 +48,42 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
43
48
  results
44
49
  };
45
50
  }
51
+ /**
52
+ * The packages whose exports are usable without a namespace: those R has on its search path at the end of the
53
+ * program, the ones the project declares, and the base packages R attaches on startup.
54
+ */
55
+ function attachedPackages(analyzer, environment) {
56
+ return new Set([
57
+ ...environment_1.REnvironment.attachedPackages(environment.current),
58
+ ...analyzer.inspectContext().deps.getDependencies().map(d => d.name),
59
+ ...r_base_packages_1.AttachedBasePackages
60
+ ]);
61
+ }
62
+ /** every entry of `extra` appended to the matching list of `base`, so configured entries extend the defaults instead of replacing them */
63
+ function addAll(base, extra) {
64
+ const result = { ...base };
65
+ for (const [key, value] of record_1.Record.entries(extra)) {
66
+ if (value !== undefined) {
67
+ result[key] = [...(base[key] ?? []), ...value];
68
+ }
69
+ }
70
+ return result;
71
+ }
46
72
  async function resolveSearches(analyzer, config) {
47
73
  const result = {};
74
+ if (config.linkedObjects !== undefined) {
75
+ result.linkedObjects = config.linkedObjects;
76
+ }
77
+ if (config.linkedEntryPoints !== undefined) {
78
+ result.linkedEntryPoints = config.linkedEntryPoints;
79
+ }
48
80
  for (const [key, value] of record_1.Record.entries(config)) {
49
- if (value === undefined || Array.isArray(value)) {
50
- result[key] = value;
81
+ if (key === 'linkedObjects' || key === 'linkedEntryPoints') {
82
+ continue;
83
+ }
84
+ else if (value === undefined || Array.isArray(value)) {
85
+ // entries may be written as `pkg::fn` strings in the configuration, which only mean the namespaced function once parsed
86
+ result[key] = value?.map(e => typeof e === 'string' ? identifier_1.Identifier.parse(e) : e);
51
87
  }
52
88
  else {
53
89
  const searchResult = await (0, flowr_search_executor_1.runSearch)(value, analyzer);
@@ -13,6 +13,7 @@ const input_sources_query_executor_1 = require("./input-sources-query-executor")
13
13
  const range_1 = require("../../../util/range");
14
14
  const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
15
15
  const linter_format_1 = require("../../../linter/linter-format");
16
+ const record_1 = require("../../../util/record");
16
17
  const read_functions_1 = require("../dependencies-query/function-info/read-functions");
17
18
  const input_source_functions_1 = require("./input-source-functions");
18
19
  exports.DefaultInputClassifierConfig = {
@@ -25,7 +26,9 @@ exports.DefaultInputClassifierConfig = {
25
26
  [simple_input_classifier_1.InputType.Ffi]: input_source_functions_1.FfiFunctions,
26
27
  [simple_input_classifier_1.InputType.Lang]: input_source_functions_1.LangFunctions,
27
28
  [simple_input_classifier_1.InputType.Options]: input_source_functions_1.OptionsFunctions,
28
- [simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions
29
+ [simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions,
30
+ linkedObjects: input_source_functions_1.LinkedInputObjects,
31
+ linkedEntryPoints: input_source_functions_1.LinkedInputEntryPoints
29
32
  };
30
33
  function inputSourcesQueryLineParser(output, line, _config) {
31
34
  const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
@@ -47,12 +50,16 @@ exports.InputSourcesDefinition = {
47
50
  const nast = (await analyzer.normalize()).idMap;
48
51
  for (const [key, sources] of Object.entries(out.results)) {
49
52
  result.push(` ╰ Input Sources for ${key}`);
50
- for (const { id, trace, types, name, value } of sources) {
53
+ for (const { id, trace, types, name, value, declaredAt } of sources) {
51
54
  const kNode = nast.get(id);
52
55
  const kLoc = kNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(kNode)) : 'unknown location';
53
56
  const nameStr = name !== undefined ? `, name: ${name}` : '';
54
57
  const valueStr = value !== undefined ? `, value: ${JSON.stringify(value)}` : '';
55
- result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}${nameStr}${valueStr}`);
58
+ const declStr = declaredAt ? `, declared at: ${declaredAt.map(d => {
59
+ const dNode = nast.get(d);
60
+ return dNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(dNode)) : String(d);
61
+ }).join(', ')}` : '';
62
+ result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}${nameStr}${valueStr}${declStr}`);
56
63
  }
57
64
  }
58
65
  return true;
@@ -74,6 +81,17 @@ exports.InputSourcesDefinition = {
74
81
  [simple_input_classifier_1.InputType.Lang]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
75
82
  [simple_input_classifier_1.InputType.Options]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
76
83
  [simple_input_classifier_1.InputType.User]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read interactive user input (e.g., file.choose, readline, menu, askYesNo).'),
84
+ linkedObjects: joi_1.default.array().items(joi_1.default.object({
85
+ name: joi_1.default.string().required().description('Name of the object, e.g. input.'),
86
+ type: joi_1.default.string().valid(...record_1.Record.values(simple_input_classifier_1.InputType)).required().description('How reads of the object (or of its fields) are classified.'),
87
+ withParams: joi_1.default.array().items(joi_1.default.string()).optional().description('Only link the object if the function binding it declares all of these parameters as well.')
88
+ })).optional().description('Objects a framework provides without a definition in the code, e.g. shiny\'s input.'),
89
+ linkedEntryPoints: joi_1.default.array().items(joi_1.default.object({
90
+ call: joi_1.default.string().required().description('The call taking the function, e.g. shiny::shinyApp.'),
91
+ argName: joi_1.default.string().required().description('Name of the argument holding the function.'),
92
+ argIdx: joi_1.default.number().required().description('Index of that argument when it is passed positionally.'),
93
+ params: joi_1.default.array().items(joi_1.default.string().allow(null)).required().description('Which linkedObject the framework binds to each parameter, by position.')
94
+ })).optional().description('Calls that hand a function to a framework, which binds its objects to the parameters by position.')
77
95
  }).optional()
78
96
  }).description('Input Sources query definition'),
79
97
  flattenInvolvedNodes: (queryResults) => {
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The classification lattice of the {@link InputSourcesQuery|input-sources} analysis, kept free of any imports so
3
+ * that the configuration can name its members without pulling the analysis in.
4
+ * @module
5
+ */
6
+ /**
7
+ * Lattice flattening until we have a taint engine :)
8
+ * Please note that the classifier considers this basis with a set-lift,
9
+ * joining differing lattice elements.
10
+ *
11
+ *```
12
+ * [ Unknown ]
13
+ * |
14
+ * [Param] [File] [Net] [User], ...
15
+ * | | | |
16
+ * | [TempFile] | |
17
+ * +---------+------+------+- ...
18
+ * |
19
+ * [ DerivedConstant ]
20
+ * |
21
+ * [ Constant ]
22
+ *```
23
+ *
24
+ */
25
+ export declare enum InputType {
26
+ Parameter = "param",
27
+ File = "file",
28
+ /** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
29
+ TempFile = "tempfile",
30
+ Network = "net",
31
+ Random = "rand",
32
+ /** Calls to system/system2 and similar */
33
+ System = "system",
34
+ /** Calls to .C / Fortran interfaces (foreign function interfaces) */
35
+ Ffi = "ffi",
36
+ /** Language objects (quote/substitute/etc.) */
37
+ Lang = "lang",
38
+ /** Global options / option accessors (options, getOption) */
39
+ Options = "options",
40
+ /** Interactive user input (file choosers, prompts, dialogs, menu selections) */
41
+ User = "user",
42
+ Constant = "const",
43
+ /** Read from environment/call scope */
44
+ Scope = "scope",
45
+ /** Pure calculations from constants that lead to a constant */
46
+ DerivedConstant = "dconst",
47
+ Unknown = "unknown"
48
+ }
49
+ export declare enum InputTraceType {
50
+ /** Derived only from aliasing */
51
+ Alias = "alias",
52
+ /** Derived from pure function chains */
53
+ Pure = "pure",
54
+ /** Derived from known but not necessarily all pure function chains */
55
+ Known = "known",
56
+ /** Not fully known origin */
57
+ Unknown = "unknown"
58
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * The classification lattice of the {@link InputSourcesQuery|input-sources} analysis, kept free of any imports so
4
+ * that the configuration can name its members without pulling the analysis in.
5
+ * @module
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.InputTraceType = exports.InputType = void 0;
9
+ /**
10
+ * Lattice flattening until we have a taint engine :)
11
+ * Please note that the classifier considers this basis with a set-lift,
12
+ * joining differing lattice elements.
13
+ *
14
+ *```
15
+ * [ Unknown ]
16
+ * |
17
+ * [Param] [File] [Net] [User], ...
18
+ * | | | |
19
+ * | [TempFile] | |
20
+ * +---------+------+------+- ...
21
+ * |
22
+ * [ DerivedConstant ]
23
+ * |
24
+ * [ Constant ]
25
+ *```
26
+ *
27
+ */
28
+ var InputType;
29
+ (function (InputType) {
30
+ InputType["Parameter"] = "param";
31
+ InputType["File"] = "file";
32
+ /** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
33
+ InputType["TempFile"] = "tempfile";
34
+ InputType["Network"] = "net";
35
+ InputType["Random"] = "rand";
36
+ /** Calls to system/system2 and similar */
37
+ InputType["System"] = "system";
38
+ /** Calls to .C / Fortran interfaces (foreign function interfaces) */
39
+ InputType["Ffi"] = "ffi";
40
+ /** Language objects (quote/substitute/etc.) */
41
+ InputType["Lang"] = "lang";
42
+ /** Global options / option accessors (options, getOption) */
43
+ InputType["Options"] = "options";
44
+ /** Interactive user input (file choosers, prompts, dialogs, menu selections) */
45
+ InputType["User"] = "user";
46
+ InputType["Constant"] = "const";
47
+ /** Read from environment/call scope */
48
+ InputType["Scope"] = "scope";
49
+ /** Pure calculations from constants that lead to a constant */
50
+ InputType["DerivedConstant"] = "dconst";
51
+ InputType["Unknown"] = "unknown";
52
+ })(InputType || (exports.InputType = InputType = {}));
53
+ var InputTraceType;
54
+ (function (InputTraceType) {
55
+ /** Derived only from aliasing */
56
+ InputTraceType["Alias"] = "alias";
57
+ /** Derived from pure function chains */
58
+ InputTraceType["Pure"] = "pure";
59
+ /** Derived from known but not necessarily all pure function chains */
60
+ InputTraceType["Known"] = "known";
61
+ /** Not fully known origin */
62
+ InputTraceType["Unknown"] = "unknown";
63
+ })(InputTraceType || (exports.InputTraceType = InputTraceType = {}));
64
+ //# sourceMappingURL=input-types.js.map
@@ -1,60 +1,54 @@
1
1
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import { InputTraceType, InputType } from './input-types';
3
+ export { InputTraceType, InputType } from './input-types';
2
4
  import type { DataflowGraph } from '../../../dataflow/graph/graph';
3
5
  import type { MergeableRecord } from '../../../util/objects';
4
6
  import { Identifier } from '../../../dataflow/environments/identifier';
5
7
  import type { FlowrSearchLike } from '../../../search/flowr-search-builder';
6
8
  /**
7
- * Lattice flattening until we have a taint engine :)
8
- * Please note that the classifier considers this basis with a set-lift,
9
- * joining differing lattice elements.
10
- *
11
- *```
12
- * [ Unknown ]
13
- * |
14
- * [Param] [File] [Net] [User], ...
15
- * | | | |
16
- * | [TempFile] | |
17
- * +---------+------+------+- ...
18
- * |
19
- * [ DerivedConstant ]
20
- * |
21
- * [ Constant ]
22
- *```
23
- *
9
+ * An object that a framework hands to its users without any visible definition, like the `input` of a
10
+ * shiny server function. Reads of such an object (and of its fields) are classified as its given type,
11
+ * so traces link up to the framework instead of stopping at an opaque parameter.
24
12
  */
25
- export declare enum InputType {
26
- Parameter = "param",
27
- File = "file",
28
- /** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
29
- TempFile = "tempfile",
30
- Network = "net",
31
- Random = "rand",
32
- /** Calls to system/system2 and similar */
33
- System = "system",
34
- /** Calls to .C / Fortran interfaces (foreign function interfaces) */
35
- Ffi = "ffi",
36
- /** Language objects (quote/substitute/etc.) */
37
- Lang = "lang",
38
- /** Global options / option accessors (options, getOption) */
39
- Options = "options",
40
- /** Interactive user input (file choosers, prompts, dialogs, menu selections) */
41
- User = "user",
42
- Constant = "const",
43
- /** Read from environment/call scope */
44
- Scope = "scope",
45
- /** Pure calculations from constants that lead to a constant */
46
- DerivedConstant = "dconst",
47
- Unknown = "unknown"
13
+ export interface LinkedInputObject {
14
+ /** the name of the object, e.g. `input` */
15
+ readonly name: string;
16
+ /** how reads of the object (or of its fields) are to be classified */
17
+ readonly type: InputType;
18
+ /**
19
+ * If given, the object only counts as linked if the function binding it declares all of these parameters as well
20
+ * (e.g., shiny's `function(input, output, session)`). Without this, every `input` would be treated as the framework's.
21
+ */
22
+ readonly withParams?: readonly string[];
23
+ /** the package that has to be attached for this object to exist, e.g. `shiny` */
24
+ readonly requires?: string;
25
+ /** if given, only these fields are inputs (`session$clientData` is, `session$userData` is not) and the object itself is none */
26
+ readonly fields?: readonly string[];
27
+ /** how the framework declares the entries of this object, so a read of `input$n` links to the `textInput("n", …)` defining it */
28
+ readonly declaredBy?: LinkedInputDeclaration;
48
29
  }
49
- export declare enum InputTraceType {
50
- /** Derived only from aliasing */
51
- Alias = "alias",
52
- /** Derived from pure function chains */
53
- Pure = "pure",
54
- /** Derived from known but not necessarily all pure function chains */
55
- Known = "known",
56
- /** Not fully known origin */
57
- Unknown = "unknown"
30
+ /** The calls that declare the entries of a {@link LinkedInputObject}, and where they carry the entry's name. */
31
+ export interface LinkedInputDeclaration {
32
+ /** the declaring calls, e.g. shiny's `textInput`, `selectInput`, … */
33
+ readonly calls: readonly Identifier[];
34
+ /** the name of the argument holding the entry's name */
35
+ readonly argName: string;
36
+ /** the index of that argument when it is passed positionally */
37
+ readonly argIdx: number;
38
+ }
39
+ /**
40
+ * A call a framework is given a function through, binding its parameters *by position* - which is how R passes
41
+ * them, so this catches a `shinyApp(ui, function(i, o, s))` that no name-based rule can.
42
+ */
43
+ export interface LinkedInputEntryPoint {
44
+ /** the call taking the function, e.g. `shiny::shinyApp` */
45
+ readonly call: Identifier;
46
+ /** the name of the argument holding the function */
47
+ readonly argName: string;
48
+ /** the index of that argument when it is passed positionally */
49
+ readonly argIdx: number;
50
+ /** which {@link LinkedInputObject} the framework binds to each parameter, by position; `undefined` leaves one alone */
51
+ readonly params: readonly (string | undefined)[];
58
52
  }
59
53
  /**
60
54
  * Scalar R constant values representable in TypeScript.
@@ -72,10 +66,15 @@ export interface InputSource extends MergeableRecord {
72
66
  trace: InputTraceType;
73
67
  /** if the trace is affected by control dependencies, they are classified too, this is a duplicate free array */
74
68
  cds?: InputType[];
75
- /** argument name when this source originates from a named argument of the criterion function call */
69
+ /**
70
+ * Argument name when this source originates from a named argument of the criterion function call,
71
+ * or the accessed field when it originates from a {@link LinkedInputObject} (e.g. `n` for `input$n`).
72
+ */
76
73
  name?: string;
77
74
  /** the concrete scalar value when the source is a constant or a pure alias of one */
78
75
  value?: ConstantValue;
76
+ /** where the framework entry this source reads is declared, e.g. the `textInput("n", …)` behind an `input$n` */
77
+ declaredAt?: NodeId[];
79
78
  }
80
79
  /**
81
80
  * Map of input sources, keyed by the node id of the input source. Each input source is classified with an {@link InputSource} object.
@@ -94,6 +93,16 @@ export interface InputClassifierConfig<Functions extends InputClassifierFunction
94
93
  * Functions which are considered to be pure (i.e., deterministic, trusted, safe, idempotent on the lub of the input types)
95
94
  */
96
95
  [InputTraceType.Pure]?: Functions;
96
+ /**
97
+ * Objects provided by a framework rather than by the code itself, like shiny's `input`.
98
+ * @see {@link LinkedInputObject}
99
+ */
100
+ linkedObjects?: readonly LinkedInputObject[];
101
+ /**
102
+ * Calls that hand a function to a framework, which then binds {@link linkedObjects} to its parameters by position.
103
+ * @see {@link LinkedInputEntryPoint}
104
+ */
105
+ linkedEntryPoints?: readonly LinkedInputEntryPoint[];
97
106
  }
98
107
  /**
99
108
  * Takes the given id which is expected to either be:
@@ -101,6 +110,7 @@ export interface InputClassifierConfig<Functions extends InputClassifierFunction
101
110
  * - anything else - in that case the node itself is considered as an "input" - please note that in these scenarios the *return* value will only contain one mapping - that for the id you passed in.
102
111
  *
103
112
  * This method traces the dependencies in the dataflow graph using the specification of functions passed in.
104
- * For the scope escape analysis, pass on the full, non-reduced DFG as `fullDfg`.
113
+ * For the scope escape analysis, pass on the full, non-reduced DFG as `fullDfg`, and the packages attached in the
114
+ * program as `packages` so that bare calls only match the entries of packages that are actually in scope.
105
115
  */
106
- export declare function classifyInput(id: NodeId, dfg: DataflowGraph, config: InputClassifierConfig<InputClassifierFunctionIdentifiers>, fullDfg?: DataflowGraph): InputSources;
116
+ export declare function classifyInput(id: NodeId, dfg: DataflowGraph, config: InputClassifierConfig<InputClassifierFunctionIdentifiers>, fullDfg?: DataflowGraph, packages?: ReadonlySet<string>): InputSources;