PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
223 stars 53 forks source link

feat(init): function support #1285

Closed mhasel closed 2 months ago

mhasel commented 3 months ago

Adds a lowering stage in the pipeline to rusty. A new AstVisitorMut trait is introduced, which basically copies the existing AstVisitor trait line for line, but with mutable borrows of visited items instead to allow for in-place manipulation/replacements.

Init functions are now lowered into the AST after the annotation-step. A new AST is created and a new index and annotations are created based on the updated AST.

Adds support for stack-local initializers in POUs (functions, VAR_TEMP)

Out of scope of this PR:

I will create tracking issues for these features once this PR has been reviewed and approved.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 89.86928% with 124 lines in your changes missing coverage. Please review.

Project coverage is 91.37%. Comparing base (be78df6) to head (7645b17). Report is 53 commits behind head on master.

Files with missing lines Patch % Lines
compiler/plc_ast/src/mut_visitor.rs 68.43% 107 Missing :warning:
src/lowering.rs 96.43% 15 Missing :warning:
compiler/plc_ast/src/ast.rs 0.00% 1 Missing :warning:
src/lowering/initializers.rs 99.57% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1285 +/- ## ========================================== + Coverage 91.11% 91.37% +0.26% ========================================== Files 153 159 +6 Lines 44816 48469 +3653 ========================================== + Hits 40833 44290 +3457 - Misses 3983 4179 +196 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.