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

29 lines
No EOL
854 B
C#

using System;
using System.IO;
using Indy.IL2CPU.Assembler;
using Mono.Cecil;
using Mono.Cecil.Cil;
using CPU = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.IL.X86 {
[OpCode(Code.Ldtoken)]
public class Ldtoken: Op {
private string mTokenAddress;
public Ldtoken(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
: base(aInstruction, aMethodInfo) {
FieldDefinition xFieldDef = aInstruction.Operand as FieldDefinition;
if (xFieldDef == null) {
throw new Exception("Unsupported Token type!");
}
if (!xFieldDef.IsStatic) {
throw new Exception("Nonstatic field-backed tokens not supported yet!");
}
Engine.QueueStaticField(xFieldDef);
mTokenAddress=DataMember.GetStaticFieldName(xFieldDef);
}
public override void DoAssemble() {
Pushd(mTokenAddress);
}
}
}