@eagleoutice/flowr 2.4.7 → 2.5.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 (101) hide show
  1. package/README.md +48 -38
  2. package/abstract-interpretation/data-frame/absint-visitor.js +3 -2
  3. package/benchmark/slicer.js +2 -2
  4. package/benchmark/summarizer/first-phase/process.js +1 -1
  5. package/benchmark/summarizer/second-phase/graph.js +2 -2
  6. package/cli/repl/commands/repl-query.js +11 -2
  7. package/cli/repl/core.d.ts +2 -2
  8. package/cli/repl/core.js +26 -7
  9. package/cli/repl/server/connection.js +3 -1
  10. package/cli/repl/server/messages/message-slice.d.ts +3 -0
  11. package/cli/repl/server/messages/message-slice.js +2 -0
  12. package/cli/slicer-app.js +7 -2
  13. package/control-flow/extract-cfg.d.ts +3 -3
  14. package/control-flow/extract-cfg.js +4 -4
  15. package/control-flow/useless-loop.js +30 -21
  16. package/dataflow/environments/built-in.d.ts +1 -1
  17. package/dataflow/environments/default-builtin-config.d.ts +9 -0
  18. package/dataflow/environments/default-builtin-config.js +21 -21
  19. package/dataflow/environments/environment.js +18 -9
  20. package/dataflow/environments/overwrite.js +2 -2
  21. package/dataflow/extractor.js +1 -1
  22. package/dataflow/graph/diff-dataflow-graph.js +4 -4
  23. package/dataflow/graph/graph.d.ts +3 -3
  24. package/dataflow/graph/graph.js +4 -1
  25. package/dataflow/graph/quads.js +4 -4
  26. package/dataflow/info.js +1 -1
  27. package/dataflow/internal/linker.d.ts +2 -0
  28. package/dataflow/internal/linker.js +18 -1
  29. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
  30. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +68 -21
  31. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -2
  32. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -4
  33. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -18
  34. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -0
  35. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
  36. package/dataflow/internal/process/functions/call/common.js +4 -3
  37. package/documentation/doc-util/doc-query.js +6 -2
  38. package/documentation/doc-util/doc-types.d.ts +7 -2
  39. package/documentation/doc-util/doc-types.js +20 -4
  40. package/documentation/print-core-wiki.js +5 -1
  41. package/documentation/print-dataflow-graph-wiki.js +21 -12
  42. package/documentation/print-faq-wiki.js +5 -0
  43. package/documentation/print-interface-wiki.js +2 -0
  44. package/documentation/print-linter-wiki.js +2 -3
  45. package/documentation/print-linting-and-testing-wiki.js +4 -0
  46. package/documentation/print-query-wiki.js +22 -7
  47. package/documentation/print-readme.js +6 -0
  48. package/linter/linter-executor.js +25 -17
  49. package/linter/linter-format.d.ts +10 -1
  50. package/linter/linter-format.js +8 -0
  51. package/linter/linter-rules.d.ts +1 -0
  52. package/linter/rules/absolute-path.js +8 -8
  53. package/linter/rules/dataframe-access-validation.js +1 -1
  54. package/linter/rules/file-path-validity.js +8 -11
  55. package/linter/rules/naming-convention.d.ts +5 -1
  56. package/linter/rules/naming-convention.js +24 -8
  57. package/linter/rules/seeded-randomness.js +2 -2
  58. package/linter/rules/unused-definition.js +1 -1
  59. package/package.json +20 -15
  60. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +5 -1
  61. package/queries/catalog/call-context-query/call-context-query-executor.js +14 -12
  62. package/queries/catalog/call-context-query/call-context-query-format.d.ts +6 -5
  63. package/queries/catalog/call-context-query/call-context-query-format.js +1 -1
  64. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -1
  65. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  66. package/queries/catalog/config-query/config-query-executor.js +7 -1
  67. package/queries/catalog/config-query/config-query-format.d.ts +7 -0
  68. package/queries/catalog/config-query/config-query-format.js +72 -1
  69. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -75
  70. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +50 -26
  71. package/queries/catalog/dependencies-query/dependencies-query-format.js +75 -20
  72. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -2
  73. package/queries/catalog/dependencies-query/function-info/visualize-functions.d.ts +2 -0
  74. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +13 -0
  75. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -1
  76. package/queries/catalog/linter-query/linter-query-format.js +4 -0
  77. package/queries/query-print.d.ts +2 -2
  78. package/queries/query-print.js +3 -2
  79. package/queries/query.d.ts +28 -21
  80. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  81. package/r-bridge/retriever.d.ts +14 -2
  82. package/r-bridge/retriever.js +10 -4
  83. package/search/flowr-search-builder.d.ts +1 -1
  84. package/search/flowr-search-builder.js +1 -1
  85. package/search/flowr-search-filters.d.ts +20 -10
  86. package/search/flowr-search-filters.js +19 -3
  87. package/search/search-executor/search-enrichers.d.ts +1 -1
  88. package/search/search-executor/search-enrichers.js +3 -2
  89. package/search/search-executor/search-generators.js +1 -1
  90. package/search/search-executor/search-transformer.js +1 -1
  91. package/util/formats/adapter-format.d.ts +6 -0
  92. package/util/formats/adapter-format.js +3 -0
  93. package/util/formats/adapter.d.ts +16 -0
  94. package/util/formats/adapter.js +42 -0
  95. package/util/formats/adapters/r-adapter.d.ts +4 -0
  96. package/util/formats/adapters/r-adapter.js +7 -0
  97. package/util/formats/adapters/rmd-adapter.d.ts +26 -0
  98. package/util/formats/adapters/rmd-adapter.js +91 -0
  99. package/util/objects.d.ts +11 -0
  100. package/util/objects.js +26 -0
  101. package/util/version.js +1 -1
@@ -58,6 +58,8 @@ function onlyLoopsOnce(loop, dataflow, controlflow, ast, config) {
58
58
  return visitor.loopsOnlyOnce();
59
59
  }
60
60
  class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
61
+ loopCds = undefined;
62
+ encounteredLoopBreaker = false;
61
63
  onlyLoopyOnce = false;
62
64
  loopToCheck;
63
65
  constructor(loop, config) {
@@ -76,7 +78,7 @@ class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.Seman
76
78
  }
77
79
  startVisitor(_) {
78
80
  const g = this.config.controlFlow.graph;
79
- const n = (i) => g.ingoingEdges(i);
81
+ const ingoing = (i) => g.ingoingEdges(i);
80
82
  const exits = new Set(g.getVertex(this.loopToCheck)?.end ?? []);
81
83
  (0, assert_1.guard)(exits.size !== 0, "Can't find end of loop");
82
84
  const stack = [this.loopToCheck];
@@ -86,38 +88,45 @@ class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.Seman
86
88
  continue;
87
89
  }
88
90
  if (!exits.has(current)) {
89
- const next = n(current) ?? [];
91
+ const next = ingoing(current) ?? [];
90
92
  for (const [to] of next) {
91
93
  stack.unshift(to);
92
94
  }
93
95
  }
96
+ this.onlyLoopyOnce ||= this.encounteredLoopBreaker && (0, info_1.happensInEveryBranch)(this.loopCds);
97
+ }
98
+ this.onlyLoopyOnce ||= this.encounteredLoopBreaker && (0, info_1.happensInEveryBranch)(this.loopCds);
99
+ }
100
+ app(cds) {
101
+ if (cds === undefined) {
102
+ return;
103
+ }
104
+ const filtered = cds.filter(c => c.id !== this.loopToCheck);
105
+ if (filtered.length > 0) {
106
+ if (this.loopCds === undefined) {
107
+ this.loopCds = filtered;
108
+ }
109
+ else {
110
+ this.loopCds = this.loopCds.concat(filtered);
111
+ }
94
112
  }
95
113
  }
96
114
  onDefaultFunctionCall(data) {
97
- let stopsLoop = false;
98
- const alwaysHappens = () => {
99
- if (!data.call.cds ||
100
- (data.call.cds.length === 1 && data.call.cds[0].id === this.loopToCheck)) {
101
- return true;
115
+ for (const origin of data.call.origin) {
116
+ if (origin === 'builtin:stop' || origin === 'builtin:return' || origin === 'builtin:break') {
117
+ this.encounteredLoopBreaker = true;
118
+ this.app(data.call.cds);
119
+ return;
102
120
  }
103
- const cds = data.call.cds.filter(d => d.id !== this.loopToCheck);
104
- return (0, info_1.happensInEveryBranch)(cds);
105
- };
106
- switch (data.call.origin[0]) {
107
- case 'builtin:return':
108
- case 'builtin:stop':
109
- case 'builtin:break':
110
- stopsLoop = alwaysHappens();
111
- break;
112
- case 'builtin:stopifnot': {
121
+ else if (origin === 'builtin:stopifnot') {
113
122
  const arg = this.getBoolArgValue(data);
114
- if (arg !== undefined) {
115
- stopsLoop = !arg && alwaysHappens();
123
+ if (arg === false) {
124
+ this.encounteredLoopBreaker = true;
125
+ this.app(data.call.cds);
126
+ return;
116
127
  }
117
- break;
118
128
  }
119
129
  }
120
- this.onlyLoopyOnce = this.onlyLoopyOnce || stopsLoop;
121
130
  }
122
131
  loopsOnlyOnce() {
123
132
  this.startVisitor([]);
@@ -55,7 +55,7 @@ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
55
55
  readonly returnsNthArgument?: number | 'last';
56
56
  readonly cfg?: ExitPointType;
57
57
  readonly readAllArguments?: boolean;
58
- readonly hasUnknownSideEffects?: boolean | LinkTo;
58
+ readonly hasUnknownSideEffects?: boolean | LinkTo<RegExp | string>;
59
59
  /** record mapping the actual function name called to the arguments that should be treated as function calls */
60
60
  readonly treatAsFnCall?: Record<string, readonly string[]>;
61
61
  /** Name that should be used for the origin (useful when needing to differentiate between
@@ -1,5 +1,14 @@
1
1
  import type { BuiltInDefinitions } from './built-in-config';
2
2
  import type { BuiltInMappingName } from './built-in';
3
+ export declare const GgPlotCreate: readonly ["ggplot", "ggplotly", "ggMarginal", "ggcorrplot", "ggseasonplot", "ggdendrogram", "qmap", "qplot", "quickplot", "autoplot", "grid.arrange", "fviz_pca_biplot", "fviz_pca", "fviz_pca_ind", "fviz_pca_var", "fviz_screeplot", "fviz_mca_biplot", "fviz_mca", "fviz_mca_ind", "fviz_mca_var", "fviz_cluster", "fviz_dend", "ggsurvplot"];
4
+ export declare const TinyPlotCrate: readonly ["tinyplot", "plt"];
5
+ export declare const GraphicsPlotCreate: string[];
6
+ export declare const PlotCreate: string[];
7
+ export declare const TinyPlotAddons: string[];
8
+ export declare const GgPlotImplicitAddons: readonly ["geom_count", "geom_bin_2d", "geom_spoke", "geom_tile", "geom_rect", "geom_function", "geom_crossbar", "geom_density2d", "geom_abline", "geom_errorbar", "geom_errorbarh", "geom_jitter", "geom_line", "geom_density", "geom_quantile", "geom_qq", "geom_qq_line", "geom_segment", "geom_label", "geom_density_2d", "geom_violin", "geom_contour", "geom_boxplot", "geom_col", "geom_blank", "geom_histogram", "geom_hline", "geom_area", "geom_sf_text", "geom_smooth", "geom_text", "geom_density2d_filled", "geom_ribbon", "geom_sf", "geom_dotplot", "geom_freqpoly", "geom_step", "geom_map", "geom_bin2d", "geom_rug", "geom_raster", "geom_pointrange", "geom_point", "geom_hex", "geom_contour_filled", "geom_bar", "geom_vline", "geom_linerange", "geom_curve", "geom_path", "geom_polygon", "geom_sf_label", "geom_density_2d_filled", "geom_dumbbell", "geom_encircle", "stat_count", "stat_density", "stat_bin_hex", "stat_bin_2d", "stat_summary_bin", "stat_identity", "stat_qq", "stat_binhex", "stat_boxplot", "stat_function", "stat_align", "stat_contour_filled", "stat_summary_2d", "stat_qq_line", "stat_contour", "stat_ydensity", "stat_summary_hex", "stat_summary2d", "stat_sf_coordinates", "stat_density_2d_filled", "stat_smooth", "stat_density2d", "stat_ecdf", "stat_sf", "stat_quantile", "stat_unique", "stat_density_2d", "stat_ellipse", "stat_summary", "stat_density2d_filled", "stat_bin", "stat_sum", "stat_spoke", "stat_bin2d", "labs", "theme_void", "theme_test", "theme_minimal", "theme_light", "theme", "theme_get", "theme_gray", "theme_dark", "theme_classic", "theme_linedraw", "theme_update", "theme_replace", "theme_grey", "theme_bw", "theme_tufte", "theme_survminer", "facet_null", "facet_grid", "facet_wrap", "xlab", "xlim", "ylab", "ylim", "scale_linewidth_ordinal", "scale_fill_steps", "scale_color_gradient2", "scale_size_manual", "scale_colour_discrete", "scale_color_identity", "scale_fill_fermenter", "scale_alpha_manual", "scale_fill_gradient", "scale_size_date", "scale_fill_viridis_b", "scale_x_time", "scale_linetype_manual", "scale_alpha_binned", "scale_color_grey", "scale_colour_gradient", "scale_linewidth_date", "scale_color_steps2", "scale_color_viridis_b", "scale_size_binned", "scale_colour_gradientn", "scale_linewidth_manual", "scale_fill_viridis_c", "scale_fill_manual", "scale_color_viridis_c", "scale_fill_discrete", "scale_size_discrete", "scale_fill_binned", "scale_fill_viridis_d", "scale_colour_fermenter", "scale_color_viridis_d", "scale_x_datetime", "scale_size_identity", "scale_linewidth_identity", "scale_shape_ordinal", "scale_linewidth_discrete", "scale_fill_ordinal", "scale_y_time", "scale_color_ordinal", "scale_size_ordinal", "scale_colour_distiller", "scale_linewidth_datetime", "scale_alpha_identity", "scale_color_steps", "scale_alpha_discrete", "scale_fill_date", "scale_x_reverse", "scale_fill_gradientn", "scale_size_datetime", "scale_y_continuous", "scale_colour_steps", "scale_color_distiller", "scale_colour_ordinal", "scale_y_datetime", "scale_linetype_discrete", "scale_colour_viridis_b", "scale_alpha_datetime", "scale_continuous_identity", "scale_fill_brewer", "scale_shape_identity", "scale_color_discrete", "scale_colour_viridis_c", "scale_linetype_identity", "scale_colour_hue", "scale_linewidth_binned", "scale_color_hue", "scale_shape_continuous", "scale_colour_viridis_d", "scale_size_continuous", "scale_color_manual", "scale_alpha_date", "scale_y_sqrt", "scale_shape_binned", "scale_size", "scale_color_fermenter", "scale_color_stepsn", "scale_size_area", "scale_y_binned", "scale_y_discrete", "scale_alpha_continuous", "scale_fill_continuous", "scale_linetype_continuous", "scale_colour_steps2", "scale_colour_datetime", "scale_colour_grey", "scale_x_log10", "scale_x_discrete", "scale_color_continuous", "scale_type", "scale_y_reverse", "scale_colour_gradient2", "scale_color_datetime", "scale_color_date", "scale_x_continuous", "scale_colour_manual", "scale_fill_gradient2", "scale_fill_grey", "scale_colour_stepsn", "scale_colour_binned", "scale_color_binned", "scale_color_gradientn", "scale_colour_date", "scale_fill_distiller", "scale_color_gradient", "scale_linewidth_continuous", "scale_shape", "scale_fill_hue", "scale_linetype", "scale_colour_identity", "scale_discrete_manual", "scale_fill_identity", "scale_y_log10", "scale_linetype_binned", "scale_size_binned_area", "scale_y_date", "scale_x_binned", "scale_shape_discrete", "scale_colour_brewer", "scale_x_date", "scale_discrete_identity", "scale_alpha", "scale_fill_steps2", "scale_color_brewer", "scale_fill_datetime", "scale_shape_manual", "scale_colour_continuous", "scale_alpha_ordinal", "scale_linewidth", "scale_x_sqrt", "scale_fill_stepsn", "scale_radius", "rotateTextX", "removeGridX", "removeGridY", "removeGrid", "coord_trans", "coord_sf", "coord_cartesian", "coord_fixed", "coord_flip", "coord_quickmap", "coord_equal", "coord_map", "coord_polar", "coord_munch", "coord_radial", "annotate", "annotation_custom", "annotation_raster", "annotation_map", "annotation_logticks", "borders", "ggtitle", "expansion", "expand_limits", "expand_scale", "guides", "wrap_by", "theme_solid", "theme_hc", "theme_excel_new", "theme_few", "theme_clean", "theme_wsj", "theme_calc", "theme_par", "theme_tufte", "theme_igray", "theme_solarized_2", "theme_excel", "theme_economist", "theme_stata", "theme_map", "theme_fivethirtyeight", "theme_economist_white", "theme_base", "theme_foundation", "theme_gdocs", "theme_pander", "theme_solarized", "scale_shape_tableau", "scale_fill_pander", "scale_shape_few", "scale_colour_excel_new", "scale_colour_hc", "scale_fill_ptol", "scale_fill_gradient2_tableau", "scale_shape_calc", "scale_fill_stata", "scale_colour_tableau", "scale_colour_colorblind", "scale_color_stata", "scale_colour_economist", "scale_fill_calc", "scale_fill_gradient_tableau", "scale_shape_cleveland", "scale_color_pander", "scale_colour_pander", "scale_color_fivethirtyeight", "scale_color_wsj", "scale_shape_stata", "scale_colour_gdocs", "scale_color_continuous_tableau", "scale_fill_excel", "scale_color_few", "scale_linetype_stata", "scale_shape_tremmel", "scale_color_tableau", "scale_color_colorblind", "scale_fill_colorblind", "scale_colour_stata", "scale_fill_wsj", "scale_colour_calc", "scale_colour_fivethirtyeight", "scale_fill_hc", "scale_shape_circlefill", "scale_fill_excel_new", "scale_color_solarized", "scale_color_excel", "scale_colour_excel", "scale_fill_tableau", "scale_colour_ptol", "scale_colour_canva", "scale_color_gradient2_tableau", "scale_colour_solarized", "scale_colour_gradient2_tableau", "scale_fill_canva", "scale_color_ptol", "scale_color_excel_new", "scale_color_economist", "scale_fill_economist", "scale_fill_fivethirtyeight", "scale_colour_gradient_tableau", "scale_colour_few", "scale_color_calc", "scale_fill_few", "scale_fill_gdocs", "scale_color_hc", "scale_color_gdocs", "scale_color_canva", "scale_color_gradient_tableau", "scale_fill_solarized", "scale_fill_continuous_tableau", "scale_colour_wsj", "gradient_color", "ggsurvplot_add_all"];
9
+ export declare const PlotFunctionsWithAddParam: Set<string>;
10
+ export declare const GraphicsPlotAddons: string[];
11
+ export declare const GgPlotAddons: string[];
3
12
  /**
4
13
  * Contains the built-in definitions recognized by flowR
5
14
  */
@@ -1,36 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultBuiltinConfig = void 0;
3
+ exports.DefaultBuiltinConfig = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = void 0;
4
4
  exports.getDefaultProcessor = getDefaultProcessor;
5
5
  const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
6
6
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
7
7
  const cascade_action_1 = require("../../queries/catalog/call-context-query/cascade-action");
8
8
  const unnamed_call_handling_1 = require("../internal/process/functions/call/unnamed-call-handling");
9
- const GgPlotCreate = [
9
+ exports.GgPlotCreate = [
10
10
  'ggplot', 'ggplotly', 'ggMarginal', 'ggcorrplot', 'ggseasonplot', 'ggdendrogram', 'qmap', 'qplot', 'quickplot', 'autoplot', 'grid.arrange',
11
11
  'fviz_pca_biplot', 'fviz_pca', 'fviz_pca_ind', 'fviz_pca_var', 'fviz_screeplot', 'fviz_mca_biplot', 'fviz_mca', 'fviz_mca_ind', 'fviz_mca_var', 'fviz_cluster', 'fviz_dend',
12
12
  'ggsurvplot',
13
13
  ];
14
- const TinyPlotCrate = [
14
+ exports.TinyPlotCrate = [
15
15
  'tinyplot', 'plt'
16
16
  ];
17
- const PlotCreate = [
17
+ exports.GraphicsPlotCreate = [
18
18
  'plot', 'plot.new', 'xspline', 'map', 'curve', 'image', 'boxplot', 'dotchart', 'sunflowerplot', 'barplot', 'matplot', 'hist', 'stem',
19
19
  'density', 'smoothScatter', 'contour', 'persp', 'XYPlot', 'xyplot', 'stripplot', 'bwplot', 'dotPlot', 'dotplot', 'histPlot', 'densityPlot', 'qPlot', 'qqplot', 'qqPlot', 'boxPlot',
20
20
  'bxp', 'assocplot', 'mosaicplot', 'stripchart', 'fourfoldplot', 'plot.xy', 'plot.formula', 'plot.default', 'plot.design', 'stars', 'cotabplot', 'pheatmap',
21
21
  'spineplot', 'Plotranges', 'regressogram', 'bootcurve', 'meanplot', 'vioplot', 'pairs', 'copolot', 'histogram', 'splom', 'leaflet', 'tm_shape', 'plot_ly', 'plotProfLik', 'plotSimulatedResiduals', 'plotmeans',
22
22
  'overplot', 'residplot', 'heatmap.2', 'lmplot2', 'sinkplot', 'textplot', 'boxplot2', 'profLikCI',
23
- ...TinyPlotCrate,
24
- ...GgPlotCreate
25
23
  ];
24
+ exports.PlotCreate = exports.GraphicsPlotCreate.concat(exports.TinyPlotCrate, exports.GgPlotCreate);
26
25
  const GraphicDeviceOpen = [
27
26
  'pdf', 'jpeg', 'png', 'windows', 'postscript', 'xfig', 'bitmap', 'pictex', 'cairo_pdf', 'svg', 'bmp', 'tiff', 'X11', 'quartz', 'image_graph',
28
27
  'image_draw', 'dev.new', 'trellis.device', 'raster_pdf', 'agg_pdf'
29
28
  ];
30
- const TinyPlotAddons = [
29
+ exports.TinyPlotAddons = [
31
30
  'tinyplot_add', 'plt_add'
32
31
  ];
33
- const GgPlotImplicitAddons = [
32
+ exports.GgPlotImplicitAddons = [
34
33
  'geom_count', 'geom_bin_2d', 'geom_spoke', 'geom_tile', 'geom_rect',
35
34
  'geom_function', 'geom_crossbar', 'geom_density2d', 'geom_abline', 'geom_errorbar', 'geom_errorbarh',
36
35
  'geom_jitter', 'geom_line', 'geom_density', 'geom_quantile', 'geom_qq', 'geom_qq_line', 'geom_segment', 'geom_label', 'geom_density_2d',
@@ -75,17 +74,18 @@ const GgPlotImplicitAddons = [
75
74
  'scale_colour_gradient_tableau', 'scale_colour_few', 'scale_color_calc', 'scale_fill_few', 'scale_fill_gdocs', 'scale_color_hc', 'scale_color_gdocs', 'scale_color_canva', 'scale_color_gradient_tableau',
76
75
  'scale_fill_solarized', 'scale_fill_continuous_tableau', 'scale_colour_wsj', 'gradient_color', 'ggsurvplot_add_all'
77
76
  ];
78
- const PlotFunctionsWithAddParam = new Set([
77
+ exports.PlotFunctionsWithAddParam = new Set([
79
78
  'map', 'matplot', 'barplot', 'boxplot', 'curve', 'image', 'plotCI', 'bandplot', 'barplot2', 'bubbleplot'
80
79
  ]);
81
- const PlotAddons = [
80
+ exports.GraphicsPlotAddons = [
82
81
  'points', 'abline', 'mtext', 'lines', 'text', 'legend', 'title', 'axis', 'polygon', 'polypath', 'pie', 'rect', 'segments', 'arrows', 'symbols',
83
82
  'qqline', 'qqnorm', 'rasterImage',
84
- 'tiplabels', 'rug', 'grid', 'box', 'clip', 'matpoints', 'matlines', ...GgPlotImplicitAddons, ...PlotFunctionsWithAddParam
83
+ 'tiplabels', 'rug', 'grid', 'box', 'clip', 'matpoints', 'matlines',
85
84
  ];
86
- const GgPlotAddons = [
85
+ exports.GgPlotAddons = [
87
86
  'ggdraw', 'last_plot'
88
87
  ];
88
+ const PlotAddons = exports.GraphicsPlotAddons.concat(exports.GgPlotImplicitAddons, ...exports.PlotFunctionsWithAddParam);
89
89
  function toRegex(n) {
90
90
  return new RegExp(`^(${[...new Set(n)].map(s => s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')).filter(s => s.length > 0).join('|')})$`);
91
91
  }
@@ -129,7 +129,7 @@ exports.DefaultBuiltinConfig = [
129
129
  { type: 'function', names: ['apply', 'tapply', 'Tapply'], processor: 'builtin:apply', config: { indexOfFunction: 2, nameOfFunctionArgument: 'FUN' }, assumePrimitive: false },
130
130
  { type: 'function', names: ['print', 'message', 'warning'], processor: 'builtin:default', config: { returnsNthArgument: 0, forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
131
131
  // graphics base
132
- { type: 'function', names: PlotCreate,
132
+ { type: 'function', names: exports.PlotCreate,
133
133
  processor: 'builtin:default',
134
134
  config: {
135
135
  forceArgs: 'all',
@@ -137,7 +137,7 @@ exports.DefaultBuiltinConfig = [
137
137
  type: 'link-to-last-call',
138
138
  ignoreIf: (source, graph) => {
139
139
  /* map with add = true appends to an existing plot */
140
- return (PlotFunctionsWithAddParam.has(source.name) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, source, {
140
+ return (exports.PlotFunctionsWithAddParam.has(source.name) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, source, {
141
141
  index: -1,
142
142
  name: 'add'
143
143
  }, [type_1.RType.Logical])?.content === true);
@@ -154,11 +154,11 @@ exports.DefaultBuiltinConfig = [
154
154
  },
155
155
  hasUnknownSideEffects: {
156
156
  type: 'link-to-last-call',
157
- callName: toRegex([...PlotCreate, ...PlotAddons]),
157
+ callName: toRegex([...exports.PlotCreate, ...PlotAddons]),
158
158
  ignoreIf: (source, graph) => {
159
159
  const sourceVertex = graph.getVertex(source);
160
160
  /* map with add = true appends to an existing plot */
161
- return (PlotFunctionsWithAddParam.has(sourceVertex.name ?? '') && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, sourceVertex, {
161
+ return (exports.PlotFunctionsWithAddParam.has(sourceVertex.name ?? '') && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, sourceVertex, {
162
162
  index: -1,
163
163
  name: 'add'
164
164
  }, [type_1.RType.Logical])?.content !== true);
@@ -175,25 +175,25 @@ exports.DefaultBuiltinConfig = [
175
175
  // plot tags
176
176
  {
177
177
  type: 'function',
178
- names: GgPlotAddons,
178
+ names: exports.GgPlotAddons,
179
179
  processor: 'builtin:default',
180
180
  config: {
181
181
  forceArgs: 'all',
182
182
  hasUnknownSideEffects: {
183
183
  type: 'link-to-last-call',
184
- callName: toRegex([...GgPlotCreate, ...GgPlotAddons])
184
+ callName: toRegex([...exports.GgPlotCreate, ...exports.GgPlotAddons])
185
185
  }
186
186
  }, assumePrimitive: true
187
187
  },
188
188
  {
189
189
  type: 'function',
190
- names: TinyPlotAddons,
190
+ names: exports.TinyPlotAddons,
191
191
  processor: 'builtin:default',
192
192
  config: {
193
193
  forceArgs: 'all',
194
194
  hasUnknownSideEffects: {
195
195
  type: 'link-to-last-call',
196
- callName: toRegex([...TinyPlotCrate, ...TinyPlotAddons])
196
+ callName: toRegex([...exports.TinyPlotCrate, ...exports.TinyPlotAddons])
197
197
  }
198
198
  }, assumePrimitive: true
199
199
  },
@@ -205,7 +205,7 @@ exports.DefaultBuiltinConfig = [
205
205
  forceArgs: 'all',
206
206
  hasUnknownSideEffects: {
207
207
  type: 'link-to-last-call',
208
- callName: toRegex([...GraphicDeviceOpen, ...PlotCreate, ...PlotAddons, ...GgPlotAddons, ...TinyPlotAddons])
208
+ callName: toRegex([...GraphicDeviceOpen, ...exports.PlotCreate, ...PlotAddons, ...exports.GgPlotAddons, ...exports.TinyPlotAddons])
209
209
  }
210
210
  }, assumePrimitive: true
211
211
  },
@@ -18,8 +18,10 @@ function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = u
18
18
  const definitions = ref.name ? (0, resolve_by_name_1.resolveByName)(ref.name, environments, ref.type) : undefined;
19
19
  for (const definition of definitions ?? []) {
20
20
  if (definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant) {
21
- if (definition.controlDependencies && defaultCd && !definition.controlDependencies.find(c => c.id === defaultCd.id)) {
22
- definition.controlDependencies.push(defaultCd);
21
+ if (definition.controlDependencies) {
22
+ if (defaultCd && !definition.controlDependencies.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
23
+ definition.controlDependencies.push(defaultCd);
24
+ }
23
25
  }
24
26
  else {
25
27
  definition.controlDependencies = defaultCd ? [defaultCd] : [];
@@ -30,20 +32,27 @@ function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = u
30
32
  const node = graph.get(ref.nodeId, true);
31
33
  if (node) {
32
34
  const [fst] = node;
33
- if (fst.cds && defaultCd && !fst.cds.includes(defaultCd)) {
34
- fst.cds.push(defaultCd);
35
+ if (fst.cds) {
36
+ if (defaultCd && !fst.cds.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
37
+ fst.cds.push(defaultCd);
38
+ }
35
39
  }
36
40
  else {
37
41
  fst.cds = defaultCd ? [defaultCd] : [];
38
42
  }
39
43
  }
40
- return { ...ref, controlDependencies: [...ref.controlDependencies ?? [], ...(defaultCd ? [defaultCd] : [])] };
44
+ if (ref.controlDependencies) {
45
+ if (defaultCd && !ref.controlDependencies.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
46
+ return { ...ref, controlDependencies: (ref.controlDependencies ?? []).concat(defaultCd ? [defaultCd] : []) };
47
+ }
48
+ }
49
+ else {
50
+ return { ...ref, controlDependencies: ref.controlDependencies ?? (defaultCd ? [defaultCd] : []) };
51
+ }
52
+ return ref;
41
53
  }
42
54
  function makeAllMaybe(references, graph, environments, includeDefs, defaultCd = undefined) {
43
- if (references === undefined) {
44
- return [];
45
- }
46
- return references.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd));
55
+ return references?.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd)) ?? [];
47
56
  }
48
57
  /**
49
58
  * Please use this function only if you do not know the object type.
@@ -27,7 +27,7 @@ function overwriteIEnvironmentWith(base, next, includeParent = true, applyCds) {
27
27
  if (hasMaybe) {
28
28
  const old = map.get(key);
29
29
  // we need to make a copy to avoid side effects for old reference in other environments
30
- const updatedOld = old ?? [];
30
+ const updatedOld = [...old ?? []];
31
31
  for (const v of values) {
32
32
  const index = updatedOld.findIndex(o => o.nodeId === v.nodeId && o.definedAt === v.definedAt);
33
33
  if (index < 0) {
@@ -42,7 +42,7 @@ function overwriteIEnvironmentWith(base, next, includeParent = true, applyCds) {
42
42
  }
43
43
  }
44
44
  }
45
- map.set(key, [...updatedOld]);
45
+ map.set(key, updatedOld);
46
46
  }
47
47
  else {
48
48
  map.set(key, values);
@@ -64,7 +64,7 @@ function resolveLinkToSideEffects(ast, graph) {
64
64
  if (typeof s !== 'object') {
65
65
  continue;
66
66
  }
67
- cfg ??= (0, extract_cfg_1.extractSimpleCfg)(ast).graph;
67
+ cfg ??= (0, extract_cfg_1.extractCfgQuick)(ast).graph;
68
68
  /* this has to change whenever we add a new link to relations because we currently offer no abstraction for the type */
69
69
  const potentials = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(s.id, cfg, graph, s.linkTo);
70
70
  for (const pot of potentials) {
@@ -36,8 +36,8 @@ function diffDataflowGraph(ctx) {
36
36
  diffOutgoingEdges(ctx);
37
37
  }
38
38
  function diffOutgoingEdges(ctx) {
39
- const lEdges = new Map([...ctx.left.edges()]);
40
- const rEdges = new Map([...ctx.right.edges()]);
39
+ const lEdges = new Map(ctx.left.edges());
40
+ const rEdges = new Map(ctx.right.edges());
41
41
  if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph || lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
42
42
  ctx.report.addComment(`Detected different number of edges! ${ctx.leftname} has ${lEdges.size} (${JSON.stringify(lEdges, json_1.jsonReplacer)}). ${ctx.rightname} has ${rEdges.size} ${JSON.stringify(rEdges, json_1.jsonReplacer)}`);
43
43
  }
@@ -131,8 +131,8 @@ function diffFunctionArguments(fn, a, b, ctx) {
131
131
  }
132
132
  function diffVertices(ctx) {
133
133
  // collect vertices from both sides
134
- const lVert = [...ctx.left.vertices(true)].map(([id, info]) => [id, info]);
135
- const rVert = [...ctx.right.vertices(true)].map(([id, info]) => [id, info]);
134
+ const lVert = ctx.left.vertices(true).map(([id, info]) => [id, info]).toArray();
135
+ const rVert = ctx.right.vertices(true).map(([id, info]) => [id, info]).toArray();
136
136
  if (lVert.length < rVert.length && !ctx.config.leftIsSubgraph
137
137
  || lVert.length > rVert.length && !ctx.config.rightIsSubgraph) {
138
138
  ctx.report.addComment(`Detected different number of vertices! ${ctx.leftname} has ${lVert.length}, ${ctx.rightname} has ${rVert.length}`);
@@ -160,13 +160,13 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
160
160
  *
161
161
  * @see #edges
162
162
  */
163
- vertices(includeDefinedFunctions: boolean): IterableIterator<[NodeId, Vertex]>;
163
+ vertices(includeDefinedFunctions: boolean): MapIterator<[NodeId, Vertex]>;
164
164
  /**
165
165
  * @returns the ids of all edges in the graph together with their edge information
166
166
  *
167
167
  * @see #vertices
168
168
  */
169
- edges(): IterableIterator<[NodeId, OutgoingEdges]>;
169
+ edges(): MapIterator<[NodeId, OutgoingEdges]>;
170
170
  /**
171
171
  * Returns true if the graph contains a node with the given id.
172
172
  *
@@ -219,7 +219,7 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
219
219
  /** If you do not pass the `to` node, this will just mark the node as maybe */
220
220
  addControlDependency(from: NodeId, to?: NodeId, when?: boolean): this;
221
221
  /** Marks the given node as having unknown side effects */
222
- markIdForUnknownSideEffects(id: NodeId, target?: LinkTo): this;
222
+ markIdForUnknownSideEffects(id: NodeId, target?: LinkTo<RegExp | string>): this;
223
223
  /**
224
224
  * Constructs a dataflow graph instance from the given JSON data and returns the result.
225
225
  * This can be useful for data sent by the flowR server when analyzing it further.
@@ -335,7 +335,10 @@ class DataflowGraph {
335
335
  /** Marks the given node as having unknown side effects */
336
336
  markIdForUnknownSideEffects(id, target) {
337
337
  if (target) {
338
- this._unknownSideEffects.add({ id: (0, node_id_1.normalizeIdToNumberIfPossible)(id), linkTo: typeof target.callName === 'string' ? { ...target, callName: new RegExp(target.callName) } : target });
338
+ this._unknownSideEffects.add({
339
+ id: (0, node_id_1.normalizeIdToNumberIfPossible)(id),
340
+ linkTo: typeof target.callName === 'string' ? { ...target, callName: new RegExp(target.callName) } : target
341
+ });
339
342
  return this;
340
343
  }
341
344
  this._unknownSideEffects.add((0, node_id_1.normalizeIdToNumberIfPossible)(id));
@@ -11,16 +11,16 @@ const edge_1 = require("./edge");
11
11
  function df2quads(graph, config) {
12
12
  return (0, quads_1.graph2quads)({
13
13
  rootIds: [...graph.rootIds()],
14
- vertices: [...graph.vertices(true)]
14
+ vertices: graph.vertices(true)
15
15
  .map(([id, v]) => ({
16
16
  ...v,
17
17
  id
18
- })),
19
- edges: [...graph.edges()].flatMap(([fromId, targets]) => [...targets].map(([toId, info]) => ({
18
+ })).toArray(),
19
+ edges: graph.edges().flatMap(([fromId, targets]) => [...targets].map(([toId, info]) => ({
20
20
  from: fromId,
21
21
  to: toId,
22
22
  type: [...(0, edge_1.edgeTypesToNames)(info.types)],
23
- })))
23
+ }))).toArray()
24
24
  }, config);
25
25
  }
26
26
  //# sourceMappingURL=quads.js.map
package/dataflow/info.js CHANGED
@@ -91,7 +91,7 @@ function diffControlDependencies(a, b, info) {
91
91
  return;
92
92
  }
93
93
  if (a.length !== b.length) {
94
- info.report.addComment(`${info.position}Different control dependency lengths: ${a.length} vs. ${b.length}`);
94
+ info.report.addComment(`${info.position}Different control dependency lengths: ${a.length} (${JSON.stringify(a)}) vs. ${b.length} (${JSON.stringify(b)})`);
95
95
  }
96
96
  for (let i = 0; i < a.length; ++i) {
97
97
  diffControlDependency(a[i], b[i], { ...info, position: `${info.position}Control dependency at index: ${i}: ` });
@@ -7,6 +7,7 @@ import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/mo
7
7
  import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition, DataflowGraphVertexInfo } from '../graph/vertex';
8
8
  import type { BuiltIn } from '../environments/built-in';
9
9
  import type { REnvironmentInformation } from '../environments/environment';
10
+ import type { ExitPoint } from '../info';
10
11
  export type NameIdMap = DefaultMap<string, IdentifierReference[]>;
11
12
  export declare function findNonLocalReads(graph: DataflowGraph, ignore: readonly IdentifierReference[]): IdentifierReference[];
12
13
  export declare function produceNameSharedIdMap(references: IdentifierReference[]): NameIdMap;
@@ -51,3 +52,4 @@ export declare function linkInputs(referencesToLinkAgainstEnvironment: readonly
51
52
  * `x_2` must get a read marker to `x_1` as `x_1` is the active redefinition in the second loop iteration.
52
53
  */
53
54
  export declare function linkCircularRedefinitionsWithinALoop(graph: DataflowGraph, openIns: NameIdMap, outgoing: readonly IdentifierReference[]): void;
55
+ export declare function reapplyLoopExitPoints(exits: readonly ExitPoint[], references: readonly IdentifierReference[]): void;
@@ -9,6 +9,7 @@ exports.getAllFunctionCallTargets = getAllFunctionCallTargets;
9
9
  exports.getAllLinkedFunctionDefinitions = getAllLinkedFunctionDefinitions;
10
10
  exports.linkInputs = linkInputs;
11
11
  exports.linkCircularRedefinitionsWithinALoop = linkCircularRedefinitionsWithinALoop;
12
+ exports.reapplyLoopExitPoints = reapplyLoopExitPoints;
12
13
  const defaultmap_1 = require("../../util/collections/defaultmap");
13
14
  const assert_1 = require("../../util/assert");
14
15
  const log_1 = require("../../util/log");
@@ -25,7 +26,7 @@ const built_in_1 = require("../environments/built-in");
25
26
  const prefix_1 = require("../../util/prefix");
26
27
  function findNonLocalReads(graph, ignore) {
27
28
  const ignores = new Set(ignore.map(i => i.nodeId));
28
- const ids = new Set([...graph.vertices(true)]
29
+ const ids = new Set(graph.vertices(true)
29
30
  .filter(([_, info]) => info.tag === vertex_1.VertexType.Use || info.tag === vertex_1.VertexType.FunctionCall)
30
31
  .map(([id, _]) => id));
31
32
  /* find all variable use ids which do not link to a given id */
@@ -325,4 +326,20 @@ function linkCircularRedefinitionsWithinALoop(graph, openIns, outgoing) {
325
326
  }
326
327
  }
327
328
  }
329
+ function reapplyLoopExitPoints(exits, references) {
330
+ // just apply the cds of all exit points not already present
331
+ const exitCds = new Set(exits.flatMap(e => e.controlDependencies).filter(assert_1.isNotUndefined));
332
+ for (const ref of references) {
333
+ for (const cd of exitCds) {
334
+ if (ref.controlDependencies) {
335
+ if (!ref.controlDependencies?.find(c => c.id === cd.id && c.when === cd.when)) {
336
+ ref.controlDependencies.push(cd);
337
+ }
338
+ }
339
+ else {
340
+ ref.controlDependencies = [cd];
341
+ }
342
+ }
343
+ }
344
+ }
328
345
  //# sourceMappingURL=linker.js.map
@@ -32,7 +32,9 @@ export interface AssignmentToSymbolParameters<OtherInfo> extends AssignmentConfi
32
32
  readonly nameOfAssignmentFunction: string;
33
33
  readonly source: RNode<OtherInfo & ParentInformation>;
34
34
  readonly args: [DataflowInformation, DataflowInformation];
35
- readonly target: RSymbol<OtherInfo & ParentInformation>;
35
+ readonly targetId: NodeId;
36
+ /** pass only if the assignment target differs from normal R assignments (i.e., if the symbol is to be resolved) */
37
+ readonly targetName?: string;
36
38
  readonly rootId: NodeId;
37
39
  readonly data: DataflowProcessorInformation<OtherInfo>;
38
40
  readonly information: DataflowInformation;