@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.
- package/config.d.ts +2 -0
- package/config.js +3 -1
- package/dataflow/environments/default-builtin-config.d.ts +57 -0
- package/dataflow/environments/default-builtin-config.js +6 -2
- package/dataflow/environments/environment.d.ts +11 -19
- package/dataflow/environments/environment.js +17 -39
- package/dataflow/environments/frame-memory.d.ts +33 -68
- package/dataflow/environments/frame-memory.js +77 -200
- package/dataflow/environments/identifier.d.ts +5 -0
- package/dataflow/environments/resolve-by-name.js +7 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.js +17 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +16 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +12 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +5 -19
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-named-call.js +3 -3
- package/documentation/wiki-setup.js +28 -3
- package/linter/rules/unescaped-arguments.js +43 -3
- package/package.json +1 -1
- package/project/context/flowr-analyzer-files-context.d.ts +2 -2
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -0
- package/project/sigdb/decode.d.ts +5 -4
- package/project/sigdb/decode.js +13 -18
- package/project/sigdb/dict.d.ts +35 -0
- package/project/sigdb/dict.js +97 -0
- package/project/sigdb/hash.d.ts +7 -2
- package/project/sigdb/reader.d.ts +9 -6
- package/project/sigdb/reader.js +40 -28
- package/slicing/static/fingerprint.js +6 -12
- package/util/text/playground-link.d.ts +14 -5
- package/util/text/playground-link.js +32 -8
- package/util/version.js +2 -2
package/config.d.ts
CHANGED
|
@@ -158,6 +158,8 @@ export interface FlowrConfig {
|
|
|
158
158
|
readonly loadProjectDependencies: boolean;
|
|
159
159
|
readonly eagerlyLoad: boolean;
|
|
160
160
|
readonly eagerlyLoadExports: boolean;
|
|
161
|
+
/** How many MiB of decoded package blobs every open bundle may hold together; a bigger budget re-reads and re-parses less, a smaller one keeps less in memory (default `16`). */
|
|
162
|
+
readonly blobCacheBudgetMb?: number;
|
|
161
163
|
/**
|
|
162
164
|
* R version assumed when resolving versioned (base-R) exports: a pin, or `"auto"` to detect the installed R
|
|
163
165
|
* (falling back to {@link DefaultAssumedRVersion} if none, e.g. tree-sitter). See {@link resolveAssumedRVersion}.
|
package/config.js
CHANGED
|
@@ -245,6 +245,7 @@ exports.FlowrConfig = {
|
|
|
245
245
|
*/
|
|
246
246
|
default() {
|
|
247
247
|
return {
|
|
248
|
+
logLevel: 'fatal',
|
|
248
249
|
ignoreSourceCalls: false,
|
|
249
250
|
ignoreLoadCalls: false,
|
|
250
251
|
semantics: {
|
|
@@ -292,7 +293,7 @@ exports.FlowrConfig = {
|
|
|
292
293
|
variables: VariableResolve.Alias,
|
|
293
294
|
evalStrings: true,
|
|
294
295
|
trackEnvironments: true,
|
|
295
|
-
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, assumedRVersion: 'auto', linkBaseR: false, linkDescriptionDependencies: false, linkBaseRCalls: false, linkPackageCalls: false, warmInBackground: false, additionalPaths: [], autoSync: false, versionSelection: VersionSelection.Newest, versionOverrides: {}, installedLibrary: { enabled: false, paths: [], useEnvironment: true, useProjectLibrary: true, maxDepth: 3, packages: [] } },
|
|
296
|
+
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, blobCacheBudgetMb: 16, assumedRVersion: 'auto', linkBaseR: false, linkDescriptionDependencies: false, linkBaseRCalls: false, linkPackageCalls: false, warmInBackground: false, additionalPaths: [], autoSync: false, versionSelection: VersionSelection.Newest, versionOverrides: {}, installedLibrary: { enabled: false, paths: [], useEnvironment: true, useProjectLibrary: true, maxDepth: 3, packages: [] } },
|
|
296
297
|
versionManagement: { linkedVersionGroups: [] },
|
|
297
298
|
resolveSource: {
|
|
298
299
|
dropPaths: DropPathsOption.No,
|
|
@@ -441,6 +442,7 @@ exports.FlowrConfig = {
|
|
|
441
442
|
maxDepth: joi_1.default.number().optional().description('How far to descend into the nested layout of a project-local library (default 3).'),
|
|
442
443
|
packages: joi_1.default.array().items(joi_1.default.string()).optional().description('Only recover packages whose name matches one of these regular expressions; empty means any.')
|
|
443
444
|
}).optional().description('Recovering packages no signature database knows from the copy installed on this machine.'),
|
|
445
|
+
blobCacheBudgetMb: joi_1.default.number().min(0).optional().description('How many MiB of decoded package blobs every open bundle may hold together (default 16).'),
|
|
444
446
|
versionSelection: joi_1.default.string().valid(...Object.values(VersionSelection)).optional().description('When a project constrains a dependency, resolve to the newest (default), oldest, or system-installed version satisfying it; system needs R and falls back to newest. Base-R packages always resolve against the assumed R version.'),
|
|
445
447
|
versionOverrides: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional().description('Force an exact version for specific packages (name -> version), overriding both the project constraint and the versionSelection policy (default {}).')
|
|
446
448
|
}).description('Resolving library exports from a signature database.'),
|
|
@@ -4584,6 +4584,63 @@ export declare const WrittenBuiltinDefinitions: [{
|
|
|
4584
4584
|
readonly tags: [SemanticCallTag.Deprecated];
|
|
4585
4585
|
};
|
|
4586
4586
|
readonly assumePrimitive: false;
|
|
4587
|
+
}, {
|
|
4588
|
+
readonly type: "function";
|
|
4589
|
+
readonly names: [Identifier];
|
|
4590
|
+
readonly processor: BuiltInProcName.StringTemplate;
|
|
4591
|
+
readonly config: {
|
|
4592
|
+
readonly open: "${";
|
|
4593
|
+
readonly props: CallProp.MayPure;
|
|
4594
|
+
};
|
|
4595
|
+
readonly assumePrimitive: false;
|
|
4596
|
+
}, {
|
|
4597
|
+
readonly type: "function";
|
|
4598
|
+
readonly names: Identifier[];
|
|
4599
|
+
readonly processor: BuiltInProcName.StringTemplate;
|
|
4600
|
+
readonly config: {
|
|
4601
|
+
readonly open: ".(";
|
|
4602
|
+
readonly close: ")";
|
|
4603
|
+
readonly props: CallProp.MayPure;
|
|
4604
|
+
};
|
|
4605
|
+
readonly assumePrimitive: false;
|
|
4606
|
+
}, {
|
|
4607
|
+
readonly type: "function";
|
|
4608
|
+
readonly names: Identifier[];
|
|
4609
|
+
readonly processor: BuiltInProcName.StringTemplate;
|
|
4610
|
+
readonly config: {
|
|
4611
|
+
readonly props: CallProp.MayPure;
|
|
4612
|
+
};
|
|
4613
|
+
readonly assumePrimitive: false;
|
|
4614
|
+
}, {
|
|
4615
|
+
readonly type: "function";
|
|
4616
|
+
readonly names: [Identifier];
|
|
4617
|
+
readonly processor: BuiltInProcName.StringTemplate;
|
|
4618
|
+
readonly config: {
|
|
4619
|
+
readonly open: "{{";
|
|
4620
|
+
readonly close: "}}";
|
|
4621
|
+
readonly props: CallProp.MayPure;
|
|
4622
|
+
};
|
|
4623
|
+
readonly assumePrimitive: false;
|
|
4624
|
+
}, {
|
|
4625
|
+
readonly type: "function";
|
|
4626
|
+
readonly names: [Identifier];
|
|
4627
|
+
readonly processor: BuiltInProcName.StringTemplate;
|
|
4628
|
+
readonly config: {
|
|
4629
|
+
readonly open: "<%=";
|
|
4630
|
+
readonly close: "%>";
|
|
4631
|
+
readonly props: CallProp.MayPure;
|
|
4632
|
+
};
|
|
4633
|
+
readonly assumePrimitive: false;
|
|
4634
|
+
}, {
|
|
4635
|
+
readonly type: "function";
|
|
4636
|
+
readonly names: [Identifier];
|
|
4637
|
+
readonly processor: BuiltInProcName.StringTemplate;
|
|
4638
|
+
readonly config: {
|
|
4639
|
+
readonly open: "$";
|
|
4640
|
+
readonly close: "";
|
|
4641
|
+
readonly props: CallProp.MayPure;
|
|
4642
|
+
};
|
|
4643
|
+
readonly assumePrimitive: false;
|
|
4587
4644
|
}, {
|
|
4588
4645
|
readonly type: "function";
|
|
4589
4646
|
readonly names: [Identifier];
|
|
@@ -1030,11 +1030,15 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
1030
1030
|
{ type: 'function', names: [...identifier_1.Identifier.fromAllIn(TidyEvalPackages, ['quo', 'quos', 'expr']), identifier_1.Identifier.from(['exprs', "rlang" /* PkgName.Rlang */])], processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, unquote: nse_1.Unquote.Rlang, keepEnvironment: true, libFn: true, props: built_in_props_1.CallProp.Lang }, assumePrimitive: true },
|
|
1031
1031
|
{ type: 'function', names: [identifier_1.Identifier.from(['exec', "rlang" /* PkgName.Rlang */])], processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: '.fn', unquoteFunction: true, hasUnknownSideEffects: true, libFn: true, props: built_in_props_1.CallProp.MayPure, sig: [['.fn', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
1032
1032
|
{ type: 'function', names: identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['invoke', 'invoke_map']), processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: '.f', unquoteFunction: true, hasUnknownSideEffects: true, libFn: true, props: built_in_props_1.CallProp.MayPure, tags: [built_in_props_1.SemanticCallTag.Deprecated], sig: [['.f', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
1033
|
-
/* the `{...}` of a template holds R code, evaluated where the call is; `cli_abort` stays with the other
|
|
1034
|
-
* error exits, as terminating a branch matters more than interpolating its message */
|
|
1035
1033
|
{ type: 'function', names: [...identifier_1.Identifier.fromAll("glue" /* PkgName.Glue */, ['glue', 'glue_safe', 'glue_collapse']), identifier_1.Identifier.from(['str_glue', "stringr" /* PkgName.Stringr */])], processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1036
1034
|
{ type: 'function', names: identifier_1.Identifier.fromAll("cli" /* PkgName.Cli */, ['cli_text', 'cli_alert', 'cli_alert_info', 'cli_alert_success', 'cli_alert_warning', 'cli_alert_danger', 'cli_h1', 'cli_h2', 'cli_h3', 'cli_li', 'cli_bullets', 'cli_inform', 'cli_warn', 'format_inline', 'cli_verbatim']), processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { markup: true, props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1037
1035
|
{ type: 'function', names: [identifier_1.Identifier.from(['str_interp', "stringr" /* PkgName.Stringr */])], processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '${', props: built_in_props_1.CallProp.MayPure, tags: [built_in_props_1.SemanticCallTag.Deprecated] }, assumePrimitive: false },
|
|
1036
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['gstring', "R.utils" /* PkgName.Rutils */])], processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '${', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1037
|
+
{ type: 'function', names: identifier_1.Identifier.fromAll("wrapr" /* PkgName.Wrapr */, ['sinterp', 'si']), processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '.(', close: ')', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1038
|
+
{ type: 'function', names: identifier_1.Identifier.fromAll("stringmagic" /* PkgName.Stringmagic */, ['string_magic', '.string_magic', 'sma']), processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1039
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['whisker.render', "whisker" /* PkgName.Whisker */])], processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '{{', close: '}}', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1040
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['brew', "brew" /* PkgName.Brew */])], processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '<%=', close: '%>', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1041
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['rprintf', "rprintf" /* PkgName.Rprintf */])], processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '$', close: '', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
|
|
1038
1042
|
/* `local(expr)` evaluates `expr` in a frame of its own and hands its value back */
|
|
1039
1043
|
{ type: 'function', names: [identifier_1.Identifier.from(['local', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Local, config: { args: { env: 'envir', expr: 'expr' }, sig: [['expr', built_in_props_1.ArgProp.Alias | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
|
|
1040
1044
|
{ type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['with', 'within']), processor: built_in_proc_name_1.BuiltInProcName.With, config: {}, assumePrimitive: false },
|
|
@@ -2,7 +2,8 @@ import type { BuiltInMemory } from './built-in';
|
|
|
2
2
|
import type { BrandedIdentifier, IdentifierDefinition } from './identifier';
|
|
3
3
|
import { Identifier } from './identifier';
|
|
4
4
|
import type { ControlDependency } from '../info';
|
|
5
|
-
import { Frame
|
|
5
|
+
import { Frame } from './frame-memory';
|
|
6
|
+
import type { MemoryView } from './frame-memory';
|
|
6
7
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
8
|
/** A single entry/scope within an {@link REnvironmentInformation} */
|
|
8
9
|
export interface IEnvironment {
|
|
@@ -44,17 +45,13 @@ export declare class Environment implements IEnvironment {
|
|
|
44
45
|
/** if created by a closure, the node id of that closure */
|
|
45
46
|
private c?;
|
|
46
47
|
parent: Environment;
|
|
47
|
-
/**
|
|
48
|
+
/** where this environment's names live; shared with every clone until one of them writes */
|
|
48
49
|
private frame;
|
|
49
|
-
/** the version of {@link frame} this environment sees */
|
|
50
|
-
private fv;
|
|
51
|
-
private view?;
|
|
52
|
-
private writable?;
|
|
53
50
|
cache?: Map<Identifier, IdentifierDefinition[]>;
|
|
54
51
|
/** what a resolution found below this frame, by target and name; only frames nothing writes keep one */
|
|
55
52
|
tailCache?: Map<string, readonly IdentifierDefinition[] | undefined>;
|
|
56
53
|
builtInEnv?: true;
|
|
57
|
-
/** {@link memory}
|
|
54
|
+
/** {@link memory} is shared with a clone; writing needs {@link writableMemory} to unshare it first */
|
|
58
55
|
private sharedMemory?;
|
|
59
56
|
/** {@link parent} is shared with the environment this was cloned from; writing through it needs {@link writableParent} */
|
|
60
57
|
private sharedParent?;
|
|
@@ -64,7 +61,7 @@ export declare class Environment implements IEnvironment {
|
|
|
64
61
|
superMemory?: MemoryView;
|
|
65
62
|
/** What the configuration states about packages R does not attach on startup, by package; only the built-in env carries it (see {@link statedIn}). */
|
|
66
63
|
namespaces?: ReadonlyMap<string, BuiltInMemory>;
|
|
67
|
-
constructor(parent: Environment, isBuiltInDefault?: true | undefined, frame?: Frame
|
|
64
|
+
constructor(parent: Environment, isBuiltInDefault?: true | undefined, frame?: Frame);
|
|
68
65
|
/** Marks this as an attached-package layer (see {@link EnvType}) for package `name`. */
|
|
69
66
|
asLibrary(name: string, type: EnvType): this;
|
|
70
67
|
/** Marks this as the global environment (`.GlobalEnv`); see {@link globalEnv}. */
|
|
@@ -80,22 +77,17 @@ export declare class Environment implements IEnvironment {
|
|
|
80
77
|
* and lets it materialize one frame at a time here, since a removal usually reaches only a frame or two.
|
|
81
78
|
*/
|
|
82
79
|
get writableParent(): Environment;
|
|
83
|
-
/** What
|
|
80
|
+
/** What this frame binds. */
|
|
84
81
|
get memory(): MemoryView;
|
|
85
82
|
/** Whether `other` holds the very bindings this does. */
|
|
86
83
|
sameMemoryAs(other: Environment): boolean;
|
|
87
|
-
/** What `name` holds here
|
|
84
|
+
/** What `name` holds here; the chain walks of name resolution take this rather than {@link memory}. */
|
|
88
85
|
lookup(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
|
|
89
|
-
/** the bindings as a plain map where one is at hand, so a merge copies map from map */
|
|
90
|
-
private get copyableMemory();
|
|
91
86
|
/** Takes `map` as the bindings, sharing it until something writes. */
|
|
92
|
-
adoptMap(map:
|
|
93
|
-
/** {@link memory} ready to be written to
|
|
94
|
-
get writableMemory():
|
|
95
|
-
/**
|
|
96
|
-
* Clones this environment, sharing {@link memory} until either side writes to it (see {@link writableMemory}); cloning
|
|
97
|
-
* is therefore independent of how many definitions a frame holds, which matters for packages with thousands of them.
|
|
98
|
-
*/
|
|
87
|
+
adoptMap(map: MemoryView): void;
|
|
88
|
+
/** {@link memory} ready to be written to. Every write goes through here, since {@link clone} shares the frame. */
|
|
89
|
+
get writableMemory(): Frame;
|
|
90
|
+
/** Clones this, sharing {@link memory} until either side writes; the cost is the same for a frame of any size. */
|
|
99
91
|
clone(recurseParents: boolean): Environment;
|
|
100
92
|
/** Define a new identifier definition within this environment. */
|
|
101
93
|
define(definition: IdentifierDefinition & {
|
|
@@ -38,17 +38,13 @@ class Environment {
|
|
|
38
38
|
/** if created by a closure, the node id of that closure */
|
|
39
39
|
c;
|
|
40
40
|
parent;
|
|
41
|
-
/**
|
|
41
|
+
/** where this environment's names live; shared with every clone until one of them writes */
|
|
42
42
|
frame;
|
|
43
|
-
/** the version of {@link frame} this environment sees */
|
|
44
|
-
fv;
|
|
45
|
-
view;
|
|
46
|
-
writable;
|
|
47
43
|
cache;
|
|
48
44
|
/** what a resolution found below this frame, by target and name; only frames nothing writes keep one */
|
|
49
45
|
tailCache;
|
|
50
46
|
builtInEnv;
|
|
51
|
-
/** {@link memory}
|
|
47
|
+
/** {@link memory} is shared with a clone; writing needs {@link writableMemory} to unshare it first */
|
|
52
48
|
sharedMemory;
|
|
53
49
|
/** {@link parent} is shared with the environment this was cloned from; writing through it needs {@link writableParent} */
|
|
54
50
|
sharedParent;
|
|
@@ -58,15 +54,12 @@ class Environment {
|
|
|
58
54
|
superMemory;
|
|
59
55
|
/** What the configuration states about packages R does not attach on startup, by package; only the built-in env carries it (see {@link statedIn}). */
|
|
60
56
|
namespaces;
|
|
61
|
-
constructor(parent, isBuiltInDefault = undefined, frame
|
|
57
|
+
constructor(parent, isBuiltInDefault = undefined, frame) {
|
|
62
58
|
this.id = isBuiltInDefault ? 0 : environmentIdCounter++;
|
|
63
59
|
this.parent = parent;
|
|
64
60
|
this.frame = frame ?? frame_memory_1.Frame.empty();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/* the shared empty frame, so the first write forks it */
|
|
68
|
-
this.sharedMemory = true;
|
|
69
|
-
}
|
|
61
|
+
/* a clone hands its frame in and the empty one is everybody's, so the first write forks either way */
|
|
62
|
+
this.sharedMemory = true;
|
|
70
63
|
// do not store if not needed!
|
|
71
64
|
if (isBuiltInDefault) {
|
|
72
65
|
this.builtInEnv = isBuiltInDefault;
|
|
@@ -109,53 +102,38 @@ class Environment {
|
|
|
109
102
|
}
|
|
110
103
|
return this.parent;
|
|
111
104
|
}
|
|
112
|
-
/** What
|
|
105
|
+
/** What this frame binds. */
|
|
113
106
|
get memory() {
|
|
114
|
-
return this.
|
|
107
|
+
return this.frame;
|
|
115
108
|
}
|
|
116
109
|
/** Whether `other` holds the very bindings this does. */
|
|
117
110
|
sameMemoryAs(other) {
|
|
118
|
-
return this === other ||
|
|
111
|
+
return this === other || this.frame === other.frame;
|
|
119
112
|
}
|
|
120
|
-
/** What `name` holds here
|
|
113
|
+
/** What `name` holds here; the chain walks of name resolution take this rather than {@link memory}. */
|
|
121
114
|
lookup(name) {
|
|
122
|
-
|
|
123
|
-
return this.fv === frame.version ? frame.live.get(name) : frame.get(name, this.fv);
|
|
124
|
-
}
|
|
125
|
-
/** the bindings as a plain map where one is at hand, so a merge copies map from map */
|
|
126
|
-
get copyableMemory() {
|
|
127
|
-
return this.frame.settledAt(this.fv) ?? this.memory;
|
|
115
|
+
return this.frame.get(name);
|
|
128
116
|
}
|
|
129
117
|
/** Takes `map` as the bindings, sharing it until something writes. */
|
|
130
118
|
adoptMap(map) {
|
|
131
119
|
this.frame = frame_memory_1.Frame.of(map);
|
|
132
|
-
this.fv = this.frame.version;
|
|
133
|
-
this.view = undefined;
|
|
134
|
-
this.writable = undefined;
|
|
135
|
-
/* the map belongs to whoever handed it over, so the first write forks */
|
|
136
120
|
this.sharedMemory = true;
|
|
137
121
|
}
|
|
138
|
-
/** {@link memory} ready to be written to
|
|
122
|
+
/** {@link memory} ready to be written to. Every write goes through here, since {@link clone} shares the frame. */
|
|
139
123
|
get writableMemory() {
|
|
140
124
|
this.tailCache = undefined;
|
|
141
125
|
if (this.sharedMemory) {
|
|
142
|
-
this.frame = this.frame.forWrite(
|
|
143
|
-
this.fv = this.frame.nextVersion();
|
|
126
|
+
this.frame = this.frame.forWrite();
|
|
144
127
|
this.sharedMemory = undefined;
|
|
145
|
-
this.view = undefined;
|
|
146
|
-
this.writable = undefined;
|
|
147
128
|
}
|
|
148
|
-
return this.
|
|
129
|
+
return this.frame;
|
|
149
130
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Clones this environment, sharing {@link memory} until either side writes to it (see {@link writableMemory}); cloning
|
|
152
|
-
* is therefore independent of how many definitions a frame holds, which matters for packages with thousands of them.
|
|
153
|
-
*/
|
|
131
|
+
/** Clones this, sharing {@link memory} until either side writes; the cost is the same for a frame of any size. */
|
|
154
132
|
clone(recurseParents) {
|
|
155
133
|
if (this.builtInEnv) {
|
|
156
134
|
return this; // do not clone the built-in environment
|
|
157
135
|
}
|
|
158
|
-
const clone = new Environment(this.parent, this.builtInEnv, this.frame
|
|
136
|
+
const clone = new Environment(this.parent, this.builtInEnv, this.frame);
|
|
159
137
|
clone.c = this.c;
|
|
160
138
|
clone.n = this.n;
|
|
161
139
|
clone.t = this.t;
|
|
@@ -296,7 +274,7 @@ class Environment {
|
|
|
296
274
|
if (shortcut !== undefined) {
|
|
297
275
|
return shortcut;
|
|
298
276
|
}
|
|
299
|
-
const map = new Map(this.
|
|
277
|
+
const map = new Map(this.memory);
|
|
300
278
|
for (const [key, values] of other.memory) {
|
|
301
279
|
const hasMaybe = applyCds === undefined ? values.length === 0 || values.some(v => v.cds !== undefined) : true;
|
|
302
280
|
if (hasMaybe) {
|
|
@@ -346,7 +324,7 @@ class Environment {
|
|
|
346
324
|
if (shortcut !== undefined) {
|
|
347
325
|
return shortcut;
|
|
348
326
|
}
|
|
349
|
-
const map = new Map(this.
|
|
327
|
+
const map = new Map(this.memory);
|
|
350
328
|
for (const [key, value] of other.memory) {
|
|
351
329
|
const old = map.get(key);
|
|
352
330
|
if (old) {
|
|
@@ -1,84 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* One environment frame's bindings, shared
|
|
3
|
-
*
|
|
4
|
-
* definitions retained memory in the square of them. The newest version is answered from a plain map, an older one
|
|
5
|
-
* from what the writes recorded.
|
|
2
|
+
* One environment frame's bindings, shared until something writes: the writer forks, so cloning is free and a
|
|
3
|
+
* definition pays for the copy.
|
|
6
4
|
* @module
|
|
7
5
|
*/
|
|
8
6
|
import type { BrandedIdentifier, IdentifierDefinition } from './identifier';
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/** the bindings at {@link version} and no other, so read it only after checking the version, as {@link get} does */
|
|
15
|
-
readonly live: Map<BrandedIdentifier, IdentifierDefinition[]>;
|
|
16
|
-
/** whether {@link live} is this frame's own to write, see {@link Frame.of} */
|
|
7
|
+
/** the bindings of one frame, as everything that only reads them sees it */
|
|
8
|
+
export type MemoryView = ReadonlyMap<BrandedIdentifier, IdentifierDefinition[]>;
|
|
9
|
+
/** One frame's bindings. {@link Frame.of|Taken from a map} it is frozen, since the map is somebody else's. */
|
|
10
|
+
export declare class Frame implements MemoryView {
|
|
11
|
+
private readonly bindings;
|
|
17
12
|
private readonly frozen;
|
|
18
|
-
/** what each *rewritten* name held per version, for older snapshots; built on the first rewrite, as most see none */
|
|
19
|
-
private history;
|
|
20
|
-
/** when each name still on its first binding came in; a write-once name needs no more, and most are */
|
|
21
|
-
private bornAt;
|
|
22
|
-
/** the last past version walked out into a map, so re-reading that snapshot skips the walk; one slot only */
|
|
23
|
-
private walked;
|
|
24
|
-
/** the newest version written here, counting this frame's writes alone; only a snapshot at it may extend the frame */
|
|
25
|
-
version: number;
|
|
26
13
|
private constructor();
|
|
27
|
-
/** A frame
|
|
28
|
-
static of(map:
|
|
29
|
-
/**
|
|
14
|
+
/** A frame over `map`, frozen, so a write forks rather than reaching back into it. */
|
|
15
|
+
static of(map: MemoryView): Frame;
|
|
16
|
+
/** The empty frame, the same one every time, so an environment defining nothing allocates nothing. */
|
|
30
17
|
static empty(): Frame;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/** Whether `name` was bound at `version`. */
|
|
36
|
-
has(name: BrandedIdentifier, version: number): boolean;
|
|
37
|
-
/** The names `version` binds. */
|
|
38
|
-
keys(version: number): MapIterator<BrandedIdentifier>;
|
|
39
|
-
/** What `version` binds, without the names. */
|
|
40
|
-
values(version: number): MapIterator<IdentifierDefinition[]>;
|
|
41
|
-
/** How many names `version` binds. */
|
|
42
|
-
size(version: number): number;
|
|
43
|
-
/** What `version` binds, name by name. */
|
|
44
|
-
entries(version: number): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
45
|
-
/**
|
|
46
|
-
* `version` as a map, `undefined` when it has to be walked out. A frame that never rewrote or took on a name has
|
|
47
|
-
* held the same bindings throughout, so {@link live} answers for any version of it.
|
|
48
|
-
*/
|
|
49
|
-
settledAt(version: number): ReadonlyMap<BrandedIdentifier, IdentifierDefinition[]> | undefined;
|
|
50
|
-
/** `version` walked out into a map, kept in the {@link walked} slot. */
|
|
51
|
-
private materialize;
|
|
52
|
-
/** What `version` bound; the rewritten names come first, since one dropped since is no longer in {@link live}. */
|
|
53
|
-
private recorded;
|
|
54
|
-
/** The frame a snapshot at `version` writes to: this one if it holds the newest version, a fork otherwise. */
|
|
55
|
-
forWrite(version: number): Frame;
|
|
56
|
-
/** The version the next write goes to; only a frame {@link forWrite} just returned may hand one out. */
|
|
57
|
-
nextVersion(): number;
|
|
58
|
-
/** Binds `name` at `version`, `undefined` removing it. Only the newest version may be written; snapshots hold the rest. */
|
|
59
|
-
set(name: BrandedIdentifier, defs: IdentifierDefinition[] | undefined, version: number): void;
|
|
60
|
-
}
|
|
61
|
-
/** One environment's view of its {@link Frame}, as a {@link ReadonlyMap} so the old readers of the map still work. */
|
|
62
|
-
export declare class MemoryView implements ReadonlyMap<BrandedIdentifier, IdentifierDefinition[]> {
|
|
63
|
-
readonly frame: Frame;
|
|
64
|
-
readonly version: number;
|
|
65
|
-
constructor(frame: Frame, version: number);
|
|
18
|
+
/** A copy of these bindings that the caller owns. */
|
|
19
|
+
forWrite(): Frame;
|
|
20
|
+
set(name: BrandedIdentifier, defs: IdentifierDefinition[]): void;
|
|
21
|
+
delete(name: BrandedIdentifier): void;
|
|
66
22
|
get(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
|
|
67
23
|
has(name: BrandedIdentifier): boolean;
|
|
68
24
|
get size(): number;
|
|
69
|
-
entries(): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
70
|
-
[Symbol.iterator](): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
71
25
|
keys(): MapIterator<BrandedIdentifier>;
|
|
72
26
|
values(): MapIterator<IdentifierDefinition[]>;
|
|
73
|
-
|
|
27
|
+
entries(): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
28
|
+
[Symbol.iterator](): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
29
|
+
forEach(fn: (defs: IdentifierDefinition[], name: BrandedIdentifier, map: MemoryView) => void, thisArg?: unknown): void;
|
|
74
30
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The bindings of an attached package, built one name at a time. An attach used to materialize a definition per
|
|
33
|
+
* export, and a script attaching a handful of packages carries hundreds of thousands of them for the few dozen
|
|
34
|
+
* names it ever mentions. Here the export list is all that is held until a lookup asks for one.
|
|
35
|
+
*/
|
|
36
|
+
export declare class LazyBindings implements MemoryView {
|
|
37
|
+
private readonly names;
|
|
38
|
+
private readonly bind;
|
|
39
|
+
private readonly built;
|
|
40
|
+
constructor(names: ReadonlySet<BrandedIdentifier>, bind: (name: BrandedIdentifier) => IdentifierDefinition[]);
|
|
82
41
|
get(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
|
|
83
42
|
has(name: BrandedIdentifier): boolean;
|
|
43
|
+
get size(): number;
|
|
44
|
+
keys(): MapIterator<BrandedIdentifier>;
|
|
45
|
+
entries(): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
46
|
+
[Symbol.iterator](): MapIterator<[BrandedIdentifier, IdentifierDefinition[]]>;
|
|
47
|
+
values(): MapIterator<IdentifierDefinition[]>;
|
|
48
|
+
forEach(fn: (defs: IdentifierDefinition[], name: BrandedIdentifier, map: MemoryView) => void, thisArg?: unknown): void;
|
|
84
49
|
}
|