Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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(";");
            }
        }
Ejemplo n.º 3
0
        private void CreateDefaultConstructor(TypeDeclaration typeDeclaration)
        {
            IType type = typeDeclaration.Annotation <TypeResolveResult>().Type;

            Formatter.AppendIndented(String.Empty);
            TypeVisitor.FormatTypeDelaration(type);
            Formatter.Append("(){};");
        }
Ejemplo n.º 4
0
 /// <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(";");
 }
Ejemplo n.º 5
0
        /// <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(";");
        }
Ejemplo n.º 6
0
        private void OutputEntityType(TypeDeclaration typeDeclaration)
        {
            switch (typeDeclaration.ClassType)
            {
            case ClassType.Interface:
                Formatter.AppendIndented("class ");
                break;

            case ClassType.Struct:
                Formatter.AppendIndented("struct ");
                break;

            default:
                Formatter.AppendIndented("class ");
                break;
            }
        }
Ejemplo n.º 7
0
        /// <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(";");
        }
Ejemplo n.º 8
0
        /// <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;
            }
        }