-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add support for structs #203
Conversation
babd211
to
89420bf
Compare
89420bf
to
a598a81
Compare
Codecov Report
@@ Coverage Diff @@
## master #203 +/- ##
==========================================
- Coverage 94.26% 94.04% -0.22%
==========================================
Files 51 53 +2
Lines 3487 3679 +192
==========================================
+ Hits 3287 3460 +173
- Misses 200 219 +19
Continue to review full report at Codecov.
|
56f8ffb
to
515c565
Compare
dc80649
to
dca8f72
Compare
883bf53
to
b1af6a5
Compare
543aadc
to
9ac8ca6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Just one comment for now, will look over more thoroughly today.
let body = statement! { return_val := alloc(0) }; | ||
return function_definition! { | ||
function [function_name]() -> return_val { | ||
[body] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just return 0
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what we return here is a pointer address if I return 0
doesn't this end up as being wrongfully interpreted as the pointer address where the (non-existent) struct is being stored. As far as I understand the pointer address 0
actually stores the highest available pointer so we would end up pointing there, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand the pointer address 0 actually stores the highest available pointer so we would end up pointing there, no?
That's correct, but if it's an empty struct, we should be able to make the assumption that we'll never write or read to the address. Using alloc
here performs a read and write on the 0x00
address that has no effect , since we're allocating 0
bytes. If anything, we would use the avail
function to get the highest available memory pointer (which would return the same thing that alloc(0)
does). But again, since this pointer is never used, we could just simplify things and return 0
. If there's a situation where we write to an empty struct, then we have a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, that makes sense. I'll do the change and will put a comment on it to explain it.
9ac8ca6
to
5adc2af
Compare
37e2737
to
68a4024
Compare
02ae2e6
to
daf801e
Compare
What was wrong?
Fe should support structs to allow better user defined abstractions.
How was it fixed?
This PR lays the ground work for struct support as demonstrated with the following test.
There are still a few open todos which were moved into dedicated issues (see todos)
To-Do
OPTIONAL: Update Spec if applicable
Add entry to the release notes (may forgo for trivial changes)
Clean up commit history
Create issue for
pub
field support (it parses but isn't respected) -> Full support for pub qualifier on structs #236Create issue for storage assignment support -> Make storage assignments for structs work #235
Create issue for enforcing KW syntax for structs -> Enforce key value syntax to initialize structs #234