mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Added IEnumerable<T> to sized arrays
This commit is contained in:
parent
7787efda7e
commit
458eb90752
2 changed files with 65 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
|||
using System.Collections;
|
||||
namespace System
|
||||
{
|
||||
[AlwaysInclude]
|
||||
struct SizedArray<T, CSize> where CSize : const int
|
||||
struct SizedArray<T, CSize> : IEnumerable<T> 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<T>
|
||||
{
|
||||
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<T> GetNext() mut
|
||||
{
|
||||
if (!MoveNext())
|
||||
return .Err;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue