diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/CSharp/ForeachLoopTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/CSharp/ForeachLoopTests.cs index 45a55ede8..2f6d08d18 100644 --- a/Tests/Cosmos.Compiler.Tests.Bcl/CSharp/ForeachLoopTests.cs +++ b/Tests/Cosmos.Compiler.Tests.Bcl/CSharp/ForeachLoopTests.cs @@ -31,6 +31,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp { int xFindMe = 3; int[] xArray = {1, 2, 3, 4, 5}; + foreach (int i in xArray) { if (i == xFindMe) @@ -38,6 +39,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp return true; } } + return false; } @@ -45,6 +47,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp { int xFindMe = 3; var xList = new List {1, 2, 3, 4, 5}; + foreach (int i in xList) { if (i == xFindMe) @@ -52,6 +55,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp return true; } } + return false; } @@ -60,6 +64,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp bool xResult = false; int xFindMe = 3; int[] xArray = {1, 2, 3, 4, 5}; + foreach (int i in xArray) { if (i == xFindMe) @@ -67,7 +72,10 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp xResult = true; break; } + + xResult = false; } + return xResult; } @@ -76,6 +84,7 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp bool xResult = false; int xFindMe = 3; var xList = new List {1, 2, 3, 4, 5}; + foreach (int i in xList) { if (i == xFindMe) @@ -83,7 +92,10 @@ namespace Cosmos.Compiler.Tests.Bcl.CSharp xResult = true; break; } + + xResult = false; } + return xResult; } } diff --git a/source/Cosmos.Core.Plugs/System/ArrayImpl.cs b/source/Cosmos.Core.Plugs/System/ArrayImpl.cs index ba33753e9..9c87dbcd7 100644 --- a/source/Cosmos.Core.Plugs/System/ArrayImpl.cs +++ b/source/Cosmos.Core.Plugs/System/ArrayImpl.cs @@ -1,6 +1,5 @@ using System; using Cosmos.IL2CPU.Plugs; -using Cosmos.IL2CPU.Plugs.Assemblers; using Cosmos.IL2CPU.Plugs.Assemblers.Array; 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_")] - 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 += 3; diff --git a/source/Cosmos.IL2CPU/ExceptionHelper.cs b/source/Cosmos.IL2CPU/ExceptionHelper.cs index 394b26bdf..a52f34c19 100644 --- a/source/Cosmos.IL2CPU/ExceptionHelper.cs +++ b/source/Cosmos.IL2CPU/ExceptionHelper.cs @@ -25,4 +25,4 @@ namespace Cosmos.IL2CPU { CurrentExceptionRef = typeof(ExceptionHelper).GetField("CurrentException"); } } -} \ No newline at end of file +} diff --git a/source/Cosmos.IL2CPU/IL/Br.cs b/source/Cosmos.IL2CPU/IL/Br.cs index 202eb46a4..3fb33b977 100644 --- a/source/Cosmos.IL2CPU/IL/Br.cs +++ b/source/Cosmos.IL2CPU/IL/Br.cs @@ -1,20 +1,20 @@ -using System; -using CPU = Cosmos.Assembler.x86; +using XSharp.Compiler; namespace Cosmos.IL2CPU.X86.IL { - [Cosmos.IL2CPU.OpCode( ILOpCode.Code.Br )] + [OpCode(ILOpCode.Code.Br)] public class Br : ILOp { - public Br( Cosmos.Assembler.Assembler aAsmblr ) - : base( aAsmblr ) + public Br(Cosmos.Assembler.Assembler aAsmblr) + : base(aAsmblr) { } - 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) }; } + } } diff --git a/source/Cosmos.IL2CPU/IL/Dup.cs b/source/Cosmos.IL2CPU/IL/Dup.cs index e3b4aa006..08f8d44e4 100644 --- a/source/Cosmos.IL2CPU/IL/Dup.cs +++ b/source/Cosmos.IL2CPU/IL/Dup.cs @@ -1,9 +1,9 @@ -using System; -using CPUx86 = Cosmos.Assembler.x86; +using XSharp.Compiler; +using static XSharp.Compiler.XSRegisters; namespace Cosmos.IL2CPU.X86.IL { - [Cosmos.IL2CPU.OpCode(ILOpCode.Code.Dup)] + [OpCode(ILOpCode.Code.Dup)] public class Dup : ILOp { public Dup(Cosmos.Assembler.Assembler aAsmblr) @@ -19,9 +19,10 @@ namespace Cosmos.IL2CPU.X86.IL 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) }; } } } -} \ No newline at end of file +} diff --git a/source/Cosmos.IL2CPU/IL/Leave.cs b/source/Cosmos.IL2CPU/IL/Leave.cs index 220ece9ac..ecbb9e539 100644 --- a/source/Cosmos.IL2CPU/IL/Leave.cs +++ b/source/Cosmos.IL2CPU/IL/Leave.cs @@ -1,27 +1,32 @@ -using System; using System.Reflection; -using CPUx86 = Cosmos.Assembler.x86; + +using Cosmos.IL2CPU.ILOpCodes; +using XSharp.Compiler; + namespace Cosmos.IL2CPU.X86.IL { - [Cosmos.IL2CPU.OpCode( ILOpCode.Code.Leave )] + [OpCode(ILOpCode.Code.Leave)] public class Leave : ILOp { - public Leave( Cosmos.Assembler.Assembler aAsmblr ) - : base( aAsmblr ) + public Leave(Cosmos.Assembler.Assembler aAsmblr) + : base(aAsmblr) { } - public override void Execute( MethodInfo aMethod, ILOpCode aOpCode ) + public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) { // apparently, Roslyn changed something to the output. We now have to figure out where to jump to. 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 { - new CPUx86.Jump {DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode)}; + XS.Jump(AppAssembler.TmpBranchLabel(aMethod, aOpCode)); + //new CPUx86.Jump {DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode)}; } } diff --git a/source/Cosmos.IL2CPU/IL/Ret.cs b/source/Cosmos.IL2CPU/IL/Ret.cs index 41b5fc330..40f85f221 100644 --- a/source/Cosmos.IL2CPU/IL/Ret.cs +++ b/source/Cosmos.IL2CPU/IL/Ret.cs @@ -18,4 +18,4 @@ namespace Cosmos.IL2CPU.X86.IL //XS.Jump(MethodFooterOp.EndOfMethodLabelNameNormal); } } -} \ No newline at end of file +} diff --git a/source/Cosmos.IL2CPU/ILOp.cs b/source/Cosmos.IL2CPU/ILOp.cs index 41764d7b3..4f928cab4 100644 --- a/source/Cosmos.IL2CPU/ILOp.cs +++ b/source/Cosmos.IL2CPU/ILOp.cs @@ -94,12 +94,14 @@ namespace Cosmos.IL2CPU protected static void Jump_Exception(MethodInfo aMethod) { // 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) { - 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) diff --git a/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs index 15f411e89..4309a600b 100644 --- a/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -160,7 +160,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing //SetDirectoryEntryData(xData); } - + public FatDirectoryEntry AddDirectoryEntry(string aName, DirectoryEntryTypeEnum aType) { Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.AddDirectoryEntry --");