/// <inheritdoc/> public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { IType type = propertyDeclaration.ReturnType.GetResolveResult().Type; if (propertyDeclaration.Getter != null) { Formatter.AppendIndented(String.Empty); TypeVisitor.FormatTypeDelaration(type); Formatter.Append(" get_"); Formatter.Append(propertyDeclaration.NameToken.Name); Formatter.AppendLine("();"); } if (propertyDeclaration.Setter != null) { Formatter.AppendIndented("void set_"); Formatter.Append(propertyDeclaration.NameToken.Name); Formatter.Append("("); TypeVisitor.FormatTypeDelaration(type); Formatter.AppendLine(" x_value );"); } ICSharpCode.Decompiler.IL.ILFunction inst = propertyDeclaration.Getter.Annotation <ICSharpCode.Decompiler.IL.ILFunction>(); String hiddenName = MyIlVisitor.GetHiddenPropertyName(inst.Body as ICSharpCode.Decompiler.IL.BlockContainer); if (!String.IsNullOrEmpty(hiddenName)) { Formatter.AppendIndented(String.Empty); TypeVisitor.FormatTypeDelaration(type); Formatter.Append(" "); Formatter.Append(hiddenName); Formatter.AppendLine(";"); } }
/// <inheritdoc/> public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration) { IType type = typeDeclaration.Annotation <TypeResolveResult>().Type; Formatter.NameSpace = type.Namespace; switch (typeDeclaration.ClassType) { case ClassType.Enum: Formatter.AppendIndented("enum "); break; case ClassType.Interface: Formatter.AppendIndented("class "); break; case ClassType.Struct: Formatter.AppendIndented("struct "); break; default: Formatter.AppendIndented("class "); break; } TypeVisitor.FormatType(type); if (typeDeclaration.ClassType == ClassType.Enum) { OutputEnumValues(typeDeclaration); } else { Formatter.Append(";"); } Formatter.AppendLine(String.Empty); }
private void CreateDefaultConstructor(TypeDeclaration typeDeclaration) { IType type = typeDeclaration.Annotation <TypeResolveResult>().Type; Formatter.AppendIndented(String.Empty); TypeVisitor.FormatTypeDelaration(type); Formatter.Append("(){};"); }
/// <inheritdoc/> public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { Formatter.AppendIndented("static "); operatorDeclaration.ReturnType.AcceptVisitor(this); Formatter.Append(" "); Formatter.Append(Operators[operatorDeclaration.OperatorType]); WriteCommaSeparatedListInParenthesis(operatorDeclaration.Parameters); Formatter.AppendLine(";"); }
/// <inheritdoc/> public override void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration) { Formatter.AppendIndentedName(enumMemberDeclaration.NameToken.Name); Formatter.Append("_"); Formatter.Append(EnumName); if (!enumMemberDeclaration.Initializer.IsNull) { Formatter.Append(" = "); enumMemberDeclaration.Initializer.AcceptVisitor(this); } }
private void OutputParentage(TypeDeclaration typeDeclaration, IType type) { if (typeDeclaration.BaseTypes.Any()) { Formatter.Append(" : public "); WriteBaseClasses(typeDeclaration.BaseTypes); } else if (type.Kind == TypeKind.Class || type.Kind == TypeKind.Struct) { Formatter.Append(" : public Object"); } }
/// <inheritdoc/> public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration) { Formatter.AppendIndented(String.Empty); WriteModifiers(methodDeclaration.ModifierTokens); IType type = methodDeclaration.ReturnType.GetResolveResult().Type; TypeVisitor.FormatTypeDelaration(type); Formatter.Append(" "); WriteMethodHeader(methodDeclaration.NameToken.Name, methodDeclaration.Parameters); if (methodDeclaration.Body.IsNull) { Formatter.Append(" = 0"); } Formatter.AppendLine(";"); }
/// <summary> /// Add base classes to output /// </summary> /// <param name="nodes">list of classes</param> protected void WriteBaseClasses(IEnumerable <AstNode> nodes) { bool isFirst = true; foreach (AstNode node in nodes) { IType type = node.Annotation <TypeResolveResult>().Type; if (!isFirst) { Formatter.Append(","); } node.AcceptVisitor(this); isFirst = false; } }
/// <summary> /// Output using namespaces /// </summary> private void WriteUsingNamespaces() { Formatter.CloseNamespace(); foreach (String ns in namespaces.Values) { Formatter.Append("using namespace "); if (String.IsNullOrEmpty(ns)) { Formatter.Append("UNNAMED"); } else { Formatter.Append(ns + "_NS"); } Formatter.AppendLine(";"); } }
/// <inheritdoc/> public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration) { VariableInitializer variable = fieldDeclaration.Variables.First <VariableInitializer>(); Formatter.AppendIndented(String.Empty); var sym = fieldDeclaration.GetSymbol() as IEntity; if (sym != null && sym.IsStatic) { Formatter.Append("static "); } IType type = fieldDeclaration.ReturnType.GetResolveResult().Type; TypeVisitor.FormatTypeDelaration(type); Formatter.Append(" "); WriteCommaSeparatedList(fieldDeclaration.Variables); Formatter.AppendLine(";"); }
/// <inheritdoc/> public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) { bool isStatic = (constructorDeclaration.Modifiers & Modifiers.Static) != 0; TypeDeclaration type = constructorDeclaration.Parent as TypeDeclaration; String name = null; if (type != null && type.Name != constructorDeclaration.Name) { name = type.NameToken.Name; } else { name = constructorDeclaration.NameToken.Name; } Formatter.AppendIndented(String.Empty); if (!isStatic) { IType type2 = constructorDeclaration.GetResolveResult().Type; WriteMethodHeader(name, constructorDeclaration.Parameters); Formatter.AppendLine(";"); } else { Formatter.Append("static Boolean "); Formatter.AppendName(name); Formatter.AppendLine("_Static();"); Formatter.AppendIndented("static Boolean "); Formatter.AppendName(name); Formatter.AppendLine("_Initilized;"); } HadConstructor = true; if (constructorDeclaration.Parameters.Count == 0) { HadDefaultConstructor = true; } }