Removed unnecessary cast/unbox opcode for static members

このコミットが含まれているのは:
Sergio Pedri committed 2019-09-15 15:17:40 +02:00
1 親 f5093e21b8
コミット b84a5b5fe7
2ファイル変更
+15 -1

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -47,7 +47,7 @@ namespace ComputeSharp.Shaders.Translation.Models
// Load the argument (the object instance) and cast it to the right type
il.Emit(OpCodes.Ldarg_0);
il.Emit(DeclaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, DeclaringType);
if (!IsStatic) il.Emit(DeclaringType.IsValueType ? OpCodes.Unbox : OpCodes.Castclass, DeclaringType);
// Get the member value with the appropriate method
if (Property != null) il.EmitCall(OpCodes.Callvirt, Property.GetMethod, null);
+14
ファイルの表示
@@ -68,6 +68,20 @@ namespace ComputeSharp.Shaders.Translation.Models
/// </summary>
public string Name => (Field?.Name ?? Property?.Name) ?? throw new InvalidOperationException("Field and property can't both be null at the same time");
/// <summary>
/// Gets whether or not the current member is not an instance member
/// </summary>
public bool IsStatic
{
get
{
if (Field != null) return Field.IsStatic;
if (Property != null) return Property.GetMethod.IsStatic;
throw new InvalidOperationException("Field and property can't both be null at the same time");
}
}
/// <summary>
/// Converts a <see cref="FieldInfo"/> object into a <see cref="ReadableMember"/> instance
/// </summary>