// e.g. given the method void f() {...}, prints "void f" // for a cast operator #fn(Foo, #cast, #(...)) it prints "operator Foo" if requested private LNode PrintTypeAndName(bool isConstructor, bool isCastOperator = false, AttrStyle attrStyle = AttrStyle.IsDefinition, string eventKeywordOpt = null) { LNode retType = _n.Args[0], name = _n.Args[1]; var ifClause = GetIfClause(); if (retType.HasPAttrs()) { using (With(retType)) G.Verify(0 == PrintAttrs(StartStmt, AttrStyle.NoKeywordAttrs, 0, null, "return")); } G.Verify(0 == PrintAttrs(StartStmt, attrStyle, 0, ifClause)); if (eventKeywordOpt != null) { _out.Write(eventKeywordOpt, true); } if (_n.Name == S.Delegate) { _out.Write("delegate", true); _out.Space(); } if (isCastOperator) { _out.Write("operator", true); _out.Space(); PrintType(retType, ContinueExpr, Ambiguity.AllowPointer | Ambiguity.DropAttributes); } else { if (!isConstructor) { PrintType(retType, ContinueExpr, Ambiguity.AllowPointer | Ambiguity.DropAttributes); _out.Space(); } if (isConstructor && name.IsIdNamed(S.This)) { _out.Write("this", true); } else { PrintExpr(name, ContinueExpr, Ambiguity.InDefinitionName); } } return(ifClause); }
// e.g. given the method void f() {...}, prints "void f" // for a cast operator #fn(Foo, #cast, #(...)) it prints "operator Foo" if requested private void PrintTypeAndName(bool isConstructor, bool isCastOperator = false, AttrStyle attrStyle = AttrStyle.IsDefinition, string eventKeywordOpt = null) { LNode retType = _n.Args[0], name = _n.Args[1]; if (retType.HasPAttrs()) using (With(retType, StartStmt)) G.Verify(0 == PrintAttrs(AttrStyle.NoKeywordAttrs, null, "return")); G.Verify(0 == PrintAttrs(attrStyle)); var target = _n.Target; // #fn or #prop PrintTrivia(target, trailingTrivia: false); PrintTrivia(target, trailingTrivia: true); if (eventKeywordOpt != null) _out.Write(eventKeywordOpt, true); if (_name == S.Delegate) { _out.Write("delegate", true); _out.Space(); } if (isCastOperator) { _out.Write("operator", true); _out.Space(); PrintType(retType, ContinueExpr, Ambiguity.AllowPointer); } else { if (!isConstructor) { PrintType(retType, ContinueExpr, Ambiguity.AllowPointer | Ambiguity.NoParentheses); if (_out.LastCharWritten != '\n') _out.Space(); } if (isConstructor && name.IsIdNamed(S.This)) _out.Write("this", true); else PrintExpr(name, ContinueExpr, Ambiguity.InDefinitionName | Ambiguity.NoParentheses); } }
// e.g. given the method void f() {...}, prints "void f" // for a cast operator #fn(Foo, #cast, #(...)) it prints "operator Foo" if requested private void PrintTypeAndName(bool isConstructor, bool isCastOperator = false, AttrStyle attrStyle = AttrStyle.IsDefinition, string eventKeywordOpt = null) { LNode retType = _n.Args[0], name = _n.Args[1]; if (retType.HasPAttrs()) { using (With(retType, StartStmt)) G.Verify(0 == PrintAttrs(AttrStyle.NoKeywordAttrs, null, "return")); } G.Verify(0 == PrintAttrs(attrStyle)); var target = _n.Target; // #fn or #prop PrintTrivia(target, trailingTrivia: false); PrintTrivia(target, trailingTrivia: true); if (eventKeywordOpt != null) { _out.Write(eventKeywordOpt, true); } if (_name == S.Delegate) { _out.Write("delegate", true); _out.Space(); } if (isCastOperator) { _out.Write("operator", true); _out.Space(); PrintType(retType, ContinueExpr, Ambiguity.AllowPointer); } else { if (!isConstructor) { PrintType(retType, ContinueExpr, Ambiguity.AllowPointer | Ambiguity.NoParentheses); if (_out.LastCharWritten != '\n') { _out.Space(); } } if (isConstructor && name.IsIdNamed(S.This)) { _out.Write("this", true); } else { PrintExpr(name, ContinueExpr, Ambiguity.InDefinitionName | Ambiguity.NoParentheses); } } }
// e.g. given the method void f() {...}, prints "void f" // for a cast operator #fn(Foo, #cast, #(...)) it prints "operator Foo" if requested private LNode PrintTypeAndName(bool isConstructor, bool isCastOperator = false, AttrStyle attrStyle = AttrStyle.IsDefinition, string eventKeywordOpt = null) { LNode retType = _n.Args[0], name = _n.Args[1]; var ifClause = GetIfClause(); if (retType.HasPAttrs()) using (With(retType)) G.Verify(0 == PrintAttrs(StartStmt, AttrStyle.NoKeywordAttrs, 0, null, "return")); G.Verify(0 == PrintAttrs(StartStmt, attrStyle, 0, ifClause)); if (eventKeywordOpt != null) _out.Write(eventKeywordOpt, true); if (_n.Name == S.Delegate) { _out.Write("delegate", true); _out.Space(); } if (isCastOperator) { _out.Write("operator", true); _out.Space(); PrintType(retType, ContinueExpr, Ambiguity.AllowPointer | Ambiguity.DropAttributes); } else { if (!isConstructor) { PrintType(retType, ContinueExpr, Ambiguity.AllowPointer | Ambiguity.DropAttributes); _out.Space(); } if (isConstructor && name.IsIdNamed(S.This)) _out.Write("this", true); else PrintExpr(name, ContinueExpr, Ambiguity.InDefinitionName); } return ifClause; }