Cosmos/source/Indy.IL2CPU.IL.X86/Stfld.cs
2007-09-22 09:44:20 +00:00

34 lines
No EOL
1 KiB
C#

using System;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
using CPU = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.IL.X86 {
[OpCode(Code.Stfld)]
public class Stfld: Op {
public Stfld(Instruction aInstruction, MethodInformation aMethodInfo)
: base(aInstruction, aMethodInfo) {
FieldDefinition xField = aInstruction.Operand as FieldDefinition;
if (xField == null) {
throw new Exception("Field not found!");
}
string xFieldId = xField.ToString();
TypeInformation.Field xTheField = aMethodInfo.TypeInfo.Fields[xFieldId];
RelativeAddress = xTheField.RelativeAddress;
FieldSize = xTheField.Size;
if (FieldSize != 4) {
throw new NotSupportedException("Field sizes other than 4 bytes are not supported yet!");
}
}
public readonly string RelativeAddress;
public readonly uint FieldSize;
public override void DoAssemble() {
Pop("eax"); // new value
Pop("ecx"); // instance
Move(Assembler, "[ecx " + RelativeAddress + "]", "eax");
}
}
}