Skip to content

Commit

Permalink
transformer: add support for instrumenting the V compiler with `-d tr…
Browse files Browse the repository at this point in the history
…ace_transformer`
  • Loading branch information
spytheman committed Sep 9, 2024
1 parent f002fd4 commit 234fb8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ a copy of the compiler rather than replacing it with `v self`.
| `trace_scanner` | Prints details about the recognized tokens. *Very* verbose. Use `./vnew -no-builtin -check-syntax file.v` later. |
| `trace_parser` | Prints details about parsed statements and expressions. Very verbose. Use it for panics in the parser. |
| `trace_checker` | Prints details about the statements being checked. Very verbose. Use it for panics in the checker. |
| `trace_transformer` | Prints details about the statements being transformed. Very verbose. Use it for panics in the transformer stage. |
| | |
| `trace_gen` | Prints all the strings written to the generated C file. Very verbose. |
| `trace_cgen_stmt` | Prints details about the statements that are being processed by cgen. |
Expand Down
4 changes: 4 additions & 0 deletions vlib/v/transformer/transformer.v
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ pub fn (mut t Transformer) check_safe_array(mut node ast.IndexExpr) {
}

pub fn (mut t Transformer) stmt(mut node ast.Stmt) ast.Stmt {
$if trace_transformer ? {
ntype := typeof(*node).replace('v.ast.', '')
eprintln('transformer: ${t.file.path:-50} | pos: ${node.pos.line_str():-39} | node: ${ntype:12} | ${node}')
}
match mut node {
ast.EmptyStmt {}
ast.NodeError {}
Expand Down

0 comments on commit 234fb8e

Please sign in to comment.