@@ -11,7 +11,27 @@ import dotc.report
11
11
import dotc .typer .Inliner .InliningPosition
12
12
import collection .mutable
13
13
14
-
14
+ /**
15
+ * Tool for generating virtual lines for inlined calls and keeping track of them.
16
+
17
+ * How it works:
18
+ * - For every inlined call it assumes that empty lines are appended to the source file. These
19
+ * lines are not added anywhere in physical form. We only assume that they exist only to be used
20
+ * by `LineNumberTable` and `SourceDebugExtension`. The number of these virtual lines is every
21
+ * time equal to the size of line range of the expansion of inlined call.
22
+ * - It generates SMAP (as defined by JSR-45) containing two strata. The first stratum (`Scala`)
23
+ * is describing the mapping from the real source files to the real and virtual lines in our
24
+ * assumed source. The second stratum (`ScalaDebug`) is mapping from virtual lines to
25
+ * corresponding inlined calls.
26
+ * - Generated SMAP is written to the bytecode in `SourceDebugExtension`
27
+ * - During the generation of the bytecode backed is asking `InlinedSourceMap` about position of
28
+ * all trees that have source different from the main source of given compilation unit.
29
+ * The response to that request is number of the virtual line that is corresponding to particular
30
+ * line from the other source.
31
+ * - Debuggers can use information stored in `LineNumberTable` and `SourceDebugExtension` to
32
+ * correctly guess which line of inlined method is currently executed. They can also construct
33
+ * stack frames for inlined calls.
34
+ **/
15
35
object InlinedSourceMaps :
16
36
private case class Request (targetPos : SourcePosition , origPos : SourcePosition , firstFakeLine : Int )
17
37
0 commit comments