diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-17 20:49:22 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-17 20:49:22 +1000 |
| commit | 18868128e18d38b706e7df14e8e683e1a9739c17 (patch) | |
| tree | 6f0e0e5eee646f10cbad9c0c89c24d330bc58cc6 /Compiler/Optimizer.cs | |
| parent | d87ab8af4c86a3fc6ee237444e372d87e536e3ef (diff) | |
chore: Initial commit
Diffstat (limited to 'Compiler/Optimizer.cs')
| -rw-r--r-- | Compiler/Optimizer.cs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/Compiler/Optimizer.cs b/Compiler/Optimizer.cs deleted file mode 100644 index 4646c1c..0000000 --- a/Compiler/Optimizer.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Q1.Compiler; - -using System.Text.RegularExpressions; - -public class Optimizer -{ - private string _instructions; - private int _currentIndex = 0; - - public Optimizer(List<string> instructions) - { - this._instructions = string.Join(Environment.NewLine, instructions); - } - - public string Optimize() - { - string output = this._instructions; - output = this.RemoveRedundantFallbackReturns(output); - - return output; - } - - private string RemoveRedundantFallbackReturns(string input) - { - string pattern = @"(mov .*, V0\n\s*ret\n)\s*mov 0, V0\n\s*ret"; - return Regex.Replace(input, pattern, "$1"); - } -}
\ No newline at end of file |
