@eagleoutice/flowr 2.8.15 → 2.9.1
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 +20 -21
- 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 +1 -48
- package/benchmark/stats/print.js +0 -6
- package/benchmark/stats/stats.d.ts +0 -3
- package/benchmark/summarizer/first-phase/process.js +1 -1
- 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 +4 -0
- package/control-flow/semantic-cfg-guided-visitor.d.ts +32 -0
- package/control-flow/semantic-cfg-guided-visitor.js +36 -4
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-config.d.ts +1 -0
- package/dataflow/environments/built-in.d.ts +19 -3
- package/dataflow/environments/built-in.js +25 -7
- package/dataflow/environments/default-builtin-config.d.ts +59 -8
- package/dataflow/environments/default-builtin-config.js +20 -6
- 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 +95 -7
- package/dataflow/environments/identifier.js +161 -1
- package/dataflow/environments/resolve-by-name.d.ts +4 -4
- package/dataflow/environments/resolve-by-name.js +29 -10
- package/dataflow/eval/resolve/alias-tracking.js +8 -1
- package/dataflow/eval/resolve/resolve.d.ts +10 -6
- package/dataflow/eval/resolve/resolve.js +12 -7
- package/dataflow/eval/values/general.js +1 -1
- package/dataflow/eval/values/r-value.d.ts +4 -1
- package/dataflow/eval/values/r-value.js +2 -0
- package/dataflow/extractor.js +6 -3
- package/dataflow/fn/higher-order-function.js +4 -4
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +10 -8
- 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 +7 -7
- 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 +35 -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 +18 -51
- 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 +4 -4
- 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 +34 -9
- 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 +1 -1
- 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 +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +30 -72
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +12 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +27 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +204 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +25 -4
- 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/named-call-handling.d.ts +1 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +1 -0
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +2 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -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 +175 -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 +3 -3
- package/linter/rules/absolute-path.js +23 -23
- package/linter/rules/dataframe-access-validation.js +2 -1
- package/linter/rules/deprecated-functions.d.ts +1 -1
- package/linter/rules/deprecated-functions.js +1 -1
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/naming-convention.d.ts +9 -2
- package/linter/rules/naming-convention.js +38 -36
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/seeded-randomness.d.ts +2 -2
- package/linter/rules/seeded-randomness.js +5 -4
- package/linter/rules/unused-definition.js +4 -4
- package/package.json +6 -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 +40 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +352 -9
- 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 +3 -3
- 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.js +2 -2
- 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 +12 -7
- package/r-bridge/data/data.js +13 -7
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -12
- 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/type.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/type.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +5 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-line-directive.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -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 +13 -14
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +24 -31
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/reconstruct/auto-select/magic-comments.js +1 -1
- package/reconstruct/reconstruct.js +6 -5
- package/search/flowr-search-filters.js +2 -1
- package/search/search-executor/search-enrichers.d.ts +1 -2
- package/search/search-executor/search-enrichers.js +2 -1
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +8 -8
- 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/r-value.d.ts +3 -2
- package/util/r-value.js +3 -0
- 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
|
@@ -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,10 +254,10 @@ 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
|
-
{ type: 'function', names: ['assign', '
|
|
260
|
+
{ type: 'function', names: ['assign', 'setValidity'], processor: built_in_1.BuiltInProcName.Assignment, config: { targetVariable: true, mayHaveMoreArgs: true }, assumePrimitive: true },
|
|
260
261
|
{ type: 'function', names: ['setMethod'], processor: built_in_1.BuiltInProcName.AssignmentLike, config: { targetVariable: true, canBeReplacement: false, target: { idx: 0, name: 'f' }, source: { idx: 2, name: 'definition' } }, assumePrimitive: true },
|
|
261
262
|
{ type: 'function', names: ['delayedAssign'], processor: built_in_1.BuiltInProcName.Assignment, config: { quoteSource: true, targetVariable: true }, assumePrimitive: true },
|
|
262
263
|
{ type: 'function', names: ['<<-'], processor: built_in_1.BuiltInProcName.Assignment, config: { superAssignment: true, canBeReplacement: true }, assumePrimitive: true },
|
|
@@ -272,12 +273,16 @@ exports.DefaultBuiltinConfig = [
|
|
|
272
273
|
{ type: 'function', names: ['repeat'], processor: built_in_1.BuiltInProcName.RepeatLoop, config: {}, assumePrimitive: true },
|
|
273
274
|
{ type: 'function', names: ['while'], processor: built_in_1.BuiltInProcName.WhileLoop, config: {}, assumePrimitive: true },
|
|
274
275
|
{ type: 'function', names: ['do.call'], processor: built_in_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, unquoteFunction: true }, assumePrimitive: true },
|
|
275
|
-
{ type: 'function', names: ['NextMethod'], processor: built_in_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, unquoteFunction: true, resolveInEnvironment: 'global' }, assumePrimitive: true },
|
|
276
276
|
{ type: 'function', names: ['UseMethod'], processor: built_in_1.BuiltInProcName.S3Dispatch, config: { args: { generic: 'generic', object: 'object' } }, assumePrimitive: true },
|
|
277
|
+
{ type: 'function', names: ['NextMethod'], processor: built_in_1.BuiltInProcName.S3Dispatch, config: { args: { generic: 'generic', object: 'object' }, inferFromClosure: true }, assumePrimitive: true },
|
|
278
|
+
{ type: 'function', names: ['new_generic'], processor: built_in_1.BuiltInProcName.S7NewGeneric, config: { args: { name: 'name', dispatchArg: 'dispatch_args', fun: 'fun' } }, assumePrimitive: true },
|
|
279
|
+
{ type: 'function', names: ['setGeneric'], processor: built_in_1.BuiltInProcName.S7NewGeneric, config: { args: { name: 'name', dispatchArg: undefined, fun: 'fun' } }, assumePrimitive: true },
|
|
280
|
+
{ type: 'function', names: ['S7_dispatch'], processor: built_in_1.BuiltInProcName.S7Dispatch, config: { libFn: true }, assumePrimitive: true },
|
|
277
281
|
{ type: 'function', names: ['.Primitive', '.Internal'], processor: built_in_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, unquoteFunction: true, resolveInEnvironment: 'global' }, assumePrimitive: true },
|
|
278
282
|
{ type: 'function', names: ['interference'], processor: built_in_1.BuiltInProcName.Apply, config: { unquoteFunction: true, nameOfFunctionArgument: 'propensity_integrand', libFn: true }, assumePrimitive: false },
|
|
279
283
|
{ type: 'function', names: ['ddply'], processor: built_in_1.BuiltInProcName.Apply, config: { unquoteFunction: true, indexOfFunction: 2, nameOfFunctionArgument: '.fun', libFn: true }, assumePrimitive: false },
|
|
280
284
|
{ type: 'function', names: ['list'], processor: built_in_1.BuiltInProcName.List, config: {}, assumePrimitive: true },
|
|
285
|
+
{ type: 'function', names: ['Recall'], processor: built_in_1.BuiltInProcName.Recall, config: { libFn: true }, assumePrimitive: false },
|
|
281
286
|
{ type: 'function', names: ['c'], processor: built_in_1.BuiltInProcName.Vector, config: {}, assumePrimitive: true, evalHandler: 'built-in:c' },
|
|
282
287
|
{
|
|
283
288
|
type: 'function',
|
|
@@ -339,6 +344,15 @@ exports.DefaultBuiltinConfig = [
|
|
|
339
344
|
readIndices: true
|
|
340
345
|
}
|
|
341
346
|
},
|
|
347
|
+
{
|
|
348
|
+
type: 'replacement',
|
|
349
|
+
suffixes: ['<-', '<<-'],
|
|
350
|
+
names: ['method'],
|
|
351
|
+
config: {
|
|
352
|
+
readIndices: true,
|
|
353
|
+
constructName: 's7'
|
|
354
|
+
}
|
|
355
|
+
},
|
|
342
356
|
{
|
|
343
357
|
type: 'replacement',
|
|
344
358
|
suffixes: ['<-', '<<-'],
|
|
@@ -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
|
|
@@ -6,6 +6,7 @@ exports.diffEnvironmentInformation = diffEnvironmentInformation;
|
|
|
6
6
|
const diff_1 = require("../../util/diff");
|
|
7
7
|
const environment_1 = require("./environment");
|
|
8
8
|
const json_1 = require("../../util/json");
|
|
9
|
+
const identifier_1 = require("./identifier");
|
|
9
10
|
const info_1 = require("../info");
|
|
10
11
|
/**
|
|
11
12
|
* Compares two identifier references and reports differences.
|
|
@@ -18,7 +19,7 @@ function diffIdentifierReferences(a, b, info) {
|
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
if (a.name !== b.name) {
|
|
21
|
-
info.report.addComment(`${info.position}Different identifier names: ${info.leftname}: ${a.name} vs. ${info.rightname}: ${b.name}`);
|
|
22
|
+
info.report.addComment(`${info.position}Different identifier names: ${info.leftname}: ${a.name ? identifier_1.Identifier.toString(a.name) : 'undefined'} vs. ${info.rightname}: ${b.name ? identifier_1.Identifier.toString(b.name) : 'undefined'}`);
|
|
22
23
|
}
|
|
23
24
|
if (a.nodeId !== b.nodeId) {
|
|
24
25
|
info.report.addComment(`${info.position}Different nodeIds: ${info.leftname}: ${a.nodeId} vs. ${info.rightname}: ${b.nodeId}`);
|
|
@@ -39,7 +40,7 @@ function diffMemory(a, b, info) {
|
|
|
39
40
|
const aVal = sorted[i];
|
|
40
41
|
const bVal = sorted2[i];
|
|
41
42
|
if (aVal.name !== bVal.name) {
|
|
42
|
-
info.report.addComment(`${info.position}Different names for ${key}. ${info.leftname}: ${aVal.name} vs. ${info.rightname}: ${bVal.name}`);
|
|
43
|
+
info.report.addComment(`${info.position}Different names for ${key}. ${info.leftname}: ${aVal.name ? identifier_1.Identifier.toString(aVal.name) : 'undefined'} vs. ${info.rightname}: ${bVal.name ? identifier_1.Identifier.toString(bVal.name) : undefined}`);
|
|
43
44
|
}
|
|
44
45
|
if (aVal.nodeId !== bVal.nodeId) {
|
|
45
46
|
info.report.addComment(`${info.position}Different ids for ${key}. ${info.leftname}: ${aVal.nodeId} vs. ${info.rightname}: ${bVal.nodeId}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuiltInMemory } from './built-in';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IdentifierDefinition } from './identifier';
|
|
3
|
+
import { Identifier } from './identifier';
|
|
3
4
|
import type { ControlDependency } from '../info';
|
|
4
|
-
import type { FlowrConfigOptions } from '../../config';
|
|
5
5
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
6
|
/** A single entry/scope within an {@link REnvironmentInformation} */
|
|
7
7
|
export interface IEnvironment {
|
|
@@ -30,11 +30,22 @@ export declare function isDefaultBuiltInEnvironment(obj: unknown): boolean;
|
|
|
30
30
|
/** @see REnvironmentInformation */
|
|
31
31
|
export declare class Environment implements IEnvironment {
|
|
32
32
|
readonly id: number;
|
|
33
|
+
/** Optional name for namespaced/non-anonymous environments, please only set if you know what you are doing */
|
|
34
|
+
n?: string;
|
|
35
|
+
/** if created by a closure, the node id of that closure */
|
|
36
|
+
private c?;
|
|
33
37
|
parent: Environment;
|
|
34
38
|
memory: BuiltInMemory;
|
|
35
|
-
cache?:
|
|
39
|
+
cache?: Map<Identifier, IdentifierDefinition[]>;
|
|
36
40
|
builtInEnv?: true;
|
|
37
41
|
constructor(parent: Environment, isBuiltInDefault?: true | undefined);
|
|
42
|
+
/** please only use if you know what you are doing */
|
|
43
|
+
setClosureNodeId(nodeId: NodeId): void;
|
|
44
|
+
/**
|
|
45
|
+
* Provides the closure linked to this environment.
|
|
46
|
+
* This is of importance if, for example, if you want to know the function definition associated with this environment.
|
|
47
|
+
*/
|
|
48
|
+
get closure(): NodeId | undefined;
|
|
38
49
|
/**
|
|
39
50
|
* Create a deep clone of this environment.
|
|
40
51
|
* @param recurseParents - Whether to also clone parent environments
|
|
@@ -43,11 +54,11 @@ export declare class Environment implements IEnvironment {
|
|
|
43
54
|
/**
|
|
44
55
|
* Define a new identifier definition within this environment.
|
|
45
56
|
* @param definition - The definition to add.
|
|
46
|
-
* @param config - The flowr configuration options.
|
|
47
57
|
*/
|
|
48
58
|
define(definition: IdentifierDefinition & {
|
|
49
59
|
name: Identifier;
|
|
50
|
-
}
|
|
60
|
+
}): Environment;
|
|
61
|
+
private defineInNamespace;
|
|
51
62
|
defineSuper(definition: IdentifierDefinition & {
|
|
52
63
|
name: Identifier;
|
|
53
64
|
}): Environment;
|
|
@@ -62,7 +73,7 @@ export declare class Environment implements IEnvironment {
|
|
|
62
73
|
* This always recurses parents.
|
|
63
74
|
*/
|
|
64
75
|
append(other: Environment | undefined): Environment;
|
|
65
|
-
remove(
|
|
76
|
+
remove(id: Identifier): this;
|
|
66
77
|
removeAll(names: readonly {
|
|
67
78
|
name: Identifier;
|
|
68
79
|
}[]): Environment;
|
|
@@ -9,10 +9,11 @@ exports.builtInEnvJsonReplacer = builtInEnvJsonReplacer;
|
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
11
|
const json_1 = require("../../util/json");
|
|
12
|
+
const identifier_1 = require("./identifier");
|
|
12
13
|
const assert_1 = require("../../util/assert");
|
|
13
14
|
const info_1 = require("../info");
|
|
14
|
-
const define_1 = require("./define");
|
|
15
15
|
const append_1 = require("./append");
|
|
16
|
+
const log_1 = require("../../util/log");
|
|
16
17
|
/**
|
|
17
18
|
* Please use this function only if you do not know the object type.
|
|
18
19
|
* Otherwise, rely on {@link IEnvironment#builtInEnv}
|
|
@@ -24,6 +25,10 @@ let environmentIdCounter = 1; // Zero is reserved for built-in environment
|
|
|
24
25
|
/** @see REnvironmentInformation */
|
|
25
26
|
class Environment {
|
|
26
27
|
id;
|
|
28
|
+
/** Optional name for namespaced/non-anonymous environments, please only set if you know what you are doing */
|
|
29
|
+
n;
|
|
30
|
+
/** if created by a closure, the node id of that closure */
|
|
31
|
+
c;
|
|
27
32
|
parent;
|
|
28
33
|
memory;
|
|
29
34
|
cache;
|
|
@@ -37,6 +42,17 @@ class Environment {
|
|
|
37
42
|
this.builtInEnv = isBuiltInDefault;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
45
|
+
/** please only use if you know what you are doing */
|
|
46
|
+
setClosureNodeId(nodeId) {
|
|
47
|
+
this.c = nodeId;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Provides the closure linked to this environment.
|
|
51
|
+
* This is of importance if, for example, if you want to know the function definition associated with this environment.
|
|
52
|
+
*/
|
|
53
|
+
get closure() {
|
|
54
|
+
return this.c;
|
|
55
|
+
}
|
|
40
56
|
/**
|
|
41
57
|
* Create a deep clone of this environment.
|
|
42
58
|
* @param recurseParents - Whether to also clone parent environments
|
|
@@ -47,6 +63,8 @@ class Environment {
|
|
|
47
63
|
}
|
|
48
64
|
const parent = recurseParents ? this.parent.clone(recurseParents) : this.parent;
|
|
49
65
|
const clone = new Environment(parent, this.builtInEnv);
|
|
66
|
+
clone.c = this.c;
|
|
67
|
+
clone.n = this.n;
|
|
50
68
|
clone.memory = new Map(this.memory.entries()
|
|
51
69
|
.map(([k, v]) => [k,
|
|
52
70
|
v.map(s => ({
|
|
@@ -59,29 +77,23 @@ class Environment {
|
|
|
59
77
|
/**
|
|
60
78
|
* Define a new identifier definition within this environment.
|
|
61
79
|
* @param definition - The definition to add.
|
|
62
|
-
* @param config - The flowr configuration options.
|
|
63
80
|
*/
|
|
64
|
-
define(definition
|
|
65
|
-
const
|
|
81
|
+
define(definition) {
|
|
82
|
+
const [name, ns] = identifier_1.Identifier.toArray(definition.name);
|
|
83
|
+
if (ns !== undefined && this.n !== ns) {
|
|
84
|
+
return this.defineInNamespace(definition, ns);
|
|
85
|
+
}
|
|
66
86
|
const newEnvironment = this.clone(false);
|
|
67
87
|
// When there are defined indices, merge the definitions
|
|
68
|
-
if (definition.cds === undefined
|
|
88
|
+
if (definition.cds === undefined) {
|
|
69
89
|
newEnvironment.memory.set(name, [definition]);
|
|
70
90
|
}
|
|
71
91
|
else {
|
|
72
92
|
const existing = newEnvironment.memory.get(name);
|
|
73
93
|
const inGraphDefinition = definition;
|
|
74
|
-
if (
|
|
75
|
-
existing !== undefined &&
|
|
94
|
+
if (existing !== undefined &&
|
|
76
95
|
inGraphDefinition.cds === undefined) {
|
|
77
|
-
|
|
78
|
-
const defs = (0, define_1.mergeDefinitionsForPointer)(existing, inGraphDefinition);
|
|
79
|
-
newEnvironment.memory.set(name, defs);
|
|
80
|
-
}
|
|
81
|
-
else if (existing?.flatMap(i => i.indicesCollection ?? []).length > 0) {
|
|
82
|
-
// When indices couldn't be resolved, but indices where defined before, just add the definition
|
|
83
|
-
existing.push(definition);
|
|
84
|
-
}
|
|
96
|
+
newEnvironment.memory.set(name, [inGraphDefinition]);
|
|
85
97
|
}
|
|
86
98
|
else if (existing === undefined || definition.cds === undefined) {
|
|
87
99
|
newEnvironment.memory.set(name, [definition]);
|
|
@@ -92,9 +104,40 @@ class Environment {
|
|
|
92
104
|
}
|
|
93
105
|
return newEnvironment;
|
|
94
106
|
}
|
|
107
|
+
defineInNamespace(definition, ns) {
|
|
108
|
+
if (this.n === ns) {
|
|
109
|
+
return this.define(definition);
|
|
110
|
+
}
|
|
111
|
+
// navigate to parent until either before built-in or matching namespace
|
|
112
|
+
const newEnvironment = this.clone(false);
|
|
113
|
+
const current = newEnvironment;
|
|
114
|
+
do {
|
|
115
|
+
if (current.n === ns) {
|
|
116
|
+
current.define(definition);
|
|
117
|
+
return newEnvironment;
|
|
118
|
+
}
|
|
119
|
+
else if (current.parent && !current.parent.builtInEnv) {
|
|
120
|
+
// clone parent
|
|
121
|
+
current.parent = current.parent.clone(false);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
} while (current.n !== ns);
|
|
127
|
+
// we did not find the namespace, so we inject a new environment here
|
|
128
|
+
log_1.log.warn(`Defining ${identifier_1.Identifier.getName(definition.name)} in namespace ${ns}, which did not exist yet in the environment chain => create (r should fail or we miss attachment).`);
|
|
129
|
+
const env = new Environment(current.parent);
|
|
130
|
+
env.n = ns;
|
|
131
|
+
current.parent = env.define(definition);
|
|
132
|
+
return newEnvironment;
|
|
133
|
+
}
|
|
95
134
|
defineSuper(definition) {
|
|
96
|
-
const
|
|
97
|
-
const newEnvironment = this.clone(
|
|
135
|
+
const [name, ns] = identifier_1.Identifier.toArray(definition.name);
|
|
136
|
+
const newEnvironment = this.clone(false);
|
|
137
|
+
if (ns !== undefined && this.n !== ns) {
|
|
138
|
+
newEnvironment.parent = newEnvironment.parent.defineInNamespace(definition, ns);
|
|
139
|
+
return newEnvironment;
|
|
140
|
+
}
|
|
98
141
|
let current = newEnvironment;
|
|
99
142
|
let last = undefined;
|
|
100
143
|
let found = false;
|
|
@@ -105,6 +148,7 @@ class Environment {
|
|
|
105
148
|
break;
|
|
106
149
|
}
|
|
107
150
|
last = current;
|
|
151
|
+
current.parent = current.parent.clone(false);
|
|
108
152
|
current = current.parent;
|
|
109
153
|
} while (!current.builtInEnv);
|
|
110
154
|
if (!found) {
|
|
@@ -152,6 +196,8 @@ class Environment {
|
|
|
152
196
|
}
|
|
153
197
|
}
|
|
154
198
|
const out = new Environment(this.parent.overwrite(other.parent, applyCds));
|
|
199
|
+
out.c = this.c;
|
|
200
|
+
out.n = this.n;
|
|
155
201
|
out.memory = map;
|
|
156
202
|
return out;
|
|
157
203
|
}
|
|
@@ -177,10 +223,15 @@ class Environment {
|
|
|
177
223
|
out.memory = map;
|
|
178
224
|
return out;
|
|
179
225
|
}
|
|
180
|
-
remove(
|
|
226
|
+
remove(id) {
|
|
181
227
|
if (this.builtInEnv) {
|
|
182
228
|
return this;
|
|
183
229
|
}
|
|
230
|
+
const [name, ns] = identifier_1.Identifier.toArray(id);
|
|
231
|
+
if (ns !== undefined && this.n !== ns) {
|
|
232
|
+
this.parent.remove(id);
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
184
235
|
const definition = this.memory.get(name);
|
|
185
236
|
let cont = true;
|
|
186
237
|
if (definition !== undefined) {
|
|
@@ -1,10 +1,100 @@
|
|
|
1
1
|
import type { BuiltInIdentifierConstant, BuiltInIdentifierDefinition } from './built-in';
|
|
2
2
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { ControlDependency } from '../info';
|
|
4
|
-
|
|
5
|
-
export type
|
|
4
|
+
/** this is just a safe-guard type to prevent mixing up branded identifiers with normal strings */
|
|
5
|
+
export type BrandedIdentifier = string & {
|
|
6
6
|
__brand?: 'identifier';
|
|
7
7
|
};
|
|
8
|
+
/** this is just a safe-guard type to prevent mixing up branded namespaces with normal strings */
|
|
9
|
+
export type BrandedNamespace = string & {
|
|
10
|
+
__brand?: 'namespace';
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Refers to an identifier by its name.
|
|
14
|
+
* This can either be a simple name like `a` or a namespaced name like `pkg::a` (stored as ['a', 'pkg']).
|
|
15
|
+
* By storing the namespace second, you can easily access the actual name via `id[0]`.
|
|
16
|
+
* This represents the fundamental way to represent binding names in R.
|
|
17
|
+
* @see {@link Identifier.getName} - to get the name part
|
|
18
|
+
* @see {@link Identifier.getNamespace} - to get the namespace part
|
|
19
|
+
* @see {@link Identifier.accessesInternal} - to check if the identifier accesses internal objects (`:::`)
|
|
20
|
+
* @see {@link Identifier.toString} - to convert the identifier to a string representation
|
|
21
|
+
*/
|
|
22
|
+
export type Identifier = BrandedIdentifier | [id: BrandedIdentifier, namespace: BrandedNamespace, internal?: boolean];
|
|
23
|
+
/**
|
|
24
|
+
* Helper functions to work with {@link Identifier|identifiers}.
|
|
25
|
+
* Use {@link Identifier.matches} to check if two identifiers match according to R's scoping rules!
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const id1 = Identifier.make('a', 'pkg');
|
|
29
|
+
* const id2 = Identifier.parse('pkg::a');
|
|
30
|
+
* const id3 = Identifier.parse('a');
|
|
31
|
+
* Identifier.matches(id1, id2); // true
|
|
32
|
+
* Identifier.matches(id3, id2); // true, as id3 has no namespace
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const Identifier: {
|
|
36
|
+
/**
|
|
37
|
+
* Create an identifier from its name and optional namespace.
|
|
38
|
+
* Please note that for `internal` to count, a namespace must be provided!
|
|
39
|
+
*/
|
|
40
|
+
readonly make: (this: void, name: BrandedIdentifier, namespace?: BrandedNamespace, internal?: boolean) => Identifier;
|
|
41
|
+
/**
|
|
42
|
+
* Parse an identifier from its string representation,
|
|
43
|
+
* Please note, that in R if one writes `"pkg::a"` this refers to a symbol named `pkg::a` and NOT to the namespaced identifier `a` in package `pkg`.
|
|
44
|
+
* In this scenario, see {@link Identifier.make} instead.
|
|
45
|
+
*/
|
|
46
|
+
readonly parse: (this: void, str: string) => Identifier;
|
|
47
|
+
/**
|
|
48
|
+
* Get the name part of the identifier
|
|
49
|
+
*/
|
|
50
|
+
readonly getName: (this: void, id: Identifier) => BrandedIdentifier;
|
|
51
|
+
/**
|
|
52
|
+
* Get the namespace part of the identifier, undefined if there is none
|
|
53
|
+
*/
|
|
54
|
+
readonly getNamespace: (this: void, id: Identifier) => BrandedNamespace | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Check if the identifier accesses internal objects (`:::`)
|
|
57
|
+
*/
|
|
58
|
+
readonly accessesInternal: (this: void, id: Identifier) => boolean | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Convert the identifier to a **valid R** string representation,
|
|
61
|
+
* this will properly quote namespaces that contain `::` to avoid confusion.
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* Identifier.toString('a') // 'a'
|
|
65
|
+
* Identifier.toString(['a', 'pkg']) // 'pkg::a'
|
|
66
|
+
* Identifier.toString(['a', 'pkg:::internal', true]) // '"pkg:::internal":::a'
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
readonly toString: (this: void, id: Identifier) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Check if two identifiers match.
|
|
72
|
+
* This differs from eq!
|
|
73
|
+
* If the first identifier is not namespaced, it will match any namespace!
|
|
74
|
+
* If we search for S3 methods (s3=true), the target may have an additional suffix after a dot.
|
|
75
|
+
* If the first identifier is internal, it will match any target (internal or not).
|
|
76
|
+
*/
|
|
77
|
+
readonly matches: (this: void, id: Identifier, target: Identifier, s3?: boolean) => boolean;
|
|
78
|
+
/** Special identifier for the `...` argument */
|
|
79
|
+
readonly dotdotdot: (this: void) => BrandedIdentifier;
|
|
80
|
+
/**
|
|
81
|
+
* Check if the identifier is the special `...` argument / or one of its accesses like `..1`, `..2`, etc.
|
|
82
|
+
* This always returns false for namespaced identifiers.
|
|
83
|
+
*/
|
|
84
|
+
readonly isDotDotDotAccess: (this: void, id: Identifier) => boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Functor over the name of the identifier
|
|
87
|
+
*/
|
|
88
|
+
readonly mapName: (this: void, id: Identifier, fn: (name: BrandedIdentifier) => BrandedIdentifier) => Identifier;
|
|
89
|
+
/**
|
|
90
|
+
* Functor over the namespace of the identifier
|
|
91
|
+
*/
|
|
92
|
+
readonly mapNamespace: (this: void, id: Identifier, fn: (ns: BrandedNamespace) => BrandedNamespace) => Identifier;
|
|
93
|
+
/**
|
|
94
|
+
* Convert the identifier to its array representation
|
|
95
|
+
*/
|
|
96
|
+
readonly toArray: (this: void, id: Identifier) => [BrandedIdentifier, BrandedNamespace | undefined, boolean | undefined];
|
|
97
|
+
};
|
|
8
98
|
/**
|
|
9
99
|
* Each reference has exactly one reference type, stored as the respective number.
|
|
10
100
|
* However, when checking, we may want to allow for one of several types,
|
|
@@ -35,7 +125,9 @@ export declare enum ReferenceType {
|
|
|
35
125
|
/** The identifier is defined by a built-in function */
|
|
36
126
|
BuiltInFunction = 128,
|
|
37
127
|
/** Prefix to identify S3 methods, use this, to for example dispatch a call to `f` which will then link to `f.*` */
|
|
38
|
-
S3MethodPrefix = 256
|
|
128
|
+
S3MethodPrefix = 256,
|
|
129
|
+
/** Prefix to identify S7 methods, use this, to for example dispatch a call to `f` which will then link to `f<7>*` */
|
|
130
|
+
S7MethodPrefix = 512
|
|
39
131
|
}
|
|
40
132
|
/** Reverse mapping of the reference types so you can get the name from the bitmask (useful for debugging) */
|
|
41
133
|
export declare const ReferenceTypeReverseMapping: Map<ReferenceType, string>;
|
|
@@ -101,10 +193,6 @@ export interface InGraphIdentifierDefinition extends IdentifierReference {
|
|
|
101
193
|
* For example, in `x <- 3; y <- x`, the definition of `y` will have the value `3` in its value set
|
|
102
194
|
*/
|
|
103
195
|
readonly value?: NodeId[];
|
|
104
|
-
/**
|
|
105
|
-
* this attribute links a definition to indices (pointer links) it may be affected by or related to
|
|
106
|
-
*/
|
|
107
|
-
indicesCollection?: ContainerIndicesCollection;
|
|
108
196
|
}
|
|
109
197
|
/**
|
|
110
198
|
* Stores the definition of an identifier within an {@link IEnvironment}.
|