Exemplo n.º 1
0
 protected static string GetString(Action <IndentedStreamWriter> action)
 {
     using Stream stream = GetStream();
     using IndentedStreamWriter indentedWriter = new IndentedStreamWriter(stream);
     action(indentedWriter);
     return(GetString(stream));
 }
Exemplo n.º 2
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.Write("Return");
			if (Source != null)
				wtr.Write(" {0} {1}", SourceType, Source);
			wtr.WriteLine();
		}
Exemplo n.º 3
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.Write("CallIndirect [{0}]({1})", TargetMethod, String.Join(", ", Sources));
			if (ReturnValueDestination != null)
				wtr.Write(" -> {0}", ReturnValueDestination);
			wtr.WriteLine();
		}
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="class"><see cref="CSharpClass"/> to generate</param>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 public ClassGenerator(CSharpClass @class, IndentedStreamWriter writer) : base(writer)
 {
     _class                    = @class;
     _usingGenerator           = new UsingGenerator(_class.Usings, writer);
     _namespaceGenerator       = new NamespaceGenerator(_class.Namespace, writer);
     _classDefinitionGenerator = new ClassDefinitionGenerator(_class, writer);
 }
Exemplo n.º 5
0
        public static void Write(SwitchCaseExpression switchCaseExpression, IndentedStreamWriter writer)
        {
            writer.WriteLine($"({switchCaseExpression.Expression}) switch");
            writer.OpenBrackets();

            foreach (CaseExpression @case in switchCaseExpression.CaseExpressions)
            {
                writer.WriteLine($"{@case.Case} => {@case.Body},");
            }

            if (switchCaseExpression.DefaultCaseBody is { })
Exemplo n.º 6
0
        public static void Write(ForEachLoop forEachLoop, IndentedStreamWriter writer)
        {
            var forEachLoopHeadWriter = new ForEachLoopHeadWriter(writer, forEachLoop);

            forEachLoopHeadWriter.Make();

            writer.OpenBrackets();

            var forEachLoopBodyWriter = new ForEachLoopBodyWriter(writer, forEachLoop);

            forEachLoopBodyWriter.Make();

            writer.CloseBrackets();
        }
Exemplo n.º 7
0
        public static async Task WriteAsync(ForEachLoop forEachLoop, IndentedStreamWriter writer)
        {
            await writer.WriteLineAsync($"foreach ({forEachLoop.Item} in {forEachLoop.Collection})");

            await writer.WriteLineAsync("{").ConfigureAwait(false);

            writer.IndentationLevel++;

            var bodyWriter = new BodyWriter(writer);

            forEachLoop.Body(bodyWriter);

            writer.IndentationLevel--;
            await writer.WriteLineAsync("}").ConfigureAwait(false);
        }
Exemplo n.º 8
0
        public static async Task WriteAsync(ForLoop forLoop, IndentedStreamWriter writer)
        {
            await writer.WriteLineAsync($"for ({forLoop.Initializer}; {forLoop.Condition}; {forLoop.Iterator})").ConfigureAwait(false);

            await writer.WriteLineAsync("{").ConfigureAwait(false);

            writer.IndentationLevel++;

            var bodyWriter = new BodyWriter(writer);

            forLoop.Body(bodyWriter);

            writer.IndentationLevel--;
            await writer.WriteLineAsync("}").ConfigureAwait(false);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NamespaceGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="namespace">namespace to generate</param>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 public NamespaceGenerator(string? @namespace, IndentedStreamWriter writer) : base(writer) => _namespace = @namespace;
Exemplo n.º 10
0
 public NamespaceWriter(IndentedStreamWriter writer, string?nameSpace) : base(writer) => Namespace = nameSpace;
Exemplo n.º 11
0
 public ForLoopBodyWriter(IndentedStreamWriter writer, ForLoop forLoop) : base(writer) => _forLoop = forLoop;
Exemplo n.º 12
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("Move {0} {1} -> {2}", ArgumentType, Source, Destination);
		}
Exemplo n.º 13
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("Math {0} {1} {2} {3} -> {4}", ArgumentType, SourceA, GetOperationSymbol(Operation), SourceB, Destination);
		}
Exemplo n.º 14
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("DEAD");
		}
Exemplo n.º 15
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("Branch -> {0}", Target);
		}
Exemplo n.º 16
0
 public MethodWriter(IndentedStreamWriter writer, IEnumerable <Method> methods) : this(writer) => _methods.AddRange(methods);
Exemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="field">Field to generate</param>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 public FieldGenerator(CSharpField field, IndentedStreamWriter writer) : base(writer) => _field = field;
Exemplo n.º 18
0
 public MethodWriter(IndentedStreamWriter writer) : base(writer)
 {
 }
Exemplo n.º 19
0
 /// <summary>
 /// Creates a new instance of a <see cref="BodyGenerator"/> operating on a <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write</param>
 public BodyGenerator(IndentedStreamWriter writer) => _writer = writer;
Exemplo n.º 20
0
 public ForEachLoopHeadWriter(IndentedStreamWriter writer, ForEachLoop forEachLoop) : base(writer) => _forEachLoop = forEachLoop;
Exemplo n.º 21
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("Compare {0} {1} {2} -> {3}", SourceA, GetConditionSymbol(Condition), SourceB, Destination);
		}
Exemplo n.º 22
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("BranchTrue {0} -> {1}", Source, Target);
		}
Exemplo n.º 23
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("BranchIndirect [{0}]", Source);
		}
Exemplo n.º 24
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("// {0}", Text);
		}
Exemplo n.º 25
0
 public MethodAttributeWriter(IndentedStreamWriter writer, Method method) : base(writer) => _method = method;
Exemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="property">Property to generate</param>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 public PropertyGenerator(CSharpProperty property, IndentedStreamWriter writer) : base(writer) => _property = property;
Exemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassDefinitionGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="class"><see cref="CSharpClass"/> to generate definition for</param>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 public ClassDefinitionGenerator(CSharpClass @class, IndentedStreamWriter writer) : base(writer) => _class = @class;
Exemplo n.º 28
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("Convert {0} {1} -> {2} {3}", SourceType, Source, DestinationType, Destination);
		}
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 protected BaseGenerator(IndentedStreamWriter writer) => _writer = writer;
Exemplo n.º 30
0
 public MethodModifierWriter(IndentedStreamWriter writer, Method method) : base(writer) => _method = method;
Exemplo n.º 31
0
		internal override void Dump(IndentedStreamWriter wtr)
		{
			wtr.WriteLine("Unary {0} {1}{2} -> {3}", ArgumentType, GetOperationSymbol(Operation), Source, Destination);
		}
Exemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UsingGenerator"/> class for the specified <see cref="IndentedStreamWriter"/>
 /// </summary>
 /// <param name="usings">usings to generate</param>
 /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param>
 public UsingGenerator(ImmutableArray <string> usings, IndentedStreamWriter writer) : base(writer) => _usings = usings;