mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-29 12:20:36 +00:00
37 lines
No EOL
1,023 B
C#
37 lines
No EOL
1,023 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);
|
|
}
|
|
VariableDefinition xVarDef = aInstruction.Operand as VariableDefinition;
|
|
if (xVarDef != null) {
|
|
SetLocalIndex(xVarDef.Index, aMethodInfo);
|
|
}
|
|
}
|
|
|
|
public string Address {
|
|
get {
|
|
return mAddress;
|
|
}
|
|
}
|
|
|
|
public sealed override void DoAssemble() {
|
|
Move(Assembler, "eax", "[" + mAddress + "]");
|
|
Push(Assembler, "eax");
|
|
}
|
|
}
|
|
} |