some small changes

This commit is contained in:
mterwoord_cp 2007-09-05 15:35:56 +00:00
parent 5e3e24f163
commit 81e4fa33ff
4 changed files with 27 additions and 4 deletions

View file

@ -8,7 +8,7 @@ namespace IL2CPU {
public class Program {
public static void Main(string[] args) {
try {
string exeName = "testexe.exe";
string exeName = "HelloWorldMetal.exe";
if(args.Length ==1 ) {
exeName = args[0];
}

View file

@ -7,11 +7,20 @@ using CPU = Indy.IL2CPU.Assembler.X86;
namespace Indy.IL2CPU.IL.X86 {
[OpCode(Code.Pop)]
public class Pop: Op {
private bool mNeeded = true;
public Pop(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
: base(aInstruction, aMethodInfo) {
if (aInstruction.Previous != null &&
(aInstruction.Previous.OpCode.Code == Code.Call ||
aInstruction.Previous.OpCode.Code == Code.Calli ||
aInstruction.Previous.OpCode.Code == Code.Callvirt)) {
mNeeded = false;
}
}
public override void Assemble() {
Pop("eax");
if (mNeeded) {
Pop("eax");
}
}
}
}

View file

@ -31,7 +31,7 @@ namespace Indy.IL2CPU.IL.X86 {
for (int i = 0; i < LocalsCount; i++) {
Assembler.Add(new CPU.Pop("ebp"));
}
Assembler.Add(new CPU.Ret(TotalArgsSize.ToString()));
Assembler.Add(new CPU.Ret(""));
}
}
}

View file

@ -176,7 +176,11 @@ namespace Indy.IL2CPU {
xOp.Assemble();
}
} else {
mAssembler.Add(new Literal("; Method not being generated yet, as it's handled by an iCall"));
if (xCurrentMethod.IsPInvokeImpl) {
HandlePInvoke(xCurrentMethod, xMethodInfo);
} else {
mAssembler.Add(new Literal("; Method not being generated yet, as it's handled by an iCall"));
}
}
xOp = GetOpFromType(mMap.MethodFooterOp, null, xMethodInfo);
xOp.Assembler = mAssembler;
@ -249,5 +253,15 @@ namespace Indy.IL2CPU {
mDebugLog(String.Format(aMessage, args));
}
}
private void HandlePInvoke(MethodDefinition aMethod, MethodInformation aMethodInfo) {
mAssembler.Add(new Noop());
if(aMethodInfo.HasReturnValue) {
// mAssembler.Add(new Pushd("0"));
mAssembler.Add(new Pushd("eax"));
mAssembler.Add(new Move("eax", "0"));
}
}
}
}