diff --git a/BeefLibs/corlib/src/SizedArray.bf b/BeefLibs/corlib/src/SizedArray.bf index 909417da..97e00637 100644 --- a/BeefLibs/corlib/src/SizedArray.bf +++ b/BeefLibs/corlib/src/SizedArray.bf @@ -1,7 +1,8 @@ +using System.Collections; namespace System { [AlwaysInclude] - struct SizedArray where CSize : const int + struct SizedArray : IEnumerable where CSize : const int { protected T[CSize] mVal; @@ -36,6 +37,66 @@ namespace System } strBuffer.Append(')'); } + + public Enumerator GetEnumerator() + { + return .((T[CSize])this); + } + + public struct Enumerator : IEnumerator + { + private T[CSize] mList; + private int mIndex; + private T* mCurrent; + + public this(T[CSize] list) + { + mList = list; + mIndex = 0; + mCurrent = null; + } + + public bool MoveNext() mut + { + if ((uint(mIndex) < uint(CSize))) + { + mCurrent = &mList[mIndex]; + mIndex++; + return true; + } + return MoveNextRare(); + } + + private bool MoveNextRare() mut + { + mIndex = CSize + 1; + mCurrent = null; + return false; + } + + public T Current + { + get + { + return *mCurrent; + } + } + + public int Index + { + get + { + return mIndex - 1; + } + } + + public Result GetNext() mut + { + if (!MoveNext()) + return .Err; + return Current; + } + } } } diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index dcff9f82..a6d084ea 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -603,6 +603,9 @@ bool BfGenericInferContext::InferGenericArguments(BfMethodInstance* methodInstan { InferGenericArgument(methodInstance, srcGenericArg, ifaceConstraint, BfIRValue()); auto typeInstance = srcGenericArg->ToTypeInstance(); + if (typeInstance == NULL) + typeInstance = mModule->GetWrappedStructType(srcGenericArg); + if (typeInstance != NULL) { for (auto ifaceEntry : typeInstance->mInterfaces)