public override TResult VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) { Debug.Assert(context.CurrentMethod == null); try { context.CurrentMethod = operatorDeclaration.Annotation <MethodDef>(); return(base.VisitOperatorDeclaration(operatorDeclaration, data)); } finally { context.CurrentMethod = null; } }
public virtual void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { StartNode(operatorDeclaration); var builder = operatorDeclaration.Annotation<MethodDebugInfoBuilder>(); if (builder != null) builder.StartPosition = writer.GetLocation(); WriteAttributes(operatorDeclaration.Attributes); WriteModifiers(operatorDeclaration.ModifierTokens); var oldRef = currentMethodReference; currentMethodReference = new object(); if (operatorDeclaration.OperatorType == OperatorType.Explicit) { WriteKeyword(OperatorDeclaration.ExplicitRole); } else if (operatorDeclaration.OperatorType == OperatorType.Implicit) { WriteKeyword(OperatorDeclaration.ImplicitRole); } else { operatorDeclaration.ReturnType.AcceptVisitor(this); } WriteKeywordIdentifier(OperatorDeclaration.OperatorKeywordRole); Space(); if (operatorDeclaration.OperatorType == OperatorType.Explicit || operatorDeclaration.OperatorType == OperatorType.Implicit) { operatorDeclaration.ReturnType.AcceptVisitor(this); } else { WriteTokenOperatorOrKeyword(OperatorDeclaration.GetToken(operatorDeclaration.OperatorType), OperatorDeclaration.GetRole(operatorDeclaration.OperatorType)); } Space(policy.SpaceBeforeMethodDeclarationParentheses); WriteCommaSeparatedListInParenthesis(operatorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses, CodeBracesRangeFlags.Parentheses); WriteMethodBody(operatorDeclaration.Body); if (builder != null) builder.EndPosition = writer.GetLocation(); currentMethodReference = oldRef; EndNode(operatorDeclaration); }