Cesium
Cesium copied to clipboard
More efficient constant conversion
From #157:
Current implementation is inefficient for constants. For example,
1 + 'b'
gives the following:IL_0000: ldc.i4 1 IL_0005: ldc.i4 98 IL_000a: conv.u1 IL_000b: conv.i4 IL_000c: add IL_000d: stloc V_0
As you see, the char is first converted from int to byte, and then back to int. This could be removed if we implement lowering to implicit casts - the cast expression would see that the operand is a constant and emit it immediately. But this would require a lot of refactoring. so I left it for another day.
Isn't issue is done when I add TypeCastExpression
? I belive this is expressible in the tree, so we can collapse constants.
We have a test (Cesium.CodeGen.Tests.CodeGenOperatorTests.AddIntToChar
) that confirms we still do the aforementioned conversion to byte
and to int
.
So, nope, this doesn't seem to be complete.