mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 08:58:00 +02:00
Initial const eval feature release
This commit is contained in:
parent
be929c3626
commit
ff1f8aff3f
27 changed files with 887 additions and 178 deletions
|
@ -260,6 +260,12 @@ namespace System
|
|||
|
||||
}
|
||||
|
||||
[AttributeUsage(.Method | .Invocation)]
|
||||
public struct ConstEvalAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[AttributeUsage(.Method /*2*/)]
|
||||
public struct IntrinsicAttribute : Attribute
|
||||
{
|
||||
|
|
|
@ -34,5 +34,21 @@ namespace System
|
|||
|
||||
[LinkName("#IsConstEval")]
|
||||
public static extern bool IsConstEval;
|
||||
|
||||
[LinkName("#IsBuilding")]
|
||||
public static extern bool IsBuilding;
|
||||
|
||||
[LinkName("#IsReified")]
|
||||
public static extern bool IsReified;
|
||||
|
||||
[LinkName("#CompileRev")]
|
||||
public static extern int32 CompileRev;
|
||||
|
||||
[ConstEval]
|
||||
public static void Assert(bool cond)
|
||||
{
|
||||
if (!cond)
|
||||
Runtime.FatalError("Assert failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,30 @@ namespace System.Reflection
|
|||
}
|
||||
}
|
||||
|
||||
public bool IsConst
|
||||
{
|
||||
get
|
||||
{
|
||||
return mFieldData.mFlags.HasFlag(.Const);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsStatic
|
||||
{
|
||||
get
|
||||
{
|
||||
return mFieldData.mFlags.HasFlag(.Static);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInstanceField
|
||||
{
|
||||
get
|
||||
{
|
||||
return !mFieldData.mFlags.HasFlag(.Static) && !mFieldData.mFlags.HasFlag(.Const);
|
||||
}
|
||||
}
|
||||
|
||||
public StringView Name
|
||||
{
|
||||
get
|
||||
|
@ -520,6 +544,14 @@ namespace System.Reflection
|
|||
}
|
||||
}
|
||||
|
||||
public int32 Index
|
||||
{
|
||||
get
|
||||
{
|
||||
return mIdx;
|
||||
}
|
||||
}
|
||||
|
||||
public Result<FieldInfo> GetNext() mut
|
||||
{
|
||||
if (!MoveNext())
|
||||
|
|
|
@ -454,14 +454,20 @@ namespace System
|
|||
{
|
||||
return (int32)mTypeId;
|
||||
}
|
||||
|
||||
|
||||
static extern Type ConstEval_GetTypeById(int32 typeId);
|
||||
|
||||
protected static Type GetType(TypeId typeId)
|
||||
{
|
||||
if (Compiler.IsConstEval)
|
||||
return ConstEval_GetTypeById((.)typeId);
|
||||
return sTypes[(int32)typeId];
|
||||
}
|
||||
|
||||
protected static Type GetType_(int32 typeId)
|
||||
{
|
||||
if (Compiler.IsConstEval)
|
||||
return ConstEval_GetTypeById(typeId);
|
||||
return sTypes[typeId];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue