Cosmos/source/Indy.IL2CPU.IL.X86/Sizeof.cs
2007-11-17 12:53:28 +00:00

23 lines
No EOL
732 B
C#

using System;
using System.IO;
using Mono.Cecil;
using Mono.Cecil.Cil;
using CPU = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.IL.X86 {
[OpCode(Code.Sizeof)]
public class Sizeof: Op {
private int mTheSize;
public Sizeof(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
: base(aInstruction, aMethodInfo) {
TypeReference xTypeRef = aInstruction.Operand as TypeReference;
if (xTypeRef == null) {
throw new Exception("Type not found!");}
Engine.GetTypeFieldInfo(Engine.GetDefinitionFromTypeReference(xTypeRef), out mTheSize);
}
public override void DoAssemble() {
new CPU.Pushd("0" + mTheSize.ToString("X") + "h");
Assembler.StackSizes.Push(4);
}
}
}