add more APIs to compiler/debugutils; re-export it (#18243)
This commit is contained in:
parent
a250481dcd
commit
87cd9b24a3
4 changed files with 85 additions and 0 deletions
38
tests/compiler/tdebugutils.nim
Normal file
38
tests/compiler/tdebugutils.nim
Normal file
|
|
@ -0,0 +1,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).}
|
||||
Loading…
Add table
Add a link
Reference in a new issue