Fixed return on foreach

Fixed Array.Clear
Minor changes
This commit is contained in:
José Pedro 2016-11-09 00:08:23 +00:00
parent c8844527a5
commit 39ea6ee678
9 changed files with 48 additions and 29 deletions

View file

@ -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<int> {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<int> {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;
}
}

View file

@ -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;

View file

@ -25,4 +25,4 @@ namespace Cosmos.IL2CPU {
CurrentExceptionRef = typeof(ExceptionHelper).GetField("CurrentException");
}
}
}
}

View file

@ -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) };
}
}
}

View file

@ -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) };
}
}
}
}
}

View file

@ -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)};
}
}

View file

@ -18,4 +18,4 @@ namespace Cosmos.IL2CPU.X86.IL
//XS.Jump(MethodFooterOp.EndOfMethodLabelNameNormal);
}
}
}
}

View file

@ -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)

View file

@ -160,7 +160,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing
//SetDirectoryEntryData(xData);
}
public FatDirectoryEntry AddDirectoryEntry(string aName, DirectoryEntryTypeEnum aType)
{
Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.AddDirectoryEntry --");