Пример #1
0
        protected override void GenerateInner(CodeGenerator generator, string name, CodeBasicPropertyMember property, CodeCompositeTypeDeclaration enclosingType)
        {
            generator.Write(TokenType.Keyword, name);

            generator.EnterLocalScope();

            generator.IsInSetterProperty = name == "set";
            if (generator.IsInSetterProperty)
            {
                generator.ReserveLocal("value");
            }
            if (property is CodeIndexerMember indexer)
            {
                foreach (var parameter in indexer.Parameters)
                {
                    generator.ReserveLocal(parameter.Name);
                }
            }

            generator.ExitLocalScope();

            if (Statements.Count == 1 && Statements[0] is CodeReturnStatement returnStatement && returnStatement.Expression != null)
            {
                generator.Write(TokenType.Space, ' ');
                generator.Write(TokenType.Operator, "=>");
                generator.Write(TokenType.Space, ' ');
                returnStatement.Expression.Generate(generator);
                generator.WriteLine(TokenType.Punctuation, ";");
            }
Пример #2
0
        public void Generate(CodeGenerator generator, string name, CodeBasicPropertyMember property, CodeCompositeTypeDeclaration enclosingType)
        {
            generator.EnterElement(this);

            StartDirectives.Generate(generator);
            Comments.Generate(generator);
            Modifiers.Generate(generator);
            GenerateInner(generator, name, property, enclosingType);
            EndDirectives.Generate(generator);

            generator.ExitElement();
        }
Пример #3
0
 protected abstract void GenerateInner(CodeGenerator generator, string name, CodeBasicPropertyMember property, CodeCompositeTypeDeclaration enclosingType);