Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Structs] Struct field access/copy codetrees #312

Merged
merged 30 commits into from
Jan 16, 2023

Conversation

jwajgelt
Copy link
Owner

Closes #301

@jwajgelt jwajgelt added the enhancement New feature or request label Jan 14, 2023
@jwajgelt jwajgelt added this to the Week 13 milestone Jan 14, 2023
@jwajgelt jwajgelt self-assigned this Jan 14, 2023
@jwajgelt jwajgelt force-pushed the jwajgelt/struct-access-codetrees branch from 5575734 to 0602784 Compare January 14, 2023 11:01
@jwajgelt jwajgelt force-pushed the jwajgelt/struct-access-codetrees branch from 0ad08c6 to 7d2fca4 Compare January 15, 2023 17:00
@jwajgelt jwajgelt changed the title [WIP][Structs] Struct field access/copy codetrees [Structs] Struct field access/copy codetrees Jan 15, 2023
Copy link
Collaborator

@Kaliciak Kaliciak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cool 😎, good job 💪

@Kaliciak Kaliciak linked an issue Jan 16, 2023 that may be closed by this pull request
jwajgelt and others added 2 commits January 16, 2023 23:02
Co-authored-by: Kaliciak <62755153+Kaliciak@users.noreply.github.com>
@jwajgelt jwajgelt merged commit e6a0796 into development Jan 16, 2023
aleksanderkatan added a commit that referenced this pull request Jan 18, 2023
* Add interfaces for week 12 (#266)

* Add new Ast nodes for structs

* Add StructDeclarations to NameResolutionResult

* Add null pointer literal value

* Add PointerDereference AST node

* Add allocation function to External functions

* Add argument to external new(value) function

* Make external new(value) function return a pointer type

* Add ast nodes extensions for pointers and structs (#278)

* Make lfs of assigment ast nod an expression (#283)

* [Fix] Override `Children` in new AST nodes (#276)

* [Struct][Pointer] Add unit tests for Type Checking (#282)

* Run tests on PRs to development branch (#284)

* [Struct][Pointer] Add syntax for structs and pointers (#279)

* Make LexicalGrammar static

* Add struct declaration to grammars

* Add struct value to grammars

* Add null literal to grammars

* Add pointer type to grammars

* Comment name-resolution and type-checking for now

* Add pointer dereference to grammars

* Add field access to grammars

* Add assignable to grammars

* Skip type-checking tests for structs and pointers

* [Struct][Pointer] Improvements in type checking unit tests (#288)

* Struct and pointer example programs (#286)

* Add example programs regarding structures.

* Add additional programs regarding structs

* Add example programs regarding pointers and structs

* Add example program

* Fix correct programs

* Provide test cases for example incorrect programs

* Fix test

* Add new example program

* Mark program as correct

* Add new programs regarding structs

* Add new example programs

* Fix invalid semicolons in programs

* Nit

Co-authored-by: Łukasz Selwa <49595727+LukaszSelwa@users.noreply.github.com>

Co-authored-by: Łukasz Selwa <49595727+LukaszSelwa@users.noreply.github.com>

* Calculate struct declarations in NameResolution (#291)

* Add base for upcoming struct handling

* Add function type recognision

* Add extensions and first test

* Add remaining tests, fixes

* Add missing tests, lint

* Refactor

* Update src/sernick/Ast/Analysis/NameResolution/NameResolutionAlgorithm.cs

Simplify list creation

Co-authored-by: Demian Banakh <dembanakh01@gmail.com>

* Update src/sernick/Ast/Analysis/NameResolution/NameResolutionAlgorithm.cs

Simplify switch

Co-authored-by: Demian Banakh <dembanakh01@gmail.com>

* Update src/sernick/Ast/Analysis/NameResolution/NameResolutionResult.cs

Change dict to readonly

Co-authored-by: Demian Banakh <dembanakh01@gmail.com>

* Simplify VisitVariableDeclaration

* Make methods into extension methods

* Add missing visit to VisitStructValue

* Make another method into extension method

* Add default comparators to Dictionaries

* Adjust to new Assignments

* Remove unnecessary diagnostic report

* Comment failing tests out again, lint

* Update NameResolutionError messages, uncomment test

* Add a test

* Fix failing test

Co-authored-by: Demian Banakh <dembanakh01@gmail.com>

* Fix unit tests for typechecking (#295)

- Create new nodes every time

* [Structs] Handle structs, pointer and "new(...)" in TypeChecking (#289)

Closes #269

Implements all tasks mentioned in #269

* [Structs] Improve VariableAccessMap (#311)

* Add new tests, modify old tests

* Replace CurrentFun with VisitorParam

* Change VisitVariableValue

* [Struct] Compute struct sizes and its fields' offsets, handle local struct variables (#314)

* [NameResolution] Remove unnecessary map (#316)

* Add new tests, modify old tests

* Replace CurrentFun with VisitorParam

* Change VisitVariableValue

* Remove from TypeChecking

* refactor ContainsControlFlowVisitor

* Remove from all places apart from NameResolution itself

* Remove from NameResolution

* Lint

* Update src/sernick/Ast/Analysis/ControlFlowGraph/ControlFlowAnalyzer.cs

simplify method

Co-authored-by: Kaliciak <62755153+Kaliciak@users.noreply.github.com>

Co-authored-by: Kaliciak <62755153+Kaliciak@users.noreply.github.com>

* [Structs] Improve TypeChecking (#310)

- Improve TypeChecking
  - report recursive struct definition
  - report missing fields
  - report duplicate fields declaration
  - report duplicate fields initialization
  - validate the left side of assignments 
    - check if it is a proper L-value
    - check if it is not an assignment to a field of const struct
- Enable Incorrect-Fronted-Tests
  - fix some tests
- Add more tests for TypeChecking

* Quick-fix: NameResolution does't report assignment to function parameter (#320)

* Move reporting assignment to function-parameter from name-resolution to type checking

* [Structs] Struct field access/copy codetrees (#312)

* Add StructPropertiesProcessor template

* correct namespace

* Implement StructPropertiesProcessor

* Throw diagnostic item in StructPropertiesProcessor

* Add size parameter to AddLocal

* Add struct helpers

* Add isStruct to AddLocal, implement GenerateVariableRead

* Correct indirect variable location exception message

* Linter fixes

* Add Size and InStruct in FunctionContext constructor

* More linter fixes

* post-merge fixes

* attempt at AST->CFG for struct assignments

* pull out helpers into separate file

* implement struct functionality in side effects analyzer

* fix build errors

* add rest of struct operations to AST->CFG

* format

* bug fixing

* more bugfixes

* use struct properties for field sizes

* fix field expr assignment

* Apply suggestions from code review

* Update ControlFlowAnalysisHelpers.cs

* Handle structs as arguments and return types (#319)

* Add StructPropertiesProcessor template

* correct namespace

* Implement StructPropertiesProcessor

* Throw diagnostic item in StructPropertiesProcessor

* Add size parameter to AddLocal

* Add struct helpers

* Add isStruct to AddLocal, implement GenerateVariableRead

* Correct indirect variable location exception message

* Linter fixes

* Add Size and InStruct in FunctionContext constructor

* More linter fixes

* post-merge fixes

* attempt at AST->CFG for struct assignments

* pull out helpers into separate file

* return struct address as first argument

* implement struct functionality in side effects analyzer

* fix build errors

* add rest of struct operations to AST->CFG

* format

* Add temporary for result struct

* Pass structs by value

* Set correct size for returned value

* Update src/sernick/Compiler/Function/FunctionContext.cs

Co-authored-by: Demian Banakh <dembanakh01@gmail.com>

* Fix prepends

* pass StructProperties to SideEffectsAnalyzer

Co-authored-by: Szymon Salabura <ssalabura@protonmail.com>
Co-authored-by: Juliusz Wajgelt <jwajgelt@gmail.com>
Co-authored-by: Demian Banakh <dembanakh01@gmail.com>

* Clean up frontend and backend

* Add VariableInitializationAnalyzer test

* Lint

* Remove const struct field access checking, remove development

* Remove extra Error

Co-authored-by: Łukasz Selwa <49595727+LukaszSelwa@users.noreply.github.com>
Co-authored-by: Szymon Salabura <56295611+ssalabura@users.noreply.github.com>
Co-authored-by: Demian Banakh <dembanakh01@gmail.com>
Co-authored-by: Kaliciak <62755153+Kaliciak@users.noreply.github.com>
Co-authored-by: Władysław Raczek <wsw.raczek@gmail.com>
Co-authored-by: Juliusz Wajgelt <49338439+jwajgelt@users.noreply.github.com>
Co-authored-by: Krzysztof Ziobro <86822080+krzysztofziobro@users.noreply.github.com>
Co-authored-by: Szymon Salabura <ssalabura@protonmail.com>
Co-authored-by: Juliusz Wajgelt <jwajgelt@gmail.com>
@dembanakh dembanakh deleted the jwajgelt/struct-access-codetrees branch January 24, 2023 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Structs] Implement structs functionality
3 participants