Cosmos/source/Indy.IL2CPU.IL.X86/Ldloc.cs
2007-09-11 16:29:45 +00:00

33 lines
No EOL
841 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.Ldloc)]
public class Ldloc: Op {
private string mAddress;
protected void SetLocalIndex(int aIndex, MethodInformation aMethodInfo) {
mAddress = aMethodInfo.Locals[aIndex].VirtualAddress;
}
public Ldloc(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
: base(aInstruction, aMethodInfo) {
int xLocalIndex;
if (Int32.TryParse((aInstruction.Operand ?? "").ToString(), out xLocalIndex)) {
SetLocalIndex(xLocalIndex, aMethodInfo);
}
}
public string Address {
get {
return mAddress;
}
}
public sealed override void Assemble() {
Push("eax");
Move("eax", "[" + mAddress + "]");
}
}
}