-
Notifications
You must be signed in to change notification settings - Fork 13
[Query] Control Flow
Generated from 'wiki-query.ts' on 2026-09-10, 07:04:46 UTC (v2.15.8), do not edit directly.
Control-Flow Query [overview]
Provides the control-flow of the program.
This query is requested with the type control-flow.
This control-flow query provides you access to the control flow graph.
In other words, if you have a script simply reading: if(TRUE) 1 else 2, the following query returns the CFG:
[ { "type": "control-flow" } ](This can be shortened to @control-flow when used with the REPL command :query).
Show Results
Results (prettified and summarized):
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.
{
"control-flow": {
".meta": {},
"controlFlow": {
"graph": {"roots":[0,1,5],"vtxInfos":[[0,[2,0]],[1,[1,1]],[5,[1,5]]],"bbChildren":[],"edgeInfos":[[0,[[1,0]]],[1,[[5,0]]]],"mayHaveBasicBlocks":false},
"entryPoints": [0],
"exitPoints": [5],
"returns": [],
"breaks": [],
"nexts": []
}
},
".meta": {}
}You can also overwrite the simplification passes to tune the perspective. for example, if you want to have basic blocks:
[
{
"type": "control-flow",
"config": {
"simplificationPasses": [
"unique-cf-sets",
"to-basic-blocks"
]
}
}
]Show Results
Results (prettified and summarized):
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.
{
"control-flow": {
".meta": {},
"controlFlow": {
"returns": [],
"entryPoints": ["bb-0"],
"exitPoints": ["bb-0"],
"breaks": [],
"nexts": [],
"graph": {
"roots": ["bb-0"],
"vtxInfos": [["bb-0",[3,"bb-0",[[2,0],[1,1],[1,5]]]]],
"bbChildren": [[0,"bb-0"],[1,"bb-0"],[5,"bb-0"]],
"edgeInfos": [],
"mayHaveBasicBlocks": true
}
}
},
".meta": {}
}this produces:
flowchart LR
subgraph nbb-0 [Block bb-0]
direction LR
n0(["`RLogical (0)
**TRUE**`"])
n1["`RNumber (1)
**1**`"]
n0 --> n1
n5["`RIfThenElse (5)
**if(TRUE) 1 else 2**`"]
n1 --> n5
end
style nbb-0 stroke:cyan,stroke-width:6.5px; style nbb-0 stroke:green,stroke-width:6.5px;
(The analysis ran (including the dataflow analysis, normalization, and parsing with the r-shell engine) within the generation environment.
We used the following simplifications: unique-cf-sets, to-basic-blocks .
)
If, on the other hand, you want to prune dead code edges:
[
{
"type": "control-flow",
"config": {
"simplificationPasses": [
"unique-cf-sets",
"analyze-dead-code"
]
}
}
]Show Results
Results (prettified and summarized):
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.
{
"control-flow": {
".meta": {},
"controlFlow": {
"returns": [],
"entryPoints": [0],
"exitPoints": [5],
"breaks": [],
"nexts": [],
"graph": {"roots":[0,1,5],"vtxInfos":[[0,[2,0]],[1,[1,1]],[5,[1,5]]],"bbChildren":[],"edgeInfos":[[0,[[1,0]]],[1,[[5,0]]]],"mayHaveBasicBlocks":false}
}
},
".meta": {}
}this produces:
flowchart LR
n0(["`RLogical (0)
**TRUE**`"])
n1["`RNumber (1)
**1**`"]
n5["`RIfThenElse (5)
**if(TRUE) 1 else 2**`"]
n0 -->|"flows to"| n1
n1 -->|"flows to"| n5
style n0 stroke:cyan,stroke-width:6.5px; style n5 stroke:green,stroke-width:6.5px;
(The analysis ran (including the dataflow analysis, normalization, and parsing with the r-shell engine) within the generation environment.
We used the following simplifications: unique-cf-sets, analyze-dead-code .
)
Or, completely remove dead code:
[
{
"type": "control-flow",
"config": {
"simplificationPasses": [
"unique-cf-sets",
"analyze-dead-code",
"remove-dead-code"
]
}
}
]Show Results
Results (prettified and summarized):
Show Detailed Results as Json
The analysis ran (including parsing and normalization and the query) within the generation environment.
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.
{
"control-flow": {
".meta": {},
"controlFlow": {
"returns": [],
"entryPoints": [0],
"exitPoints": [5],
"breaks": [],
"nexts": [],
"graph": {"roots":[0,1,5],"vtxInfos":[[0,[2,0]],[1,[1,1]],[5,[1,5]]],"bbChildren":[],"edgeInfos":[[0,[[1,0]]],[1,[[5,0]]]],"mayHaveBasicBlocks":false}
}
},
".meta": {}
}this produces:
flowchart LR
n0(["`RLogical (0)
**TRUE**`"])
n1["`RNumber (1)
**1**`"]
n5["`RIfThenElse (5)
**if(TRUE) 1 else 2**`"]
n0 -->|"flows to"| n1
n1 -->|"flows to"| n5
style n0 stroke:cyan,stroke-width:6.5px; style n5 stroke:green,stroke-width:6.5px;
(The analysis ran (including the dataflow analysis, normalization, and parsing with the r-shell engine) within the generation environment.
We used the following simplifications: unique-cf-sets, analyze-dead-code, remove-dead-code .
)
Implementation Details
Responsible for the execution of the Control-Flow Query query is executeControlFlowQuery in ./src/queries/catalog/control-flow-query/control-flow-query-executor.ts.
Currently maintained by Florian Sihler and Oliver Gerstl at Ulm University
Email | GitHub | Penguins | Portfolio
- 🧑💻 Developer Onboarding
- 💻 Setup
- 👓 Overview
- 🪟 Interfacing with flowR
- 🌋 Core
- 🧹 Testing & Linting (Benchmark Page)
⁉️ FAQ- ℹ️ Extra Information