@eagleoutice/flowr 2.8.14 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -26
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -3
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +2 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +13 -10
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +7 -6
- package/abstract-interpretation/data-frame/resolve-args.js +2 -1
- package/benchmark/slicer.d.ts +0 -16
- package/benchmark/slicer.js +0 -47
- package/benchmark/stats/print.js +0 -6
- package/benchmark/stats/stats.d.ts +0 -3
- package/benchmark/summarizer/second-phase/process.js +0 -6
- package/cli/benchmark-app.d.ts +0 -1
- package/cli/benchmark-app.js +0 -1
- package/cli/benchmark-helper-app.d.ts +0 -1
- package/cli/benchmark-helper-app.js +1 -5
- package/cli/common/options.d.ts +0 -10
- package/cli/common/options.js +0 -2
- package/cli/common/scripts-info.d.ts +0 -10
- package/cli/repl/server/connection.js +1 -1
- package/config.d.ts +0 -15
- package/config.js +0 -21
- package/control-flow/cfg-dead-code.js +0 -3
- package/control-flow/extract-cfg.js +5 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +11 -4
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-config.d.ts +1 -0
- package/dataflow/environments/built-in.d.ts +9 -3
- package/dataflow/environments/built-in.js +15 -7
- package/dataflow/environments/default-builtin-config.d.ts +10 -1
- package/dataflow/environments/default-builtin-config.js +6 -4
- package/dataflow/environments/define.d.ts +4 -11
- package/dataflow/environments/define.js +16 -96
- package/dataflow/environments/diff.js +3 -2
- package/dataflow/environments/environment.d.ts +17 -6
- package/dataflow/environments/environment.js +69 -18
- package/dataflow/environments/identifier.d.ts +92 -6
- package/dataflow/environments/identifier.js +159 -1
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.d.ts +4 -4
- package/dataflow/environments/resolve-by-name.js +24 -8
- package/dataflow/eval/resolve/resolve.d.ts +10 -6
- package/dataflow/eval/resolve/resolve.js +12 -7
- package/dataflow/extractor.js +6 -3
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +23 -6
- package/dataflow/fn/higher-order-function.js +7 -7
- package/dataflow/graph/call-graph.d.ts +13 -0
- package/dataflow/graph/call-graph.js +46 -20
- package/dataflow/graph/diff-dataflow-graph.js +6 -4
- package/dataflow/graph/edge.d.ts +48 -31
- package/dataflow/graph/edge.js +66 -60
- package/dataflow/graph/graph.d.ts +18 -9
- package/dataflow/graph/graph.js +29 -13
- package/dataflow/graph/quads.js +1 -1
- package/dataflow/graph/resolve-graph.js +1 -1
- package/dataflow/graph/unknown-replacement.d.ts +2 -1
- package/dataflow/graph/vertex.d.ts +2 -103
- package/dataflow/graph/vertex.js +0 -44
- package/dataflow/internal/linker.d.ts +2 -2
- package/dataflow/internal/linker.js +27 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +13 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +0 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -72
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +4 -16
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/process/process-named-call.d.ts +2 -1
- package/dataflow/internal/process/process-named-call.js +0 -1
- package/dataflow/internal/process/process-symbol.d.ts +3 -1
- package/dataflow/internal/process/process-symbol.js +8 -5
- package/dataflow/origin/dfg-get-origin.d.ts +2 -2
- package/dataflow/origin/dfg-get-origin.js +4 -4
- package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
- package/documentation/data/interface/doc-writing-code.d.ts +6 -0
- package/documentation/data/interface/doc-writing-code.js +176 -0
- package/documentation/doc-util/doc-types.d.ts +3 -1
- package/documentation/doc-util/doc-types.js +4 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-analyzer.js +17 -2
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-dataflow-graph.js +9 -8
- package/documentation/wiki-interface.js +8 -164
- package/documentation/wiki-mk/doc-context.d.ts +12 -1
- package/documentation/wiki-mk/doc-context.js +21 -4
- package/documentation/wiki-normalized-ast.js +5 -0
- package/linter/linter-rules.d.ts +6 -6
- package/linter/rules/absolute-path.js +23 -23
- package/linter/rules/dataframe-access-validation.js +2 -1
- package/linter/rules/deprecated-functions.d.ts +2 -2
- package/linter/rules/deprecated-functions.js +1 -1
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/network-functions.d.ts +2 -2
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +7 -5
- package/linter/rules/unused-definition.js +4 -4
- package/package.json +5 -5
- package/project/context/flowr-analyzer-context.d.ts +17 -1
- package/project/context/flowr-analyzer-context.js +17 -1
- package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
- package/project/context/flowr-analyzer-meta-context.js +47 -0
- package/project/flowr-analyzer.d.ts +17 -1
- package/project/flowr-analyzer.js +18 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +17 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +292 -10
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
- package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -4
- package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +14 -4
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
- package/r-bridge/data/data.d.ts +8 -3
- package/r-bridge/data/data.js +9 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +0 -11
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +12 -13
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +4 -11
- package/reconstruct/reconstruct.js +6 -5
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +37 -6
- package/search/search-executor/search-enrichers.d.ts +1 -2
- package/search/search-executor/search-enrichers.js +9 -7
- package/slicing/static/slice-call.js +5 -5
- package/slicing/static/static-slicer.js +2 -2
- package/statistics/features/common-syntax-probability.js +3 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
- package/statistics/features/supported/used-functions/used-functions.js +3 -2
- package/util/mermaid/dfg.js +3 -3
- package/util/simple-df/dfg-ascii.js +5 -5
- package/util/version.js +1 -1
- package/util/containers.d.ts +0 -66
- package/util/containers.js +0 -143
package/cli/common/options.js
CHANGED
|
@@ -23,7 +23,6 @@ exports.benchmarkOptions = [
|
|
|
23
23
|
{ name: 'output', alias: 'o', type: String, description: `Folder to write all the measurements to in a per-file-basis (defaults to {italic benchmark-${StartTimeString}})`, defaultValue: `benchmark-${StartTimeString}`, typeLabel: '{underline folder}' },
|
|
24
24
|
{ name: 'parser', type: String, description: 'The parser to use for the benchmark', defaultValue: 'r-shell', typeLabel: '{underline parser}' },
|
|
25
25
|
{ name: 'dataframe-shape-inference', type: Boolean, description: 'Infer the shape of data frames using abstract interpretation (includes control flow graph extraction)', defaultValue: false },
|
|
26
|
-
{ name: 'enable-pointer-tracking', type: Boolean, description: 'Run dataflow analysis with pointer tracking', defaultValue: false },
|
|
27
26
|
{ name: 'max-file-slices', type: Number, description: 'If file has more than passed number of slices, the file is not processed', defaultValue: -1, typeLabel: '{underline number}' },
|
|
28
27
|
{ name: 'threshold', alias: 't', type: Number, description: 'How many re-visits of the same node are ok?', defaultValue: undefined, typeLabel: '{underline number}' },
|
|
29
28
|
{ name: 'per-file-time-limit', type: Number, description: 'Time limit in milliseconds to process single file (disabled by default)', defaultValue: undefined, typeLabel: '{underline number}' },
|
|
@@ -41,7 +40,6 @@ exports.benchmarkHelperOptions = [
|
|
|
41
40
|
{ name: 'output', alias: 'o', type: String, description: 'File to write the measurements to (appends a single line in JSON format)', typeLabel: '{underline file}' },
|
|
42
41
|
{ name: 'parser', type: String, description: 'The parser to use for the benchmark', defaultValue: 'r-shell', typeLabel: '{underline parser}' },
|
|
43
42
|
{ name: 'dataframe-shape-inference', type: Boolean, description: 'Infer the shape of data frames using abstract interpretation (includes control flow graph extraction)', defaultValue: false },
|
|
44
|
-
{ name: 'enable-pointer-tracking', type: Boolean, description: 'Run dataflow analysis with pointer tracking', defaultValue: false },
|
|
45
43
|
{ name: 'max-slices', type: Number, description: 'If file has more than passed number of slices, the file is not processed', defaultValue: -1, typeLabel: '{underline number}' },
|
|
46
44
|
{ name: 'threshold', alias: 't', type: Number, description: 'How many re-visits of the same node are ok?', defaultValue: undefined, typeLabel: '{underline number}' },
|
|
47
45
|
{ name: 'sampling-strategy', type: String, description: 'Which strategy to use, when sampling is enabled', defaultValue: 'random', typeLabel: '{underline random/equidistant}' },
|
|
@@ -162,11 +162,6 @@ declare const _scripts: {
|
|
|
162
162
|
readonly type: BooleanConstructor;
|
|
163
163
|
readonly description: "Infer the shape of data frames using abstract interpretation (includes control flow graph extraction)";
|
|
164
164
|
readonly defaultValue: false;
|
|
165
|
-
}, {
|
|
166
|
-
readonly name: "enable-pointer-tracking";
|
|
167
|
-
readonly type: BooleanConstructor;
|
|
168
|
-
readonly description: "Run dataflow analysis with pointer tracking";
|
|
169
|
-
readonly defaultValue: false;
|
|
170
165
|
}, {
|
|
171
166
|
readonly name: "max-file-slices";
|
|
172
167
|
readonly type: NumberConstructor;
|
|
@@ -261,11 +256,6 @@ declare const _scripts: {
|
|
|
261
256
|
readonly type: BooleanConstructor;
|
|
262
257
|
readonly description: "Infer the shape of data frames using abstract interpretation (includes control flow graph extraction)";
|
|
263
258
|
readonly defaultValue: false;
|
|
264
|
-
}, {
|
|
265
|
-
readonly name: "enable-pointer-tracking";
|
|
266
|
-
readonly type: BooleanConstructor;
|
|
267
|
-
readonly description: "Run dataflow analysis with pointer tracking";
|
|
268
|
-
readonly defaultValue: false;
|
|
269
259
|
}, {
|
|
270
260
|
readonly name: "max-slices";
|
|
271
261
|
readonly type: NumberConstructor;
|
|
@@ -256,7 +256,7 @@ class FlowRServerConnection {
|
|
|
256
256
|
type: 'response-slice',
|
|
257
257
|
id: request.id,
|
|
258
258
|
results: Object.fromEntries(Object.entries(result)
|
|
259
|
-
.filter(([k
|
|
259
|
+
.filter(([k]) => default_pipelines_1.DEFAULT_SLICING_PIPELINE.steps.get(k)?.executed === 1 /* PipelineStepStage.OncePerRequest */))
|
|
260
260
|
});
|
|
261
261
|
}).catch(e => {
|
|
262
262
|
this.logger.error(`[${this.name}] Error while analyzing file for token ${request.filetoken}: ${String(e)}`);
|
package/config.d.ts
CHANGED
|
@@ -131,17 +131,6 @@ export interface FlowrConfigOptions extends MergeableRecord {
|
|
|
131
131
|
* Should we include eval(parse(text="...")) calls in the dataflow graph?
|
|
132
132
|
*/
|
|
133
133
|
readonly evalStrings: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Whether to track pointers in the dataflow graph,
|
|
136
|
-
* if not, the graph will be over-approximated wrt.
|
|
137
|
-
* containers and accesses
|
|
138
|
-
*/
|
|
139
|
-
readonly pointerTracking: boolean | {
|
|
140
|
-
/**
|
|
141
|
-
* The maximum number of indices tracked per obj with the pointer analysis (currently this focuses on initialization)
|
|
142
|
-
*/
|
|
143
|
-
readonly maxIndexCount: number;
|
|
144
|
-
};
|
|
145
134
|
/** These keys are only intended for use within code, allowing to instrument the dataflow analyzer! */
|
|
146
135
|
readonly instrument: {
|
|
147
136
|
/**
|
|
@@ -249,7 +238,3 @@ export declare function getConfig(configFile?: string, configWorkingDirectory?:
|
|
|
249
238
|
export declare function getEngineConfig<T extends EngineConfig['type']>(config: FlowrConfigOptions, engine: T): EngineConfig & {
|
|
250
239
|
type: T;
|
|
251
240
|
} | undefined;
|
|
252
|
-
/**
|
|
253
|
-
* Checks whether the given count is over the pointer analysis threshold configured in the config.
|
|
254
|
-
*/
|
|
255
|
-
export declare function isOverPointerAnalysisThreshold(config: FlowrConfigOptions, count: number): boolean;
|
package/config.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.amendConfig = amendConfig;
|
|
|
9
9
|
exports.cloneConfig = cloneConfig;
|
|
10
10
|
exports.getConfig = getConfig;
|
|
11
11
|
exports.getEngineConfig = getEngineConfig;
|
|
12
|
-
exports.isOverPointerAnalysisThreshold = isOverPointerAnalysisThreshold;
|
|
13
12
|
const objects_1 = require("./util/objects");
|
|
14
13
|
const path_1 = __importDefault(require("path"));
|
|
15
14
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -77,7 +76,6 @@ exports.defaultConfigOptions = {
|
|
|
77
76
|
solver: {
|
|
78
77
|
variables: VariableResolve.Alias,
|
|
79
78
|
evalStrings: true,
|
|
80
|
-
pointerTracking: false,
|
|
81
79
|
resolveSource: {
|
|
82
80
|
dropPaths: DropPathsOption.No,
|
|
83
81
|
ignoreCapitalization: true,
|
|
@@ -133,9 +131,6 @@ exports.flowrConfigFileSchema = joi_1.default.object({
|
|
|
133
131
|
solver: joi_1.default.object({
|
|
134
132
|
variables: joi_1.default.string().valid(...Object.values(VariableResolve)).description('How to resolve variables and their values.'),
|
|
135
133
|
evalStrings: joi_1.default.boolean().description('Should we include eval(parse(text="...")) calls in the dataflow graph?'),
|
|
136
|
-
pointerTracking: joi_1.default.alternatives(joi_1.default.boolean(), joi_1.default.object({
|
|
137
|
-
maxIndexCount: joi_1.default.number().required().description('The maximum number of indices tracked per object with the pointer analysis.')
|
|
138
|
-
})).description('Whether to track pointers in the dataflow graph, if not, the graph will be over-approximated wrt. containers and accesses.'),
|
|
139
134
|
instrument: joi_1.default.object({
|
|
140
135
|
dataflowExtractors: joi_1.default.any().optional().description('These keys are only intended for use within code, allowing to instrument the dataflow analyzer!')
|
|
141
136
|
}),
|
|
@@ -221,22 +216,6 @@ function getEngineConfig(config, engine) {
|
|
|
221
216
|
return engines.find(e => e.type == engine);
|
|
222
217
|
}
|
|
223
218
|
}
|
|
224
|
-
function getPointerAnalysisThreshold(config) {
|
|
225
|
-
const pointerTracking = config.solver.pointerTracking;
|
|
226
|
-
if (typeof pointerTracking === 'object') {
|
|
227
|
-
return pointerTracking.maxIndexCount;
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
return pointerTracking ? 'unlimited' : 'disabled';
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Checks whether the given count is over the pointer analysis threshold configured in the config.
|
|
235
|
-
*/
|
|
236
|
-
function isOverPointerAnalysisThreshold(config, count) {
|
|
237
|
-
const threshold = getPointerAnalysisThreshold(config);
|
|
238
|
-
return threshold !== 'unlimited' && (threshold === 'disabled' || count > threshold);
|
|
239
|
-
}
|
|
240
219
|
function loadConfigFromFile(configFile, workingDirectory) {
|
|
241
220
|
if (configFile !== undefined) {
|
|
242
221
|
if (path_1.default.isAbsolute(configFile) && fs_1.default.existsSync(configFile)) {
|
|
@@ -107,9 +107,6 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
|
|
|
107
107
|
onWhileLoopCall(data) {
|
|
108
108
|
this.handleWithCondition(data);
|
|
109
109
|
}
|
|
110
|
-
onReturnCall(data) {
|
|
111
|
-
this.cachedStatements.set(data.call.id, true);
|
|
112
|
-
}
|
|
113
110
|
onStopCall(data) {
|
|
114
111
|
this.cachedStatements.set(data.call.id, true);
|
|
115
112
|
}
|
|
@@ -79,7 +79,7 @@ function extractCfgQuick(ast) {
|
|
|
79
79
|
function getCallsInCfg(cfg, graph) {
|
|
80
80
|
const calls = new Map();
|
|
81
81
|
for (const vertexId of cfg.graph.vertices().keys()) {
|
|
82
|
-
const vertex = graph.getVertex(vertexId
|
|
82
|
+
const vertex = graph.getVertex(vertexId);
|
|
83
83
|
if ((0, vertex_1.isFunctionCallVertex)(vertex)) {
|
|
84
84
|
calls.set(vertexId, vertex);
|
|
85
85
|
}
|
|
@@ -332,6 +332,10 @@ function cfgFunctionCall(call, name, args, exit = 'exit') {
|
|
|
332
332
|
for (const exit of lastArgExits) {
|
|
333
333
|
graph.addEdge(callId + '-exit', exit, { label: 0 /* CfgEdgeType.Fd */ });
|
|
334
334
|
}
|
|
335
|
+
if (call.named && call.functionName.content === 'return') {
|
|
336
|
+
info.returns.push(callId + '-exit');
|
|
337
|
+
info.exitPoints.length = 0;
|
|
338
|
+
}
|
|
335
339
|
// should not contain any breaks, nexts, or returns, (except for the body if something like 'break()')
|
|
336
340
|
return info;
|
|
337
341
|
}
|
|
@@ -534,4 +534,11 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, ControlFlow ex
|
|
|
534
534
|
protected onReturnCall(_data: {
|
|
535
535
|
call: DataflowGraphVertexFunctionCall;
|
|
536
536
|
}): void;
|
|
537
|
+
/**
|
|
538
|
+
* This event triggers for every call to `Recall`, which is used to recall the function closure (usually in recursive functions).
|
|
539
|
+
* @protected
|
|
540
|
+
*/
|
|
541
|
+
protected onRecallCall(_data: {
|
|
542
|
+
call: DataflowGraphVertexFunctionCall;
|
|
543
|
+
}): void;
|
|
537
544
|
}
|
|
@@ -202,11 +202,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
202
202
|
case built_in_1.BuiltInProcName.TableAssignment: {
|
|
203
203
|
const outgoing = this.config.dfg.outgoingEdges(call.id);
|
|
204
204
|
if (outgoing) {
|
|
205
|
-
const target =
|
|
205
|
+
const target = outgoing.entries().filter(([, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)).toArray();
|
|
206
206
|
if (target.length === 1) {
|
|
207
207
|
const targetOut = this.config.dfg.outgoingEdges(target[0][0]);
|
|
208
208
|
if (targetOut) {
|
|
209
|
-
const source = [...targetOut.entries()].filter(([t, e]) =>
|
|
209
|
+
const source = [...targetOut.entries()].filter(([t, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.DefinedBy) && t !== call.id);
|
|
210
210
|
if (source.length === 1) {
|
|
211
211
|
return this.onAssignmentCall({ call, target: target[0][0], source: source[0][0] });
|
|
212
212
|
}
|
|
@@ -236,11 +236,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
236
236
|
case built_in_1.BuiltInProcName.Replacement: {
|
|
237
237
|
const outgoing = this.config.dfg.outgoingEdges(call.id);
|
|
238
238
|
if (outgoing) {
|
|
239
|
-
const target =
|
|
239
|
+
const target = outgoing.entries().filter(([, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)).toArray();
|
|
240
240
|
if (target.length === 1) {
|
|
241
241
|
const targetOut = this.config.dfg.outgoingEdges(target[0][0]);
|
|
242
242
|
if (targetOut) {
|
|
243
|
-
const source =
|
|
243
|
+
const source = targetOut.entries().filter(([t, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.DefinedBy) && t !== call.id).toArray();
|
|
244
244
|
if (source.length === 1) {
|
|
245
245
|
return this.onReplacementCall({ call, target: target[0][0], source: source[0][0] });
|
|
246
246
|
}
|
|
@@ -269,6 +269,8 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
269
269
|
return this.onReturnCall({ call });
|
|
270
270
|
case built_in_1.BuiltInProcName.Unnamed:
|
|
271
271
|
return this.onUnnamedCall({ call });
|
|
272
|
+
case built_in_1.BuiltInProcName.Recall:
|
|
273
|
+
return this.onRecallCall({ call });
|
|
272
274
|
case built_in_1.BuiltInProcName.Default:
|
|
273
275
|
case built_in_1.BuiltInProcName.Function:
|
|
274
276
|
case built_in_1.BuiltInProcName.FunctionDefinition:
|
|
@@ -606,6 +608,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
|
|
|
606
608
|
* @protected
|
|
607
609
|
*/
|
|
608
610
|
onReturnCall(_data) { }
|
|
611
|
+
/**
|
|
612
|
+
* This event triggers for every call to `Recall`, which is used to recall the function closure (usually in recursive functions).
|
|
613
|
+
* @protected
|
|
614
|
+
*/
|
|
615
|
+
onRecallCall(_data) { }
|
|
609
616
|
}
|
|
610
617
|
exports.SemanticCfgGuidedVisitor = SemanticCfgGuidedVisitor;
|
|
611
618
|
//# sourceMappingURL=semantic-cfg-guided-visitor.js.map
|
package/dataflow/cluster.js
CHANGED
|
@@ -35,9 +35,9 @@ function makeCluster(graph, from, notReached) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
// cluster adjacent edges
|
|
38
|
-
for (const [dest,
|
|
38
|
+
for (const [dest, e] of [...graph.outgoingEdges(from) ?? [], ...graph.ingoingEdges(from) ?? []]) {
|
|
39
39
|
// don't cluster for function content if it isn't returned
|
|
40
|
-
if (
|
|
40
|
+
if (edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Returns) && info.onlyBuiltin && info.name == '{') {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
43
|
if (notReached.delete(dest)) {
|
|
@@ -39,6 +39,7 @@ export interface BuiltInReplacementDefinition extends BaseBuiltInDefinition {
|
|
|
39
39
|
readonly suffixes: ('<<-' | '<-')[];
|
|
40
40
|
readonly config: {
|
|
41
41
|
readIndices: boolean;
|
|
42
|
+
libFn?: boolean;
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
export type BuiltInDefinition<T extends keyof typeof BuiltInProcessorMapper = keyof typeof BuiltInProcessorMapper> = BuiltInConstantDefinition<unknown> | BuiltInFunctionDefinition<T> | BuiltInReplacementDefinition;
|
|
@@ -8,7 +8,7 @@ import { processPipe } from '../internal/process/functions/call/built-in/built-i
|
|
|
8
8
|
import { processForLoop } from '../internal/process/functions/call/built-in/built-in-for-loop';
|
|
9
9
|
import { processRepeatLoop } from '../internal/process/functions/call/built-in/built-in-repeat-loop';
|
|
10
10
|
import { processWhileLoop } from '../internal/process/functions/call/built-in/built-in-while-loop';
|
|
11
|
-
import { type
|
|
11
|
+
import { type BrandedIdentifier, type IdentifierDefinition, type IdentifierReference, ReferenceType } from './identifier';
|
|
12
12
|
import { processReplacementFunction } from '../internal/process/functions/call/built-in/built-in-replacement';
|
|
13
13
|
import { processQuote } from '../internal/process/functions/call/built-in/built-in-quote';
|
|
14
14
|
import { processFunctionDefinition } from '../internal/process/functions/call/built-in/built-in-function-definition';
|
|
@@ -39,6 +39,7 @@ import { processTryCatch } from '../internal/process/functions/call/built-in/bui
|
|
|
39
39
|
import { processRegisterHook } from '../internal/process/functions/call/built-in/built-in-register-hook';
|
|
40
40
|
import { processLocal } from '../internal/process/functions/call/built-in/built-in-local';
|
|
41
41
|
import { processS3Dispatch } from '../internal/process/functions/call/built-in/built-in-s-three-dispatch';
|
|
42
|
+
import { processRecall } from '../internal/process/functions/call/built-in/built-in-recall';
|
|
42
43
|
export type BuiltIn = `built-in:${string}`;
|
|
43
44
|
/**
|
|
44
45
|
* Generate a built-in id for the given name
|
|
@@ -122,6 +123,10 @@ export declare enum BuiltInProcName {
|
|
|
122
123
|
Pipe = "builtin:pipe",
|
|
123
124
|
/** for `quote`, and other substituting calls, see {@link processQuote} */
|
|
124
125
|
Quote = "builtin:quote",
|
|
126
|
+
/**
|
|
127
|
+
* for `recall` calls, see {@link processRecall}
|
|
128
|
+
*/
|
|
129
|
+
Recall = "builtin:recall",
|
|
125
130
|
/** for `on.exìt` and other hooks, see {@link processRegisterHook} */
|
|
126
131
|
RegisterHook = "builtin:register-hook",
|
|
127
132
|
/** for `repeat` loops, see {@link processRepeatLoop} */
|
|
@@ -170,6 +175,7 @@ export declare const BuiltInProcessorMapper: {
|
|
|
170
175
|
readonly "builtin:local": typeof processLocal;
|
|
171
176
|
readonly "builtin:pipe": typeof processPipe;
|
|
172
177
|
readonly "builtin:quote": typeof processQuote;
|
|
178
|
+
readonly "builtin:recall": typeof processRecall;
|
|
173
179
|
readonly "builtin:register-hook": typeof processRegisterHook;
|
|
174
180
|
readonly "builtin:repeat-loop": typeof processRepeatLoop;
|
|
175
181
|
readonly "builtin:replacement": typeof processReplacementFunction;
|
|
@@ -189,7 +195,7 @@ export declare const BuiltInEvalHandlerMapper: {
|
|
|
189
195
|
readonly 'built-in:-': typeof resolveAsMinus;
|
|
190
196
|
};
|
|
191
197
|
export type ConfigOfBuiltInMappingName<N extends keyof typeof BuiltInProcessorMapper> = Parameters<typeof BuiltInProcessorMapper[N]>[4];
|
|
192
|
-
export type BuiltInMemory = Map<
|
|
198
|
+
export type BuiltInMemory = Map<BrandedIdentifier, IdentifierDefinition[]>;
|
|
193
199
|
export declare class BuiltIns {
|
|
194
200
|
/**
|
|
195
201
|
* Register a built-in constant (like `NULL` or `TRUE`) to the given {@link BuiltIns}
|
|
@@ -221,6 +227,6 @@ export declare class BuiltIns {
|
|
|
221
227
|
* @see {@link builtInMemory}
|
|
222
228
|
*/
|
|
223
229
|
emptyBuiltInMemory: BuiltInMemory;
|
|
224
|
-
set(identifier:
|
|
230
|
+
set(identifier: BrandedIdentifier, definition: IdentifierDefinition[], includeInEmptyMemory: boolean | undefined): void;
|
|
225
231
|
}
|
|
226
232
|
export {};
|
|
@@ -38,6 +38,7 @@ const built_in_try_catch_1 = require("../internal/process/functions/call/built-i
|
|
|
38
38
|
const built_in_register_hook_1 = require("../internal/process/functions/call/built-in/built-in-register-hook");
|
|
39
39
|
const built_in_local_1 = require("../internal/process/functions/call/built-in/built-in-local");
|
|
40
40
|
const built_in_s_three_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-three-dispatch");
|
|
41
|
+
const built_in_recall_1 = require("../internal/process/functions/call/built-in/built-in-recall");
|
|
41
42
|
/**
|
|
42
43
|
* Generate a built-in id for the given name
|
|
43
44
|
*/
|
|
@@ -81,7 +82,7 @@ function defaultBuiltInProcessor(name, args, rootId, data, { returnsNthArgument,
|
|
|
81
82
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId, hasUnknownSideEffects);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
const fnCallNames = treatAsFnCall?.[name.content];
|
|
85
|
+
const fnCallNames = treatAsFnCall?.[identifier_1.Identifier.getName(name.content)];
|
|
85
86
|
if (fnCallNames) {
|
|
86
87
|
for (const arg of args) {
|
|
87
88
|
if (arg !== r_function_call_1.EmptyArgument && arg.value && fnCallNames.includes(arg.name?.content)) {
|
|
@@ -158,6 +159,10 @@ var BuiltInProcName;
|
|
|
158
159
|
BuiltInProcName["Pipe"] = "builtin:pipe";
|
|
159
160
|
/** for `quote`, and other substituting calls, see {@link processQuote} */
|
|
160
161
|
BuiltInProcName["Quote"] = "builtin:quote";
|
|
162
|
+
/**
|
|
163
|
+
* for `recall` calls, see {@link processRecall}
|
|
164
|
+
*/
|
|
165
|
+
BuiltInProcName["Recall"] = "builtin:recall";
|
|
161
166
|
/** for `on.exìt` and other hooks, see {@link processRegisterHook} */
|
|
162
167
|
BuiltInProcName["RegisterHook"] = "builtin:register-hook";
|
|
163
168
|
/** for `repeat` loops, see {@link processRepeatLoop} */
|
|
@@ -206,6 +211,7 @@ exports.BuiltInProcessorMapper = {
|
|
|
206
211
|
[BuiltInProcName.Local]: built_in_local_1.processLocal,
|
|
207
212
|
[BuiltInProcName.Pipe]: built_in_pipe_1.processPipe,
|
|
208
213
|
[BuiltInProcName.Quote]: built_in_quote_1.processQuote,
|
|
214
|
+
[BuiltInProcName.Recall]: built_in_recall_1.processRecall,
|
|
209
215
|
[BuiltInProcName.RegisterHook]: built_in_register_hook_1.processRegisterHook,
|
|
210
216
|
[BuiltInProcName.RepeatLoop]: built_in_repeat_loop_1.processRepeatLoop,
|
|
211
217
|
[BuiltInProcName.Replacement]: built_in_replacement_1.processReplacementFunction,
|
|
@@ -230,7 +236,8 @@ class BuiltIns {
|
|
|
230
236
|
*/
|
|
231
237
|
registerBuiltInConstant({ names, value, assumePrimitive }) {
|
|
232
238
|
for (const name of names) {
|
|
233
|
-
const
|
|
239
|
+
const n = identifier_1.Identifier.getName(name);
|
|
240
|
+
const id = builtInId(n);
|
|
234
241
|
const d = [{
|
|
235
242
|
type: identifier_1.ReferenceType.BuiltInConstant,
|
|
236
243
|
definedAt: id,
|
|
@@ -239,7 +246,7 @@ class BuiltIns {
|
|
|
239
246
|
name,
|
|
240
247
|
nodeId: id
|
|
241
248
|
}];
|
|
242
|
-
this.set(
|
|
249
|
+
this.set(n, d, assumePrimitive);
|
|
243
250
|
}
|
|
244
251
|
}
|
|
245
252
|
/**
|
|
@@ -250,7 +257,8 @@ class BuiltIns {
|
|
|
250
257
|
const mappedProcessor = exports.BuiltInProcessorMapper[processor];
|
|
251
258
|
(0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(exports.BuiltInProcessorMapper))}!`);
|
|
252
259
|
for (const name of names) {
|
|
253
|
-
const
|
|
260
|
+
const n = identifier_1.Identifier.getName(name);
|
|
261
|
+
const id = builtInId(n);
|
|
254
262
|
const d = [{
|
|
255
263
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
256
264
|
definedAt: id,
|
|
@@ -261,7 +269,7 @@ class BuiltIns {
|
|
|
261
269
|
name,
|
|
262
270
|
nodeId: id
|
|
263
271
|
}];
|
|
264
|
-
this.set(
|
|
272
|
+
this.set(n, d, assumePrimitive);
|
|
265
273
|
}
|
|
266
274
|
}
|
|
267
275
|
/**
|
|
@@ -272,7 +280,7 @@ class BuiltIns {
|
|
|
272
280
|
(0, assert_1.guard)(replacer !== undefined, () => `Processor for ${BuiltInProcName.Replacement} is undefined!`);
|
|
273
281
|
for (const assignment of names) {
|
|
274
282
|
for (const suffix of suffixes) {
|
|
275
|
-
const effectiveName = `${assignment}${suffix}`;
|
|
283
|
+
const effectiveName = `${identifier_1.Identifier.getName(assignment)}${suffix}`;
|
|
276
284
|
const id = builtInId(effectiveName);
|
|
277
285
|
const d = [{
|
|
278
286
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
@@ -283,7 +291,7 @@ class BuiltIns {
|
|
|
283
291
|
assignmentOperator: suffix,
|
|
284
292
|
makeMaybe: true
|
|
285
293
|
},
|
|
286
|
-
name:
|
|
294
|
+
name: assignment,
|
|
287
295
|
cds: undefined,
|
|
288
296
|
nodeId: id
|
|
289
297
|
}];
|
|
@@ -5,6 +5,7 @@ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-i
|
|
|
5
5
|
import { CascadeAction } from '../../queries/catalog/call-context-query/cascade-action';
|
|
6
6
|
import { BuiltInProcName } from './built-in';
|
|
7
7
|
import { KnownHooks } from '../hooks';
|
|
8
|
+
import { Identifier } from './identifier';
|
|
8
9
|
export declare const GgPlotCreate: readonly ["ggplot", "ggplotly", "ggMarginal", "ggcorrplot", "ggseasonplot", "ggdendrogram", "qmap", "qplot", "quickplot", "autoplot", "grid.arrange", "fviz_pca_biplot", "fviz_pca", "fviz_pca_ind", "fviz_pca_var", "fviz_screeplot", "fviz_mca_biplot", "fviz_mca", "fviz_mca_ind", "fviz_mca_var", "fviz_cluster", "fviz_dend", "ggsurvplot"];
|
|
9
10
|
export declare const TinyPlotCrate: readonly ["tinyplot", "plt"];
|
|
10
11
|
export declare const GraphicsPlotCreate: string[];
|
|
@@ -383,7 +384,7 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
383
384
|
readonly assumePrimitive: false;
|
|
384
385
|
}, {
|
|
385
386
|
readonly type: "function";
|
|
386
|
-
readonly names: [
|
|
387
|
+
readonly names: [Identifier, Identifier];
|
|
387
388
|
readonly processor: BuiltInProcName.Library;
|
|
388
389
|
readonly config: {};
|
|
389
390
|
readonly assumePrimitive: false;
|
|
@@ -598,6 +599,14 @@ export declare const DefaultBuiltinConfig: [{
|
|
|
598
599
|
readonly processor: BuiltInProcName.List;
|
|
599
600
|
readonly config: {};
|
|
600
601
|
readonly assumePrimitive: true;
|
|
602
|
+
}, {
|
|
603
|
+
readonly type: "function";
|
|
604
|
+
readonly names: ["Recall"];
|
|
605
|
+
readonly processor: BuiltInProcName.Recall;
|
|
606
|
+
readonly config: {
|
|
607
|
+
readonly libFn: true;
|
|
608
|
+
};
|
|
609
|
+
readonly assumePrimitive: false;
|
|
601
610
|
}, {
|
|
602
611
|
readonly type: "function";
|
|
603
612
|
readonly names: ["c"];
|
|
@@ -8,6 +8,7 @@ const cascade_action_1 = require("../../queries/catalog/call-context-query/casca
|
|
|
8
8
|
const built_in_1 = require("./built-in");
|
|
9
9
|
const unnamed_call_handling_1 = require("../internal/process/functions/call/unnamed-call-handling");
|
|
10
10
|
const hooks_1 = require("../hooks");
|
|
11
|
+
const identifier_1 = require("./identifier");
|
|
11
12
|
exports.GgPlotCreate = [
|
|
12
13
|
'ggplot', 'ggplotly', 'ggMarginal', 'ggcorrplot', 'ggseasonplot', 'ggdendrogram', 'qmap', 'qplot', 'quickplot', 'autoplot', 'grid.arrange',
|
|
13
14
|
'fviz_pca_biplot', 'fviz_pca', 'fviz_pca_ind', 'fviz_pca_var', 'fviz_screeplot', 'fviz_mca_biplot', 'fviz_mca', 'fviz_mca_ind', 'fviz_mca_var', 'fviz_cluster', 'fviz_dend',
|
|
@@ -140,7 +141,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
140
141
|
type: 'link-to-last-call',
|
|
141
142
|
ignoreIf: (source, graph) => {
|
|
142
143
|
/* map with add = true appends to an existing plot */
|
|
143
|
-
return (exports.PlotFunctionsWithAddParam.has(source.name) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, source, {
|
|
144
|
+
return (exports.PlotFunctionsWithAddParam.has(identifier_1.Identifier.getName(source.name)) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, source, {
|
|
144
145
|
index: -1,
|
|
145
146
|
name: 'add'
|
|
146
147
|
}, [type_1.RType.Logical])?.content === true);
|
|
@@ -161,14 +162,14 @@ exports.DefaultBuiltinConfig = [
|
|
|
161
162
|
ignoreIf: (source, graph) => {
|
|
162
163
|
const sourceVertex = graph.getVertex(source);
|
|
163
164
|
/* map with add = true appends to an existing plot */
|
|
164
|
-
return (exports.PlotFunctionsWithAddParam.has(sourceVertex.name
|
|
165
|
+
return (exports.PlotFunctionsWithAddParam.has(identifier_1.Identifier.getName(sourceVertex.name)) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, sourceVertex, {
|
|
165
166
|
index: -1,
|
|
166
167
|
name: 'add'
|
|
167
168
|
}, [type_1.RType.Logical])?.content !== true);
|
|
168
169
|
},
|
|
169
170
|
cascadeIf: (target, _, graph) => {
|
|
170
171
|
/* map with add = true appends to an existing plot */
|
|
171
|
-
return target.name
|
|
172
|
+
return identifier_1.Identifier.getName(target.name) ? ((0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, target, {
|
|
172
173
|
index: 11,
|
|
173
174
|
name: 'add'
|
|
174
175
|
}, [type_1.RType.Logical])?.content === true ? cascade_action_1.CascadeAction.Continue : cascade_action_1.CascadeAction.Stop) : cascade_action_1.CascadeAction.Stop;
|
|
@@ -253,7 +254,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
253
254
|
{ type: 'function', names: ['ifelse', 'fifelse', 'IfElse'], processor: built_in_1.BuiltInProcName.IfThenElse, config: { args: { cond: 'test', yes: 'yes', no: 'no' } }, assumePrimitive: true },
|
|
254
255
|
{ type: 'function', names: ['if_else'], processor: built_in_1.BuiltInProcName.IfThenElse, config: { args: { cond: 'condition', yes: 'true', no: 'false' } }, assumePrimitive: true },
|
|
255
256
|
{ type: 'function', names: ['get'], processor: built_in_1.BuiltInProcName.Get, config: {}, assumePrimitive: false },
|
|
256
|
-
{ type: 'function', names: ['library', 'require'], processor: built_in_1.BuiltInProcName.Library, config: {}, assumePrimitive: false },
|
|
257
|
+
{ type: 'function', names: [identifier_1.Identifier.make('library', 'base'), identifier_1.Identifier.make('require', 'base')], processor: built_in_1.BuiltInProcName.Library, config: {}, assumePrimitive: false },
|
|
257
258
|
{ type: 'function', names: ['<-', '='], processor: built_in_1.BuiltInProcName.Assignment, config: { canBeReplacement: true }, assumePrimitive: true },
|
|
258
259
|
{ type: 'function', names: [':='], processor: built_in_1.BuiltInProcName.Assignment, config: {}, assumePrimitive: true },
|
|
259
260
|
{ type: 'function', names: ['assign', 'setGeneric', 'setValidity'], processor: built_in_1.BuiltInProcName.Assignment, config: { targetVariable: true, mayHaveMoreArgs: true }, assumePrimitive: true },
|
|
@@ -278,6 +279,7 @@ exports.DefaultBuiltinConfig = [
|
|
|
278
279
|
{ type: 'function', names: ['interference'], processor: built_in_1.BuiltInProcName.Apply, config: { unquoteFunction: true, nameOfFunctionArgument: 'propensity_integrand', libFn: true }, assumePrimitive: false },
|
|
279
280
|
{ type: 'function', names: ['ddply'], processor: built_in_1.BuiltInProcName.Apply, config: { unquoteFunction: true, indexOfFunction: 2, nameOfFunctionArgument: '.fun', libFn: true }, assumePrimitive: false },
|
|
280
281
|
{ type: 'function', names: ['list'], processor: built_in_1.BuiltInProcName.List, config: {}, assumePrimitive: true },
|
|
282
|
+
{ type: 'function', names: ['Recall'], processor: built_in_1.BuiltInProcName.Recall, config: { libFn: true }, assumePrimitive: false },
|
|
281
283
|
{ type: 'function', names: ['c'], processor: built_in_1.BuiltInProcName.Vector, config: {}, assumePrimitive: true, evalHandler: 'built-in:c' },
|
|
282
284
|
{
|
|
283
285
|
type: 'function',
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import type { REnvironmentInformation } from './environment';
|
|
2
|
-
import
|
|
3
|
-
import type { FlowrConfigOptions } from '../../config';
|
|
2
|
+
import { Identifier, type IdentifierDefinition } from './identifier';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
export declare function mergeDefinitionsForPointer(existing: readonly IdentifierDefinition[], definition: InGraphIdentifierDefinition): InGraphIdentifierDefinition[];
|
|
8
|
-
/**
|
|
9
|
-
* Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
|
|
10
|
-
* Does not modify the passed along `environments` in-place! It returns the new reference.
|
|
11
|
-
* @see {@link Environment#define} - for details on how (local) definitions are handled.
|
|
12
|
-
* @see {@link Environment#defineSuper} - for details on how (super) definitions are handled.
|
|
4
|
+
* Define an identifier in the environment, possibly as a super assignment.
|
|
5
|
+
* This recalculates the level
|
|
13
6
|
*/
|
|
14
7
|
export declare function define(definition: IdentifierDefinition & {
|
|
15
8
|
name: Identifier;
|
|
16
|
-
}, superAssign: boolean | undefined, { level, current }: REnvironmentInformation
|
|
9
|
+
}, superAssign: boolean | undefined, { level, current }: REnvironmentInformation): REnvironmentInformation;
|
|
@@ -1,105 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeDefinitionsForPointer = mergeDefinitionsForPointer;
|
|
4
3
|
exports.define = define;
|
|
5
|
-
const
|
|
6
|
-
const vertex_1 = require("../graph/vertex");
|
|
4
|
+
const identifier_1 = require("./identifier");
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
6
|
+
* Define an identifier in the environment, possibly as a super assignment.
|
|
7
|
+
* This recalculates the level
|
|
9
8
|
*/
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
if (definition.indicesCollection?.some(indices => indices.isContainer)) {
|
|
13
|
-
return [definition];
|
|
14
|
-
}
|
|
15
|
-
const existingDefs = existing.filter(assert_1.isNotUndefined);
|
|
16
|
-
const overwriteIndices = definition.indicesCollection?.flatMap(indices => indices.indices) ?? [];
|
|
17
|
-
// Compare existing and new definitions,
|
|
18
|
-
// add new definitions and remove existing definitions that are overwritten by new definition
|
|
19
|
-
const newExistingDefs = [];
|
|
20
|
-
const hasCache = new Set();
|
|
21
|
-
for (const overwriteIndex of overwriteIndices) {
|
|
22
|
-
for (const existingDef of existingDefs) {
|
|
23
|
-
// empty or missing
|
|
24
|
-
if (existingDef.indicesCollection === undefined || existingDef.indicesCollection.length === 0) {
|
|
25
|
-
const existingDefPrint = JSON.stringify(existingDef);
|
|
26
|
-
if (!hasCache.has(existingDefPrint)) {
|
|
27
|
-
newExistingDefs.push(existingDef);
|
|
28
|
-
hasCache.add(existingDefPrint);
|
|
29
|
-
}
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const newIndicesCollection = overwriteContainerIndices(existingDef.indicesCollection, overwriteIndex);
|
|
33
|
-
// if indices are now empty list, don't keep empty definition
|
|
34
|
-
if (newIndicesCollection.length > 0) {
|
|
35
|
-
const obj = {
|
|
36
|
-
...existingDef,
|
|
37
|
-
indicesCollection: newIndicesCollection,
|
|
38
|
-
};
|
|
39
|
-
const objHash = JSON.stringify(obj);
|
|
40
|
-
if (!hasCache.has(objHash)) {
|
|
41
|
-
newExistingDefs.push(obj);
|
|
42
|
-
hasCache.add(objHash);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// store changed existing definitions and add new one
|
|
48
|
-
return [...newExistingDefs, definition];
|
|
49
|
-
}
|
|
50
|
-
function overwriteContainerIndices(existingIndices, overwriteIndex) {
|
|
51
|
-
const newIndicesCollection = [];
|
|
52
|
-
for (const indices of existingIndices) {
|
|
53
|
-
let newIndices;
|
|
54
|
-
// When overwrite index is container itself, then only overwrite sub-index
|
|
55
|
-
if ((0, vertex_1.isParentContainerIndex)(overwriteIndex)) {
|
|
56
|
-
newIndices = [];
|
|
57
|
-
for (const index of indices.indices) {
|
|
58
|
-
if ((0, vertex_1.isSameIndex)(index, overwriteIndex) && (0, vertex_1.isParentContainerIndex)(index)) {
|
|
59
|
-
const overwriteSubIndices = overwriteIndex.subIndices.flatMap(a => a.indices);
|
|
60
|
-
let newSubIndices = index.subIndices;
|
|
61
|
-
for (const overwriteSubIndex of overwriteSubIndices) {
|
|
62
|
-
newSubIndices = overwriteContainerIndices(newSubIndices, overwriteSubIndex);
|
|
63
|
-
}
|
|
64
|
-
if (newSubIndices.length > 0) {
|
|
65
|
-
newIndices.push({
|
|
66
|
-
...index,
|
|
67
|
-
subIndices: newSubIndices,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!(0, vertex_1.isSameIndex)(index, overwriteIndex) || !(0, vertex_1.isParentContainerIndex)(index)) {
|
|
72
|
-
newIndices.push(index);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (indices.isContainer) {
|
|
77
|
-
// If indices are not a single, e.g., a list, take the whole definition
|
|
78
|
-
newIndices = indices.indices;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// Filter existing indices with the same name
|
|
82
|
-
newIndices = indices.indices.filter(def => !(0, vertex_1.isSameIndex)(def, overwriteIndex));
|
|
83
|
-
}
|
|
84
|
-
if (indices.isContainer || newIndices.length > 0) {
|
|
85
|
-
newIndicesCollection.push({
|
|
86
|
-
...indices,
|
|
87
|
-
indices: newIndices,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return newIndicesCollection;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
|
|
95
|
-
* Does not modify the passed along `environments` in-place! It returns the new reference.
|
|
96
|
-
* @see {@link Environment#define} - for details on how (local) definitions are handled.
|
|
97
|
-
* @see {@link Environment#defineSuper} - for details on how (super) definitions are handled.
|
|
98
|
-
*/
|
|
99
|
-
function define(definition, superAssign, { level, current }, config) {
|
|
9
|
+
function define(definition, superAssign, { level, current }) {
|
|
10
|
+
const newEnv = superAssign ? current.defineSuper(definition) : current.define(definition);
|
|
100
11
|
return {
|
|
101
|
-
level,
|
|
102
|
-
current:
|
|
12
|
+
level: identifier_1.Identifier.getNamespace(definition.name) === undefined ? level : recalculateLevel(newEnv),
|
|
13
|
+
current: newEnv,
|
|
103
14
|
};
|
|
104
15
|
}
|
|
16
|
+
function recalculateLevel(env) {
|
|
17
|
+
let level = 0;
|
|
18
|
+
let current = env;
|
|
19
|
+
while (current.parent && !current.parent.builtInEnv) {
|
|
20
|
+
level++;
|
|
21
|
+
current = current.parent;
|
|
22
|
+
}
|
|
23
|
+
return level;
|
|
24
|
+
}
|
|
105
25
|
//# sourceMappingURL=define.js.map
|