@@ -8,12 +8,12 @@ import config.Printers
8
8
import core .Mode
9
9
10
10
object trace extends TraceSyntax :
11
- inline def isForced : false = false
12
- protected val doForceTrace = isForced
11
+ inline def isEnabled = Config .tracingEnabled
12
+ protected val isForced = false
13
13
14
14
object force extends TraceSyntax :
15
- inline def isForced : true = true
16
- protected val doForceTrace = isForced
15
+ inline def isEnabled : true = true
16
+ protected val isForced = true
17
17
end trace
18
18
19
19
/** This module is carefully optimized to give zero overhead if Config.tracingEnabled
@@ -22,24 +22,24 @@ end trace
22
22
*/
23
23
trait TraceSyntax :
24
24
25
- inline def isForced : Boolean
26
- protected val doForceTrace : Boolean
25
+ inline def isEnabled : Boolean
26
+ protected val isForced : Boolean
27
27
28
28
inline def onDebug [TD ](inline question : String )(inline op : TD )(using Context ): TD =
29
29
conditionally(ctx.settings.YdebugTrace .value, question, false )(op)
30
30
31
31
inline def conditionally [TC ](inline cond : Boolean , inline question : String , inline show : Boolean )(inline op : TC )(using Context ): TC =
32
- inline if isForced || Config .tracingEnabled then
32
+ inline if isEnabled then
33
33
apply(question, if cond then Printers .default else Printers .noPrinter, show)(op)
34
34
else op
35
35
36
36
inline def apply [T ](inline question : String , inline printer : Printers .Printer , inline showOp : Any => String )(inline op : T )(using Context ): T =
37
- inline if isForced || Config .tracingEnabled then
37
+ inline if isEnabled then
38
38
doTrace[T ](question, printer, showOp)(op)
39
39
else op
40
40
41
41
inline def apply [T ](inline question : String , inline printer : Printers .Printer , inline show : Boolean )(inline op : T )(using Context ): T =
42
- inline if isForced || Config .tracingEnabled then
42
+ inline if isEnabled then
43
43
doTrace[T ](question, printer, if show then showShowable(_) else alwaysToString)(op)
44
44
else op
45
45
@@ -62,7 +62,7 @@ trait TraceSyntax:
62
62
printer : Printers .Printer = Printers .default,
63
63
showOp : Any => String = alwaysToString)
64
64
(op : => T )(using Context ): T =
65
- if ctx.mode.is(Mode .Printing ) || ! doForceTrace && (printer eq Printers .noPrinter) then op
65
+ if ctx.mode.is(Mode .Printing ) || ! isForced && (printer eq Printers .noPrinter) then op
66
66
else
67
67
// Avoid evaluating question multiple time, since each evaluation
68
68
// may cause some extra logging output.
@@ -73,7 +73,7 @@ trait TraceSyntax:
73
73
var logctx = ctx
74
74
while logctx.reporter.isInstanceOf [StoreReporter ] do logctx = logctx.outer
75
75
def margin = ctx.base.indentTab * ctx.base.indent
76
- def doLog (s : String ) = if doForceTrace then println(s) else report.log(s)
76
+ def doLog (s : String ) = if isForced then println(s) else report.log(s)
77
77
def finalize (result : Any , note : String ) =
78
78
if ! finalized then
79
79
ctx.base.indent -= 1
0 commit comments