Sometimes I need to convert bool values into some kind of integral type(such as uint) like:
publicstaticintU(inty)=>y>0?1:0;
which currently generates (on SharpLab x64 Release)
C.U(Int32) L0000: testecx,ecx L0002: jg L0007 L0004: xoreax,eax L0006: ret L0007: moveax,0x1 L000c: ret
while
publicstaticboolG(inty)=>y>0;
becomes
C.G(Int32) L0000: testecx,ecx L0002: setg al L0005: movzxeax,al L0008: ret
I need both codes compiles into same code as G(that uses setg instruction instead of jg).
Proposal
By allowing conversion from bool to int like:
publicstaticintU(inty)=>(int)(y>0);
it can be compiled into
C.U(Int32) L0000: testecx,ecx L0002: setg al L0005: movzxeax,al L0008: ret
Sometimes I need to convert
boolvalues into some kind of integral type(such asuint) like:which currently generates (on SharpLab x64 Release)
while
becomes
I need both codes compiles into same code as G(that uses
setginstruction instead ofjg).Proposal
By allowing conversion from
booltointlike:it can be compiled into