[Patch] Node semantic pass and supporting code
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch seeks to address a couple of compilation bugs by adding an additional pass to the node system that performs semantic checks. Most importantly, some code from TGotoNode.pass_1 was moved to a new routine to help patch issue #32913 without causing regressions.
Some additional code had to be programmed in order to fully support this feature, including the presence of a new transient flags field for TNode and it descendants. The patches were split to the best of one's ability to keep the features separate, but there is a lot of overlap in the "firstpass" procedure of "compiler/pass_1.pas".
Steps to reproduce:
N/A
Additional information:
- "node_flags.patch" and "node_pass_semantic_base.patch" need to be applied together for the compiler to build.
- "node_pass_semantic_specific.patch" requires the other two patches and is optional, but addresses #32913 as well as pre-emptively minimising the chances of similar bugs from appearing (semantic checks that can raise errors are moved from "pass_1" to "pass_semantic".
- "Node Semantic Pass.pdf" is a design specification to explain the motivation behind the changes and how they were put together in much more depth.
Finally, in order to help offset the performance penalty of an additional pass, "firstpass" was refactored to replace recursive calls with a "goto" to a point near the start of the procedure. The subroutine's design make compiler-driven tail recursion difficult, wihle constructs that don't use "goto" were more difficult to follow. The performance gain is explained in the PDF.
Mantis conversion info:
- Mantis ID: 35857
- OS: Microsoft Windows
- OS Build: 10 Professional
- Build: r42445
- Platform: Cross-platform
- Version: 3.3.1
- Monitored by: » @ccrause (Christo Crause)