Skip to content

Commit

Permalink
refactor: move QuantumParser out of View
Browse files Browse the repository at this point in the history
  • Loading branch information
linderd committed Feb 21, 2024
1 parent 002bc25 commit 4ebc28d
Show file tree
Hide file tree
Showing 33 changed files with 39 additions and 47 deletions.
2 changes: 1 addition & 1 deletion QuIDE/CodeHelpers/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Text;
using QuIDE.QuantumModel;
using QuIDE.QuantumModel.Gates;
using QuIDE.ViewModels.MainModels.QuantumParser;
using QuIDE.QuantumParser;

#endregion

Expand Down
1 change: 0 additions & 1 deletion QuIDE/QuIDE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<ItemGroup>
<Folder Include="Models"/>
<AvaloniaResource Include="Assets\**"/>
<Folder Include="ViewModels\MainModels\QuantumModel\Gates\" />
<None Remove="Assets\Images\CopyHS.png"/>
<AvaloniaResource Include="Assets\Images\CopyHS.png"/>
<None Remove="Assets\Images\CutHS.png"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
public class CircuitEvaluator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
interface IQuantumComputer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
interface IRegister
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
public class MethodCode
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class AddExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class AddModuloExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class AddModuloQFTExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class AddQFTExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class ControlledUGateExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
// Quantum networks for elementary arithmetic operations
// Vlatko Vedral, Adriano Barenco, and Artur Ekert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class GatesExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class LoadNumberExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class MultModuloExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class MultModuloQFTExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class QFTExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class ResetExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class SwapExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Operations
namespace QuIDE.QuantumParser.Operations
{
public static class WalshExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ You should have received a copy of the GNU General Public License
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.Loader;
using System.Text;
using System.Text.RegularExpressions;
using QuIDE.ViewModels.MainModels.QuantumParser.Operations;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System.Reflection.Metadata;
using QuIDE.QuantumModel;
using QuIDE.QuantumParser.Operations;

namespace QuIDE.ViewModels.MainModels.QuantumParser;
namespace QuIDE.QuantumParser;

public class KeywordNotAllowedException(string keyword) : Exception(
"Code cannot contain some special keywords. Please remove them. \nForbidden keyword found: " +
Expand Down Expand Up @@ -271,7 +271,7 @@ public static Dictionary<string, List<MethodCode>> GetMethodsCodes(string code)

private static string Preprocess(string code)
{
const string parserLocation = "using QuIDE.ViewModels.MainModels.QuantumParser";
const string parserLocation = "using QuIDE.QuantumParser";

// Delete "using Quantum{.Operations};" with QuantumParser equivalents
var pattern = @"using\s+Quantum\s*;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
public class QuantumComputer : IQuantumComputer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ You should have received a copy of the GNU General Public License
using System.Text;
using QuIDE.QuantumModel;
using QuIDE.QuantumModel.Gates;
using QuIDE.ViewModels.MainModels.QuantumParser.Validation;
using QuIDE.QuantumParser.Validation;

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
public class Register : IRegister
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
public struct RegisterRef
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser
namespace QuIDE.QuantumParser
{
public class StepEvaluator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You should have received a copy of the GNU General Public License

#endregion

namespace QuIDE.ViewModels.MainModels.QuantumParser.Validation
namespace QuIDE.QuantumParser.Validation
{
public static class MatrixValidator
{
Expand Down
2 changes: 1 addition & 1 deletion QuIDE/ViewModels/Controls/OutputGridViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using Avalonia.Interactivity;
using QuIDE.CodeHelpers;
using QuIDE.QuantumModel;
using QuIDE.QuantumParser;
using QuIDE.ViewModels.Helpers;
using QuIDE.ViewModels.MainModels.QuantumParser;

#endregion

Expand Down
4 changes: 2 additions & 2 deletions QuIDE/ViewModels/Controls/PropertiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
using QuIDE.CodeHelpers;
using QuIDE.Properties;
using QuIDE.ViewModels.Helpers;
using QuIDE.ViewModels.MainModels.QuantumParser;
using QuIDE.ViewModels.MainModels.QuantumParser.Validation;
using Quantum.Helpers;
using QuIDE.QuantumModel;
using QuIDE.QuantumModel.Gates;
using QuIDE.QuantumParser;
using QuIDE.QuantumParser.Validation;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion QuIDE/ViewModels/Dialog/MatrixInputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Numerics;
using QuIDE.CodeHelpers;
using QuIDE.Properties;
using QuIDE.ViewModels.MainModels.QuantumParser.Validation;
using QuIDE.QuantumParser.Validation;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion QuIDE/ViewModels/Dialog/ParametricInputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using System.Text;
using QuIDE.QuantumModel;
using QuIDE.QuantumModel.Gates;
using QuIDE.QuantumParser;
using QuIDE.ViewModels.Helpers;
using QuIDE.ViewModels.MainModels.QuantumParser;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion QuIDE/ViewModels/Helpers/GateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
using QuIDE.CodeHelpers;
using QuIDE.QuantumModel;
using QuIDE.QuantumModel.Gates;
using QuIDE.QuantumParser;
using QuIDE.ViewModels.Controls;
using QuIDE.ViewModels.Dialog;
using QuIDE.ViewModels.MainModels.QuantumParser;
using QuIDE.Views.Dialog;

#endregion
Expand Down
2 changes: 1 addition & 1 deletion QuIDE/ViewModels/Helpers/ParameterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.ComponentModel;
using System.Text;
using QuIDE.QuantumModel;
using QuIDE.ViewModels.MainModels.QuantumParser;
using QuIDE.QuantumParser;

#endregion

Expand Down
13 changes: 3 additions & 10 deletions QuIDE/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#region

using System;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Avalonia.Controls;
using QuIDE.CodeHelpers;
using QuIDE.ViewModels.Controls;
using QuIDE.ViewModels.Dialog;
using QuIDE.ViewModels.MainModels.QuantumParser;
using QuIDE.Views;
using QuIDE.Views.Dialog;
using CommunityToolkit.Mvvm.Input;
using QuIDE.QuantumModel;

#endregion
using QuIDE.QuantumParser;
using Parser = QuIDE.QuantumParser.Parser;

namespace QuIDE.ViewModels;

Expand Down Expand Up @@ -392,8 +389,6 @@ public ICommand RunCommand
#endregion // Commands


#region Public Methods

public static void CompositeSelected()
{
SelectedAction = ActionName.Composite;
Expand Down Expand Up @@ -654,8 +649,6 @@ private async void ShowAbout(object o)
await new AboutWindow().ShowDialog(_window);
}

#endregion // Public Methods


#region Private Helpers

Expand Down

0 comments on commit 4ebc28d

Please sign in to comment.