Skip to content

Commit

Permalink
(#354) CodeGen: emit additional type case before calling the cast ope…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
ForNeVeR committed Nov 5, 2023
1 parent fc71a17 commit ee109a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
IL_0000: ldc.i4.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call Cesium.Runtime.VoidPtr Cesium.Runtime.VoidPtr::op_Implicit(System.Void*)
IL_0009: call System.Int32 Test::Func(Cesium.Runtime.VoidPtr)
IL_000e: ret
IL_0004: conv.i
IL_0005: call Cesium.Runtime.VoidPtr Cesium.Runtime.VoidPtr::op_Implicit(System.Void*)
IL_000a: call System.Int32 Test::Func(Cesium.Runtime.VoidPtr)
IL_000f: ret

System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
IL_0000: ldc.i4.0
IL_0001: stloc.0
IL_0002: ldloca.s V_0
IL_0004: call Cesium.Runtime.VoidPtr Cesium.Runtime.VoidPtr::op_Implicit(System.Void*)
IL_0009: call System.Int32 Test::Func(Cesium.Runtime.VoidPtr)
IL_000e: ret
IL_0004: conv.i
IL_0005: call Cesium.Runtime.VoidPtr Cesium.Runtime.VoidPtr::op_Implicit(System.Void*)
IL_000a: call System.Int32 Test::Func(Cesium.Runtime.VoidPtr)
IL_000f: ret

System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
Expand Down
1 change: 1 addition & 0 deletions Cesium.CodeGen/Ir/Expressions/TypeCastExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void EmitTo(IEmitScope scope)
{
if (iType.UnderlyingType.FullName == TypeSystemEx.VoidPtrFullTypeName)
{
Add(OpCodes.Conv_I); // TODO: Should only emit if required.
scope.Method.Body.Instructions.Add(
Instruction.Create(OpCodes.Call, iType.GetConvertCall(scope.AssemblyContext)));
}
Expand Down

0 comments on commit ee109a1

Please sign in to comment.