Skip to content

Commit aa88c0f

Browse files
author
NielsDev
committed
castclass may do a peek instead of pop and push
1 parent b9b2d5a commit aa88c0f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

CSharpLLVM/CSharpLLVM.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<Compile Include="Generator\Instructions\Objects\EmitLdflda.cs" />
101101
<Compile Include="Generator\Instructions\Prefixes\EmitTail.cs" />
102102
<Compile Include="Generator\Instructions\Prefixes\EmitVolatile.cs" />
103-
<Compile Include="Generator\Instructions\Objects\EmitCastClass.cs" />
103+
<Compile Include="Generator\Instructions\Casting\EmitCastClass.cs" />
104104
<Compile Include="Generator\Instructions\Stack\EmitLdnull.cs" />
105105
<Compile Include="Generator\Instructions\StoreLoad\EmitStarg.cs" />
106106
<Compile Include="Generator\Instructions\StoreLoad\EmitLdarga.cs" />

CSharpLLVM/Generator/Instructions/Objects/EmitCastClass.cs renamed to CSharpLLVM/Generator/Instructions/Casting/EmitCastClass.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using CSharpLLVM.Stack;
66
using CSharpLLVM.Helpers;
77

8-
namespace CSharpLLVM.Generator.Instructions.Objects
8+
namespace CSharpLLVM.Generator.Instructions.Casting
99
{
1010
[InstructionHandler(Code.Castclass)]
1111
class EmitCastclass : ICodeEmitter
@@ -20,11 +20,11 @@ public void Emit(Instruction instruction, MethodContext context, BuilderRef buil
2020
{
2121
// Change type of top element.
2222
TypeDefinition dstType = (TypeDefinition)instruction.Operand;
23-
StackElement top = context.CurrentStack.Pop();
23+
StackElement top = context.CurrentStack.Peek();
2424

2525
TypeRef dstTypeRef = LLVM.PointerType(TypeHelper.GetTypeRefFromType(dstType), 0);
2626
top.ILType = new PointerType(dstType);
27-
if(TypeHelper.IsPointer(top))
27+
if (TypeHelper.IsPointer(top))
2828
{
2929
top.Value = LLVM.BuildPointerCast(builder, top.Value, top.Type, "castclass");
3030
}
@@ -33,8 +33,6 @@ public void Emit(Instruction instruction, MethodContext context, BuilderRef buil
3333
top.Value = LLVM.BuildIntToPtr(builder, top.Value, top.Type, "castclass");
3434
}
3535
top.Type = dstTypeRef;
36-
37-
context.CurrentStack.Push(top);
3836
}
3937
}
4038
}

0 commit comments

Comments
 (0)