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

Add typecast expression #267

Merged
merged 2 commits into from
Aug 28, 2022
Merged

Add typecast expression #267

merged 2 commits into from
Aug 28, 2022

Conversation

kant2002
Copy link
Collaborator

@kant2002 kant2002 commented Aug 28, 2022

  • Make typecast explicit operation in the IR.
  • Due to fact that IDeclarationScope is inaccessible during Lower call. I put explicit typecasts during emit phase. That require subsequet changes in IExpression interface and possible in the ToIntermediate as well.
  • BinaryOperatorExpression.EmitConversion consult now CTypeSystem, I plan to remove that method altogether and replace it by insertion of corresponding TypeCastExpression when needed.
  • Changes in PrimitiveTypes test is artifact of typecast insertion. Once constant evaluation would start appearing, I expect changes in these area again. Same for FloatConstTest2, it will emit ldc.r4 becasue (float)1.5 would be folded directly to 1.5f

I did not close #246 with that PR because I need to invest in more tests for conversions, and rework of ArithmeticBinaryOperatorExpression to insert TypeCastExpression. Basically I expect during lowering following conversion IntConstant(1) + CharConstant('c') => IntegerConstant(1) + IntegerConstant(99), but introduction of TypeCastExpression is allow to work on that issue.

Closes: #243

- Make typecast explicit operation in the IR.
- Due to fact that `IDeclarationScope` is inaccessible during Lower call. I put explicit typecasts during emit phase. That require subsequet changes in `IExpression` interface and possible in the `ToIntermediate` as well.
- `BinaryOperatorExpression.EmitConversion` consult now `CTypeSystem`, I plan to remove that method altogether and replace it by insertion of corresponding `TypeCastExpression` when needed.
- Changes in `PrimitiveTypes` test is artifact of typecast insertion. Once constant evaluation would start appearing, I expect changes in these area again. Same for `FloatConstTest2`, it will emit ldc.r4 becasue `(float)1.5` would be folded directly to `1.5f`

I did not close ForNeVeR#246 with that PR because I need to invest in more tests for conversions, and rework of `ArithmeticBinaryOperatorExpression` to insert `TypeCastExpression`. Basically I expect during lowering following conversion `IntConstant(1) + CharConstant('c')` => `IntegerConstant(1) + IntegerConstant(99)`, but introduction of `TypeCastExpression` is allow to work on that issue.
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 1032228 into ForNeVeR:main Aug 28, 2022
@kant2002 kant2002 deleted the kant/typecast branch September 29, 2022 06:21
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.

Insert implicit casts during IR building Support for float type
2 participants