mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
33 lines
938 B
C#
33 lines
938 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Cosmos.IL2CPU.ILOpCodes;
|
|
using XSharp.Compiler;
|
|
using CPUx86 = Cosmos.Assembler.x86;
|
|
using static XSharp.Compiler.XSRegisters;
|
|
|
|
namespace Cosmos.IL2CPU.X86.IL
|
|
{
|
|
[OpCode(ILOpCode.Code.Ldloca)]
|
|
public class Ldloca : ILOp
|
|
{
|
|
public Ldloca(Assembler.Assembler aAsmblr)
|
|
: base(aAsmblr)
|
|
{
|
|
}
|
|
|
|
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
|
|
{
|
|
var xOpVar = (OpVar)aOpCode;
|
|
var xVar = aMethod.MethodBase.GetMethodBody().LocalVariables[xOpVar.Value];
|
|
var xEBPOffset = GetEBPOffsetForLocal(aMethod, xOpVar.Value);
|
|
xEBPOffset += (uint)(((int)GetStackCountForLocal(aMethod, xVar) - 1) * 4);
|
|
|
|
XS.Comment("Local type = " + xVar.LocalType);
|
|
XS.Comment("Local EBP offset = " + xEBPOffset);
|
|
|
|
XS.Set(EAX, EBP);
|
|
XS.Sub(EAX, xEBPOffset);
|
|
XS.Push(EAX);
|
|
}
|
|
}
|
|
}
|