Browse Source

Use operator syntax when decompiling operator methods. Closes #103.

pull/112/head
Daniel Grunwald 15 years ago
parent
commit
2e4f0411cd
  1. 18
      ICSharpCode.Decompiler/Ast/AstBuilder.cs

18
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -594,7 +594,7 @@ namespace ICSharpCode.Decompiler.Ast @@ -594,7 +594,7 @@ namespace ICSharpCode.Decompiler.Ast
}
}
MethodDeclaration CreateMethod(MethodDefinition methodDef)
AttributedNode CreateMethod(MethodDefinition methodDef)
{
MethodDeclaration astMethod = new MethodDeclaration();
astMethod.AddAnnotation(methodDef);
@ -618,6 +618,22 @@ namespace ICSharpCode.Decompiler.Ast @@ -618,6 +618,22 @@ namespace ICSharpCode.Decompiler.Ast
}
}
}
// Convert MethodDeclaration to OperatorDeclaration if possible
if (methodDef.IsSpecialName && !methodDef.HasGenericParameters) {
OperatorType? opType = OperatorDeclaration.GetOperatorType(methodDef.Name);
if (opType.HasValue) {
OperatorDeclaration op = new OperatorDeclaration();
op.CopyAnnotationsFrom(astMethod);
op.ReturnType = astMethod.ReturnType.Detach();
op.OperatorType = opType.Value;
op.Modifiers = astMethod.Modifiers;
astMethod.Parameters.MoveTo(op.Parameters);
astMethod.Attributes.MoveTo(op.Attributes);
op.Body = astMethod.Body.Detach();
return op;
}
}
return astMethod;
}

Loading…
Cancel
Save