60 lines
2.4 KiB
C#
Raw Normal View History

2021-09-20 18:20:01 +02:00
/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace dnSpy.Roslyn.Debugger.Formatters.CSharp {
static class Operators {
static readonly Dictionary<string, string[]> nameToOperatorName = new Dictionary<string, string[]>(StringComparer.Ordinal) {
{ "op_Addition", "operator +".Split(' ') },
{ "op_BitwiseAnd", "operator &".Split(' ') },
{ "op_BitwiseOr", "operator |".Split(' ') },
{ "op_Decrement", "operator --".Split(' ') },
{ "op_Division", "operator /".Split(' ') },
{ "op_Equality", "operator ==".Split(' ') },
{ "op_ExclusiveOr", "operator ^".Split(' ') },
{ "op_Explicit", "explicit operator".Split(' ') },
{ "op_False", "operator false".Split(' ') },
{ "op_GreaterThan", "operator >".Split(' ') },
{ "op_GreaterThanOrEqual", "operator >=".Split(' ') },
{ "op_Implicit", "implicit operator".Split(' ') },
{ "op_Increment", "operator ++".Split(' ') },
{ "op_Inequality", "operator !=".Split(' ') },
{ "op_LeftShift", "operator <<".Split(' ') },
{ "op_LessThan", "operator <".Split(' ') },
{ "op_LessThanOrEqual", "operator <=".Split(' ') },
{ "op_LogicalNot", "operator !".Split(' ') },
{ "op_Modulus", "operator %".Split(' ') },
{ "op_Multiply", "operator *".Split(' ') },
{ "op_OnesComplement", "operator ~".Split(' ') },
{ "op_RightShift", "operator >>".Split(' ') },
{ "op_Subtraction", "operator -".Split(' ') },
{ "op_True", "operator true".Split(' ') },
{ "op_UnaryNegation", "operator -".Split(' ') },
{ "op_UnaryPlus", "operator +".Split(' ') },
};
public static string[]? TryGetOperatorInfo(string name) {
nameToOperatorName.TryGetValue(name, out var list);
return list;
}
}
}