1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-26 19:48:01 +02:00

Inference of tuple 'params T`

This commit is contained in:
Brian Fiete 2025-02-18 07:56:02 -08:00
parent f6d18c111f
commit 66d3581911
14 changed files with 721 additions and 75 deletions

View file

@ -334,6 +334,7 @@ namespace System
static extern void Comptime_EmitMethodEntry(int64 methodHandle, StringView text);
static extern void Comptime_EmitMethodExit(int64 methodHandle, StringView text);
static extern void Comptime_EmitMixin(StringView text);
static extern String Comptime_GetStringById(int32 id);
[Comptime(OnlyFromComptime=true)]
public static MethodBuilder CreateMethod(Type owner, StringView methodName, Type returnType, MethodFlags methodFlags)

View file

@ -1392,6 +1392,10 @@ namespace System
while (true)
{
int charsLeft = len - pos;
Reserve(mLength + charsLeft);
char8* ptr = Ptr;
int p = pos;
int i = pos;
while (pos < len)
@ -1418,7 +1422,8 @@ namespace System
}
}
Append(ch);
//Append(ch);
ptr[mLength++] = ch;
}
if (pos == len) break;
@ -1519,25 +1524,36 @@ namespace System
}
if (ch != '}') return FormatError();
pos++;
if (s == null)
s = scope:: String(128);
s.Clear();
IFormattable formattableArg = arg as IFormattable;
if (formattableArg != null)
formattableArg.ToString(s, fmt, provider);
else if (arg != null)
arg.ToString(s);
if ((provider == null) && (fmt.IsEmpty) && (width == 0))
{
if (arg == null)
s.Append("null");
else
arg.ToString(this);
}
else
s.Append("null");
if (fmt != (Object)"")
fmt.Clear();
if (s == null) s = String.Empty;
int pad = width - s.Length;
if (!leftJustify && pad > 0) Append(' ', pad);
Append(s);
if (leftJustify && pad > 0) Append(' ', pad);
{
if (s == null)
s = scope:: String(128);
s.Clear();
IFormattable formattableArg = arg as IFormattable;
if (formattableArg != null)
formattableArg.ToString(s, fmt, provider);
else if (arg != null)
arg.ToString(s);
else
s.Append("null");
if (fmt != (Object)"")
fmt.Clear();
if (s == null) s = String.Empty;
int pad = width - s.Length;
if (!leftJustify && pad > 0) Append(' ', pad);
Append(s);
if (leftJustify && pad > 0) Append(' ', pad);
}
}
return .Ok;
@ -2999,6 +3015,16 @@ namespace System
}
}
public static String GetById(int id)
{
if (Compiler.IsComptime)
{
return Compiler.[Friend]Comptime_GetStringById((.)id);
}
else
return sIdStringLiterals[id];
}
public struct RawEnumerator : IRefEnumerator<char8*>, IEnumerator<char8>
{
char8* mPtr;

View file

@ -650,6 +650,17 @@ namespace System
}
}
public virtual TypeInstance WrappedType
{
get
{
if (Compiler.IsComptime)
return Comptime_GetWrappedType((.)mTypeId) as TypeInstance;
return null;
}
}
public virtual TypeInstance.InterfaceEnumerator Interfaces
{
get
@ -754,6 +765,7 @@ namespace System
static extern int32 Comptime_Type_GetBaseType(int32 typeId);
static extern bool Comptime_Type_HasDeclaredMember(int32 typeId, int32 kind, StringView name);
static extern Type Comptime_GetTypeById(int32 typeId);
static extern Type Comptime_GetWrappedType(int32 typeId);
static extern Type Comptime_GetTypeByName(StringView name);
static extern String Comptime_Type_ToString(int32 typeId);
static extern String Comptime_TypeName_ToString(int32 typeId);
@ -864,6 +876,15 @@ namespace System
return type == this || (type.IsTypedPrimitive && type.UnderlyingType == this);
}
public virtual bool ImplementsInterface(Type checkInterface)
{
var wrappedType = WrappedType;
if (wrappedType != null)
return wrappedType.ImplementsInterface(checkInterface);
return false;
}
public virtual Result<FieldInfo> GetField(String fieldName)
{
return .Err;
@ -1247,6 +1268,19 @@ namespace System.Reflection
}
}
public override bool ImplementsInterface(Type checkInterface)
{
for (int ifaceIdx < mInterfaceCount)
{
if (mInterfaceDataPtr[ifaceIdx].mInterfaceType == checkInterface.TypeId)
return true;
}
var baseType = BaseType;
if (baseType != null)
return baseType.ImplementsInterface(checkInterface);
return false;
}
public override void GetFullName(String strBuffer)
{
if (mTypeFlags.HasFlag(TypeFlags.Tuple))
@ -1528,7 +1562,8 @@ namespace System.Reflection
public override void GetFullName(String strBuffer)
{
strBuffer.Append("const ");
switch (GetType(mValueType))
var type = GetType(mValueType);
switch (type)
{
case typeof(float):
(*(float*)&mValue).ToString(strBuffer);
@ -1543,6 +1578,10 @@ namespace System.Reflection
strBuffer.Append('\'');
case typeof(uint64), typeof(uint):
(*(uint64*)&mValue).ToString(strBuffer);
case typeof(String):
int32 stringId = *(int32*)&mValue;
String str = String.GetById(stringId);
str.Quote(strBuffer);
default:
mValue.ToString(strBuffer);
}