mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 14:02:19 +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 class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
try {
|
try {
|
||||||
string exeName = "testexe.exe";
|
string exeName = "HelloWorldMetal.exe";
|
||||||
if(args.Length ==1 ) {
|
if(args.Length ==1 ) {
|
||||||
exeName = args[0];
|
exeName = args[0];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,20 @@ using CPU = Indy.IL2CPU.Assembler.X86;
|
||||||
namespace Indy.IL2CPU.IL.X86 {
|
namespace Indy.IL2CPU.IL.X86 {
|
||||||
[OpCode(Code.Pop)]
|
[OpCode(Code.Pop)]
|
||||||
public class Pop: Op {
|
public class Pop: Op {
|
||||||
|
private bool mNeeded = true;
|
||||||
public Pop(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
public Pop(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
||||||
: base(aInstruction, 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() {
|
public override void Assemble() {
|
||||||
|
if (mNeeded) {
|
||||||
Pop("eax");
|
Pop("eax");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
||||||
for (int i = 0; i < LocalsCount; i++) {
|
for (int i = 0; i < LocalsCount; i++) {
|
||||||
Assembler.Add(new CPU.Pop("ebp"));
|
Assembler.Add(new CPU.Pop("ebp"));
|
||||||
}
|
}
|
||||||
Assembler.Add(new CPU.Ret(TotalArgsSize.ToString()));
|
Assembler.Add(new CPU.Ret(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,9 +175,13 @@ namespace Indy.IL2CPU {
|
||||||
xOp.Assembler = mAssembler;
|
xOp.Assembler = mAssembler;
|
||||||
xOp.Assemble();
|
xOp.Assemble();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (xCurrentMethod.IsPInvokeImpl) {
|
||||||
|
HandlePInvoke(xCurrentMethod, xMethodInfo);
|
||||||
} else {
|
} else {
|
||||||
mAssembler.Add(new Literal("; Method not being generated yet, as it's handled by an iCall"));
|
mAssembler.Add(new Literal("; Method not being generated yet, as it's handled by an iCall"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
xOp = GetOpFromType(mMap.MethodFooterOp, null, xMethodInfo);
|
xOp = GetOpFromType(mMap.MethodFooterOp, null, xMethodInfo);
|
||||||
xOp.Assembler = mAssembler;
|
xOp.Assembler = mAssembler;
|
||||||
xOp.Assemble();
|
xOp.Assemble();
|
||||||
|
|
@ -249,5 +253,15 @@ namespace Indy.IL2CPU {
|
||||||
mDebugLog(String.Format(aMessage, args));
|
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