@eagleoutice/flowr 1.5.2 → 2.0.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/abstract-interpretation/handler/binop/binop.d.ts +3 -4
- package/abstract-interpretation/handler/binop/binop.js +4 -2
- package/abstract-interpretation/handler/binop/operators.d.ts +2 -2
- package/abstract-interpretation/handler/binop/operators.js +14 -28
- package/abstract-interpretation/processor.d.ts +3 -2
- package/abstract-interpretation/processor.js +2 -2
- package/benchmark/slicer.d.ts +101 -0
- package/benchmark/slicer.js +214 -0
- package/benchmark/stats/print.d.ts +7 -0
- package/benchmark/stats/print.js +151 -0
- package/benchmark/stats/stats.d.ts +42 -0
- package/benchmark/stats/stats.js +6 -0
- package/benchmark/stopwatch.d.ts +35 -0
- package/benchmark/stopwatch.js +79 -0
- package/benchmark/summarizer/data.d.ts +54 -0
- package/benchmark/summarizer/first-phase/input.d.ts +3 -0
- package/benchmark/summarizer/first-phase/input.js +76 -0
- package/benchmark/summarizer/first-phase/process.d.ts +11 -0
- package/benchmark/summarizer/first-phase/process.js +205 -0
- package/benchmark/summarizer/second-phase/graph.d.ts +2 -0
- package/benchmark/summarizer/second-phase/graph.js +54 -0
- package/benchmark/summarizer/second-phase/process.d.ts +6 -0
- package/benchmark/summarizer/second-phase/process.js +127 -0
- package/benchmark/summarizer/summarizer.d.ts +31 -0
- package/benchmark/summarizer/summarizer.js +58 -0
- package/cli/benchmark-app.d.ts +10 -0
- package/cli/benchmark-app.js +67 -0
- package/cli/benchmark-helper-app.d.ts +9 -0
- package/cli/benchmark-helper-app.js +69 -0
- package/cli/common/features.d.ts +3 -0
- package/cli/common/features.js +30 -0
- package/cli/common/options.d.ts +20 -0
- package/cli/common/options.js +85 -0
- package/cli/common/script.d.ts +21 -0
- package/cli/common/script.js +61 -0
- package/cli/common/scripts-info.d.ts +25 -0
- package/cli/common/scripts-info.js +83 -0
- package/cli/export-quads-app.d.ts +7 -0
- package/cli/export-quads-app.js +43 -0
- package/cli/flowr.d.ts +29 -0
- package/cli/flowr.js +141 -0
- package/cli/repl/commands/cfg.d.ts +3 -0
- package/cli/repl/commands/cfg.js +37 -0
- package/cli/repl/commands/commands.d.ts +13 -0
- package/cli/repl/commands/commands.js +142 -0
- package/cli/repl/commands/dataflow.d.ts +3 -0
- package/cli/repl/commands/dataflow.js +34 -0
- package/cli/repl/commands/execute.d.ts +4 -0
- package/cli/repl/commands/execute.js +27 -0
- package/cli/repl/commands/main.d.ts +39 -0
- package/cli/repl/commands/main.js +14 -0
- package/cli/repl/commands/normalize.d.ts +3 -0
- package/cli/repl/commands/normalize.js +34 -0
- package/cli/repl/commands/parse.d.ts +2 -0
- package/cli/repl/commands/parse.js +110 -0
- package/cli/repl/commands/quit.d.ts +2 -0
- package/cli/repl/commands/quit.js +15 -0
- package/cli/repl/commands/version.d.ts +16 -0
- package/cli/repl/commands/version.js +28 -0
- package/cli/repl/core.d.ts +36 -0
- package/cli/repl/core.js +174 -0
- package/cli/repl/execute.d.ts +28 -0
- package/cli/repl/execute.js +79 -0
- package/cli/repl/print-version.d.ts +2 -0
- package/cli/repl/print-version.js +10 -0
- package/cli/repl/prompt.d.ts +2 -0
- package/cli/repl/prompt.js +9 -0
- package/cli/repl/server/connection.d.ts +21 -0
- package/cli/repl/server/connection.js +218 -0
- package/cli/repl/server/messages/analysis.d.ts +72 -0
- package/cli/repl/server/messages/analysis.js +21 -0
- package/cli/repl/server/messages/error.d.ts +11 -0
- package/{core/input.js → cli/repl/server/messages/error.js} +1 -1
- package/cli/repl/server/messages/hello.d.ts +20 -0
- package/{core/output.js → cli/repl/server/messages/hello.js} +1 -1
- package/cli/repl/server/messages/messages.d.ts +35 -0
- package/cli/repl/server/messages/messages.js +40 -0
- package/cli/repl/server/messages/repl.d.ts +33 -0
- package/cli/repl/server/messages/repl.js +37 -0
- package/cli/repl/server/messages/slice.d.ts +26 -0
- package/cli/repl/server/messages/slice.js +37 -0
- package/cli/repl/server/net.d.ts +49 -0
- package/cli/repl/server/net.js +63 -0
- package/cli/repl/server/send.d.ts +4 -0
- package/cli/repl/server/send.js +18 -0
- package/cli/repl/server/server.d.ts +20 -0
- package/cli/repl/server/server.js +66 -0
- package/cli/repl/server/validate.d.ts +15 -0
- package/cli/repl/server/validate.js +34 -0
- package/cli/slicer-app.d.ts +11 -0
- package/cli/slicer-app.js +83 -0
- package/cli/statistics-app.d.ts +11 -0
- package/cli/statistics-app.js +99 -0
- package/cli/statistics-helper-app.d.ts +11 -0
- package/cli/statistics-helper-app.js +87 -0
- package/cli/summarizer-app.d.ts +18 -0
- package/cli/summarizer-app.js +66 -0
- package/core/pipeline-executor.d.ts +154 -0
- package/core/pipeline-executor.js +221 -0
- package/core/print/dataflow-printer.d.ts +3 -4
- package/core/print/dataflow-printer.js +5 -5
- package/core/print/normalize-printer.d.ts +1 -1
- package/core/print/normalize-printer.js +3 -3
- package/core/print/parse-printer.js +3 -3
- package/core/print/print.d.ts +13 -4
- package/core/print/print.js +13 -2
- package/core/print/slice-diff-ansi.d.ts +3 -2
- package/core/print/slice-diff-ansi.js +4 -4
- package/core/steps/all/core/00-parse.d.ts +28 -0
- package/core/steps/all/core/00-parse.js +24 -0
- package/core/steps/all/core/10-normalize.d.ts +29 -0
- package/core/steps/all/core/10-normalize.js +26 -0
- package/core/steps/all/core/20-dataflow.d.ts +27 -0
- package/core/steps/all/core/20-dataflow.js +29 -0
- package/core/steps/all/static-slicing/00-slice.d.ts +28 -0
- package/core/steps/all/static-slicing/00-slice.js +21 -0
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +25 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +21 -0
- package/core/steps/pipeline/create-pipeline.d.ts +6 -0
- package/core/steps/pipeline/create-pipeline.js +130 -0
- package/core/steps/pipeline/default-pipelines.d.ts +251 -0
- package/core/steps/pipeline/default-pipelines.js +18 -0
- package/core/steps/pipeline/invalid-pipeline-error.d.ts +6 -0
- package/core/steps/pipeline/invalid-pipeline-error.js +14 -0
- package/core/steps/pipeline/pipeline.d.ts +60 -0
- package/core/steps/pipeline/pipeline.js +28 -0
- package/core/steps/pipeline-step.d.ts +85 -0
- package/core/steps/pipeline-step.js +8 -0
- package/dataflow/environments/append.d.ts +4 -4
- package/dataflow/environments/append.js +4 -4
- package/dataflow/environments/built-in.d.ts +25 -0
- package/dataflow/environments/built-in.js +123 -0
- package/dataflow/environments/clone.d.ts +2 -0
- package/dataflow/environments/clone.js +23 -0
- package/dataflow/environments/{register.d.ts → define.d.ts} +3 -3
- package/dataflow/environments/define.js +51 -0
- package/dataflow/environments/diff.d.ts +6 -0
- package/dataflow/environments/diff.js +85 -0
- package/dataflow/environments/environment.d.ts +10 -43
- package/dataflow/environments/environment.js +32 -138
- package/dataflow/environments/identifier.d.ts +31 -0
- package/dataflow/environments/identifier.js +3 -0
- package/dataflow/environments/overwrite.d.ts +4 -4
- package/dataflow/environments/overwrite.js +9 -22
- package/dataflow/environments/resolve-by-name.d.ts +7 -6
- package/dataflow/environments/resolve-by-name.js +35 -19
- package/dataflow/environments/scoping.js +1 -4
- package/dataflow/extractor.d.ts +6 -6
- package/dataflow/extractor.js +47 -57
- package/dataflow/graph/diff.d.ts +24 -7
- package/dataflow/graph/diff.js +114 -74
- package/dataflow/graph/edge.d.ts +66 -20
- package/dataflow/graph/edge.js +73 -27
- package/dataflow/graph/graph.d.ts +53 -29
- package/dataflow/graph/graph.js +84 -89
- package/dataflow/graph/quads.js +2 -2
- package/dataflow/graph/vertex.d.ts +37 -34
- package/dataflow/info.d.ts +49 -0
- package/dataflow/info.js +29 -0
- package/dataflow/internal/linker.d.ts +11 -10
- package/dataflow/internal/linker.js +64 -90
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +6 -0
- package/dataflow/internal/process/functions/call/argument/make-argument.js +31 -0
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +3 -0
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +18 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +82 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +29 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +167 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +165 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +97 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +165 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +36 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +100 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +32 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-logical-bin-op.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-logical-bin-op.js +35 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +35 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +29 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +32 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +12 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +45 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +72 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +61 -0
- package/dataflow/internal/process/functions/call/common.d.ts +35 -0
- package/dataflow/internal/process/functions/call/common.js +70 -0
- package/dataflow/internal/process/functions/call/default-call-handling.d.ts +5 -0
- package/dataflow/internal/process/functions/call/default-call-handling.js +15 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +26 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +62 -0
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +7 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +53 -0
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +6 -0
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +58 -0
- package/dataflow/internal/process/functions/process-argument.d.ts +9 -0
- package/dataflow/internal/process/functions/{argument.js → process-argument.js} +25 -20
- package/dataflow/internal/process/functions/{parameter.d.ts → process-parameter.d.ts} +3 -2
- package/dataflow/internal/process/functions/{parameter.js → process-parameter.js} +10 -13
- package/dataflow/internal/process/process-named-call.d.ts +6 -0
- package/dataflow/internal/process/process-named-call.js +17 -0
- package/dataflow/internal/process/process-symbol.d.ts +5 -0
- package/dataflow/internal/process/process-symbol.js +26 -0
- package/dataflow/internal/process/process-uninteresting-leaf.d.ts +4 -0
- package/dataflow/internal/process/process-uninteresting-leaf.js +9 -0
- package/dataflow/internal/process/process-value.d.ts +4 -0
- package/dataflow/internal/process/process-value.js +22 -0
- package/dataflow/logger.d.ts +1 -0
- package/dataflow/logger.js +6 -0
- package/dataflow/processor.d.ts +18 -13
- package/dataflow/processor.js +1 -1
- package/package.json +48 -85
- package/r-bridge/data/data.d.ts +603 -0
- package/r-bridge/data/data.js +753 -0
- package/r-bridge/data/get.d.ts +19 -0
- package/r-bridge/data/get.js +51 -0
- package/r-bridge/data/print.d.ts +1 -0
- package/r-bridge/data/print.js +58 -0
- package/r-bridge/data/types.d.ts +33 -0
- package/r-bridge/data/types.js +3 -0
- package/r-bridge/init.d.ts +3 -0
- package/r-bridge/init.js +22 -0
- package/r-bridge/lang-4.x/ast/model/collect.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/collect.js +2 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +26 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +4 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +0 -17
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +0 -11
- package/r-bridge/lang-4.x/ast/model/operators.d.ts +6 -18
- package/r-bridge/lang-4.x/ast/model/operators.js +36 -48
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +19 -15
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +59 -54
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +18 -0
- package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +28 -17
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +7 -34
- package/r-bridge/lang-4.x/ast/model/processing/visitor.js +5 -2
- package/r-bridge/lang-4.x/ast/model/type.js +13 -6
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +4 -1
- package/r-bridge/lang-4.x/ast/parser/json/format.js +9 -2
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +5 -5
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +22 -27
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +10 -7
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +19 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/{if-then-else.d.ts → normalize-if-then-else.d.ts} +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/{if-then-else.js → normalize-if-then-else.js} +10 -13
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/{if-then.d.ts → normalize-if-then.d.ts} +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/{if-then.js → normalize-if-then.js} +9 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/normalize-expression.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/normalize-expression.js +64 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{argument.d.ts → normalize-argument.d.ts} +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{argument.js → normalize-argument.js} +13 -17
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{call.d.ts → normalize-call.d.ts} +6 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{call.js → normalize-call.js} +24 -29
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/normalize-definition.d.ts +12 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{definition.js → normalize-definition.js} +14 -19
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{parameter.d.ts → normalize-parameter.d.ts} +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/{parameter.js → normalize-parameter.js} +12 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-break.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/{break.js → normalize-break.js} +6 -8
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-for.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/{for.js → normalize-for.js} +18 -20
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-next.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/{next.js → normalize-next.js} +6 -8
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-repeat.d.ts +13 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/{repeat.js → normalize-repeat.js} +13 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-while.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/{while.js → normalize-while.js} +10 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/{access.d.ts → normalize-access.d.ts} +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/{access.js → normalize-access.js} +44 -45
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/{binary.d.ts → normalize-binary.d.ts} +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/{binary.js → normalize-binary.js} +23 -73
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/normalize-unary.d.ts +13 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/normalize-unary.js +47 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/normalize-comment.d.ts +11 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/{comment.js → normalize-comment.js} +5 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/normalize-line-directive.d.ts +13 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/{line-directive.js → normalize-line-directive.js} +7 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-delimiter.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-delimiter.js +15 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-expressions.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-expressions.js +182 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-root.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-root.js +34 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-single-node.d.ts +13 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-single-node.js +59 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/normalize-number.d.ts +16 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/{number.js → normalize-number.js} +12 -18
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/normalize-string.d.ts +11 -0
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/{string.js → normalize-string.js} +7 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/{symbol.d.ts → normalize-symbol.d.ts} +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/{symbol.js → normalize-symbol.js} +12 -15
- package/r-bridge/lang-4.x/ast/parser/xml/{internal/meta.d.ts → normalize-meta.d.ts} +5 -3
- package/r-bridge/lang-4.x/ast/parser/xml/{internal/meta.js → normalize-meta.js} +8 -8
- package/r-bridge/lang-4.x/ast/parser/xml/{data.d.ts → normalizer-data.d.ts} +1 -5
- package/r-bridge/lang-4.x/ast/parser/xml/normalizer-data.js +3 -0
- package/r-bridge/lang-4.x/{values.d.ts → convert-values.d.ts} +2 -2
- package/r-bridge/lang-4.x/{values.js → convert-values.js} +5 -5
- package/r-bridge/retriever.d.ts +5 -5
- package/r-bridge/retriever.js +11 -24
- package/r-bridge/shell-executor.d.ts +0 -1
- package/r-bridge/shell-executor.js +7 -12
- package/r-bridge/shell.d.ts +14 -12
- package/r-bridge/shell.js +50 -45
- package/reconstruct/reconstruct.d.ts +4 -2
- package/reconstruct/reconstruct.js +193 -185
- package/slicing/criterion/collect-all.d.ts +4 -3
- package/slicing/criterion/collect-all.js +5 -1
- package/slicing/criterion/filters/all-variables.js +14 -22
- package/slicing/criterion/parse.d.ts +4 -2
- package/slicing/criterion/parse.js +13 -11
- package/slicing/static/fingerprint.d.ts +5 -0
- package/slicing/static/fingerprint.js +17 -0
- package/slicing/static/slice-call.d.ts +10 -0
- package/slicing/static/slice-call.js +86 -0
- package/slicing/static/slicer-types.d.ts +33 -0
- package/slicing/static/slicer-types.js +3 -0
- package/slicing/static/static-slicer.d.ts +6 -24
- package/slicing/static/static-slicer.js +54 -155
- package/slicing/static/visiting-queue.d.ts +23 -0
- package/slicing/static/visiting-queue.js +53 -0
- package/statistics/features/common-syntax-probability.d.ts +29 -0
- package/statistics/features/common-syntax-probability.js +159 -0
- package/statistics/features/feature.d.ts +182 -0
- package/statistics/features/feature.js +39 -0
- package/statistics/features/post-processing.d.ts +12 -0
- package/statistics/features/post-processing.js +21 -0
- package/statistics/features/supported/assignments/assignments.d.ts +12 -0
- package/statistics/features/supported/assignments/assignments.js +55 -0
- package/statistics/features/supported/assignments/post-process.d.ts +3 -0
- package/statistics/features/supported/assignments/post-process.js +124 -0
- package/statistics/features/supported/comments/comments.d.ts +18 -0
- package/statistics/features/supported/comments/comments.js +133 -0
- package/statistics/features/supported/comments/post-process.d.ts +3 -0
- package/statistics/features/supported/comments/post-process.js +49 -0
- package/statistics/features/supported/control-flow/control-flow.d.ts +17 -0
- package/statistics/features/supported/control-flow/control-flow.js +68 -0
- package/statistics/features/supported/control-flow/post-process.d.ts +3 -0
- package/statistics/features/supported/control-flow/post-process.js +64 -0
- package/statistics/features/supported/data-access/data-access.d.ts +15 -0
- package/statistics/features/supported/data-access/data-access.js +120 -0
- package/statistics/features/supported/data-access/post-process.d.ts +3 -0
- package/statistics/features/supported/data-access/post-process.js +106 -0
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +34 -0
- package/statistics/features/supported/defined-functions/defined-functions.js +142 -0
- package/statistics/features/supported/defined-functions/post-process.d.ts +6 -0
- package/statistics/features/supported/defined-functions/post-process.js +169 -0
- package/statistics/features/supported/expression-list/expression-list.d.ts +9 -0
- package/statistics/features/supported/expression-list/expression-list.js +36 -0
- package/statistics/features/supported/expression-list/post-process.d.ts +3 -0
- package/statistics/features/supported/expression-list/post-process.js +43 -0
- package/statistics/features/supported/loops/loops.d.ts +20 -0
- package/statistics/features/supported/loops/loops.js +79 -0
- package/statistics/features/supported/loops/post-process.d.ts +3 -0
- package/statistics/features/supported/loops/post-process.js +71 -0
- package/statistics/features/supported/used-functions/post-process.d.ts +6 -0
- package/statistics/features/supported/used-functions/post-process.js +178 -0
- package/statistics/features/supported/used-functions/used-functions.d.ts +24 -0
- package/statistics/features/supported/used-functions/used-functions.js +97 -0
- package/statistics/features/supported/used-packages/post-process.d.ts +3 -0
- package/statistics/features/supported/used-packages/post-process.js +120 -0
- package/statistics/features/supported/used-packages/used-packages.d.ts +16 -0
- package/statistics/features/supported/used-packages/used-packages.js +130 -0
- package/statistics/features/supported/values/post-process.d.ts +3 -0
- package/statistics/features/supported/values/post-process.js +71 -0
- package/statistics/features/supported/values/values.d.ts +14 -0
- package/statistics/features/supported/values/values.js +101 -0
- package/statistics/features/supported/variables/post-process.d.ts +9 -0
- package/statistics/features/supported/variables/post-process.js +121 -0
- package/statistics/features/supported/variables/variables.d.ts +15 -0
- package/statistics/features/supported/variables/variables.js +60 -0
- package/statistics/meta-statistics.d.ts +33 -0
- package/statistics/meta-statistics.js +17 -0
- package/statistics/output/file-provider.d.ts +37 -0
- package/statistics/output/file-provider.js +97 -0
- package/statistics/output/print-stats.d.ts +17 -0
- package/statistics/output/print-stats.js +69 -0
- package/statistics/output/statistics-file.d.ts +37 -0
- package/statistics/output/statistics-file.js +69 -0
- package/statistics/statistics.d.ts +28 -0
- package/statistics/statistics.js +108 -0
- package/statistics/summarizer/auto-detect.d.ts +2 -0
- package/statistics/summarizer/auto-detect.js +32 -0
- package/statistics/summarizer/first-phase/process.d.ts +6 -0
- package/statistics/summarizer/first-phase/process.js +81 -0
- package/statistics/summarizer/post-process/clusterer.d.ts +26 -0
- package/statistics/summarizer/post-process/clusterer.js +43 -0
- package/statistics/summarizer/post-process/file-based-count.d.ts +17 -0
- package/statistics/summarizer/post-process/file-based-count.js +49 -0
- package/statistics/summarizer/post-process/histogram.d.ts +59 -0
- package/statistics/summarizer/post-process/histogram.js +128 -0
- package/statistics/summarizer/post-process/post-process-output.d.ts +16 -0
- package/statistics/summarizer/post-process/post-process-output.js +105 -0
- package/statistics/summarizer/second-phase/process.d.ts +11 -0
- package/statistics/summarizer/second-phase/process.js +116 -0
- package/statistics/summarizer/summarizer.d.ts +35 -0
- package/statistics/summarizer/summarizer.js +135 -0
- package/util/ansi.d.ts +2 -2
- package/util/ansi.js +2 -2
- package/util/arrays.d.ts +11 -1
- package/util/arrays.js +34 -1
- package/util/assert.d.ts +1 -0
- package/util/assert.js +5 -1
- package/util/cfg/cfg.d.ts +3 -2
- package/util/cfg/cfg.js +17 -28
- package/util/cfg/visitor.d.ts +1 -1
- package/util/defaultmap.d.ts +1 -1
- package/util/defaultmap.js +1 -1
- package/util/diff.d.ts +4 -4
- package/util/files.d.ts +2 -2
- package/util/files.js +1 -1
- package/util/log.d.ts +1 -0
- package/util/log.js +7 -1
- package/util/logic.d.ts +1 -0
- package/util/logic.js +3 -0
- package/util/mermaid/ast.d.ts +1 -1
- package/util/mermaid/ast.js +2 -2
- package/util/mermaid/cfg.d.ts +1 -1
- package/util/mermaid/dfg.d.ts +34 -8
- package/util/mermaid/dfg.js +99 -70
- package/util/mermaid/mermaid.d.ts +1 -1
- package/util/mermaid/mermaid.js +6 -7
- package/util/objects.js +4 -0
- package/util/quads.d.ts +3 -3
- package/util/quads.js +0 -1
- package/util/range.d.ts +27 -14
- package/util/range.js +31 -27
- package/util/version.js +1 -1
- package/core/index.d.ts +0 -4
- package/core/index.js +0 -23
- package/core/input.d.ts +0 -42
- package/core/output.d.ts +0 -15
- package/core/slicer.d.ts +0 -124
- package/core/slicer.js +0 -227
- package/core/steps.d.ts +0 -508
- package/core/steps.js +0 -100
- package/dataflow/environments/index.d.ts +0 -7
- package/dataflow/environments/index.js +0 -23
- package/dataflow/environments/register.js +0 -40
- package/dataflow/environments/scopes.d.ts +0 -6
- package/dataflow/environments/scopes.js +0 -6
- package/dataflow/graph/index.d.ts +0 -4
- package/dataflow/graph/index.js +0 -21
- package/dataflow/index.d.ts +0 -5
- package/dataflow/index.js +0 -24
- package/dataflow/internal/info.d.ts +0 -21
- package/dataflow/internal/info.js +0 -16
- package/dataflow/internal/process/access.d.ts +0 -4
- package/dataflow/internal/process/access.js +0 -53
- package/dataflow/internal/process/expression-list.d.ts +0 -8
- package/dataflow/internal/process/expression-list.js +0 -144
- package/dataflow/internal/process/functions/argument.d.ts +0 -8
- package/dataflow/internal/process/functions/exit-points.d.ts +0 -2
- package/dataflow/internal/process/functions/exit-points.js +0 -121
- package/dataflow/internal/process/functions/function-call.d.ts +0 -5
- package/dataflow/internal/process/functions/function-call.js +0 -105
- package/dataflow/internal/process/functions/function-definition.d.ts +0 -4
- package/dataflow/internal/process/functions/function-definition.js +0 -176
- package/dataflow/internal/process/functions/source.d.ts +0 -8
- package/dataflow/internal/process/functions/source.js +0 -81
- package/dataflow/internal/process/if-then-else.d.ts +0 -4
- package/dataflow/internal/process/if-then-else.js +0 -56
- package/dataflow/internal/process/loops/for-loop.d.ts +0 -4
- package/dataflow/internal/process/loops/for-loop.js +0 -54
- package/dataflow/internal/process/loops/repeat-loop.d.ts +0 -4
- package/dataflow/internal/process/loops/repeat-loop.js +0 -21
- package/dataflow/internal/process/loops/while-loop.d.ts +0 -4
- package/dataflow/internal/process/loops/while-loop.js +0 -31
- package/dataflow/internal/process/operators/assignment.d.ts +0 -4
- package/dataflow/internal/process/operators/assignment.js +0 -129
- package/dataflow/internal/process/operators/non-assignment-binary-op.d.ts +0 -4
- package/dataflow/internal/process/operators/non-assignment-binary-op.js +0 -25
- package/dataflow/internal/process/operators/pipe.d.ts +0 -4
- package/dataflow/internal/process/operators/pipe.js +0 -46
- package/dataflow/internal/process/operators/unary-op.d.ts +0 -4
- package/dataflow/internal/process/operators/unary-op.js +0 -10
- package/dataflow/internal/process/symbol.d.ts +0 -4
- package/dataflow/internal/process/symbol.js +0 -21
- package/dataflow/internal/process/uninteresting-leaf.d.ts +0 -3
- package/dataflow/internal/process/uninteresting-leaf.js +0 -9
- package/index.d.ts +0 -4
- package/index.js +0 -21
- package/r-bridge/index.d.ts +0 -11
- package/r-bridge/index.js +0 -28
- package/r-bridge/lang-4.x/ast/index.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/index.js +0 -22
- package/r-bridge/lang-4.x/ast/model/index.d.ts +0 -6
- package/r-bridge/lang-4.x/ast/model/index.js +0 -23
- package/r-bridge/lang-4.x/ast/model/nodes/index.d.ts +0 -21
- package/r-bridge/lang-4.x/ast/model/nodes/index.js +0 -38
- package/r-bridge/lang-4.x/ast/model/nodes/info/index.d.ts +0 -13
- package/r-bridge/lang-4.x/ast/model/nodes/info/index.js +0 -27
- package/r-bridge/lang-4.x/ast/model/processing/index.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/model/processing/index.js +0 -22
- package/r-bridge/lang-4.x/ast/parser/xml/hooks.d.ts +0 -292
- package/r-bridge/lang-4.x/ast/parser/xml/hooks.js +0 -136
- package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -20
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/index.js +0 -19
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.d.ts +0 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +0 -65
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/index.js +0 -18
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.d.ts +0 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/index.js +0 -20
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -26
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.d.ts +0 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.d.ts +0 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/index.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/index.js +0 -22
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.d.ts +0 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.d.ts +0 -13
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.d.ts +0 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/index.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/index.js +0 -20
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/special.d.ts +0 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/special.js +0 -24
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.d.ts +0 -13
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +0 -59
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.d.ts +0 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/index.js +0 -18
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.d.ts +0 -12
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.d.ts +0 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +0 -159
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/index.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/index.js +0 -20
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.d.ts +0 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +0 -33
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.d.ts +0 -13
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +0 -64
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/index.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/index.js +0 -20
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.d.ts +0 -13
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.d.ts +0 -11
- package/r-bridge/lang-4.x/index.d.ts +0 -2
- package/r-bridge/lang-4.x/index.js +0 -19
- package/slicing/criterion/filters/index.d.ts +0 -1
- package/slicing/criterion/filters/index.js +0 -18
- package/slicing/criterion/index.d.ts +0 -3
- package/slicing/criterion/index.js +0 -20
- package/slicing/index.d.ts +0 -3
- package/slicing/index.js +0 -20
- package/slicing/static/index.d.ts +0 -1
- package/slicing/static/index.js +0 -18
- package/util/mermaid/index.d.ts +0 -3
- package/util/mermaid/index.js +0 -20
- /package/{r-bridge/lang-4.x/ast/parser/xml → benchmark/summarizer}/data.js +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processAssignment = void 0;
|
|
4
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
5
|
+
const assert_1 = require("../../../../../../util/assert");
|
|
6
|
+
const log_1 = require("../../../../../../util/log");
|
|
7
|
+
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
8
|
+
const process_named_call_1 = require("../../../process-named-call");
|
|
9
|
+
const make_argument_1 = require("../argument/make-argument");
|
|
10
|
+
const logger_1 = require("../../../../../logger");
|
|
11
|
+
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
12
|
+
const retriever_1 = require("../../../../../../r-bridge/retriever");
|
|
13
|
+
const define_1 = require("../../../../../environments/define");
|
|
14
|
+
function toReplacementSymbol(target, prefix, superAssignment) {
|
|
15
|
+
return {
|
|
16
|
+
type: "RSymbol" /* RType.Symbol */,
|
|
17
|
+
info: target.info,
|
|
18
|
+
/* they are all mapped to <- in R, but we mark super as well */
|
|
19
|
+
content: `${prefix}${superAssignment ? '<<-' : '<-'}`,
|
|
20
|
+
lexeme: target.lexeme,
|
|
21
|
+
location: target.location,
|
|
22
|
+
namespace: undefined
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getEffectiveOrder(config, args) {
|
|
26
|
+
return config.swapSourceAndTarget ? [args[1], args[0]] : args;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Processes an assignment, i.e., `<target> <- <source>`.
|
|
30
|
+
* Handling it as a function call \`<-\` `(<target>, <source>)`.
|
|
31
|
+
* This includes handling of replacement functions (e.g., `names(x) <- ...` as \`names<-\` `(x, ...)`).
|
|
32
|
+
*/
|
|
33
|
+
function processAssignment(name,
|
|
34
|
+
/* we expect them to be ordered in the sense that we have (source, target): `<source> <- <target>` */
|
|
35
|
+
args, rootId, data, config) {
|
|
36
|
+
if (args.length != 2) {
|
|
37
|
+
logger_1.dataflowLogger.warn(`Assignment ${name.content} has something else than 2 arguments, skipping`);
|
|
38
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
39
|
+
}
|
|
40
|
+
const effectiveArgs = getEffectiveOrder(config, args);
|
|
41
|
+
const { target, source } = extractSourceAndTarget(effectiveArgs, name);
|
|
42
|
+
const { type, flavor } = target;
|
|
43
|
+
if (type === "RSymbol" /* RType.Symbol */) {
|
|
44
|
+
const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, reverseOrder: !config.swapSourceAndTarget });
|
|
45
|
+
return processAssignmentToSymbol({
|
|
46
|
+
...config,
|
|
47
|
+
name,
|
|
48
|
+
source,
|
|
49
|
+
target,
|
|
50
|
+
args: getEffectiveOrder(config, res.processedArguments),
|
|
51
|
+
rootId,
|
|
52
|
+
data,
|
|
53
|
+
information: res.information,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (config.canBeReplacement && type === "RFunctionCall" /* RType.FunctionCall */ && flavor === 'named') {
|
|
57
|
+
/* as replacement functions take precedence over the lhs fn-call (i.e., `names(x) <- ...` is independent from the definition of `names`), we do not have to process the call */
|
|
58
|
+
logger_1.dataflowLogger.debug(`Assignment ${name.content} has a function call as target => replacement function ${target.lexeme}`);
|
|
59
|
+
const replacement = toReplacementSymbol(target, target.functionName.content, config.superAssignment ?? false);
|
|
60
|
+
return (0, process_named_call_1.processAsNamedCall)(replacement, data, replacement.content, [...target.arguments, source]);
|
|
61
|
+
}
|
|
62
|
+
else if (config.canBeReplacement && type === "RAccess" /* RType.Access */) {
|
|
63
|
+
logger_1.dataflowLogger.debug(`Assignment ${name.content} has an access as target => replacement function ${target.lexeme}`);
|
|
64
|
+
const replacement = toReplacementSymbol(target, target.operator, config.superAssignment ?? false);
|
|
65
|
+
return (0, process_named_call_1.processAsNamedCall)(replacement, data, replacement.content, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source]);
|
|
66
|
+
}
|
|
67
|
+
else if (type === "RString" /* RType.String */) {
|
|
68
|
+
return processAssignmentToString(target, args, name, rootId, data, config, source);
|
|
69
|
+
}
|
|
70
|
+
logger_1.dataflowLogger.warn(`Assignment ${name.content} has an unknown target type ${target.type}, skipping`);
|
|
71
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args: effectiveArgs, rootId, data }).information;
|
|
72
|
+
}
|
|
73
|
+
exports.processAssignment = processAssignment;
|
|
74
|
+
function extractSourceAndTarget(args, name) {
|
|
75
|
+
const source = (0, unpack_argument_1.unpackArgument)(args[1]);
|
|
76
|
+
const target = (0, unpack_argument_1.unpackArgument)(args[0]);
|
|
77
|
+
(0, assert_1.guard)(source !== undefined, () => `Assignment ${name.content} has no source, impossible!`);
|
|
78
|
+
(0, assert_1.guard)(target !== undefined, () => `Assignment ${name.content} has no target, impossible!`);
|
|
79
|
+
return { source, target };
|
|
80
|
+
}
|
|
81
|
+
function produceWrittenNodes(rootId, target, isFunctionDef, data, makeMaybe) {
|
|
82
|
+
return target.in.map(ref => ({
|
|
83
|
+
...ref,
|
|
84
|
+
kind: isFunctionDef ? 'function' : 'variable',
|
|
85
|
+
definedAt: rootId,
|
|
86
|
+
controlDependencies: data.controlDependencies ?? (makeMaybe ? [] : undefined)
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
function processAssignmentToString(target, args, name, rootId, data, config, source) {
|
|
90
|
+
const symbol = {
|
|
91
|
+
type: "RSymbol" /* RType.Symbol */,
|
|
92
|
+
info: target.info,
|
|
93
|
+
content: (0, retriever_1.removeRQuotes)(target.lexeme),
|
|
94
|
+
lexeme: target.lexeme,
|
|
95
|
+
location: target.location,
|
|
96
|
+
namespace: undefined
|
|
97
|
+
};
|
|
98
|
+
// treat first argument to Symbol
|
|
99
|
+
const mappedArgs = config.swapSourceAndTarget ? [args[0], {
|
|
100
|
+
...args[1],
|
|
101
|
+
value: symbol
|
|
102
|
+
}] : [{ ...args[0], value: symbol }, args[1]];
|
|
103
|
+
const res = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
104
|
+
name,
|
|
105
|
+
args: mappedArgs,
|
|
106
|
+
rootId,
|
|
107
|
+
data,
|
|
108
|
+
reverseOrder: !config.swapSourceAndTarget
|
|
109
|
+
});
|
|
110
|
+
return processAssignmentToSymbol({
|
|
111
|
+
...config,
|
|
112
|
+
name,
|
|
113
|
+
source,
|
|
114
|
+
target: symbol,
|
|
115
|
+
args: getEffectiveOrder(config, res.processedArguments),
|
|
116
|
+
rootId,
|
|
117
|
+
data,
|
|
118
|
+
information: res.information
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function checkFunctionDef(source, sourceInfo) {
|
|
122
|
+
return sourceInfo.graph.getVertex(source.info.id)?.tag === "function-definition" /* VertexType.FunctionDefinition */;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Helper function whenever it is known that the _target_ of an assignment is a (single) symbol (i.e. `x <- ...`, but not `names(x) <- ...`).
|
|
126
|
+
*/
|
|
127
|
+
function processAssignmentToSymbol({ name, source, args: [targetArg, sourceArg], target, rootId, data, information, superAssignment, makeMaybe, quoteSource }) {
|
|
128
|
+
const isFunctionDef = checkFunctionDef(source, sourceArg);
|
|
129
|
+
const writeNodes = produceWrittenNodes(rootId, targetArg, isFunctionDef, data, makeMaybe ?? false);
|
|
130
|
+
if (writeNodes.length !== 1 && log_1.log.settings.minLevel <= 4 /* LogLevel.Warn */) {
|
|
131
|
+
log_1.log.warn(`Unexpected write number in assignment: ${JSON.stringify(writeNodes)}`);
|
|
132
|
+
}
|
|
133
|
+
// we drop the first arg which we use to pass along arguments :D
|
|
134
|
+
const readFromSourceWritten = sourceArg.out.slice(1);
|
|
135
|
+
const readTargets = [{ nodeId: name.info.id, name: name.content, controlDependencies: data.controlDependencies }, ...sourceArg.unknownReferences, ...sourceArg.in, ...targetArg.in.filter(i => i.nodeId !== target.info.id), ...readFromSourceWritten];
|
|
136
|
+
const writeTargets = [...writeNodes, ...writeNodes, ...readFromSourceWritten];
|
|
137
|
+
information.environment = (0, overwrite_1.overwriteEnvironment)(targetArg.environment, sourceArg.environment);
|
|
138
|
+
// install assigned variables in environment
|
|
139
|
+
for (const write of writeNodes) {
|
|
140
|
+
information.environment = (0, define_1.define)(write, superAssignment, information.environment);
|
|
141
|
+
information.graph.setDefinitionOfVertex(write);
|
|
142
|
+
if (!quoteSource) {
|
|
143
|
+
information.graph.addEdge(write, source.info.id, { type: 2 /* EdgeType.DefinedBy */ });
|
|
144
|
+
}
|
|
145
|
+
information.graph.addEdge(write, rootId, { type: 2 /* EdgeType.DefinedBy */ });
|
|
146
|
+
// kinda dirty, but we have to remove existing read edges for the symbol, added by the child
|
|
147
|
+
const out = information.graph.outgoingEdges(write.nodeId);
|
|
148
|
+
for (const [id, edge] of (out ?? [])) {
|
|
149
|
+
edge.types &= ~1 /* EdgeType.Reads */;
|
|
150
|
+
if (edge.types == 0) {
|
|
151
|
+
out?.delete(id);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
information.graph.addEdge(name.info.id, targetArg.entryPoint, { type: 8 /* EdgeType.Returns */ });
|
|
156
|
+
if (quoteSource) {
|
|
157
|
+
information.graph.addEdge(rootId, source.info.id, { type: 256 /* EdgeType.NonStandardEvaluation */ });
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
...information,
|
|
161
|
+
unknownReferences: [],
|
|
162
|
+
entryPoint: name.info.id,
|
|
163
|
+
in: readTargets,
|
|
164
|
+
out: writeTargets
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=built-in-assignment.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processes a list of expressions joining their dataflow graphs accordingly.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
6
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
7
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
|
+
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
10
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
11
|
+
export declare function processExpressionList<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processExpressionList = void 0;
|
|
4
|
+
const info_1 = require("../../../../../info");
|
|
5
|
+
const processor_1 = require("../../../../../processor");
|
|
6
|
+
const linker_1 = require("../../../../linker");
|
|
7
|
+
const assert_1 = require("../../../../../../util/assert");
|
|
8
|
+
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
11
|
+
const graph_1 = require("../../../../../graph/graph");
|
|
12
|
+
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
13
|
+
const scoping_1 = require("../../../../../environments/scoping");
|
|
14
|
+
const built_in_1 = require("../../../../../environments/built-in");
|
|
15
|
+
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
16
|
+
const logger_1 = require("../../../../../logger");
|
|
17
|
+
const dotDotDotAccess = /\.\.\d+/;
|
|
18
|
+
function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph) {
|
|
19
|
+
const readName = read.name && dotDotDotAccess.test(read.name) ? '...' : read.name;
|
|
20
|
+
const probableTarget = readName ? (0, resolve_by_name_1.resolveByName)(readName, environments) : undefined;
|
|
21
|
+
// record if at least one has not been defined
|
|
22
|
+
if (probableTarget === undefined || probableTarget.some(t => !listEnvironments.has(t.nodeId))) {
|
|
23
|
+
if (remainingRead.has(readName)) {
|
|
24
|
+
remainingRead.get(readName)?.push(read);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
remainingRead.set(readName, [read]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// keep it, for we have no target, as read-ids are unique within the same fold, this should work for same links
|
|
31
|
+
// we keep them if they are defined outside the current parent and maybe throw them away later
|
|
32
|
+
if (probableTarget === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (const target of probableTarget) {
|
|
36
|
+
// we can stick with maybe even if readId.attribute is always
|
|
37
|
+
nextGraph.addEdge(read, target, { type: 1 /* EdgeType.Reads */ });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function processNextExpression(currentElement, environment, listEnvironments, remainingRead, nextGraph) {
|
|
41
|
+
// all inputs that have not been written until now, are read!
|
|
42
|
+
for (const read of [...currentElement.in, ...currentElement.unknownReferences]) {
|
|
43
|
+
linkReadNameToWriteIfPossible(read, environment, listEnvironments, remainingRead, nextGraph);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextGraph) {
|
|
47
|
+
for (const { functionCall, called } of calledEnvs) {
|
|
48
|
+
for (const calledFn of called) {
|
|
49
|
+
(0, assert_1.guard)(calledFn.tag === 'function-definition', 'called function must call a function definition');
|
|
50
|
+
// only merge the environments they have in common
|
|
51
|
+
let environment = calledFn.environment;
|
|
52
|
+
while (environment.level > inputEnvironment.level) {
|
|
53
|
+
environment = (0, scoping_1.popLocalEnvironment)(environment);
|
|
54
|
+
}
|
|
55
|
+
// update alle definitions to be defined at this function call
|
|
56
|
+
let current = environment.current;
|
|
57
|
+
while (current !== undefined) {
|
|
58
|
+
for (const definitions of current.memory.values()) {
|
|
59
|
+
for (const def of definitions) {
|
|
60
|
+
if (def.definedAt !== built_in_1.BuiltIn) {
|
|
61
|
+
nextGraph.addEdge(def.nodeId, functionCall, { type: 128 /* EdgeType.SideEffectOnCall */ });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
current = current.parent;
|
|
66
|
+
}
|
|
67
|
+
// we update all definitions to be linked with the corresponding function call
|
|
68
|
+
inputEnvironment = (0, overwrite_1.overwriteEnvironment)(inputEnvironment, environment);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return inputEnvironment;
|
|
72
|
+
}
|
|
73
|
+
function processExpressionList(name, args, rootId, data) {
|
|
74
|
+
const expressions = args.map(unpack_argument_1.unpackArgument);
|
|
75
|
+
logger_1.dataflowLogger.trace(`processing expression list with ${expressions.length} expressions`);
|
|
76
|
+
let environment = data.environment;
|
|
77
|
+
// used to detect if a "write" happens within the same expression list
|
|
78
|
+
const listEnvironments = new Set();
|
|
79
|
+
const remainingRead = new Map();
|
|
80
|
+
const nextGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
81
|
+
const out = [];
|
|
82
|
+
const exitPoints = [];
|
|
83
|
+
let expressionCounter = 0;
|
|
84
|
+
const processedExpressions = [];
|
|
85
|
+
let defaultReturnExpr = undefined;
|
|
86
|
+
for (const expression of expressions) {
|
|
87
|
+
logger_1.dataflowLogger.trace(`processing expression ${++expressionCounter} of ${expressions.length}`);
|
|
88
|
+
if (expression === undefined) {
|
|
89
|
+
processedExpressions.push(undefined);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// use the current environments for processing
|
|
93
|
+
data = { ...data, environment: environment };
|
|
94
|
+
const processed = (0, processor_1.processDataflowFor)(expression, data);
|
|
95
|
+
processedExpressions.push(processed);
|
|
96
|
+
nextGraph.mergeWith(processed.graph);
|
|
97
|
+
defaultReturnExpr = processed;
|
|
98
|
+
// if the expression contained next or break anywhere before the next loop, the overwrite should be an append because we do not know if the rest is executed
|
|
99
|
+
// update the environments for the next iteration with the previous writes
|
|
100
|
+
if (exitPoints.length > 0) {
|
|
101
|
+
processed.out = (0, environment_1.makeAllMaybe)(processed.out, nextGraph, processed.environment, true);
|
|
102
|
+
processed.in = (0, environment_1.makeAllMaybe)(processed.in, nextGraph, processed.environment, false);
|
|
103
|
+
processed.unknownReferences = (0, environment_1.makeAllMaybe)(processed.unknownReferences, nextGraph, processed.environment, false);
|
|
104
|
+
}
|
|
105
|
+
(0, info_1.addNonDefaultExitPoints)(exitPoints, processed.exitPoints);
|
|
106
|
+
out.push(...processed.out);
|
|
107
|
+
logger_1.dataflowLogger.trace(`expression ${expressionCounter} of ${expressions.length} has ${processed.unknownReferences.length} unknown nodes`);
|
|
108
|
+
processNextExpression(processed, environment, listEnvironments, remainingRead, nextGraph);
|
|
109
|
+
const calledEnvs = (0, linker_1.linkFunctionCalls)(nextGraph, data.completeAst.idMap, processed.graph);
|
|
110
|
+
environment = exitPoints.length > 0 ? (0, overwrite_1.overwriteEnvironment)(environment, processed.environment) : processed.environment;
|
|
111
|
+
// if the called function has global redefinitions, we have to keep them within our environment
|
|
112
|
+
environment = updateSideEffectsForCalledFunctions(calledEnvs, environment, nextGraph);
|
|
113
|
+
for (const { nodeId } of processed.out) {
|
|
114
|
+
listEnvironments.add(nodeId);
|
|
115
|
+
}
|
|
116
|
+
/** if at least built-one of the exit points encountered happens unconditionally, we exit here (dead code)! */
|
|
117
|
+
if ((0, info_1.alwaysExits)(processed)) {
|
|
118
|
+
/* if there is an always-exit expression, there is no default return active anymore */
|
|
119
|
+
defaultReturnExpr = undefined;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
logger_1.dataflowLogger.trace(`expression list exits with ${remainingRead.size} remaining read names`);
|
|
124
|
+
if (defaultReturnExpr) {
|
|
125
|
+
exitPoints.push({
|
|
126
|
+
type: 0 /* ExitPointType.Default */,
|
|
127
|
+
nodeId: defaultReturnExpr.entryPoint,
|
|
128
|
+
controlDependencies: data.controlDependencies
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const ingoing = [...remainingRead.values()].flat();
|
|
132
|
+
const rootNode = data.completeAst.idMap.get(rootId);
|
|
133
|
+
const withGroup = rootNode?.grouping;
|
|
134
|
+
if (withGroup) {
|
|
135
|
+
ingoing.push({ nodeId: rootId, name: name.content, controlDependencies: data.controlDependencies });
|
|
136
|
+
(0, common_1.patchFunctionCall)({
|
|
137
|
+
nextGraph,
|
|
138
|
+
rootId,
|
|
139
|
+
name,
|
|
140
|
+
data,
|
|
141
|
+
argumentProcessResult: processedExpressions
|
|
142
|
+
});
|
|
143
|
+
// process all exit points as potential returns:
|
|
144
|
+
for (const exit of exitPoints) {
|
|
145
|
+
if (exit.type === 1 /* ExitPointType.Return */ || exit.type === 0 /* ExitPointType.Default */) {
|
|
146
|
+
nextGraph.addEdge(rootId, exit.nodeId, { type: 8 /* EdgeType.Returns */ });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const meId = withGroup ? rootId : (processedExpressions.find(assert_1.isNotUndefined)?.entryPoint ?? rootId);
|
|
151
|
+
return {
|
|
152
|
+
/* no active nodes remain, they are consumed within the remaining read collection */
|
|
153
|
+
unknownReferences: [],
|
|
154
|
+
in: ingoing,
|
|
155
|
+
out,
|
|
156
|
+
environment: environment,
|
|
157
|
+
graph: nextGraph,
|
|
158
|
+
/* if we have no group we take the last evaluated expr */
|
|
159
|
+
entryPoint: meId,
|
|
160
|
+
exitPoints: withGroup ? [{ nodeId: rootId, type: 0 /* ExitPointType.Default */, controlDependencies: data.controlDependencies }]
|
|
161
|
+
: exitPoints
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
exports.processExpressionList = processExpressionList;
|
|
165
|
+
//# sourceMappingURL=built-in-expression-list.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
7
|
+
export declare function processForLoop<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processForLoop = void 0;
|
|
4
|
+
const processor_1 = require("../../../../../processor");
|
|
5
|
+
const info_1 = require("../../../../../info");
|
|
6
|
+
const linker_1 = require("../../../../linker");
|
|
7
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
8
|
+
const assert_1 = require("../../../../../../util/assert");
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
11
|
+
const logger_1 = require("../../../../../logger");
|
|
12
|
+
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
13
|
+
const define_1 = require("../../../../../environments/define");
|
|
14
|
+
const append_1 = require("../../../../../environments/append");
|
|
15
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
16
|
+
const scoping_1 = require("../../../../../environments/scoping");
|
|
17
|
+
function processForLoop(name, args, rootId, data) {
|
|
18
|
+
if (args.length !== 3) {
|
|
19
|
+
logger_1.dataflowLogger.warn(`For-Loop ${name.content} does not have three arguments, skipping`);
|
|
20
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
21
|
+
}
|
|
22
|
+
const [variableArg, vectorArg, bodyArg] = args.map(unpack_argument_1.unpackArgument);
|
|
23
|
+
(0, assert_1.guard)(variableArg !== undefined && vectorArg !== undefined && bodyArg !== undefined, () => `For-Loop ${JSON.stringify(args)} has missing arguments! Bad!`);
|
|
24
|
+
const vector = (0, processor_1.processDataflowFor)(vectorArg, data);
|
|
25
|
+
if ((0, info_1.alwaysExits)(vector)) {
|
|
26
|
+
logger_1.dataflowLogger.warn(`For-Loop ${rootId} forces exit in vector, skipping rest`);
|
|
27
|
+
return vector;
|
|
28
|
+
}
|
|
29
|
+
const variable = (0, processor_1.processDataflowFor)(variableArg, data);
|
|
30
|
+
// this should not be able to exit always!
|
|
31
|
+
const originalDependency = data.controlDependencies;
|
|
32
|
+
data = { ...data, controlDependencies: [...data.controlDependencies ?? [], name.info.id] };
|
|
33
|
+
let headEnvironments = (0, overwrite_1.overwriteEnvironment)(vector.environment, variable.environment);
|
|
34
|
+
const headGraph = variable.graph.mergeWith(vector.graph);
|
|
35
|
+
const writtenVariable = [...variable.unknownReferences, ...variable.in];
|
|
36
|
+
for (const write of writtenVariable) {
|
|
37
|
+
headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, kind: 'variable' }, false, headEnvironments);
|
|
38
|
+
}
|
|
39
|
+
data = { ...data, environment: headEnvironments };
|
|
40
|
+
/* process the body without any environment first, to retrieve all open references */
|
|
41
|
+
let environment = (0, environment_1.initializeCleanEnvironments)();
|
|
42
|
+
while (headEnvironments.level > environment.level) {
|
|
43
|
+
environment = (0, scoping_1.pushLocalEnvironment)(environment);
|
|
44
|
+
}
|
|
45
|
+
const body = (0, processor_1.processDataflowFor)(bodyArg, { ...data, environment });
|
|
46
|
+
const nextGraph = headGraph.mergeWith(body.graph);
|
|
47
|
+
const outEnvironment = (0, append_1.appendEnvironment)(headEnvironments, body.environment);
|
|
48
|
+
// again within an if-then-else we consider all actives to be read
|
|
49
|
+
// currently I add it at the end, but is this correct?
|
|
50
|
+
const ingoing = [
|
|
51
|
+
...vector.in,
|
|
52
|
+
...(0, environment_1.makeAllMaybe)(body.in, nextGraph, outEnvironment, false),
|
|
53
|
+
...vector.unknownReferences,
|
|
54
|
+
...(0, environment_1.makeAllMaybe)(body.unknownReferences, nextGraph, outEnvironment, false)
|
|
55
|
+
];
|
|
56
|
+
// now we have to bind all open reads with the given name to the locally defined writtenVariable!
|
|
57
|
+
const nameIdShares = (0, linker_1.produceNameSharedIdMap)(ingoing);
|
|
58
|
+
for (const write of writtenVariable) {
|
|
59
|
+
nextGraph.addEdge(write.nodeId, vector.entryPoint, { type: 2 /* EdgeType.DefinedBy */ });
|
|
60
|
+
const name = write.name;
|
|
61
|
+
if (name) {
|
|
62
|
+
const readIdsToLink = nameIdShares.get(name);
|
|
63
|
+
for (const readId of readIdsToLink) {
|
|
64
|
+
nextGraph.addEdge(readId.nodeId, write.nodeId, { type: 1 /* EdgeType.Reads */ });
|
|
65
|
+
}
|
|
66
|
+
// now, we remove the name from the id shares as they are no longer needed
|
|
67
|
+
nameIdShares.delete(name);
|
|
68
|
+
nextGraph.setDefinitionOfVertex(write);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const outgoing = [...variable.out, ...writtenVariable, ...(0, environment_1.makeAllMaybe)(body.out, nextGraph, outEnvironment, true)];
|
|
72
|
+
(0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out);
|
|
73
|
+
(0, common_1.patchFunctionCall)({
|
|
74
|
+
nextGraph,
|
|
75
|
+
rootId,
|
|
76
|
+
name,
|
|
77
|
+
data: { ...data, controlDependencies: originalDependency },
|
|
78
|
+
argumentProcessResult: [variable, vector, body]
|
|
79
|
+
});
|
|
80
|
+
/* mark the last argument as nse */
|
|
81
|
+
nextGraph.addEdge(rootId, body.entryPoint, { type: 256 /* EdgeType.NonStandardEvaluation */ });
|
|
82
|
+
// as the for-loop always evaluates its variable and condition
|
|
83
|
+
nextGraph.addEdge(name.info.id, variable.entryPoint, { type: 1 /* EdgeType.Reads */ });
|
|
84
|
+
nextGraph.addEdge(name.info.id, vector.entryPoint, { type: 1 /* EdgeType.Reads */ });
|
|
85
|
+
return {
|
|
86
|
+
unknownReferences: [],
|
|
87
|
+
// we only want those not bound by a local variable
|
|
88
|
+
in: [{ nodeId: rootId, name: name.content, controlDependencies: originalDependency }, ...variable.in, ...[...nameIdShares.values()].flat()],
|
|
89
|
+
out: outgoing,
|
|
90
|
+
graph: nextGraph,
|
|
91
|
+
entryPoint: name.info.id,
|
|
92
|
+
exitPoints: (0, info_1.filterOutLoopExitPoints)(body.exitPoints),
|
|
93
|
+
environment: outEnvironment
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
exports.processForLoop = processForLoop;
|
|
97
|
+
//# sourceMappingURL=built-in-for-loop.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
5
|
+
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
export declare function processFunctionDefinition<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processFunctionDefinition = void 0;
|
|
4
|
+
const processor_1 = require("../../../../../processor");
|
|
5
|
+
const linker_1 = require("../../../../linker");
|
|
6
|
+
const known_call_handling_1 = require("../known-call-handling");
|
|
7
|
+
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
8
|
+
const assert_1 = require("../../../../../../util/assert");
|
|
9
|
+
const logger_1 = require("../../../../../logger");
|
|
10
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
|
+
const graph_1 = require("../../../../../graph/graph");
|
|
12
|
+
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
13
|
+
const scoping_1 = require("../../../../../environments/scoping");
|
|
14
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
15
|
+
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
16
|
+
function processFunctionDefinition(name, args, rootId, data) {
|
|
17
|
+
if (args.length < 1) {
|
|
18
|
+
logger_1.dataflowLogger.warn(`Function Definition ${name.content} does not have an argument, skipping`);
|
|
19
|
+
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data }).information;
|
|
20
|
+
}
|
|
21
|
+
/* we remove the last argument, as it is the body */
|
|
22
|
+
const parameters = args.slice(0, -1);
|
|
23
|
+
const bodyArg = (0, unpack_argument_1.unpackArgument)(args[args.length - 1]);
|
|
24
|
+
(0, assert_1.guard)(bodyArg !== undefined, () => `Function Definition ${JSON.stringify(args)} has missing body! Bad!`);
|
|
25
|
+
const originalEnvironment = data.environment;
|
|
26
|
+
// within a function def we do not pass on the outer binds as they could be overwritten when called
|
|
27
|
+
data = prepareFunctionEnvironment(data);
|
|
28
|
+
const subgraph = new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
29
|
+
let readInParameters = [];
|
|
30
|
+
for (const param of parameters) {
|
|
31
|
+
(0, assert_1.guard)(param !== r_function_call_1.EmptyArgument, () => `Empty argument in function definition ${name.content}, ${JSON.stringify(args)}`);
|
|
32
|
+
const processed = (0, processor_1.processDataflowFor)(param, data);
|
|
33
|
+
subgraph.mergeWith(processed.graph);
|
|
34
|
+
const read = [...processed.in, ...processed.unknownReferences];
|
|
35
|
+
(0, linker_1.linkInputs)(read, data.environment, readInParameters, subgraph, false);
|
|
36
|
+
data = { ...data, environment: (0, overwrite_1.overwriteEnvironment)(data.environment, processed.environment) };
|
|
37
|
+
}
|
|
38
|
+
const paramsEnvironments = data.environment;
|
|
39
|
+
const body = (0, processor_1.processDataflowFor)(bodyArg, data);
|
|
40
|
+
// As we know, parameters cannot technically duplicate (i.e., their names are unique), we overwrite their environments.
|
|
41
|
+
// This is the correct behavior, even if someone uses non-`=` arguments in functions.
|
|
42
|
+
const bodyEnvironment = body.environment;
|
|
43
|
+
readInParameters = findPromiseLinkagesForParameters(subgraph, readInParameters, paramsEnvironments, body);
|
|
44
|
+
const readInBody = [...body.in, ...body.unknownReferences];
|
|
45
|
+
// there is no uncertainty regarding the arguments, as if a function header is executed, so is its body
|
|
46
|
+
const remainingRead = (0, linker_1.linkInputs)(readInBody, paramsEnvironments, readInParameters.slice(), body.graph, true /* functions do not have to be called */);
|
|
47
|
+
subgraph.mergeWith(body.graph);
|
|
48
|
+
logger_1.dataflowLogger.trace(`Function definition with id ${name.info.id} has ${remainingRead.length} remaining reads`);
|
|
49
|
+
const outEnvironment = (0, overwrite_1.overwriteEnvironment)(paramsEnvironments, bodyEnvironment);
|
|
50
|
+
for (const read of remainingRead) {
|
|
51
|
+
if (read.name) {
|
|
52
|
+
subgraph.addVertex({
|
|
53
|
+
tag: "use" /* VertexType.Use */,
|
|
54
|
+
id: read.nodeId,
|
|
55
|
+
environment: undefined,
|
|
56
|
+
controlDependencies: []
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const flow = {
|
|
61
|
+
unknownReferences: [],
|
|
62
|
+
in: remainingRead,
|
|
63
|
+
out: [],
|
|
64
|
+
entryPoint: body.entryPoint,
|
|
65
|
+
graph: new Set(subgraph.rootIds()),
|
|
66
|
+
environment: outEnvironment
|
|
67
|
+
};
|
|
68
|
+
const exitPoints = body.exitPoints;
|
|
69
|
+
updateNestedFunctionClosures(exitPoints, subgraph, outEnvironment, name);
|
|
70
|
+
const graph = new graph_1.DataflowGraph(data.completeAst.idMap).mergeWith(subgraph, false);
|
|
71
|
+
graph.addVertex({
|
|
72
|
+
tag: "function-definition" /* VertexType.FunctionDefinition */,
|
|
73
|
+
id: name.info.id,
|
|
74
|
+
environment: (0, scoping_1.popLocalEnvironment)(outEnvironment),
|
|
75
|
+
controlDependencies: data.controlDependencies,
|
|
76
|
+
subflow: flow,
|
|
77
|
+
exitPoints: exitPoints?.filter(e => e.type === 1 /* ExitPointType.Return */ || e.type === 0 /* ExitPointType.Default */).map(e => e.nodeId) ?? []
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
/* nothing escapes a function definition, but the function itself, will be forced in assignment: { nodeId: functionDefinition.info.id, scope: data.activeScope, used: 'always', name: functionDefinition.info.id as string } */
|
|
81
|
+
unknownReferences: [],
|
|
82
|
+
in: [],
|
|
83
|
+
out: [],
|
|
84
|
+
exitPoints: [],
|
|
85
|
+
entryPoint: name.info.id,
|
|
86
|
+
graph,
|
|
87
|
+
environment: originalEnvironment
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.processFunctionDefinition = processFunctionDefinition;
|
|
91
|
+
function updateNestedFunctionClosures(exitPoints, subgraph, outEnvironment, name) {
|
|
92
|
+
// track *all* function definitions - including those nested within the current graph
|
|
93
|
+
// try to resolve their 'in' by only using the lowest scope which will be popped after this definition
|
|
94
|
+
for (const [id, info] of subgraph.vertices(true)) {
|
|
95
|
+
if (info.tag !== "function-definition" /* VertexType.FunctionDefinition */) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const ingoingRefs = info.subflow.in;
|
|
99
|
+
const remainingIn = new Set();
|
|
100
|
+
for (const ingoing of ingoingRefs) {
|
|
101
|
+
for (const { nodeId } of exitPoints) {
|
|
102
|
+
const node = subgraph.getVertex(nodeId, true);
|
|
103
|
+
const env = (0, environment_1.initializeCleanEnvironments)();
|
|
104
|
+
env.current.memory = node === undefined ? outEnvironment.current.memory : (node.environment?.current.memory ?? outEnvironment.current.memory);
|
|
105
|
+
const resolved = ingoing.name ? (0, resolve_by_name_1.resolveByName)(ingoing.name, env) : undefined;
|
|
106
|
+
if (resolved === undefined) {
|
|
107
|
+
remainingIn.add(ingoing);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
logger_1.dataflowLogger.trace(`Found ${resolved.length} references to open ref ${id} in closure of function definition ${name.info.id}`);
|
|
111
|
+
for (const ref of resolved) {
|
|
112
|
+
subgraph.addEdge(ingoing, ref, { type: 1 /* EdgeType.Reads */ });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
logger_1.dataflowLogger.trace(`Keeping ${remainingIn.size} (unique) references to open ref ${id} in closure of function definition ${name.info.id}`);
|
|
117
|
+
info.subflow.in = [...remainingIn];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function prepareFunctionEnvironment(data) {
|
|
121
|
+
let env = (0, environment_1.initializeCleanEnvironments)();
|
|
122
|
+
for (let i = 0; i < data.environment.level + 1 /* add another env */; i++) {
|
|
123
|
+
env = (0, scoping_1.pushLocalEnvironment)(env);
|
|
124
|
+
}
|
|
125
|
+
return { ...data, environment: env };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Within something like `f <- function(a=b, m=3) { b <- 1; a; b <- 5; a + 1 }`
|
|
129
|
+
* `a` will be defined by `b` and `b`will be a promise object bound by the first definition of b it can find.
|
|
130
|
+
* This means, that this function returns `2` due to the first `b <- 1` definition.
|
|
131
|
+
* If the code is `f <- function(a=b, m=3) { if(m > 3) { b <- 1; }; a; b <- 5; a + 1 }`, we need a link to `b <- 1` and `b <- 6`
|
|
132
|
+
* as `b` can be defined by either one of them.
|
|
133
|
+
* <p>
|
|
134
|
+
* <b>Currently we may be unable to narrow down every definition within the body as we have not implemented ways to track what covers a first definitions</b>
|
|
135
|
+
*/
|
|
136
|
+
function findPromiseLinkagesForParameters(parameters, readInParameters, parameterEnvs, body) {
|
|
137
|
+
// first, we try to bind again within parameters - if we have it, fine
|
|
138
|
+
const remainingRead = [];
|
|
139
|
+
for (const read of readInParameters) {
|
|
140
|
+
const resolved = read.name ? (0, resolve_by_name_1.resolveByName)(read.name, parameterEnvs) : undefined;
|
|
141
|
+
if (resolved !== undefined) {
|
|
142
|
+
for (const ref of resolved) {
|
|
143
|
+
parameters.addEdge(read, ref, { type: 1 /* EdgeType.Reads */ });
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
// If not resolved, link all outs within the body as potential reads.
|
|
148
|
+
// Regarding the sort, we can ignore equality as nodeIds are unique.
|
|
149
|
+
// We sort to get the lowest id - if it is an 'always' flag, we can safely use it instead of all of them.
|
|
150
|
+
const writingOuts = body.out.filter(o => o.name === read.name).sort((a, b) => String(a.nodeId) < String(b.nodeId) ? 1 : -1);
|
|
151
|
+
if (writingOuts.length === 0) {
|
|
152
|
+
remainingRead.push(read);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (writingOuts[0].controlDependencies === undefined) {
|
|
156
|
+
parameters.addEdge(read, writingOuts[0], { type: 1 /* EdgeType.Reads */ });
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
for (const out of writingOuts) {
|
|
160
|
+
parameters.addEdge(read, out, { type: 1 /* EdgeType.Reads */ });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return remainingRead;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=built-in-function-definition.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
|
+
export declare function processGet<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|