v: add a new v.comptime stage COMPTIME, that runs after the checker (CHECK), and before the transformer (TRANSFORM), to simplify the work that later stages do #26068#26161
Conversation
|
I notice that you are currently moving the This is definitely a deliberate attempt. Is this possible? |
|
It's tough to separate these stages, but the compiler will be better for it in the end. For example: It would almost be better to check at least some of the comptime stuff before the type resolver, as there is no reason to resolve something that won't be included... If the parser took care of comptime However, that starts getting very complex very quickly. Later stages simply need to know what to keep and what to throw out. comptime section before checker does make sense, as the checker wouldn't be able to check stuff that's already been removed... same argument as for the parser - if it didn't bother to parse things in the It all comes down to which tradeoffs to make in memory vs performance. |
|
@kbkpbot |
|
the CI failures seem unrelated as it does fail in this commit too https://github.com/vlang/v/actions/runs/20527758186/job/58974092824 |
|
|
There is |
yes, that is fixed on master, but please do not rebase, since the CI is a bit clogged now. |
COMPTIME, that runs after the checker (CHECK), and before the transformer (TRANSFORM), to simplify the work that later stages do #26068
I'm still very new to the compiler so I'm not very confident in these changes. (feel free to push changes)
See #26068 for the issue talking about this change
The idea behind this is to move all the comptime logic in a new stage so no later stages need to manage this.
I tried to keep his PR minimal, by introducing the new stage and moving only 1 small comptime resolution from cgen to the new comptime stage.
The most of the code in the new comptime stage is a simplified version of the transformer. (without this code the PR is small)
@spytheman @kbkpbot and other contributors what do you think?