113 lines
3.0 KiB
C#
113 lines
3.0 KiB
C#
using System;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal struct BinaryOperatorSignature : IEquatable<BinaryOperatorSignature>
|
|
{
|
|
public static BinaryOperatorSignature Error;
|
|
|
|
public readonly TypeSymbol LeftType;
|
|
|
|
public readonly TypeSymbol RightType;
|
|
|
|
public readonly TypeSymbol ReturnType;
|
|
|
|
public readonly MethodSymbol Method;
|
|
|
|
public readonly TypeSymbol ConstrainedToTypeOpt;
|
|
|
|
public readonly BinaryOperatorKind Kind;
|
|
|
|
public int? Priority;
|
|
|
|
public RefKind LeftRefKind
|
|
{
|
|
get
|
|
{
|
|
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((object)Method == null || Method.ParameterRefKinds.IsDefaultOrEmpty)
|
|
{
|
|
return (RefKind)0;
|
|
}
|
|
return Method.ParameterRefKinds[0];
|
|
}
|
|
}
|
|
|
|
public RefKind RightRefKind
|
|
{
|
|
get
|
|
{
|
|
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((object)Method == null || Method.ParameterRefKinds.IsDefaultOrEmpty)
|
|
{
|
|
return (RefKind)0;
|
|
}
|
|
return Method.ParameterRefKinds[1];
|
|
}
|
|
}
|
|
|
|
public BinaryOperatorSignature(BinaryOperatorKind kind, TypeSymbol leftType, TypeSymbol rightType, TypeSymbol returnType)
|
|
{
|
|
Kind = kind;
|
|
LeftType = leftType;
|
|
RightType = rightType;
|
|
ReturnType = returnType;
|
|
Method = null;
|
|
ConstrainedToTypeOpt = null;
|
|
Priority = null;
|
|
}
|
|
|
|
public BinaryOperatorSignature(BinaryOperatorKind kind, TypeSymbol leftType, TypeSymbol rightType, TypeSymbol returnType, MethodSymbol method, TypeSymbol constrainedToTypeOpt)
|
|
{
|
|
Kind = kind;
|
|
LeftType = leftType;
|
|
RightType = rightType;
|
|
ReturnType = returnType;
|
|
Method = method;
|
|
ConstrainedToTypeOpt = constrainedToTypeOpt;
|
|
Priority = null;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
|
|
return string.Format("kind: {0} leftType: {1} leftRefKind: {2} rightType: {3} rightRefKind: {4} return: {5}", new object[6] { Kind, LeftType, LeftRefKind, RightType, RightRefKind, ReturnType });
|
|
}
|
|
|
|
public bool Equals(BinaryOperatorSignature other)
|
|
{
|
|
if (Kind == other.Kind && TypeSymbol.Equals(LeftType, other.LeftType, (TypeCompareKind)0) && TypeSymbol.Equals(RightType, other.RightType, (TypeCompareKind)0) && TypeSymbol.Equals(ReturnType, other.ReturnType, (TypeCompareKind)0))
|
|
{
|
|
return Method == other.Method;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static bool operator ==(BinaryOperatorSignature x, BinaryOperatorSignature y)
|
|
{
|
|
return x.Equals(y);
|
|
}
|
|
|
|
public static bool operator !=(BinaryOperatorSignature x, BinaryOperatorSignature y)
|
|
{
|
|
return !x.Equals(y);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj is BinaryOperatorSignature)
|
|
{
|
|
return Equals((BinaryOperatorSignature)obj);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return Hash.Combine<TypeSymbol>(ReturnType, Hash.Combine<TypeSymbol>(LeftType, Hash.Combine<TypeSymbol>(RightType, Hash.Combine<MethodSymbol>(Method, (int)Kind))));
|
|
}
|
|
}
|