-
Notifications
You must be signed in to change notification settings - Fork 14
[Query] Dice
This document was generated from 'src/documentation/wiki-query.ts' on 2026-07-20, 17:48:27 UTC presenting an overview of flowR's query API (v2.12.3). Please do not edit this file/wiki page directly.
Dice Query [overview]
Reduces the code to the parts that carry information from a given start point to a given end point.
This query is requested with the type dice.
Run in the REPL: :query @dice (<crit>;...->crit;...)[iIcB] <code | file://path>
While the Static Slice Query answers "what affects this point?" (or "what does this point affect?"),
a dice answers the two-sided question: which parts of the program carry information from A to B?
It is the intersection of a forward slice seeded at from and a backward slice seeded at to,
so only the code that lies on some dependency path between the two criteria survives.
Both from and to are arrays of slicing criteria, just like for the Static Slice Query.
Unlike that query, there is no direction property: the direction is already fixed by the from→to pairing.
Consider the following code:
x <- 1
y <- 2
z <- x + y
w <- z * 2
print(z)Asking what connects the definition of x to the definition of z drops y <- 2 (it never depends on x)
as well as w <- z * 2 and print(z) (they are not on a path into the to criterion):
[
{
"type": "dice",
"from": [
"1@x"
],
"to": [
"3@z"
]
}
](This can be shortened to @dice (1@x->3@z) "x <- 1\ny <- 2\nz <- x + y\nw <- z * 2\nprint(z)" when used with the REPL command :query).
Results (prettified and summarized):
x <- 1
z <- x + y
All queries together required ≈11 ms (1ms accuracy, total 11 ms)
Show Detailed Results as Json
The analysis required 11.3 ms (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.
{
"dice": {
".meta": {
"timing": 10
},
"results": {
"{\"type\":\"dice\",\"from\":[\"1@x\"],\"to\":[\"3@z\"]}": {
"slice": {
"timesHitThreshold": 0,
"result": [
0,
2,
7,
9,
10,
6
],
"slicedFor": [
0,
6
],
".meta": {
"timing": 1
}
},
"reconstruct": {
"code": "x <- 1\nz <- x + y",
"linesWithAutoSelected": 0,
".meta": {
"timing": 1
}
}
}
}
},
".meta": {
"timing": 11
}
}Beyond from and to, the dice query understands the same options as the Static Slice Query
(noReconstruction, noMagicComments, inlineSources, inlineFull, and includeCallees), as both share the
SliceQueryOptions of ./src/queries/catalog/slice-query-options.ts.
Multiple Criteria per Side
Each side accepts several criteria, which are seeded together:
[
{
"type": "dice",
"from": [
"1@x",
"2@y"
],
"to": [
"5@print"
]
}
]Results (prettified and summarized):
x <- 1
y <- 2
z <- x + y
print(z)
All queries together required ≈8 ms (1ms accuracy, total 9 ms)
Show Detailed Results as Json
The analysis required 9.3 ms (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.
{
"dice": {
".meta": {
"timing": 8
},
"results": {
"{\"type\":\"dice\",\"from\":[\"1@x\",\"2@y\"],\"to\":[\"5@print\"]}": {
"slice": {
"timesHitThreshold": 0,
"result": [
0,
3,
5,
8,
9,
10,
6,
17,
19,
2,
7
],
"slicedFor": [
0,
3,
19
],
".meta": {
"timing": 1
}
},
"reconstruct": {
"code": "x <- 1\ny <- 2\nz <- x + y\nprint(z)",
"linesWithAutoSelected": 0,
".meta": {
"timing": 0
}
}
}
}
},
".meta": {
"timing": 8
}
}Implementation Details
Responsible for the execution of the Dice Query query is executeDiceQuery in ./src/queries/catalog/dice-query/dice-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