[SAOC 2025] Separate Semantic Routines from AST Nodes Weekly Update #3
Mohamed El Shorbagy
mohrizq895 at gmail.com
Mon Oct 6 18:01:51 UTC 2025
## Summary of Progress (September 29 - October 06)
This week, I further eliminated some semantic function calls
inside AST node files, and I am still working on some of the
previous issues I encountered during this process.
## What I Worked On
1. Moved `ClassReferenceExp.getFieldIndex` and
`StructLiteralExp.getFieldIndex` to `dmd/expressionsem.d` to
eliminate calls to `Type.size` (See [Merged
PR](https://github.com/dlang/dmd/pull/21931)).
2. Broke semantic dependency of `dmd/expression.d` on
`dmd/typesem.d` by moving `Expression.isLvalue` to
`dmd/expressionsem.d` to eliminate calls to `typesem.mutableOf`
and `typesem.unSharedOf` (See [Merged
PR](https://github.com/dlang/dmd/pull/21935)).
3. (WIP) Still figuring out the proper places to call
`oneMembers` and `computeIsTrivialAlias` (See
[PR](https://github.com/dlang/dmd/pull/21917/files)).
4. (WIP) Fixing the problem of casting
`TemplateDeclaration.instances` from `void *` to
`TemplateInstance[TemplateInstanceBox]` to break semantic
dependency of `dtemplate.d` on `templatesem.d`. There is an
issue, however, with an old bootstrap compiler (v2.079) when
doing the following:
```d
auto instances = new TemplateInstance[TemplateInstanceBox];
```
The error message is (as far as I remember): can only `new`
structs, classes and dynamic arrays, not
`TemplateInstance[TemplateInstanceBox]`.
Therefore, we did a workaround by using `root.aav.AssocArray`;
however, this implementation does not support `.remove` or
`.clear` operations that are needed by various functions in
`templatesem.d` and `traits.d` (See
[PR](https://github.com/dlang/dmd/pull/21937)).
More information about the Digitalmars-d
mailing list