File: tdebugutils.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (38 lines) | stat: -rw-r--r-- 1,338 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
discard """
  joinable: false
  disabled: true
"""

#[
This test illustrates some features of `debugutils` to debug the compiler.

## example
this shows how to enable compiler logging just for a section of user code,
without generating tons of unrelated log messages for code you're not interested
in debugging.

```sh
# enable some debugging code, e.g. the `when false:` block in `semExpr`
nim c -o:bin/nim_temp --stacktrace -d:debug -d:nimDebugUtils compiler/nim
bin/nim_temp c tests/compiler/tdebugutils.nim
```

(use --filenames:abs for abs files)

## result
("<", "tdebugutils.nim(16, 3)",  {.define(nimCompilerDebug).}, nil)
(">", "tdebugutils.nim(17, 3)", let a = 2.5 * 3, {}, nkLetSection)
(">", "tdebugutils.nim(17, 15)", 2.5 * 3, {efAllowDestructor, efWantValue}, nkInfix)
(">", "tdebugutils.nim(17, 11)", 2.5, {efAllowStmt, efDetermineType, efOperand}, nkFloatLit)
("<", "tdebugutils.nim(17, 11)", 2.5, float64)
(">", "tdebugutils.nim(17, 17)", 3, {efAllowStmt, efDetermineType, efOperand}, nkIntLit)
("<", "tdebugutils.nim(17, 17)", 3, int literal(3))
("<", "tdebugutils.nim(17, 15)", 2.5 * 3, float)
("<", "tdebugutils.nim(17, 3)", let a = 2.5 * 3, nil)
(">", "tdebugutils.nim(18, 3)",  {.undef(nimCompilerDebug).}, {}, nkPragma)
]#

proc main =
  {.define(nimCompilerDebug).}
  let a = 2.5 * 3
  {.undef(nimCompilerDebug).}