-
Notifications
You must be signed in to change notification settings - Fork 62
Support for Polymorphism #1474
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
Support for Polymorphism #1474
Conversation
A new type is added for every function block, class or interface this represents a vtable with the methods declared in the class. If a class extends another class, the parent's class is also included. If a class extends an interface, the interface is also included.
recursive validation is ignored for internals stdlib tests ignored
function blocks now contain an extra entry for the vtable standard lib functions now account for the exta entry
The `__vtable` field in classes and function blocks is assigned at init time to the correct global variable TODO: missing tests
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1474 +/- ##
==========================================
- Coverage 93.67% 91.29% -2.38%
==========================================
Files 166 174 +8
Lines 50097 57498 +7401
==========================================
+ Hits 46928 52493 +5565
- Misses 3169 5005 +1836 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Moves the `__body` field right after the "parent" vtable field if it exists. Also add introduce some further vtable specific codegen tests.
Move `__body` before local methods
Closing this in favor of #1493 since there were some "drastic" changes and starting from scratch was easier than cleaning up this branch |
This is the initial work to support polymorphism in function blocks/classes
The commit introduces a virtual table field on the top level function block in an inheritance chain which points to a globally declared vtable.
Each class will then have its own assigned vtable with method pointers to concrete implementations.
On initialization, the vtable for the concrete type is assigned to the variable.
This does break the function block calling convension but there was no way around it.
Steps to do:
Interfaces will be a different PR