diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4288bb814883f5..57e03b38cd0442 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. | diff --git a/vlib/v/transformer/transformer.v b/vlib/v/transformer/transformer.v index dd844d09a04e75..6896d83d6f2aeb 100644 --- a/vlib/v/transformer/transformer.v +++ b/vlib/v/transformer/transformer.v @@ -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 {}