mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-26 00:06:02 +00:00
e055217292
* Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Run dotnet format pass * Remove left-over files and adjust namespaces * Fix alignment
58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using System.Text;
|
|
|
|
namespace Ryujinx.Horizon.Kernel.Generators
|
|
{
|
|
class CodeGenerator
|
|
{
|
|
private const string Indent = " ";
|
|
private readonly StringBuilder _sb;
|
|
private string _currentIndent;
|
|
|
|
public CodeGenerator()
|
|
{
|
|
_sb = new StringBuilder();
|
|
}
|
|
|
|
public void EnterScope(string header = null)
|
|
{
|
|
if (header != null)
|
|
{
|
|
AppendLine(header);
|
|
}
|
|
|
|
AppendLine("{");
|
|
IncreaseIndentation();
|
|
}
|
|
|
|
public void LeaveScope()
|
|
{
|
|
DecreaseIndentation();
|
|
AppendLine("}");
|
|
}
|
|
|
|
public void IncreaseIndentation()
|
|
{
|
|
_currentIndent += Indent;
|
|
}
|
|
|
|
public void DecreaseIndentation()
|
|
{
|
|
_currentIndent = _currentIndent.Substring(0, _currentIndent.Length - Indent.Length);
|
|
}
|
|
|
|
public void AppendLine()
|
|
{
|
|
_sb.AppendLine();
|
|
}
|
|
|
|
public void AppendLine(string text)
|
|
{
|
|
_sb.AppendLine(_currentIndent + text);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return _sb.ToString();
|
|
}
|
|
}
|
|
}
|