Skip to content

Commit 2ca4b2a

Browse files
committed
Add comparers for byte and char.
1 parent 04e45a7 commit 2ca4b2a

File tree

4 files changed

+60
-29
lines changed

4 files changed

+60
-29
lines changed

Demos/ZMachine/ZKernel/ZKernel.csproj

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.0</TargetFramework>
55
<RuntimeIdentifier>cosmos</RuntimeIdentifier>
6-
<Profile>Bochs</Profile>
6+
<Profile>VMware</Profile>
77
<BinFormat>ELF</BinFormat>
88
<StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled>
99
<StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel>
@@ -19,11 +19,11 @@
1919
<_DebugMode>Source</_DebugMode>
2020
<_IgnoreDebugStubAttribute>False</_IgnoreDebugStubAttribute>
2121
<_PxeInterface>192.168.211.1</_PxeInterface>
22-
<Description>Use Bochs emulator to deploy and debug.</Description>
23-
<Launch>Bochs</Launch>
22+
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
23+
<Launch>VMware</Launch>
2424
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
25-
<EnableGDB>True</EnableGDB>
26-
<StartCosmosGDB>True</StartCosmosGDB>
25+
<EnableGDB>False</EnableGDB>
26+
<StartCosmosGDB>False</StartCosmosGDB>
2727
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
2828
<VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel>
2929
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
@@ -36,6 +36,18 @@
3636
<VMware_PxeInterface>192.168.211.1</VMware_PxeInterface>
3737
<VMware_EnableGDB>True</VMware_EnableGDB>
3838
<VMware_StartCosmosGDB>True</VMware_StartCosmosGDB>
39+
<Bochs_StackCorruptionDetectionEnabled>True</Bochs_StackCorruptionDetectionEnabled>
40+
<Bochs_StackCorruptionDetectionLevel>MethodFooters</Bochs_StackCorruptionDetectionLevel>
41+
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
42+
<Bochs_Deployment>ISO</Bochs_Deployment>
43+
<Bochs_Launch>Bochs</Bochs_Launch>
44+
<Bochs_DebugEnabled>True</Bochs_DebugEnabled>
45+
<Bochs_DebugMode>Source</Bochs_DebugMode>
46+
<Bochs_IgnoreDebugStubAttribute>False</Bochs_IgnoreDebugStubAttribute>
47+
<Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
48+
<Bochs_PxeInterface>192.168.211.1</Bochs_PxeInterface>
49+
<Bochs_EnableGDB>True</Bochs_EnableGDB>
50+
<Bochs_StartCosmosGDB>True</Bochs_StartCosmosGDB>
3951
</PropertyGroup>
4052

4153
<ItemGroup>

Demos/ZMachine/ZLibrary/Machine/ZConsoleScreen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ public class ZConsoleScreen : IZScreen
129129
public ZConsoleScreen(ZMachine aMachine)
130130
{
131131
_machine = aMachine;
132-
_consoles.Add(new VirtualConsole(19, 60, 1, 0));
133-
_consoles.Add(new VirtualConsole(1, 60, 0,0));
132+
_consoles.Add(new VirtualConsole(19, 70, 1, 0));
133+
_consoles.Add(new VirtualConsole(1, 70, 0,0));
134134
}
135135

136136
public string ReadLine(string aInitialValue, int aTimeout, ushort timeoutRoutine, byte[] terminatingKeys, out byte terminator)

Demos/ZMachine/ZLibrary/ZDebug.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using System.Diagnostics;
1+
#define COSMOSDEBUG
2+
using System.Diagnostics;
23

34
namespace ZLibrary
45
{
56
public static class ZDebug
67
{
7-
public static bool Enable = true;
8+
public static bool Enable = false;
89

9-
#if COSMOS
10+
#if COSMOSDEBUG
1011
private static Cosmos.Debug.Kernel.Debugger Debugger = new Cosmos.Debug.Kernel.Debugger("", "");
1112
#else
1213
//private static StreamWriter writer = new StreamWriter("log.txt");
@@ -20,7 +21,7 @@ public static void Output(string s)
2021
Debugger.Send(s);
2122
#else
2223
//writer.WriteLine(s);
23-
Debug.WriteLine(s);
24+
//Debug.WriteLine(s);
2425
#endif
2526
}
2627
}

source/Cosmos.Core_Plugs/System/Collections/Generic/ComparerHelpersImpl.cs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,68 +31,86 @@ public static object CreateDefaultEqualityComparer(Type aType)
3131
return new StringEqualityComparer();
3232
}
3333

34+
if (aType == typeof(char))
35+
{
36+
return new CharEqualityComparer();
37+
}
38+
3439
if (aType == typeof(int))
3540
{
3641
return new Int32EqualityComparer();
3742
}
3843

44+
if (aType == typeof(byte))
45+
{
46+
return new ByteEqualityComparer();
47+
}
48+
3949
// TODO: Nullable<>
4050

4151
// TODO: Enum (Comparer is special to avoid boxing)
4252

43-
//else
44-
//{
45-
// xResult = new ObjectComparer<object>();
46-
//}
4753
mDebugger.Send($"No EqualityComparer for type {aType}");
4854
return null;
4955
}
5056
}
5157

5258
public class StringComparer : Comparer<string>
5359
{
54-
private readonly Debugger mDebugger = new Debugger("Core", "String Comparer");
55-
5660
public override int Compare(string x, string y)
5761
{
58-
mDebugger.Send("StringComparer.Compare");
59-
6062
throw new NotImplementedException();
6163
}
6264
}
6365

6466
public class StringEqualityComparer : EqualityComparer<string>
6567
{
66-
private readonly Debugger mDebugger = new Debugger("Core", "String Equality Comparer");
67-
6868
public override bool Equals(string x, string y)
6969
{
70-
mDebugger.Send("StringEqualityComparer.Equals");
7170
return String.Equals(x, y);
7271
}
7372

7473
public override int GetHashCode(string obj)
7574
{
76-
mDebugger.Send("StringEqualityComparer.GetHashCode");
77-
7875
return obj.GetHashCode();
7976
}
8077
}
8178

82-
public class Int32EqualityComparer : EqualityComparer<int>
79+
public class CharEqualityComparer : EqualityComparer<char>
80+
{
81+
public override bool Equals(char x, char y)
82+
{
83+
return x == y;
84+
}
85+
86+
public override int GetHashCode(char val)
87+
{
88+
return val.GetHashCode();
89+
}
90+
}
91+
92+
public class ByteEqualityComparer : EqualityComparer<byte>
8393
{
84-
private readonly Debugger mDebugger = new Debugger("Core", "Int32 Equality Comparer");
94+
public override bool Equals(byte x, byte y)
95+
{
96+
return x == y;
97+
}
8598

99+
public override int GetHashCode(byte val)
100+
{
101+
return val.GetHashCode();
102+
}
103+
}
104+
105+
public class Int32EqualityComparer : EqualityComparer<int>
106+
{
86107
public override bool Equals(int x, int y)
87108
{
88-
mDebugger.Send("Int32EqualityComparer.Equals");
89109
return x == y;
90110
}
91111

92112
public override int GetHashCode(int val)
93113
{
94-
mDebugger.Send("Int32EqualityComparer.GetHashCode");
95-
96114
return val.GetHashCode();
97115
}
98116
}

0 commit comments

Comments
 (0)