Append() public method

public Append ( string codeText ) : void
codeText string
return void
コード例 #1
0
        private static void ToCode(this CSharp.Class @class, CsBuilder builder)
        {
            builder.StartClass(@class.AccessModifiers, @class.ClassModifiers, @class.Keyword, @class.Name);

            foreach (var field in @class.Fields)
            {
                builder.StartField(field.AccessModifiers, field.FieldModifiers, field.TypeName, field.Name);

                var initExpr = field.InitExpression;
                if (!String.IsNullOrEmpty(initExpr))
                {
                    builder.Append(initExpr);
                }
            }

            foreach (var property in @class.Properties)
            {
                builder.Property(property.AccessModifiers, property.TypeName, property.Name);
            }

            foreach (var method in @class.Methods)
            {
                var parameters = method.Parameters
                                 .Select(p => (name: p.Name, type: p.TypeName))
                                 .ToArray();
                builder.WriteIndent();
                builder.StartMethod(method.AccessModifiers, method.MethodModifiers, method.TypeName, method.Name, parameters);
                builder.WriteIndent();
                builder.AppendLine(method.GetBody(0).ToString());
                builder.EndScope();
            }

            foreach (var @enum in @class.Enums)
            {
                builder.StartEnum(@enum.AccessModifiers, @enum.Name, @enum.BaseTypeName);

                foreach (var option in @enum.Options)
                {
                    builder.WriteIndent();
                    builder.Append($"{option.Name}");
                    if (!String.IsNullOrEmpty(option.Value))
                    {
                        builder.Append($" = {option.Value}");
                    }
                    builder.AppendLine(",");
                }

                builder.EndScope();
            }

            foreach (var nested in @class.Classes)
            {
                nested.ToCode(builder);
            }

            builder.EndScope();
        }
コード例 #2
0
 public override void VisitLiteralBoolean(AstLiteralBoolean literalBool)
 {
     _builder.Append(literalBool.Value ? "true" : "false");
 }
コード例 #3
0
            public override void Build(CsBuilder builder, AstFunctionDefinition functionDef)
            {
                var conversion = "Conversion";

                builder.Append($"Zsharp.Runtime.{conversion}.{functionDef.Identifier.SymbolName.CanonicalName.FullName}");
            }