protected static string GetString(Action <IndentedStreamWriter> action) { using Stream stream = GetStream(); using IndentedStreamWriter indentedWriter = new IndentedStreamWriter(stream); action(indentedWriter); return(GetString(stream)); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.Write("Return"); if (Source != null) wtr.Write(" {0} {1}", SourceType, Source); wtr.WriteLine(); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.Write("CallIndirect [{0}]({1})", TargetMethod, String.Join(", ", Sources)); if (ReturnValueDestination != null) wtr.Write(" -> {0}", ReturnValueDestination); wtr.WriteLine(); }
/// <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); }
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 { })
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(); }
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); }
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); }
/// <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;
public NamespaceWriter(IndentedStreamWriter writer, string?nameSpace) : base(writer) => Namespace = nameSpace;
public ForLoopBodyWriter(IndentedStreamWriter writer, ForLoop forLoop) : base(writer) => _forLoop = forLoop;
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("Move {0} {1} -> {2}", ArgumentType, Source, Destination); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("Math {0} {1} {2} {3} -> {4}", ArgumentType, SourceA, GetOperationSymbol(Operation), SourceB, Destination); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("DEAD"); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("Branch -> {0}", Target); }
public MethodWriter(IndentedStreamWriter writer, IEnumerable <Method> methods) : this(writer) => _methods.AddRange(methods);
/// <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;
public MethodWriter(IndentedStreamWriter writer) : base(writer) { }
/// <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;
public ForEachLoopHeadWriter(IndentedStreamWriter writer, ForEachLoop forEachLoop) : base(writer) => _forEachLoop = forEachLoop;
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("Compare {0} {1} {2} -> {3}", SourceA, GetConditionSymbol(Condition), SourceB, Destination); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("BranchTrue {0} -> {1}", Source, Target); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("BranchIndirect [{0}]", Source); }
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("// {0}", Text); }
public MethodAttributeWriter(IndentedStreamWriter writer, Method method) : base(writer) => _method = method;
/// <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;
/// <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;
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("Convert {0} {1} -> {2} {3}", SourceType, Source, DestinationType, Destination); }
/// <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;
public MethodModifierWriter(IndentedStreamWriter writer, Method method) : base(writer) => _method = method;
internal override void Dump(IndentedStreamWriter wtr) { wtr.WriteLine("Unary {0} {1}{2} -> {3}", ArgumentType, GetOperationSymbol(Operation), Source, Destination); }
/// <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;