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

Track type information for IR expressions #135

Merged
merged 3 commits into from
Jul 23, 2022

Conversation

gsomix
Copy link
Contributor

@gsomix gsomix commented Jul 19, 2022

For now pointer member access operator (#129) works only for lvalues, but not rvalues. E.g. this sample doesn't compile:

foo x;
(&x)->x = 42; // error

In #129 to find members by identifier we relied on GetValueType: unit -> TypeReference method implemented for all lvalues. I propose to extend this approach and track type information for all IR expressions:

foo x;
// `x` is lvalue expression of type `foo`
// `(&x)` is rvalue expression of type `foo*`
// `(&x)->x` is lvalue expression of type `int`
(&x)->x = 42; // works!
(42)->x = 42; // error: "Int32" has no member named "x"
  • Fix parser for expressions in parentheses
  • Implement GetConstantType for constants
  • Implement GetExpessionType for address-of operator (&) expression
  • Implement GetExpressionType for other unary expressions
  • Implement GetExpessionType for binary operator expressions See Implement usual arithmetic conversions #136
  • Implement GetExpressionType for other expressions
  • Fix pointer member access operator
  • Tests, tests, tests!
  • Add sample

@gsomix gsomix force-pushed the experimental/iexpression-type branch from f65806a to 39c35f4 Compare July 20, 2022 19:25
@gsomix gsomix marked this pull request as ready for review July 20, 2022 19:26
@gsomix gsomix mentioned this pull request Jul 20, 2022
2 tasks
@gsomix gsomix force-pushed the experimental/iexpression-type branch from 39c35f4 to 2d3edcf Compare July 20, 2022 20:41
@ForNeVeR ForNeVeR self-requested a review July 21, 2022 18:23
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

In general, I approve this plan. There are some small issues, though.

@gsomix gsomix requested a review from ForNeVeR July 23, 2022 10:00
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

Thanks!

@ForNeVeR ForNeVeR merged commit 1945ffe into ForNeVeR:main Jul 23, 2022
ForNeVeR pushed a commit that referenced this pull request Jul 23, 2022
@gsomix
Copy link
Contributor Author

gsomix commented Jul 23, 2022

Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants