Add comparers for byte and char.

This commit is contained in:
Charles Betros 2018-10-10 18:02:57 -05:00
parent 04e45a7d00
commit 2ca4b2adb8
4 changed files with 60 additions and 29 deletions

View file

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>cosmos</RuntimeIdentifier> <RuntimeIdentifier>cosmos</RuntimeIdentifier>
<Profile>Bochs</Profile> <Profile>VMware</Profile>
<BinFormat>ELF</BinFormat> <BinFormat>ELF</BinFormat>
<StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled> <StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled>
<StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel> <StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel>
@ -19,11 +19,11 @@
<_DebugMode>Source</_DebugMode> <_DebugMode>Source</_DebugMode>
<_IgnoreDebugStubAttribute>False</_IgnoreDebugStubAttribute> <_IgnoreDebugStubAttribute>False</_IgnoreDebugStubAttribute>
<_PxeInterface>192.168.211.1</_PxeInterface> <_PxeInterface>192.168.211.1</_PxeInterface>
<Description>Use Bochs emulator to deploy and debug.</Description> <Description>Use VMware Player or Workstation to deploy and debug.</Description>
<Launch>Bochs</Launch> <Launch>VMware</Launch>
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort> <VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
<EnableGDB>True</EnableGDB> <EnableGDB>False</EnableGDB>
<StartCosmosGDB>True</StartCosmosGDB> <StartCosmosGDB>False</StartCosmosGDB>
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled> <VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
<VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel> <VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel>
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description> <VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
@ -36,6 +36,18 @@
<VMware_PxeInterface>192.168.211.1</VMware_PxeInterface> <VMware_PxeInterface>192.168.211.1</VMware_PxeInterface>
<VMware_EnableGDB>True</VMware_EnableGDB> <VMware_EnableGDB>True</VMware_EnableGDB>
<VMware_StartCosmosGDB>True</VMware_StartCosmosGDB> <VMware_StartCosmosGDB>True</VMware_StartCosmosGDB>
<Bochs_StackCorruptionDetectionEnabled>True</Bochs_StackCorruptionDetectionEnabled>
<Bochs_StackCorruptionDetectionLevel>MethodFooters</Bochs_StackCorruptionDetectionLevel>
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
<Bochs_Deployment>ISO</Bochs_Deployment>
<Bochs_Launch>Bochs</Bochs_Launch>
<Bochs_DebugEnabled>True</Bochs_DebugEnabled>
<Bochs_DebugMode>Source</Bochs_DebugMode>
<Bochs_IgnoreDebugStubAttribute>False</Bochs_IgnoreDebugStubAttribute>
<Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
<Bochs_PxeInterface>192.168.211.1</Bochs_PxeInterface>
<Bochs_EnableGDB>True</Bochs_EnableGDB>
<Bochs_StartCosmosGDB>True</Bochs_StartCosmosGDB>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -129,8 +129,8 @@ namespace ZLibrary.Machine
public ZConsoleScreen(ZMachine aMachine) public ZConsoleScreen(ZMachine aMachine)
{ {
_machine = aMachine; _machine = aMachine;
_consoles.Add(new VirtualConsole(19, 60, 1, 0)); _consoles.Add(new VirtualConsole(19, 70, 1, 0));
_consoles.Add(new VirtualConsole(1, 60, 0,0)); _consoles.Add(new VirtualConsole(1, 70, 0,0));
} }
public string ReadLine(string aInitialValue, int aTimeout, ushort timeoutRoutine, byte[] terminatingKeys, out byte terminator) public string ReadLine(string aInitialValue, int aTimeout, ushort timeoutRoutine, byte[] terminatingKeys, out byte terminator)

View file

@ -1,12 +1,13 @@
using System.Diagnostics; #define COSMOSDEBUG
using System.Diagnostics;
namespace ZLibrary namespace ZLibrary
{ {
public static class ZDebug public static class ZDebug
{ {
public static bool Enable = true; public static bool Enable = false;
#if COSMOS #if COSMOSDEBUG
private static Cosmos.Debug.Kernel.Debugger Debugger = new Cosmos.Debug.Kernel.Debugger("", ""); private static Cosmos.Debug.Kernel.Debugger Debugger = new Cosmos.Debug.Kernel.Debugger("", "");
#else #else
//private static StreamWriter writer = new StreamWriter("log.txt"); //private static StreamWriter writer = new StreamWriter("log.txt");
@ -20,7 +21,7 @@ namespace ZLibrary
Debugger.Send(s); Debugger.Send(s);
#else #else
//writer.WriteLine(s); //writer.WriteLine(s);
Debug.WriteLine(s); //Debug.WriteLine(s);
#endif #endif
} }
} }

View file

@ -31,19 +31,25 @@ namespace Cosmos.Core_Plugs.System.Collections.Generic
return new StringEqualityComparer(); return new StringEqualityComparer();
} }
if (aType == typeof(char))
{
return new CharEqualityComparer();
}
if (aType == typeof(int)) if (aType == typeof(int))
{ {
return new Int32EqualityComparer(); return new Int32EqualityComparer();
} }
if (aType == typeof(byte))
{
return new ByteEqualityComparer();
}
// TODO: Nullable<> // TODO: Nullable<>
// TODO: Enum (Comparer is special to avoid boxing) // TODO: Enum (Comparer is special to avoid boxing)
//else
//{
// xResult = new ObjectComparer<object>();
//}
mDebugger.Send($"No EqualityComparer for type {aType}"); mDebugger.Send($"No EqualityComparer for type {aType}");
return null; return null;
} }
@ -51,48 +57,60 @@ namespace Cosmos.Core_Plugs.System.Collections.Generic
public class StringComparer : Comparer<string> public class StringComparer : Comparer<string>
{ {
private readonly Debugger mDebugger = new Debugger("Core", "String Comparer");
public override int Compare(string x, string y) public override int Compare(string x, string y)
{ {
mDebugger.Send("StringComparer.Compare");
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public class StringEqualityComparer : EqualityComparer<string> public class StringEqualityComparer : EqualityComparer<string>
{ {
private readonly Debugger mDebugger = new Debugger("Core", "String Equality Comparer");
public override bool Equals(string x, string y) public override bool Equals(string x, string y)
{ {
mDebugger.Send("StringEqualityComparer.Equals");
return String.Equals(x, y); return String.Equals(x, y);
} }
public override int GetHashCode(string obj) public override int GetHashCode(string obj)
{ {
mDebugger.Send("StringEqualityComparer.GetHashCode");
return obj.GetHashCode(); return obj.GetHashCode();
} }
} }
public class CharEqualityComparer : EqualityComparer<char>
{
public override bool Equals(char x, char y)
{
return x == y;
}
public override int GetHashCode(char val)
{
return val.GetHashCode();
}
}
public class ByteEqualityComparer : EqualityComparer<byte>
{
public override bool Equals(byte x, byte y)
{
return x == y;
}
public override int GetHashCode(byte val)
{
return val.GetHashCode();
}
}
public class Int32EqualityComparer : EqualityComparer<int> public class Int32EqualityComparer : EqualityComparer<int>
{ {
private readonly Debugger mDebugger = new Debugger("Core", "Int32 Equality Comparer");
public override bool Equals(int x, int y) public override bool Equals(int x, int y)
{ {
mDebugger.Send("Int32EqualityComparer.Equals");
return x == y; return x == y;
} }
public override int GetHashCode(int val) public override int GetHashCode(int val)
{ {
mDebugger.Send("Int32EqualityComparer.GetHashCode");
return val.GetHashCode(); return val.GetHashCode();
} }
} }