/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

http://github.com/icsharpcode/ILSpy · C# · 3023 lines · 13 code · 3 blank · 3007 comment · 0 complexity · e098561aafdc0914575cd1308fe85882 MD5 · raw file

  1. // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
  2. // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
  3. using System;
  4. using System.Linq;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Globalization;
  9. using System.Text;
  10. using ICSharpCode.NRefactory.VB.Ast;
  11. using ICSharpCode.NRefactory.VB.Parser;
  12. using ICSharpCode.NRefactory.VB.Visitors;
  13. namespace ICSharpCode.NRefactory.VB.PrettyPrinter
  14. {
  15. // public sealed class VBNetOutputVisitor : NodeTrackingAstVisitor, IOutputDomVisitor
  16. // {
  17. // Errors errors = new Errors();
  18. // VBNetOutputFormatter outputFormatter;
  19. // VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions();
  20. // TypeDeclaration currentType;
  21. //
  22. // Stack<int> exitTokenStack = new Stack<int>();
  23. //
  24. // public string Text {
  25. // get {
  26. // return outputFormatter.Text;
  27. // }
  28. // }
  29. //
  30. // public Errors Errors {
  31. // get {
  32. // return errors;
  33. // }
  34. // }
  35. //
  36. // AbstractPrettyPrintOptions IOutputDomVisitor.Options {
  37. // get { return prettyPrintOptions; }
  38. // }
  39. //
  40. // public VBNetPrettyPrintOptions Options {
  41. // get { return prettyPrintOptions; }
  42. // }
  43. //
  44. // public IOutputFormatter OutputFormatter {
  45. // get {
  46. // return outputFormatter;
  47. // }
  48. // }
  49. //
  50. // public VBNetOutputVisitor()
  51. // {
  52. // outputFormatter = new VBNetOutputFormatter(prettyPrintOptions);
  53. // }
  54. //
  55. // public event Action<INode> BeforeNodeVisit;
  56. // public event Action<INode> AfterNodeVisit;
  57. //
  58. // protected override void BeginVisit(INode node)
  59. // {
  60. // if (BeforeNodeVisit != null) {
  61. // BeforeNodeVisit(node);
  62. // }
  63. // base.BeginVisit(node);
  64. // }
  65. //
  66. // protected override void EndVisit(INode node)
  67. // {
  68. // base.EndVisit(node);
  69. // if (AfterNodeVisit != null) {
  70. // AfterNodeVisit(node);
  71. // }
  72. // }
  73. //
  74. // object TrackedVisit(INode node, object data)
  75. // {
  76. // return node.AcceptVisitor(this, data);
  77. // }
  78. //
  79. // void Error(string text, Location position)
  80. // {
  81. // errors.Error(position.Line, position.Column, text);
  82. // }
  83. //
  84. // void UnsupportedNode(INode node)
  85. // {
  86. // Error(node.GetType().Name + " is unsupported", node.StartLocation);
  87. // }
  88. //
  89. // #region ICSharpCode.NRefactory.Parser.IAstVisitor interface implementation
  90. // public override object TrackedVisitCompilationUnit(CompilationUnit compilationUnit, object data)
  91. // {
  92. // compilationUnit.AcceptChildren(this, data);
  93. // outputFormatter.EndFile();
  94. // return null;
  95. // }
  96. //
  97. // /// <summary>
  98. // /// Converts type name to primitive type name. Returns typeString if typeString is not
  99. // /// a primitive type.
  100. // /// </summary>
  101. // static string ConvertTypeString(string typeString)
  102. // {
  103. // string primitiveType;
  104. // if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType))
  105. // return primitiveType;
  106. // else
  107. // return typeString;
  108. // }
  109. //
  110. // public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
  111. // {
  112. // if (typeReference == TypeReference.ClassConstraint) {
  113. // outputFormatter.PrintToken(Tokens.Class);
  114. // } else if (typeReference == TypeReference.StructConstraint) {
  115. // outputFormatter.PrintToken(Tokens.Structure);
  116. // } else if (typeReference == TypeReference.NewConstraint) {
  117. // outputFormatter.PrintToken(Tokens.New);
  118. // } else {
  119. // PrintTypeReferenceWithoutArray(typeReference);
  120. // if (typeReference.IsArrayType) {
  121. // PrintArrayRank(typeReference.RankSpecifier, 0);
  122. // }
  123. // }
  124. // return null;
  125. // }
  126. //
  127. // void PrintTypeReferenceWithoutArray(TypeReference typeReference)
  128. // {
  129. // if (typeReference.IsGlobal) {
  130. // outputFormatter.PrintToken(Tokens.Global);
  131. // outputFormatter.PrintToken(Tokens.Dot);
  132. // }
  133. // bool printGenerics = true;
  134. // if (typeReference.IsKeyword) {
  135. // outputFormatter.PrintText(ConvertTypeString(typeReference.Type));
  136. // } else {
  137. // outputFormatter.PrintIdentifier(typeReference.Type);
  138. // }
  139. // if (printGenerics && typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
  140. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  141. // outputFormatter.PrintToken(Tokens.Of);
  142. // outputFormatter.Space();
  143. // AppendCommaSeparatedList(typeReference.GenericTypes);
  144. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  145. // }
  146. // for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
  147. // outputFormatter.PrintToken(Tokens.Times);
  148. // }
  149. // }
  150. //
  151. // void PrintArrayRank(int[] rankSpecifier, int startRank)
  152. // {
  153. // for (int i = startRank; i < rankSpecifier.Length; ++i) {
  154. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  155. // for (int j = 0; j < rankSpecifier[i]; ++j) {
  156. // outputFormatter.PrintToken(Tokens.Comma);
  157. // }
  158. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  159. // }
  160. // }
  161. //
  162. // public override object TrackedVisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data)
  163. // {
  164. // TrackedVisit(innerClassTypeReference.BaseType, data);
  165. // outputFormatter.PrintToken(Tokens.Dot);
  166. // return VisitTypeReference((TypeReference)innerClassTypeReference, data);
  167. // }
  168. //
  169. // #region Global scope
  170. // bool printAttributeSectionInline; // is set to true when printing parameter's attributes
  171. //
  172. // public override object TrackedVisitAttributeSection(AttributeSection attributeSection, object data)
  173. // {
  174. // if (!printAttributeSectionInline)
  175. // outputFormatter.Indent();
  176. // outputFormatter.PrintText("<");
  177. // if (!string.IsNullOrEmpty(attributeSection.AttributeTarget) && !string.Equals(attributeSection.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) {
  178. // outputFormatter.PrintText(char.ToUpperInvariant(attributeSection.AttributeTarget[0]) + attributeSection.AttributeTarget.Substring(1));
  179. // outputFormatter.PrintToken(Tokens.Colon);
  180. // outputFormatter.Space();
  181. // }
  182. // Debug.Assert(attributeSection.Attributes != null);
  183. // AppendCommaSeparatedList(attributeSection.Attributes);
  184. //
  185. // outputFormatter.PrintText(">");
  186. //
  187. // if ("assembly".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)
  188. // || "module".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)) {
  189. // outputFormatter.NewLine();
  190. // } else {
  191. // if (printAttributeSectionInline)
  192. // outputFormatter.Space();
  193. // else
  194. // outputFormatter.PrintLineContinuation();
  195. // }
  196. //
  197. // return null;
  198. // }
  199. //
  200. // public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data)
  201. // {
  202. // outputFormatter.PrintIdentifier(attribute.Type);
  203. // if (attribute.PositionalArguments.Count > 0 || attribute.NamedArguments.Count > 0) {
  204. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  205. // AppendCommaSeparatedList(attribute.PositionalArguments);
  206. //
  207. // if (attribute.NamedArguments.Count > 0) {
  208. // if (attribute.PositionalArguments.Count > 0) {
  209. // outputFormatter.PrintToken(Tokens.Comma);
  210. // outputFormatter.Space();
  211. // }
  212. // AppendCommaSeparatedList(attribute.NamedArguments);
  213. // }
  214. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  215. // }
  216. // return null;
  217. // }
  218. //
  219. // public override object TrackedVisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data)
  220. // {
  221. // outputFormatter.PrintIdentifier(namedArgumentExpression.Name);
  222. // outputFormatter.Space();
  223. // outputFormatter.PrintToken(Tokens.Colon);
  224. // outputFormatter.PrintToken(Tokens.Assign);
  225. // outputFormatter.Space();
  226. // TrackedVisit(namedArgumentExpression.Expression, data);
  227. // return null;
  228. // }
  229. //
  230. // public override object TrackedVisitUsing(ImportsClause @using, object data)
  231. // {
  232. // Debug.Fail("Should never be called. The usings should be handled in Visit(UsingDeclaration)");
  233. // return null;
  234. // }
  235. //
  236. // public override object TrackedVisitUsingDeclaration(ImportsStatement usingDeclaration, object data)
  237. // {
  238. // outputFormatter.Indent();
  239. // outputFormatter.PrintToken(Tokens.Imports);
  240. // outputFormatter.Space();
  241. // for (int i = 0; i < usingDeclaration.ImportsClauses.Count; ++i) {
  242. // outputFormatter.PrintIdentifier(((ImportsClause)usingDeclaration.ImportsClauses[i]).Name);
  243. // if (((ImportsClause)usingDeclaration.ImportsClauses[i]).IsAlias) {
  244. // outputFormatter.Space();
  245. // outputFormatter.PrintToken(Tokens.Assign);
  246. // outputFormatter.Space();
  247. // TrackedVisit(((ImportsClause)usingDeclaration.ImportsClauses[i]).Alias, data);
  248. // }
  249. // if (i + 1 < usingDeclaration.ImportsClauses.Count) {
  250. // outputFormatter.PrintToken(Tokens.Comma);
  251. // outputFormatter.Space();
  252. // }
  253. // }
  254. // outputFormatter.NewLine();
  255. // return null;
  256. // }
  257. //
  258. // public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
  259. // {
  260. // outputFormatter.Indent();
  261. // outputFormatter.PrintToken(Tokens.Namespace);
  262. // outputFormatter.Space();
  263. // outputFormatter.PrintIdentifier(namespaceDeclaration.Name);
  264. // outputFormatter.NewLine();
  265. //
  266. // ++outputFormatter.IndentationLevel;
  267. // namespaceDeclaration.AcceptChildren(this, data);
  268. // --outputFormatter.IndentationLevel;
  269. //
  270. // outputFormatter.Indent();
  271. // outputFormatter.PrintToken(Tokens.End);
  272. // outputFormatter.Space();
  273. // outputFormatter.PrintToken(Tokens.Namespace);
  274. // outputFormatter.NewLine();
  275. // return null;
  276. // }
  277. //
  278. // static int GetTypeToken(TypeDeclaration typeDeclaration)
  279. // {
  280. // switch (typeDeclaration.Type) {
  281. // case ClassType.Class:
  282. // return Tokens.Class;
  283. // case ClassType.Enum:
  284. // return Tokens.Enum;
  285. // case ClassType.Interface:
  286. // return Tokens.Interface;
  287. // case ClassType.Struct:
  288. // return Tokens.Structure;
  289. // case ClassType.Module:
  290. // return Tokens.Module;
  291. // default:
  292. // return Tokens.Class;
  293. // }
  294. // }
  295. //
  296. // void PrintTemplates(List<TemplateDefinition> templates)
  297. // {
  298. // if (templates != null && templates.Count > 0) {
  299. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  300. // outputFormatter.PrintToken(Tokens.Of);
  301. // outputFormatter.Space();
  302. // AppendCommaSeparatedList(templates);
  303. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  304. // }
  305. // }
  306. //
  307. // public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
  308. // {
  309. // VisitAttributes(typeDeclaration.Attributes, data);
  310. //
  311. // outputFormatter.Indent();
  312. // OutputModifier(typeDeclaration.Modifier, true, false);
  313. //
  314. // int typeToken = GetTypeToken(typeDeclaration);
  315. // outputFormatter.PrintToken(typeToken);
  316. // outputFormatter.Space();
  317. // outputFormatter.PrintIdentifier(typeDeclaration.Name);
  318. //
  319. // PrintTemplates(typeDeclaration.Templates);
  320. //
  321. // if (typeDeclaration.Type == ClassType.Enum
  322. // && typeDeclaration.BaseTypes != null && typeDeclaration.BaseTypes.Count > 0)
  323. // {
  324. // outputFormatter.Space();
  325. // outputFormatter.PrintToken(Tokens.As);
  326. // outputFormatter.Space();
  327. // foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
  328. // TrackedVisit(baseTypeRef, data);
  329. // }
  330. // }
  331. //
  332. // outputFormatter.NewLine();
  333. // ++outputFormatter.IndentationLevel;
  334. //
  335. // if (typeDeclaration.BaseTypes != null && typeDeclaration.Type != ClassType.Enum) {
  336. // foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
  337. // outputFormatter.Indent();
  338. //
  339. // string baseType = baseTypeRef.Type;
  340. // if (baseType.IndexOf('.') >= 0) {
  341. // baseType = baseType.Substring(baseType.LastIndexOf('.') + 1);
  342. // }
  343. // bool baseTypeIsInterface = baseType.Length >= 2 && baseType[0] == 'I' && Char.IsUpper(baseType[1]);
  344. //
  345. // if (!baseTypeIsInterface || typeDeclaration.Type == ClassType.Interface) {
  346. // outputFormatter.PrintToken(Tokens.Inherits);
  347. // } else {
  348. // outputFormatter.PrintToken(Tokens.Implements);
  349. // }
  350. // outputFormatter.Space();
  351. // TrackedVisit(baseTypeRef, data);
  352. // outputFormatter.NewLine();
  353. // }
  354. // }
  355. //
  356. // TypeDeclaration oldType = currentType;
  357. // currentType = typeDeclaration;
  358. //
  359. // if (typeDeclaration.Type == ClassType.Enum) {
  360. // OutputEnumMembers(typeDeclaration, data);
  361. // } else {
  362. // typeDeclaration.AcceptChildren(this, data);
  363. // }
  364. // currentType = oldType;
  365. //
  366. // --outputFormatter.IndentationLevel;
  367. //
  368. //
  369. // outputFormatter.Indent();
  370. // outputFormatter.PrintToken(Tokens.End);
  371. // outputFormatter.Space();
  372. // outputFormatter.PrintToken(typeToken);
  373. // outputFormatter.NewLine();
  374. // return null;
  375. // }
  376. //
  377. // void OutputEnumMembers(TypeDeclaration typeDeclaration, object data)
  378. // {
  379. // foreach (FieldDeclaration fieldDeclaration in typeDeclaration.Children) {
  380. // BeginVisit(fieldDeclaration);
  381. // VariableDeclaration f = (VariableDeclaration)fieldDeclaration.Fields[0];
  382. // VisitAttributes(fieldDeclaration.Attributes, data);
  383. // outputFormatter.Indent();
  384. // outputFormatter.PrintIdentifier(f.Name);
  385. // if (f.Initializer != null && !f.Initializer.IsNull) {
  386. // outputFormatter.Space();
  387. // outputFormatter.PrintToken(Tokens.Assign);
  388. // outputFormatter.Space();
  389. // TrackedVisit(f.Initializer, data);
  390. // }
  391. // outputFormatter.NewLine();
  392. // EndVisit(fieldDeclaration);
  393. // }
  394. // }
  395. //
  396. // public override object TrackedVisitTemplateDefinition(TemplateDefinition templateDefinition, object data)
  397. // {
  398. // VisitAttributes(templateDefinition.Attributes, data);
  399. // switch (templateDefinition.VarianceModifier) {
  400. // case VarianceModifier.Invariant:
  401. // // nothing
  402. // break;
  403. // case VarianceModifier.Covariant:
  404. // outputFormatter.Space();
  405. // outputFormatter.PrintToken(Tokens.Out);
  406. // outputFormatter.Space();
  407. // break;
  408. // case VarianceModifier.Contravariant:
  409. // outputFormatter.Space();
  410. // outputFormatter.PrintToken(Tokens.In);
  411. // outputFormatter.Space();
  412. // break;
  413. // default:
  414. // throw new Exception("Invalid value for VarianceModifier");
  415. // }
  416. // outputFormatter.PrintIdentifier(templateDefinition.Name);
  417. // if (templateDefinition.Bases.Count > 0) {
  418. // outputFormatter.PrintText(" As ");
  419. // VisitReturnTypeAttributes(templateDefinition.Attributes, data);
  420. // if (templateDefinition.Bases.Count == 1) {
  421. // TrackedVisit(templateDefinition.Bases[0], data);
  422. // } else {
  423. // outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
  424. // AppendCommaSeparatedList(templateDefinition.Bases);
  425. // outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
  426. // }
  427. // }
  428. // return null;
  429. // }
  430. //
  431. // public override object TrackedVisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data)
  432. // {
  433. // VisitAttributes(delegateDeclaration.Attributes, data);
  434. //
  435. // outputFormatter.Indent();
  436. // OutputModifier(delegateDeclaration.Modifier, true, false);
  437. // outputFormatter.PrintToken(Tokens.Delegate);
  438. // outputFormatter.Space();
  439. //
  440. // bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void");
  441. // if (isFunction) {
  442. // outputFormatter.PrintToken(Tokens.Function);
  443. // outputFormatter.Space();
  444. // } else {
  445. // outputFormatter.PrintToken(Tokens.Sub);
  446. // outputFormatter.Space();
  447. // }
  448. // outputFormatter.PrintIdentifier(delegateDeclaration.Name);
  449. //
  450. // PrintTemplates(delegateDeclaration.Templates);
  451. //
  452. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  453. // AppendCommaSeparatedList(delegateDeclaration.Parameters);
  454. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  455. //
  456. // if (isFunction) {
  457. // outputFormatter.Space();
  458. // outputFormatter.PrintToken(Tokens.As);
  459. // outputFormatter.Space();
  460. // VisitReturnTypeAttributes(delegateDeclaration.Attributes, data);
  461. // TrackedVisit(delegateDeclaration.ReturnType, data);
  462. // }
  463. // outputFormatter.NewLine();
  464. // return null;
  465. // }
  466. //
  467. // public override object TrackedVisitOptionDeclaration(OptionDeclaration optionDeclaration, object data)
  468. // {
  469. // outputFormatter.PrintToken(Tokens.Option);
  470. // outputFormatter.Space();
  471. // switch (optionDeclaration.OptionType) {
  472. // case OptionType.Strict:
  473. // outputFormatter.PrintToken(Tokens.Strict);
  474. // outputFormatter.Space();
  475. // outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
  476. // break;
  477. // case OptionType.Explicit:
  478. // outputFormatter.PrintToken(Tokens.Explicit);
  479. // outputFormatter.Space();
  480. // outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
  481. // break;
  482. // case OptionType.Infer:
  483. // outputFormatter.PrintToken(Tokens.Infer);
  484. // outputFormatter.Space();
  485. // outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
  486. // break;
  487. // case OptionType.CompareBinary:
  488. // outputFormatter.PrintToken(Tokens.Compare);
  489. // outputFormatter.Space();
  490. // outputFormatter.PrintToken(Tokens.Binary);
  491. // break;
  492. // case OptionType.CompareText:
  493. // outputFormatter.PrintToken(Tokens.Compare);
  494. // outputFormatter.Space();
  495. // outputFormatter.PrintToken(Tokens.Text);
  496. // break;
  497. // }
  498. // outputFormatter.NewLine();
  499. // return null;
  500. // }
  501. // #endregion
  502. //
  503. // #region Type level
  504. // TypeReference currentVariableType;
  505. // public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
  506. // {
  507. //
  508. // VisitAttributes(fieldDeclaration.Attributes, data);
  509. // outputFormatter.Indent();
  510. // if (fieldDeclaration.Modifier == Modifiers.None) {
  511. // outputFormatter.PrintToken(Tokens.Private);
  512. // outputFormatter.Space();
  513. // } else {
  514. // OutputModifier(fieldDeclaration.Modifier, false, true);
  515. // }
  516. // currentVariableType = fieldDeclaration.TypeReference;
  517. // AppendCommaSeparatedList(fieldDeclaration.Fields);
  518. // currentVariableType = null;
  519. //
  520. // outputFormatter.NewLine();
  521. //
  522. // return null;
  523. // }
  524. //
  525. // public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
  526. // {
  527. // outputFormatter.PrintIdentifier(variableDeclaration.Name);
  528. //
  529. // TypeReference varType = currentVariableType;
  530. // if (varType != null && varType.IsNull)
  531. // varType = null;
  532. // if (varType == null && !variableDeclaration.TypeReference.IsNull)
  533. // varType = variableDeclaration.TypeReference;
  534. //
  535. // if (varType != null) {
  536. // outputFormatter.Space();
  537. // outputFormatter.PrintToken(Tokens.As);
  538. // outputFormatter.Space();
  539. // ObjectCreateExpression init = variableDeclaration.Initializer as ObjectCreateExpression;
  540. // if (init != null && TypeReference.AreEqualReferences(init.CreateType, varType)) {
  541. // TrackedVisit(variableDeclaration.Initializer, data);
  542. // return null;
  543. // } else {
  544. // TrackedVisit(varType, data);
  545. // }
  546. // }
  547. //
  548. // if (!variableDeclaration.Initializer.IsNull) {
  549. // outputFormatter.Space();
  550. // outputFormatter.PrintToken(Tokens.Assign);
  551. // outputFormatter.Space();
  552. // TrackedVisit(variableDeclaration.Initializer, data);
  553. // }
  554. // return null;
  555. // }
  556. //
  557. // public override object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
  558. // {
  559. // VisitAttributes(propertyDeclaration.Attributes, data);
  560. // outputFormatter.Indent();
  561. // OutputModifier(propertyDeclaration.Modifier);
  562. //
  563. // if ((propertyDeclaration.Modifier & (Modifiers.ReadOnly | Modifiers.WriteOnly)) == Modifiers.None) {
  564. // if (propertyDeclaration.IsReadOnly) {
  565. // outputFormatter.PrintToken(Tokens.ReadOnly);
  566. // outputFormatter.Space();
  567. // } else if (propertyDeclaration.IsWriteOnly) {
  568. // outputFormatter.PrintToken(Tokens.WriteOnly);
  569. // outputFormatter.Space();
  570. // }
  571. // }
  572. //
  573. // outputFormatter.PrintToken(Tokens.Property);
  574. // outputFormatter.Space();
  575. // outputFormatter.PrintIdentifier(propertyDeclaration.Name);
  576. //
  577. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  578. // AppendCommaSeparatedList(propertyDeclaration.Parameters);
  579. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  580. //
  581. // if (!propertyDeclaration.TypeReference.IsNull) {
  582. // outputFormatter.Space();
  583. // outputFormatter.PrintToken(Tokens.As);
  584. // outputFormatter.Space();
  585. //
  586. // VisitReturnTypeAttributes(propertyDeclaration.Attributes, data);
  587. //
  588. // ObjectCreateExpression init = propertyDeclaration.Initializer as ObjectCreateExpression;
  589. // if (init != null && TypeReference.AreEqualReferences(init.CreateType, propertyDeclaration.TypeReference)) {
  590. // TrackedVisit(propertyDeclaration.Initializer, data);
  591. // } else {
  592. // TrackedVisit(propertyDeclaration.TypeReference, data);
  593. // }
  594. // }
  595. //
  596. // PrintInterfaceImplementations(propertyDeclaration.InterfaceImplementations);
  597. //
  598. // if (!propertyDeclaration.Initializer.IsNull && !(propertyDeclaration.Initializer is ObjectCreateExpression)) {
  599. // outputFormatter.Space();
  600. // outputFormatter.PrintToken(Tokens.Assign);
  601. // outputFormatter.Space();
  602. // TrackedVisit(propertyDeclaration.Initializer, data);
  603. // }
  604. //
  605. // outputFormatter.NewLine();
  606. //
  607. // if (!IsAbstract(propertyDeclaration) && (propertyDeclaration.GetRegion.Block != NullBlockStatement.Instance || propertyDeclaration.SetRegion.Block != NullBlockStatement.Instance)) {
  608. // outputFormatter.IsInMemberBody = true;
  609. // ++outputFormatter.IndentationLevel;
  610. // exitTokenStack.Push(Tokens.Property);
  611. // TrackedVisit(propertyDeclaration.GetRegion, data);
  612. // TrackedVisit(propertyDeclaration.SetRegion, data);
  613. // exitTokenStack.Pop();
  614. // --outputFormatter.IndentationLevel;
  615. // outputFormatter.IsInMemberBody = false;
  616. //
  617. // outputFormatter.Indent();
  618. // outputFormatter.PrintToken(Tokens.End);
  619. // outputFormatter.Space();
  620. // outputFormatter.PrintToken(Tokens.Property);
  621. // outputFormatter.NewLine();
  622. // }
  623. //
  624. // return null;
  625. // }
  626. //
  627. // public override object TrackedVisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data)
  628. // {
  629. // VisitAttributes(propertyGetRegion.Attributes, data);
  630. // outputFormatter.Indent();
  631. // OutputModifier(propertyGetRegion.Modifier);
  632. // outputFormatter.PrintToken(Tokens.Get);
  633. // outputFormatter.NewLine();
  634. //
  635. // ++outputFormatter.IndentationLevel;
  636. // TrackedVisit(propertyGetRegion.Block, data);
  637. // --outputFormatter.IndentationLevel;
  638. // outputFormatter.Indent();
  639. // outputFormatter.PrintToken(Tokens.End);
  640. // outputFormatter.Space();
  641. // outputFormatter.PrintToken(Tokens.Get);
  642. // outputFormatter.NewLine();
  643. // return null;
  644. // }
  645. //
  646. // public override object TrackedVisitPropertySetRegion(PropertySetRegion propertySetRegion, object data)
  647. // {
  648. // VisitAttributes(propertySetRegion.Attributes, data);
  649. // outputFormatter.Indent();
  650. // OutputModifier(propertySetRegion.Modifier);
  651. // outputFormatter.PrintToken(Tokens.Set);
  652. // outputFormatter.NewLine();
  653. //
  654. // ++outputFormatter.IndentationLevel;
  655. // TrackedVisit(propertySetRegion.Block, data);
  656. // --outputFormatter.IndentationLevel;
  657. // outputFormatter.Indent();
  658. // outputFormatter.PrintToken(Tokens.End);
  659. // outputFormatter.Space();
  660. // outputFormatter.PrintToken(Tokens.Set);
  661. // outputFormatter.NewLine();
  662. // return null;
  663. // }
  664. //
  665. // TypeReference currentEventType = null;
  666. // public override object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data)
  667. // {
  668. // bool customEvent = eventDeclaration.HasAddRegion || eventDeclaration.HasRemoveRegion;
  669. //
  670. // VisitAttributes(eventDeclaration.Attributes, data);
  671. // outputFormatter.Indent();
  672. // OutputModifier(eventDeclaration.Modifier);
  673. // if (customEvent) {
  674. // outputFormatter.PrintText("Custom");
  675. // outputFormatter.Space();
  676. // }
  677. //
  678. // outputFormatter.PrintToken(Tokens.Event);
  679. // outputFormatter.Space();
  680. // outputFormatter.PrintIdentifier(eventDeclaration.Name);
  681. //
  682. // if (eventDeclaration.Parameters.Count > 0) {
  683. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  684. // this.AppendCommaSeparatedList(eventDeclaration.Parameters);
  685. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  686. // }
  687. // if (!eventDeclaration.TypeReference.IsNull) {
  688. // outputFormatter.Space();
  689. // outputFormatter.PrintToken(Tokens.As);
  690. // outputFormatter.Space();
  691. // VisitReturnTypeAttributes(eventDeclaration.Attributes, data);
  692. // TrackedVisit(eventDeclaration.TypeReference, data);
  693. // }
  694. //
  695. // PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations);
  696. //
  697. // if (!eventDeclaration.Initializer.IsNull) {
  698. // outputFormatter.Space();
  699. // outputFormatter.PrintToken(Tokens.Assign);
  700. // outputFormatter.Space();
  701. // TrackedVisit(eventDeclaration.Initializer, data);
  702. // }
  703. //
  704. // outputFormatter.NewLine();
  705. //
  706. // if (customEvent) {
  707. // ++outputFormatter.IndentationLevel;
  708. // currentEventType = eventDeclaration.TypeReference;
  709. // exitTokenStack.Push(Tokens.Sub);
  710. // TrackedVisit(eventDeclaration.AddRegion, data);
  711. // TrackedVisit(eventDeclaration.RemoveRegion, data);
  712. // exitTokenStack.Pop();
  713. // --outputFormatter.IndentationLevel;
  714. //
  715. // outputFormatter.Indent();
  716. // outputFormatter.PrintToken(Tokens.End);
  717. // outputFormatter.Space();
  718. // outputFormatter.PrintToken(Tokens.Event);
  719. // outputFormatter.NewLine();
  720. // }
  721. // return null;
  722. // }
  723. //
  724. // void PrintInterfaceImplementations(IList<InterfaceImplementation> list)
  725. // {
  726. // if (list == null || list.Count == 0)
  727. // return;
  728. // outputFormatter.Space();
  729. // outputFormatter.PrintToken(Tokens.Implements);
  730. // for (int i = 0; i < list.Count; i++) {
  731. // if (i > 0)
  732. // outputFormatter.PrintToken(Tokens.Comma);
  733. // outputFormatter.Space();
  734. // TrackedVisit(list[i].InterfaceType, null);
  735. // outputFormatter.PrintToken(Tokens.Dot);
  736. // outputFormatter.PrintIdentifier(list[i].MemberName);
  737. // }
  738. // }
  739. //
  740. // public override object TrackedVisitEventAddRegion(EventAddRegion eventAddRegion, object data)
  741. // {
  742. // VisitAttributes(eventAddRegion.Attributes, data);
  743. // outputFormatter.Indent();
  744. // outputFormatter.PrintText("AddHandler(");
  745. // if (eventAddRegion.Parameters.Count == 0) {
  746. // outputFormatter.PrintToken(Tokens.ByVal);
  747. // outputFormatter.Space();
  748. // outputFormatter.PrintIdentifier("value");
  749. // outputFormatter.Space();
  750. // outputFormatter.PrintToken(Tokens.As);
  751. // outputFormatter.Space();
  752. // TrackedVisit(currentEventType, data);
  753. // } else {
  754. // this.AppendCommaSeparatedList(eventAddRegion.Parameters);
  755. // }
  756. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  757. // outputFormatter.NewLine();
  758. //
  759. // ++outputFormatter.IndentationLevel;
  760. // TrackedVisit(eventAddRegion.Block, data);
  761. // --outputFormatter.IndentationLevel;
  762. //
  763. // outputFormatter.Indent();
  764. // outputFormatter.PrintToken(Tokens.End);
  765. // outputFormatter.Space();
  766. // outputFormatter.PrintText("AddHandler");
  767. // outputFormatter.NewLine();
  768. // return null;
  769. // }
  770. //
  771. // public override object TrackedVisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data)
  772. // {
  773. // VisitAttributes(eventRemoveRegion.Attributes, data);
  774. // outputFormatter.Indent();
  775. // outputFormatter.PrintText("RemoveHandler");
  776. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  777. // if (eventRemoveRegion.Parameters.Count == 0) {
  778. // outputFormatter.PrintToken(Tokens.ByVal);
  779. // outputFormatter.Space();
  780. // outputFormatter.PrintIdentifier("value");
  781. // outputFormatter.Space();
  782. // outputFormatter.PrintToken(Tokens.As);
  783. // outputFormatter.Space();
  784. // TrackedVisit(currentEventType, data);
  785. // } else {
  786. // this.AppendCommaSeparatedList(eventRemoveRegion.Parameters);
  787. // }
  788. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  789. // outputFormatter.NewLine();
  790. //
  791. // ++outputFormatter.IndentationLevel;
  792. // TrackedVisit(eventRemoveRegion.Block, data);
  793. // --outputFormatter.IndentationLevel;
  794. //
  795. // outputFormatter.Indent();
  796. // outputFormatter.PrintToken(Tokens.End);
  797. // outputFormatter.Space();
  798. // outputFormatter.PrintText("RemoveHandler");
  799. // outputFormatter.NewLine();
  800. // return null;
  801. // }
  802. //
  803. // public override object TrackedVisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data)
  804. // {
  805. // VisitAttributes(eventRaiseRegion.Attributes, data);
  806. // outputFormatter.Indent();
  807. // outputFormatter.PrintText("RaiseEvent");
  808. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  809. // if (eventRaiseRegion.Parameters.Count == 0) {
  810. // outputFormatter.PrintToken(Tokens.ByVal);
  811. // outputFormatter.Space();
  812. // outputFormatter.PrintIdentifier("value");
  813. // outputFormatter.Space();
  814. // outputFormatter.PrintToken(Tokens.As);
  815. // outputFormatter.Space();
  816. // TrackedVisit(currentEventType, data);
  817. // } else {
  818. // this.AppendCommaSeparatedList(eventRaiseRegion.Parameters);
  819. // }
  820. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  821. // outputFormatter.NewLine();
  822. //
  823. // ++outputFormatter.IndentationLevel;
  824. // TrackedVisit(eventRaiseRegion.Block, data);
  825. // --outputFormatter.IndentationLevel;
  826. //
  827. // outputFormatter.Indent();
  828. // outputFormatter.PrintToken(Tokens.End);
  829. // outputFormatter.Space();
  830. // outputFormatter.PrintText("RaiseEvent");
  831. // outputFormatter.NewLine();
  832. // return null;
  833. // }
  834. //
  835. // public override object TrackedVisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data)
  836. // {
  837. // printAttributeSectionInline = true;
  838. // VisitAttributes(parameterDeclarationExpression.Attributes, data);
  839. // printAttributeSectionInline = false;
  840. // OutputModifier(parameterDeclarationExpression.ParamModifier);
  841. // outputFormatter.PrintIdentifier(parameterDeclarationExpression.ParameterName);
  842. // if (!parameterDeclarationExpression.TypeReference.IsNull) {
  843. // outputFormatter.Space();
  844. // outputFormatter.PrintToken(Tokens.As);
  845. // outputFormatter.Space();
  846. // VisitReturnTypeAttributes(parameterDeclarationExpression.Attributes, data);
  847. // TrackedVisit(parameterDeclarationExpression.TypeReference, data);
  848. // }
  849. // if (!parameterDeclarationExpression.DefaultValue.IsNull) {
  850. // outputFormatter.Space();
  851. // outputFormatter.PrintToken(Tokens.Assign);
  852. // outputFormatter.Space();
  853. // TrackedVisit(parameterDeclarationExpression.DefaultValue, data);
  854. // }
  855. // return null;
  856. // }
  857. //
  858. // public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
  859. // {
  860. // VisitAttributes(methodDeclaration.Attributes, data);
  861. // if (methodDeclaration.IsExtensionMethod) {
  862. // outputFormatter.Indent();
  863. // outputFormatter.PrintText("<System.Runtime.CompilerServices.Extension> _");
  864. // outputFormatter.NewLine();
  865. // }
  866. // outputFormatter.Indent();
  867. // OutputModifier(methodDeclaration.Modifier);
  868. //
  869. // bool isSub = methodDeclaration.TypeReference.IsNull ||
  870. // methodDeclaration.TypeReference.Type == "System.Void";
  871. //
  872. // if (isSub) {
  873. // outputFormatter.PrintToken(Tokens.Sub);
  874. // } else {
  875. // outputFormatter.PrintToken(Tokens.Function);
  876. // }
  877. // outputFormatter.Space();
  878. // outputFormatter.PrintIdentifier(methodDeclaration.Name);
  879. //
  880. // PrintTemplates(methodDeclaration.Templates);
  881. //
  882. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  883. // AppendCommaSeparatedList(methodDeclaration.Parameters);
  884. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  885. //
  886. // if (!isSub) {
  887. // outputFormatter.Space();
  888. // outputFormatter.PrintToken(Tokens.As);
  889. // outputFormatter.Space();
  890. // VisitReturnTypeAttributes(methodDeclaration.Attributes, data);
  891. // TrackedVisit(methodDeclaration.TypeReference, data);
  892. // }
  893. //
  894. // PrintInterfaceImplementations(methodDeclaration.InterfaceImplementations);
  895. //
  896. // if (methodDeclaration.HandlesClause.Count > 0) {
  897. // outputFormatter.Space();
  898. // outputFormatter.PrintToken(Tokens.Handles);
  899. // for (int i = 0; i < methodDeclaration.HandlesClause.Count; i++) {
  900. // if (i > 0)
  901. // outputFormatter.PrintToken(Tokens.Comma);
  902. // outputFormatter.Space();
  903. // outputFormatter.PrintText(methodDeclaration.HandlesClause[i]);
  904. // }
  905. // }
  906. //
  907. // outputFormatter.NewLine();
  908. //
  909. // if (!IsAbstract(methodDeclaration)) {
  910. // outputFormatter.IsInMemberBody = true;
  911. // BeginVisit(methodDeclaration.Body);
  912. // ++outputFormatter.IndentationLevel;
  913. // exitTokenStack.Push(isSub ? Tokens.Sub : Tokens.Function);
  914. // // we're doing the tracking manually using BeginVisit/EndVisit, so call Tracked... directly
  915. // this.TrackedVisitBlockStatement(methodDeclaration.Body, data);
  916. // exitTokenStack.Pop();
  917. // --outputFormatter.IndentationLevel;
  918. //
  919. // outputFormatter.Indent();
  920. // outputFormatter.PrintToken(Tokens.End);
  921. // outputFormatter.Space();
  922. // if (isSub) {
  923. // outputFormatter.PrintToken(Tokens.Sub);
  924. // } else {
  925. // outputFormatter.PrintToken(Tokens.Function);
  926. // }
  927. // outputFormatter.NewLine();
  928. // EndVisit(methodDeclaration.Body);
  929. // outputFormatter.IsInMemberBody = false;
  930. // }
  931. // return null;
  932. // }
  933. //
  934. // public override object TrackedVisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data)
  935. // {
  936. // throw new InvalidOperationException();
  937. // }
  938. //
  939. // bool IsAbstract(AttributedNode node)
  940. // {
  941. // if ((node.Modifier & Modifiers.Abstract) == Modifiers.Abstract)
  942. // return true;
  943. // return currentType != null && currentType.Type == ClassType.Interface;
  944. // }
  945. //
  946. // public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
  947. // {
  948. // VisitAttributes(constructorDeclaration.Attributes, data);
  949. // outputFormatter.Indent();
  950. // OutputModifier(constructorDeclaration.Modifier);
  951. // outputFormatter.PrintToken(Tokens.Sub);
  952. // outputFormatter.Space();
  953. // outputFormatter.PrintToken(Tokens.New);
  954. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  955. // AppendCommaSeparatedList(constructorDeclaration.Parameters);
  956. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  957. // outputFormatter.NewLine();
  958. //
  959. // outputFormatter.IsInMemberBody = true;
  960. // ++outputFormatter.IndentationLevel;
  961. // exitTokenStack.Push(Tokens.Sub);
  962. //
  963. // TrackedVisit(constructorDeclaration.ConstructorInitializer, data);
  964. //
  965. // TrackedVisit(constructorDeclaration.Body, data);
  966. // exitTokenStack.Pop();
  967. // --outputFormatter.IndentationLevel;
  968. // outputFormatter.IsInMemberBody = false;
  969. //
  970. // outputFormatter.Indent();
  971. // outputFormatter.PrintToken(Tokens.End);
  972. // outputFormatter.Space();
  973. // outputFormatter.PrintToken(Tokens.Sub);
  974. // outputFormatter.NewLine();
  975. //
  976. // return null;
  977. // }
  978. //
  979. // public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
  980. // {
  981. // outputFormatter.Indent();
  982. // if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) {
  983. // outputFormatter.PrintToken(Tokens.Me);
  984. // } else {
  985. // outputFormatter.PrintToken(Tokens.MyBase);
  986. // }
  987. // outputFormatter.PrintToken(Tokens.Dot);
  988. // outputFormatter.PrintToken(Tokens.New);
  989. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  990. // AppendCommaSeparatedList(constructorInitializer.Arguments);
  991. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  992. //
  993. // outputFormatter.NewLine();
  994. // return null;
  995. // }
  996. //
  997. // public override object TrackedVisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data)
  998. // {
  999. // VisitAttributes(operatorDeclaration.Attributes, data);
  1000. // outputFormatter.Indent();
  1001. // OutputModifier(operatorDeclaration.Modifier);
  1002. //
  1003. // if (operatorDeclaration.IsConversionOperator) {
  1004. // if (operatorDeclaration.ConversionType == ConversionType.Implicit) {
  1005. // outputFormatter.PrintToken(Tokens.Widening);
  1006. // } else {
  1007. // outputFormatter.PrintToken(Tokens.Narrowing);
  1008. // }
  1009. // outputFormatter.Space();
  1010. // }
  1011. //
  1012. // outputFormatter.PrintToken(Tokens.Operator);
  1013. // outputFormatter.Space();
  1014. //
  1015. // int op = -1;
  1016. //
  1017. // switch(operatorDeclaration.OverloadableOperator)
  1018. // {
  1019. // case OverloadableOperatorType.Add:
  1020. // case OverloadableOperatorType.UnaryPlus:
  1021. // op = Tokens.Plus;
  1022. // break;
  1023. // case OverloadableOperatorType.UnaryMinus:
  1024. // case OverloadableOperatorType.Subtract:
  1025. // op = Tokens.Minus;
  1026. // break;
  1027. // case OverloadableOperatorType.Multiply:
  1028. // op = Tokens.Times;
  1029. // break;
  1030. // case OverloadableOperatorType.Divide:
  1031. // op = Tokens.Div;
  1032. // break;
  1033. // case OverloadableOperatorType.Modulus:
  1034. // op = Tokens.Mod;
  1035. // break;
  1036. // case OverloadableOperatorType.Concat:
  1037. // op = Tokens.ConcatString;
  1038. // break;
  1039. // case OverloadableOperatorType.Not:
  1040. // op = Tokens.Not;
  1041. // break;
  1042. // case OverloadableOperatorType.BitNot:
  1043. // op = Tokens.Not;
  1044. // break;
  1045. // case OverloadableOperatorType.BitwiseAnd:
  1046. // op = Tokens.And;
  1047. // break;
  1048. // case OverloadableOperatorType.BitwiseOr:
  1049. // op = Tokens.Or;
  1050. // break;
  1051. // case OverloadableOperatorType.ExclusiveOr:
  1052. // op = Tokens.Xor;
  1053. // break;
  1054. // case OverloadableOperatorType.ShiftLeft:
  1055. // op = Tokens.ShiftLeft;
  1056. // break;
  1057. // case OverloadableOperatorType.ShiftRight:
  1058. // op = Tokens.ShiftRight;
  1059. // break;
  1060. // case OverloadableOperatorType.GreaterThan:
  1061. // op = Tokens.GreaterThan;
  1062. // break;
  1063. // case OverloadableOperatorType.GreaterThanOrEqual:
  1064. // op = Tokens.GreaterEqual;
  1065. // break;
  1066. // case OverloadableOperatorType.Equality:
  1067. // op = Tokens.Assign;
  1068. // break;
  1069. // case OverloadableOperatorType.InEquality:
  1070. // op = Tokens.NotEqual;
  1071. // break;
  1072. // case OverloadableOperatorType.LessThan:
  1073. // op = Tokens.LessThan;
  1074. // break;
  1075. // case OverloadableOperatorType.LessThanOrEqual:
  1076. // op = Tokens.LessEqual;
  1077. // break;
  1078. // case OverloadableOperatorType.Increment:
  1079. // Error("Increment operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
  1080. // break;
  1081. // case OverloadableOperatorType.Decrement:
  1082. // Error("Decrement operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
  1083. // break;
  1084. // case OverloadableOperatorType.IsTrue:
  1085. // outputFormatter.PrintText("IsTrue");
  1086. // break;
  1087. // case OverloadableOperatorType.IsFalse:
  1088. // outputFormatter.PrintText("IsFalse");
  1089. // break;
  1090. // case OverloadableOperatorType.Like:
  1091. // op = Tokens.Like;
  1092. // break;
  1093. // case OverloadableOperatorType.Power:
  1094. // op = Tokens.Power;
  1095. // break;
  1096. // case OverloadableOperatorType.CType:
  1097. // op = Tokens.CType;
  1098. // break;
  1099. // case OverloadableOperatorType.DivideInteger:
  1100. // op = Tokens.DivInteger;
  1101. // break;
  1102. // }
  1103. //
  1104. //
  1105. //
  1106. // if (operatorDeclaration.IsConversionOperator) {
  1107. // outputFormatter.PrintToken(Tokens.CType);
  1108. // } else {
  1109. // if(op != -1) outputFormatter.PrintToken(op);
  1110. // }
  1111. //
  1112. // PrintTemplates(operatorDeclaration.Templates);
  1113. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  1114. // AppendCommaSeparatedList(operatorDeclaration.Parameters);
  1115. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  1116. // if (!operatorDeclaration.TypeReference.IsNull) {
  1117. // outputFormatter.Space();
  1118. // outputFormatter.PrintToken(Tokens.As);
  1119. // outputFormatter.Space();
  1120. // VisitReturnTypeAttributes(operatorDeclaration.Attributes, data);
  1121. // TrackedVisit(operatorDeclaration.TypeReference, data);
  1122. // }
  1123. //
  1124. // outputFormatter.NewLine();
  1125. //
  1126. // ++outputFormatter.IndentationLevel;
  1127. // TrackedVisit(operatorDeclaration.Body, data);
  1128. // --outputFormatter.IndentationLevel;
  1129. //
  1130. // outputFormatter.Indent();
  1131. // outputFormatter.PrintToken(Tokens.End);
  1132. // outputFormatter.Space();
  1133. // outputFormatter.PrintToken(Tokens.Operator);
  1134. // outputFormatter.NewLine();
  1135. //
  1136. // return null;
  1137. // }
  1138. //
  1139. // public override object TrackedVisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
  1140. // {
  1141. // VisitAttributes(declareDeclaration.Attributes, data);
  1142. // outputFormatter.Indent();
  1143. // OutputModifier(declareDeclaration.Modifier);
  1144. // outputFormatter.PrintToken(Tokens.Declare);
  1145. // outputFormatter.Space();
  1146. //
  1147. // switch (declareDeclaration.Charset) {
  1148. // case CharsetModifier.Auto:
  1149. // outputFormatter.PrintToken(Tokens.Auto);
  1150. // outputFormatter.Space();
  1151. // break;
  1152. // case CharsetModifier.Unicode:
  1153. // outputFormatter.PrintToken(Tokens.Unicode);
  1154. // outputFormatter.Space();
  1155. // break;
  1156. // case CharsetModifier.Ansi:
  1157. // outputFormatter.PrintToken(Tokens.Ansi);
  1158. // outputFormatter.Space();
  1159. // break;
  1160. // }
  1161. //
  1162. // bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void";
  1163. // if (isVoid) {
  1164. // outputFormatter.PrintToken(Tokens.Sub);
  1165. // } else {
  1166. // outputFormatter.PrintToken(Tokens.Function);
  1167. // }
  1168. // outputFormatter.Space();
  1169. //
  1170. // outputFormatter.PrintIdentifier(declareDeclaration.Name);
  1171. //
  1172. // outputFormatter.Space();
  1173. // outputFormatter.PrintToken(Tokens.Lib);
  1174. // outputFormatter.Space();
  1175. // outputFormatter.PrintText(ConvertString(declareDeclaration.Library));
  1176. // outputFormatter.Space();
  1177. //
  1178. // if (declareDeclaration.Alias.Length > 0) {
  1179. // outputFormatter.PrintToken(Tokens.Alias);
  1180. // outputFormatter.Space();
  1181. // outputFormatter.PrintText(ConvertString(declareDeclaration.Alias));
  1182. // outputFormatter.Space();
  1183. // }
  1184. //
  1185. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  1186. // AppendCommaSeparatedList(declareDeclaration.Parameters);
  1187. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  1188. //
  1189. // if (!isVoid) {
  1190. // outputFormatter.Space();
  1191. // outputFormatter.PrintToken(Tokens.As);
  1192. // outputFormatter.Space();
  1193. // VisitReturnTypeAttributes(declareDeclaration.Attributes, data);
  1194. // TrackedVisit(declareDeclaration.TypeReference, data);
  1195. // }
  1196. //
  1197. // outputFormatter.NewLine();
  1198. //
  1199. // return null;
  1200. // }
  1201. // #endregion
  1202. //
  1203. // #region Statements
  1204. // public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
  1205. // {
  1206. // if (blockStatement.Parent is BlockStatement) {
  1207. // outputFormatter.Indent();
  1208. // outputFormatter.PrintText("If True Then");
  1209. // outputFormatter.NewLine();
  1210. // outputFormatter.IndentationLevel += 1;
  1211. // }
  1212. // VisitStatementList(blockStatement.Children);
  1213. // if (blockStatement.Parent is BlockStatement) {
  1214. // outputFormatter.IndentationLevel -= 1;
  1215. // outputFormatter.Indent();
  1216. // outputFormatter.PrintText("End If");
  1217. // outputFormatter.NewLine();
  1218. // }
  1219. // return null;
  1220. // }
  1221. //
  1222. // void PrintIndentedBlock(Statement stmt)
  1223. // {
  1224. // outputFormatter.IndentationLevel += 1;
  1225. // if (stmt is BlockStatement) {
  1226. // TrackedVisit(stmt, null);
  1227. // } else {
  1228. // outputFormatter.Indent();
  1229. // TrackedVisit(stmt, null);
  1230. // outputFormatter.NewLine();
  1231. // }
  1232. // outputFormatter.IndentationLevel -= 1;
  1233. // }
  1234. //
  1235. // void PrintIndentedBlock(IEnumerable statements)
  1236. // {
  1237. // outputFormatter.IndentationLevel += 1;
  1238. // VisitStatementList(statements);
  1239. // outputFormatter.IndentationLevel -= 1;
  1240. // }
  1241. //
  1242. // void VisitStatementList(IEnumerable statements)
  1243. // {
  1244. // foreach (Statement stmt in statements) {
  1245. // if (stmt is BlockStatement) {
  1246. // TrackedVisit(stmt, null);
  1247. // } else {
  1248. // outputFormatter.Indent();
  1249. // TrackedVisit(stmt, null);
  1250. // outputFormatter.NewLine();
  1251. // }
  1252. // }
  1253. // }
  1254. //
  1255. // public override object TrackedVisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data)
  1256. // {
  1257. // outputFormatter.PrintToken(Tokens.AddHandler);
  1258. // outputFormatter.Space();
  1259. // TrackedVisit(addHandlerStatement.EventExpression, data);
  1260. // outputFormatter.PrintToken(Tokens.Comma);
  1261. // outputFormatter.Space();
  1262. // TrackedVisit(addHandlerStatement.HandlerExpression, data);
  1263. // return null;
  1264. // }
  1265. //
  1266. // public override object TrackedVisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data)
  1267. // {
  1268. // outputFormatter.PrintToken(Tokens.RemoveHandler);
  1269. // outputFormatter.Space();
  1270. // TrackedVisit(removeHandlerStatement.EventExpression, data);
  1271. // outputFormatter.PrintToken(Tokens.Comma);
  1272. // outputFormatter.Space();
  1273. // TrackedVisit(removeHandlerStatement.HandlerExpression, data);
  1274. // return null;
  1275. // }
  1276. //
  1277. // public override object TrackedVisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data)
  1278. // {
  1279. // outputFormatter.PrintToken(Tokens.RaiseEvent);
  1280. // outputFormatter.Space();
  1281. // outputFormatter.PrintIdentifier(raiseEventStatement.EventName);
  1282. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  1283. // AppendCommaSeparatedList(raiseEventStatement.Arguments);
  1284. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  1285. // return null;
  1286. // }
  1287. //
  1288. // public override object TrackedVisitEraseStatement(EraseStatement eraseStatement, object data)
  1289. // {
  1290. // outputFormatter.PrintToken(Tokens.Erase);
  1291. // outputFormatter.Space();
  1292. // AppendCommaSeparatedList(eraseStatement.Expressions);
  1293. // return null;
  1294. // }
  1295. //
  1296. // public override object TrackedVisitErrorStatement(ErrorStatement errorStatement, object data)
  1297. // {
  1298. // outputFormatter.PrintToken(Tokens.Error);
  1299. // outputFormatter.Space();
  1300. // TrackedVisit(errorStatement.Expression, data);
  1301. // return null;
  1302. // }
  1303. //
  1304. // public override object TrackedVisitOnErrorStatement(OnErrorStatement onErrorStatement, object data)
  1305. // {
  1306. // outputFormatter.PrintToken(Tokens.On);
  1307. // outputFormatter.Space();
  1308. // outputFormatter.PrintToken(Tokens.Error);
  1309. // outputFormatter.Space();
  1310. // TrackedVisit(onErrorStatement.EmbeddedStatement, data);
  1311. // return null;
  1312. // }
  1313. //
  1314. // public override object TrackedVisitReDimStatement(ReDimStatement reDimStatement, object data)
  1315. // {
  1316. // outputFormatter.PrintToken(Tokens.ReDim);
  1317. // outputFormatter.Space();
  1318. // if (reDimStatement.IsPreserve) {
  1319. // outputFormatter.PrintToken(Tokens.Preserve);
  1320. // outputFormatter.Space();
  1321. // }
  1322. //
  1323. // AppendCommaSeparatedList(reDimStatement.ReDimClauses);
  1324. // return null;
  1325. // }
  1326. //
  1327. // public override object TrackedVisitExpressionStatement(ExpressionStatement expressionStatement, object data)
  1328. // {
  1329. // TrackedVisit(expressionStatement.Expression, data);
  1330. // return null;
  1331. // }
  1332. //
  1333. // public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
  1334. // {
  1335. // if (localVariableDeclaration.Modifier != Modifiers.None) {
  1336. // OutputModifier(localVariableDeclaration.Modifier & ~Modifiers.Dim);
  1337. // }
  1338. // if (!isUsingResourceAcquisition) {
  1339. // if ((localVariableDeclaration.Modifier & Modifiers.Const) == 0) {
  1340. // outputFormatter.PrintToken(Tokens.Dim);
  1341. // }
  1342. // outputFormatter.Space();
  1343. // }
  1344. // currentVariableType = localVariableDeclaration.TypeReference;
  1345. //
  1346. // AppendCommaSeparatedList(localVariableDeclaration.Variables);
  1347. // currentVariableType = null;
  1348. //
  1349. // return null;
  1350. // }
  1351. //
  1352. // public override object TrackedVisitReturnStatement(ReturnStatement returnStatement, object data)
  1353. // {
  1354. // outputFormatter.PrintToken(Tokens.Return);
  1355. // if (!returnStatement.Expression.IsNull) {
  1356. // outputFormatter.Space();
  1357. // TrackedVisit(returnStatement.Expression, data);
  1358. // }
  1359. // return null;
  1360. // }
  1361. //
  1362. // public override object TrackedVisitIfElseStatement(IfElseStatement ifElseStatement, object data)
  1363. // {
  1364. // outputFormatter.PrintToken(Tokens.If);
  1365. // outputFormatter.Space();
  1366. // TrackedVisit(ifElseStatement.Condition, data);
  1367. // outputFormatter.Space();
  1368. // outputFormatter.PrintToken(Tokens.Then);
  1369. // outputFormatter.NewLine();
  1370. //
  1371. // PrintIndentedBlock(ifElseStatement.TrueStatement);
  1372. //
  1373. // foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) {
  1374. // TrackedVisit(elseIfSection, data);
  1375. // }
  1376. //
  1377. // if (ifElseStatement.HasElseStatements) {
  1378. // outputFormatter.Indent();
  1379. // outputFormatter.PrintToken(Tokens.Else);
  1380. // outputFormatter.NewLine();
  1381. // PrintIndentedBlock(ifElseStatement.FalseStatement);
  1382. // }
  1383. //
  1384. // outputFormatter.Indent();
  1385. // outputFormatter.PrintToken(Tokens.End);
  1386. // outputFormatter.Space();
  1387. // outputFormatter.PrintToken(Tokens.If);
  1388. // return null;
  1389. // }
  1390. //
  1391. // public override object TrackedVisitElseIfSection(ElseIfSection elseIfSection, object data)
  1392. // {
  1393. // outputFormatter.Indent();
  1394. // outputFormatter.PrintToken(Tokens.ElseIf);
  1395. // outputFormatter.Space();
  1396. // TrackedVisit(elseIfSection.Condition, data);
  1397. // outputFormatter.Space();
  1398. // outputFormatter.PrintToken(Tokens.Then);
  1399. // outputFormatter.NewLine();
  1400. // PrintIndentedBlock(elseIfSection.EmbeddedStatement);
  1401. // return null;
  1402. // }
  1403. //
  1404. // public override object TrackedVisitLabelStatement(LabelStatement labelStatement, object data)
  1405. // {
  1406. // outputFormatter.PrintIdentifier(labelStatement.Label);
  1407. // outputFormatter.PrintToken(Tokens.Colon);
  1408. // return null;
  1409. // }
  1410. //
  1411. // public override object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data)
  1412. // {
  1413. // outputFormatter.PrintToken(Tokens.GoTo);
  1414. // outputFormatter.Space();
  1415. // outputFormatter.PrintIdentifier(gotoStatement.Label);
  1416. // return null;
  1417. // }
  1418. //
  1419. // public override object TrackedVisitSwitchStatement(SwitchStatement switchStatement, object data)
  1420. // {
  1421. // exitTokenStack.Push(Tokens.Select);
  1422. // outputFormatter.PrintToken(Tokens.Select);
  1423. // outputFormatter.Space();
  1424. // outputFormatter.PrintToken(Tokens.Case);
  1425. // outputFormatter.Space();
  1426. // TrackedVisit(switchStatement.SwitchExpression, data);
  1427. // outputFormatter.NewLine();
  1428. // ++outputFormatter.IndentationLevel;
  1429. // foreach (SwitchSection section in switchStatement.SwitchSections) {
  1430. // TrackedVisit(section, data);
  1431. // }
  1432. // --outputFormatter.IndentationLevel;
  1433. // outputFormatter.Indent();
  1434. // outputFormatter.PrintToken(Tokens.End);
  1435. // outputFormatter.Space();
  1436. // outputFormatter.PrintToken(Tokens.Select);
  1437. // exitTokenStack.Pop();
  1438. // return null;
  1439. // }
  1440. //
  1441. // public override object TrackedVisitSwitchSection(SwitchSection switchSection, object data)
  1442. // {
  1443. // outputFormatter.Indent();
  1444. // outputFormatter.PrintToken(Tokens.Case);
  1445. // outputFormatter.Space();
  1446. // this.AppendCommaSeparatedList(switchSection.SwitchLabels);
  1447. // outputFormatter.NewLine();
  1448. //
  1449. // PrintIndentedBlock(switchSection.Children);
  1450. //
  1451. // return null;
  1452. // }
  1453. //
  1454. // public override object TrackedVisitCaseLabel(CaseLabel caseLabel, object data)
  1455. // {
  1456. // if (caseLabel.IsDefault) {
  1457. // outputFormatter.PrintToken(Tokens.Else);
  1458. // } else {
  1459. // if (caseLabel.BinaryOperatorType != BinaryOperatorType.None) {
  1460. // switch (caseLabel.BinaryOperatorType) {
  1461. // case BinaryOperatorType.Equality:
  1462. // outputFormatter.PrintToken(Tokens.Assign);
  1463. // break;
  1464. // case BinaryOperatorType.InEquality:
  1465. // outputFormatter.PrintToken(Tokens.LessThan);
  1466. // outputFormatter.PrintToken(Tokens.GreaterThan);
  1467. // break;
  1468. //
  1469. // case BinaryOperatorType.GreaterThan:
  1470. // outputFormatter.PrintToken(Tokens.GreaterThan);
  1471. // break;
  1472. // case BinaryOperatorType.GreaterThanOrEqual:
  1473. // outputFormatter.PrintToken(Tokens.GreaterEqual);
  1474. // break;
  1475. // case BinaryOperatorType.LessThan:
  1476. // outputFormatter.PrintToken(Tokens.LessThan);
  1477. // break;
  1478. // case BinaryOperatorType.LessThanOrEqual:
  1479. // outputFormatter.PrintToken(Tokens.LessEqual);
  1480. // break;
  1481. // }
  1482. // outputFormatter.Space();
  1483. // }
  1484. //
  1485. // TrackedVisit(caseLabel.Label, data);
  1486. // if (!caseLabel.ToExpression.IsNull) {
  1487. // outputFormatter.Space();
  1488. // outputFormatter.PrintToken(Tokens.To);
  1489. // outputFormatter.Space();
  1490. // TrackedVisit(caseLabel.ToExpression, data);
  1491. // }
  1492. // }
  1493. //
  1494. // return null;
  1495. // }
  1496. //
  1497. // public override object TrackedVisitStopStatement(StopStatement stopStatement, object data)
  1498. // {
  1499. // outputFormatter.PrintToken(Tokens.Stop);
  1500. // return null;
  1501. // }
  1502. //
  1503. // public override object TrackedVisitResumeStatement(ResumeStatement resumeStatement, object data)
  1504. // {
  1505. // outputFormatter.PrintToken(Tokens.Resume);
  1506. // outputFormatter.Space();
  1507. // if (resumeStatement.IsResumeNext) {
  1508. // outputFormatter.PrintToken(Tokens.Next);
  1509. // } else {
  1510. // outputFormatter.PrintIdentifier(resumeStatement.LabelName);
  1511. // }
  1512. // return null;
  1513. // }
  1514. //
  1515. // public override object TrackedVisitEndStatement(EndStatement endStatement, object data)
  1516. // {
  1517. // outputFormatter.PrintToken(Tokens.End);
  1518. // return null;
  1519. // }
  1520. //
  1521. // public override object TrackedVisitContinueStatement(ContinueStatement continueStatement, object data)
  1522. // {
  1523. // outputFormatter.PrintToken(Tokens.Continue);
  1524. // outputFormatter.Space();
  1525. // switch (continueStatement.ContinueType) {
  1526. // case ContinueType.Do:
  1527. // outputFormatter.PrintToken(Tokens.Do);
  1528. // break;
  1529. // case ContinueType.For:
  1530. // outputFormatter.PrintToken(Tokens.For);
  1531. // break;
  1532. // case ContinueType.While:
  1533. // outputFormatter.PrintToken(Tokens.While);
  1534. // break;
  1535. // default:
  1536. // outputFormatter.PrintToken(exitTokenStack.Peek());
  1537. // break;
  1538. // }
  1539. // return null;
  1540. // }
  1541. //
  1542. // public override object TrackedVisitDoLoopStatement(DoLoopStatement doLoopStatement, object data)
  1543. // {
  1544. // if (doLoopStatement.ConditionPosition == ConditionPosition.None) {
  1545. // Error(String.Format("Unknown condition position for loop : {0}.", doLoopStatement), doLoopStatement.StartLocation);
  1546. // }
  1547. //
  1548. // if (doLoopStatement.ConditionPosition == ConditionPosition.Start) {
  1549. // switch (doLoopStatement.ConditionType) {
  1550. // case ConditionType.DoWhile:
  1551. // exitTokenStack.Push(Tokens.Do);
  1552. // outputFormatter.PrintToken(Tokens.Do);
  1553. // outputFormatter.Space();
  1554. // outputFormatter.PrintToken(Tokens.While);
  1555. // break;
  1556. // case ConditionType.While:
  1557. // exitTokenStack.Push(Tokens.While);
  1558. // outputFormatter.PrintToken(Tokens.While);
  1559. // break;
  1560. // case ConditionType.Until:
  1561. // exitTokenStack.Push(Tokens.Do);
  1562. // outputFormatter.PrintToken(Tokens.Do);
  1563. // outputFormatter.Space();
  1564. // outputFormatter.PrintToken(Tokens.While);
  1565. // break;
  1566. // default:
  1567. // throw new InvalidOperationException();
  1568. // }
  1569. // outputFormatter.Space();
  1570. // TrackedVisit(doLoopStatement.Condition, null);
  1571. // } else {
  1572. // exitTokenStack.Push(Tokens.Do);
  1573. // outputFormatter.PrintToken(Tokens.Do);
  1574. // }
  1575. //
  1576. // outputFormatter.NewLine();
  1577. //
  1578. // PrintIndentedBlock(doLoopStatement.EmbeddedStatement);
  1579. //
  1580. // outputFormatter.Indent();
  1581. // if (doLoopStatement.ConditionPosition == ConditionPosition.Start && doLoopStatement.ConditionType == ConditionType.While) {
  1582. // outputFormatter.PrintToken(Tokens.End);
  1583. // outputFormatter.Space();
  1584. // outputFormatter.PrintToken(Tokens.While);
  1585. // } else {
  1586. // outputFormatter.PrintToken(Tokens.Loop);
  1587. // }
  1588. //
  1589. // if (doLoopStatement.ConditionPosition == ConditionPosition.End && !doLoopStatement.Condition.IsNull) {
  1590. // outputFormatter.Space();
  1591. // switch (doLoopStatement.ConditionType) {
  1592. // case ConditionType.While:
  1593. // case ConditionType.DoWhile:
  1594. // outputFormatter.PrintToken(Tokens.While);
  1595. // break;
  1596. // case ConditionType.Until:
  1597. // outputFormatter.PrintToken(Tokens.Until);
  1598. // break;
  1599. // }
  1600. // outputFormatter.Space();
  1601. // TrackedVisit(doLoopStatement.Condition, null);
  1602. // }
  1603. // exitTokenStack.Pop();
  1604. // return null;
  1605. // }
  1606. //
  1607. // public override object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data)
  1608. // {
  1609. // exitTokenStack.Push(Tokens.For);
  1610. // outputFormatter.PrintToken(Tokens.For);
  1611. // outputFormatter.Space();
  1612. // outputFormatter.PrintToken(Tokens.Each);
  1613. // outputFormatter.Space();
  1614. //
  1615. // // loop control variable
  1616. // outputFormatter.PrintIdentifier(foreachStatement.VariableName);
  1617. // if (!foreachStatement.TypeReference.IsNull) {
  1618. // outputFormatter.Space();
  1619. // outputFormatter.PrintToken(Tokens.As);
  1620. // outputFormatter.Space();
  1621. // TrackedVisit(foreachStatement.TypeReference, data);
  1622. // }
  1623. //
  1624. // outputFormatter.Space();
  1625. // outputFormatter.PrintToken(Tokens.In);
  1626. // outputFormatter.Space();
  1627. //
  1628. // TrackedVisit(foreachStatement.Expression, data);
  1629. // outputFormatter.NewLine();
  1630. //
  1631. // PrintIndentedBlock(foreachStatement.EmbeddedStatement);
  1632. //
  1633. // outputFormatter.Indent();
  1634. // outputFormatter.PrintToken(Tokens.Next);
  1635. // if (!foreachStatement.NextExpression.IsNull) {
  1636. // outputFormatter.Space();
  1637. // TrackedVisit(foreachStatement.NextExpression, data);
  1638. // }
  1639. // exitTokenStack.Pop();
  1640. // return null;
  1641. // }
  1642. //
  1643. // public override object TrackedVisitLockStatement(LockStatement lockStatement, object data)
  1644. // {
  1645. // outputFormatter.PrintToken(Tokens.SyncLock);
  1646. // outputFormatter.Space();
  1647. // TrackedVisit(lockStatement.LockExpression, data);
  1648. // outputFormatter.NewLine();
  1649. //
  1650. // PrintIndentedBlock(lockStatement.EmbeddedStatement);
  1651. //
  1652. // outputFormatter.Indent();
  1653. // outputFormatter.PrintToken(Tokens.End);
  1654. // outputFormatter.Space();
  1655. // outputFormatter.PrintToken(Tokens.SyncLock);
  1656. // return null;
  1657. // }
  1658. //
  1659. // bool isUsingResourceAcquisition;
  1660. //
  1661. // public override object TrackedVisitUsingStatement(UsingStatement usingStatement, object data)
  1662. // {
  1663. // outputFormatter.PrintToken(Tokens.Using);
  1664. // outputFormatter.Space();
  1665. //
  1666. // isUsingResourceAcquisition = true;
  1667. // TrackedVisit(usingStatement.ResourceAcquisition, data);
  1668. // isUsingResourceAcquisition = false;
  1669. // outputFormatter.NewLine();
  1670. //
  1671. // PrintIndentedBlock(usingStatement.EmbeddedStatement);
  1672. //
  1673. // outputFormatter.Indent();
  1674. // outputFormatter.PrintToken(Tokens.End);
  1675. // outputFormatter.Space();
  1676. // outputFormatter.PrintToken(Tokens.Using);
  1677. //
  1678. // return null;
  1679. // }
  1680. //
  1681. // public override object TrackedVisitWithStatement(WithStatement withStatement, object data)
  1682. // {
  1683. // outputFormatter.PrintToken(Tokens.With);
  1684. // outputFormatter.Space();
  1685. // TrackedVisit(withStatement.Expression, data);
  1686. // outputFormatter.NewLine();
  1687. //
  1688. // PrintIndentedBlock(withStatement.Body);
  1689. //
  1690. // outputFormatter.PrintToken(Tokens.End);
  1691. // outputFormatter.Space();
  1692. // outputFormatter.PrintToken(Tokens.With);
  1693. // return null;
  1694. // }
  1695. //
  1696. // public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
  1697. // {
  1698. // exitTokenStack.Push(Tokens.Try);
  1699. // outputFormatter.PrintToken(Tokens.Try);
  1700. // outputFormatter.NewLine();
  1701. //
  1702. // PrintIndentedBlock(tryCatchStatement.StatementBlock);
  1703. //
  1704. // foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
  1705. // TrackedVisit(catchClause, data);
  1706. // }
  1707. //
  1708. // if (!tryCatchStatement.FinallyBlock.IsNull) {
  1709. // outputFormatter.Indent();
  1710. // outputFormatter.PrintToken(Tokens.Finally);
  1711. // outputFormatter.NewLine();
  1712. // PrintIndentedBlock(tryCatchStatement.FinallyBlock);
  1713. // }
  1714. // outputFormatter.Indent();
  1715. // outputFormatter.PrintToken(Tokens.End);
  1716. // outputFormatter.Space();
  1717. // outputFormatter.PrintToken(Tokens.Try);
  1718. // exitTokenStack.Pop();
  1719. // return null;
  1720. // }
  1721. //
  1722. // public override object TrackedVisitCatchClause(CatchClause catchClause, object data)
  1723. // {
  1724. // outputFormatter.Indent();
  1725. // outputFormatter.PrintToken(Tokens.Catch);
  1726. //
  1727. // if (!catchClause.TypeReference.IsNull) {
  1728. // outputFormatter.Space();
  1729. // if (catchClause.VariableName.Length > 0) {
  1730. // outputFormatter.PrintIdentifier(catchClause.VariableName);
  1731. // } else {
  1732. // outputFormatter.PrintIdentifier("generatedExceptionName");
  1733. // }
  1734. // outputFormatter.Space();
  1735. // outputFormatter.PrintToken(Tokens.As);
  1736. // outputFormatter.Space();
  1737. // outputFormatter.PrintIdentifier(catchClause.TypeReference.Type);
  1738. // }
  1739. //
  1740. // if (!catchClause.Condition.IsNull) {
  1741. // outputFormatter.Space();
  1742. // outputFormatter.PrintToken(Tokens.When);
  1743. // outputFormatter.Space();
  1744. // TrackedVisit(catchClause.Condition, data);
  1745. // }
  1746. // outputFormatter.NewLine();
  1747. //
  1748. // PrintIndentedBlock(catchClause.StatementBlock);
  1749. //
  1750. // return null;
  1751. // }
  1752. //
  1753. // public override object TrackedVisitThrowStatement(ThrowStatement throwStatement, object data)
  1754. // {
  1755. // outputFormatter.PrintToken(Tokens.Throw);
  1756. // if (!throwStatement.Expression.IsNull) {
  1757. // outputFormatter.Space();
  1758. // TrackedVisit(throwStatement.Expression, data);
  1759. // }
  1760. // return null;
  1761. // }
  1762. //
  1763. // public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data)
  1764. // {
  1765. // outputFormatter.PrintToken(Tokens.Exit);
  1766. // if (exitStatement.ExitType != ExitType.None) {
  1767. // outputFormatter.Space();
  1768. // switch (exitStatement.ExitType) {
  1769. // case ExitType.Sub:
  1770. // outputFormatter.PrintToken(Tokens.Sub);
  1771. // break;
  1772. // case ExitType.Function:
  1773. // outputFormatter.PrintToken(Tokens.Function);
  1774. // break;
  1775. // case ExitType.Property:
  1776. // outputFormatter.PrintToken(Tokens.Property);
  1777. // break;
  1778. // case ExitType.Do:
  1779. // outputFormatter.PrintToken(Tokens.Do);
  1780. // break;
  1781. // case ExitType.For:
  1782. // outputFormatter.PrintToken(Tokens.For);
  1783. // break;
  1784. // case ExitType.Try:
  1785. // outputFormatter.PrintToken(Tokens.Try);
  1786. // break;
  1787. // case ExitType.While:
  1788. // outputFormatter.PrintToken(Tokens.While);
  1789. // break;
  1790. // case ExitType.Select:
  1791. // outputFormatter.PrintToken(Tokens.Select);
  1792. // break;
  1793. // default:
  1794. // Error(String.Format("Unsupported exit type : {0}", exitStatement.ExitType), exitStatement.StartLocation);
  1795. // break;
  1796. // }
  1797. // }
  1798. //
  1799. // return null;
  1800. // }
  1801. //
  1802. // public override object TrackedVisitForNextStatement(ForNextStatement forNextStatement, object data)
  1803. // {
  1804. // exitTokenStack.Push(Tokens.For);
  1805. // outputFormatter.PrintToken(Tokens.For);
  1806. // outputFormatter.Space();
  1807. //
  1808. // if (!forNextStatement.LoopVariableExpression.IsNull) {
  1809. // TrackedVisit(forNextStatement.LoopVariableExpression, data);
  1810. // } else {
  1811. // outputFormatter.PrintIdentifier(forNextStatement.VariableName);
  1812. //
  1813. // if (!forNextStatement.TypeReference.IsNull) {
  1814. // outputFormatter.Space();
  1815. // outputFormatter.PrintToken(Tokens.As);
  1816. // outputFormatter.Space();
  1817. // TrackedVisit(forNextStatement.TypeReference, data);
  1818. // }
  1819. // }
  1820. //
  1821. // outputFormatter.Space();
  1822. // outputFormatter.PrintToken(Tokens.Assign);
  1823. // outputFormatter.Space();
  1824. //
  1825. // TrackedVisit(forNextStatement.Start, data);
  1826. //
  1827. // outputFormatter.Space();
  1828. // outputFormatter.PrintToken(Tokens.To);
  1829. // outputFormatter.Space();
  1830. //
  1831. // TrackedVisit(forNextStatement.End, data);
  1832. //
  1833. // if (!forNextStatement.Step.IsNull) {
  1834. // outputFormatter.Space();
  1835. // outputFormatter.PrintToken(Tokens.Step);
  1836. // outputFormatter.Space();
  1837. // TrackedVisit(forNextStatement.Step, data);
  1838. // }
  1839. // outputFormatter.NewLine();
  1840. //
  1841. // PrintIndentedBlock(forNextStatement.EmbeddedStatement);
  1842. //
  1843. // outputFormatter.Indent();
  1844. // outputFormatter.PrintToken(Tokens.Next);
  1845. //
  1846. // if (forNextStatement.NextExpressions.Count > 0) {
  1847. // outputFormatter.Space();
  1848. // AppendCommaSeparatedList(forNextStatement.NextExpressions);
  1849. // }
  1850. // exitTokenStack.Pop();
  1851. // return null;
  1852. // }
  1853. // #endregion
  1854. //
  1855. // #region Expressions
  1856. //
  1857. // public override object TrackedVisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data)
  1858. // {
  1859. // outputFormatter.PrintToken(Tokens.MyClass);
  1860. // return null;
  1861. // }
  1862. //
  1863. //
  1864. // static string ConvertCharLiteral(char ch)
  1865. // {
  1866. // if (Char.IsControl(ch)) {
  1867. // string charName = GetCharName(ch);
  1868. // if (charName != null)
  1869. // return "ControlChars." + charName;
  1870. // else
  1871. // return "ChrW(" + ((int)ch).ToString() + ")";
  1872. // } else if (ch == '"') {
  1873. // return "\"\"\"\"C";
  1874. // } else {
  1875. // return "\"" + ch.ToString() + "\"C";
  1876. // }
  1877. // }
  1878. //
  1879. // static string GetCharName(char ch)
  1880. // {
  1881. // switch (ch) {
  1882. // case '\b':
  1883. // return "Back";
  1884. // case '\r':
  1885. // return "Cr";
  1886. // case '\f':
  1887. // return "FormFeed";
  1888. // case '\n':
  1889. // return "Lf";
  1890. // case '\0':
  1891. // return "NullChar";
  1892. // case '\t':
  1893. // return "Tab";
  1894. // case '\v':
  1895. // return "VerticalTab";
  1896. // default:
  1897. // return null;
  1898. // }
  1899. // }
  1900. //
  1901. // static string ConvertString(string str)
  1902. // {
  1903. // StringBuilder sb = new StringBuilder();
  1904. // bool inString = false;
  1905. // foreach (char ch in str) {
  1906. // if (char.IsControl(ch)) {
  1907. // if (inString) {
  1908. // sb.Append('"');
  1909. // inString = false;
  1910. // }
  1911. // if (sb.Length > 0)
  1912. // sb.Append(" & ");
  1913. // string charName = GetCharName(ch);
  1914. // if (charName != null)
  1915. // sb.Append("vb" + charName);
  1916. // else
  1917. // sb.Append("ChrW(" + ((int)ch) + ")");
  1918. // } else {
  1919. // if (!inString) {
  1920. // if (sb.Length > 0)
  1921. // sb.Append(" & ");
  1922. // sb.Append('"');
  1923. // inString = true;
  1924. // }
  1925. // if (ch == '"') {
  1926. // sb.Append("\"\"");
  1927. // } else {
  1928. // sb.Append(ch);
  1929. // }
  1930. // }
  1931. // }
  1932. // if (inString)
  1933. // sb.Append('"');
  1934. // if (sb.Length == 0)
  1935. // return "\"\"";
  1936. // return sb.ToString();
  1937. // }
  1938. //
  1939. // public override object TrackedVisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
  1940. // {
  1941. // outputFormatter.PrintText(ToVBNetString(primitiveExpression));
  1942. // return null;
  1943. // }
  1944. //
  1945. // internal static string ToVBNetString(PrimitiveExpression primitiveExpression)
  1946. // {
  1947. // object val = primitiveExpression.Value;
  1948. // if (val == null) {
  1949. // return "Nothing";
  1950. // }
  1951. // if (val is bool) {
  1952. // if ((bool)primitiveExpression.Value) {
  1953. // return "True";
  1954. // } else {
  1955. // return "False";
  1956. // }
  1957. // }
  1958. //
  1959. // if (val is string) {
  1960. // return ConvertString((string)val);
  1961. // }
  1962. //
  1963. // if (val is char) {
  1964. // return ConvertCharLiteral((char)primitiveExpression.Value);
  1965. // }
  1966. //
  1967. // if (val is decimal) {
  1968. // return ((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D";
  1969. // }
  1970. //
  1971. // if (val is float) {
  1972. // return ((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F";
  1973. // }
  1974. //
  1975. // if (val is double) {
  1976. // string text = ((double)val).ToString(NumberFormatInfo.InvariantInfo);
  1977. // if (text.IndexOf('.') < 0 && text.IndexOf('E') < 0)
  1978. // return text + ".0";
  1979. // else
  1980. // return text;
  1981. // }
  1982. //
  1983. // if (val is IFormattable) {
  1984. // StringBuilder b = new StringBuilder();
  1985. // if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) {
  1986. // b.Append("&H");
  1987. // b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo));
  1988. // } else {
  1989. // b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo));
  1990. // }
  1991. // if (val is ushort || val is uint || val is ulong) {
  1992. // b.Append('U');
  1993. // if (val is uint)
  1994. // b.Append('I');
  1995. // }
  1996. // if (val is long || val is ulong)
  1997. // b.Append('L');
  1998. // if (val is short || val is ushort)
  1999. // b.Append('S');
  2000. // return b.ToString();
  2001. // } else {
  2002. // return val.ToString();
  2003. // }
  2004. // }
  2005. //
  2006. // public override object TrackedVisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data)
  2007. // {
  2008. // int op = 0;
  2009. // switch (binaryOperatorExpression.Op) {
  2010. // case BinaryOperatorType.Concat:
  2011. // op = Tokens.ConcatString;
  2012. // break;
  2013. //
  2014. // case BinaryOperatorType.Add:
  2015. // op = Tokens.Plus;
  2016. // break;
  2017. //
  2018. // case BinaryOperatorType.Subtract:
  2019. // op = Tokens.Minus;
  2020. // break;
  2021. //
  2022. // case BinaryOperatorType.Multiply:
  2023. // op = Tokens.Times;
  2024. // break;
  2025. //
  2026. // case BinaryOperatorType.Divide:
  2027. // op = Tokens.Div;
  2028. // break;
  2029. //
  2030. // case BinaryOperatorType.DivideInteger:
  2031. // op = Tokens.DivInteger;
  2032. // break;
  2033. //
  2034. // case BinaryOperatorType.Modulus:
  2035. // op = Tokens.Mod;
  2036. // break;
  2037. //
  2038. // case BinaryOperatorType.ShiftLeft:
  2039. // op = Tokens.ShiftLeft;
  2040. // break;
  2041. //
  2042. // case BinaryOperatorType.ShiftRight:
  2043. // op = Tokens.ShiftRight;
  2044. // break;
  2045. //
  2046. // case BinaryOperatorType.BitwiseAnd:
  2047. // op = Tokens.And;
  2048. // break;
  2049. // case BinaryOperatorType.BitwiseOr:
  2050. // op = Tokens.Or;
  2051. // break;
  2052. // case BinaryOperatorType.ExclusiveOr:
  2053. // op = Tokens.Xor;
  2054. // break;
  2055. //
  2056. // case BinaryOperatorType.LogicalAnd:
  2057. // op = Tokens.AndAlso;
  2058. // break;
  2059. // case BinaryOperatorType.LogicalOr:
  2060. // op = Tokens.OrElse;
  2061. // break;
  2062. // case BinaryOperatorType.ReferenceEquality:
  2063. // op = Tokens.Is;
  2064. // break;
  2065. // case BinaryOperatorType.ReferenceInequality:
  2066. // op = Tokens.IsNot;
  2067. // break;
  2068. //
  2069. // case BinaryOperatorType.Equality:
  2070. // op = Tokens.Assign;
  2071. // break;
  2072. // case BinaryOperatorType.GreaterThan:
  2073. // op = Tokens.GreaterThan;
  2074. // break;
  2075. // case BinaryOperatorType.GreaterThanOrEqual:
  2076. // op = Tokens.GreaterEqual;
  2077. // break;
  2078. // case BinaryOperatorType.InEquality:
  2079. // op = Tokens.NotEqual;
  2080. // break;
  2081. // case BinaryOperatorType.NullCoalescing:
  2082. // outputFormatter.PrintText("If(");
  2083. // TrackedVisit(binaryOperatorExpression.Left, data);
  2084. // outputFormatter.PrintToken(Tokens.Comma);
  2085. // outputFormatter.Space();
  2086. // TrackedVisit(binaryOperatorExpression.Right, data);
  2087. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2088. // return null;
  2089. // case BinaryOperatorType.DictionaryAccess:
  2090. // {
  2091. // PrimitiveExpression pright = binaryOperatorExpression.Right as PrimitiveExpression;
  2092. // TrackedVisit(binaryOperatorExpression.Left, data);
  2093. // if (pright != null && pright.Value is string) {
  2094. // outputFormatter.PrintText("!" + (string)pright.Value);
  2095. // } else {
  2096. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2097. // TrackedVisit(binaryOperatorExpression.Right, data);
  2098. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2099. // }
  2100. // return null;
  2101. // }
  2102. // case BinaryOperatorType.LessThan:
  2103. // op = Tokens.LessThan;
  2104. // break;
  2105. // case BinaryOperatorType.LessThanOrEqual:
  2106. // op = Tokens.LessEqual;
  2107. // break;
  2108. // }
  2109. //
  2110. //
  2111. // BinaryOperatorExpression childBoe = binaryOperatorExpression.Left as BinaryOperatorExpression;
  2112. // bool requireParenthesis = childBoe != null && OperatorPrecedence.ComparePrecedenceVB(binaryOperatorExpression.Op, childBoe.Op) > 0;
  2113. // if (requireParenthesis)
  2114. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2115. // TrackedVisit(binaryOperatorExpression.Left, data);
  2116. // if (requireParenthesis)
  2117. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2118. //
  2119. // outputFormatter.Space();
  2120. // outputFormatter.PrintToken(op);
  2121. // outputFormatter.Space();
  2122. //
  2123. // childBoe = binaryOperatorExpression.Right as BinaryOperatorExpression;
  2124. // requireParenthesis = childBoe != null && OperatorPrecedence.ComparePrecedenceVB(binaryOperatorExpression.Op, childBoe.Op) >= 0;
  2125. // if (requireParenthesis)
  2126. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2127. // TrackedVisit(binaryOperatorExpression.Right, data);
  2128. // if (requireParenthesis)
  2129. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2130. //
  2131. // return null;
  2132. // }
  2133. //
  2134. // public override object TrackedVisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
  2135. // {
  2136. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2137. // TrackedVisit(parenthesizedExpression.Expression, data);
  2138. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2139. // return null;
  2140. // }
  2141. //
  2142. // public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data)
  2143. // {
  2144. // TrackedVisit(invocationExpression.TargetObject, data);
  2145. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2146. // AppendCommaSeparatedList(invocationExpression.Arguments);
  2147. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2148. // return null;
  2149. // }
  2150. //
  2151. // void PrintTypeArguments(List<TypeReference> typeArguments)
  2152. // {
  2153. // if (typeArguments != null && typeArguments.Count > 0) {
  2154. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2155. // outputFormatter.PrintToken(Tokens.Of);
  2156. // outputFormatter.Space();
  2157. // AppendCommaSeparatedList(typeArguments);
  2158. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2159. // }
  2160. // }
  2161. //
  2162. // public override object TrackedVisitIdentifierExpression(SimpleNameExpression identifierExpression, object data)
  2163. // {
  2164. // outputFormatter.PrintIdentifier(identifierExpression.Identifier);
  2165. // PrintTypeArguments(identifierExpression.TypeArguments);
  2166. // return null;
  2167. // }
  2168. //
  2169. // public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
  2170. // {
  2171. // TrackedVisit(typeReferenceExpression.TypeReference, data);
  2172. // return null;
  2173. // }
  2174. //
  2175. // public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
  2176. // {
  2177. // switch (unaryOperatorExpression.Op) {
  2178. // case UnaryOperatorType.Not:
  2179. // case UnaryOperatorType.BitNot:
  2180. // outputFormatter.PrintToken(Tokens.Not);
  2181. // outputFormatter.Space();
  2182. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2183. // return null;
  2184. //
  2185. // case UnaryOperatorType.Decrement:
  2186. // outputFormatter.PrintText("System.Threading.Interlocked.Decrement(");
  2187. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2188. // outputFormatter.PrintText(")");
  2189. // return null;
  2190. //
  2191. // case UnaryOperatorType.Increment:
  2192. // outputFormatter.PrintText("System.Threading.Interlocked.Increment(");
  2193. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2194. // outputFormatter.PrintText(")");
  2195. // return null;
  2196. //
  2197. // case UnaryOperatorType.Minus:
  2198. // outputFormatter.PrintToken(Tokens.Minus);
  2199. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2200. // return null;
  2201. //
  2202. // case UnaryOperatorType.Plus:
  2203. // outputFormatter.PrintToken(Tokens.Plus);
  2204. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2205. // return null;
  2206. //
  2207. // case UnaryOperatorType.PostDecrement:
  2208. // outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Decrement(");
  2209. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2210. // outputFormatter.PrintText("),");
  2211. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2212. // outputFormatter.PrintText(" + 1)");
  2213. // return null;
  2214. //
  2215. // case UnaryOperatorType.PostIncrement:
  2216. // outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Increment(");
  2217. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2218. // outputFormatter.PrintText("),");
  2219. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2220. // outputFormatter.PrintText(" - 1)");
  2221. // return null;
  2222. //
  2223. // case UnaryOperatorType.Dereference:
  2224. // outputFormatter.PrintToken(Tokens.Times);
  2225. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2226. // return null;
  2227. // case UnaryOperatorType.AddressOf:
  2228. // outputFormatter.PrintToken(Tokens.AddressOf);
  2229. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2230. // return null;
  2231. // default:
  2232. // Error("unknown unary operator: " + unaryOperatorExpression.Op.ToString(), unaryOperatorExpression.StartLocation);
  2233. // outputFormatter.PrintText(unaryOperatorExpression.Op.ToString());
  2234. // outputFormatter.PrintText("(");
  2235. // TrackedVisit(unaryOperatorExpression.Expression, data);
  2236. // outputFormatter.PrintText(")");
  2237. // return null;
  2238. // }
  2239. // }
  2240. //
  2241. // public override object TrackedVisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
  2242. // {
  2243. // int op = 0;
  2244. // bool unsupportedOpAssignment = false;
  2245. // switch (assignmentExpression.Op) {
  2246. // case AssignmentOperatorType.Assign:
  2247. // op = Tokens.Assign;
  2248. // break;
  2249. // case AssignmentOperatorType.Add:
  2250. // op = Tokens.PlusAssign;
  2251. // break;
  2252. // case AssignmentOperatorType.Subtract:
  2253. // op = Tokens.MinusAssign;
  2254. // break;
  2255. // case AssignmentOperatorType.Multiply:
  2256. // op = Tokens.TimesAssign;
  2257. // break;
  2258. // case AssignmentOperatorType.Divide:
  2259. // op = Tokens.DivAssign;
  2260. // break;
  2261. // case AssignmentOperatorType.ShiftLeft:
  2262. // op = Tokens.ShiftLeftAssign;
  2263. // break;
  2264. // case AssignmentOperatorType.ShiftRight:
  2265. // op = Tokens.ShiftRightAssign;
  2266. // break;
  2267. //
  2268. // case AssignmentOperatorType.ExclusiveOr:
  2269. // op = Tokens.Xor;
  2270. // unsupportedOpAssignment = true;
  2271. // break;
  2272. // case AssignmentOperatorType.Modulus:
  2273. // op = Tokens.Mod;
  2274. // unsupportedOpAssignment = true;
  2275. // break;
  2276. // case AssignmentOperatorType.BitwiseAnd:
  2277. // op = Tokens.And;
  2278. // unsupportedOpAssignment = true;
  2279. // break;
  2280. // case AssignmentOperatorType.BitwiseOr:
  2281. // op = Tokens.Or;
  2282. // unsupportedOpAssignment = true;
  2283. // break;
  2284. // }
  2285. //
  2286. // TrackedVisit(assignmentExpression.Left, data);
  2287. // outputFormatter.Space();
  2288. //
  2289. // if (unsupportedOpAssignment) { // left = left OP right
  2290. // outputFormatter.PrintToken(Tokens.Assign);
  2291. // outputFormatter.Space();
  2292. // TrackedVisit(assignmentExpression.Left, data);
  2293. // outputFormatter.Space();
  2294. // }
  2295. //
  2296. // outputFormatter.PrintToken(op);
  2297. // outputFormatter.Space();
  2298. // TrackedVisit(assignmentExpression.Right, data);
  2299. //
  2300. // return null;
  2301. // }
  2302. //
  2303. // public override object TrackedVisitTypeOfExpression(TypeOfExpression typeOfExpression, object data)
  2304. // {
  2305. // outputFormatter.PrintToken(Tokens.GetType);
  2306. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2307. // TrackedVisit(typeOfExpression.TypeReference, data);
  2308. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2309. // return null;
  2310. // }
  2311. //
  2312. // public override object TrackedVisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
  2313. // {
  2314. // // assigning nothing to a generic type in VB compiles to a DefaultValueExpression
  2315. // outputFormatter.PrintToken(Tokens.Nothing);
  2316. // return null;
  2317. // }
  2318. //
  2319. // public override object TrackedVisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data)
  2320. // {
  2321. // outputFormatter.PrintToken(Tokens.TypeOf);
  2322. // outputFormatter.Space();
  2323. // TrackedVisit(typeOfIsExpression.Expression, data);
  2324. // outputFormatter.Space();
  2325. // outputFormatter.PrintToken(Tokens.Is);
  2326. // outputFormatter.Space();
  2327. // TrackedVisit(typeOfIsExpression.TypeReference, data);
  2328. // return null;
  2329. // }
  2330. //
  2331. // public override object TrackedVisitAddressOfExpression(AddressOfExpression addressOfExpression, object data)
  2332. // {
  2333. // outputFormatter.PrintToken(Tokens.AddressOf);
  2334. // outputFormatter.Space();
  2335. // TrackedVisit(addressOfExpression.Expression, data);
  2336. // return null;
  2337. // }
  2338. //
  2339. // public override object TrackedVisitCastExpression(CastExpression castExpression, object data)
  2340. // {
  2341. // if (castExpression.CastType == CastType.TryCast) {
  2342. // return PrintCast(Tokens.TryCast, castExpression);
  2343. // }
  2344. // if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) {
  2345. // return PrintCast(Tokens.DirectCast, castExpression);
  2346. // }
  2347. // switch (castExpression.CastTo.Type) {
  2348. // case "System.Boolean":
  2349. // outputFormatter.PrintToken(Tokens.CBool);
  2350. // break;
  2351. // case "System.Byte":
  2352. // outputFormatter.PrintToken(Tokens.CByte);
  2353. // break;
  2354. // case "System.SByte":
  2355. // outputFormatter.PrintToken(Tokens.CSByte);
  2356. // break;
  2357. // case "System.Char":
  2358. // outputFormatter.PrintToken(Tokens.CChar);
  2359. // break;
  2360. // case "System.DateTime":
  2361. // outputFormatter.PrintToken(Tokens.CDate);
  2362. // break;
  2363. // case "System.Decimal":
  2364. // outputFormatter.PrintToken(Tokens.CDec);
  2365. // break;
  2366. // case "System.Double":
  2367. // outputFormatter.PrintToken(Tokens.CDbl);
  2368. // break;
  2369. // case "System.Int16":
  2370. // outputFormatter.PrintToken(Tokens.CShort);
  2371. // break;
  2372. // case "System.Int32":
  2373. // outputFormatter.PrintToken(Tokens.CInt);
  2374. // break;
  2375. // case "System.Int64":
  2376. // outputFormatter.PrintToken(Tokens.CLng);
  2377. // break;
  2378. // case "System.UInt16":
  2379. // outputFormatter.PrintToken(Tokens.CUShort);
  2380. // break;
  2381. // case "System.UInt32":
  2382. // outputFormatter.PrintToken(Tokens.CUInt);
  2383. // break;
  2384. // case "System.UInt64":
  2385. // outputFormatter.PrintToken(Tokens.CULng);
  2386. // break;
  2387. // case "System.Object":
  2388. // outputFormatter.PrintToken(Tokens.CObj);
  2389. // break;
  2390. // case "System.Single":
  2391. // outputFormatter.PrintToken(Tokens.CSng);
  2392. // break;
  2393. // case "System.String":
  2394. // outputFormatter.PrintToken(Tokens.CStr);
  2395. // break;
  2396. // default:
  2397. // return PrintCast(Tokens.CType, castExpression);
  2398. // }
  2399. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2400. // TrackedVisit(castExpression.Expression, data);
  2401. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2402. // return null;
  2403. // }
  2404. //
  2405. // object PrintCast(int castToken, CastExpression castExpression)
  2406. // {
  2407. // outputFormatter.PrintToken(castToken);
  2408. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2409. // TrackedVisit(castExpression.Expression, null);
  2410. // outputFormatter.PrintToken(Tokens.Comma);
  2411. // outputFormatter.Space();
  2412. // TrackedVisit(castExpression.CastTo, null);
  2413. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2414. // return null;
  2415. // }
  2416. //
  2417. // public override object TrackedVisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data)
  2418. // {
  2419. // outputFormatter.PrintToken(Tokens.Me);
  2420. // return null;
  2421. // }
  2422. //
  2423. // public override object TrackedVisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data)
  2424. // {
  2425. // outputFormatter.PrintToken(Tokens.MyBase);
  2426. // return null;
  2427. // }
  2428. //
  2429. // public override object TrackedVisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
  2430. // {
  2431. // outputFormatter.PrintToken(Tokens.New);
  2432. // if (!objectCreateExpression.IsAnonymousType) {
  2433. // outputFormatter.Space();
  2434. // TrackedVisit(objectCreateExpression.CreateType, data);
  2435. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2436. // AppendCommaSeparatedList(objectCreateExpression.Parameters);
  2437. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2438. // }
  2439. // CollectionInitializerExpression initializer = objectCreateExpression.ObjectInitializer;
  2440. // if (!initializer.IsNull) {
  2441. // outputFormatter.Space();
  2442. // if (initializer.CreateExpressions.Any(ce => ce is MemberInitializerExpression))
  2443. // outputFormatter.PrintToken(Tokens.With);
  2444. // else
  2445. // outputFormatter.PrintToken(Tokens.From);
  2446. // outputFormatter.Space();
  2447. // outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
  2448. // outputFormatter.IndentationLevel++;
  2449. // for (int i = 0; i < initializer.CreateExpressions.Count; i++) {
  2450. // Expression expr = initializer.CreateExpressions[i];
  2451. // if (i > 0)
  2452. // outputFormatter.PrintToken(Tokens.Comma);
  2453. // outputFormatter.PrintLineContinuation();
  2454. // outputFormatter.Indent();
  2455. // TrackedVisit(expr, data);
  2456. // }
  2457. // outputFormatter.IndentationLevel--;
  2458. // outputFormatter.PrintLineContinuation();
  2459. // outputFormatter.Indent();
  2460. // outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
  2461. // }
  2462. // return null;
  2463. // }
  2464. //
  2465. // public override object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
  2466. // {
  2467. // outputFormatter.PrintToken(Tokens.New);
  2468. // outputFormatter.Space();
  2469. // PrintTypeReferenceWithoutArray(arrayCreateExpression.CreateType);
  2470. //
  2471. // if (arrayCreateExpression.Arguments.Count > 0) {
  2472. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2473. // AppendCommaSeparatedList(arrayCreateExpression.Arguments);
  2474. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2475. // PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 1);
  2476. // } else {
  2477. // PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 0);
  2478. // }
  2479. //
  2480. // outputFormatter.Space();
  2481. //
  2482. // if (arrayCreateExpression.ArrayInitializer.IsNull) {
  2483. // outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
  2484. // outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
  2485. // } else {
  2486. // TrackedVisit(arrayCreateExpression.ArrayInitializer, data);
  2487. // }
  2488. // return null;
  2489. // }
  2490. //
  2491. // public override object TrackedVisitCollectionInitializerExpression(CollectionInitializerExpression arrayInitializerExpression, object data)
  2492. // {
  2493. // outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
  2494. // this.AppendCommaSeparatedList(arrayInitializerExpression.CreateExpressions);
  2495. // outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
  2496. // return null;
  2497. // }
  2498. //
  2499. // public override object TrackedVisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data)
  2500. // {
  2501. // if (memberInitializerExpression.IsKey) {
  2502. // outputFormatter.PrintToken(Tokens.Key);
  2503. // outputFormatter.Space();
  2504. // }
  2505. // outputFormatter.PrintToken(Tokens.Dot);
  2506. // outputFormatter.PrintIdentifier(memberInitializerExpression.Name);
  2507. // outputFormatter.Space();
  2508. // outputFormatter.PrintToken(Tokens.Assign);
  2509. // outputFormatter.Space();
  2510. // TrackedVisit(memberInitializerExpression.Expression, data);
  2511. // return null;
  2512. // }
  2513. //
  2514. // public override object TrackedVisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
  2515. // {
  2516. // TrackedVisit(memberReferenceExpression.TargetObject, data);
  2517. // outputFormatter.PrintToken(Tokens.Dot);
  2518. // if (string.Equals(memberReferenceExpression.MemberName, "New", StringComparison.OrdinalIgnoreCase)
  2519. // && (memberReferenceExpression.TargetObject is BaseReferenceExpression || memberReferenceExpression.TargetObject is ThisReferenceExpression || memberReferenceExpression.TargetObject is ClassReferenceExpression))
  2520. // {
  2521. // outputFormatter.PrintToken(Tokens.New);
  2522. // } else {
  2523. // outputFormatter.PrintIdentifier(memberReferenceExpression.MemberName);
  2524. // }
  2525. // PrintTypeArguments(memberReferenceExpression.TypeArguments);
  2526. // return null;
  2527. // }
  2528. //
  2529. // public override object TrackedVisitDirectionExpression(DirectionExpression directionExpression, object data)
  2530. // {
  2531. // // VB does not need to specify the direction in method calls
  2532. // TrackedVisit(directionExpression.Expression, data);
  2533. // return null;
  2534. // }
  2535. //
  2536. //
  2537. // public override object TrackedVisitConditionalExpression(ConditionalExpression conditionalExpression, object data)
  2538. // {
  2539. // outputFormatter.PrintText("If");
  2540. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2541. // TrackedVisit(conditionalExpression.Condition, data);
  2542. // outputFormatter.PrintToken(Tokens.Comma);
  2543. // outputFormatter.Space();
  2544. // TrackedVisit(conditionalExpression.TrueExpression, data);
  2545. // outputFormatter.PrintToken(Tokens.Comma);
  2546. // outputFormatter.Space();
  2547. // TrackedVisit(conditionalExpression.FalseExpression, data);
  2548. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2549. // return null;
  2550. // }
  2551. //
  2552. // #endregion
  2553. // #endregion
  2554. //
  2555. //
  2556. // void OutputModifier(ParameterModifiers modifier)
  2557. // {
  2558. // if ((modifier & ParameterModifiers.Optional) == ParameterModifiers.Optional) {
  2559. // outputFormatter.PrintToken(Tokens.Optional);
  2560. // outputFormatter.Space();
  2561. // }
  2562. // if ((modifier & ParameterModifiers.Ref) == ParameterModifiers.Ref
  2563. // || (modifier & ParameterModifiers.Out) == ParameterModifiers.Out) {
  2564. // outputFormatter.PrintToken(Tokens.ByRef);
  2565. // outputFormatter.Space();
  2566. // }
  2567. // if ((modifier & ParameterModifiers.Params) == ParameterModifiers.Params) {
  2568. // outputFormatter.PrintToken(Tokens.ParamArray);
  2569. // outputFormatter.Space();
  2570. // }
  2571. // if (prettyPrintOptions.OutputByValModifier &&
  2572. // (modifier & (ParameterModifiers.Params | ParameterModifiers.Ref)) == ParameterModifiers.None)
  2573. // {
  2574. // outputFormatter.PrintToken(Tokens.ByVal);
  2575. // outputFormatter.Space();
  2576. // }
  2577. // }
  2578. //
  2579. // void OutputModifier(Modifiers modifier)
  2580. // {
  2581. // OutputModifier(modifier, false, false);
  2582. // }
  2583. //
  2584. // void OutputModifier(Modifiers modifier, bool forTypeDecl, bool forFieldDecl)
  2585. // {
  2586. // if ((modifier & Modifiers.Public) == Modifiers.Public) {
  2587. // outputFormatter.PrintToken(Tokens.Public);
  2588. // outputFormatter.Space();
  2589. // } else if ((modifier & Modifiers.Private) == Modifiers.Private) {
  2590. // outputFormatter.PrintToken(Tokens.Private);
  2591. // outputFormatter.Space();
  2592. // } else if ((modifier & (Modifiers.Protected | Modifiers.Internal)) == (Modifiers.Protected | Modifiers.Internal)) {
  2593. // outputFormatter.PrintToken(Tokens.Protected);
  2594. // outputFormatter.Space();
  2595. // outputFormatter.PrintToken(Tokens.Friend);
  2596. // outputFormatter.Space();
  2597. // } else if ((modifier & Modifiers.Internal) == Modifiers.Internal) {
  2598. // outputFormatter.PrintToken(Tokens.Friend);
  2599. // outputFormatter.Space();
  2600. // } else if ((modifier & Modifiers.Protected) == Modifiers.Protected) {
  2601. // outputFormatter.PrintToken(Tokens.Protected);
  2602. // outputFormatter.Space();
  2603. // }
  2604. //
  2605. // if ((modifier & Modifiers.Static) == Modifiers.Static) {
  2606. // outputFormatter.PrintToken(Tokens.Shared);
  2607. // outputFormatter.Space();
  2608. // }
  2609. // if ((modifier & Modifiers.Virtual) == Modifiers.Virtual) {
  2610. // outputFormatter.PrintToken(Tokens.Overridable);
  2611. // outputFormatter.Space();
  2612. // }
  2613. // if ((modifier & Modifiers.Abstract) == Modifiers.Abstract) {
  2614. // if (forFieldDecl)
  2615. // outputFormatter.PrintToken(Tokens.Dim);
  2616. // else if (forTypeDecl)
  2617. // outputFormatter.PrintToken(Tokens.MustInherit);
  2618. // else
  2619. // outputFormatter.PrintToken(Tokens.MustOverride);
  2620. // outputFormatter.Space();
  2621. // }
  2622. // if ((modifier & Modifiers.Dim) == Modifiers.Dim) {
  2623. // outputFormatter.PrintToken(Tokens.Dim);
  2624. // outputFormatter.Space();
  2625. // }
  2626. // if ((modifier & Modifiers.Overloads) == Modifiers.Overloads) {
  2627. // outputFormatter.PrintToken(Tokens.Overloads);
  2628. // outputFormatter.Space();
  2629. // }
  2630. // if ((modifier & Modifiers.Override) == Modifiers.Override) {
  2631. // outputFormatter.PrintToken(Tokens.Overrides);
  2632. // outputFormatter.Space();
  2633. // }
  2634. // if ((modifier & Modifiers.New) == Modifiers.New) {
  2635. // outputFormatter.PrintToken(Tokens.Shadows);
  2636. // outputFormatter.Space();
  2637. // }
  2638. //
  2639. // if ((modifier & Modifiers.Sealed) == Modifiers.Sealed) {
  2640. // outputFormatter.PrintToken(forTypeDecl ? Tokens.NotInheritable : Tokens.NotOverridable);
  2641. // outputFormatter.Space();
  2642. // }
  2643. //
  2644. // if ((modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly) {
  2645. // outputFormatter.PrintToken(Tokens.ReadOnly);
  2646. // outputFormatter.Space();
  2647. // }
  2648. // if ((modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly) {
  2649. // outputFormatter.PrintToken(Tokens.WriteOnly);
  2650. // outputFormatter.Space();
  2651. // }
  2652. // if ((modifier & Modifiers.Const) == Modifiers.Const) {
  2653. // outputFormatter.PrintToken(Tokens.Const);
  2654. // outputFormatter.Space();
  2655. // }
  2656. // if ((modifier & Modifiers.WithEvents) == Modifiers.WithEvents) {
  2657. // outputFormatter.PrintToken(Tokens.WithEvents);
  2658. // outputFormatter.Space();
  2659. // }
  2660. // if ((modifier & Modifiers.Partial) == Modifiers.Partial) {
  2661. // outputFormatter.PrintToken(Tokens.Partial);
  2662. // outputFormatter.Space();
  2663. // }
  2664. //
  2665. // if ((modifier & Modifiers.Extern) == Modifiers.Extern) {
  2666. // // not required in VB
  2667. // }
  2668. //
  2669. // if ((modifier & Modifiers.Default) == Modifiers.Default) {
  2670. // outputFormatter.PrintToken(Tokens.Default);
  2671. // outputFormatter.Space();
  2672. // }
  2673. //
  2674. // if ((modifier & Modifiers.Volatile) == Modifiers.Volatile) {
  2675. // Error("'Volatile' modifier not convertable", Location.Empty);
  2676. // }
  2677. //
  2678. // if ((modifier & Modifiers.Unsafe) == Modifiers.Unsafe) {
  2679. // Error("'Unsafe' modifier not convertable", Location.Empty);
  2680. // }
  2681. // }
  2682. //
  2683. // public void AppendCommaSeparatedList<T>(ICollection<T> list) where T : class, INode
  2684. // {
  2685. // if (list != null) {
  2686. // int i = 0;
  2687. // foreach (T node in list) {
  2688. // TrackedVisit(node, null);
  2689. // if (i + 1 < list.Count) {
  2690. // outputFormatter.PrintToken(Tokens.Comma);
  2691. // outputFormatter.Space();
  2692. // if ((i + 1) % 6 == 0) {
  2693. // outputFormatter.PrintLineContinuation();
  2694. // outputFormatter.Indent();
  2695. // outputFormatter.PrintText("\t");
  2696. // }
  2697. // }
  2698. // i++;
  2699. // }
  2700. // }
  2701. // }
  2702. //
  2703. // void VisitAttributes(ICollection attributes, object data)
  2704. // {
  2705. // if (attributes == null) {
  2706. // return;
  2707. // }
  2708. // foreach (AttributeSection section in attributes) {
  2709. // if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase))
  2710. // continue;
  2711. // TrackedVisit(section, data);
  2712. // }
  2713. // }
  2714. //
  2715. // void VisitReturnTypeAttributes(ICollection attributes, object data)
  2716. // {
  2717. // if (attributes == null) {
  2718. // return;
  2719. // }
  2720. // printAttributeSectionInline = true;
  2721. // foreach (AttributeSection section in attributes) {
  2722. // if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) {
  2723. // TrackedVisit(section, data);
  2724. // }
  2725. // }
  2726. // printAttributeSectionInline = false;
  2727. // }
  2728. //
  2729. // public override object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data)
  2730. // {
  2731. // bool isSub = !lambdaExpression.ReturnType.IsNull &&
  2732. // lambdaExpression.ReturnType.Type == "System.Void" && lambdaExpression.ReturnType.IsKeyword;
  2733. //
  2734. // if (isSub)
  2735. // outputFormatter.PrintToken(Tokens.Sub);
  2736. // else
  2737. // outputFormatter.PrintToken(Tokens.Function);
  2738. //
  2739. // outputFormatter.PrintToken(Tokens.OpenParenthesis);
  2740. // AppendCommaSeparatedList(lambdaExpression.Parameters);
  2741. // outputFormatter.PrintToken(Tokens.CloseParenthesis);
  2742. //
  2743. // outputFormatter.Space();
  2744. //
  2745. // if (!lambdaExpression.ExpressionBody.IsNull) {
  2746. // return lambdaExpression.ExpressionBody.AcceptVisitor(this, data);
  2747. // } else {
  2748. // if (!isSub && !lambdaExpression.ReturnType.IsNull) {
  2749. // outputFormatter.PrintToken(Tokens.As);
  2750. // outputFormatter.Space();
  2751. // TrackedVisit(lambdaExpression.ReturnType, data);
  2752. // }
  2753. //
  2754. // if (lambdaExpression.StatementBody is BlockStatement)
  2755. // outputFormatter.NewLine();
  2756. //
  2757. // TrackedVisit(lambdaExpression.StatementBody, data);
  2758. //
  2759. // if (lambdaExpression.StatementBody is BlockStatement) {
  2760. // outputFormatter.NewLine();
  2761. // outputFormatter.PrintToken(Tokens.End);
  2762. // outputFormatter.Space();
  2763. // if (isSub)
  2764. // outputFormatter.PrintToken(Tokens.Sub);
  2765. // else
  2766. // outputFormatter.PrintToken(Tokens.Function);
  2767. // }
  2768. //
  2769. // return null;
  2770. // }
  2771. // }
  2772. //
  2773. // public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data)
  2774. // {
  2775. // outputFormatter.IndentationLevel++;
  2776. // for (int i = 0; i < queryExpression.Clauses.Count; i++) {
  2777. // QueryExpressionClause clause = queryExpression.Clauses[i];
  2778. // if (!clause.IsNull) {
  2779. // if (i != 0) {
  2780. // outputFormatter.PrintLineContinuation();
  2781. // outputFormatter.Indent();
  2782. // }
  2783. // clause.AcceptVisitor(this, null);
  2784. // }
  2785. // }
  2786. // outputFormatter.IndentationLevel--;
  2787. // return null;
  2788. // }
  2789. //
  2790. // void PrintClause(QueryExpressionClause clause)
  2791. // {
  2792. //
  2793. // }
  2794. //
  2795. // public override object TrackedVisitQueryExpressionFromClause(QueryExpressionFromClause fromClause, object data)
  2796. // {
  2797. // outputFormatter.PrintText("From");
  2798. // outputFormatter.Space();
  2799. // for (int i = 0; i < fromClause.Sources.Count; i++) {
  2800. // CollectionRangeVariable clause = fromClause.Sources[i];
  2801. // outputFormatter.PrintIdentifier(clause.Identifier);
  2802. // outputFormatter.Space();
  2803. // outputFormatter.PrintToken(Tokens.In);
  2804. // outputFormatter.Space();
  2805. // clause.Expression.AcceptVisitor(this, data);
  2806. // if (i < fromClause.Sources.Count - 1)
  2807. // outputFormatter.PrintToken(Tokens.Comma);
  2808. // }
  2809. // return null;
  2810. // }
  2811. //
  2812. // public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause joinClause, object data)
  2813. // {
  2814. // outputFormatter.PrintText("Join");
  2815. // outputFormatter.Space();
  2816. // CollectionRangeVariable clause = joinClause.Source;
  2817. // outputFormatter.PrintIdentifier(clause.Identifier);
  2818. // outputFormatter.Space();
  2819. // outputFormatter.PrintToken(Tokens.In);
  2820. // outputFormatter.Space();
  2821. // clause.Expression.AcceptVisitor(this, data);
  2822. // outputFormatter.Space();
  2823. // outputFormatter.PrintToken(Tokens.On);
  2824. // outputFormatter.Space();
  2825. // joinClause.OnExpression.AcceptVisitor(this, data);
  2826. // outputFormatter.Space();
  2827. // outputFormatter.PrintToken(Tokens.Assign);
  2828. // outputFormatter.Space();
  2829. // joinClause.EqualsExpression.AcceptVisitor(this, data);
  2830. // if (!string.IsNullOrEmpty(joinClause.IntoIdentifier)) {
  2831. // outputFormatter.Space();
  2832. // outputFormatter.PrintText("Into");
  2833. // outputFormatter.Space();
  2834. // outputFormatter.PrintIdentifier(joinClause.IntoIdentifier);
  2835. // }
  2836. // return null;
  2837. // }
  2838. //
  2839. //// void VisitQueryExpressionFromOrJoinClause(QueryExpressionFromOrJoinClause clause, object data)
  2840. //// {
  2841. //// outputFormatter.PrintIdentifier(clause.Identifier);
  2842. //// outputFormatter.Space();
  2843. //// outputFormatter.PrintToken(Tokens.In);
  2844. //// outputFormatter.Space();
  2845. //// clause.InExpression.AcceptVisitor(this, data);
  2846. //// }
  2847. //
  2848. // public override object TrackedVisitQueryExpressionLetClause(QueryExpressionLetClause letClause, object data)
  2849. // {
  2850. // outputFormatter.PrintToken(Tokens.Let);
  2851. // outputFormatter.Space();
  2852. // outputFormatter.PrintIdentifier(letClause.Identifier);
  2853. // outputFormatter.Space();
  2854. // outputFormatter.PrintToken(Tokens.Assign);
  2855. // outputFormatter.Space();
  2856. // return letClause.Expression.AcceptVisitor(this, data);
  2857. // }
  2858. //
  2859. // public override object TrackedVisitQueryExpressionGroupClause(QueryExpressionGroupClause groupClause, object data)
  2860. // {
  2861. // outputFormatter.PrintText("Group");
  2862. // outputFormatter.Space();
  2863. // groupClause.Projection.AcceptVisitor(this, data);
  2864. // outputFormatter.Space();
  2865. // outputFormatter.PrintText("By");
  2866. // outputFormatter.Space();
  2867. // return groupClause.GroupBy.AcceptVisitor(this, data);
  2868. // }
  2869. //
  2870. // public override object TrackedVisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data)
  2871. // {
  2872. // outputFormatter.PrintText("Order By");
  2873. // outputFormatter.Space();
  2874. // AppendCommaSeparatedList(queryExpressionOrderClause.Orderings);
  2875. // return null;
  2876. // }
  2877. //
  2878. // public override object TrackedVisitQueryExpressionOrdering(QueryExpressionOrdering ordering, object data)
  2879. // {
  2880. // ordering.Criteria.AcceptVisitor(this, data);
  2881. // if (ordering.Direction == QueryExpressionOrderingDirection.Ascending) {
  2882. // outputFormatter.Space();
  2883. // outputFormatter.PrintText("Ascending");
  2884. // } else if (ordering.Direction == QueryExpressionOrderingDirection.Descending) {
  2885. // outputFormatter.Space();
  2886. // outputFormatter.PrintText("Descending");
  2887. // }
  2888. // return null;
  2889. // }
  2890. //
  2891. // public override object TrackedVisitQueryExpressionSelectVBClause(QueryExpressionSelectVBClause selectClause, object data)
  2892. // {
  2893. // outputFormatter.PrintToken(Tokens.Select);
  2894. // outputFormatter.Space();
  2895. // foreach (ExpressionRangeVariable var in selectClause.Variables) {
  2896. // var.AcceptVisitor(this, data);
  2897. // }
  2898. // return null;
  2899. // }
  2900. //
  2901. // public override object TrackedVisitQueryExpressionWhereClause(QueryExpressionWhereClause whereClause, object data)
  2902. // {
  2903. // outputFormatter.Space();
  2904. // outputFormatter.PrintText("Where");
  2905. // outputFormatter.Space();
  2906. // return whereClause.Condition.AcceptVisitor(this, data);
  2907. // }
  2908. //
  2909. // public override object TrackedVisitExternAliasDirective(ExternAliasDirective externAliasDirective, object data)
  2910. // {
  2911. // UnsupportedNode(externAliasDirective);
  2912. // return null;
  2913. // }
  2914. //
  2915. // public override object TrackedVisitXmlContentExpression(XmlContentExpression xmlContentExpression, object data)
  2916. // {
  2917. // switch (xmlContentExpression.Type) {
  2918. // case XmlContentType.Comment:
  2919. // outputFormatter.PrintText("<!--" + xmlContentExpression.Content + "-->");
  2920. // break;
  2921. // case XmlContentType.Text:
  2922. // outputFormatter.PrintText(xmlContentExpression.Content);
  2923. // break;
  2924. // case XmlContentType.CData:
  2925. // outputFormatter.PrintText("<![CDATA[" + xmlContentExpression.Content + "]]>");
  2926. // break;
  2927. // case XmlContentType.ProcessingInstruction:
  2928. // outputFormatter.PrintText("<?" + xmlContentExpression.Content + "?>");
  2929. // break;
  2930. // default:
  2931. // throw new Exception("Invalid value for XmlContentType");
  2932. // }
  2933. // return null;
  2934. // }
  2935. //
  2936. // public override object TrackedVisitXmlEmbeddedExpression(XmlEmbeddedExpression xmlEmbeddedExpression, object data)
  2937. // {
  2938. // outputFormatter.PrintText("<%=");
  2939. // outputFormatter.Space();
  2940. // xmlEmbeddedExpression.InlineVBExpression.AcceptVisitor(this, data);
  2941. // outputFormatter.Space();
  2942. // outputFormatter.PrintText("%>");
  2943. // return null;
  2944. // }
  2945. //
  2946. // public override object TrackedVisitXmlAttributeExpression(XmlAttributeExpression xmlAttributeExpression, object data)
  2947. // {
  2948. // outputFormatter.PrintText(xmlAttributeExpression.Name);
  2949. // outputFormatter.PrintToken(Tokens.Assign);
  2950. // if (xmlAttributeExpression.IsLiteralValue) {
  2951. // if (xmlAttributeExpression.UseDoubleQuotes)
  2952. // outputFormatter.PrintText("\"");
  2953. // else
  2954. // outputFormatter.PrintText("'");
  2955. // outputFormatter.PrintText(xmlAttributeExpression.LiteralValue);
  2956. // if (xmlAttributeExpression.UseDoubleQuotes)
  2957. // outputFormatter.PrintText("\"");
  2958. // else
  2959. // outputFormatter.PrintText("'");
  2960. // } else
  2961. // xmlAttributeExpression.ExpressionValue.AcceptVisitor(this, data);
  2962. // return null;
  2963. // }
  2964. //
  2965. // public override object TrackedVisitXmlElementExpression(XmlElementExpression xmlElementExpression, object data)
  2966. // {
  2967. // outputFormatter.PrintText("<");
  2968. // if (xmlElementExpression.NameIsExpression) {
  2969. // outputFormatter.PrintToken(Tokens.XmlStartInlineVB);
  2970. // outputFormatter.Space();
  2971. // xmlElementExpression.NameExpression.AcceptVisitor(this, data);
  2972. // outputFormatter.Space();
  2973. // outputFormatter.PrintToken(Tokens.XmlEndInlineVB);
  2974. // } else {
  2975. // outputFormatter.PrintText(xmlElementExpression.XmlName);
  2976. // }
  2977. // foreach (XmlExpression attribute in xmlElementExpression.Attributes) {
  2978. // outputFormatter.Space();
  2979. // attribute.AcceptVisitor(this, data);
  2980. // }
  2981. // if (xmlElementExpression.Children.Any()) {
  2982. // outputFormatter.PrintText(">");
  2983. // foreach (INode node in xmlElementExpression.Children) {
  2984. // node.AcceptVisitor(this, data);
  2985. // }
  2986. // outputFormatter.PrintText("</");
  2987. // if (!xmlElementExpression.NameIsExpression)
  2988. // outputFormatter.PrintText(xmlElementExpression.XmlName);
  2989. // outputFormatter.PrintText(">");
  2990. // } else {
  2991. // outputFormatter.Space();
  2992. // outputFormatter.PrintText("/>");
  2993. // }
  2994. // return null;
  2995. // }
  2996. //
  2997. // public override object TrackedVisitXmlMemberAccessExpression(XmlMemberAccessExpression xmlMemberAccessExpression, object data)
  2998. // {
  2999. // xmlMemberAccessExpression.TargetObject.AcceptVisitor(this, data);
  3000. // switch (xmlMemberAccessExpression.AxisType) {
  3001. // case XmlAxisType.Element:
  3002. // outputFormatter.PrintToken(Tokens.Dot);
  3003. // break;
  3004. // case XmlAxisType.Attribute:
  3005. // outputFormatter.PrintToken(Tokens.DotAt);
  3006. // break;
  3007. // case XmlAxisType.Descendents:
  3008. // outputFormatter.PrintToken(Tokens.TripleDot);
  3009. // break;
  3010. // default:
  3011. // throw new Exception("Invalid value for XmlAxisType");
  3012. // }
  3013. // if (xmlMemberAccessExpression.IsXmlIdentifier)
  3014. // outputFormatter.PrintText("<" + xmlMemberAccessExpression.Identifier + ">");
  3015. // else
  3016. // outputFormatter.PrintIdentifier(xmlMemberAccessExpression.Identifier);
  3017. // return null;
  3018. // }
  3019. // }
  3020. }