@eagleoutice/flowr 1.3.11 → 1.3.12

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 (125) hide show
  1. package/cli/common/scripts-info.d.ts +1 -1
  2. package/package.json +1 -1
  3. package/benchmark/benchmark-slicer.js +0 -223
  4. package/core/pipeline-executor.js +0 -221
  5. package/core/stepping-slicer.js +0 -160
  6. package/core/steps/all/00-parse.js +0 -19
  7. package/core/steps/all/10-normalize.js +0 -21
  8. package/core/steps/all/20-dataflow.js +0 -21
  9. package/core/steps/all/30-slice.js +0 -16
  10. package/core/steps/all/40-reconstruct.js +0 -16
  11. package/core/steps/all/core/00-parse.js +0 -24
  12. package/core/steps/all/core/10-normalize.js +0 -46
  13. package/core/steps/all/core/20-dataflow.js +0 -39
  14. package/core/steps/all/static-slicing/00-slice.js +0 -21
  15. package/core/steps/all/static-slicing/10-reconstruct.js +0 -21
  16. package/core/steps/index.js +0 -21
  17. package/core/steps/input.js +0 -3
  18. package/core/steps/output.js +0 -3
  19. package/core/steps/pipeline/create.js +0 -130
  20. package/core/steps/pipeline/default.js +0 -15
  21. package/core/steps/pipeline/dependency-checker.js +0 -76
  22. package/core/steps/pipeline/index.js +0 -20
  23. package/core/steps/pipeline/invalid-pipeline-error.js +0 -14
  24. package/core/steps/pipeline/pipeline.js +0 -28
  25. package/core/steps/step.js +0 -8
  26. package/core/steps/steps-provider.js +0 -3
  27. package/core/steps/steps.js +0 -35
  28. package/dataflow/common/environments/append.js +0 -48
  29. package/dataflow/common/environments/environment.js +0 -165
  30. package/dataflow/common/environments/index.js +0 -23
  31. package/dataflow/common/environments/overwrite.js +0 -82
  32. package/dataflow/common/environments/register.js +0 -49
  33. package/dataflow/common/environments/resolve-by-name.js +0 -35
  34. package/dataflow/common/environments/scopes.js +0 -6
  35. package/dataflow/common/environments/scoping.js +0 -27
  36. package/dataflow/graph/equal.js +0 -127
  37. package/dataflow/v1/extractor.js +0 -60
  38. package/dataflow/v1/graph/diff.js +0 -206
  39. package/dataflow/v1/graph/edge.js +0 -32
  40. package/dataflow/v1/graph/graph.js +0 -298
  41. package/dataflow/v1/graph/index.js +0 -21
  42. package/dataflow/v1/graph/quads.js +0 -27
  43. package/dataflow/v1/graph/vertex.js +0 -3
  44. package/dataflow/v1/index.js +0 -24
  45. package/dataflow/v1/internal/info.js +0 -16
  46. package/dataflow/v1/internal/linker.js +0 -255
  47. package/dataflow/v1/internal/process/access.js +0 -54
  48. package/dataflow/v1/internal/process/expression-list.js +0 -154
  49. package/dataflow/v1/internal/process/functions/argument.js +0 -46
  50. package/dataflow/v1/internal/process/functions/exit-points.js +0 -125
  51. package/dataflow/v1/internal/process/functions/function-call.js +0 -99
  52. package/dataflow/v1/internal/process/functions/function-definition.js +0 -176
  53. package/dataflow/v1/internal/process/functions/parameter.js +0 -47
  54. package/dataflow/v1/internal/process/if-then-else.js +0 -57
  55. package/dataflow/v1/internal/process/loops/for-loop.js +0 -54
  56. package/dataflow/v1/internal/process/loops/repeat-loop.js +0 -21
  57. package/dataflow/v1/internal/process/loops/while-loop.js +0 -31
  58. package/dataflow/v1/internal/process/operators/assignment.js +0 -129
  59. package/dataflow/v1/internal/process/operators/non-assignment-binary-op.js +0 -25
  60. package/dataflow/v1/internal/process/operators/pipe.js +0 -46
  61. package/dataflow/v1/internal/process/operators/unary-op.js +0 -10
  62. package/dataflow/v1/internal/process/symbol.js +0 -21
  63. package/dataflow/v1/internal/process/uninteresting-leaf.js +0 -9
  64. package/dataflow/v1/processor.js +0 -20
  65. package/dataflow/v2/entry.js +0 -11
  66. package/flowr-1.3.7.tgz +0 -0
  67. package/r-bridge/lang-4.x/ast/parser/xml/common/config.js +0 -16
  68. package/r-bridge/lang-4.x/ast/parser/xml/common/input-format.js +0 -42
  69. package/r-bridge/lang-4.x/ast/parser/xml/common/meta.js +0 -118
  70. package/r-bridge/lang-4.x/ast/parser/xml/common/xml-to-json.js +0 -58
  71. package/r-bridge/lang-4.x/ast/parser/xml/v1/data.js +0 -3
  72. package/r-bridge/lang-4.x/ast/parser/xml/v1/hooks.js +0 -136
  73. package/r-bridge/lang-4.x/ast/parser/xml/v1/index.js +0 -22
  74. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/access.js +0 -107
  75. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/control/if-then-else.js +0 -32
  76. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/control/if-then.js +0 -46
  77. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/control/index.js +0 -19
  78. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/expression/expression.js +0 -65
  79. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/expression/index.js +0 -18
  80. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/argument.js +0 -74
  81. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/call.js +0 -149
  82. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/definition.js +0 -60
  83. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/index.js +0 -20
  84. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/functions/parameter.js +0 -64
  85. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/index.js +0 -27
  86. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/break.js +0 -24
  87. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/for.js +0 -72
  88. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/index.js +0 -22
  89. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/next.js +0 -24
  90. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/repeat.js +0 -42
  91. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/loops/while.js +0 -45
  92. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/binary.js +0 -162
  93. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/index.js +0 -20
  94. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/special.js +0 -24
  95. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/operators/unary.js +0 -59
  96. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/other/comment.js +0 -34
  97. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/other/index.js +0 -18
  98. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/other/line-directive.js +0 -55
  99. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/elements.js +0 -159
  100. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/index.js +0 -20
  101. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/root.js +0 -34
  102. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/structure/single-element.js +0 -64
  103. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/index.js +0 -20
  104. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/number.js +0 -56
  105. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/string.js +0 -41
  106. package/r-bridge/lang-4.x/ast/parser/xml/v1/internal/values/symbol.js +0 -56
  107. package/r-bridge/lang-4.x/ast/parser/xml/v1/normalize.js +0 -30
  108. package/r-bridge/lang-4.x/ast/parser/xml/v2/data.js +0 -3
  109. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/access.js +0 -95
  110. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/expression.js +0 -99
  111. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/functions/argument.js +0 -71
  112. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/operators/binary.js +0 -30
  113. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/operators/index.js +0 -19
  114. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/operators/unary.js +0 -35
  115. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/other/comment.js +0 -25
  116. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/other/index.js +0 -18
  117. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/other/line-directive.js +0 -38
  118. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/root.js +0 -26
  119. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/single-element.js +0 -63
  120. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/index.js +0 -18
  121. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/number.js +0 -46
  122. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/string.js +0 -33
  123. package/r-bridge/lang-4.x/ast/parser/xml/v2/internal/values/symbol.js +0 -63
  124. package/r-bridge/lang-4.x/ast/parser/xml/v2/normalize.js +0 -25
  125. package/util/summarizer/benchmark/benchmark-summarizer.js +0 -208
@@ -1,165 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cloneEnvironments = exports.diffEnvironments = exports.diffEnvironment = exports.initializeCleanEnvironments = exports.DefaultEnvironmentMemory = exports.Environment = exports.makeAllMaybe = exports.diffIdentifierReferences = exports.BuiltIn = void 0;
4
- const resolve_by_name_1 = require("./resolve-by-name");
5
- const scopes_1 = require("./scopes");
6
- const diff_1 = require("../../../util/diff");
7
- const json_1 = require("../../../util/json");
8
- exports.BuiltIn = 'built-in';
9
- function diffIdentifierReferences(a, b, info) {
10
- if (a.name !== b.name) {
11
- info.report.addComment(`${info.position}Different identifier names: ${a.name} vs. ${b.name}`);
12
- }
13
- if (a.scope !== b.scope) {
14
- info.report.addComment(`${info.position}Different scopes: ${a.scope} vs. ${b.scope}`);
15
- }
16
- if (a.nodeId !== b.nodeId) {
17
- info.report.addComment(`${info.position}Different nodeIds: ${a.nodeId} vs. ${b.nodeId}`);
18
- }
19
- if (a.used !== b.used) {
20
- info.report.addComment(`${info.position}Different used: ${a.used} vs. ${b.used}`);
21
- }
22
- }
23
- exports.diffIdentifierReferences = diffIdentifierReferences;
24
- function makeReferenceMaybe(ref, graph, environments) {
25
- const node = graph.get(ref.nodeId, true);
26
- const definitions = (0, resolve_by_name_1.resolveByName)(ref.name, scopes_1.LocalScope, environments);
27
- for (const definition of definitions ?? []) {
28
- if (definition.kind !== 'built-in-function') {
29
- definition.used = 'maybe';
30
- }
31
- }
32
- if (node) {
33
- node[0].when = 'maybe';
34
- }
35
- return { ...ref, used: 'maybe' };
36
- }
37
- function makeAllMaybe(references, graph, environments) {
38
- if (references === undefined) {
39
- return [];
40
- }
41
- return references.map(ref => makeReferenceMaybe(ref, graph, environments));
42
- }
43
- exports.makeAllMaybe = makeAllMaybe;
44
- let environmentIdCounter = 0;
45
- class Environment {
46
- name;
47
- id = `${environmentIdCounter++}`;
48
- parent;
49
- memory;
50
- constructor(name, parent) {
51
- this.name = name;
52
- this.parent = parent;
53
- this.memory = new Map();
54
- }
55
- }
56
- exports.Environment = Environment;
57
- exports.DefaultEnvironmentMemory = new Map([
58
- ['return', [{
59
- kind: 'built-in-function',
60
- scope: scopes_1.GlobalScope,
61
- used: 'always',
62
- definedAt: exports.BuiltIn,
63
- name: 'return',
64
- nodeId: exports.BuiltIn
65
- }]],
66
- ['cat', [{
67
- kind: 'built-in-function',
68
- scope: scopes_1.GlobalScope,
69
- used: 'always',
70
- definedAt: exports.BuiltIn,
71
- name: 'cat',
72
- nodeId: exports.BuiltIn
73
- }]],
74
- ['print', [{
75
- kind: 'built-in-function',
76
- scope: scopes_1.GlobalScope,
77
- used: 'always',
78
- definedAt: exports.BuiltIn,
79
- name: 'print',
80
- nodeId: exports.BuiltIn
81
- }]]
82
- ]);
83
- function initializeCleanEnvironments() {
84
- const global = new Environment(scopes_1.GlobalScope);
85
- // use a copy
86
- global.memory = new Map(exports.DefaultEnvironmentMemory);
87
- return {
88
- current: global,
89
- level: 0
90
- };
91
- }
92
- exports.initializeCleanEnvironments = initializeCleanEnvironments;
93
- function diffEnvironment(a, b, info) {
94
- if (a === undefined || b === undefined) {
95
- if (a !== b) {
96
- info.report.addComment(`${info.position}Different environments. ${info.leftname}: ${JSON.stringify(a, json_1.jsonReplacer)} vs. ${info.rightname}: ${JSON.stringify(b, json_1.jsonReplacer)}`);
97
- }
98
- return;
99
- }
100
- if (a.name !== b.name) {
101
- info.report.addComment(`${info.position}Different environment names. ${info.leftname}: ${JSON.stringify(a, json_1.jsonReplacer)} vs. ${info.rightname}: ${JSON.stringify(b, json_1.jsonReplacer)}`);
102
- }
103
- if (a.memory.size !== b.memory.size) {
104
- info.report.addComment(`${info.position}Different environment sizes. ${info.leftname}: ${JSON.stringify(a, json_1.jsonReplacer)} vs. ${info.rightname}: ${JSON.stringify(b, json_1.jsonReplacer)}`);
105
- (0, diff_1.setDifference)(new Set([...a.memory.keys()]), new Set([...b.memory.keys()]), { ...info, position: `${info.position}Key comparison. ` });
106
- }
107
- for (const [key, value] of a.memory) {
108
- const value2 = b.memory.get(key);
109
- if (value2 === undefined || value.length !== value2.length) {
110
- info.report.addComment(`${info.position}Different definitions for ${key}. ${info.leftname}: ${JSON.stringify(value, json_1.jsonReplacer)} vs. ${info.rightname}: ${JSON.stringify(value2, json_1.jsonReplacer)}`);
111
- continue;
112
- }
113
- // we sort both value arrays by their id so that we have no problems with differently ordered arrays (which have no impact)
114
- const sorted = [...value].sort((a, b) => a.nodeId.localeCompare(b.nodeId));
115
- const sorted2 = [...value2].sort((a, b) => a.nodeId.localeCompare(b.nodeId));
116
- for (let i = 0; i < value.length; ++i) {
117
- const aVal = sorted[i];
118
- const bVal = sorted2[i];
119
- if (aVal.name !== bVal.name) {
120
- info.report.addComment(`${info.position}Different names for ${key}. ${info.leftname}: ${aVal.name} vs. ${info.rightname}: ${bVal.name}`);
121
- }
122
- if (aVal.nodeId !== bVal.nodeId) {
123
- info.report.addComment(`${info.position}Different ids for ${key}. ${info.leftname}: ${aVal.nodeId} vs. ${info.rightname}: ${bVal.nodeId}`);
124
- }
125
- if (aVal.scope !== bVal.scope) {
126
- info.report.addComment(`${info.position}Different scopes for ${key} (${aVal.nodeId}). ${info.leftname}: ${aVal.scope} vs. ${info.rightname}: ${bVal.scope}`);
127
- }
128
- if (aVal.used !== bVal.used) {
129
- info.report.addComment(`${info.position}Different used for ${key} (${aVal.nodeId}). ${info.leftname}: ${aVal.used} vs. ${info.rightname}: ${bVal.used}`);
130
- }
131
- if (aVal.definedAt !== bVal.definedAt) {
132
- info.report.addComment(`${info.position}Different definition ids (definedAt) for ${key} (${aVal.nodeId}). ${info.leftname}: ${aVal.definedAt} vs. ${info.rightname}: ${bVal.definedAt}`);
133
- }
134
- if (aVal.kind !== bVal.kind) {
135
- info.report.addComment(`${info.position}Different kinds for ${key} (${aVal.nodeId}). ${info.leftname}: ${aVal.kind} vs. ${info.rightname}: ${bVal.kind}`);
136
- }
137
- }
138
- }
139
- diffEnvironment(a.parent, b.parent, { ...info, position: `${info.position}Parents of ${a.id} & ${b.id}. ` });
140
- }
141
- exports.diffEnvironment = diffEnvironment;
142
- function diffEnvironments(a, b, info) {
143
- if (a === undefined || b === undefined) {
144
- info.report.addComment(`${info.position}Different environments: ${JSON.stringify(a, json_1.jsonReplacer)} vs. ${JSON.stringify(b, json_1.jsonReplacer)}`);
145
- return;
146
- }
147
- diffEnvironment(a.current, b.current, info);
148
- }
149
- exports.diffEnvironments = diffEnvironments;
150
- function cloneEnvironment(environment, recurseParents) {
151
- if (environment === undefined) {
152
- return undefined;
153
- }
154
- const clone = new Environment(environment.name, recurseParents ? cloneEnvironment(environment.parent, recurseParents) : environment.parent);
155
- clone.memory = new Map(JSON.parse(JSON.stringify([...environment.memory])));
156
- return clone;
157
- }
158
- function cloneEnvironments(environment, recurseParents = true) {
159
- return {
160
- current: cloneEnvironment(environment.current, recurseParents),
161
- level: environment.level
162
- };
163
- }
164
- exports.cloneEnvironments = cloneEnvironments;
165
- //# sourceMappingURL=environment.js.map
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./append"), exports);
18
- __exportStar(require("./resolve-by-name"), exports);
19
- __exportStar(require("./scoping"), exports);
20
- __exportStar(require("./overwrite"), exports);
21
- __exportStar(require("./environment"), exports);
22
- __exportStar(require("./register"), exports);
23
- //# sourceMappingURL=index.js.map
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.overwriteEnvironments = exports.overwriteIEnvironmentWith = void 0;
4
- const assert_1 = require("../../../util/assert");
5
- const environment_1 = require("./environment");
6
- function anyIsMaybeGuardingSame(values) {
7
- if (values.length === 0) {
8
- return true;
9
- }
10
- const attr = values[0].used;
11
- if (attr === 'maybe') {
12
- return true;
13
- }
14
- let same = true;
15
- for (let i = 1; i < values.length; i++) {
16
- const used = values[i].used;
17
- if (used === 'maybe') {
18
- return true;
19
- }
20
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- in case we want to add more attributes in the future
21
- if (used !== attr) {
22
- same = false;
23
- }
24
- }
25
- if (!same) {
26
- throw new Error('all values must have either a maybe or are all the same');
27
- }
28
- return false;
29
- }
30
- function overwriteIEnvironmentWith(base, next, includeParent = true) {
31
- (0, assert_1.guard)(base !== undefined && next !== undefined, 'can not overwrite environments with undefined');
32
- (0, assert_1.guard)(base.name === next.name, 'cannot overwrite environments with different names');
33
- const map = new Map(base.memory);
34
- for (const [key, values] of next.memory) {
35
- const hasMaybe = anyIsMaybeGuardingSame(values);
36
- if (hasMaybe) {
37
- const old = map.get(key);
38
- // we need to make a copy to avoid side effects for old reference in other environments
39
- const updatedOld = old ?? [];
40
- for (const v of values) {
41
- const index = updatedOld.findIndex(o => o.nodeId === v.nodeId && o.definedAt === v.definedAt);
42
- if (index < 0) {
43
- updatedOld.push(v);
44
- }
45
- }
46
- map.set(key, [...updatedOld]);
47
- }
48
- else {
49
- map.set(key, values);
50
- }
51
- }
52
- let parent;
53
- if (includeParent) {
54
- parent = base.parent === undefined ? undefined : overwriteIEnvironmentWith(base.parent, next.parent);
55
- }
56
- else {
57
- parent = base.parent;
58
- }
59
- const out = new environment_1.Environment(base.name, parent);
60
- out.memory = map;
61
- return out;
62
- }
63
- exports.overwriteIEnvironmentWith = overwriteIEnvironmentWith;
64
- /**
65
- * Assumes, that all definitions within next replace those within base (given the same name).
66
- * <b>But</b> if all definitions within next are maybe, then they are appended to the base definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironments}.
67
- */
68
- function overwriteEnvironments(base, next) {
69
- if (base === undefined) {
70
- return next;
71
- }
72
- else if (next === undefined) {
73
- return base;
74
- }
75
- (0, assert_1.guard)(next.level === base.level, `cannot overwrite environments with differently nested local scopes, base ${base.level} vs. next ${next.level}. This should not happen.`);
76
- return {
77
- current: overwriteIEnvironmentWith(base.current, next.current),
78
- level: base.level
79
- };
80
- }
81
- exports.overwriteEnvironments = overwriteEnvironments;
82
- //# sourceMappingURL=overwrite.js.map
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.define = void 0;
4
- const assert_1 = require("../../../util/assert");
5
- const environment_1 = require("./environment");
6
- const scopes_1 = require("./scopes");
7
- function defInEnv(newEnvironments, definition) {
8
- const existing = newEnvironments.memory.get(definition.name);
9
- // check if it is maybe or not
10
- if (existing === undefined || definition.used === 'always') {
11
- newEnvironments.memory.set(definition.name, [definition]);
12
- }
13
- else {
14
- existing.push(definition);
15
- }
16
- }
17
- /**
18
- * Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
19
- * Does not modify the passed along `environments` in-place! It returns the new reference.
20
- */
21
- function define(definition, withinScope, environments) {
22
- let newEnvironments = environments;
23
- if (withinScope === scopes_1.LocalScope) {
24
- newEnvironments = (0, environment_1.cloneEnvironments)(environments, false);
25
- defInEnv(newEnvironments.current, definition);
26
- }
27
- else if (withinScope === scopes_1.GlobalScope) {
28
- newEnvironments = (0, environment_1.cloneEnvironments)(environments, true);
29
- let current = newEnvironments.current;
30
- let last = undefined;
31
- let found = false;
32
- do {
33
- if (current.memory.has(definition.name)) {
34
- current.memory.set(definition.name, [definition]);
35
- found = true;
36
- break;
37
- }
38
- last = current;
39
- current = current.parent;
40
- } while (current !== undefined);
41
- if (!found) {
42
- (0, assert_1.guard)(last !== undefined, () => `Could not find global scope for ${definition.name}`);
43
- last.memory.set(definition.name, [definition]);
44
- }
45
- }
46
- return newEnvironments;
47
- }
48
- exports.define = define;
49
- //# sourceMappingURL=register.js.map
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveByName = void 0;
4
- const v1_1 = require("../../v1");
5
- const scopes_1 = require("./scopes");
6
- /**
7
- * Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
8
- *
9
- * @param name - The name of the identifier to resolve
10
- * @param withinScope - The scope in which the identifier is used
11
- * @param environments - The current environments used for name resolution
12
- *
13
- * @returns A list of possible definitions of the identifier (one if the definition location is exactly and always known), or `undefined` if the identifier is undefined in the current scope/with the current environment information.
14
- */
15
- function resolveByName(name, withinScope, environments) {
16
- if (withinScope !== scopes_1.LocalScope) {
17
- throw new Error('Non-local scoping is not yet supported');
18
- }
19
- return resolve(name, withinScope, environments);
20
- }
21
- exports.resolveByName = resolveByName;
22
- function resolve(name, withinScope, environments) {
23
- v1_1.dataflowLogger.trace(`Resolving local identifier ${name} (scope name: ${withinScope}, local stack size: ${environments.level})`);
24
- let current = environments.current;
25
- do {
26
- const definition = current.memory.get(name);
27
- if (definition !== undefined) {
28
- return definition;
29
- }
30
- current = current.parent;
31
- } while (current !== undefined);
32
- v1_1.dataflowLogger.trace(`Unable to find identifier ${name} in stack`);
33
- return undefined;
34
- }
35
- //# sourceMappingURL=resolve-by-name.js.map
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalScope = exports.GlobalScope = void 0;
4
- exports.GlobalScope = '.GlobalEnv';
5
- exports.LocalScope = 'local';
6
- //# sourceMappingURL=scopes.js.map
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.popLocalEnvironment = exports.pushLocalEnvironment = void 0;
4
- const environment_1 = require("./environment");
5
- const assert_1 = require("../../../util/assert");
6
- const scopes_1 = require("./scopes");
7
- /** Add a new local environment scope to the stack, returns the modified variant - sharing the original environments in the stack (no deep-clone) */
8
- function pushLocalEnvironment(base) {
9
- const local = new environment_1.Environment(scopes_1.LocalScope);
10
- local.parent = base.current;
11
- return {
12
- current: local,
13
- level: base.level + 1
14
- };
15
- }
16
- exports.pushLocalEnvironment = pushLocalEnvironment;
17
- function popLocalEnvironment(base) {
18
- (0, assert_1.guard)(base.level > 0, 'cannot remove the global/root environment');
19
- const parent = base.current.parent;
20
- (0, assert_1.guard)(parent !== undefined, 'level is wrong, parent is undefined even though level suggested depth > 0 (starts with 0)');
21
- return {
22
- current: parent,
23
- level: base.level - 1
24
- };
25
- }
26
- exports.popLocalEnvironment = popLocalEnvironment;
27
- //# sourceMappingURL=scoping.js.map
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.equalEdges = exports.equalVertices = exports.equalFunctionArguments = exports.equalExitPoints = void 0;
4
- const environments_1 = require("../environments");
5
- const index_1 = require("../index");
6
- const assert_1 = require("../../util/assert");
7
- const json_1 = require("../../util/json");
8
- const set_1 = require("../../util/set");
9
- function equalFunctionArgumentsReferences(a, b) {
10
- if (a === '<value>' || b === '<value>') {
11
- return a === b;
12
- }
13
- return (0, environments_1.equalIdentifierReferences)(a, b);
14
- }
15
- function equalExitPoints(a, b) {
16
- if (a === undefined || b === undefined) {
17
- return a === b;
18
- }
19
- if (a.length !== b.length) {
20
- return false;
21
- }
22
- for (let i = 0; i < a.length; ++i) {
23
- if (a[i] !== b[i]) {
24
- return false;
25
- }
26
- }
27
- return true;
28
- }
29
- exports.equalExitPoints = equalExitPoints;
30
- function equalFunctionArguments(a, b) {
31
- if (a === false || b === false) {
32
- return a === b;
33
- }
34
- else if (a.length !== b.length) {
35
- return false;
36
- }
37
- for (let i = 0; i < a.length; ++i) {
38
- const aArg = a[i];
39
- const bArg = b[i];
40
- if (Array.isArray(aArg) && Array.isArray(bArg)) {
41
- // must have same name
42
- if (aArg[0] !== bArg[0]) {
43
- return false;
44
- }
45
- if (!equalFunctionArgumentsReferences(aArg[1], bArg[1])) {
46
- return false;
47
- }
48
- }
49
- else if (!equalFunctionArgumentsReferences(aArg, bArg)) {
50
- return false;
51
- }
52
- }
53
- return true;
54
- }
55
- exports.equalFunctionArguments = equalFunctionArguments;
56
- function equalVertices(our, other) {
57
- if (our.size !== other.size) {
58
- index_1.dataflowLogger.warn(`graph size does not match: ${our.size} vs ${other.size}`);
59
- return false;
60
- }
61
- for (const [id, info] of our) {
62
- const otherInfo = other.get(id);
63
- if (otherInfo === undefined || info.tag !== otherInfo.tag || info.name !== otherInfo.name) {
64
- index_1.dataflowLogger.warn(`node ${id} does not match (${JSON.stringify(info)} vs ${JSON.stringify(otherInfo)})`);
65
- return false;
66
- }
67
- if (info.tag === 'variable-definition' || info.tag === 'function-definition') {
68
- (0, assert_1.guard)(info.tag === otherInfo.tag, () => `node ${id} does not match on tag (${info.tag} vs ${otherInfo.tag})`);
69
- if (info.scope !== otherInfo.scope) {
70
- index_1.dataflowLogger.warn(`node ${id} does not match on scope (${JSON.stringify(info.scope)} vs ${JSON.stringify(otherInfo.scope)})`);
71
- return false;
72
- }
73
- }
74
- if (info.when !== otherInfo.when) {
75
- index_1.dataflowLogger.warn(`node ${id} does not match on when (${JSON.stringify(info.when)} vs ${JSON.stringify(otherInfo.when)})`);
76
- return false;
77
- }
78
- if (!(0, environments_1.environmentsEqual)(info.environment, otherInfo.environment)) {
79
- index_1.dataflowLogger.warn(`node ${id} does not match on environments (${JSON.stringify(info.environment)} vs ${JSON.stringify(otherInfo.environment)})`);
80
- return false;
81
- }
82
- if (info.tag === 'function-call') {
83
- (0, assert_1.guard)(otherInfo.tag === 'function-call', 'otherInfo must be a function call as well');
84
- if (!equalFunctionArguments(info.args, otherInfo.args)) {
85
- index_1.dataflowLogger.warn(`node ${id} does not match on function arguments (${JSON.stringify(info.args)} vs ${JSON.stringify(otherInfo.args)})`);
86
- return false;
87
- }
88
- }
89
- if (info.tag === 'function-definition') {
90
- (0, assert_1.guard)(otherInfo.tag === 'function-definition', 'otherInfo must be a function definition as well');
91
- if (!equalExitPoints(info.exitPoints, otherInfo.exitPoints)) {
92
- index_1.dataflowLogger.warn(`node ${id} does not match on exit points (${JSON.stringify(info.exitPoints)} vs ${JSON.stringify(otherInfo.exitPoints)})`);
93
- return false;
94
- }
95
- if (info.subflow.scope !== otherInfo.subflow.scope || !(0, environments_1.environmentsEqual)(info.subflow.environments, otherInfo.subflow.environments)) {
96
- index_1.dataflowLogger.warn(`node ${id} does not match on subflow (${JSON.stringify(info)} vs ${JSON.stringify(otherInfo)})`);
97
- return false;
98
- }
99
- if (!(0, set_1.setEquals)(info.subflow.graph, otherInfo.subflow.graph)) {
100
- index_1.dataflowLogger.warn(`node ${id} does not match on subflow graph (${JSON.stringify(info)} vs ${JSON.stringify(otherInfo)})`);
101
- return false;
102
- }
103
- }
104
- }
105
- return true;
106
- }
107
- exports.equalVertices = equalVertices;
108
- function equalEdges(id, our, other) {
109
- if (our === undefined || other === undefined) {
110
- return our === other;
111
- }
112
- if (our.size !== other.size) {
113
- index_1.dataflowLogger.warn(`total edge size for ${id} does not match: ${our.size} vs ${other.size} (${JSON.stringify(our, json_1.jsonReplacer)}, ${JSON.stringify(other, json_1.jsonReplacer)})`);
114
- return false;
115
- }
116
- // order independent compare
117
- for (const [target, edge] of our) {
118
- const otherEdge = other.get(target);
119
- if (otherEdge === undefined || edge.types.size !== otherEdge.types.size || [...edge.types].some(e => !otherEdge.types.has(e)) || edge.attribute !== otherEdge.attribute) {
120
- index_1.dataflowLogger.warn(`edge with ${id}->${target} does not match (${JSON.stringify(edge, json_1.jsonReplacer)} vs ${JSON.stringify(otherEdge, json_1.jsonReplacer)})`);
121
- return false;
122
- }
123
- }
124
- return true;
125
- }
126
- exports.equalEdges = equalEdges;
127
- //# sourceMappingURL=equal.js.map
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processBinaryOp = exports.produceDataFlowGraph = void 0;
4
- const processor_1 = require("./processor");
5
- const uninteresting_leaf_1 = require("./internal/process/uninteresting-leaf");
6
- const symbol_1 = require("./internal/process/symbol");
7
- const non_assignment_binary_op_1 = require("./internal/process/operators/non-assignment-binary-op");
8
- const unary_op_1 = require("./internal/process/operators/unary-op");
9
- const expression_list_1 = require("./internal/process/expression-list");
10
- const repeat_loop_1 = require("./internal/process/loops/repeat-loop");
11
- const for_loop_1 = require("./internal/process/loops/for-loop");
12
- const while_loop_1 = require("./internal/process/loops/while-loop");
13
- const if_then_else_1 = require("./internal/process/if-then-else");
14
- const function_call_1 = require("./internal/process/functions/function-call");
15
- const function_definition_1 = require("./internal/process/functions/function-definition");
16
- const parameter_1 = require("./internal/process/functions/parameter");
17
- const environments_1 = require("../common/environments");
18
- const argument_1 = require("./internal/process/functions/argument");
19
- const assignment_1 = require("./internal/process/operators/assignment");
20
- const access_1 = require("./internal/process/access");
21
- const pipe_1 = require("./internal/process/operators/pipe");
22
- const scopes_1 = require("../common/environments/scopes");
23
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- allows type adaption without re-creation
24
- const processors = {
25
- ["RNumber" /* RType.Number */]: uninteresting_leaf_1.processUninterestingLeaf,
26
- ["RString" /* RType.String */]: uninteresting_leaf_1.processUninterestingLeaf,
27
- ["RLogical" /* RType.Logical */]: uninteresting_leaf_1.processUninterestingLeaf,
28
- ["RAccess" /* RType.Access */]: access_1.processAccess,
29
- ["RSymbol" /* RType.Symbol */]: symbol_1.processSymbol,
30
- ["RBinaryOp" /* RType.BinaryOp */]: processBinaryOp,
31
- ["RPipe" /* RType.Pipe */]: pipe_1.processPipeOperation,
32
- ["RUnaryOp" /* RType.UnaryOp */]: unary_op_1.processUnaryOp,
33
- ["RForLoop" /* RType.ForLoop */]: for_loop_1.processForLoop,
34
- ["RWhileLoop" /* RType.WhileLoop */]: while_loop_1.processWhileLoop,
35
- ["RRepeatLoop" /* RType.RepeatLoop */]: repeat_loop_1.processRepeatLoop,
36
- ["RIfThenElse" /* RType.IfThenElse */]: if_then_else_1.processIfThenElse,
37
- ["RBreak" /* RType.Break */]: uninteresting_leaf_1.processUninterestingLeaf,
38
- ["RNext" /* RType.Next */]: uninteresting_leaf_1.processUninterestingLeaf,
39
- ["RComment" /* RType.Comment */]: uninteresting_leaf_1.processUninterestingLeaf,
40
- ["RLineDirective" /* RType.LineDirective */]: uninteresting_leaf_1.processUninterestingLeaf,
41
- ["RFunctionCall" /* RType.FunctionCall */]: function_call_1.processFunctionCall,
42
- ["RFunctionDefinition" /* RType.FunctionDefinition */]: function_definition_1.processFunctionDefinition,
43
- ["RParameter" /* RType.Parameter */]: parameter_1.processFunctionParameter,
44
- ["RArgument" /* RType.Argument */]: argument_1.processFunctionArgument,
45
- ["RExpressionList" /* RType.ExpressionList */]: expression_list_1.processExpressionList,
46
- };
47
- function produceDataFlowGraph(ast, initialScope = scopes_1.LocalScope) {
48
- return (0, processor_1.processDataflowFor)(ast.ast, { completeAst: ast, activeScope: initialScope, environments: (0, environments_1.initializeCleanEnvironments)(), processors: processors });
49
- }
50
- exports.produceDataFlowGraph = produceDataFlowGraph;
51
- function processBinaryOp(node, data) {
52
- if (node.flavor === 'assignment') {
53
- return (0, assignment_1.processAssignment)(node, data);
54
- }
55
- else {
56
- return (0, non_assignment_binary_op_1.processNonAssignmentBinaryOp)(node, data);
57
- }
58
- }
59
- exports.processBinaryOp = processBinaryOp;
60
- //# sourceMappingURL=extractor.js.map