mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
Fixed return on foreach
Fixed Array.Clear Minor changes
This commit is contained in:
parent
c8844527a5
commit
39ea6ee678
9 changed files with 48 additions and 29 deletions
|
|
@ -31,6 +31,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
{
|
{
|
||||||
int xFindMe = 3;
|
int xFindMe = 3;
|
||||||
int[] xArray = {1, 2, 3, 4, 5};
|
int[] xArray = {1, 2, 3, 4, 5};
|
||||||
|
|
||||||
foreach (int i in xArray)
|
foreach (int i in xArray)
|
||||||
{
|
{
|
||||||
if (i == xFindMe)
|
if (i == xFindMe)
|
||||||
|
|
@ -38,6 +39,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,6 +47,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
{
|
{
|
||||||
int xFindMe = 3;
|
int xFindMe = 3;
|
||||||
var xList = new List<int> {1, 2, 3, 4, 5};
|
var xList = new List<int> {1, 2, 3, 4, 5};
|
||||||
|
|
||||||
foreach (int i in xList)
|
foreach (int i in xList)
|
||||||
{
|
{
|
||||||
if (i == xFindMe)
|
if (i == xFindMe)
|
||||||
|
|
@ -52,6 +55,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +64,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
bool xResult = false;
|
bool xResult = false;
|
||||||
int xFindMe = 3;
|
int xFindMe = 3;
|
||||||
int[] xArray = {1, 2, 3, 4, 5};
|
int[] xArray = {1, 2, 3, 4, 5};
|
||||||
|
|
||||||
foreach (int i in xArray)
|
foreach (int i in xArray)
|
||||||
{
|
{
|
||||||
if (i == xFindMe)
|
if (i == xFindMe)
|
||||||
|
|
@ -67,7 +72,10 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
xResult = true;
|
xResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xResult = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xResult;
|
return xResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,6 +84,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
bool xResult = false;
|
bool xResult = false;
|
||||||
int xFindMe = 3;
|
int xFindMe = 3;
|
||||||
var xList = new List<int> {1, 2, 3, 4, 5};
|
var xList = new List<int> {1, 2, 3, 4, 5};
|
||||||
|
|
||||||
foreach (int i in xList)
|
foreach (int i in xList)
|
||||||
{
|
{
|
||||||
if (i == xFindMe)
|
if (i == xFindMe)
|
||||||
|
|
@ -83,7 +92,10 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp
|
||||||
xResult = true;
|
xResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xResult = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xResult;
|
return xResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using Cosmos.IL2CPU.Plugs;
|
using Cosmos.IL2CPU.Plugs;
|
||||||
using Cosmos.IL2CPU.Plugs.Assemblers;
|
|
||||||
using Cosmos.IL2CPU.Plugs.Assemblers.Array;
|
using Cosmos.IL2CPU.Plugs.Assemblers.Array;
|
||||||
|
|
||||||
namespace Cosmos.Core.Plugs.System
|
namespace Cosmos.Core.Plugs.System
|
||||||
|
|
@ -10,7 +9,7 @@ namespace Cosmos.Core.Plugs.System
|
||||||
{
|
{
|
||||||
|
|
||||||
[PlugMethod(Signature = "System_Void__System_Array_Clear_System_Array__System_Int32__System_Int32_")]
|
[PlugMethod(Signature = "System_Void__System_Array_Clear_System_Array__System_Int32__System_Int32_")]
|
||||||
public static unsafe void Clear(uint* aArray, uint aIndex, uint aLength)
|
public static unsafe void Clear([ObjectPointerAccess]uint* aArray, uint aIndex, uint aLength)
|
||||||
{
|
{
|
||||||
aArray = (uint*)aArray[0];
|
aArray = (uint*)aArray[0];
|
||||||
aArray += 3;
|
aArray += 3;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using System;
|
using XSharp.Compiler;
|
||||||
using CPU = Cosmos.Assembler.x86;
|
|
||||||
|
|
||||||
namespace Cosmos.IL2CPU.X86.IL
|
namespace Cosmos.IL2CPU.X86.IL
|
||||||
{
|
{
|
||||||
[Cosmos.IL2CPU.OpCode( ILOpCode.Code.Br )]
|
[OpCode(ILOpCode.Code.Br)]
|
||||||
public class Br : ILOp
|
public class Br : ILOp
|
||||||
{
|
{
|
||||||
public Br(Cosmos.Assembler.Assembler aAsmblr)
|
public Br(Cosmos.Assembler.Assembler aAsmblr)
|
||||||
|
|
@ -13,8 +12,9 @@ namespace Cosmos.IL2CPU.X86.IL
|
||||||
|
|
||||||
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
|
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
|
||||||
{
|
{
|
||||||
new CPU.Jump { DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode) };
|
XS.Jump(AppAssembler.TmpBranchLabel(aMethod, aOpCode));
|
||||||
}
|
//new CPU.Jump { DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode) };
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using XSharp.Compiler;
|
||||||
using CPUx86 = Cosmos.Assembler.x86;
|
using static XSharp.Compiler.XSRegisters;
|
||||||
|
|
||||||
namespace Cosmos.IL2CPU.X86.IL
|
namespace Cosmos.IL2CPU.X86.IL
|
||||||
{
|
{
|
||||||
[Cosmos.IL2CPU.OpCode(ILOpCode.Code.Dup)]
|
[OpCode(ILOpCode.Code.Dup)]
|
||||||
public class Dup : ILOp
|
public class Dup : ILOp
|
||||||
{
|
{
|
||||||
public Dup(Cosmos.Assembler.Assembler aAsmblr)
|
public Dup(Cosmos.Assembler.Assembler aAsmblr)
|
||||||
|
|
@ -19,7 +19,8 @@ namespace Cosmos.IL2CPU.X86.IL
|
||||||
|
|
||||||
for (int i = StackSize; i > 0; i--)
|
for (int i = StackSize; i > 0; i--)
|
||||||
{
|
{
|
||||||
new CPUx86.Push { DestinationReg = CPUx86.RegistersEnum.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)((StackSize - 1) * 4) };
|
XS.Push(ESP, true, (StackSize - 1) * 4);
|
||||||
|
//new CPUx86.Push { DestinationReg = CPUx86.RegistersEnum.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)((StackSize - 1) * 4) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using CPUx86 = Cosmos.Assembler.x86;
|
|
||||||
|
using Cosmos.IL2CPU.ILOpCodes;
|
||||||
|
using XSharp.Compiler;
|
||||||
|
|
||||||
namespace Cosmos.IL2CPU.X86.IL
|
namespace Cosmos.IL2CPU.X86.IL
|
||||||
{
|
{
|
||||||
[Cosmos.IL2CPU.OpCode( ILOpCode.Code.Leave )]
|
[OpCode(ILOpCode.Code.Leave)]
|
||||||
public class Leave : ILOp
|
public class Leave : ILOp
|
||||||
{
|
{
|
||||||
public Leave(Cosmos.Assembler.Assembler aAsmblr)
|
public Leave(Cosmos.Assembler.Assembler aAsmblr)
|
||||||
|
|
@ -15,13 +17,16 @@ namespace Cosmos.IL2CPU.X86.IL
|
||||||
{
|
{
|
||||||
// apparently, Roslyn changed something to the output. We now have to figure out where to jump to.
|
// apparently, Roslyn changed something to the output. We now have to figure out where to jump to.
|
||||||
if (aOpCode.CurrentExceptionHandler.Flags.HasFlag(ExceptionHandlingClauseOptions.Finally)
|
if (aOpCode.CurrentExceptionHandler.Flags.HasFlag(ExceptionHandlingClauseOptions.Finally)
|
||||||
&& aOpCode.CurrentExceptionHandler.HandlerOffset > aOpCode.Position)
|
&& aOpCode.CurrentExceptionHandler.HandlerOffset > aOpCode.Position
|
||||||
|
&& ((OpBranch)aOpCode).Value <= aOpCode.CurrentExceptionHandler.HandlerOffset + aOpCode.CurrentExceptionHandler.HandlerLength)
|
||||||
{
|
{
|
||||||
new CPUx86.Jump {DestinationLabel = AppAssembler.TmpPosLabel(aMethod, aOpCode.CurrentExceptionHandler.HandlerOffset)};
|
XS.Jump(AppAssembler.TmpPosLabel(aMethod, aOpCode.CurrentExceptionHandler.HandlerOffset));
|
||||||
|
//new CPUx86.Jump {DestinationLabel = AppAssembler.TmpPosLabel(aMethod, aOpCode.CurrentExceptionHandler.HandlerOffset + aOpCode.CurrentExceptionHandler.HandlerLength) };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new CPUx86.Jump {DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode)};
|
XS.Jump(AppAssembler.TmpBranchLabel(aMethod, aOpCode));
|
||||||
|
//new CPUx86.Jump {DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,12 +94,14 @@ namespace Cosmos.IL2CPU
|
||||||
protected static void Jump_Exception(MethodInfo aMethod)
|
protected static void Jump_Exception(MethodInfo aMethod)
|
||||||
{
|
{
|
||||||
// todo: port to numeric labels
|
// todo: port to numeric labels
|
||||||
new CPU.Jump { DestinationLabel = GetMethodLabel(aMethod) + AppAssembler.EndOfMethodLabelNameException };
|
XS.Jump (GetMethodLabel(aMethod) + AppAssembler.EndOfMethodLabelNameException);
|
||||||
|
//new CPU.Jump { DestinationLabel = GetMethodLabel(aMethod) + AppAssembler.EndOfMethodLabelNameException };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void Jump_End(MethodInfo aMethod)
|
protected static void Jump_End(MethodInfo aMethod)
|
||||||
{
|
{
|
||||||
new CPU.Jump { DestinationLabel = GetMethodLabel(aMethod) + AppAssembler.EndOfMethodLabelNameNormal };
|
XS.Jump(GetMethodLabel(aMethod) + AppAssembler.EndOfMethodLabelNameNormal);
|
||||||
|
//new CPU.Jump { DestinationLabel = GetMethodLabel(aMethod) + AppAssembler.EndOfMethodLabelNameNormal };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static uint GetStackCountForLocal(MethodInfo aMethod, LocalVariableInfo aField)
|
public static uint GetStackCountForLocal(MethodInfo aMethod, LocalVariableInfo aField)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue