@eagleoutice/flowr 2.15.4 → 2.15.8

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 (34) hide show
  1. package/config.d.ts +2 -0
  2. package/config.js +3 -1
  3. package/dataflow/environments/default-builtin-config.d.ts +57 -0
  4. package/dataflow/environments/default-builtin-config.js +6 -2
  5. package/dataflow/environments/environment.d.ts +11 -19
  6. package/dataflow/environments/environment.js +17 -39
  7. package/dataflow/environments/frame-memory.d.ts +33 -68
  8. package/dataflow/environments/frame-memory.js +77 -200
  9. package/dataflow/environments/identifier.d.ts +5 -0
  10. package/dataflow/environments/resolve-by-name.js +7 -1
  11. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +1 -1
  12. package/dataflow/internal/process/functions/call/argument/make-argument.js +17 -1
  13. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +16 -4
  14. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +12 -0
  15. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +5 -19
  16. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  17. package/dataflow/internal/process/process-named-call.js +3 -3
  18. package/documentation/wiki-setup.js +28 -3
  19. package/linter/rules/unescaped-arguments.js +43 -3
  20. package/package.json +1 -1
  21. package/project/context/flowr-analyzer-files-context.d.ts +2 -2
  22. package/project/context/flowr-analyzer-files-context.js +3 -0
  23. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -0
  24. package/project/sigdb/decode.d.ts +5 -4
  25. package/project/sigdb/decode.js +13 -18
  26. package/project/sigdb/dict.d.ts +35 -0
  27. package/project/sigdb/dict.js +97 -0
  28. package/project/sigdb/hash.d.ts +7 -2
  29. package/project/sigdb/reader.d.ts +9 -6
  30. package/project/sigdb/reader.js +40 -28
  31. package/slicing/static/fingerprint.js +6 -12
  32. package/util/text/playground-link.d.ts +14 -5
  33. package/util/text/playground-link.js +32 -8
  34. package/util/version.js +2 -2
@@ -1,241 +1,118 @@
1
1
  "use strict";
2
2
  /**
3
- * One environment frame's bindings, shared by every snapshot of it: a snapshot is the frame plus a version, not a
4
- * copy. Copying instead cost a whole map per snapshot, and a call vertex keeps one, so a scope with thousands of
5
- * definitions retained memory in the square of them. The newest version is answered from a plain map, an older one
6
- * from what the writes recorded.
3
+ * One environment frame's bindings, shared until something writes: the writer forks, so cloning is free and a
4
+ * definition pays for the copy.
7
5
  * @module
8
6
  */
9
7
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.WritableMemory = exports.MemoryView = exports.Frame = void 0;
8
+ exports.LazyBindings = exports.Frame = void 0;
11
9
  const assert_1 = require("../../util/assert");
12
- /** the index in `history` of what the greatest version at most `version` bound, `-1` if unbound then */
13
- function at(history, version) {
14
- let low = 0;
15
- let high = (history.length >> 1) - 1;
16
- while (low <= high) {
17
- const mid = (low + high) >> 1;
18
- if (history[mid << 1] <= version) {
19
- low = mid + 1;
20
- }
21
- else {
22
- high = mid - 1;
23
- }
24
- }
25
- return high < 0 ? -1 : (high << 1) + 1;
26
- }
27
- /**
28
- * One frame's bindings across its versions. A frame {@link Frame.of|taken from a map} is frozen: one state, never
29
- * written, versioned only once {@link forWrite} forks it -- the built-in environment and the package layers.
30
- */
10
+ /** One frame's bindings. {@link Frame.of|Taken from a map} it is frozen, since the map is somebody else's. */
31
11
  class Frame {
32
- /** the bindings at {@link version} and no other, so read it only after checking the version, as {@link get} does */
33
- live;
34
- /** whether {@link live} is this frame's own to write, see {@link Frame.of} */
12
+ bindings;
35
13
  frozen;
36
- /** what each *rewritten* name held per version, for older snapshots; built on the first rewrite, as most see none */
37
- history;
38
- /** when each name still on its first binding came in; a write-once name needs no more, and most are */
39
- bornAt;
40
- /** the last past version walked out into a map, so re-reading that snapshot skips the walk; one slot only */
41
- walked;
42
- /** the newest version written here, counting this frame's writes alone; only a snapshot at it may extend the frame */
43
- version = 0;
44
- constructor(live, frozen) {
45
- this.live = live;
14
+ constructor(bindings, frozen) {
15
+ this.bindings = bindings;
46
16
  this.frozen = frozen;
47
17
  }
48
- /** A frame holding what `map` holds, frozen: only read through here, a write forks rather than reaching back. */
18
+ /** A frame over `map`, frozen, so a write forks rather than reaching back into it. */
49
19
  static of(map) {
50
20
  return new Frame(map, true);
51
21
  }
52
- /** A frame holding nothing, the same one every time, so an environment that defines nothing allocates nothing. */
22
+ /** The empty frame, the same one every time, so an environment defining nothing allocates nothing. */
53
23
  static empty() {
54
24
  return EmptyFrame;
55
25
  }
56
- /** What `name` held at `version`. One lookup for the newest version, small enough for V8 to inline. */
57
- get(name, version) {
58
- return version === this.version ? this.live.get(name) : this.bound(name, version);
59
- }
60
- /** What `name` held at a version written past since. */
61
- bound(name, version) {
62
- const history = this.history?.get(name);
63
- if (history !== undefined) {
64
- const index = at(history, version);
65
- return index < 0 ? undefined : history[index];
66
- }
67
- const born = this.bornAt?.get(name);
68
- /* never rewritten, so it still holds what it held then -- unless it came in after then */
69
- return born !== undefined && born > version ? undefined : this.live.get(name);
70
- }
71
- /** Whether `name` was bound at `version`. */
72
- has(name, version) {
73
- return (version === this.version ? this.live.get(name) : this.bound(name, version)) !== undefined;
74
- }
75
- /** The names `version` binds. */
76
- keys(version) {
77
- return (this.settledAt(version) ?? this.materialize(version)).keys();
78
- }
79
- /** What `version` binds, without the names. */
80
- values(version) {
81
- return (this.settledAt(version) ?? this.materialize(version)).values();
82
- }
83
- /** How many names `version` binds. */
84
- size(version) {
85
- return (this.settledAt(version) ?? this.materialize(version)).size;
86
- }
87
- /** What `version` binds, name by name. */
88
- entries(version) {
89
- return (this.settledAt(version) ?? this.materialize(version)).entries();
90
- }
91
- /**
92
- * `version` as a map, `undefined` when it has to be walked out. A frame that never rewrote or took on a name has
93
- * held the same bindings throughout, so {@link live} answers for any version of it.
94
- */
95
- settledAt(version) {
96
- if (version === this.version || (this.history === undefined && this.bornAt === undefined)) {
97
- return this.live;
98
- }
99
- const walked = this.walked;
100
- return walked !== undefined && walked.version === version ? walked.bindings : undefined;
101
- }
102
- /** `version` walked out into a map, kept in the {@link walked} slot. */
103
- materialize(version) {
104
- const bindings = new Map(this.recorded(version));
105
- this.walked = { version, bindings };
106
- return bindings;
107
- }
108
- /** What `version` bound; the rewritten names come first, since one dropped since is no longer in {@link live}. */
109
- *recorded(version) {
110
- const history = this.history;
111
- if (history !== undefined) {
112
- for (const name of history.keys()) {
113
- const defs = this.bound(name, version);
114
- if (defs !== undefined) {
115
- yield [name, defs];
116
- }
117
- }
118
- }
119
- for (const [name, defs] of this.live) {
120
- if (history?.has(name)) {
121
- continue;
122
- }
123
- const born = this.bornAt?.get(name);
124
- if (born === undefined || born <= version) {
125
- yield [name, defs];
126
- }
127
- }
26
+ /** A copy of these bindings that the caller owns. */
27
+ forWrite() {
28
+ return new Frame(new Map(this.bindings), false);
128
29
  }
129
- /** The frame a snapshot at `version` writes to: this one if it holds the newest version, a fork otherwise. */
130
- forWrite(version) {
131
- if (!this.frozen && version === this.version) {
132
- return this;
133
- }
134
- return new Frame(new Map(this.settledAt(version) ?? this.materialize(version)), false);
135
- }
136
- /** The version the next write goes to; only a frame {@link forWrite} just returned may hand one out. */
137
- nextVersion() {
138
- (0, assert_1.guard)(!this.frozen, 'a frozen frame hands out no version, fork it with forWrite first');
139
- return ++this.version;
140
- }
141
- /** Binds `name` at `version`, `undefined` removing it. Only the newest version may be written; snapshots hold the rest. */
142
- set(name, defs, version) {
143
- const live = this.live;
144
- (0, assert_1.guard)(!this.frozen && version === this.version, () => `cannot write version ${version} of a frame standing at ${this.version}`);
145
- const history = this.history?.get(name);
146
- if (history !== undefined) {
147
- if (history[history.length - 2] === version) {
148
- history[history.length - 1] = defs;
149
- }
150
- else {
151
- history.push(version, defs);
152
- }
153
- }
154
- else {
155
- const before = live.get(name);
156
- const born = this.bornAt?.get(name);
157
- if (before === undefined && born === undefined) {
158
- /* never held here, so when it came in is all an older snapshot needs */
159
- (this.bornAt ??= new Map()).set(name, version);
160
- }
161
- else {
162
- /* record what it is replacing before the write buries it */
163
- this.bornAt?.delete(name);
164
- (this.history ??= new Map()).set(name, [born ?? 0, before, version, defs]);
165
- }
166
- }
167
- if (defs === undefined) {
168
- live.delete(name);
169
- }
170
- else {
171
- live.set(name, defs);
172
- }
30
+ set(name, defs) {
31
+ (0, assert_1.guard)(!this.frozen, 'a frozen frame takes no writes, fork it with forWrite first');
32
+ this.bindings.set(name, defs);
173
33
  }
174
- }
175
- exports.Frame = Frame;
176
- /** what every environment starts out on, until a write forks it one of its own */
177
- const EmptyFrame = Frame.of(new Map());
178
- /** One environment's view of its {@link Frame}, as a {@link ReadonlyMap} so the old readers of the map still work. */
179
- class MemoryView {
180
- frame;
181
- version;
182
- constructor(frame, version) {
183
- this.frame = frame;
184
- this.version = version;
34
+ delete(name) {
35
+ (0, assert_1.guard)(!this.frozen, 'a frozen frame takes no writes, fork it with forWrite first');
36
+ this.bindings.delete(name);
185
37
  }
186
38
  get(name) {
187
- return this.frame.get(name, this.version);
39
+ return this.bindings.get(name);
188
40
  }
189
41
  has(name) {
190
- return this.frame.has(name, this.version);
42
+ return this.bindings.has(name);
191
43
  }
192
44
  get size() {
193
- return this.frame.size(this.version);
45
+ return this.bindings.size;
46
+ }
47
+ keys() {
48
+ return this.bindings.keys();
49
+ }
50
+ values() {
51
+ return this.bindings.values();
194
52
  }
195
53
  entries() {
196
- return this.frame.entries(this.version);
54
+ return this.bindings.entries();
197
55
  }
198
56
  [Symbol.iterator]() {
199
- return this.frame.entries(this.version);
57
+ return this.bindings.entries();
200
58
  }
201
- keys() {
202
- return this.frame.keys(this.version);
59
+ forEach(fn, thisArg) {
60
+ this.bindings.forEach(fn, thisArg);
203
61
  }
204
- values() {
205
- return this.frame.values(this.version);
62
+ }
63
+ exports.Frame = Frame;
64
+ /** what every environment starts out on, until a write forks it one of its own */
65
+ const EmptyFrame = Frame.of(new Map());
66
+ /**
67
+ * The bindings of an attached package, built one name at a time. An attach used to materialize a definition per
68
+ * export, and a script attaching a handful of packages carries hundreds of thousands of them for the few dozen
69
+ * names it ever mentions. Here the export list is all that is held until a lookup asks for one.
70
+ */
71
+ class LazyBindings {
72
+ names;
73
+ bind;
74
+ built = new Map();
75
+ constructor(names, bind) {
76
+ this.names = names;
77
+ this.bind = bind;
206
78
  }
207
- forEach(fn, thisArg) {
208
- const settled = this.frame.settledAt(this.version);
209
- if (settled !== undefined) {
210
- settled.forEach(fn, thisArg);
211
- return;
79
+ get(name) {
80
+ if (!this.names.has(name)) {
81
+ return undefined;
212
82
  }
213
- for (const [name, defs] of this.frame.entries(this.version)) {
214
- fn.call(thisArg, defs, name, this);
83
+ let defs = this.built.get(name);
84
+ if (defs === undefined) {
85
+ this.built.set(name, defs = this.bind(name));
215
86
  }
87
+ return defs;
216
88
  }
217
- }
218
- exports.MemoryView = MemoryView;
219
- /** The write end of a {@link Frame} at one version, standing in for the map writers used to get. */
220
- class WritableMemory {
221
- frame;
222
- version;
223
- constructor(frame, version) {
224
- this.frame = frame;
225
- this.version = version;
89
+ has(name) {
90
+ return this.names.has(name);
226
91
  }
227
- set(name, defs) {
228
- this.frame.set(name, defs, this.version);
92
+ get size() {
93
+ return this.names.size;
229
94
  }
230
- delete(name) {
231
- this.frame.set(name, undefined, this.version);
95
+ keys() {
96
+ return this.names.keys();
232
97
  }
233
- get(name) {
234
- return this.frame.get(name, this.version);
98
+ *entries() {
99
+ for (const name of this.names) {
100
+ yield [name, this.get(name)];
101
+ }
235
102
  }
236
- has(name) {
237
- return this.frame.has(name, this.version);
103
+ [Symbol.iterator]() {
104
+ return this.entries();
105
+ }
106
+ *values() {
107
+ for (const [, defs] of this.entries()) {
108
+ yield defs;
109
+ }
110
+ }
111
+ forEach(fn, thisArg) {
112
+ for (const [name, defs] of this.entries()) {
113
+ fn.call(thisArg, defs, name, this);
114
+ }
238
115
  }
239
116
  }
240
- exports.WritableMemory = WritableMemory;
117
+ exports.LazyBindings = LazyBindings;
241
118
  //# sourceMappingURL=frame-memory.js.map
@@ -176,6 +176,7 @@ export declare const enum PkgName {
176
176
  Av = "av",
177
177
  AwsS3 = "aws.s3",
178
178
  Box = "box",
179
+ Brew = "brew",
179
180
  Callr = "callr",
180
181
  Car = "car",
181
182
  Claddis = "Claddis",
@@ -269,6 +270,7 @@ export declare const enum PkgName {
269
270
  RmethodsS3 = "R.methodsS3",
270
271
  Rnetcdf = "RNetCDF",
271
272
  Roo = "R.oo",
273
+ Rprintf = "rprintf",
272
274
  RsConnect = "rsconnect",
273
275
  Rstatix = "rstatix",
274
276
  RstudioApi = "rstudioapi",
@@ -287,6 +289,7 @@ export declare const enum PkgName {
287
289
  Sourcetools = "sourcetools",
288
290
  Sqldf = "sqldf",
289
291
  Stars = "stars",
292
+ Stringmagic = "stringmagic",
290
293
  Stringr = "stringr",
291
294
  SvDialogs = "svDialogs",
292
295
  Svglite = "svglite",
@@ -304,7 +307,9 @@ export declare const enum PkgName {
304
307
  UseThis = "usethis",
305
308
  VisNetwork = "visNetwork",
306
309
  Vroom = "vroom",
310
+ Whisker = "whisker",
307
311
  Withr = "withr",
312
+ Wrapr = "wrapr",
308
313
  Writexl = "writexl",
309
314
  Xfun = "xfun",
310
315
  XlConnect = "XLConnect",
@@ -10,6 +10,8 @@ const identifier_1 = require("./identifier");
10
10
  const info_1 = require("../info");
11
11
  const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
12
12
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
13
+ /** how many answers a frozen layer memoizes before it starts over, so the memo cannot grow without bound */
14
+ const TailCacheCap = 4096;
13
15
  /** A namespaced lookup only sees its matching layer; a bare lookup skips loaded-but-unattached namespaces (`requireNamespace`). */
14
16
  function layerSkipped(layer, ns) {
15
17
  if (ns !== undefined) {
@@ -164,7 +166,11 @@ function resolveByTargetType(id, environment, target) {
164
166
  ? (builtIns === undefined || builtIns.length === 0 ? definitions : definitions.concat(builtIns))
165
167
  : (builtIns === undefined || builtIns.length > 0 ? builtIns : undefined);
166
168
  if (flattenAt !== undefined) {
167
- (flattenAt.tailCache ??= new Map()).set(key, result);
169
+ const memo = flattenAt.tailCache ??= new Map();
170
+ if (memo.size >= TailCacheCap) {
171
+ memo.clear();
172
+ }
173
+ memo.set(key, result);
168
174
  }
169
175
  return result;
170
176
  }
@@ -10,4 +10,4 @@ export declare function toUnnamedArgument<OtherInfo>(node: RNode<OtherInfo & Par
10
10
  /**
11
11
  * Wraps the given nodes as unnamed arguments where necessary.
12
12
  */
13
- export declare function wrapArgumentsUnnamed<OtherInfo>(nodes: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[], idMap: AstIdMap<OtherInfo>): ("<>" | RArgument<OtherInfo & ParentInformation>)[];
13
+ export declare function wrapArgumentsUnnamed<OtherInfo>(nodes: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[], idMap: AstIdMap<OtherInfo>): readonly ("<>" | RArgument<OtherInfo & ParentInformation>)[];
@@ -32,6 +32,22 @@ function toUnnamedArgument(node, idMap) {
32
32
  * Wraps the given nodes as unnamed arguments where necessary.
33
33
  */
34
34
  function wrapArgumentsUnnamed(nodes, idMap) {
35
- return nodes.map(n => graph_1.FunctionArgument.isEmpty(n) || r_argument_1.RArgument.is(n) ? n : toUnnamedArgument(n, idMap));
35
+ let needsWrap = false;
36
+ for (let i = 0; i < nodes.length; i++) {
37
+ const n = nodes[i];
38
+ if (!graph_1.FunctionArgument.isEmpty(n) && !r_argument_1.RArgument.is(n)) {
39
+ needsWrap = true;
40
+ break;
41
+ }
42
+ }
43
+ if (!needsWrap) {
44
+ return nodes;
45
+ }
46
+ const result = new Array(nodes.length);
47
+ for (let i = 0; i < nodes.length; i++) {
48
+ const n = nodes[i];
49
+ result[i] = graph_1.FunctionArgument.isEmpty(n) || r_argument_1.RArgument.is(n) ? n : toUnnamedArgument(n, idMap);
50
+ }
51
+ return result;
36
52
  }
37
53
  //# sourceMappingURL=make-argument.js.map
@@ -22,6 +22,7 @@ const logger_1 = require("../../../../../logger");
22
22
  const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
23
23
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
24
24
  const make_argument_1 = require("../argument/make-argument");
25
+ const frame_memory_1 = require("../../../../../environments/frame-memory");
25
26
  const identifier_1 = require("../../../../../environments/identifier");
26
27
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
27
28
  const environment_1 = require("../../../../../environments/environment");
@@ -350,6 +351,17 @@ function selectExports(callables, spec) {
350
351
  }
351
352
  return callables.filter(c => !spec.exclude?.has(c)).map(c => ({ exported: c, as: c }));
352
353
  }
354
+ /**
355
+ * What a package's attached layer binds, built per name on the first lookup. An attach names thousands of exports
356
+ * and a script mentions a few dozen, so the definitions are only made for the ones something asks about.
357
+ */
358
+ function lazyExports(pack, exports, ctx, definedAt) {
359
+ const byName = new Map();
360
+ for (const exp of exports) {
361
+ byName.set(identifier_1.Identifier.getName(identifier_1.Identifier.make(exp.as, pack)), exp);
362
+ }
363
+ return new frame_memory_1.LazyBindings(new Set(byName.keys()), name => [exportDefinition(pack, byName.get(name), ctx, definedAt)]);
364
+ }
353
365
  /**
354
366
  * The identifier definition binding a package export (or its alias) to its built-in function-definition.
355
367
  * The identity stays the plain export (so a call still materializes its `built-in:pkg:fn` vertex); whatever the configuration states about that name (processor, config, eval handler) rides along on top.
@@ -392,15 +404,15 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
392
404
  // a subset import restricts the attached exports, so no imports layer is materialized
393
405
  if (spec.namespaceOnly || (spec.include !== undefined && !spec.all)) {
394
406
  const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
395
- const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType)
396
- .defineAll(exports.map(exp => exportDefinition(pack, exp, ctx, definedAt)));
407
+ const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType);
408
+ layer.adoptMap(lazyExports(pack, exports, ctx, definedAt));
397
409
  return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, spec.pos) };
398
410
  }
399
411
  // full attach: imports layer at the bottom, namespace (exports) layer on top
400
412
  let importsEnv = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.Imports);
401
413
  importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
402
- const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
403
- .defineAll(exports.map(exp => exportDefinition(pack, exp, ctx, definedAt)));
414
+ const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace);
415
+ namespaceEnv.adoptMap(lazyExports(pack, exports, ctx, definedAt));
404
416
  const attached = { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
405
417
  /* whatever R puts on the search path with it, `pack` first so a dependency cycle stays finite (the guard above stops it) */
406
418
  return (0, attached_packages_1.attachedAlongside)(pack, ctx.deps.signatureSources()).reduce((env, alongside) => {
@@ -34,6 +34,18 @@ function interpolationsOf(template, open, close, markup = false) {
34
34
  continue;
35
35
  }
36
36
  const from = at + open.length;
37
+ if (close === '') {
38
+ /* no closing delimiter, as `rprintf` uses `$name`: the interpolation is just the identifier that follows */
39
+ const match = /^[A-Za-z._][A-Za-z0-9._]*/.exec(template.slice(from));
40
+ if (match) {
41
+ found.push(match[0]);
42
+ at = from + match[0].length;
43
+ }
44
+ else {
45
+ at = from;
46
+ }
47
+ continue;
48
+ }
37
49
  let depth = 1, quote = undefined, i = from;
38
50
  for (; i < template.length && depth > 0; i++) {
39
51
  const c = template[i];
@@ -161,18 +161,11 @@ function* escapeTargetFrames(fdef) {
161
161
  * dominated by the built-ins it holds, so filtering each frame once per pass saves the bulk of the work.
162
162
  */
163
163
  function escapedDefinitions() {
164
- /* keyed by frame and then by version: one frame answers differently at each, so the version has to be part of it */
165
164
  const perFrame = new Map();
166
165
  return (_id, fdef) => {
167
166
  const defs = [];
168
167
  for (const e of escapeTargetFrames(fdef)) {
169
- const { frame, version } = e.memory;
170
- let byVersion = perFrame.get(frame);
171
- if (byVersion === undefined) {
172
- byVersion = new Map();
173
- perFrame.set(frame, byVersion);
174
- }
175
- let escaped = byVersion.get(version);
168
+ let escaped = perFrame.get(e.memory);
176
169
  if (escaped === undefined) {
177
170
  /* a package frame holds thousands of entries and keeps none of them, so this walks them in place
178
171
  * rather than through a spread/flatMap/filter/map chain that allocates an array per step */
@@ -185,7 +178,7 @@ function escapedDefinitions() {
185
178
  }
186
179
  }
187
180
  escaped = collected;
188
- byVersion.set(version, escaped);
181
+ perFrame.set(e.memory, escaped);
189
182
  }
190
183
  for (const d of escaped) {
191
184
  defs.push(d);
@@ -249,23 +242,16 @@ function propagateTransitivePackages(graph, environment, ctx) {
249
242
  /** Maps each escaped definition's node id to its full (name-carrying) definition. */
250
243
  function escapedDefinitionMap(graph) {
251
244
  const map = new Map();
252
- /* a frame answers differently at each version, so a visit is only a repeat when both match */
253
- const seen = new Map();
245
+ const seen = new Set();
254
246
  for (const [, vertex] of graph.vertices(true)) {
255
247
  if (!vertex_1.FunctionDefinitionVertex.is(vertex)) {
256
248
  continue;
257
249
  }
258
250
  for (const e of escapeTargetFrames(vertex)) {
259
- const { frame, version } = e.memory;
260
- let versions = seen.get(frame);
261
- if (versions === undefined) {
262
- versions = new Set();
263
- seen.set(frame, versions);
264
- }
265
- else if (versions.has(version)) {
251
+ if (seen.has(e.memory)) {
266
252
  continue; // a frame shared with an already-visited definition contributes the same entries
267
253
  }
268
- versions.add(version);
254
+ seen.add(e.memory);
269
255
  for (const definitions of e.memory.values()) {
270
256
  for (const def of definitions) {
271
257
  if (!node_id_1.NodeId.isBuiltIn(def.nodeId) && def.name !== undefined) {
@@ -7,9 +7,9 @@ import type { Identifier } from '../../environments/identifier';
7
7
  import { RBinaryOp } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
8
8
  import { RPipe } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe';
9
9
  /**
10
- * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
10
+ * Helper function for {@link processNamedCall} using the given `content` as the name of the function.
11
11
  */
12
- export declare function processAsNamedCall<OtherInfo>({ info, lexeme, location }: RNode<OtherInfo & ParentInformation> & RAstNodeBase<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, name: Identifier, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation;
12
+ export declare function processAsNamedCall<OtherInfo>({ info, lexeme, location }: RNode<OtherInfo & ParentInformation> & RAstNodeBase<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, content: Identifier, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation;
13
13
  type RBinaryOpOrPipe<OtherInfo> = (RBinaryOp<OtherInfo & ParentInformation> | RPipe<OtherInfo & ParentInformation>) & RAstNodeBase<OtherInfo> & Location;
14
14
  /** A named, infix-special call, e.g. magrittr's `lhs %>% rhs`: normalized as a {@link RType#FunctionCall}, not as {@link RType#BinaryOp}. */
15
15
  type RInfixSpecialCall<OtherInfo> = RNamedFunctionCall<OtherInfo & ParentInformation>;
@@ -12,13 +12,13 @@ const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-bina
12
12
  const r_pipe_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
13
13
  const assert_1 = require("../../../util/assert");
14
14
  /**
15
- * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
15
+ * Helper function for {@link processNamedCall} using the given `content` as the name of the function.
16
16
  */
17
- function processAsNamedCall({ info, lexeme, location }, data, name, args) {
17
+ function processAsNamedCall({ info, lexeme, location }, data, content, args) {
18
18
  return (0, named_call_handling_1.processNamedCall)({
19
19
  type: type_1.RType.Symbol,
20
20
  info,
21
- content: name,
21
+ content,
22
22
  lexeme,
23
23
  location,
24
24
  }, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), info.id, data);
@@ -4,6 +4,7 @@ exports.WikiSetup = void 0;
4
4
  const doc_maker_1 = require("./wiki-mk/doc-maker");
5
5
  const doc_files_1 = require("./doc-util/doc-files");
6
6
  const node_version_1 = require("../util/node-version");
7
+ const doc_playground_1 = require("./doc-util/doc-playground");
7
8
  /**
8
9
  * https://github.com/flowr-analysis/flowr/wiki/Setup
9
10
  */
@@ -14,7 +15,8 @@ class WikiSetup extends doc_maker_1.DocMaker {
14
15
  text({ ctx }) {
15
16
  return `
16
17
  There are several ways to use _flowR_.
17
- You can download and build it from source, download the accompanying ${ctx.linkPage('flowr:docker', 'docker image')},
18
+ Want to try it without installing anything? Run code straight away in the ${(0, doc_playground_1.linkToPlayground)('Playground', {})}, or search what _flowR_ knows about R packages in the [Signature Database](${doc_files_1.FlowrSiteBaseRef}/wiki/sigdb/).
19
+ Otherwise, you can download and build it from source, download the accompanying ${ctx.linkPage('flowr:docker', 'docker image')},
18
20
  or use its ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')} and ${ctx.linkPage('flowr:rstudio-addin', 'RStudio Addin')}.
19
21
 
20
22
  - [🗒️ Using the Visual Studio Code Extension](#-using-the-visual-studio-code-extension)
@@ -24,7 +26,7 @@ or use its ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')} and $
24
26
  - [📜 Developing for _flowR_](#-developing-for-flowr)
25
27
 
26
28
 
27
- If you want to develop for _flowR_, you want to see how to [build from scratch](#-building-from-scratch) and have a
29
+ If you want to develop for _flowR_, you want to see how to [build from scratch](#-building-from-scratch) and have a
28
30
  look at the [Contributing Guidelines](${doc_files_1.RemoteFlowrFilePathBaseRef}.github/CONTRIBUTING.md).
29
31
 
30
32
  ## 🗒️ Using the Visual Studio Code Extension
@@ -111,7 +113,30 @@ For details on _how_ to contribute, please refer to the [CONTRIBUTING.md](${doc_
111
113
 
112
114
  ### 📦 The Signature Database
113
115
 
114
- _flowR_ resolves \`library(pkg)\`/\`pkg::fn\` calls from a downloaded signature database (\`flowr-sigdb\`); no shards are committed (only the \`sigdb.remote.json\` pointer), everything else is fetched on demand &mdash; see the ${ctx.linkPage('wiki/Signature Database')} page.
116
+ _flowR_ knows the exported functions of thousands of R packages, resolving \`library(pkg)\`/\`pkg::fn\` calls from a downloaded signature database (\`flowr-sigdb\`); no shards are committed (only the \`sigdb.remote.json\` pointer), everything else is fetched on demand. Search it live at [flowr-analysis.github.io/flowr/wiki/sigdb](${doc_files_1.FlowrSiteBaseRef}/wiki/sigdb/), try _flowR_ itself in the ${(0, doc_playground_1.linkToPlayground)('Playground', {})} without installing anything, or see the ${ctx.linkPage('wiki/Signature Database')} page for how the database works.
117
+
118
+ ### 📦 Using _flowR_ as a Dependency in Another Project
119
+
120
+ _flowR_ is published as \`@eagleoutice/flowr\`, but you may want an unreleased branch or a local build instead. Plain \`npm install /path/to/flowr\` (or \`npm link\`) looks like it works, but skips resolving _flowR_'s own dependencies, so the bundled WASM parser fails at runtime with an \`ENOENT\` on \`tree-sitter.wasm\`. Package a tarball instead, which installs like any normal package:
121
+
122
+ \`\`\`shell
123
+ npm run build:dev
124
+ npm run pack-library
125
+ \`\`\`
126
+
127
+ This produces \`eagleoutice-flowr-<version>.tgz\` in the repository root. Install it in your project:
128
+
129
+ \`\`\`shell
130
+ npm install /path/to/flowr/eagleoutice-flowr-<version>.tgz
131
+ \`\`\`
132
+
133
+ You can also depend on a Git branch directly:
134
+
135
+ \`\`\`shell
136
+ npm install github:flowr-analysis/flowr#your-branch-name
137
+ \`\`\`
138
+
139
+ npm clones the repository and runs its \`prepare\` script (\`build:dev\`) before installing it, so it arrives fully built with its own dependencies resolved. Some package managers (npm's own script-approval prompt included, plus pnpm and Yarn PnP) block install/lifecycle scripts by default; approve _flowR_'s if the install warns that they were skipped.
115
140
 
116
141
  -----
117
142
  <a id="note1" href="#note1ref">&lt;1&gt;</a>: Currently, _flowR_ is only tested with R versions \`4.x\` and \`3.6.x\`.