@eagleoutice/flowr 2.2.15 → 2.3.0

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 (255) hide show
  1. package/README.md +226 -6
  2. package/abstract-interpretation/data-frame/absint-info.d.ts +109 -0
  3. package/abstract-interpretation/data-frame/absint-info.js +31 -0
  4. package/abstract-interpretation/data-frame/absint-visitor.d.ts +59 -0
  5. package/abstract-interpretation/data-frame/absint-visitor.js +173 -0
  6. package/abstract-interpretation/data-frame/domain.d.ts +107 -0
  7. package/abstract-interpretation/data-frame/domain.js +315 -0
  8. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +17 -0
  9. package/abstract-interpretation/data-frame/mappers/access-mapper.js +166 -0
  10. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +117 -0
  11. package/abstract-interpretation/data-frame/mappers/arguments.js +188 -0
  12. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +20 -0
  13. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +34 -0
  14. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +261 -0
  15. package/abstract-interpretation/data-frame/mappers/function-mapper.js +1219 -0
  16. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +12 -0
  17. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +206 -0
  18. package/abstract-interpretation/data-frame/resolve-args.d.ts +42 -0
  19. package/abstract-interpretation/data-frame/resolve-args.js +118 -0
  20. package/abstract-interpretation/data-frame/semantics.d.ts +213 -0
  21. package/abstract-interpretation/data-frame/semantics.js +366 -0
  22. package/abstract-interpretation/data-frame/shape-inference.d.ts +38 -0
  23. package/abstract-interpretation/data-frame/shape-inference.js +117 -0
  24. package/benchmark/slicer.d.ts +18 -2
  25. package/benchmark/slicer.js +143 -5
  26. package/benchmark/stats/print.js +123 -45
  27. package/benchmark/stats/size-of.d.ts +7 -0
  28. package/benchmark/stats/size-of.js +1 -0
  29. package/benchmark/stats/stats.d.ts +30 -1
  30. package/benchmark/stats/stats.js +4 -2
  31. package/benchmark/summarizer/data.d.ts +33 -2
  32. package/benchmark/summarizer/first-phase/input.js +5 -1
  33. package/benchmark/summarizer/first-phase/process.d.ts +2 -1
  34. package/benchmark/summarizer/first-phase/process.js +49 -3
  35. package/benchmark/summarizer/second-phase/process.js +101 -3
  36. package/cli/benchmark-app.d.ts +2 -0
  37. package/cli/benchmark-app.js +5 -1
  38. package/cli/benchmark-helper-app.d.ts +2 -0
  39. package/cli/benchmark-helper-app.js +13 -8
  40. package/cli/common/options.js +4 -0
  41. package/cli/export-quads-app.js +2 -1
  42. package/cli/flowr.js +58 -57
  43. package/cli/repl/commands/repl-cfg.js +13 -13
  44. package/cli/repl/commands/repl-commands.js +2 -2
  45. package/cli/repl/commands/repl-dataflow.js +10 -10
  46. package/cli/repl/commands/repl-execute.d.ts +2 -3
  47. package/cli/repl/commands/repl-execute.js +4 -4
  48. package/cli/repl/commands/repl-lineage.js +4 -4
  49. package/cli/repl/commands/repl-main.d.ts +12 -1
  50. package/cli/repl/commands/repl-normalize.js +6 -6
  51. package/cli/repl/commands/repl-parse.js +2 -2
  52. package/cli/repl/commands/repl-query.js +9 -9
  53. package/cli/repl/commands/repl-version.js +1 -1
  54. package/cli/repl/core.d.ts +5 -2
  55. package/cli/repl/core.js +10 -8
  56. package/cli/repl/server/connection.d.ts +3 -1
  57. package/cli/repl/server/connection.js +7 -5
  58. package/cli/repl/server/server.d.ts +3 -2
  59. package/cli/repl/server/server.js +4 -2
  60. package/cli/script-core/statistics-core.d.ts +2 -1
  61. package/cli/script-core/statistics-core.js +2 -2
  62. package/cli/script-core/statistics-helper-core.d.ts +2 -1
  63. package/cli/script-core/statistics-helper-core.js +5 -4
  64. package/cli/slicer-app.js +4 -2
  65. package/cli/statistics-app.js +2 -1
  66. package/cli/statistics-helper-app.js +2 -1
  67. package/config.d.ts +43 -10
  68. package/config.js +47 -43
  69. package/control-flow/cfg-dead-code.js +45 -2
  70. package/control-flow/cfg-simplification.d.ts +2 -0
  71. package/control-flow/control-flow-graph.d.ts +2 -0
  72. package/control-flow/control-flow-graph.js +8 -0
  73. package/control-flow/dfg-cfg-guided-visitor.d.ts +5 -3
  74. package/control-flow/dfg-cfg-guided-visitor.js +15 -4
  75. package/control-flow/extract-cfg.d.ts +4 -2
  76. package/control-flow/extract-cfg.js +4 -3
  77. package/control-flow/semantic-cfg-guided-visitor.d.ts +20 -2
  78. package/control-flow/semantic-cfg-guided-visitor.js +24 -4
  79. package/core/pipeline-executor.d.ts +4 -1
  80. package/core/pipeline-executor.js +6 -5
  81. package/core/steps/all/core/10-normalize.d.ts +2 -0
  82. package/core/steps/all/core/10-normalize.js +1 -1
  83. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
  84. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
  85. package/core/steps/all/core/20-dataflow.d.ts +2 -1
  86. package/core/steps/all/core/20-dataflow.js +2 -2
  87. package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
  88. package/core/steps/all/static-slicing/00-slice.js +2 -2
  89. package/core/steps/pipeline/default-pipelines.d.ts +32 -31
  90. package/core/steps/pipeline/default-pipelines.js +8 -8
  91. package/core/steps/pipeline-step.d.ts +2 -1
  92. package/dataflow/environments/built-in-config.d.ts +3 -3
  93. package/dataflow/environments/built-in.d.ts +11 -3
  94. package/dataflow/environments/built-in.js +5 -3
  95. package/dataflow/environments/default-builtin-config.js +4 -2
  96. package/dataflow/environments/define.d.ts +2 -1
  97. package/dataflow/environments/define.js +4 -5
  98. package/dataflow/environments/remove.d.ts +6 -0
  99. package/dataflow/environments/remove.js +29 -0
  100. package/dataflow/eval/resolve/alias-tracking.d.ts +7 -2
  101. package/dataflow/eval/resolve/alias-tracking.js +11 -8
  102. package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
  103. package/dataflow/eval/resolve/resolve-argument.js +118 -0
  104. package/dataflow/eval/resolve/resolve.d.ts +65 -18
  105. package/dataflow/eval/resolve/resolve.js +144 -48
  106. package/dataflow/eval/values/string/string-constants.d.ts +1 -1
  107. package/dataflow/eval/values/string/string-constants.js +7 -2
  108. package/dataflow/extractor.d.ts +2 -1
  109. package/dataflow/extractor.js +2 -1
  110. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
  111. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  112. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  113. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +11 -11
  114. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +10 -11
  115. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
  116. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
  117. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
  118. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  119. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  120. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +6 -3
  121. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -15
  122. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
  123. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  124. package/dataflow/internal/process/functions/call/common.js +1 -1
  125. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  126. package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
  127. package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
  128. package/dataflow/processor.d.ts +5 -0
  129. package/documentation/doc-util/doc-cfg.js +4 -3
  130. package/documentation/doc-util/doc-code.d.ts +1 -1
  131. package/documentation/doc-util/doc-dfg.js +3 -2
  132. package/documentation/doc-util/doc-functions.d.ts +24 -0
  133. package/documentation/doc-util/doc-functions.js +65 -0
  134. package/documentation/doc-util/doc-normalized-ast.js +3 -2
  135. package/documentation/doc-util/doc-print.d.ts +5 -0
  136. package/documentation/doc-util/doc-print.js +36 -0
  137. package/documentation/doc-util/doc-query.js +13 -2
  138. package/documentation/doc-util/doc-repl.js +2 -1
  139. package/documentation/doc-util/doc-search.js +3 -2
  140. package/documentation/doc-util/doc-types.d.ts +28 -6
  141. package/documentation/doc-util/doc-types.js +89 -45
  142. package/documentation/print-cfg-wiki.js +6 -7
  143. package/documentation/print-core-wiki.js +5 -5
  144. package/documentation/print-dataflow-graph-wiki.js +10 -10
  145. package/documentation/print-engines-wiki.js +1 -2
  146. package/documentation/print-faq-wiki.js +8 -2
  147. package/documentation/print-interface-wiki.js +12 -2
  148. package/documentation/print-linter-issue.d.ts +1 -0
  149. package/documentation/print-linter-issue.js +71 -0
  150. package/documentation/print-linter-wiki.js +223 -34
  151. package/documentation/print-linting-and-testing-wiki.js +2 -4
  152. package/documentation/print-normalized-ast-wiki.js +3 -3
  153. package/documentation/print-query-wiki.js +18 -2
  154. package/documentation/print-readme.js +24 -1
  155. package/documentation/print-search-wiki.js +1 -2
  156. package/linter/linter-executor.d.ts +3 -1
  157. package/linter/linter-executor.js +3 -2
  158. package/linter/linter-format.d.ts +67 -7
  159. package/linter/linter-format.js +12 -1
  160. package/linter/linter-rules.d.ts +178 -16
  161. package/linter/linter-rules.js +14 -4
  162. package/linter/linter-tags.d.ts +80 -0
  163. package/linter/linter-tags.js +85 -0
  164. package/linter/rules/absolute-path.d.ts +71 -0
  165. package/linter/rules/absolute-path.js +177 -0
  166. package/linter/rules/dataframe-access-validation.d.ts +53 -0
  167. package/linter/rules/dataframe-access-validation.js +116 -0
  168. package/linter/rules/deprecated-functions.d.ts +43 -0
  169. package/linter/rules/deprecated-functions.js +58 -0
  170. package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
  171. package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
  172. package/linter/rules/naming-convention.d.ts +71 -0
  173. package/linter/rules/naming-convention.js +168 -0
  174. package/linter/rules/seeded-randomness.d.ts +65 -0
  175. package/linter/rules/seeded-randomness.js +122 -0
  176. package/linter/rules/unused-definition.d.ts +41 -0
  177. package/linter/rules/unused-definition.js +105 -0
  178. package/package.json +5 -2
  179. package/queries/base-query-format.d.ts +2 -0
  180. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  181. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  182. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  183. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  184. package/queries/catalog/config-query/config-query-executor.js +2 -3
  185. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  186. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -2
  187. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
  188. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  189. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  190. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -116
  191. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  192. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +3 -0
  193. package/queries/catalog/df-shape-query/df-shape-query-executor.js +46 -0
  194. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +72 -0
  195. package/queries/catalog/df-shape-query/df-shape-query-format.js +31 -0
  196. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  197. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  198. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
  199. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  200. package/queries/catalog/linter-query/linter-query-executor.js +2 -2
  201. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  202. package/queries/catalog/linter-query/linter-query-format.js +16 -12
  203. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  204. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  205. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  206. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  207. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  208. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  209. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  210. package/queries/catalog/search-query/search-query-executor.js +2 -2
  211. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  212. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  213. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
  214. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  215. package/queries/query.d.ts +76 -16
  216. package/queries/query.js +2 -0
  217. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
  218. package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
  219. package/r-bridge/lang-4.x/convert-values.js +2 -1
  220. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
  221. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  222. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
  223. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +7 -5
  224. package/r-bridge/shell.d.ts +3 -2
  225. package/r-bridge/shell.js +4 -5
  226. package/search/flowr-search-builder.d.ts +6 -2
  227. package/search/flowr-search-builder.js +7 -0
  228. package/search/flowr-search-filters.d.ts +32 -8
  229. package/search/flowr-search-filters.js +42 -15
  230. package/search/flowr-search.d.ts +4 -0
  231. package/search/search-executor/search-enrichers.d.ts +7 -3
  232. package/search/search-executor/search-enrichers.js +29 -20
  233. package/search/search-executor/search-generators.js +1 -1
  234. package/search/search-executor/search-transformer.d.ts +2 -0
  235. package/search/search-executor/search-transformer.js +10 -1
  236. package/slicing/static/static-slicer.d.ts +1 -1
  237. package/slicing/static/static-slicer.js +2 -3
  238. package/statistics/statistics.d.ts +3 -1
  239. package/statistics/statistics.js +5 -4
  240. package/util/containers.d.ts +12 -9
  241. package/util/containers.js +12 -9
  242. package/util/files.d.ts +8 -2
  243. package/util/files.js +22 -4
  244. package/util/objects.d.ts +5 -4
  245. package/util/r-value.d.ts +23 -0
  246. package/util/r-value.js +113 -0
  247. package/util/range.d.ts +5 -1
  248. package/util/range.js +11 -3
  249. package/util/text/strings.d.ts +6 -0
  250. package/util/text/strings.js +35 -0
  251. package/util/version.js +1 -1
  252. package/linter/rules/1-deprecated-functions.d.ts +0 -34
  253. package/linter/rules/1-deprecated-functions.js +0 -54
  254. package/util/cfg/cfg.d.ts +0 -0
  255. package/util/cfg/cfg.js +0 -2
@@ -42,7 +42,7 @@ function isBuiltIn(name) {
42
42
  return String(name).startsWith('built-in:');
43
43
  }
44
44
  function defaultBuiltInProcessor(name, args, rootId, data, config) {
45
- const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'builtin:default' });
45
+ const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: config.useAsProcessor ?? 'builtin:default' });
46
46
  if (config.returnsNthArgument !== undefined) {
47
47
  const arg = config.returnsNthArgument === 'last' ? processedArguments[args.length - 1] : processedArguments[config.returnsNthArgument];
48
48
  if (arg !== undefined) {
@@ -90,7 +90,7 @@ function defaultBuiltInProcessor(name, args, rootId, data, config) {
90
90
  environment: data.environment,
91
91
  onlyBuiltin: false,
92
92
  cds: data.controlDependencies,
93
- origin: ['builtin:default']
93
+ origin: [config.useAsProcessor ?? 'builtin:default']
94
94
  });
95
95
  }
96
96
  }
@@ -144,7 +144,9 @@ exports.BuiltInProcessorMapper = {
144
144
  };
145
145
  exports.BuiltInEvalHandlerMapper = {
146
146
  'built-in:c': resolve_1.resolveAsVector,
147
- 'builtin:vector': resolve_1.resolveAsVector
147
+ 'built-in::': resolve_1.resolveAsSeq,
148
+ 'built-in:+': resolve_1.resolveAsPlus,
149
+ 'built-in:-': resolve_1.resolveAsMinus
148
150
  };
149
151
  exports.BuiltInMemory = new Map();
150
152
  exports.EmptyBuiltInMemory = new Map();
@@ -102,7 +102,7 @@ exports.DefaultBuiltinConfig = [
102
102
  '~', '+', '-', '*', '/', '^', '!', '?', '**', '==', '!=', '>', '<', '>=', '<=', '%%', '%/%', '%*%', '%in%', ':',
103
103
  'rep', 'seq', 'seq_len', 'seq_along', 'seq.int', 'gsub', 'which', 'class', 'dimnames', 'min', 'max',
104
104
  'intersect', 'subset', 'match', 'sqrt', 'abs', 'round', 'floor', 'ceiling', 'signif', 'trunc', 'log', 'log10', 'log2', 'sum', 'mean',
105
- 'unique', 'paste', 'paste0', 'read.csv', 'stop', 'is.null', 'numeric', 'as.character', 'as.integer', 'as.logical', 'as.numeric', 'as.matrix',
105
+ 'unique', 'paste', 'paste0', 'read.csv', 'is.null', 'numeric', 'as.character', 'as.integer', 'as.logical', 'as.numeric', 'as.matrix',
106
106
  'rbind', 'nrow', 'ncol', 'tryCatch', 'expression', 'factor',
107
107
  'missing', 'as.data.frame', 'data.frame', 'na.omit', 'rownames', 'names', 'order', 'length', 'any', 'dim', 'matrix', 'cbind', 'nchar',
108
108
  'pdf', 'jpeg', 'png', 'windows', 'postscript', 'xfig', 'bitmap', 'pictex', 'cairo_pdf', 'svg', 'bmp', 'tiff', 'X11', 'quartz',
@@ -215,7 +215,9 @@ exports.DefaultBuiltinConfig = [
215
215
  { type: 'function', names: ['eval'], processor: 'builtin:eval', config: { includeFunctionCall: true }, assumePrimitive: true },
216
216
  { type: 'function', names: ['cat'], processor: 'builtin:default', config: { forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
217
217
  { type: 'function', names: ['switch'], processor: 'builtin:default', config: { forceArgs: [true] }, assumePrimitive: false },
218
- { type: 'function', names: ['return'], processor: 'builtin:default', config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return */ }, assumePrimitive: false },
218
+ { type: 'function', names: ['return'], processor: 'builtin:default', config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return */, useAsProcessor: 'builtin:return' }, assumePrimitive: false },
219
+ { type: 'function', names: ['stop'], processor: 'builtin:default', config: { useAsProcessor: 'builtin:stop' }, assumePrimitive: false },
220
+ { type: 'function', names: ['stopifnot'], processor: 'builtin:default', config: { useAsProcessor: 'builtin:stopifnot' }, assumePrimitive: false },
219
221
  { type: 'function', names: ['break'], processor: 'builtin:default', config: { cfg: 2 /* ExitPointType.Break */ }, assumePrimitive: false },
220
222
  { type: 'function', names: ['next'], processor: 'builtin:default', config: { cfg: 3 /* ExitPointType.Next */ }, assumePrimitive: false },
221
223
  { type: 'function', names: ['{'], processor: 'builtin:expression-list', config: {}, assumePrimitive: true },
@@ -1,5 +1,6 @@
1
1
  import type { REnvironmentInformation } from './environment';
2
2
  import type { IdentifierDefinition, InGraphIdentifierDefinition } from './identifier';
3
+ import type { FlowrConfigOptions } from '../../config';
3
4
  /**
4
5
  * assumes: existing is not undefined, the overwrite has indices
5
6
  */
@@ -8,4 +9,4 @@ export declare function mergeDefinitions(existing: readonly IdentifierDefinition
8
9
  * Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
9
10
  * Does not modify the passed along `environments` in-place! It returns the new reference.
10
11
  */
11
- export declare function define(definition: IdentifierDefinition, superAssign: boolean | undefined, environment: REnvironmentInformation): REnvironmentInformation;
12
+ export declare function define(definition: IdentifierDefinition, superAssign: boolean | undefined, environment: REnvironmentInformation, config: FlowrConfigOptions): REnvironmentInformation;
@@ -6,12 +6,11 @@ const assert_1 = require("../../util/assert");
6
6
  const environment_1 = require("./environment");
7
7
  const clone_1 = require("./clone");
8
8
  const vertex_1 = require("../graph/vertex");
9
- const config_1 = require("../../config");
10
- function defInEnv(newEnvironments, name, definition) {
9
+ function defInEnv(newEnvironments, name, definition, config) {
11
10
  const existing = newEnvironments.memory.get(name);
12
11
  // When there are defined indices, merge the definitions
13
12
  const inGraphDefinition = definition;
14
- if ((0, config_1.getConfig)().solver.pointerTracking &&
13
+ if (config.solver.pointerTracking &&
15
14
  existing !== undefined &&
16
15
  inGraphDefinition.controlDependencies === undefined) {
17
16
  if (inGraphDefinition.indicesCollection !== undefined) {
@@ -122,7 +121,7 @@ function overwriteContainerIndices(existingIndices, overwriteIndex) {
122
121
  * Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
123
122
  * Does not modify the passed along `environments` in-place! It returns the new reference.
124
123
  */
125
- function define(definition, superAssign, environment) {
124
+ function define(definition, superAssign, environment, config) {
126
125
  const name = definition.name;
127
126
  (0, assert_1.guard)(name !== undefined, () => `Name must be defined, but isn't for ${JSON.stringify(definition)}`);
128
127
  let newEnvironment;
@@ -147,7 +146,7 @@ function define(definition, superAssign, environment) {
147
146
  }
148
147
  else {
149
148
  newEnvironment = (0, clone_1.cloneEnvironmentInformation)(environment, false);
150
- defInEnv(newEnvironment.current, name, definition);
149
+ defInEnv(newEnvironment.current, name, definition, config);
151
150
  }
152
151
  return newEnvironment;
153
152
  }
@@ -1,6 +1,12 @@
1
1
  import type { REnvironmentInformation } from './environment';
2
2
  import type { Identifier } from './identifier';
3
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
4
  /**
4
5
  * Removes all definitions of a given name from the environment.
5
6
  */
6
7
  export declare function remove(name: Identifier, environment: REnvironmentInformation): REnvironmentInformation;
8
+ /** Creates a copy of the original environment but without the definitions of the given ids */
9
+ export declare function removeAll(definitions: readonly {
10
+ nodeId: NodeId;
11
+ name: Identifier | undefined;
12
+ }[], environment: REnvironmentInformation): REnvironmentInformation;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.remove = remove;
4
+ exports.removeAll = removeAll;
4
5
  const environment_1 = require("./environment");
5
6
  const info_1 = require("../info");
7
+ const clone_1 = require("./clone");
6
8
  /**
7
9
  * Removes all definitions of a given name from the environment.
8
10
  */
@@ -21,4 +23,31 @@ function remove(name, environment) {
21
23
  // we never remove built ins
22
24
  return environment;
23
25
  }
26
+ /** Creates a copy of the original environment but without the definitions of the given ids */
27
+ function removeAll(definitions, environment) {
28
+ environment = (0, clone_1.cloneEnvironmentInformation)(environment, true);
29
+ let current = environment.current;
30
+ do {
31
+ for (const { nodeId, name } of definitions) {
32
+ if (name) {
33
+ current.memory.delete(name);
34
+ }
35
+ else {
36
+ // remove all definitions for the node id
37
+ for (const [key, values] of current.memory) {
38
+ const res = values.filter(v => v.nodeId === nodeId);
39
+ if (res.length > 0) {
40
+ current.memory.set(key, values);
41
+ }
42
+ else {
43
+ current.memory.delete(key);
44
+ }
45
+ }
46
+ }
47
+ }
48
+ current = current.parent;
49
+ } while (current.id !== environment_1.BuiltInEnvironment.id);
50
+ // we never remove built ins so we can stop one early
51
+ return environment;
52
+ }
24
53
  //# sourceMappingURL=remove.js.map
@@ -1,3 +1,4 @@
1
+ import { VariableResolve } from '../../../config';
1
2
  import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
3
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
4
  import type { REnvironmentInformation } from '../../environments/environment';
@@ -14,6 +15,8 @@ export interface ResolveInfo {
14
15
  graph?: DataflowGraph;
15
16
  /** Whether to track variables */
16
17
  full?: boolean;
18
+ /** Variable resolve mode */
19
+ resolve: VariableResolve;
17
20
  }
18
21
  /**
19
22
  * Gets the definitions / aliases of a node
@@ -48,8 +51,9 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
48
51
  * @param graph - The graph to resolve in
49
52
  * @param idMap - The id map to resolve the node if given as an id
50
53
  * @param full - Whether to track aliases on resolve
54
+ * @param resolve - Variable resolve mode
51
55
  */
52
- export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full }: ResolveInfo): ResolveResult;
56
+ export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, resolve }: ResolveInfo): ResolveResult;
53
57
  /**
54
58
  * Please use {@link resolveIdToValue}
55
59
  *
@@ -57,13 +61,14 @@ export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefine
57
61
  * {@link getAliases} function) to resolve a node to a value.
58
62
  *
59
63
  *
64
+ * @param resolve - Variable resolve mode
60
65
  * @param identifier - Identifier to resolve
61
66
  * @param use - Environment to use
62
67
  * @param graph - Dataflow graph
63
68
  * @param idMap - id map of Dataflow graph
64
69
  * @returns Value of Identifier or Top
65
70
  */
66
- export declare function trackAliasInEnvironments(identifier: Identifier | undefined, use: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ResolveResult;
71
+ export declare function trackAliasInEnvironments(resolve: VariableResolve, identifier: Identifier | undefined, use: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ResolveResult;
67
72
  /**
68
73
  * Please use {@link resolveIdToValue}
69
74
  *
@@ -115,8 +115,9 @@ function getAliases(sourceIds, dataflow, environment) {
115
115
  * @param graph - The graph to resolve in
116
116
  * @param idMap - The id map to resolve the node if given as an id
117
117
  * @param full - Whether to track aliases on resolve
118
+ * @param resolve - Variable resolve mode
118
119
  */
119
- function resolveIdToValue(id, { environment, graph, idMap, full = true }) {
120
+ function resolveIdToValue(id, { environment, graph, idMap, full = true, resolve }) {
120
121
  if (id === undefined) {
121
122
  return r_value_1.Top;
122
123
  }
@@ -129,16 +130,18 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true }) {
129
130
  case type_1.RType.Argument:
130
131
  case type_1.RType.Symbol:
131
132
  if (environment) {
132
- return full ? trackAliasInEnvironments(node.lexeme, environment, graph, idMap) : r_value_1.Top;
133
+ return full ? trackAliasInEnvironments(resolve, node.lexeme, environment, graph, idMap) : r_value_1.Top;
133
134
  }
134
- else if (graph && (0, config_1.getConfig)().solver.variables === config_1.VariableResolve.Alias) {
135
+ else if (graph && resolve === config_1.VariableResolve.Alias) {
135
136
  return full ? trackAliasesInGraph(node.info.id, graph, idMap) : r_value_1.Top;
136
137
  }
137
138
  else {
138
139
  return r_value_1.Top;
139
140
  }
140
141
  case type_1.RType.FunctionCall:
141
- return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)(node, environment, graph, idMap));
142
+ case type_1.RType.BinaryOp:
143
+ case type_1.RType.UnaryOp:
144
+ return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)(resolve, node, environment, graph, idMap));
142
145
  case type_1.RType.String:
143
146
  case type_1.RType.Number:
144
147
  case type_1.RType.Logical:
@@ -154,13 +157,14 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true }) {
154
157
  * {@link getAliases} function) to resolve a node to a value.
155
158
  *
156
159
  *
160
+ * @param resolve - Variable resolve mode
157
161
  * @param identifier - Identifier to resolve
158
162
  * @param use - Environment to use
159
163
  * @param graph - Dataflow graph
160
164
  * @param idMap - id map of Dataflow graph
161
165
  * @returns Value of Identifier or Top
162
166
  */
163
- function trackAliasInEnvironments(identifier, use, graph, idMap) {
167
+ function trackAliasInEnvironments(resolve, identifier, use, graph, idMap) {
164
168
  if (identifier === undefined) {
165
169
  return r_value_1.Top;
166
170
  }
@@ -184,7 +188,7 @@ function trackAliasInEnvironments(identifier, use, graph, idMap) {
184
188
  for (const alias of def.value) {
185
189
  const definitionOfAlias = idMap?.get(alias);
186
190
  if (definitionOfAlias !== undefined) {
187
- const value = (0, resolve_1.resolveNode)(definitionOfAlias, use, graph, idMap);
191
+ const value = (0, resolve_1.resolveNode)(resolve, definitionOfAlias, use, graph, idMap);
188
192
  if ((0, r_value_1.isTop)(value)) {
189
193
  return r_value_1.Top;
190
194
  }
@@ -198,6 +202,7 @@ function trackAliasInEnvironments(identifier, use, graph, idMap) {
198
202
  }
199
203
  return (0, set_constants_1.setFrom)(...values);
200
204
  }
205
+ /** given an unknown alias, we have to clear all values in the environments */
201
206
  (0, unknown_side_effect_1.onUnknownSideEffect)((_graph, env, _id, target) => {
202
207
  if (target) {
203
208
  return;
@@ -258,8 +263,6 @@ function isNestedInLoop(node, ast) {
258
263
  function trackAliasesInGraph(id, graph, idMap) {
259
264
  idMap ??= graph.idMap;
260
265
  (0, assert_1.guard)(idMap !== undefined, 'The ID map is required to get the lineage of a node');
261
- const start = graph.getVertex(id);
262
- (0, assert_1.guard)(start !== undefined, 'Unable to find start for alias tracking');
263
266
  const queue = new visiting_queue_1.VisitingQueue(25);
264
267
  const clean = (0, environment_1.initializeCleanEnvironments)();
265
268
  const cleanFingerprint = (0, fingerprint_1.envFingerprint)(clean);
@@ -0,0 +1,8 @@
1
+ import type { DataflowGraph } from '../../graph/graph';
2
+ import type { DataflowGraphVertexFunctionCall } from '../../graph/vertex';
3
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
+ import type { VariableResolve } from '../../../config';
5
+ /**
6
+ * Get the values of all arguments matching the criteria.
7
+ */
8
+ export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined): Map<NodeId, Set<string | undefined>> | undefined;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getArgumentStringValue = getArgumentStringValue;
4
+ const graph_1 = require("../../graph/graph");
5
+ const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
6
+ const assert_1 = require("../../../util/assert");
7
+ const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
8
+ const dependencies_query_format_1 = require("../../../queries/catalog/dependencies-query/dependencies-query-format");
9
+ const general_1 = require("../values/general");
10
+ const alias_tracking_1 = require("./alias-tracking");
11
+ const r_value_1 = require("../values/r-value");
12
+ const convert_values_1 = require("../../../r-bridge/lang-4.x/convert-values");
13
+ const string_constants_1 = require("../values/string/string-constants");
14
+ /**
15
+ * Get the values of all arguments matching the criteria.
16
+ */
17
+ function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue) {
18
+ if (argumentName) {
19
+ const arg = vertex?.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && arg.name === argumentName);
20
+ if (arg >= 0) {
21
+ argumentIndex = arg;
22
+ }
23
+ }
24
+ if (!vertex || argumentIndex === undefined) {
25
+ return undefined;
26
+ }
27
+ if (argumentIndex === 'unnamed') {
28
+ // return all unnamed arguments
29
+ const references = vertex.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.getReferenceOfArgument).filter(assert_1.isNotUndefined);
30
+ const map = new Map();
31
+ for (const ref of references) {
32
+ let valueNode = graph.idMap?.get(ref);
33
+ if (valueNode?.type === type_1.RType.Argument) {
34
+ valueNode = valueNode.value;
35
+ }
36
+ if (valueNode) {
37
+ // this should be evaluated in the callee-context
38
+ const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue) ?? [dependencies_query_format_1.Unknown];
39
+ map.set(ref, new Set(values));
40
+ }
41
+ }
42
+ return map;
43
+ }
44
+ if (argumentIndex < vertex.args.length) {
45
+ const arg = (0, graph_1.getReferenceOfArgument)(vertex.args[argumentIndex]);
46
+ if (!arg) {
47
+ return undefined;
48
+ }
49
+ let valueNode = graph.idMap?.get(arg);
50
+ if (valueNode?.type === type_1.RType.Argument) {
51
+ valueNode = valueNode.value;
52
+ }
53
+ if (valueNode) {
54
+ const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, vertex.environment, graph.idMap, resolveValue) ?? [dependencies_query_format_1.Unknown];
55
+ return new Map([[arg, new Set(values)]]);
56
+ }
57
+ }
58
+ return undefined;
59
+ }
60
+ function hasCharacterOnly(variableResolve, graph, vertex, idMap) {
61
+ if (!vertex.args || vertex.args.length === 0 || !idMap) {
62
+ return false;
63
+ }
64
+ const treatAsChar = getArgumentStringValue(variableResolve, graph, vertex, 5, 'character.only', true);
65
+ if (!treatAsChar) {
66
+ return false;
67
+ }
68
+ const hasTrue = [...treatAsChar.values()].some(set => set?.has('TRUE'));
69
+ const hasFalse = hasTrue ? [...treatAsChar.values()].some(set => set === undefined || set.has('FALSE')) : false;
70
+ if (hasTrue && hasFalse) {
71
+ return 'maybe';
72
+ }
73
+ else {
74
+ return hasTrue;
75
+ }
76
+ }
77
+ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, environment, idMap, resolveValue) {
78
+ let full = true;
79
+ if (!resolveValue) {
80
+ full = false;
81
+ }
82
+ if (resolveValue === 'library') {
83
+ const hasChar = hasCharacterOnly(variableResolve, graph, vertex, idMap);
84
+ if (hasChar === false) {
85
+ if (argument.type === type_1.RType.Symbol) {
86
+ return [argument.lexeme];
87
+ }
88
+ full = false;
89
+ }
90
+ }
91
+ const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(argument, { environment, graph, full, resolve: variableResolve }));
92
+ if (resolved) {
93
+ const values = [];
94
+ for (const value of resolved.elements) {
95
+ if (!(0, r_value_1.isValue)(value)) {
96
+ return undefined;
97
+ }
98
+ else if (value.type === 'string' && (0, r_value_1.isValue)(value.value)) {
99
+ values.push(value.value.str);
100
+ }
101
+ else if (value.type === 'logical' && (0, r_value_1.isValue)(value.value)) {
102
+ values.push(value.value.valueOf() ? convert_values_1.RTrue : convert_values_1.RFalse);
103
+ }
104
+ else if (value.type === 'vector' && (0, r_value_1.isValue)(value.elements)) {
105
+ const elements = (0, string_constants_1.collectStrings)(value.elements, !full);
106
+ if (elements === undefined) {
107
+ return undefined;
108
+ }
109
+ values.push(...elements);
110
+ }
111
+ else {
112
+ return undefined;
113
+ }
114
+ }
115
+ return values;
116
+ }
117
+ }
118
+ //# sourceMappingURL=resolve-argument.js.map
@@ -1,34 +1,81 @@
1
1
  import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import type { REnvironmentInformation } from '../../environments/environment';
3
3
  import type { DataflowGraph } from '../../graph/graph';
4
- import type { Value } from '../values/r-value';
4
+ import type { Lift, Value, ValueNumber, ValueVector } from '../values/r-value';
5
+ import { Top } from '../values/r-value';
6
+ import type { VariableResolve } from '../../../config';
5
7
  /**
6
8
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
7
- * you want to resolve the value of a identifier / node
9
+ * you want to resolve the value of an identifier / node
8
10
  *
9
- * This function converts an RNode to its Value, but also recursivly resolves
11
+ * This function converts an RNode to its Value, but also recursively resolves
10
12
  * aliases and vectors (in case of a vector).
11
13
  *
12
- * @param a - Ast node to resolve
13
- * @param env - Environment to use
14
- * @param graph - Dataflow Graph to use
15
- * @param map - Idmap of Dataflow Graph
14
+ * @param a - Ast node to resolve
15
+ * @param resolve - Variable resolve mode
16
+ * @param env - Environment to use
17
+ * @param graph - Dataflow Graph to use
18
+ * @param map - Idmap of Dataflow Graph
16
19
  * @returns resolved value or top/bottom
17
20
  */
18
- export declare function resolveNode(a: RNodeWithParent, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
21
+ export declare function resolveNode(resolve: VariableResolve, a: RNodeWithParent, env?: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
19
22
  /**
20
23
  * Helper function used by {@link resolveIdToValue}, please use that instead, if
21
- * you want to resolve the value of a identifier / node
24
+ * you want to resolve the value of an identifier / node
22
25
  *
23
- * This function converts an rnode to a Value Vector {@link vectorFrom}
24
- * It also recursivly resolves any symbols, values, function calls (only c), in
25
- * order to construct the value of the vector to resolve by calling {@link resolveIdToValue}
26
- * or {@link resolveNode}
26
+ * This function resolves a vector function call `c` to a {@link ValueVector}
27
+ * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
27
28
  *
28
- * @param a - Node of the vector to resolve
29
- * @param env - Environment to use
30
- * @param graph - Dataflow graph
31
- * @param map - Idmap of Dataflow Graph
29
+ * @param resolve - Variable resolve mode
30
+ * @param node - Node of the vector function to resolve
31
+ * @param env - Environment to use
32
+ * @param graph - Dataflow graph
33
+ * @param map - Id map of the dataflow graph
32
34
  * @returns ValueVector or Top
33
35
  */
34
- export declare function resolveAsVector(a: RNodeWithParent, env: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap): Value;
36
+ export declare function resolveAsVector(resolve: VariableResolve, node: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueVector<Lift<Value[]>> | typeof Top;
37
+ /**
38
+ * Helper function used by {@link resolveIdToValue}, please use that instead, if
39
+ * you want to resolve the value of an identifier / node
40
+ *
41
+ * This function resolves a binary sequence operator `:` to a {@link ValueVector} of {@link ValueNumber}s
42
+ * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
43
+ *
44
+ * @param resolve - Variable resolve mode
45
+ * @param operator - Node of the sequence operator to resolve
46
+ * @param env - Environment to use
47
+ * @param graph - Dataflow graph
48
+ * @param map - Id map of the dataflow graph
49
+ * @returns ValueVector of ValueNumbers or Top
50
+ */
51
+ export declare function resolveAsSeq(resolve: VariableResolve, operator: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueVector<Lift<ValueNumber[]>> | typeof Top;
52
+ /**
53
+ * Helper function used by {@link resolveIdToValue}, please use that instead, if
54
+ * you want to resolve the value of an identifier / node
55
+ *
56
+ * This function resolves a unary plus operator `+` to a {@link ValueNumber} or {@link ValueVector} of ValueNumbers
57
+ * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
58
+ *
59
+ * @param resolve - Variable resolve mode
60
+ * @param operator - Node of the plus operator to resolve
61
+ * @param env - Environment to use
62
+ * @param graph - Dataflow graph
63
+ * @param map - Id map of the dataflow graph
64
+ * @returns ValueNumber, ValueVector of ValueNumbers, or Top
65
+ */
66
+ export declare function resolveAsPlus(resolve: VariableResolve, operator: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;
67
+ /**
68
+ * Helper function used by {@link resolveIdToValue}, please use that instead, if
69
+ * you want to resolve the value of an identifier / node
70
+ *
71
+ * This function resolves a unary minus operator `-` to a {@link ValueNumber} or {@link ValueVector} of ValueNumbers
72
+ * by recursively resolving the values of the arguments by calling {@link resolveIdToValue}
73
+ *
74
+ * @param resolve - Variable resolve mode
75
+ * @param operator - Node of the minus operator to resolve
76
+ * @param env - Environment to use
77
+ * @param graph - Dataflow graph
78
+ * @param map - Id map of the dataflow graph
79
+ * @returns ValueNumber, ValueVector of ValueNumbers, or Top
80
+ */
81
+ export declare function resolveAsMinus(resolve: VariableResolve, operator: RNodeWithParent, environment?: REnvironmentInformation, graph?: DataflowGraph, idMap?: AstIdMap): ValueNumber | ValueVector<Lift<ValueNumber[]>> | typeof Top;