| @@ -283,12 +283,12 @@ A trait dictionary without constraints (`Num<Int>`) is emitted as `static const` |
| 283 | 283 | |
| 284 | 284 | Generated C carries `#line` directives, so C compiler errors, sanitizer reports and debuggers (with `-g`) show `.til` files and lines instead of the generated file's. |
| 285 | 285 | |
| 286 | | −- **Where lines come from.** Core keeps a source span on each `let` (the innermost expression it was lowered for; a `let` pattern's bindings are at the pattern) and on each function (its definition, or the lambda or call site it was made for). Generated helpers, dictionaries and derived methods have none. The C backend turns a span into a line with the file's line index (`tilc_span`), and points at the file by the path the compiler was given (`<std/list.til>` for the embedded standard library). |
| 286 | +- **Where lines come from.** Core keeps a source span on each `let` (the innermost expression it was lowered for; a `let` pattern's bindings are at the pattern) and on each function (its definition, or the lambda or call site it was made for). Dictionaries and derived methods have none. The C backend turns a span into a line with the file's line index (`tilc_span`), and points at the file by the path the compiler was given (`<std/list.til>` for the embedded standard library). |
| 287 | 287 | - **Shape of the file.** Glue comes first and keeps its own C line numbers: the prelude, literals, prototypes, constant dictionaries, closure entries, `tl_entry` and `main`, then functions without a span. Functions with a span come last, each starting with `#line N "file"`, so no directive ever points back into the generated file. |
| 288 | 288 | - **One source line per statement.** C numbers the lines after `#line N` as `N`, `N + 1`, and so on, but all the C of one Core `let` (a call, its yield check, the unwinding path) belongs to one source line. So every further C line gets its own `#line N` (without the file). A directive is only written between whole lines: `TL_MUSTTAIL return f(...);` stays on one line, so no directive separates the attribute from its statement, and self tail calls (`goto entry`) are unaffected. The `dup`s, `drop`s and `release`s Perceus puts before a `let` are at its line (a `release` after a `match`'s projections is at the first line of the arm's code; a `reuse` is a `let`, at the construction's line); other code without a span (a `switch`, a `return`) keeps the line of the enclosing `let` or function, which is restored after a nested block. |
| 289 | 289 | - **Cost.** The C file grows (about +75% lines and +25% bytes for `tests/bench/html.til`); no difference in C compile time was measurable. |
| 290 | 290 | - **Turning it off.** Setting `TILC_NO_LINE_DIRECTIVES` (to any value) leaves the directives out, to read, grep or debug the generated C by its own lines. The library API takes the source files as an option (`tilc_codegen_c::generate(program, entry, Some(sources))`); `None` also leaves them out. |
| 291 | | −- **Tests.** `crates/tilc_codegen_c/tests/lines.rs` checks the line of every C line of a function, a C compiler error pointing at the `.til` call, and (with clang) a UBSan report from generated code pointing at the `.til` line. |
| 291 | +- **Tests.** `crates/tilc_codegen_c/tests/lines.rs` checks where the C lines of a function point (its prologue, a call and the yield check after it, a `musttail` call, a `release` and a `reuse`), a C compiler error pointing at the `.til` call, and (with clang) a UBSan report from generated code pointing at the `.til` line. |
| 292 | 292 | |
| 293 | 293 | **Not yet implemented:** |
| 294 | 294 | - several scheduler threads (ADR 0004, Revision 1); |