diff --git a/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs b/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs index 14725cee46..e430b8e3bf 100644 --- a/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs +++ b/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs @@ -26,7 +26,7 @@ protected static void CopyCompound(Transform transform, Context context, Operand var srcReg = transform.VirtualRegisters.AllocateNativeInteger(); var dstReg = transform.VirtualRegisters.AllocateNativeInteger(); - context.AppendInstruction(transform.AddInstruction, srcReg, sourceBase, source); + context.SetInstruction(transform.AddInstruction, srcReg, sourceBase, source); context.AppendInstruction(transform.AddInstruction, dstReg, destinationBase, destination); var tmp = transform.VirtualRegisters.AllocateNativeInteger(); diff --git a/Source/Mosa.Korlib/System.Collections.Generic/List.cs b/Source/Mosa.Korlib/System.Collections.Generic/List.cs index 8ee930a6e6..2c80012803 100644 --- a/Source/Mosa.Korlib/System.Collections.Generic/List.cs +++ b/Source/Mosa.Korlib/System.Collections.Generic/List.cs @@ -345,11 +345,11 @@ public void Insert(int index, T item) { EnsureCapacity(_size + 1); - _size++; - for (int i = index; i < _size; i++) + for (int i = _size; i > index; i--) { - _items[i] = _items[i + 1]; + _items[i] = _items[i - 1]; } + _size++; _items[index] = item; } diff --git a/Source/Mosa.UnitTests/Korlib/ListTests.cs b/Source/Mosa.UnitTests/Korlib/ListTests.cs index 88f5df2b86..09d5b6c109 100644 --- a/Source/Mosa.UnitTests/Korlib/ListTests.cs +++ b/Source/Mosa.UnitTests/Korlib/ListTests.cs @@ -29,7 +29,7 @@ public static bool Add1() list.Add(101); - return list.Count == 1; + return list[0] == 101 && list.Count == 1; } [MosaUnitTest] @@ -40,7 +40,77 @@ public static bool Add2() list.Add(101); list.Add(202); - return list.Count == 2; + return list[0] == 101 && list[1] == 202 && list.Count == 2; + } + + [MosaUnitTest] + public static bool Add4() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 3 && list[4] == 4 && list[5] == 5; + } + + [MosaUnitTest] + public static int Check0() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + return list[0]; + } + + [MosaUnitTest] + public static int Check1() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + return list[1]; + } + + [MosaUnitTest] + public static int Check2() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + return list[2]; + } + + [MosaUnitTest] + public static int Check4() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + return list[4]; } [MosaUnitTest] @@ -110,6 +180,150 @@ public static bool Remove2() return list.IndexOf(101) == 0; } + [MosaUnitTest] + public static bool RemoveAt0() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.RemoveAt(0); + + return list[0] == 1 && list[1] == 2 && list[2] == 3 && list[3] == 4; + } + + [MosaUnitTest] + public static bool RemoveAt1() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.RemoveAt(1); + + return list[0] == 0 && list[1] == 2 && list[2] == 3 && list[3] == 3; + } + + [MosaUnitTest] + public static bool RemoveAt3() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.RemoveAt(4); + + return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 4; + } + + [MosaUnitTest] + public static bool RemoveAt4() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.RemoveAt(4); + + return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 3; + } + + [MosaUnitTest] + public static bool Insert0() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.Insert(0, 99); + + return list[0] == 99 && list[1] == 0 && list[2] == 1 && list[3] == 2 && list[4] == 3 && list[5] == 4; + } + + [MosaUnitTest] + public static bool Insert1() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.Insert(1, 99); + + return list[0] == 0 && list[1] == 99 && list[2] == 1 && list[3] == 2 && list[4] == 3 && list[5] == 4; + } + + [MosaUnitTest] + public static bool Insert2() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.Insert(2, 99); + + return list[0] == 0 && list[1] == 1 && list[2] == 99 && list[3] == 2 && list[4] == 3 && list[5] == 4; + } + + [MosaUnitTest] + public static bool Insert3() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.Insert(3, 99); + + return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 99 && list[4] == 3 && list[5] == 4; + } + + [MosaUnitTest] + public static bool Insert4() + { + var list = new List(); + + list.Add(0); + list.Add(1); + list.Add(2); + list.Add(3); + list.Add(4); + + list.Insert(4, 99); + + return list[0] == 0 && list[1] == 1 && list[2] == 2 && list[3] == 3 && list[4] == 99 && list[5] == 4; + } + private static List Populate(int count) { var list = new List(); diff --git a/Tools/reduce-qemu.bat b/Tools/reduce-qemu.bat index 1d84eb44a2..191bae892b 100644 --- a/Tools/reduce-qemu.bat +++ b/Tools/reduce-qemu.bat @@ -1,7 +1,7 @@ -# curl https://qemu.weilnetz.de/w64/qemu-w64-setup-20230810.exe --output qemu-installer.exe -# del /S /Q qemu -# 7zip\7z.exe x -wqemu -oqemu -x!*.nsis -y qemu-installer.exe -# del /Q qemu-installer.exe +curl https://qemu.weilnetz.de/w64/2024/qemu-w64-setup-20240903.exe --output qemu-installer.exe +del /S /Q qemu +7zip\7z.exe x -wqemu -oqemu -x!*.nsis -y qemu-installer.exe +del /Q qemu-installer.exe del /S /Q qemu\share\icons del /S /Q qemu\share\doc @@ -75,5 +75,5 @@ del /S /Q qemu\lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis del /S /Q qemu\share\petalogix-*.dtb del /S /Q qemu\share\trace-events-all del /S /Q qemu\share\s390-ccw.img - - +del /S /Q qemu\share\edk2-riscv*.fd +del /S /Q qemu\share\hppa-firmware64.img