Browse Source

Prefer expressions without pi / e.

pull/1350/head
Siegfried Pammer 7 years ago
parent
commit
f0626009c1
  1. 24
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

24
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -958,19 +958,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -958,19 +958,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
expr = new PrimitiveExpression(constantValue);
}
}
if (expr == null && UseSpecialConstants) {
IType mathType;
if (isDouble)
mathType = compilation.FindType(typeof(Math));
else
mathType = compilation.FindType(new TopLevelTypeName("System", "MathF")).GetDefinition()
?? compilation.FindType(typeof(Math));
expr = TryExtractExpression(mathType, type, constantValue, "PI", isDouble)
?? TryExtractExpression(mathType, type, constantValue, "E", isDouble);
}
if (expr == null) {
(long num, long den) = isDouble
? FractionApprox((double)constantValue, MAX_DENOMINATOR)
@ -984,6 +972,18 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -984,6 +972,18 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
if (expr == null && UseSpecialConstants) {
IType mathType;
if (isDouble)
mathType = compilation.FindType(typeof(Math));
else
mathType = compilation.FindType(new TopLevelTypeName("System", "MathF")).GetDefinition()
?? compilation.FindType(typeof(Math));
expr = TryExtractExpression(mathType, type, constantValue, "PI", isDouble)
?? TryExtractExpression(mathType, type, constantValue, "E", isDouble);
}
if (expr == null)
expr = new PrimitiveExpression(constantValue);

Loading…
Cancel
Save