@eagleoutice/flowr 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/benchmark/slicer.js +30 -5
  2. package/benchmark/stats/print.js +28 -9
  3. package/benchmark/stats/stats.d.ts +5 -0
  4. package/benchmark/summarizer/data.d.ts +10 -1
  5. package/benchmark/summarizer/first-phase/process.d.ts +1 -1
  6. package/benchmark/summarizer/first-phase/process.js +83 -30
  7. package/benchmark/summarizer/second-phase/process.js +20 -4
  8. package/cli/repl/commands/commands.js +19 -1
  9. package/cli/slicer-app.js +1 -1
  10. package/dataflow/environments/append.js +1 -2
  11. package/dataflow/environments/built-in.js +2 -1
  12. package/dataflow/environments/clone.js +1 -1
  13. package/dataflow/environments/diff.d.ts +1 -1
  14. package/dataflow/environments/diff.js +16 -18
  15. package/dataflow/environments/environment.d.ts +4 -7
  16. package/dataflow/environments/environment.js +5 -8
  17. package/dataflow/environments/identifier.d.ts +2 -1
  18. package/dataflow/environments/overwrite.js +1 -2
  19. package/dataflow/environments/scoping.js +1 -1
  20. package/dataflow/graph/diff.js +11 -6
  21. package/dataflow/graph/graph.d.ts +6 -2
  22. package/dataflow/graph/graph.js +13 -7
  23. package/dataflow/graph/vertex.d.ts +2 -1
  24. package/dataflow/info.d.ts +10 -1
  25. package/dataflow/info.js +54 -2
  26. package/dataflow/internal/linker.d.ts +1 -1
  27. package/dataflow/internal/linker.js +1 -2
  28. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +5 -5
  29. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
  30. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -25
  31. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +6 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +10 -8
  33. package/dataflow/internal/process/functions/call/built-in/built-in-logical-bin-op.d.ts +1 -0
  34. package/dataflow/internal/process/functions/call/built-in/built-in-logical-bin-op.js +1 -2
  35. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  36. package/dataflow/internal/process/functions/call/default-call-handling.js +1 -1
  37. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
  38. package/dataflow/processor.d.ts +2 -3
  39. package/package.json +4 -2
  40. package/r-bridge/data/data.d.ts +1 -1
  41. package/r-bridge/data/data.js +1 -1
  42. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +2 -2
  43. package/r-bridge/lang-4.x/ast/model/operators.js +1 -1
  44. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -1
  45. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -1
  46. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +2 -2
  47. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/normalize-call.js +2 -2
  48. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/normalize-binary.js +1 -1
  49. package/r-bridge/retriever.d.ts +1 -1
  50. package/r-bridge/retriever.js +3 -2
  51. package/r-bridge/shell.js +4 -3
  52. package/reconstruct/reconstruct.d.ts +3 -3
  53. package/reconstruct/reconstruct.js +40 -41
  54. package/slicing/criterion/filters/all-variables.js +1 -1
  55. package/slicing/static/static-slicer.js +2 -2
  56. package/statistics/features/common-syntax-probability.js +1 -1
  57. package/statistics/features/supported/control-flow/control-flow.js +1 -1
  58. package/statistics/features/supported/defined-functions/defined-functions.js +1 -1
  59. package/statistics/features/supported/loops/loops.js +1 -1
  60. package/statistics/features/supported/used-functions/used-functions.js +1 -1
  61. package/util/assert.d.ts +1 -1
  62. package/util/mermaid/ast.js +4 -0
  63. package/util/mermaid/dfg.js +15 -5
  64. package/util/mermaid/mermaid.js +21 -1
  65. package/util/version.js +1 -1
@@ -63,7 +63,7 @@ function visitCalls(info, input) {
63
63
  if (dataflowNode) {
64
64
  hasCallsEdge = [...dataflowNode[1].values()].some(e => (0, edge_1.edgeIncludesType)(e.types, 4 /* EdgeType.Calls */));
65
65
  }
66
- if (node.flavor === 'unnamed') {
66
+ if (!node.named) {
67
67
  info.unnamedCalls++;
68
68
  (0, statistics_file_1.appendStatisticsFile)(exports.usedFunctions.name, 'unnamed-calls', [node.lexeme], input.filepath);
69
69
  allCalls.push([
package/util/assert.d.ts CHANGED
@@ -9,4 +9,4 @@ export type GuardMessage = string | (() => string);
9
9
  * @param message - if a string, will be used as error message, if a function, will be called to produce the error message (can be used to avoid costly message generations)
10
10
  * @throws GuardError - if the assertion fails
11
11
  */
12
- export declare function guard(assertion: boolean, message?: GuardMessage): asserts assertion;
12
+ export declare function guard(assertion: boolean | undefined, message?: GuardMessage): asserts assertion;
@@ -13,6 +13,10 @@ function normalizedAstToMermaid(ast, prefix = '') {
13
13
  const roleSuffix = context.role === "expr-list-child" /* RoleInParent.ExpressionListChild */ || context.role === "call-argument" /* RoleInParent.FunctionCallArgument */ || context.role === "function-def-param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
14
14
  output += ` n${n.info.parent} -->|"${context.role}${roleSuffix}"| n${n.info.id}\n`;
15
15
  }
16
+ if (n.type === "RExpressionList" /* RType.ExpressionList */ && n.grouping !== undefined) {
17
+ output += ` n${n.info.id} -.-|"group-open"| n${n.grouping[0].info.id}\n`;
18
+ output += ` n${n.info.id} -.-|"group-close"| n${n.grouping[1].info.id}\n`;
19
+ }
16
20
  return false;
17
21
  });
18
22
  return output;
@@ -12,6 +12,14 @@ function formatRange(range) {
12
12
  if (range === undefined) {
13
13
  return '??-??';
14
14
  }
15
+ else if (range[0] === range[2]) {
16
+ if (range[1] === range[3]) {
17
+ return `${range[0]}.${range[1]}`;
18
+ }
19
+ else {
20
+ return `${range[0]}.${range[1]}-${range[3]}`;
21
+ }
22
+ }
15
23
  return `${range[0]}.${range[1]}-${range[2]}.${range[3]}`;
16
24
  }
17
25
  exports.formatRange = formatRange;
@@ -102,7 +110,7 @@ function printEnvironmentToLines(env) {
102
110
  else if (env.id === environment_1.BuiltInEnvironment.id) {
103
111
  return ['Built-in'];
104
112
  }
105
- const lines = [...printEnvironmentToLines(env.parent), `${env.id}--${env.name}${'-'.repeat(40)}`];
113
+ const lines = [...printEnvironmentToLines(env.parent), `${env.id}${'-'.repeat(40)}`];
106
114
  const longestName = Math.max(...[...env.memory.keys()].map(x => x.length));
107
115
  for (const [name, defs] of env.memory.entries()) {
108
116
  const printName = `${name}:`;
@@ -119,15 +127,17 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark) {
119
127
  }
120
128
  }
121
129
  const node = mermaid.rootGraph.idMap?.get(info.id);
122
- const escapedName = (0, mermaid_1.escapeMarkdown)(node ? `[${node.type}] ${node.lexeme ?? '??'}` : '??');
130
+ const lexeme = node?.lexeme ?? (node?.type === "RExpressionList" /* RType.ExpressionList */ ? node?.grouping?.[0]?.lexeme : '') ?? '??';
131
+ const escapedName = (0, mermaid_1.escapeMarkdown)(node ? `[${node.type}] ${lexeme}` : '??');
123
132
  const deps = info.controlDependencies ? ', :maybe:' + info.controlDependencies.join(',') : '';
124
- mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}${escapedName.length > 10 ? '\n ' : ' '}(${id}${deps})\n *${formatRange(mermaid.rootGraph.idMap?.get(id)?.location)}*${fCall ? displayFunctionArgMapping(info.args) : ''}\`"${close}`);
133
+ const n = node?.info.fullRange ?? node?.location ?? (node?.type === "RExpressionList" /* RType.ExpressionList */ ? node?.grouping?.[0].location : undefined);
134
+ mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}${escapedName.length > 10 ? '\n ' : ' '}(${id}${deps})\n *${formatRange(n)}*${fCall ? displayFunctionArgMapping(info.args) : ''}\`"${close}`);
125
135
  if (mark?.has(id)) {
126
136
  mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:black,stroke-width:7px; `);
127
137
  }
128
138
  const edges = mermaid.rootGraph.get(id, true);
129
139
  (0, assert_1.guard)(edges !== undefined, `node ${id} must be found`);
130
- const artificialCdEdges = (info.controlDependencies ?? []).map(x => [x, { types: new Set(['CD']) }]);
140
+ const artificialCdEdges = (info.controlDependencies ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']) }]);
131
141
  for (const [target, edge] of [...edges[1], ...artificialCdEdges]) {
132
142
  const edgeTypes = typeof edge.types == 'number' ? new Set((0, edge_1.splitEdgeTypes)(edge.types)) : edge.types;
133
143
  const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
@@ -138,7 +148,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark) {
138
148
  // who invented this syntax?!
139
149
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:red,color:red,stroke-width:4px;`);
140
150
  }
141
- if (edgeTypes.has('CD')) {
151
+ if (edgeTypes.has('CD-True')) {
142
152
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray,color:gray;`);
143
153
  }
144
154
  if (target === built_in_1.BuiltIn) {
@@ -1,8 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mermaidCodeToUrl = exports.escapeMarkdown = void 0;
4
+ const replacements = {
5
+ // keep newlines
6
+ '\\n': '\n',
7
+ '`': '#96;',
8
+ '[': '#91;',
9
+ ']': '#93;',
10
+ '<': '#60;',
11
+ '>': '#62;',
12
+ '*': '#42;',
13
+ '+': '#43;',
14
+ '-': '#45;',
15
+ '"': '#34;',
16
+ '\\': '#92;',
17
+ '_': '#95;',
18
+ '{': '#123;',
19
+ '}': '#125;'
20
+ };
4
21
  function escapeMarkdown(text) {
5
- return text.replaceAll(/([+*<>-])/g, '\\$1').replaceAll('"', '\'\'');
22
+ for (const [key, value] of Object.entries(replacements)) {
23
+ text = text.replaceAll(key, value);
24
+ }
25
+ return text;
6
26
  }
7
27
  exports.escapeMarkdown = escapeMarkdown;
8
28
  /**
package/util/version.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrVersion = void 0;
4
4
  const semver_1 = require("semver");
5
5
  // this is automatically replaced with the current version by release-it
6
- const version = '2.0.0';
6
+ const version = '2.0.2';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }