diff options
| author | Emmanuel Hansen <emmausssss@gmail.com> | 2024-08-31 14:39:26 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-31 11:39:26 -0300 |
| commit | 2c5c0392f9ff80a3907bbf376a13f797ebbc12cc (patch) | |
| tree | 66eac1cb8ec09aae5196520cad19ab8ee6aba241 /src/Ryujinx.HLE.Generators/CodeGenerator.cs | |
| parent | e0acde04bb032fd056904b909b3fd00c1a6fb996 (diff) | |
Make HLE project AOT friendly (#7085)
* add hle service generator
remove usage of reflection in device state
* remove rd.xml generation
* make applet manager reflection free
* fix typos
* fix encoding
* fix style report
* remove rogue generator reference
* remove double assignment
Diffstat (limited to 'src/Ryujinx.HLE.Generators/CodeGenerator.cs')
| -rw-r--r-- | src/Ryujinx.HLE.Generators/CodeGenerator.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE.Generators/CodeGenerator.cs b/src/Ryujinx.HLE.Generators/CodeGenerator.cs new file mode 100644 index 00000000..7e4848ad --- /dev/null +++ b/src/Ryujinx.HLE.Generators/CodeGenerator.cs @@ -0,0 +1,63 @@ +using System.Text; + +namespace Ryujinx.HLE.Generators +{ + class CodeGenerator + { + private const int IndentLength = 4; + + private readonly StringBuilder _sb; + private int _currentIndentCount; + + public CodeGenerator() + { + _sb = new StringBuilder(); + } + + public void EnterScope(string header = null) + { + if (header != null) + { + AppendLine(header); + } + + AppendLine("{"); + IncreaseIndentation(); + } + + public void LeaveScope(string suffix = "") + { + DecreaseIndentation(); + AppendLine($"}}{suffix}"); + } + + public void IncreaseIndentation() + { + _currentIndentCount++; + } + + public void DecreaseIndentation() + { + if (_currentIndentCount - 1 >= 0) + { + _currentIndentCount--; + } + } + + public void AppendLine() + { + _sb.AppendLine(); + } + + public void AppendLine(string text) + { + _sb.Append(' ', IndentLength * _currentIndentCount); + _sb.AppendLine(text); + } + + public override string ToString() + { + return _sb.ToString(); + } + } +} |
