1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-18 16:10:26 +02:00

Fixes while working on ref for dictionary

This commit is contained in:
Brian Fiete 2020-05-01 09:12:50 -07:00
parent 191d0337d0
commit 70d32885b1
6 changed files with 29 additions and 23 deletions

View file

@ -13,9 +13,9 @@ namespace System.Collections
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
public class Dictionary<TKey, TValue> : ICollection<(TKey key, TValue* value)>, IEnumerable<(TKey key, TValue* value)> where TKey : IHashable //: IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>, ISerializable, IDeserializationCallback public class Dictionary<TKey, TValue> : ICollection<(TKey key, TValue value)>, IEnumerable<(TKey key, TValue value)> where TKey : IHashable
{ {
typealias KeyValuePair=(TKey key, TValue* value); typealias KeyValuePair=(TKey key, TValue value);
private struct Entry private struct Entry
{ {
@ -112,7 +112,7 @@ namespace System.Collections
public void Add(KeyValuePair kvPair) public void Add(KeyValuePair kvPair)
{ {
Insert(kvPair.key, *kvPair.value, true); Insert(kvPair.key, kvPair.value, true);
} }
public bool TryAdd(TKey key, TValue value) public bool TryAdd(TKey key, TValue value)
@ -226,10 +226,12 @@ namespace System.Collections
public bool Contains(KeyValuePair kvPair) public bool Contains(KeyValuePair kvPair)
{ {
TValue value; TValue value;
if(TryGetValue(kvPair.key, out value)) if (TryGetValue(kvPair.key, out value))
{
return value == kvPair.value;
}
else
{ {
return value == *kvPair.value;
}else{
return false; return false;
} }
} }
@ -242,9 +244,9 @@ namespace System.Collections
repeat repeat
{ {
if(i >= index) if (i >= index)
{ {
kvPair[i]=(Keys.Current, &Values.CurrentRef); kvPair[i] = (Keys.Current, Values.Current);
} }
} }
while(Keys.MoveNext() && Values.MoveNext()); while(Keys.MoveNext() && Values.MoveNext());
@ -682,7 +684,7 @@ namespace System.Collections
public KeyValuePair Current public KeyValuePair Current
{ {
get { return (mDictionary.mEntries[mCurrentIndex].mKey, &mDictionary.mEntries[mCurrentIndex].mValue); } get { return (mDictionary.mEntries[mCurrentIndex].mKey, mDictionary.mEntries[mCurrentIndex].mValue); }
} }
public void Dispose() public void Dispose()

View file

@ -5,7 +5,6 @@ namespace System.Collections
interface IEnumerator<T> interface IEnumerator<T>
{ {
Result<T> GetNext() mut; Result<T> GetNext() mut;
T Current { get; };
} }
interface IResettable interface IResettable

View file

@ -120,7 +120,7 @@ namespace System
for (let kv in envVars) for (let kv in envVars)
{ {
keys[idx] = kv.key; keys[idx] = kv.key;
values[idx] = *kv.value; values[idx] = kv.value;
++idx; ++idx;
} }
@ -158,7 +158,7 @@ namespace System
for (let kv in envVars) for (let kv in envVars)
{ {
keys[idx] = kv.key; keys[idx] = kv.key;
values[idx] = *kv.value; values[idx] = kv.value;
++idx; ++idx;
} }

View file

@ -76,7 +76,7 @@ namespace System
for (let kv in lhs.mProperties) for (let kv in lhs.mProperties)
{ {
Object lhsVal = *kv.value; Object lhsVal = kv.value;
Object rhsVal; Object rhsVal;
if (!rhs.Get(kv.key, out rhsVal)) if (!rhs.Get(kv.key, out rhsVal))
return false; return false;

View file

@ -570,16 +570,13 @@ namespace System.Reflection
int16 mMethodDataCount; int16 mMethodDataCount;
int16 mPropertyDataCount; int16 mPropertyDataCount;
int16 mFieldDataCount; int16 mFieldDataCount;
int16 mConstructorDataCount;
void* mInterfaceDataPtr; void* mInterfaceDataPtr;
MethodData* mMethodDataPtr; MethodData* mMethodDataPtr;
void* mPropertyDataPtr; void* mPropertyDataPtr;
FieldData* mFieldDataPtr; FieldData* mFieldDataPtr;
void* mConstructorDataPtr;
void** mCustomAttrDataPtr; void** mCustomAttrDataPtr;
public override int32 InstanceSize public override int32 InstanceSize
{ {
get get
@ -873,7 +870,7 @@ namespace System.Reflection
EnumDiscriminator = 0x0200 EnumDiscriminator = 0x0200
} }
public enum MethodFlags : int16 public enum MethodFlags : uint16
{ {
MethodAccessMask = 0x0007, MethodAccessMask = 0x0007,
PrivateScope = 0x0000, // Member not referenceable. PrivateScope = 0x0000, // Member not referenceable.
@ -906,6 +903,7 @@ namespace System.Reflection
StdCall = 0x1000, StdCall = 0x1000,
FastCall = 0x2000, FastCall = 0x2000,
ThisCall = 0x3000, // Purposely resuing StdCall|FastCall ThisCall = 0x3000, // Purposely resuing StdCall|FastCall
Mutating = 0x4000 Mutating = 0x4000,
Constructor = 0x8000,
} }
} }

View file

@ -16,6 +16,7 @@ namespace System
public class Type public class Type
{ {
extern const Type* sTypes; extern const Type* sTypes;
extern static int32 sTypeCount;
protected const BindingFlags cDefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; protected const BindingFlags cDefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
@ -26,6 +27,14 @@ namespace System
protected TypeCode mTypeCode; protected TypeCode mTypeCode;
protected uint8 mAlign; protected uint8 mAlign;
public static TypeId TypeIdEnd
{
get
{
return (.)sTypeCount;
}
}
public int32 Size public int32 Size
{ {
get get
@ -570,13 +579,11 @@ namespace System.Reflection
int16 mMethodDataCount; int16 mMethodDataCount;
int16 mPropertyDataCount; int16 mPropertyDataCount;
int16 mFieldDataCount; int16 mFieldDataCount;
int16 mConstructorDataCount;
void* mInterfaceDataPtr; void* mInterfaceDataPtr;
MethodData* mMethodDataPtr; MethodData* mMethodDataPtr;
void* mPropertyDataPtr; void* mPropertyDataPtr;
FieldData* mFieldDataPtr; FieldData* mFieldDataPtr;
void* mConstructorDataPtr;
void** mCustomAttrDataPtr; void** mCustomAttrDataPtr;