summary refs log tree commit diff stats
path: root/compiler/cbuilder.nim
Commit message (Collapse)AuthorAgeFilesLines
* use cbuilder for tuple/object generation (#24145)metagn2024-09-271-0/+121
based on #24127 Needs some tweaks to replace the other `struct` type generations, e.g. seqs, maybe by exposing `BaseTypeKind` as a parameter. C++ and codegenDecl etc seem like they are going to need attention. Also `Builder` should really be `distinct string` that one has to call `extract` on, but for this to be optimal in the current codegen, we would need something like: ```nim template buildInto(s: var string, builderName: untyped, body) = template `builderName`: untyped = Builder(s) body buildInto(result, builder): builder.add ... ``` but this could be a separate PR since it might not work with the compiler. The possibly-not-optimal alternative is to do: ```nim template build(builderName: untyped, body): string = var `builderName` = Builder("") body extract(`builderName`) result = build(builder): builder.add ... ``` where the compiler maybe copies the built string but shouldn't. --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>