mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 04:48:53 +00:00
some small changes
This commit is contained in:
parent
5e3e24f163
commit
81e4fa33ff
4 changed files with 27 additions and 4 deletions
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue