From 70d32885b156495e72e765865f98e401748054fc Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 1 May 2020 09:12:50 -0700 Subject: [PATCH] Fixes while working on ref for dictionary --- BeefLibs/corlib/src/Collections/Dictionary.bf | 20 ++++++++++--------- .../corlib/src/Collections/IEnumerator.bf | 1 - BeefLibs/corlib/src/Environment.bf | 4 ++-- BeefLibs/corlib/src/PropertyBag.bf | 2 +- BeefLibs/corlib/src/Type.bf | 8 +++----- IDE/mintest/minlib/src/System/Type.bf | 17 +++++++++++----- 6 files changed, 29 insertions(+), 23 deletions(-) diff --git a/BeefLibs/corlib/src/Collections/Dictionary.bf b/BeefLibs/corlib/src/Collections/Dictionary.bf index 9917ccf9..69dc57fd 100644 --- a/BeefLibs/corlib/src/Collections/Dictionary.bf +++ b/BeefLibs/corlib/src/Collections/Dictionary.bf @@ -13,9 +13,9 @@ namespace System.Collections using System.Diagnostics; using System.Diagnostics.Contracts; - public class Dictionary : ICollection<(TKey key, TValue* value)>, IEnumerable<(TKey key, TValue* value)> where TKey : IHashable //: IDictionary, IDictionary, IReadOnlyDictionary, ISerializable, IDeserializationCallback + public class Dictionary : 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 { @@ -112,7 +112,7 @@ namespace System.Collections public void Add(KeyValuePair kvPair) { - Insert(kvPair.key, *kvPair.value, true); + Insert(kvPair.key, kvPair.value, true); } public bool TryAdd(TKey key, TValue value) @@ -226,10 +226,12 @@ namespace System.Collections public bool Contains(KeyValuePair kvPair) { 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; } } @@ -242,9 +244,9 @@ namespace System.Collections repeat { - if(i >= index) + if (i >= index) { - kvPair[i]=(Keys.Current, &Values.CurrentRef); + kvPair[i] = (Keys.Current, Values.Current); } } while(Keys.MoveNext() && Values.MoveNext()); @@ -682,7 +684,7 @@ namespace System.Collections 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() diff --git a/BeefLibs/corlib/src/Collections/IEnumerator.bf b/BeefLibs/corlib/src/Collections/IEnumerator.bf index 0515a636..e1950341 100644 --- a/BeefLibs/corlib/src/Collections/IEnumerator.bf +++ b/BeefLibs/corlib/src/Collections/IEnumerator.bf @@ -5,7 +5,6 @@ namespace System.Collections interface IEnumerator { Result GetNext() mut; - T Current { get; }; } interface IResettable diff --git a/BeefLibs/corlib/src/Environment.bf b/BeefLibs/corlib/src/Environment.bf index 0ccc010a..cca20b79 100644 --- a/BeefLibs/corlib/src/Environment.bf +++ b/BeefLibs/corlib/src/Environment.bf @@ -120,7 +120,7 @@ namespace System for (let kv in envVars) { keys[idx] = kv.key; - values[idx] = *kv.value; + values[idx] = kv.value; ++idx; } @@ -158,7 +158,7 @@ namespace System for (let kv in envVars) { keys[idx] = kv.key; - values[idx] = *kv.value; + values[idx] = kv.value; ++idx; } diff --git a/BeefLibs/corlib/src/PropertyBag.bf b/BeefLibs/corlib/src/PropertyBag.bf index 04543eb7..f9864082 100644 --- a/BeefLibs/corlib/src/PropertyBag.bf +++ b/BeefLibs/corlib/src/PropertyBag.bf @@ -76,7 +76,7 @@ namespace System for (let kv in lhs.mProperties) { - Object lhsVal = *kv.value; + Object lhsVal = kv.value; Object rhsVal; if (!rhs.Get(kv.key, out rhsVal)) return false; diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index 6a7cece5..17bb02d8 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -570,16 +570,13 @@ namespace System.Reflection int16 mMethodDataCount; int16 mPropertyDataCount; int16 mFieldDataCount; - int16 mConstructorDataCount; void* mInterfaceDataPtr; MethodData* mMethodDataPtr; void* mPropertyDataPtr; FieldData* mFieldDataPtr; - void* mConstructorDataPtr; void** mCustomAttrDataPtr; - public override int32 InstanceSize { get @@ -873,7 +870,7 @@ namespace System.Reflection EnumDiscriminator = 0x0200 } - public enum MethodFlags : int16 + public enum MethodFlags : uint16 { MethodAccessMask = 0x0007, PrivateScope = 0x0000, // Member not referenceable. @@ -906,6 +903,7 @@ namespace System.Reflection StdCall = 0x1000, FastCall = 0x2000, ThisCall = 0x3000, // Purposely resuing StdCall|FastCall - Mutating = 0x4000 + Mutating = 0x4000, + Constructor = 0x8000, } } diff --git a/IDE/mintest/minlib/src/System/Type.bf b/IDE/mintest/minlib/src/System/Type.bf index 6a7cece5..503ab2ff 100644 --- a/IDE/mintest/minlib/src/System/Type.bf +++ b/IDE/mintest/minlib/src/System/Type.bf @@ -16,6 +16,7 @@ namespace System public class Type { extern const Type* sTypes; + extern static int32 sTypeCount; protected const BindingFlags cDefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; @@ -25,7 +26,15 @@ namespace System protected int32 mMemberDataOffset; protected TypeCode mTypeCode; protected uint8 mAlign; - + + public static TypeId TypeIdEnd + { + get + { + return (.)sTypeCount; + } + } + public int32 Size { get @@ -569,14 +578,12 @@ namespace System.Reflection uint8 mInterfaceCount; int16 mMethodDataCount; int16 mPropertyDataCount; - int16 mFieldDataCount; - int16 mConstructorDataCount; + int16 mFieldDataCount; void* mInterfaceDataPtr; MethodData* mMethodDataPtr; void* mPropertyDataPtr; - FieldData* mFieldDataPtr; - void* mConstructorDataPtr; + FieldData* mFieldDataPtr; void** mCustomAttrDataPtr;